@angular/cli 14.0.0-next.1 → 14.0.0-next.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/bin/ng.js +3 -5
  2. package/lib/cli/index.d.ts +1 -2
  3. package/lib/cli/index.js +16 -45
  4. package/lib/config/schema.json +48 -15
  5. package/lib/config/workspace-schema.d.ts +18 -1
  6. package/lib/init.js +10 -9
  7. package/package.json +21 -23
  8. package/{models → src/analytics}/analytics-collector.d.ts +0 -0
  9. package/{models → src/analytics}/analytics-collector.js +8 -2
  10. package/src/analytics/analytics.d.ts +47 -0
  11. package/src/analytics/analytics.js +306 -0
  12. package/src/command-builder/architect-base-command-module.d.ts +30 -0
  13. package/src/command-builder/architect-base-command-module.js +165 -0
  14. package/src/command-builder/architect-command-module.d.ts +25 -0
  15. package/src/command-builder/architect-command-module.js +134 -0
  16. package/src/command-builder/command-module.d.ts +89 -0
  17. package/src/command-builder/command-module.js +198 -0
  18. package/{utilities/package-json.js → src/command-builder/command-runner.d.ts} +2 -2
  19. package/src/command-builder/command-runner.js +168 -0
  20. package/src/command-builder/schematics-command-module.d.ts +43 -0
  21. package/src/command-builder/schematics-command-module.js +333 -0
  22. package/src/command-builder/utilities/command.d.ts +13 -0
  23. package/src/command-builder/utilities/command.js +27 -0
  24. package/src/command-builder/utilities/json-help.d.ts +36 -0
  25. package/src/command-builder/utilities/json-help.js +94 -0
  26. package/src/command-builder/utilities/json-schema.d.ts +40 -0
  27. package/{utilities → src/command-builder/utilities}/json-schema.js +20 -121
  28. package/src/command-builder/utilities/normalize-options-middleware.d.ts +18 -0
  29. package/src/command-builder/utilities/normalize-options-middleware.js +59 -0
  30. package/{models → src/command-builder/utilities}/schematic-engine-host.d.ts +2 -2
  31. package/{models → src/command-builder/utilities}/schematic-engine-host.js +33 -18
  32. package/src/command-builder/utilities/schematic-workflow.d.ts +14 -0
  33. package/src/command-builder/utilities/schematic-workflow.js +68 -0
  34. package/src/commands/add/cli.d.ts +33 -0
  35. package/{commands/add-impl.js → src/commands/add/cli.js} +108 -80
  36. package/src/commands/add/long-description.md +7 -0
  37. package/src/commands/analytics/cli.d.ts +16 -0
  38. package/src/commands/analytics/cli.js +35 -0
  39. package/src/commands/analytics/info/cli.d.ts +16 -0
  40. package/src/commands/analytics/info/cli.js +26 -0
  41. package/src/commands/analytics/settings/cli.d.ts +35 -0
  42. package/src/commands/analytics/settings/cli.js +61 -0
  43. package/src/commands/build/cli.d.ts +16 -0
  44. package/src/commands/build/cli.js +23 -0
  45. package/{commands/build-long.md → src/commands/build/long-description.md} +0 -0
  46. package/src/commands/cache/clean/cli.d.ts +17 -0
  47. package/src/commands/cache/clean/cli.js +32 -0
  48. package/src/commands/cache/cli.d.ts +17 -0
  49. package/src/commands/cache/cli.js +38 -0
  50. package/src/commands/cache/info/cli.d.ts +20 -0
  51. package/src/commands/cache/info/cli.js +82 -0
  52. package/src/commands/cache/long-description.md +53 -0
  53. package/src/commands/cache/settings/cli.d.ts +27 -0
  54. package/src/commands/cache/settings/cli.js +42 -0
  55. package/src/commands/cache/utilities.d.ts +11 -0
  56. package/src/commands/cache/utilities.js +49 -0
  57. package/src/commands/completion/cli.d.ts +16 -0
  58. package/src/commands/completion/cli.js +31 -0
  59. package/src/commands/completion/long-description.md +1 -0
  60. package/src/commands/config/cli.d.ts +24 -0
  61. package/{commands/config-impl.js → src/commands/config/cli.js} +102 -89
  62. package/{commands/config-long.md → src/commands/config/long-description.md} +2 -2
  63. package/src/commands/deploy/cli.d.ts +17 -0
  64. package/src/commands/deploy/cli.js +49 -0
  65. package/{commands/deploy-long.md → src/commands/deploy/long-description.md} +0 -0
  66. package/src/commands/doc/cli.d.ts +23 -0
  67. package/{commands/doc-impl.js → src/commands/doc/cli.js} +41 -12
  68. package/src/commands/e2e/cli.d.ts +18 -0
  69. package/src/commands/e2e/cli.js +35 -0
  70. package/src/commands/extract-i18n/cli.d.ts +15 -0
  71. package/src/commands/extract-i18n/cli.js +20 -0
  72. package/src/commands/generate/cli.d.ts +39 -0
  73. package/src/commands/generate/cli.js +145 -0
  74. package/src/commands/lint/cli.d.ts +17 -0
  75. package/src/commands/lint/cli.js +28 -0
  76. package/{commands/lint-long.md → src/commands/lint/long-description.md} +0 -0
  77. package/src/commands/make-this-awesome/cli.d.ts +17 -0
  78. package/{commands/easter-egg-impl.js → src/commands/make-this-awesome/cli.js} +17 -10
  79. package/src/commands/new/cli.d.ts +27 -0
  80. package/src/commands/new/cli.js +82 -0
  81. package/src/commands/run/cli.d.ts +25 -0
  82. package/src/commands/run/cli.js +83 -0
  83. package/{commands/run-long.md → src/commands/run/long-description.md} +0 -0
  84. package/src/commands/serve/cli.d.ts +16 -0
  85. package/src/commands/serve/cli.js +21 -0
  86. package/src/commands/test/cli.d.ts +16 -0
  87. package/src/commands/test/cli.js +23 -0
  88. package/{commands/test-long.md → src/commands/test/long-description.md} +0 -0
  89. package/{commands/update-impl.d.ts → src/commands/update/cli.d.ts} +26 -9
  90. package/{commands/update-impl.js → src/commands/update/cli.js} +363 -316
  91. package/{commands/update-long.md → src/commands/update/long-description.md} +0 -0
  92. package/src/commands/update/schematic/index.js +33 -20
  93. package/src/commands/version/cli.d.ts +18 -0
  94. package/{commands/version-impl.js → src/commands/version/cli.js} +56 -74
  95. package/src/typings-bazel.d.ts +14 -0
  96. package/src/typings.d.ts +1 -14
  97. package/{utilities → src/utilities}/color.d.ts +0 -0
  98. package/{utilities → src/utilities}/color.js +5 -1
  99. package/{utilities → src/utilities}/config.d.ts +6 -5
  100. package/{utilities → src/utilities}/config.js +33 -19
  101. package/src/utilities/environment-options.d.ts +12 -0
  102. package/src/utilities/environment-options.js +24 -0
  103. package/{utilities → src/utilities}/find-up.d.ts +0 -0
  104. package/{utilities → src/utilities}/find-up.js +5 -1
  105. package/{utilities → src/utilities}/json-file.d.ts +0 -0
  106. package/{utilities → src/utilities}/json-file.js +1 -0
  107. package/{utilities → src/utilities}/log-file.d.ts +0 -0
  108. package/{utilities → src/utilities}/log-file.js +0 -0
  109. package/src/utilities/memoize.d.ts +15 -0
  110. package/src/utilities/memoize.js +69 -0
  111. package/src/utilities/package-manager.d.ts +41 -0
  112. package/src/utilities/package-manager.js +287 -0
  113. package/{utilities → src/utilities}/package-metadata.d.ts +15 -37
  114. package/{utilities → src/utilities}/package-metadata.js +15 -27
  115. package/{utilities → src/utilities}/package-tree.d.ts +2 -2
  116. package/{utilities → src/utilities}/package-tree.js +5 -1
  117. package/{utilities → src/utilities}/project.d.ts +0 -0
  118. package/{utilities → src/utilities}/project.js +5 -1
  119. package/{utilities → src/utilities}/prompt.d.ts +2 -0
  120. package/{utilities → src/utilities}/prompt.js +25 -4
  121. package/{utilities → src/utilities}/spinner.d.ts +0 -0
  122. package/{utilities → src/utilities}/spinner.js +0 -0
  123. package/{utilities → src/utilities}/tty.d.ts +0 -0
  124. package/{utilities → src/utilities}/tty.js +0 -0
  125. package/{models → src/utilities}/version.d.ts +2 -1
  126. package/{models → src/utilities}/version.js +6 -6
  127. package/bin/postinstall/analytics-prompt.js +0 -27
  128. package/bin/postinstall/script.js +0 -16
  129. package/commands/add-impl.d.ts +0 -21
  130. package/commands/add.d.ts +0 -42
  131. package/commands/add.js +0 -10
  132. package/commands/add.json +0 -54
  133. package/commands/add.md +0 -10
  134. package/commands/analytics-impl.d.ts +0 -13
  135. package/commands/analytics-impl.js +0 -80
  136. package/commands/analytics-long.md +0 -8
  137. package/commands/analytics.d.ts +0 -46
  138. package/commands/analytics.js +0 -31
  139. package/commands/analytics.json +0 -37
  140. package/commands/build-impl.d.ts +0 -14
  141. package/commands/build-impl.js +0 -21
  142. package/commands/build.d.ts +0 -30
  143. package/commands/build.js +0 -10
  144. package/commands/build.json +0 -16
  145. package/commands/config-impl.d.ts +0 -15
  146. package/commands/config.d.ts +0 -34
  147. package/commands/config.js +0 -10
  148. package/commands/config.json +0 -43
  149. package/commands/definitions.json +0 -66
  150. package/commands/deploy-impl.d.ts +0 -15
  151. package/commands/deploy-impl.js +0 -36
  152. package/commands/deploy.d.ts +0 -30
  153. package/commands/deploy.js +0 -10
  154. package/commands/deploy.json +0 -34
  155. package/commands/doc-impl.d.ts +0 -13
  156. package/commands/doc.d.ts +0 -39
  157. package/commands/doc.js +0 -14
  158. package/commands/doc.json +0 -46
  159. package/commands/e2e-impl.d.ts +0 -16
  160. package/commands/e2e-impl.js +0 -36
  161. package/commands/e2e-long.md +0 -4
  162. package/commands/e2e.d.ts +0 -29
  163. package/commands/e2e.js +0 -10
  164. package/commands/e2e.json +0 -17
  165. package/commands/easter-egg-impl.d.ts +0 -12
  166. package/commands/easter-egg.d.ts +0 -14
  167. package/commands/easter-egg.js +0 -10
  168. package/commands/easter-egg.json +0 -12
  169. package/commands/extract-i18n-impl.d.ts +0 -14
  170. package/commands/extract-i18n-impl.js +0 -32
  171. package/commands/extract-i18n.d.ts +0 -29
  172. package/commands/extract-i18n.js +0 -10
  173. package/commands/extract-i18n.json +0 -17
  174. package/commands/generate-impl.d.ts +0 -18
  175. package/commands/generate-impl.js +0 -89
  176. package/commands/generate.d.ts +0 -37
  177. package/commands/generate.js +0 -10
  178. package/commands/generate.json +0 -31
  179. package/commands/help-impl.d.ts +0 -12
  180. package/commands/help-impl.js +0 -26
  181. package/commands/help-long.md +0 -7
  182. package/commands/help.d.ts +0 -17
  183. package/commands/help.js +0 -10
  184. package/commands/help.json +0 -13
  185. package/commands/lint-impl.d.ts +0 -16
  186. package/commands/lint-impl.js +0 -69
  187. package/commands/lint.d.ts +0 -29
  188. package/commands/lint.js +0 -10
  189. package/commands/lint.json +0 -36
  190. package/commands/new-impl.d.ts +0 -16
  191. package/commands/new-impl.js +0 -37
  192. package/commands/new.d.ts +0 -41
  193. package/commands/new.js +0 -10
  194. package/commands/new.json +0 -34
  195. package/commands/new.md +0 -16
  196. package/commands/run-impl.d.ts +0 -13
  197. package/commands/run-impl.js +0 -22
  198. package/commands/run.d.ts +0 -30
  199. package/commands/run.js +0 -10
  200. package/commands/run.json +0 -36
  201. package/commands/serve-impl.d.ts +0 -15
  202. package/commands/serve-impl.js +0 -24
  203. package/commands/serve.d.ts +0 -29
  204. package/commands/serve.js +0 -10
  205. package/commands/serve.json +0 -17
  206. package/commands/test-impl.d.ts +0 -15
  207. package/commands/test-impl.js +0 -22
  208. package/commands/test.d.ts +0 -29
  209. package/commands/test.js +0 -10
  210. package/commands/test.json +0 -17
  211. package/commands/update.d.ts +0 -61
  212. package/commands/update.js +0 -10
  213. package/commands/update.json +0 -78
  214. package/commands/version-impl.d.ts +0 -17
  215. package/commands/version.d.ts +0 -17
  216. package/commands/version.js +0 -10
  217. package/commands/version.json +0 -13
  218. package/commands.json +0 -20
  219. package/models/analytics.d.ts +0 -58
  220. package/models/analytics.js +0 -358
  221. package/models/architect-command.d.ts +0 -35
  222. package/models/architect-command.js +0 -364
  223. package/models/command-runner.d.ts +0 -24
  224. package/models/command-runner.js +0 -241
  225. package/models/command.d.ts +0 -34
  226. package/models/command.js +0 -143
  227. package/models/interface.d.ts +0 -196
  228. package/models/interface.js +0 -31
  229. package/models/parser.d.ts +0 -39
  230. package/models/parser.js +0 -349
  231. package/models/schematic-command.d.ts +0 -55
  232. package/models/schematic-command.js +0 -485
  233. package/utilities/INITIAL_COMMIT_MESSAGE.txt +0 -8
  234. package/utilities/install-package.d.ts +0 -16
  235. package/utilities/install-package.js +0 -193
  236. package/utilities/json-schema.d.ts +0 -17
  237. package/utilities/package-json.d.ts +0 -249
  238. package/utilities/package-manager.d.ts +0 -13
  239. package/utilities/package-manager.js +0 -106
