GeezerVison is showing github.com — replace parser with yargs-parser by alan-agius4 · Pull Request #22779 · angular/angular-cli
replace parser with yargs-parser
#22779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.bazel
(3)
.json
(4)
.lock
(1)
.ts
(4)
All 4 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -104,7 +104,6 @@
"@types/karma": "^6.3.0",
"@types/loader-utils": "^2.0.0",
"@types/minimatch": "3.0.5",
"@types/minimist": "^1.2.0",
"@types/node": "~12.12.6",
"@types/node-fetch": "^2.1.6",
"@types/npm-package-arg": "^6.1.0",
Expand All
@@ -116,6 +115,7 @@
"@types/semver": "^7.0.0",
"@types/text-table": "^0.2.1",
"@types/uuid": "^8.0.0",
"@types/yargs-parser": "^20.2.1",
"@typescript-eslint/eslint-plugin": "5.13.0",
"@typescript-eslint/parser": "5.13.0",
"@yarnpkg/lockfile": "1.1.0",
Expand Down
Expand Up
@@ -167,7 +167,6 @@
"magic-string": "0.25.7",
"mini-css-extract-plugin": "2.5.3",
"minimatch": "5.0.1",
"minimist": "^1.2.0",
"ng-packagr": "14.0.0-next.1",
"node-fetch": "^2.2.0",
"npm-package-arg": "9.0.0",
Expand Down
Expand Up
@@ -217,6 +216,7 @@
"webpack-dev-server": "4.7.4",
"webpack-merge": "5.8.0",
"webpack-subresource-integrity": "5.1.0",
"yargs-parser": "21.0.1",
"zone.js": "^0.11.3"
}
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -20,9 +20,9 @@ ts_library(
"//packages/angular_devkit/architect/node",
"//packages/angular_devkit/core",
"//packages/angular_devkit/core/node",
"@npm//@types/minimist",
"@npm//@types/node",
"@npm//@types/progress",
"@npm//@types/yargs-parser",
"@npm//ansi-colors",
"@npm//rxjs",
],
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -9,13 +9,13 @@
import { Architect, BuilderInfo, BuilderProgressState, Target } from '@angular-devkit/architect';
import { WorkspaceNodeModulesArchitectHost } from '@angular-devkit/architect/node';
import { logging, schema, tags, workspaces } from '@angular-devkit/core';
import { json, logging, schema, tags, workspaces } from '@angular-devkit/core';
import { NodeJsSyncHost, createConsoleLogger } from '@angular-devkit/core/node';
import * as ansiColors from 'ansi-colors';
import { existsSync } from 'fs';
import minimist from 'minimist';
import * as path from 'path';
import { tap } from 'rxjs/operators';
import yargsParser from 'yargs-parser';
import { MultiProgressBar } from '../src/progress';
function findUp(names: string | string[], from: string) {
Expand Down
Expand Up
@@ -78,24 +78,43 @@ async function _executeTarget(
parentLogger: logging.Logger,
workspace: workspaces.WorkspaceDefinition,
root: string,
argv: minimist.ParsedArgs ,
argv: yargsParser.Arguments ,
registry: schema.SchemaRegistry,
) {
const architectHost = new WorkspaceNodeModulesArchitectHost(workspace, root);
const architect = new Architect(architectHost, registry);
// Split a target into its parts.
const targetStr = argv._.shift() || '';
const {
_: [targetStr = ''],
help,
...options
} = argv;
const [project, target, configuration] = targetStr.split(':');
const targetSpec = { project, target, configuration };
delete argv['help'];
const logger = new logging.Logger('jobs');
const logs: logging.LogEntry[] = [];
logger.subscribe((entry) => logs.push({ ...entry, message: `${entry.name}: ` + entry.message }));
const { _, ...options } = argv;
const run = await architect.scheduleTarget(targetSpec, options, { logger });
// Camelize options as yargs will return the object in kebab-case when camel casing is disabled.
// Casting temporary until https://github.com/DefinitelyTyped/DefinitelyTyped/pull/59065 is merged and released.
const { camelCase, decamelize } = yargsParser as yargsParser.Parser & {
camelCase(str: string): string;
decamelize(str: string, joinString?: string): string;
};
const camelCasedOptions: json.JsonObject = {};
for (const [key, value] of Object.entries(options)) {
if (/[A-Z]/.test(key)) {
throw new Error(`Unknown argument ${key}. Did you mean ${decamelize(key)}?`);
}
camelCasedOptions[camelCase(key)] = value;
}
const run = await architect.scheduleTarget(targetSpec, camelCasedOptions, { logger });
const bars = new MultiProgressBar<number, BarInfo>(':name :bar (:current/:total) :status');
run.progress.subscribe((update) => {
Expand All
@@ -107,7 +126,7 @@ async function _executeTarget(
name: (
(update.target ? _targetStringFromTarget(update.target) : update.builder.name) +
' '.repeat(80)
).substr (0, 40),
).substring (0, 40),
};
if (update.status !== undefined) {
Expand Down
Expand Up
@@ -175,7 +194,15 @@ async function _executeTarget(
async function main(args: string[]): Promise<number> {
/** Parse the command line. */
const argv = minimist(args, { boolean: ['help'] });
const argv = yargsParser(args, {
boolean: ['help'],
configuration: {
'dot-notation': false,
'boolean-negation': true,
'strip-aliased': true,
'camel-case-expansion': false,
},
});
/** Create the DevKit Logger used through the CLI. */
const logger = createConsoleLogger(argv['verbose'], process.stdout, process.stderr, {
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -17,10 +17,10 @@
"@angular-devkit/architect": "0.0.0-EXPERIMENTAL-PLACEHOLDER",
"@angular-devkit/core": "0.0.0-PLACEHOLDER",
"ansi-colors": "4.1.1",
"minimist": "1.2.5",
"progress": "2.0.3",
"rxjs": "6.6.7",
"symbol-observable": "4.0.0"
"symbol-observable": "4.0.0",
"yargs-parser": "21.0.1"
},
"devDependencies": {
"@types/progress": "2.0.5"
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -25,9 +25,9 @@ ts_library(
deps = [
"//packages/angular_devkit/core",
"//packages/angular_devkit/core/node",
"@npm//@types/minimist",
"@npm//@types/node",
"@npm//@types/pidusage",
"@npm//@types/yargs-parser",
"@npm//ansi-colors",
"@npm//rxjs",
],
Expand Down
Expand Up
@@ -60,12 +60,12 @@ jasmine_node_test(
srcs = [":benchmark_test_lib"],
deps = [
"@npm//jasmine",
"@npm//minimist",
"@npm//pidtree",
"@npm//pidusage",
"@npm//source-map",
"@npm//temp",
"@npm//tree-kill",
"@npm//yargs-parser",
],
)
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -12,10 +12,10 @@
"dependencies": {
"@angular-devkit/core": "0.0.0-PLACEHOLDER",
"ansi-colors": "4.1.1",
"minimist": "1.2.5",
"pidusage": "3.0.0",
"pidtree": "0.5.0",
"rxjs": "6.6.7",
"tree-kill": "^1.2.0"
"tree-kill": "^1.2.0",
"yargs-parser": "21.0.1"
}
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -11,8 +11,8 @@ import { logging, tags } from '@angular-devkit/core';
import { ProcessOutput } from '@angular-devkit/core/node';
import * as ansiColors from 'ansi-colors';
import { appendFileSync, writeFileSync } from 'fs';
import minimist from 'minimist';
import { filter, map, toArray } from 'rxjs/operators';
import yargsParser from 'yargs-parser';
import { Command } from '../src/command';
import { defaultReporter } from '../src/default-reporter';
import { defaultStatsCapture } from '../src/default-stats-capture';
Expand All
@@ -25,6 +25,7 @@ export interface MainOptions {
stderr?: ProcessOutput;
}
// eslint-disable-next-line max-lines-per-function
export async function main({
args,
stdout = process.stdout,
Expand Down
Expand Up
@@ -69,13 +70,22 @@ export async function main({
'watch-timeout': number;
'watch-matcher'?: string;
'watch-script'?: string;
'--': string[] | null;
'--': string[];
_: string[];
$0: string;
}
// Parse the command line.
const argv = minimist (args, {
const argv = yargsParser (args, {
boolean: ['help', 'verbose', 'overwrite-output-file'],
string: ['watch-matcher', 'watch-script'],
configuration: {
'dot-notation': false,
'boolean-negation': true,
'strip-aliased': true,
'populate--': true,
'camel-case-expansion': false,
},
default: {
'exit-code': 0,
'iterations': 5,
Expand All
@@ -85,8 +95,7 @@ export async function main({
'prefix': '[benchmark]',
'watch-timeout': 10000,
},
'--': true,
}) as {} as BenchmarkCliArgv;
}) as BenchmarkCliArgv;
// Create the DevKit Logger used through the CLI.
const logger = new logging.TransformLogger('benchmark-prefix-logger', (stream) =>
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -51,12 +51,12 @@ ts_library(
"//packages/angular_devkit/schematics/tasks",
"//packages/angular_devkit/schematics/tools",
"@npm//@types/inquirer",
"@npm//@types/minimist",
"@npm//@types/node",
"@npm//@types/yargs-parser",
"@npm//ansi-colors",
"@npm//inquirer", # @external
"@npm//minimist", # @external
"@npm//symbol-observable", # @external
"@npm//yargs-parser", # @external
],
)
Expand Down
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.