diff --git a/app/lib/cli.ts b/app/lib/cli.ts index 66290f70..36c7b3a3 100644 --- a/app/lib/cli.ts +++ b/app/lib/cli.ts @@ -5,7 +5,7 @@ export function parseArgs (argv: string[], cwd: string): any { argv = argv.slice(1) } - return require('yargs') + return require('yargs/yargs')(argv.slice(1)) .usage('terminus [command] [arguments]') .command('open [directory]', 'open a shell in a directory', { directory: { type: 'string', 'default': cwd }, @@ -41,5 +41,5 @@ export function parseArgs (argv: string[], cwd: string): any { type: 'boolean', }) .help('help') - .parse(argv.slice(1)) + .parse() } diff --git a/app/webpack.main.config.js b/app/webpack.main.config.js index d4f09f06..7b171681 100644 --- a/app/webpack.main.config.js +++ b/app/webpack.main.config.js @@ -42,7 +42,6 @@ module.exports = { mz: 'commonjs mz', npm: 'commonjs npm', path: 'commonjs path', - yargs: 'commonjs yargs', util: 'commonjs util', 'source-map-support': 'commonjs source-map-support', 'windows-swca': 'commonjs windows-swca', @@ -54,4 +53,6 @@ module.exports = { 'process.type': '"main"', }), ], + // Ignore warnings due to yarg's dynamic module loading + ignoreWarnings: [/node_modules\/yargs/], } diff --git a/terminus-serial/src/components/serialTab.component.ts b/terminus-serial/src/components/serialTab.component.ts index c30408e5..8365fcdc 100644 --- a/terminus-serial/src/components/serialTab.component.ts +++ b/terminus-serial/src/components/serialTab.component.ts @@ -52,7 +52,7 @@ export class SerialTabComponent extends BaseTerminalTabComponent { super.ngOnInit() setImmediate(() => { - this.setTitle(this.connection.name) + this.setTitle(this.connection!.name) }) } @@ -65,7 +65,7 @@ export class SerialTabComponent extends BaseTerminalTabComponent { this.session = this.injector.get(SerialService).createSession(this.connection) this.session.serviceMessage$.subscribe(msg => { this.write(`\r\n${colors.black.bgWhite(' serial ')} ${msg}\r\n`) - this.session.resize(this.size.columns, this.size.rows) + this.session?.resize(this.size.columns, this.size.rows) }) this.attachSessionHandlers() this.write(`Connecting to `) @@ -108,7 +108,7 @@ export class SerialTabComponent extends BaseTerminalTabComponent { name: x.toString(), result: x, }))) this.serialPort.update({ baudRate: rate }) - this.connection.baudrate = rate + this.connection!.baudrate = rate } ngOnDestroy () { diff --git a/terminus-serial/src/services/serial.service.ts b/terminus-serial/src/services/serial.service.ts index f48638f5..eb38f6af 100644 --- a/terminus-serial/src/services/serial.service.ts +++ b/terminus-serial/src/services/serial.service.ts @@ -127,7 +127,7 @@ export class SerialService { (this.app.getParentTab(tab) ?? tab).color = connection.color } setTimeout(() => { - this.app.activeTab.emitFocused() + this.app.activeTab?.emitFocused() }) return tab } catch (error) { diff --git a/terminus-ssh/src/api.ts b/terminus-ssh/src/api.ts index d9cf4645..fd2f3ca2 100644 --- a/terminus-ssh/src/api.ts +++ b/terminus-ssh/src/api.ts @@ -177,7 +177,7 @@ export class SSHSession extends BaseSession { if (match) { this.logger.info('Executing script: "' + cmd + '"') - this.shell.write(cmd + '\n') + this.shell!.write(cmd + '\n') this.scripts = this.scripts.filter(x => x !== script) } else { if (script.optional) { @@ -380,7 +380,7 @@ export class SSHSession extends BaseSession { for (const script of this.scripts) { if (!script.expect) { console.log('Executing script:', script.send) - this.shell.write(script.send + '\n') + this.shell!.write(script.send + '\n') this.scripts = this.scripts.filter(x => x !== script) } else { break diff --git a/terminus-ssh/src/components/sshTab.component.ts b/terminus-ssh/src/components/sshTab.component.ts index c6a887a8..70e86fe7 100644 --- a/terminus-ssh/src/components/sshTab.component.ts +++ b/terminus-ssh/src/components/sshTab.component.ts @@ -33,6 +33,10 @@ export class SSHTabComponent extends BaseTerminalTabComponent { } ngOnInit (): void { + if (!this.connection) { + throw new Error('Connection not set') + } + this.logger = this.log.create('terminalTab') this.enableDynamicTitle = !this.connection.disableDynamicTitle @@ -58,7 +62,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent { super.ngOnInit() setImmediate(() => { - this.setTitle(this.connection.name) + this.setTitle(this.connection!.name) }) } @@ -150,7 +154,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent { showPortForwarding (): void { const modal = this.ngbModal.open(SSHPortForwardingModalComponent).componentInstance as SSHPortForwardingModalComponent - modal.session = this.session + modal.session = this.session! } async reconnect (): Promise { @@ -163,14 +167,14 @@ export class SSHTabComponent extends BaseTerminalTabComponent { if (!this.session?.open) { return true } - if (!(this.connection.warnOnClose ?? this.config.store.ssh.warnOnClose)) { + if (!(this.connection?.warnOnClose ?? this.config.store.ssh.warnOnClose)) { return true } return (await this.electron.showMessageBox( this.hostApp.getWindow(), { type: 'warning', - message: `Disconnect from ${this.connection.host}?`, + message: `Disconnect from ${this.connection?.host}?`, buttons: ['Cancel', 'Disconnect'], defaultId: 1, } diff --git a/terminus-ssh/src/winSCPIntegration.ts b/terminus-ssh/src/winSCPIntegration.ts index 741e626f..006f4ab1 100644 --- a/terminus-ssh/src/winSCPIntegration.ts +++ b/terminus-ssh/src/winSCPIntegration.ts @@ -44,14 +44,14 @@ export class WinSCPContextMenu extends TabContextMenuItemProvider { if (!this.getPath()) { return [] } - if (!(tab instanceof SSHTabComponent)) { + if (!(tab instanceof SSHTabComponent) || !tab.connection) { return [] } return [ { label: 'Launch WinSCP', click: (): void => { - this.launchWinSCP(tab.connection) + this.launchWinSCP(tab.connection!) }, }, ] diff --git a/terminus-terminal/src/index.ts b/terminus-terminal/src/index.ts index a5bc3e28..d2b9e6a7 100644 --- a/terminus-terminal/src/index.ts +++ b/terminus-terminal/src/index.ts @@ -171,7 +171,7 @@ export default class TerminalModule { // eslint-disable-line @typescript-eslint/ argv = argv.slice(1) } - if (require('yargs').parse(argv.slice(1))._[0] !== 'open'){ + if (require('yargs/yargs')(argv.slice(1)).parse()._[0] !== 'open'){ app.ready$.subscribe(() => { terminal.openTab() }) diff --git a/terminus-terminal/webpack.config.js b/terminus-terminal/webpack.config.js index 10b4b37d..54c3e52e 100644 --- a/terminus-terminal/webpack.config.js +++ b/terminus-terminal/webpack.config.js @@ -74,4 +74,6 @@ module.exports = { 'ngx-toastr', /^terminus-/, ], + // Ignore warnings due to yarg's dynamic module loading + ignoreWarnings: [/node_modules\/yargs/], }