@@ -1,485 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google LLC All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
- Object.defineProperty(o, "default", { enumerable: true, value: v });
18
- }) : function(o, v) {
19
- o["default"] = v;
20
- });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.SchematicCommand = exports.UnknownCollectionError = void 0;
30
- const core_1 = require("@angular-devkit/core");
31
- const schematics_1 = require("@angular-devkit/schematics");
32
- const tools_1 = require("@angular-devkit/schematics/tools");
33
- const inquirer = __importStar(require("inquirer"));
34
- const systemPath = __importStar(require("path"));
35
- const color_1 = require("../utilities/color");
36
- const config_1 = require("../utilities/config");
37
- const json_schema_1 = require("../utilities/json-schema");
38
- const package_manager_1 = require("../utilities/package-manager");
39
- const tty_1 = require("../utilities/tty");
40
- const analytics_1 = require("./analytics");
41
- const command_1 = require("./command");
42
- const parser_1 = require("./parser");
43
- const schematic_engine_host_1 = require("./schematic-engine-host");
44
- class UnknownCollectionError extends Error {
45
- constructor(collectionName) {
46
- super(`Invalid collection (${collectionName}).`);
47
- }
48
- }
49
- exports.UnknownCollectionError = UnknownCollectionError;
50
- class SchematicCommand extends command_1.Command {
51
- constructor(context, description, logger) {
52
- super(context, description, logger);
53
- this.allowPrivateSchematics = false;
54
- this.useReportAnalytics = false;
55
- this.defaultCollectionName = '@schematics/angular';
56
- this.collectionName = this.defaultCollectionName;
57
- }
58
- async initialize(options) {
59
- await this.createWorkflow(options);
60
- if (this.schematicName) {
61
- // Set the options.
62
- const collection = this.getCollection(this.collectionName);
63
- const schematic = this.getSchematic(collection, this.schematicName, true);
64
- const options = await (0, json_schema_1.parseJsonSchemaToOptions)(this._workflow.registry, schematic.description.schemaJson || {});
65
- this.description.description = schematic.description.description;
66
- this.description.options.push(...options.filter((x) => !x.hidden));
67
- // Remove any user analytics from schematics that are NOT part of our safelist.
68
- for (const o of this.description.options) {
69
- if (o.userAnalytics && !(0, analytics_1.isPackageNameSafeForAnalytics)(this.collectionName)) {
70
- o.userAnalytics = undefined;
71
- }
72
- }
73
- }
74
- }
75
- async printHelp() {
76
- await super.printHelp();
77
- this.logger.info('');
78
- const subCommandOption = this.description.options.filter((x) => x.subcommands)[0];
79
- if (!subCommandOption || !subCommandOption.subcommands) {
80
- return 0;
81
- }
82
- const schematicNames = Object.keys(subCommandOption.subcommands);
83
- if (schematicNames.length > 1) {
84
- this.logger.info('Available Schematics:');
85
- const namesPerCollection = {};
86
- schematicNames.forEach((name) => {
87
- let [collectionName, schematicName] = name.split(/:/, 2);
88
- if (!schematicName) {
89
- schematicName = collectionName;
90
- collectionName = this.collectionName;
91
- }
92
- if (!namesPerCollection[collectionName]) {
93
- namesPerCollection[collectionName] = [];
94
- }
95
- namesPerCollection[collectionName].push(schematicName);
96
- });
97
- const defaultCollection = await this.getDefaultSchematicCollection();
98
- Object.keys(namesPerCollection).forEach((collectionName) => {
99
- const isDefault = defaultCollection == collectionName;
100
- this.logger.info(` Collection "${collectionName}"${isDefault ? ' (default)' : ''}:`);
101
- namesPerCollection[collectionName].forEach((schematicName) => {
102
- this.logger.info(` ${schematicName}`);
103
- });
104
- });
105
- }
106
- return 0;
107
- }
108
- async printHelpUsage() {
109
- const subCommandOption = this.description.options.filter((x) => x.subcommands)[0];
110
- if (!subCommandOption || !subCommandOption.subcommands) {
111
- return;
112
- }
113
- const schematicNames = Object.keys(subCommandOption.subcommands);
114
- if (schematicNames.length == 1) {
115
- this.logger.info(this.description.description);
116
- const opts = this.description.options.filter((x) => x.positional === undefined);
117
- const [collectionName, schematicName] = schematicNames[0].split(/:/)[0];
118
- // Display <collectionName:schematicName> if this is not the default collectionName,
119
- // otherwise just show the schematicName.
120
- const displayName = collectionName == (await this.getDefaultSchematicCollection())
121
- ? schematicName
122
- : schematicNames[0];
123
- const schematicOptions = subCommandOption.subcommands[schematicNames[0]].options;
124
- const schematicArgs = schematicOptions.filter((x) => x.positional !== undefined);
125
- const argDisplay = schematicArgs.length > 0
126
- ? ' ' + schematicArgs.map((a) => `<${core_1.strings.dasherize(a.name)}>`).join(' ')
127
- : '';
128
- this.logger.info(core_1.tags.oneLine `
129
- usage: ng ${this.description.name} ${displayName}${argDisplay}
130
- ${opts.length > 0 ? `[options]` : ``}
131
- `);
132
- this.logger.info('');
133
- }
134
- else {
135
- await super.printHelpUsage();
136
- }
137
- }
138
- getEngine() {
139
- return this._workflow.engine;
140
- }
141
- getCollection(collectionName) {
142
- const engine = this.getEngine();
143
- const collection = engine.createCollection(collectionName);
144
- if (collection === null) {
145
- throw new UnknownCollectionError(collectionName);
146
- }
147
- return collection;
148
- }
149
- getSchematic(collection, schematicName, allowPrivate) {
150
- return collection.createSchematic(schematicName, allowPrivate);
151
- }
152
- setPathOptions(options, workingDir) {
153
- if (workingDir === '') {
154
- return {};
155
- }
156
- return options
157
- .filter((o) => o.format === 'path')
158
- .map((o) => o.name)
159
- .reduce((acc, curr) => {
160
- acc[curr] = workingDir;
161
- return acc;
162
- }, {});
163
- }
164
- /*
165
- * Runtime hook to allow specifying customized workflow
166
- */
167
- async createWorkflow(options) {
168
- if (this._workflow) {
169
- return this._workflow;
170
- }
171
- const { force, dryRun } = options;
172
- const root = this.context.root;
173
- const workflow = new tools_1.NodeWorkflow(root, {
174
- force,
175
- dryRun,
176
- packageManager: await (0, package_manager_1.getPackageManager)(root),
177
- packageRegistry: options.packageRegistry,
178
- // A schema registry is required to allow customizing addUndefinedDefaults
179
- registry: new core_1.schema.CoreSchemaRegistry(schematics_1.formats.standardFormats),
180
- resolvePaths: this.workspace
181
- ? // Workspace
182
- this.collectionName === this.defaultCollectionName
183
- ? // Favor __dirname for @schematics/angular to use the build-in version
184
- [__dirname, process.cwd(), root]
185
- : [process.cwd(), root, __dirname]
186
- : // Global
187
- [__dirname, process.cwd()],
188
- schemaValidation: true,
189
- optionTransforms: [
190
- // Add configuration file defaults
191
- async (schematic, current) => {
192
- const projectName = typeof current.project === 'string'
193
- ? current.project
194
- : getProjectName();
195
- return {
196
- ...(await (0, config_1.getSchematicDefaults)(schematic.collection.name, schematic.name, projectName)),
197
- ...current,
198
- };
199
- },
200
- ],
201
- engineHostCreator: (options) => new schematic_engine_host_1.SchematicEngineHost(options.resolvePaths),
202
- });
203
- const getProjectName = () => {
204
- if (this.workspace) {
205
- const projectNames = getProjectsByPath(this.workspace, process.cwd(), this.workspace.basePath);
206
- if (projectNames.length === 1) {
207
- return projectNames[0];
208
- }
209
- else {
210
- if (projectNames.length > 1) {
211
- this.logger.warn(core_1.tags.oneLine `
212
- Two or more projects are using identical roots.
213
- Unable to determine project using current working directory.
214
- Using default workspace project instead.
215
- `);
216
- }
217
- const defaultProjectName = this.workspace.extensions['defaultProject'];
218
- if (typeof defaultProjectName === 'string' && defaultProjectName) {
219
- return defaultProjectName;
220
- }
221
- }
222
- }
223
- return undefined;
224
- };
225
- workflow.registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
226
- workflow.registry.addSmartDefaultProvider('projectName', getProjectName);
227
- workflow.registry.useXDeprecatedProvider((msg) => this.logger.warn(msg));
228
- let shouldReportAnalytics = true;
229
- workflow.engineHost.registerOptionsTransform(async (_, options) => {
230
- if (shouldReportAnalytics) {
231
- shouldReportAnalytics = false;
232
- await this.reportAnalytics([this.description.name], options);
233
- }
234
- return options;
235
- });
236
- if (options.interactive !== false && (0, tty_1.isTTY)()) {
237
- workflow.registry.usePromptProvider((definitions) => {
238
- const questions = definitions
239
- .filter((definition) => !options.defaults || definition.default === undefined)
240
- .map((definition) => {
241
- var _a;
242
- const question = {
243
- name: definition.id,
244
- message: definition.message,
245
- default: definition.default,
246
- };
247
- const validator = definition.validator;
248
- if (validator) {
249
- question.validate = (input) => validator(input);
250
- // Filter allows transformation of the value prior to validation
251
- question.filter = async (input) => {
252
- for (const type of definition.propertyTypes) {
253
- let value;
254
- switch (type) {
255
- case 'string':
256
- value = String(input);
257
- break;
258
- case 'integer':
259
- case 'number':
260
- value = Number(input);
261
- break;
262
- default:
263
- value = input;
264
- break;
265
- }
266
- // Can be a string if validation fails
267
- const isValid = (await validator(value)) === true;
268
- if (isValid) {
269
- return value;
270
- }
271
- }
272
- return input;
273
- };
274
- }
275
- switch (definition.type) {
276
- case 'confirmation':
277
- question.type = 'confirm';
278
- break;
279
- case 'list':
280
- question.type = definition.multiselect ? 'checkbox' : 'list';
281
- question.choices = (_a = definition.items) === null || _a === void 0 ? void 0 : _a.map((item) => {
282
- return typeof item == 'string'
283
- ? item
284
- : {
285
- name: item.label,
286
- value: item.value,
287
- };
288
- });
289
- break;
290
- default:
291
- question.type = definition.type;
292
- break;
293
- }
294
- return question;
295
- });
296
- return inquirer.prompt(questions);
297
- });
298
- }
299
- return (this._workflow = workflow);
300
- }
301
- async getDefaultSchematicCollection() {
302
- let workspace = await (0, config_1.getWorkspace)('local');
303
- if (workspace) {
304
- const project = (0, config_1.getProjectByCwd)(workspace);
305
- if (project && workspace.getProjectCli(project)) {
306
- const value = workspace.getProjectCli(project)['defaultCollection'];
307
- if (typeof value == 'string') {
308
- return value;
309
- }
310
- }
311
- if (workspace.getCli()) {
312
- const value = workspace.getCli()['defaultCollection'];
313
- if (typeof value == 'string') {
314
- return value;
315
- }
316
- }
317
- }
318
- workspace = await (0, config_1.getWorkspace)('global');
319
- if (workspace && workspace.getCli()) {
320
- const value = workspace.getCli()['defaultCollection'];
321
- if (typeof value == 'string') {
322
- return value;
323
- }
324
- }
325
- return this.defaultCollectionName;
326
- }
327
- async runSchematic(options) {
328
- const { schematicOptions, debug, dryRun } = options;
329
- let { collectionName, schematicName } = options;
330
- let nothingDone = true;
331
- let loggingQueue = [];
332
- let error = false;
333
- const workflow = this._workflow;
334
- const workingDir = (0, core_1.normalize)(systemPath.relative(this.context.root, process.cwd()));
335
- // Get the option object from the schematic schema.
336
- const schematic = this.getSchematic(this.getCollection(collectionName), schematicName, this.allowPrivateSchematics);
337
- // Update the schematic and collection name in case they're not the same as the ones we
338
- // received in our options, e.g. after alias resolution or extension.
339
- collectionName = schematic.collection.description.name;
340
- schematicName = schematic.description.name;
341
- // Set the options of format "path".
342
- let o = null;
343
- let args;
344
- if (!schematic.description.schemaJson) {
345
- args = await this.parseFreeFormArguments(schematicOptions || []);
346
- }
347
- else {
348
- o = await (0, json_schema_1.parseJsonSchemaToOptions)(workflow.registry, schematic.description.schemaJson);
349
- args = await this.parseArguments(schematicOptions || [], o);
350
- }
351
- const allowAdditionalProperties = typeof schematic.description.schemaJson === 'object' &&
352
- schematic.description.schemaJson.additionalProperties;
353
- if (args['--'] && !allowAdditionalProperties) {
354
- args['--'].forEach((additional) => {
355
- this.logger.fatal(`Unknown option: '${additional.split(/=/)[0]}'`);
356
- });
357
- return 1;
358
- }
359
- const pathOptions = o ? this.setPathOptions(o, workingDir) : {};
360
- const input = {
361
- ...pathOptions,
362
- ...args,
363
- ...options.additionalOptions,
364
- };
365
- workflow.reporter.subscribe((event) => {
366
- nothingDone = false;
367
- // Strip leading slash to prevent confusion.
368
- const eventPath = event.path.startsWith('/') ? event.path.substr(1) : event.path;
369
- switch (event.kind) {
370
- case 'error':
371
- error = true;
372
- const desc = event.description == 'alreadyExist' ? 'already exists' : 'does not exist.';
373
- this.logger.warn(`ERROR! ${eventPath} ${desc}.`);
374
- break;
375
- case 'update':
376
- loggingQueue.push(core_1.tags.oneLine `
377
- ${color_1.colors.cyan('UPDATE')} ${eventPath} (${event.content.length} bytes)
378
- `);
379
- break;
380
- case 'create':
381
- loggingQueue.push(core_1.tags.oneLine `
382
- ${color_1.colors.green('CREATE')} ${eventPath} (${event.content.length} bytes)
383
- `);
384
- break;
385
- case 'delete':
386
- loggingQueue.push(`${color_1.colors.yellow('DELETE')} ${eventPath}`);
387
- break;
388
- case 'rename':
389
- const eventToPath = event.to.startsWith('/') ? event.to.substr(1) : event.to;
390
- loggingQueue.push(`${color_1.colors.blue('RENAME')} ${eventPath} => ${eventToPath}`);
391
- break;
392
- }
393
- });
394
- workflow.lifeCycle.subscribe((event) => {
395
- if (event.kind == 'end' || event.kind == 'post-tasks-start') {
396
- if (!error) {
397
- // Output the logging queue, no error happened.
398
- loggingQueue.forEach((log) => this.logger.info(log));
399
- }
400
- loggingQueue = [];
401
- error = false;
402
- }
403
- });
404
- // Temporary compatibility check for NPM 7
405
- if (collectionName === '@schematics/angular' && schematicName === 'ng-new') {
406
- if (!input.skipInstall &&
407
- (input.packageManager === undefined || input.packageManager === 'npm')) {
408
- await (0, package_manager_1.ensureCompatibleNpm)(this.context.root);
409
- }
410
- }
411
- return new Promise((resolve) => {
412
- workflow
413
- .execute({
414
- collection: collectionName,
415
- schematic: schematicName,
416
- options: input,
417
- debug: debug,
418
- logger: this.logger,
419
- allowPrivate: this.allowPrivateSchematics,
420
- })
421
- .subscribe({
422
- error: (err) => {
423
- // In case the workflow was not successful, show an appropriate error message.
424
- if (err instanceof schematics_1.UnsuccessfulWorkflowExecution) {
425
- // "See above" because we already printed the error.
426
- this.logger.fatal('The Schematic workflow failed. See above.');
427
- }
428
- else if (debug) {
429
- this.logger.fatal(`An error occurred:\n${err.message}\n${err.stack}`);
430
- }
431
- else {
432
- this.logger.fatal(err.message);
433
- }
434
- resolve(1);
435
- },
436
- complete: () => {
437
- const showNothingDone = !(options.showNothingDone === false);
438
- if (nothingDone && showNothingDone) {
439
- this.logger.info('Nothing to be done.');
440
- }
441
- if (dryRun) {
442
- this.logger.warn(`\nNOTE: The "dryRun" flag means no changes were made.`);
443
- }
444
- resolve();
445
- },
446
- });
447
- });
448
- }
449
- async parseFreeFormArguments(schematicOptions) {
450
- return (0, parser_1.parseFreeFormArguments)(schematicOptions);
451
- }
452
- async parseArguments(schematicOptions, options) {
453
- return (0, parser_1.parseArguments)(schematicOptions, options, this.logger);
454
- }
455
- }
456
- exports.SchematicCommand = SchematicCommand;
457
- function getProjectsByPath(workspace, path, root) {
458
- if (workspace.projects.size === 1) {
459
- return Array.from(workspace.projects.keys());
460
- }
461
- const isInside = (base, potential) => {
462
- const absoluteBase = systemPath.resolve(root, base);
463
- const absolutePotential = systemPath.resolve(root, potential);
464
- const relativePotential = systemPath.relative(absoluteBase, absolutePotential);
465
- if (!relativePotential.startsWith('..') && !systemPath.isAbsolute(relativePotential)) {
466
- return true;
467
- }
468
- return false;
469
- };
470
- const projects = Array.from(workspace.projects.entries())
471
- .map(([name, project]) => [systemPath.resolve(root, project.root), name])
472
- .filter((tuple) => isInside(tuple[0], path))
473
- // Sort tuples by depth, with the deeper ones first. Since the first member is a path and
474
- // we filtered all invalid paths, the longest will be the deepest (and in case of equality
475
- // the sort is stable and the first declared project will win).
476
- .sort((a, b) => b[0].length - a[0].length);
477
- if (projects.length === 1) {
478
- return [projects[0][1]];
479
- }
480
- else if (projects.length > 1) {
481
- const firstPath = projects[0][0];
482
- return projects.filter((v) => v[0] === firstPath).map((v) => v[1]);
483
- }
484
- return [];
485
- }
@@ -1,8 +0,0 @@
1
- chore: initial commit from @angular/cli
2
-
3
- _ _ ____ _ ___
4
- / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
5
- / △ \ | '_ \ / _\` | | | | |/ _\` | '__| | | | | | |
6
- / ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
7
- /_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
8
- |___/
@@ -1,16 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { PackageManager } from '../lib/config/workspace-schema';
9
- import { NgAddSaveDepedency } from '../utilities/package-metadata';
10
- export declare function installAllPackages(packageManager?: PackageManager, extraArgs?: string[], cwd?: string): Promise<1 | 0>;
11
- export declare function installPackage(packageName: string, packageManager?: PackageManager, save?: Exclude<NgAddSaveDepedency, false>, extraArgs?: string[], cwd?: string): Promise<1 | 0>;
12
- export declare function installTempPackage(packageName: string, packageManager?: PackageManager, extraArgs?: string[]): Promise<{
13
- status: 1 | 0;
14
- tempNodeModules: string;
15
- }>;
16
- export declare function runTempPackageBin(packageName: string, packageManager?: PackageManager, args?: string[]): Promise<number>;