Skip to content

Commit

Permalink
deps: update 'yargs'
Browse files Browse the repository at this point in the history
The following commit updates the `yargs` dependency and typings
to make use of the security vulnerability fix.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
Co-authored-by: Chaitanya Munukutla <chaitanya.m61292@gmail.com>
  • Loading branch information
vince-fugnitto and c16a committed Nov 10, 2020
1 parent 41070aa commit 1e519df
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@ import { ApplicationPackage } from '@theia/application-package';
const argv = yargs.option('mode', {
description: 'Mode to use',
choices: ['development', 'production'],
default: 'production'
default: 'production' as 'development' | 'production',
}).option('split-frontend', {
description: 'Split frontend modules into separate chunks. By default enabled in the dev mode and disabled in the prod mode.',
type: 'boolean',
default: undefined
}).option('app-target', {
description: 'The target application type. Overrides ["theia.target"] in the application\'s package.json.',
choices: ['browser', 'electron'],
}).argv;
const mode: 'development' | 'production' = argv.mode;
const splitFrontend: boolean = argv['split-frontend'] === undefined ? mode === 'development' : argv['split-frontend'];
const splitFrontend: boolean = argv['split-frontend'] ?? argv.mode === 'development';

export abstract class AbstractGenerator {

Expand Down
2 changes: 1 addition & 1 deletion dev-packages/application-manager/src/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import fs = require('fs-extra');
import path = require('path');

export function rebuild(target: 'electron' | 'browser', modules: string[]): void {
export function rebuild(target: 'electron' | 'browser', modules: string[] | undefined): void {
const nodeModulesPath = path.join(process.cwd(), 'node_modules');
const browserModulesPath = path.join(process.cwd(), '.browser_modules');
const modulesToProcess = modules || ['@theia/node-pty', 'nsfw', 'native-keymap', 'find-git-repositories', 'drivelist'];
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"puppeteer": "^2.0.0",
"puppeteer-to-istanbul": "^1.2.2",
"temp": "^0.9.1",
"yargs": "^11.1.0"
"yargs": "^15.3.1"
},
"devDependencies": {
"@types/proxy-from-env": "^1.0.1"
Expand Down
40 changes: 22 additions & 18 deletions dev-packages/cli/src/theia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@ function commandArgs(arg: string): string[] {
return restIndex !== -1 ? process.argv.slice(restIndex + 1) : [];
}

function rebuildCommand(command: string, target: ApplicationProps.Target): yargs.CommandModule {
function rebuildCommand(command: string, target: ApplicationProps.Target): yargs.CommandModule<unknown, { modules: string[] }> {
return {
command,
describe: 'rebuild native node modules for the ' + target,
handler: () => {
const { modules } = yargs.array('modules').argv;
builder: {
'modules': {
array: true,
},
},
handler: args => {
try {
rebuild(target, modules);
rebuild(target, args.modules);
} catch (err) {
console.error(err);
process.exit(1);
Expand All @@ -57,7 +61,7 @@ function rebuildCommand(command: string, target: ApplicationProps.Target): yargs

(function (): void {
const projectPath = process.cwd();
const appTarget: ApplicationProps.Target = yargs.argv['app-target'];
const appTarget = yargs.argv['app-target'] as ApplicationProps.Target;
const manager = new ApplicationPackageManager({ projectPath, appTarget });
const target = manager.pck.target;

Expand Down Expand Up @@ -123,7 +127,7 @@ function rebuildCommand(command: string, target: ApplicationProps.Target): yargs
.command(rebuildCommand('rebuild', target))
.command(rebuildCommand('rebuild:browser', 'browser'))
.command(rebuildCommand('rebuild:electron', 'electron'))
.command({
.command<{ suppress: boolean }>({
command: 'check:hoisted',
describe: 'check that all dependencies are hoisted',
builder: {
Expand All @@ -143,7 +147,7 @@ function rebuildCommand(command: string, target: ApplicationProps.Target): yargs
}
}
})
.command({
.command<{ packed: boolean }>({
command: 'download:plugins',
describe: 'Download defined external plugins.',
builder: {
Expand All @@ -162,7 +166,16 @@ function rebuildCommand(command: string, target: ApplicationProps.Target): yargs
process.exit(1);
}
},
}).command({
}).command<{
testInspect: boolean,
testExtension: string[],
testFile: string[],
testIgnore: string[],
testRecursive: boolean,
testSort: boolean,
testSpec: string[],
testCoverage: boolean
}>({
command: 'test',
builder: {
'test-inspect': {
Expand Down Expand Up @@ -206,16 +219,7 @@ function rebuildCommand(command: string, target: ApplicationProps.Target): yargs
default: false
}
},
handler: async ({ testInspect, testExtension, testFile, testIgnore, testRecursive, testSort, testSpec, testCoverage }: {
testInspect: boolean,
testExtension: string[],
testFile: string[],
testIgnore: string[],
testRecursive: boolean,
testSort: boolean,
testSpec: string[],
testCoverage: boolean
}) => {
handler: async ({ testInspect, testExtension, testFile, testIgnore, testRecursive, testSort, testSpec, testCoverage }) => {
try {
if (!process.env.THEIA_CONFIG_DIR) {
process.env.THEIA_CONFIG_DIR = temp.track().mkdirSync('theia-test-config-dir');
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"native-keymap": "^2.1.2",
"node-gyp": "^7.0.0",
"unzipper": "^0.9.11",
"yargs": "^11.1.0"
"yargs": "^15.3.1"
},
"scripts": {
"postinstall": "node scripts/post-install.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@types/route-parser": "^0.1.1",
"@types/safer-buffer": "^2.1.0",
"@types/ws": "^5.1.2",
"@types/yargs": "^11.1.0",
"@types/yargs": "^15",
"ajv": "^6.5.3",
"body-parser": "^1.17.2",
"cookie": "^0.4.0",
Expand Down Expand Up @@ -52,7 +52,7 @@
"vscode-uri": "^2.1.1",
"vscode-ws-jsonrpc": "^0.2.0",
"ws": "^7.1.2",
"yargs": "^11.1.0"
"yargs": "^15.3.1"
},
"publishConfig": {
"access": "public"
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/node/backend-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ export class BackendApplicationCliContribution implements CliContribution {
}

setArguments(args: yargs.Arguments): void {
this.port = args.port;
this.hostname = args.hostname;
this.ssl = args.ssl;
this.cert = args.cert;
this.certkey = args.certkey;
this.projectPath = args[appProjectPath];
this.port = args.port as number;
this.hostname = args.hostname as string;
this.ssl = args.ssl as boolean;
this.cert = args.cert as string;
this.certkey = args.certkey as string;
this.projectPath = args[appProjectPath] as string;
}

protected appProjectPath(): string {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/node/cli.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('CliManager', () => {
conf.option('bar', { alias: 'b', description: 'Some bla.', default: 'my-default', type: 'string' });
},
setArguments(args: yargs.Arguments): void {
value.resolve(args['foo']);
value.resolve(args['foo'] as string);
}
});
await mnr.initializeCli(['-f', 'bla']);
Expand All @@ -56,7 +56,7 @@ describe('CliManager', () => {
conf.option('bar', { alias: 'b', description: 'Some bla.', default: 'my-default', type: 'string' });
},
setArguments(args: yargs.Arguments): MaybePromise<void> {
value.resolve(args['bar']);
value.resolve(args['bar'] as string);
}
});
await mnr.initializeCli(['--foo']);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/node/logger-cli-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ export class LogLevelCliContribution implements CliContribution {
}

if (args['log-level'] !== undefined) {
this._defaultLogLevel = this.readLogLevelString(args['log-level'], 'Unknown log level passed to --log-level');
this._defaultLogLevel = this.readLogLevelString(args['log-level'] as string, 'Unknown log level passed to --log-level');
}

if (args['log-config'] !== undefined) {
let filename = args['log-config'];
let filename: string = args['log-config'] as string;
try {
filename = path.resolve(filename);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class PluginVsCodeCliContribution implements CliContribution, PluginHostE
}

setArguments(args: Arguments): void {
const arg = args[PluginVsCodeCliContribution.VSCODE_API_VERSION];
const arg = args[PluginVsCodeCliContribution.VSCODE_API_VERSION] as string;
if (arg) {
this.vsCodeApiVersion = arg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export class HostedPluginCliContribution implements CliContribution {
}

setArguments(args: Arguments): void {
this._extensionTestsPath = args[HostedPluginCliContribution.EXTENSION_TESTS_PATH];
this._pluginHostTerminateTimeout = args[HostedPluginCliContribution.PLUGIN_HOST_TERMINATE_TIMEOUT];
this._pluginHostStopTimeout = args[HostedPluginCliContribution.PLUGIN_HOST_STOP_TIMEOUT];
this._extensionTestsPath = args[HostedPluginCliContribution.EXTENSION_TESTS_PATH] as string;
this._pluginHostTerminateTimeout = args[HostedPluginCliContribution.PLUGIN_HOST_TERMINATE_TIMEOUT] as number;
this._pluginHostStopTimeout = args[HostedPluginCliContribution.PLUGIN_HOST_STOP_TIMEOUT] as number;
}

}
4 changes: 2 additions & 2 deletions packages/plugin-ext/src/main/node/plugin-cli-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ export class PluginCliContribution implements CliContribution {
}

setArguments(args: Arguments): void {
const pluginsArg = args[PluginCliContribution.PLUGINS];
const pluginsArg = args[PluginCliContribution.PLUGINS] as string;
if (pluginsArg && String(pluginsArg).startsWith(`${LocalDirectoryPluginDeployerResolver.LOCAL_DIR}:`)) {
this._localDir = pluginsArg;
}

const maxSessionLogsFoldersArg = args[PluginCliContribution.PLUGIN_MAX_SESSION_LOGS_FOLDERS];
const maxSessionLogsFoldersArg = args[PluginCliContribution.PLUGIN_MAX_SESSION_LOGS_FOLDERS] as number;
if (maxSessionLogsFoldersArg && Number.isInteger(maxSessionLogsFoldersArg) && maxSessionLogsFoldersArg > 0) {
this._maxSessionLogsFolders = maxSessionLogsFoldersArg;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/workspace/src/node/default-workspace-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export class WorkspaceCliContribution implements CliContribution {
}

setArguments(args: yargs.Arguments): void {
let wsPath = args._[2];
let wsPath: string | undefined = args._[2];
if (!wsPath) {
wsPath = args['root-dir'];
wsPath = args['root-dir'] as string;
if (!wsPath) {
this.workspaceRoot.resolve();
return;
Expand Down
17 changes: 12 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1567,10 +1567,17 @@
"@types/events" "*"
"@types/node" "*"

"@types/yargs@^11.1.0":
version "11.1.7"
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-11.1.7.tgz#a5be4a5f0f4b77b8accdd476004ce911f4241e8f"
integrity sha512-ynyKD3/wNHw9/vwYpiVqsrkDZjezXH7aVkg+Xp73irK0WzYYHkBOogiiM6/+eufAxmZxew3aZhAkrrjsOKbLOA==
"@types/yargs-parser@*":
version "15.0.0"
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-15.0.0.tgz#cb3f9f741869e20cce330ffbeb9271590483882d"
integrity sha512-FA/BWv8t8ZWJ+gEOnLLd8ygxH/2UFbAvgEonyfN6yWGLKc7zVjbpl2Y4CTjid9h2RfgPP6SEt6uHwEOply00yw==

"@types/yargs@^15":
version "15.0.9"
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-15.0.9.tgz#524cd7998fe810cdb02f26101b699cccd156ff19"
integrity sha512-HmU8SeIRhZCWcnRskCs36Q1Q00KBV6Cqh/ora8WN1+22dY07AZdn6Gel8QZ3t26XYPImtcL8WV/eqjhVmMEw4g==
dependencies:
"@types/yargs-parser" "*"

"@typescript-eslint/eslint-plugin-tslint@^3.1.0":
version "3.10.1"
Expand Down Expand Up @@ -14150,7 +14157,7 @@ yargs@13.3.2, yargs@^13.3.0:
y18n "^4.0.0"
yargs-parser "^13.1.2"

yargs@^11.0.0, yargs@^11.1.0:
yargs@^11.0.0:
version "11.1.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-11.1.1.tgz#5052efe3446a4df5ed669c995886cc0f13702766"
integrity sha512-PRU7gJrJaXv3q3yQZ/+/X6KBswZiaQ+zOmdprZcouPYtQgvNU35i+68M4b1ZHLZtYFT5QObFLV+ZkmJYcwKdiw==
Expand Down

0 comments on commit 1e519df

Please sign in to comment.