@angular/cli 14.1.0-next.0 → 14.1.0-next.3
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.
- package/lib/cli/index.js +2 -2
- package/lib/config/schema.json +667 -5
- package/lib/init.js +4 -2
- package/package.json +14 -14
- package/src/analytics/analytics.js +3 -0
- package/src/command-builder/architect-base-command-module.d.ts +1 -1
- package/src/command-builder/architect-base-command-module.js +4 -1
- package/src/command-builder/command-module.d.ts +3 -1
- package/src/command-builder/command-module.js +26 -3
- package/src/command-builder/command-runner.js +3 -22
- package/src/command-builder/schematics-command-module.d.ts +1 -1
- package/src/command-builder/schematics-command-module.js +3 -1
- package/src/command-builder/utilities/command.js +13 -2
- package/src/command-builder/utilities/schematic-engine-host.js +2 -0
- package/src/commands/add/cli.js +5 -0
- package/src/commands/cache/clean/cli.d.ts +1 -1
- package/src/commands/cache/clean/cli.js +1 -1
- package/src/commands/cache/cli.d.ts +1 -1
- package/src/commands/cache/cli.js +1 -1
- package/src/commands/cache/info/cli.d.ts +1 -1
- package/src/commands/cache/info/cli.js +1 -1
- package/src/commands/cache/settings/cli.d.ts +2 -2
- package/src/commands/cache/settings/cli.js +2 -2
- package/src/commands/completion/cli.js +2 -0
- package/src/commands/config/cli.js +2 -17
- package/src/commands/new/cli.d.ts +1 -1
- package/src/commands/new/cli.js +2 -2
- package/src/commands/run/cli.d.ts +1 -1
- package/src/commands/run/cli.js +11 -1
- package/src/commands/update/cli.d.ts +1 -1
- package/src/commands/update/cli.js +11 -1
- package/src/commands/update/schematic/index.js +3 -0
- package/src/utilities/color.js +0 -1
- package/src/utilities/completion.js +3 -0
- package/src/utilities/config.d.ts +1 -1
- package/src/utilities/config.js +9 -2
- package/src/utilities/error.d.ts +10 -0
- package/src/utilities/error.js +18 -0
package/src/commands/run/cli.js
CHANGED
|
@@ -14,6 +14,7 @@ const command_module_1 = require("../../command-builder/command-module");
|
|
|
14
14
|
class RunCommandModule extends architect_base_command_module_1.ArchitectBaseCommandModule {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(...arguments);
|
|
17
|
+
this.scope = command_module_1.CommandScope.In;
|
|
17
18
|
this.command = 'run <target>';
|
|
18
19
|
this.describe = 'Runs an Architect target with an optional custom builder configuration defined in your project.';
|
|
19
20
|
this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
|
|
@@ -29,6 +30,16 @@ class RunCommandModule extends architect_base_command_module_1.ArchitectBaseComm
|
|
|
29
30
|
// Also, hide choices from JSON help so that we don't display them in AIO.
|
|
30
31
|
choices: (getYargsCompletions || help) && !jsonHelp ? this.getTargetChoices() : undefined,
|
|
31
32
|
})
|
|
33
|
+
.middleware((args) => {
|
|
34
|
+
// TODO: remove in version 15.
|
|
35
|
+
const { configuration, target } = args;
|
|
36
|
+
if (typeof configuration === 'string' && target) {
|
|
37
|
+
const targetWithConfig = target.split(':', 2);
|
|
38
|
+
targetWithConfig.push(configuration);
|
|
39
|
+
throw new command_module_1.CommandModuleError('Unknown argument: configuration.\n' +
|
|
40
|
+
`Provide the configuration as part of the target 'ng run ${targetWithConfig.join(':')}'.`);
|
|
41
|
+
}
|
|
42
|
+
}, true)
|
|
32
43
|
.strict();
|
|
33
44
|
const target = this.makeTargetSpecifier();
|
|
34
45
|
if (!target) {
|
|
@@ -80,4 +91,3 @@ class RunCommandModule extends architect_base_command_module_1.ArchitectBaseComm
|
|
|
80
91
|
}
|
|
81
92
|
}
|
|
82
93
|
exports.RunCommandModule = RunCommandModule;
|
|
83
|
-
RunCommandModule.scope = command_module_1.CommandScope.In;
|
|
@@ -20,7 +20,7 @@ interface UpdateCommandArgs {
|
|
|
20
20
|
'create-commits': boolean;
|
|
21
21
|
}
|
|
22
22
|
export declare class UpdateCommandModule extends CommandModule<UpdateCommandArgs> {
|
|
23
|
-
|
|
23
|
+
scope: CommandScope;
|
|
24
24
|
protected shouldReportAnalytics: boolean;
|
|
25
25
|
command: string;
|
|
26
26
|
describe: string;
|
|
@@ -49,6 +49,7 @@ const schematic_engine_host_1 = require("../../command-builder/utilities/schemat
|
|
|
49
49
|
const schematic_workflow_1 = require("../../command-builder/utilities/schematic-workflow");
|
|
50
50
|
const color_1 = require("../../utilities/color");
|
|
51
51
|
const environment_options_1 = require("../../utilities/environment-options");
|
|
52
|
+
const error_1 = require("../../utilities/error");
|
|
52
53
|
const log_file_1 = require("../../utilities/log-file");
|
|
53
54
|
const package_metadata_1 = require("../../utilities/package-metadata");
|
|
54
55
|
const package_tree_1 = require("../../utilities/package-tree");
|
|
@@ -58,6 +59,7 @@ const UPDATE_SCHEMATIC_COLLECTION = path.join(__dirname, 'schematic/collection.j
|
|
|
58
59
|
class UpdateCommandModule extends command_module_1.CommandModule {
|
|
59
60
|
constructor() {
|
|
60
61
|
super(...arguments);
|
|
62
|
+
this.scope = command_module_1.CommandScope.In;
|
|
61
63
|
this.shouldReportAnalytics = false;
|
|
62
64
|
this.command = 'update [packages..]';
|
|
63
65
|
this.describe = 'Updates your workspace and its dependencies. See https://update.angular.io/.';
|
|
@@ -178,6 +180,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
178
180
|
packages.push(packageIdentifier);
|
|
179
181
|
}
|
|
180
182
|
catch (e) {
|
|
183
|
+
(0, error_1.assertIsError)(e);
|
|
181
184
|
logger.error(e.message);
|
|
182
185
|
return 1;
|
|
183
186
|
}
|
|
@@ -230,6 +233,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
230
233
|
logger.error(`${color_1.colors.symbols.cross} Migration failed. See above for further details.\n`);
|
|
231
234
|
}
|
|
232
235
|
else {
|
|
236
|
+
(0, error_1.assertIsError)(e);
|
|
233
237
|
const logPath = (0, log_file_1.writeErrorToLogFile)(e);
|
|
234
238
|
logger.fatal(`${color_1.colors.symbols.cross} Migration failed: ${e.message}\n` +
|
|
235
239
|
` See "${logPath}" for further details.\n`);
|
|
@@ -366,6 +370,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
366
370
|
migrations = require.resolve(migrations, { paths: [packagePath] });
|
|
367
371
|
}
|
|
368
372
|
catch (e) {
|
|
373
|
+
(0, error_1.assertIsError)(e);
|
|
369
374
|
if (e.code === 'MODULE_NOT_FOUND') {
|
|
370
375
|
logger.error('Migrations for package were not found.');
|
|
371
376
|
}
|
|
@@ -425,6 +430,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
425
430
|
});
|
|
426
431
|
}
|
|
427
432
|
catch (e) {
|
|
433
|
+
(0, error_1.assertIsError)(e);
|
|
428
434
|
logger.error(`Error fetching metadata for '${packageName}': ` + e.message);
|
|
429
435
|
return 1;
|
|
430
436
|
}
|
|
@@ -438,6 +444,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
438
444
|
manifest = (0, npm_pick_manifest_1.default)(metadata, requestIdentifier.fetchSpec);
|
|
439
445
|
}
|
|
440
446
|
catch (e) {
|
|
447
|
+
(0, error_1.assertIsError)(e);
|
|
441
448
|
if (e.code === 'ETARGET') {
|
|
442
449
|
// If not found and next was used and user did not provide a specifier, try latest.
|
|
443
450
|
// Package may not have a next tag.
|
|
@@ -448,6 +455,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
448
455
|
manifest = (0, npm_pick_manifest_1.default)(metadata, 'latest');
|
|
449
456
|
}
|
|
450
457
|
catch (e) {
|
|
458
|
+
(0, error_1.assertIsError)(e);
|
|
451
459
|
if (e.code !== 'ETARGET' && e.code !== 'ENOVERSIONS') {
|
|
452
460
|
throw e;
|
|
453
461
|
}
|
|
@@ -554,6 +562,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
554
562
|
}));
|
|
555
563
|
}
|
|
556
564
|
catch (e) {
|
|
565
|
+
(0, error_1.assertIsError)(e);
|
|
557
566
|
if (e.code === 'MODULE_NOT_FOUND') {
|
|
558
567
|
// Fallback to trying to resolve the package's main entry point
|
|
559
568
|
packagePath = require.resolve(migration.package, { paths: [this.context.root] });
|
|
@@ -564,6 +573,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
564
573
|
}
|
|
565
574
|
}
|
|
566
575
|
catch (e) {
|
|
576
|
+
(0, error_1.assertIsError)(e);
|
|
567
577
|
if (e.code === 'MODULE_NOT_FOUND') {
|
|
568
578
|
logVerbose(e.toString());
|
|
569
579
|
logger.error(`Migrations for package (${migration.package}) were not found.` +
|
|
@@ -587,6 +597,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
587
597
|
migrations = require.resolve(migration.collection, { paths: [packagePath] });
|
|
588
598
|
}
|
|
589
599
|
catch (e) {
|
|
600
|
+
(0, error_1.assertIsError)(e);
|
|
590
601
|
if (e.code === 'MODULE_NOT_FOUND') {
|
|
591
602
|
logger.error(`Migrations for package (${migration.package}) were not found.`);
|
|
592
603
|
}
|
|
@@ -740,7 +751,6 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
740
751
|
}
|
|
741
752
|
}
|
|
742
753
|
exports.UpdateCommandModule = UpdateCommandModule;
|
|
743
|
-
UpdateCommandModule.scope = command_module_1.CommandScope.In;
|
|
744
754
|
/**
|
|
745
755
|
* @return Whether or not the working directory has Git changes to commit.
|
|
746
756
|
*/
|
|
@@ -35,6 +35,7 @@ const core_1 = require("@angular-devkit/core");
|
|
|
35
35
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
36
36
|
const npa = __importStar(require("npm-package-arg"));
|
|
37
37
|
const semver = __importStar(require("semver"));
|
|
38
|
+
const error_1 = require("../../../utilities/error");
|
|
38
39
|
const package_metadata_1 = require("../../../utilities/package-metadata");
|
|
39
40
|
// Angular guarantees that a major is compatible with its following major (so packages that depend
|
|
40
41
|
// on Angular 5 are also compatible with Angular 6). This is, in code, represented by verifying
|
|
@@ -199,6 +200,7 @@ function _performUpdate(tree, context, infoMap, logger, migrateOnly) {
|
|
|
199
200
|
packageJson = JSON.parse(packageJsonContent.toString());
|
|
200
201
|
}
|
|
201
202
|
catch (e) {
|
|
203
|
+
(0, error_1.assertIsError)(e);
|
|
202
204
|
throw new schematics_1.SchematicsException('package.json could not be parsed: ' + e.message);
|
|
203
205
|
}
|
|
204
206
|
const updateDependency = (deps, name, newVersion) => {
|
|
@@ -588,6 +590,7 @@ function _getAllDependencies(tree) {
|
|
|
588
590
|
packageJson = JSON.parse(packageJsonContent.toString());
|
|
589
591
|
}
|
|
590
592
|
catch (e) {
|
|
593
|
+
(0, error_1.assertIsError)(e);
|
|
591
594
|
throw new schematics_1.SchematicsException('package.json could not be parsed: ' + e.message);
|
|
592
595
|
}
|
|
593
596
|
return [
|
package/src/utilities/color.js
CHANGED
|
@@ -64,7 +64,6 @@ function removeColor(text) {
|
|
|
64
64
|
}
|
|
65
65
|
exports.removeColor = removeColor;
|
|
66
66
|
// Create a separate instance to prevent unintended global changes to the color configuration
|
|
67
|
-
// Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44
|
|
68
67
|
const colors = ansiColors.create();
|
|
69
68
|
exports.colors = colors;
|
|
70
69
|
colors.enabled = supportColor();
|
|
@@ -40,6 +40,7 @@ const color_1 = require("../utilities/color");
|
|
|
40
40
|
const config_1 = require("../utilities/config");
|
|
41
41
|
const environment_options_1 = require("../utilities/environment-options");
|
|
42
42
|
const tty_1 = require("../utilities/tty");
|
|
43
|
+
const error_1 = require("./error");
|
|
43
44
|
/**
|
|
44
45
|
* Checks if it is appropriate to prompt the user to setup autocompletion. If not, does nothing. If
|
|
45
46
|
* so prompts and sets up autocompletion for the user. Returns an exit code if the program should
|
|
@@ -71,6 +72,7 @@ Ok, you won't be prompted again. Should you change your mind, the following comm
|
|
|
71
72
|
rcFile = await initializeAutocomplete();
|
|
72
73
|
}
|
|
73
74
|
catch (err) {
|
|
75
|
+
(0, error_1.assertIsError)(err);
|
|
74
76
|
// Failed to set up autocompeletion, log the error and abort.
|
|
75
77
|
logger.error(err.message);
|
|
76
78
|
return 1;
|
|
@@ -213,6 +215,7 @@ async function initializeAutocomplete() {
|
|
|
213
215
|
await fs_1.promises.appendFile(rcFile, '\n\n# Load Angular CLI autocompletion.\nsource <(ng completion script)\n');
|
|
214
216
|
}
|
|
215
217
|
catch (err) {
|
|
218
|
+
(0, error_1.assertIsError)(err);
|
|
216
219
|
throw new Error(`Failed to append autocompletion setup to \`${rcFile}\`:\n${err.message}`);
|
|
217
220
|
}
|
|
218
221
|
return rcFile;
|
|
@@ -31,7 +31,7 @@ export declare function getWorkspace(level: 'local' | 'global'): Promise<Angular
|
|
|
31
31
|
* NB: This method is intended to be used only for `ng config`.
|
|
32
32
|
*/
|
|
33
33
|
export declare function getWorkspaceRaw(level?: 'local' | 'global'): Promise<[JSONFile | null, string | null]>;
|
|
34
|
-
export declare function validateWorkspace(data: json.JsonObject): Promise<void>;
|
|
34
|
+
export declare function validateWorkspace(data: json.JsonObject, isGlobal: boolean): Promise<void>;
|
|
35
35
|
export declare function getProjectByCwd(workspace: AngularWorkspace): string | null;
|
|
36
36
|
export declare function getConfiguredPackageManager(): Promise<PackageManager | null>;
|
|
37
37
|
export declare function getSchematicDefaults(collection: string, schematic: string, project?: string | null): Promise<{}>;
|
package/src/utilities/config.js
CHANGED
|
@@ -200,11 +200,18 @@ async function getWorkspaceRaw(level = 'local') {
|
|
|
200
200
|
return [new json_file_1.JSONFile(configPath), configPath];
|
|
201
201
|
}
|
|
202
202
|
exports.getWorkspaceRaw = getWorkspaceRaw;
|
|
203
|
-
async function validateWorkspace(data) {
|
|
203
|
+
async function validateWorkspace(data, isGlobal) {
|
|
204
204
|
const schema = (0, json_file_1.readAndParseJson)(exports.workspaceSchemaPath);
|
|
205
|
+
// We should eventually have a dedicated global config schema and use that to validate.
|
|
206
|
+
const schemaToValidate = isGlobal
|
|
207
|
+
? {
|
|
208
|
+
'$ref': '#/definitions/global',
|
|
209
|
+
definitions: schema['definitions'],
|
|
210
|
+
}
|
|
211
|
+
: schema;
|
|
205
212
|
const { formats } = await Promise.resolve().then(() => __importStar(require('@angular-devkit/schematics')));
|
|
206
213
|
const registry = new core_1.json.schema.CoreSchemaRegistry(formats.standardFormats);
|
|
207
|
-
const validator = await registry.compile(
|
|
214
|
+
const validator = await registry.compile(schemaToValidate).toPromise();
|
|
208
215
|
const { success, errors } = await validator(data).toPromise();
|
|
209
216
|
if (!success) {
|
|
210
217
|
throw new core_1.json.schema.SchemaValidationException(errors);
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export declare function assertIsError(value: unknown): asserts value is Error & {
|
|
9
|
+
code?: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.assertIsError = void 0;
|
|
14
|
+
const assert_1 = __importDefault(require("assert"));
|
|
15
|
+
function assertIsError(value) {
|
|
16
|
+
(0, assert_1.default)(value instanceof Error, 'catch clause variable is not an Error instance');
|
|
17
|
+
}
|
|
18
|
+
exports.assertIsError = assertIsError;
|