@angular/cli 14.0.0-next.3 → 14.0.0-next.6
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/bin/ng.js +3 -5
- package/bin/postinstall/analytics-prompt.js +3 -3
- package/lib/cli/index.d.ts +1 -1
- package/lib/cli/index.js +16 -18
- package/lib/config/schema.json +8 -12
- package/lib/config/workspace-schema.d.ts +1 -1
- package/lib/init.js +8 -4
- package/package.json +17 -16
- package/{models → src/analytics}/analytics-collector.d.ts +0 -0
- package/{models → src/analytics}/analytics-collector.js +6 -2
- package/src/analytics/analytics-environment-options.d.ts +9 -0
- package/src/analytics/analytics-environment-options.js +20 -0
- package/src/analytics/analytics.d.ts +47 -0
- package/src/analytics/analytics.js +303 -0
- package/src/command-builder/architect-base-command-module.d.ts +23 -0
- package/src/command-builder/architect-base-command-module.js +103 -0
- package/src/command-builder/architect-command-module.d.ts +22 -0
- package/src/command-builder/architect-command-module.js +108 -0
- package/src/command-builder/command-module.d.ts +88 -0
- package/src/command-builder/command-module.js +191 -0
- package/src/command-builder/command-runner.d.ts +10 -0
- package/src/command-builder/command-runner.js +135 -0
- package/src/command-builder/schematics-command-module.d.ts +44 -0
- package/src/command-builder/schematics-command-module.js +295 -0
- package/src/command-builder/utilities/command.d.ts +13 -0
- package/src/command-builder/utilities/command.js +27 -0
- package/src/command-builder/utilities/json-help.d.ts +36 -0
- package/src/command-builder/utilities/json-help.js +94 -0
- package/src/command-builder/utilities/json-schema.d.ts +40 -0
- package/{utilities → src/command-builder/utilities}/json-schema.js +20 -121
- package/{models → src/command-builder/utilities}/schematic-engine-host.d.ts +0 -0
- package/{models → src/command-builder/utilities}/schematic-engine-host.js +0 -0
- package/src/command-builder/utilities/schematic-workflow.d.ts +14 -0
- package/src/command-builder/utilities/schematic-workflow.js +68 -0
- package/src/commands/add/cli.d.ts +33 -0
- package/{commands/add-impl.js → src/commands/add/cli.js} +100 -72
- package/{commands/add.md → src/commands/add/long-description.md} +0 -0
- package/src/commands/analytics/cli.d.ts +16 -0
- package/src/commands/analytics/cli.js +35 -0
- package/src/commands/analytics/info/cli.d.ts +16 -0
- package/src/commands/analytics/info/cli.js +26 -0
- package/src/commands/analytics/settings/cli.d.ts +35 -0
- package/src/commands/analytics/settings/cli.js +61 -0
- package/src/commands/build/cli.d.ts +16 -0
- package/src/commands/build/cli.js +23 -0
- package/{commands/build-long.md → src/commands/build/long-description.md} +0 -0
- package/src/commands/config/cli.d.ts +24 -0
- package/{commands/config-impl.js → src/commands/config/cli.js} +102 -89
- package/{commands/config-long.md → src/commands/config/long-description.md} +2 -2
- package/src/commands/deploy/cli.d.ts +16 -0
- package/src/commands/deploy/cli.js +35 -0
- package/{commands/deploy-long.md → src/commands/deploy/long-description.md} +0 -0
- package/src/commands/doc/cli.d.ts +23 -0
- package/{commands/doc-impl.js → src/commands/doc/cli.js} +41 -12
- package/src/commands/e2e/cli.d.ts +17 -0
- package/src/commands/e2e/cli.js +34 -0
- package/src/commands/extract-i18n/cli.d.ts +15 -0
- package/src/commands/extract-i18n/cli.js +20 -0
- package/src/commands/generate/cli.d.ts +29 -0
- package/src/commands/generate/cli.js +114 -0
- package/src/commands/lint/cli.d.ts +16 -0
- package/src/commands/lint/cli.js +31 -0
- package/{commands/lint-long.md → src/commands/lint/long-description.md} +0 -0
- package/src/commands/make-this-awesome/cli.d.ts +17 -0
- package/{commands/easter-egg-impl.js → src/commands/make-this-awesome/cli.js} +17 -10
- package/src/commands/new/cli.d.ts +25 -0
- package/src/commands/new/cli.js +66 -0
- package/src/commands/run/cli.d.ts +23 -0
- package/src/commands/run/cli.js +59 -0
- package/{commands/run-long.md → src/commands/run/long-description.md} +0 -0
- package/src/commands/serve/cli.d.ts +16 -0
- package/src/commands/serve/cli.js +21 -0
- package/src/commands/test/cli.d.ts +16 -0
- package/src/commands/test/cli.js +23 -0
- package/{commands/test-long.md → src/commands/test/long-description.md} +0 -0
- package/{commands/update-impl.d.ts → src/commands/update/cli.d.ts} +25 -9
- package/{commands/update-impl.js → src/commands/update/cli.js} +323 -306
- package/{commands/update-long.md → src/commands/update/long-description.md} +0 -0
- package/src/commands/update/schematic/index.js +6 -2
- package/src/commands/version/cli.d.ts +19 -0
- package/{commands/version-impl.js → src/commands/version/cli.js} +57 -56
- package/src/typings.d.ts +2 -2
- package/{utilities → src/utilities}/color.d.ts +0 -0
- package/{utilities → src/utilities}/color.js +5 -1
- package/{utilities → src/utilities}/config.d.ts +2 -1
- package/{utilities → src/utilities}/config.js +38 -7
- package/{utilities → src/utilities}/find-up.d.ts +0 -0
- package/{utilities → src/utilities}/find-up.js +5 -1
- package/{utilities → src/utilities}/install-package.d.ts +2 -2
- package/{utilities → src/utilities}/install-package.js +1 -1
- package/{utilities → src/utilities}/json-file.d.ts +0 -0
- package/{utilities → src/utilities}/json-file.js +0 -0
- package/{utilities → src/utilities}/log-file.d.ts +0 -0
- package/{utilities → src/utilities}/log-file.js +0 -0
- package/{utilities → src/utilities}/package-json.d.ts +0 -0
- package/{utilities → src/utilities}/package-json.js +0 -0
- package/{utilities → src/utilities}/package-manager.d.ts +1 -1
- package/{utilities → src/utilities}/package-manager.js +1 -1
- package/{utilities → src/utilities}/package-metadata.d.ts +0 -0
- package/{utilities → src/utilities}/package-metadata.js +5 -1
- package/{utilities → src/utilities}/package-tree.d.ts +0 -0
- package/{utilities → src/utilities}/package-tree.js +5 -1
- package/{utilities → src/utilities}/project.d.ts +0 -0
- package/{utilities → src/utilities}/project.js +5 -1
- package/{utilities → src/utilities}/prompt.d.ts +0 -0
- package/{utilities → src/utilities}/prompt.js +5 -1
- package/{utilities → src/utilities}/spinner.d.ts +0 -0
- package/{utilities → src/utilities}/spinner.js +0 -0
- package/{utilities → src/utilities}/tty.d.ts +0 -0
- package/{utilities → src/utilities}/tty.js +0 -0
- package/{models → src/utilities}/version.d.ts +2 -1
- package/{models → src/utilities}/version.js +6 -6
- package/commands/add-impl.d.ts +0 -21
- package/commands/add.d.ts +0 -42
- package/commands/add.js +0 -10
- package/commands/add.json +0 -54
- package/commands/analytics-impl.d.ts +0 -13
- package/commands/analytics-impl.js +0 -80
- package/commands/analytics-long.md +0 -8
- package/commands/analytics.d.ts +0 -46
- package/commands/analytics.js +0 -31
- package/commands/analytics.json +0 -37
- package/commands/build-impl.d.ts +0 -14
- package/commands/build-impl.js +0 -21
- package/commands/build.d.ts +0 -30
- package/commands/build.js +0 -10
- package/commands/build.json +0 -16
- package/commands/config-impl.d.ts +0 -15
- package/commands/config.d.ts +0 -34
- package/commands/config.js +0 -10
- package/commands/config.json +0 -43
- package/commands/definitions.json +0 -66
- package/commands/deploy-impl.d.ts +0 -15
- package/commands/deploy-impl.js +0 -36
- package/commands/deploy.d.ts +0 -30
- package/commands/deploy.js +0 -10
- package/commands/deploy.json +0 -34
- package/commands/doc-impl.d.ts +0 -13
- package/commands/doc.d.ts +0 -39
- package/commands/doc.js +0 -14
- package/commands/doc.json +0 -46
- package/commands/e2e-impl.d.ts +0 -16
- package/commands/e2e-impl.js +0 -36
- package/commands/e2e-long.md +0 -4
- package/commands/e2e.d.ts +0 -29
- package/commands/e2e.js +0 -10
- package/commands/e2e.json +0 -17
- package/commands/easter-egg-impl.d.ts +0 -12
- package/commands/easter-egg.d.ts +0 -14
- package/commands/easter-egg.js +0 -10
- package/commands/easter-egg.json +0 -12
- package/commands/extract-i18n-impl.d.ts +0 -14
- package/commands/extract-i18n-impl.js +0 -21
- package/commands/extract-i18n.d.ts +0 -29
- package/commands/extract-i18n.js +0 -10
- package/commands/extract-i18n.json +0 -15
- package/commands/generate-impl.d.ts +0 -18
- package/commands/generate-impl.js +0 -89
- package/commands/generate.d.ts +0 -37
- package/commands/generate.js +0 -10
- package/commands/generate.json +0 -31
- package/commands/help-impl.d.ts +0 -12
- package/commands/help-impl.js +0 -26
- package/commands/help-long.md +0 -7
- package/commands/help.d.ts +0 -17
- package/commands/help.js +0 -10
- package/commands/help.json +0 -13
- package/commands/lint-impl.d.ts +0 -16
- package/commands/lint-impl.js +0 -69
- package/commands/lint.d.ts +0 -29
- package/commands/lint.js +0 -10
- package/commands/lint.json +0 -36
- package/commands/new-impl.d.ts +0 -16
- package/commands/new-impl.js +0 -37
- package/commands/new.d.ts +0 -41
- package/commands/new.js +0 -10
- package/commands/new.json +0 -34
- package/commands/new.md +0 -16
- package/commands/run-impl.d.ts +0 -13
- package/commands/run-impl.js +0 -22
- package/commands/run.d.ts +0 -30
- package/commands/run.js +0 -10
- package/commands/run.json +0 -36
- package/commands/serve-impl.d.ts +0 -15
- package/commands/serve-impl.js +0 -24
- package/commands/serve.d.ts +0 -29
- package/commands/serve.js +0 -10
- package/commands/serve.json +0 -17
- package/commands/test-impl.d.ts +0 -15
- package/commands/test-impl.js +0 -22
- package/commands/test.d.ts +0 -29
- package/commands/test.js +0 -10
- package/commands/test.json +0 -17
- package/commands/update.d.ts +0 -61
- package/commands/update.js +0 -10
- package/commands/update.json +0 -78
- package/commands/version-impl.d.ts +0 -17
- package/commands/version.d.ts +0 -17
- package/commands/version.js +0 -10
- package/commands/version.json +0 -13
- package/commands.json +0 -20
- package/models/analytics.d.ts +0 -58
- package/models/analytics.js +0 -358
- package/models/architect-command.d.ts +0 -35
- package/models/architect-command.js +0 -364
- package/models/command-runner.d.ts +0 -24
- package/models/command-runner.js +0 -241
- package/models/command.d.ts +0 -34
- package/models/command.js +0 -143
- package/models/interface.d.ts +0 -196
- package/models/interface.js +0 -31
- package/models/parser.d.ts +0 -39
- package/models/parser.js +0 -349
- package/models/schematic-command.d.ts +0 -55
- package/models/schematic-command.js +0 -485
- package/utilities/INITIAL_COMMIT_MESSAGE.txt +0 -8
- package/utilities/json-schema.d.ts +0 -17
|
@@ -10,22 +10,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
13
|
+
exports.AddCommandModule = void 0;
|
|
14
14
|
const core_1 = require("@angular-devkit/core");
|
|
15
15
|
const tools_1 = require("@angular-devkit/schematics/tools");
|
|
16
16
|
const npm_package_arg_1 = __importDefault(require("npm-package-arg"));
|
|
17
17
|
const path_1 = require("path");
|
|
18
18
|
const semver_1 = require("semver");
|
|
19
|
-
const workspace_schema_1 = require("
|
|
20
|
-
const analytics_1 = require("
|
|
21
|
-
const
|
|
22
|
-
const color_1 = require("
|
|
23
|
-
const install_package_1 = require("
|
|
24
|
-
const package_manager_1 = require("
|
|
25
|
-
const package_metadata_1 = require("
|
|
26
|
-
const prompt_1 = require("
|
|
27
|
-
const spinner_1 = require("
|
|
28
|
-
const tty_1 = require("
|
|
19
|
+
const workspace_schema_1 = require("../../../lib/config/workspace-schema");
|
|
20
|
+
const analytics_1 = require("../../analytics/analytics");
|
|
21
|
+
const schematics_command_module_1 = require("../../command-builder/schematics-command-module");
|
|
22
|
+
const color_1 = require("../../utilities/color");
|
|
23
|
+
const install_package_1 = require("../../utilities/install-package");
|
|
24
|
+
const package_manager_1 = require("../../utilities/package-manager");
|
|
25
|
+
const package_metadata_1 = require("../../utilities/package-metadata");
|
|
26
|
+
const prompt_1 = require("../../utilities/prompt");
|
|
27
|
+
const spinner_1 = require("../../utilities/spinner");
|
|
28
|
+
const tty_1 = require("../../utilities/tty");
|
|
29
29
|
/**
|
|
30
30
|
* The set of packages that should have certain versions excluded from consideration
|
|
31
31
|
* when attempting to find a compatible version for a package.
|
|
@@ -35,34 +35,64 @@ const packageVersionExclusions = {
|
|
|
35
35
|
// @angular/localize@9.x versions do not have peer dependencies setup
|
|
36
36
|
'@angular/localize': '9.x',
|
|
37
37
|
};
|
|
38
|
-
class
|
|
38
|
+
class AddCommandModule extends schematics_command_module_1.SchematicsCommandModule {
|
|
39
39
|
constructor() {
|
|
40
40
|
super(...arguments);
|
|
41
|
+
this.command = 'add <collection>';
|
|
42
|
+
this.describe = 'Adds support for an external library to your project.';
|
|
43
|
+
this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
|
|
41
44
|
this.allowPrivateSchematics = true;
|
|
45
|
+
this.schematicName = 'ng-add';
|
|
42
46
|
}
|
|
43
|
-
async
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
async builder(argv) {
|
|
48
|
+
const localYargs = (await super.builder(argv))
|
|
49
|
+
.positional('collection', {
|
|
50
|
+
description: 'The package to be added.',
|
|
51
|
+
type: 'string',
|
|
52
|
+
demandOption: true,
|
|
53
|
+
})
|
|
54
|
+
.option('registry', { description: 'The NPM registry to use.', type: 'string' })
|
|
55
|
+
.option('verbose', {
|
|
56
|
+
description: 'Display additional details about internal operations during execution.',
|
|
57
|
+
type: 'boolean',
|
|
58
|
+
default: false,
|
|
59
|
+
})
|
|
60
|
+
.option('skip-confirmation', {
|
|
61
|
+
description: 'Skip asking a confirmation prompt before installing and executing the package. ' +
|
|
62
|
+
'Ensure package name is correct prior to using this option.',
|
|
63
|
+
type: 'boolean',
|
|
64
|
+
default: false,
|
|
65
|
+
})
|
|
66
|
+
// Prior to downloading we don't know the full schema and therefore we cannot be strict on the options.
|
|
67
|
+
// Possibly in the future update the logic to use the following syntax:
|
|
68
|
+
// `ng add @angular/localize -- --package-options`.
|
|
69
|
+
.strict(false);
|
|
70
|
+
const collectionName = await this.getCollectionName();
|
|
71
|
+
const workflow = await this.getOrCreateWorkflowForBuilder(collectionName);
|
|
72
|
+
try {
|
|
73
|
+
const collection = workflow.engine.createCollection(collectionName);
|
|
74
|
+
const options = await this.getSchematicOptions(collection, this.schematicName, workflow);
|
|
75
|
+
return this.addSchemaOptionsToCommand(localYargs, options);
|
|
46
76
|
}
|
|
47
|
-
|
|
48
|
-
|
|
77
|
+
catch (error) {
|
|
78
|
+
// During `ng add` prior to the downloading of the package
|
|
79
|
+
// we are not able to resolve and create a collection.
|
|
80
|
+
// Or when the the collection value is a path to a tarball.
|
|
49
81
|
}
|
|
82
|
+
return localYargs;
|
|
50
83
|
}
|
|
51
84
|
// eslint-disable-next-line max-lines-per-function
|
|
52
85
|
async run(options) {
|
|
53
86
|
var _a;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
`${color_1.colors.yellow('ng add [name] ')}. For more details, use "ng help".`);
|
|
58
|
-
return 1;
|
|
59
|
-
}
|
|
87
|
+
const { root, logger, packageManager } = this.context;
|
|
88
|
+
const { verbose, registry, collection, skipConfirmation } = options;
|
|
89
|
+
await (0, package_manager_1.ensureCompatibleNpm)(root);
|
|
60
90
|
let packageIdentifier;
|
|
61
91
|
try {
|
|
62
|
-
packageIdentifier = (0, npm_package_arg_1.default)(
|
|
92
|
+
packageIdentifier = (0, npm_package_arg_1.default)(collection);
|
|
63
93
|
}
|
|
64
94
|
catch (e) {
|
|
65
|
-
|
|
95
|
+
logger.error(e.message);
|
|
66
96
|
return 1;
|
|
67
97
|
}
|
|
68
98
|
if (packageIdentifier.name &&
|
|
@@ -71,13 +101,12 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
71
101
|
const validVersion = await this.isProjectVersionValid(packageIdentifier);
|
|
72
102
|
if (validVersion) {
|
|
73
103
|
// Already installed so just run schematic
|
|
74
|
-
|
|
75
|
-
return this.executeSchematic(packageIdentifier.name
|
|
104
|
+
logger.info('Skipping installation: Package already installed');
|
|
105
|
+
return this.executeSchematic({ ...options, collection: packageIdentifier.name });
|
|
76
106
|
}
|
|
77
107
|
}
|
|
78
108
|
const spinner = new spinner_1.Spinner();
|
|
79
109
|
spinner.start('Determining package manager...');
|
|
80
|
-
const packageManager = await (0, package_manager_1.getPackageManager)(this.context.root);
|
|
81
110
|
const usingYarn = packageManager === workspace_schema_1.PackageManager.Yarn;
|
|
82
111
|
spinner.info(`Using package manager: ${color_1.colors.grey(packageManager)}`);
|
|
83
112
|
if (packageIdentifier.name && packageIdentifier.type === 'tag' && !packageIdentifier.rawSpec) {
|
|
@@ -86,14 +115,14 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
86
115
|
spinner.start('Searching for compatible package version...');
|
|
87
116
|
let packageMetadata;
|
|
88
117
|
try {
|
|
89
|
-
packageMetadata = await (0, package_metadata_1.fetchPackageMetadata)(packageIdentifier.name,
|
|
90
|
-
registry
|
|
118
|
+
packageMetadata = await (0, package_metadata_1.fetchPackageMetadata)(packageIdentifier.name, logger, {
|
|
119
|
+
registry,
|
|
91
120
|
usingYarn,
|
|
92
|
-
verbose
|
|
121
|
+
verbose,
|
|
93
122
|
});
|
|
94
123
|
}
|
|
95
124
|
catch (e) {
|
|
96
|
-
spinner.fail(
|
|
125
|
+
spinner.fail(`Unable to load package information from registry: ${e.message}`);
|
|
97
126
|
return 1;
|
|
98
127
|
}
|
|
99
128
|
// Start with the version tagged as `latest` if it exists
|
|
@@ -103,15 +132,6 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
103
132
|
}
|
|
104
133
|
// Adjust the version based on name and peer dependencies
|
|
105
134
|
if (latestManifest && Object.keys(latestManifest.peerDependencies).length === 0) {
|
|
106
|
-
if (latestManifest.name === '@angular/pwa') {
|
|
107
|
-
const version = await this.findProjectVersion('@angular/cli');
|
|
108
|
-
const semverOptions = { includePrerelease: true };
|
|
109
|
-
if (version &&
|
|
110
|
-
(((0, semver_1.validRange)(version) && (0, semver_1.intersects)(version, '7', semverOptions)) ||
|
|
111
|
-
((0, semver_1.valid)(version) && (0, semver_1.satisfies)(version, '7', semverOptions)))) {
|
|
112
|
-
packageIdentifier = npm_package_arg_1.default.resolve('@angular/pwa', '0.12');
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
135
|
spinner.succeed(`Found compatible package version: ${color_1.colors.grey(packageIdentifier.toString())}.`);
|
|
116
136
|
}
|
|
117
137
|
else if (!latestManifest || (await this.hasMismatchedPeer(latestManifest))) {
|
|
@@ -132,7 +152,7 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
132
152
|
}
|
|
133
153
|
return true;
|
|
134
154
|
});
|
|
135
|
-
versionManifests.sort((a, b) => (0, semver_1.
|
|
155
|
+
versionManifests.sort((a, b) => (0, semver_1.compare)(a.version, b.version, true));
|
|
136
156
|
let newIdentifier;
|
|
137
157
|
for (const versionManifest of versionManifests) {
|
|
138
158
|
if (!(await this.hasMismatchedPeer(versionManifest))) {
|
|
@@ -156,9 +176,9 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
156
176
|
let savePackage;
|
|
157
177
|
try {
|
|
158
178
|
spinner.start('Loading package information from registry...');
|
|
159
|
-
const manifest = await (0, package_metadata_1.fetchPackageManifest)(packageIdentifier.toString(),
|
|
160
|
-
registry
|
|
161
|
-
verbose
|
|
179
|
+
const manifest = await (0, package_metadata_1.fetchPackageManifest)(packageIdentifier.toString(), logger, {
|
|
180
|
+
registry,
|
|
181
|
+
verbose,
|
|
162
182
|
usingYarn,
|
|
163
183
|
});
|
|
164
184
|
savePackage = (_a = manifest['ng-add']) === null || _a === void 0 ? void 0 : _a.save;
|
|
@@ -174,23 +194,23 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
174
194
|
spinner.fail(`Unable to fetch package information for '${packageIdentifier}': ${e.message}`);
|
|
175
195
|
return 1;
|
|
176
196
|
}
|
|
177
|
-
if (!
|
|
197
|
+
if (!skipConfirmation) {
|
|
178
198
|
const confirmationResponse = await (0, prompt_1.askConfirmation)(`\nThe package ${color_1.colors.blue(packageIdentifier.raw)} will be installed and executed.\n` +
|
|
179
199
|
'Would you like to proceed?', true, false);
|
|
180
200
|
if (!confirmationResponse) {
|
|
181
201
|
if (!(0, tty_1.isTTY)()) {
|
|
182
|
-
|
|
202
|
+
logger.error('No terminal detected. ' +
|
|
183
203
|
`'--skip-confirmation' can be used to bypass installation confirmation. ` +
|
|
184
204
|
`Ensure package name is correct prior to '--skip-confirmation' option usage.`);
|
|
185
205
|
}
|
|
186
|
-
|
|
206
|
+
logger.error('Command aborted.');
|
|
187
207
|
return 1;
|
|
188
208
|
}
|
|
189
209
|
}
|
|
190
210
|
if (savePackage === false) {
|
|
191
211
|
// Temporary packages are located in a different directory
|
|
192
212
|
// Hence we need to resolve them using the temp path
|
|
193
|
-
const { status, tempNodeModules } = await (0, install_package_1.installTempPackage)(packageIdentifier.raw, packageManager,
|
|
213
|
+
const { status, tempNodeModules } = await (0, install_package_1.installTempPackage)(packageIdentifier.raw, packageManager, registry ? [`--registry="${registry}"`] : undefined);
|
|
194
214
|
const resolvedCollectionPath = require.resolve((0, path_1.join)(collectionName, 'package.json'), {
|
|
195
215
|
paths: [tempNodeModules],
|
|
196
216
|
});
|
|
@@ -200,12 +220,12 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
200
220
|
collectionName = (0, path_1.dirname)(resolvedCollectionPath);
|
|
201
221
|
}
|
|
202
222
|
else {
|
|
203
|
-
const status = await (0, install_package_1.installPackage)(packageIdentifier.raw, packageManager, savePackage,
|
|
223
|
+
const status = await (0, install_package_1.installPackage)(packageIdentifier.raw, packageManager, savePackage, registry ? [`--registry="${registry}"`] : undefined);
|
|
204
224
|
if (status !== 0) {
|
|
205
225
|
return status;
|
|
206
226
|
}
|
|
207
227
|
}
|
|
208
|
-
return this.executeSchematic(
|
|
228
|
+
return this.executeSchematic({ ...options, collection: collectionName });
|
|
209
229
|
}
|
|
210
230
|
async isProjectVersionValid(packageIdentifier) {
|
|
211
231
|
if (!packageIdentifier.name) {
|
|
@@ -228,16 +248,18 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
228
248
|
}
|
|
229
249
|
return validVersion;
|
|
230
250
|
}
|
|
231
|
-
async reportAnalytics(
|
|
232
|
-
const collection =
|
|
251
|
+
async reportAnalytics(options, paths) {
|
|
252
|
+
const collection = await this.getCollectionName();
|
|
253
|
+
const dimensions = [];
|
|
233
254
|
// Add the collection if it's safe listed.
|
|
234
255
|
if (collection && (0, analytics_1.isPackageNameSafeForAnalytics)(collection)) {
|
|
235
256
|
dimensions[core_1.analytics.NgCliAnalyticsDimensions.NgAddCollection] = collection;
|
|
236
257
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
258
|
+
return super.reportAnalytics(options, paths, dimensions);
|
|
259
|
+
}
|
|
260
|
+
async getCollectionName() {
|
|
261
|
+
const [, collectionName] = this.context.args.positional;
|
|
262
|
+
return collectionName;
|
|
241
263
|
}
|
|
242
264
|
isPackageInstalled(name) {
|
|
243
265
|
try {
|
|
@@ -251,20 +273,25 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
251
273
|
}
|
|
252
274
|
return false;
|
|
253
275
|
}
|
|
254
|
-
async executeSchematic(
|
|
255
|
-
const runOptions = {
|
|
256
|
-
schematicOptions: options,
|
|
257
|
-
collectionName,
|
|
258
|
-
schematicName: 'ng-add',
|
|
259
|
-
dryRun: false,
|
|
260
|
-
force: false,
|
|
261
|
-
};
|
|
276
|
+
async executeSchematic(options) {
|
|
262
277
|
try {
|
|
263
|
-
|
|
278
|
+
const { verbose, skipConfirmation, interactive, force, dryRun, registry, defaults, collection: collectionName, ...schematicOptions } = options;
|
|
279
|
+
return await this.runSchematic({
|
|
280
|
+
schematicOptions,
|
|
281
|
+
schematicName: this.schematicName,
|
|
282
|
+
collectionName,
|
|
283
|
+
executionOptions: {
|
|
284
|
+
interactive,
|
|
285
|
+
force,
|
|
286
|
+
dryRun,
|
|
287
|
+
defaults,
|
|
288
|
+
packageRegistry: registry,
|
|
289
|
+
},
|
|
290
|
+
});
|
|
264
291
|
}
|
|
265
292
|
catch (e) {
|
|
266
293
|
if (e instanceof tools_1.NodePackageDoesNotSupportSchematics) {
|
|
267
|
-
this.logger.error(core_1.tags.oneLine `
|
|
294
|
+
this.context.logger.error(core_1.tags.oneLine `
|
|
268
295
|
The package that you are trying to add does not support schematics. You can try using
|
|
269
296
|
a different version of the package or contact the package author to add ng-add support.
|
|
270
297
|
`);
|
|
@@ -274,23 +301,24 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
274
301
|
}
|
|
275
302
|
}
|
|
276
303
|
async findProjectVersion(name) {
|
|
304
|
+
const { logger, root } = this.context;
|
|
277
305
|
let installedPackage;
|
|
278
306
|
try {
|
|
279
307
|
installedPackage = require.resolve((0, path_1.join)(name, 'package.json'), {
|
|
280
|
-
paths: [
|
|
308
|
+
paths: [root],
|
|
281
309
|
});
|
|
282
310
|
}
|
|
283
311
|
catch { }
|
|
284
312
|
if (installedPackage) {
|
|
285
313
|
try {
|
|
286
|
-
const installed = await (0, package_metadata_1.fetchPackageManifest)((0, path_1.dirname)(installedPackage),
|
|
314
|
+
const installed = await (0, package_metadata_1.fetchPackageManifest)((0, path_1.dirname)(installedPackage), logger);
|
|
287
315
|
return installed.version;
|
|
288
316
|
}
|
|
289
317
|
catch { }
|
|
290
318
|
}
|
|
291
319
|
let projectManifest;
|
|
292
320
|
try {
|
|
293
|
-
projectManifest = await (0, package_metadata_1.fetchPackageManifest)(
|
|
321
|
+
projectManifest = await (0, package_metadata_1.fetchPackageManifest)(root, logger);
|
|
294
322
|
}
|
|
295
323
|
catch { }
|
|
296
324
|
if (projectManifest) {
|
|
@@ -308,7 +336,7 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
308
336
|
peerIdentifier = npm_package_arg_1.default.resolve(peer, manifest.peerDependencies[peer]);
|
|
309
337
|
}
|
|
310
338
|
catch {
|
|
311
|
-
this.logger.warn(`Invalid peer dependency ${peer} found in package.`);
|
|
339
|
+
this.context.logger.warn(`Invalid peer dependency ${peer} found in package.`);
|
|
312
340
|
continue;
|
|
313
341
|
}
|
|
314
342
|
if (peerIdentifier.type === 'version' || peerIdentifier.type === 'range') {
|
|
@@ -336,4 +364,4 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
336
364
|
return false;
|
|
337
365
|
}
|
|
338
366
|
}
|
|
339
|
-
exports.
|
|
367
|
+
exports.AddCommandModule = AddCommandModule;
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
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 { Argv } from 'yargs';
|
|
9
|
+
import { CommandModule, CommandModuleImplementation, Options } from '../../command-builder/command-module';
|
|
10
|
+
export declare class AnalyticsCommandModule extends CommandModule implements CommandModuleImplementation {
|
|
11
|
+
command: string;
|
|
12
|
+
describe: string;
|
|
13
|
+
longDescriptionPath?: string | undefined;
|
|
14
|
+
builder(localYargs: Argv): Argv;
|
|
15
|
+
run(_options: Options<{}>): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AnalyticsCommandModule = void 0;
|
|
11
|
+
const command_module_1 = require("../../command-builder/command-module");
|
|
12
|
+
const command_1 = require("../../command-builder/utilities/command");
|
|
13
|
+
const cli_1 = require("./info/cli");
|
|
14
|
+
const cli_2 = require("./settings/cli");
|
|
15
|
+
class AnalyticsCommandModule extends command_module_1.CommandModule {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.command = 'analytics';
|
|
19
|
+
this.describe = 'Configures the gathering of Angular CLI usage metrics. See https://angular.io/cli/usage-analytics-gathering';
|
|
20
|
+
}
|
|
21
|
+
builder(localYargs) {
|
|
22
|
+
const subcommands = [
|
|
23
|
+
cli_1.AnalyticsInfoCommandModule,
|
|
24
|
+
cli_2.AnalyticsDisableModule,
|
|
25
|
+
cli_2.AnalyticsEnableModule,
|
|
26
|
+
cli_2.AnalyticsPromptModule,
|
|
27
|
+
].sort(); // sort by class name.
|
|
28
|
+
for (const module of subcommands) {
|
|
29
|
+
localYargs = (0, command_1.addCommandModuleToYargs)(localYargs, module, this.context);
|
|
30
|
+
}
|
|
31
|
+
return localYargs.demandCommand(1, command_1.demandCommandFailureMessage).strict();
|
|
32
|
+
}
|
|
33
|
+
run(_options) { }
|
|
34
|
+
}
|
|
35
|
+
exports.AnalyticsCommandModule = AnalyticsCommandModule;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 { Argv } from 'yargs';
|
|
9
|
+
import { CommandModule, CommandModuleImplementation, Options } from '../../../command-builder/command-module';
|
|
10
|
+
export declare class AnalyticsInfoCommandModule extends CommandModule implements CommandModuleImplementation {
|
|
11
|
+
command: string;
|
|
12
|
+
describe: string;
|
|
13
|
+
longDescriptionPath?: string | undefined;
|
|
14
|
+
builder(localYargs: Argv): Argv;
|
|
15
|
+
run(_options: Options<{}>): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AnalyticsInfoCommandModule = void 0;
|
|
11
|
+
const analytics_1 = require("../../../analytics/analytics");
|
|
12
|
+
const command_module_1 = require("../../../command-builder/command-module");
|
|
13
|
+
class AnalyticsInfoCommandModule extends command_module_1.CommandModule {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.command = 'info';
|
|
17
|
+
this.describe = 'Prints analytics gathering and reporting configuration in the console.';
|
|
18
|
+
}
|
|
19
|
+
builder(localYargs) {
|
|
20
|
+
return localYargs.strict();
|
|
21
|
+
}
|
|
22
|
+
async run(_options) {
|
|
23
|
+
this.context.logger.info(await (0, analytics_1.getAnalyticsInfoString)());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.AnalyticsInfoCommandModule = AnalyticsInfoCommandModule;
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { Argv } from 'yargs';
|
|
9
|
+
import { CommandModule, CommandModuleImplementation, Options } from '../../../command-builder/command-module';
|
|
10
|
+
interface AnalyticsCommandArgs {
|
|
11
|
+
global: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare abstract class AnalyticsSettingModule extends CommandModule<AnalyticsCommandArgs> implements CommandModuleImplementation<AnalyticsCommandArgs> {
|
|
14
|
+
longDescriptionPath?: string | undefined;
|
|
15
|
+
builder(localYargs: Argv): Argv<AnalyticsCommandArgs>;
|
|
16
|
+
abstract run({ global }: Options<AnalyticsCommandArgs>): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare class AnalyticsDisableModule extends AnalyticsSettingModule implements CommandModuleImplementation<AnalyticsCommandArgs> {
|
|
19
|
+
command: string;
|
|
20
|
+
aliases: string;
|
|
21
|
+
describe: string;
|
|
22
|
+
run({ global }: Options<AnalyticsCommandArgs>): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export declare class AnalyticsEnableModule extends AnalyticsSettingModule implements CommandModuleImplementation<AnalyticsCommandArgs> {
|
|
25
|
+
command: string;
|
|
26
|
+
aliases: string;
|
|
27
|
+
describe: string;
|
|
28
|
+
run({ global }: Options<AnalyticsCommandArgs>): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export declare class AnalyticsPromptModule extends AnalyticsSettingModule implements CommandModuleImplementation<AnalyticsCommandArgs> {
|
|
31
|
+
command: string;
|
|
32
|
+
describe: string;
|
|
33
|
+
run({ global }: Options<AnalyticsCommandArgs>): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AnalyticsPromptModule = exports.AnalyticsEnableModule = exports.AnalyticsDisableModule = void 0;
|
|
11
|
+
const analytics_1 = require("../../../analytics/analytics");
|
|
12
|
+
const command_module_1 = require("../../../command-builder/command-module");
|
|
13
|
+
class AnalyticsSettingModule extends command_module_1.CommandModule {
|
|
14
|
+
builder(localYargs) {
|
|
15
|
+
return localYargs
|
|
16
|
+
.option('global', {
|
|
17
|
+
description: `Configure analytics gathering and reporting globally in the caller's home directory.`,
|
|
18
|
+
alias: ['g'],
|
|
19
|
+
type: 'boolean',
|
|
20
|
+
default: false,
|
|
21
|
+
})
|
|
22
|
+
.strict();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
class AnalyticsDisableModule extends AnalyticsSettingModule {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.command = 'disable';
|
|
29
|
+
this.aliases = 'off';
|
|
30
|
+
this.describe = 'Disables analytics gathering and reporting for the user.';
|
|
31
|
+
}
|
|
32
|
+
async run({ global }) {
|
|
33
|
+
(0, analytics_1.setAnalyticsConfig)(global, false);
|
|
34
|
+
process.stderr.write(await (0, analytics_1.getAnalyticsInfoString)());
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.AnalyticsDisableModule = AnalyticsDisableModule;
|
|
38
|
+
class AnalyticsEnableModule extends AnalyticsSettingModule {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments);
|
|
41
|
+
this.command = 'enable';
|
|
42
|
+
this.aliases = 'on';
|
|
43
|
+
this.describe = 'Enables analytics gathering and reporting for the user.';
|
|
44
|
+
}
|
|
45
|
+
async run({ global }) {
|
|
46
|
+
(0, analytics_1.setAnalyticsConfig)(global, true);
|
|
47
|
+
process.stderr.write(await (0, analytics_1.getAnalyticsInfoString)());
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.AnalyticsEnableModule = AnalyticsEnableModule;
|
|
51
|
+
class AnalyticsPromptModule extends AnalyticsSettingModule {
|
|
52
|
+
constructor() {
|
|
53
|
+
super(...arguments);
|
|
54
|
+
this.command = 'prompt';
|
|
55
|
+
this.describe = 'Prompts the user to set the analytics gathering status interactively.';
|
|
56
|
+
}
|
|
57
|
+
async run({ global }) {
|
|
58
|
+
await (0, analytics_1.promptAnalytics)(global, true);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.AnalyticsPromptModule = AnalyticsPromptModule;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 { ArchitectCommandModule } from '../../command-builder/architect-command-module';
|
|
9
|
+
import { CommandModuleImplementation } from '../../command-builder/command-module';
|
|
10
|
+
export declare class BuildCommandModule extends ArchitectCommandModule implements CommandModuleImplementation {
|
|
11
|
+
multiTarget: boolean;
|
|
12
|
+
command: string;
|
|
13
|
+
aliases: string[];
|
|
14
|
+
describe: string;
|
|
15
|
+
longDescriptionPath: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.BuildCommandModule = void 0;
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
const architect_command_module_1 = require("../../command-builder/architect-command-module");
|
|
13
|
+
class BuildCommandModule extends architect_command_module_1.ArchitectCommandModule {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.multiTarget = false;
|
|
17
|
+
this.command = 'build [project]';
|
|
18
|
+
this.aliases = ['b'];
|
|
19
|
+
this.describe = 'Compiles an Angular application or library into an output directory named dist/ at the given output path.';
|
|
20
|
+
this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.BuildCommandModule = BuildCommandModule;
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { Argv } from 'yargs';
|
|
9
|
+
import { CommandModule, CommandModuleImplementation, Options } from '../../command-builder/command-module';
|
|
10
|
+
interface ConfigCommandArgs {
|
|
11
|
+
'json-path': string;
|
|
12
|
+
value?: string;
|
|
13
|
+
global?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare class ConfigCommandModule extends CommandModule<ConfigCommandArgs> implements CommandModuleImplementation<ConfigCommandArgs> {
|
|
16
|
+
command: string;
|
|
17
|
+
describe: string;
|
|
18
|
+
longDescriptionPath: string;
|
|
19
|
+
builder(localYargs: Argv): Argv<ConfigCommandArgs>;
|
|
20
|
+
run(options: Options<ConfigCommandArgs>): Promise<number | void>;
|
|
21
|
+
private get;
|
|
22
|
+
private set;
|
|
23
|
+
}
|
|
24
|
+
export {};
|