Skip to content

Commit 2e04931

Browse files
committed
refactor(@angular/cli): replace command line arguments parser
With this change we refactor the Angular CLI and replace the underlying args parser and command builder. We choose to use Yargs as our parser and command builder of choice. The main advantages of Yargs over other command builders are; - Highly configurable. - We already use it in other packages such as the compiler-cli/dev-infra etc.. - Commands and options can be added during runtime. This is a requirement that is needed to support architect and schematics commands. - Outstanding documentation. - The possibility to parse args without parser configuration (Free form). - Commands are built lazily based on the arguments passed. BREAKING CHANGE: Several changes in the Angular CLI commands and arguments handling. - `ng help` has been removed in favour of the `—-help` option. - `ng —-version` has been removed in favour of `ng version` and `ng v`. - Deprecated camel cased arguments are no longer supported. Ex. using `—-sourceMap` instead of `—-source-map` will result in an error. - `ng update`, `—-migrate-only` option no longer accepts a string of migration name, instead use `—-migrate-only -—name <migration-name>`. - `—-help json` help has been removed. Closes #20976, closes #16614 and closes #16241
1 parent bc1b36d commit 2e04931

File tree

118 files changed

+2531
-3993
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+2531
-3993
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
"@types/semver": "^7.0.0",
116116
"@types/text-table": "^0.2.1",
117117
"@types/uuid": "^8.0.0",
118+
"@types/yargs": "^17.0.8",
118119
"@types/yargs-parser": "^21.0.0",
119120
"@typescript-eslint/eslint-plugin": "5.14.0",
120121
"@typescript-eslint/parser": "5.14.0",
@@ -216,6 +217,7 @@
216217
"webpack-dev-server": "4.7.4",
217218
"webpack-merge": "5.8.0",
218219
"webpack-subresource-integrity": "5.1.0",
220+
"yargs": "17.3.1",
219221
"yargs-parser": "21.0.1",
220222
"zone.js": "^0.11.3"
221223
}

packages/angular/cli/BUILD.bazel

Lines changed: 2 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,6 @@ ts_library(
2626
# @external_begin
2727
# These files are generated from the JSON schema
2828
"//packages/angular/cli:lib/config/workspace-schema.ts",
29-
"//packages/angular/cli:commands/analytics.ts",
30-
"//packages/angular/cli:commands/add.ts",
31-
"//packages/angular/cli:commands/build.ts",
32-
"//packages/angular/cli:commands/deploy.ts",
33-
"//packages/angular/cli:commands/config.ts",
34-
"//packages/angular/cli:commands/doc.ts",
35-
"//packages/angular/cli:commands/e2e.ts",
36-
"//packages/angular/cli:commands/easter-egg.ts",
37-
"//packages/angular/cli:commands/generate.ts",
38-
"//packages/angular/cli:commands/help.ts",
39-
"//packages/angular/cli:commands/lint.ts",
40-
"//packages/angular/cli:commands/new.ts",
41-
"//packages/angular/cli:commands/serve.ts",
42-
"//packages/angular/cli:commands/test.ts",
43-
"//packages/angular/cli:commands/update.ts",
44-
"//packages/angular/cli:commands/version.ts",
45-
"//packages/angular/cli:commands/run.ts",
46-
"//packages/angular/cli:commands/extract-i18n.ts",
4729
"//packages/angular/cli:src/commands/update/schematic/schema.ts",
4830
# @external_end
4931
],
@@ -79,6 +61,7 @@ ts_library(
7961
"@npm//@types/resolve",
8062
"@npm//@types/semver",
8163
"@npm//@types/uuid",
64+
"@npm//@types/yargs",
8265
"@npm//@yarnpkg/lockfile",
8366
"@npm//ansi-colors",
8467
"@npm//ini",
@@ -88,6 +71,7 @@ ts_library(
8871
"@npm//ora",
8972
"@npm//pacote",
9073
"@npm//semver",
74+
"@npm//yargs",
9175
],
9276
)
9377

@@ -132,150 +116,6 @@ ts_json_schema(
132116
data = CLI_SCHEMA_DATA,
133117
)
134118

135-
ts_json_schema(
136-
name = "analytics_schema",
137-
src = "commands/analytics.json",
138-
data = [
139-
"commands/definitions.json",
140-
],
141-
)
142-
143-
ts_json_schema(
144-
name = "add_schema",
145-
src = "commands/add.json",
146-
data = [
147-
"commands/definitions.json",
148-
],
149-
)
150-
151-
ts_json_schema(
152-
name = "build_schema",
153-
src = "commands/build.json",
154-
data = [
155-
"commands/definitions.json",
156-
],
157-
)
158-
159-
ts_json_schema(
160-
name = "deploy_schema",
161-
src = "commands/deploy.json",
162-
data = [
163-
"commands/definitions.json",
164-
],
165-
)
166-
167-
ts_json_schema(
168-
name = "config_schema",
169-
src = "commands/config.json",
170-
data = [
171-
"commands/definitions.json",
172-
],
173-
)
174-
175-
ts_json_schema(
176-
name = "doc_schema",
177-
src = "commands/doc.json",
178-
data = [
179-
"commands/definitions.json",
180-
],
181-
)
182-
183-
ts_json_schema(
184-
name = "e2e_schema",
185-
src = "commands/e2e.json",
186-
data = [
187-
"commands/definitions.json",
188-
],
189-
)
190-
191-
ts_json_schema(
192-
name = "easter_egg_schema",
193-
src = "commands/easter-egg.json",
194-
data = [
195-
"commands/definitions.json",
196-
],
197-
)
198-
199-
ts_json_schema(
200-
name = "generate_schema",
201-
src = "commands/generate.json",
202-
data = [
203-
"commands/definitions.json",
204-
],
205-
)
206-
207-
ts_json_schema(
208-
name = "help_schema",
209-
src = "commands/help.json",
210-
data = [
211-
"commands/definitions.json",
212-
],
213-
)
214-
215-
ts_json_schema(
216-
name = "lint_schema",
217-
src = "commands/lint.json",
218-
data = [
219-
"commands/definitions.json",
220-
],
221-
)
222-
223-
ts_json_schema(
224-
name = "new_schema",
225-
src = "commands/new.json",
226-
data = [
227-
"commands/definitions.json",
228-
],
229-
)
230-
231-
ts_json_schema(
232-
name = "run_schema",
233-
src = "commands/run.json",
234-
data = [
235-
"commands/definitions.json",
236-
],
237-
)
238-
239-
ts_json_schema(
240-
name = "serve_schema",
241-
src = "commands/serve.json",
242-
data = [
243-
"commands/definitions.json",
244-
],
245-
)
246-
247-
ts_json_schema(
248-
name = "test_schema",
249-
src = "commands/test.json",
250-
data = [
251-
"commands/definitions.json",
252-
],
253-
)
254-
255-
ts_json_schema(
256-
name = "update_schema",
257-
src = "commands/update.json",
258-
data = [
259-
"commands/definitions.json",
260-
],
261-
)
262-
263-
ts_json_schema(
264-
name = "version_schema",
265-
src = "commands/version.json",
266-
data = [
267-
"commands/definitions.json",
268-
],
269-
)
270-
271-
ts_json_schema(
272-
name = "extract-i18n_schema",
273-
src = "commands/extract-i18n.json",
274-
data = [
275-
"commands/definitions.json",
276-
],
277-
)
278-
279119
ts_json_schema(
280120
name = "update_schematic_schema",
281121
src = "src/commands/update/schematic/schema.json",

packages/angular/cli/commands.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/angular/cli/commands/add.json

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)