@angular/cli 14.0.0-next.4 → 14.0.0-next.7
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/lib/cli/index.d.ts +1 -2
- package/lib/cli/index.js +16 -45
- package/lib/config/schema.json +30 -15
- package/lib/config/workspace-schema.d.ts +6 -1
- package/lib/init.js +10 -9
- package/package.json +18 -20
- package/{models → src/analytics}/analytics-collector.d.ts +0 -0
- package/{models → src/analytics}/analytics-collector.js +8 -2
- package/src/analytics/analytics.d.ts +47 -0
- package/src/analytics/analytics.js +304 -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 +89 -0
- package/src/command-builder/command-module.js +191 -0
- package/{utilities/package-json.js → src/command-builder/command-runner.d.ts} +2 -2
- package/src/command-builder/command-runner.js +152 -0
- package/src/command-builder/schematics-command-module.d.ts +46 -0
- package/src/command-builder/schematics-command-module.js +335 -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} +108 -80
- package/src/commands/add/long-description.md +7 -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/cache/clean/cli.d.ts +17 -0
- package/src/commands/cache/clean/cli.js +32 -0
- package/src/commands/cache/cli.d.ts +17 -0
- package/src/commands/cache/cli.js +38 -0
- package/src/commands/cache/info/cli.d.ts +20 -0
- package/src/commands/cache/info/cli.js +82 -0
- package/src/commands/cache/long-description.md +53 -0
- package/src/commands/cache/settings/cli.d.ts +27 -0
- package/src/commands/cache/settings/cli.js +42 -0
- package/src/commands/cache/utilities.d.ts +11 -0
- package/src/commands/cache/utilities.js +50 -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 +39 -0
- package/src/commands/generate/cli.js +145 -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 +27 -0
- package/src/commands/new/cli.js +77 -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} +26 -9
- package/{commands/update-impl.js → src/commands/update/cli.js} +362 -316
- package/{commands/update-long.md → src/commands/update/long-description.md} +0 -0
- package/src/commands/update/schematic/index.js +33 -20
- package/src/commands/version/cli.d.ts +18 -0
- package/{commands/version-impl.js → src/commands/version/cli.js} +56 -74
- package/src/typings-bazel.d.ts +14 -0
- package/src/typings.d.ts +1 -14
- 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 -2
- package/{utilities → src/utilities}/config.js +24 -16
- package/src/utilities/environment-options.d.ts +12 -0
- package/src/utilities/environment-options.js +24 -0
- package/{utilities → src/utilities}/find-up.d.ts +0 -0
- package/{utilities → src/utilities}/find-up.js +5 -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/src/utilities/package-manager.d.ts +41 -0
- package/src/utilities/package-manager.js +276 -0
- package/{utilities → src/utilities}/package-metadata.d.ts +15 -37
- package/{utilities → src/utilities}/package-metadata.js +15 -27
- package/{utilities → src/utilities}/package-tree.d.ts +2 -2
- 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 +7 -3
- 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/bin/postinstall/analytics-prompt.js +0 -27
- package/bin/postinstall/script.js +0 -16
- 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/add.md +0 -10
- 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/install-package.d.ts +0 -16
- package/utilities/install-package.js +0 -193
- package/utilities/json-schema.d.ts +0 -17
- package/utilities/package-json.d.ts +0 -249
- package/utilities/package-manager.d.ts +0 -13
- package/utilities/package-manager.js +0 -106
|
@@ -0,0 +1,276 @@
|
|
|
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.PackageManagerUtils = void 0;
|
|
11
|
+
const core_1 = require("@angular-devkit/core");
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const os_1 = require("os");
|
|
15
|
+
const path_1 = require("path");
|
|
16
|
+
const semver_1 = require("semver");
|
|
17
|
+
const workspace_schema_1 = require("../../lib/config/workspace-schema");
|
|
18
|
+
const config_1 = require("./config");
|
|
19
|
+
const spinner_1 = require("./spinner");
|
|
20
|
+
class PackageManagerUtils {
|
|
21
|
+
constructor(context) {
|
|
22
|
+
this.context = context;
|
|
23
|
+
}
|
|
24
|
+
/** Get the package manager name. */
|
|
25
|
+
get name() {
|
|
26
|
+
return this.getName();
|
|
27
|
+
}
|
|
28
|
+
/** Get the package manager version. */
|
|
29
|
+
get version() {
|
|
30
|
+
return this.getVersion(this.name);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Checks if the package manager is supported. If not, display a warning.
|
|
34
|
+
*/
|
|
35
|
+
ensureCompatibility() {
|
|
36
|
+
if (this.name !== workspace_schema_1.PackageManager.Npm) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const version = (0, semver_1.valid)(this.version);
|
|
41
|
+
if (!version) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if ((0, semver_1.satisfies)(version, '>=7 <7.5.6')) {
|
|
45
|
+
// eslint-disable-next-line no-console
|
|
46
|
+
console.warn(`npm version ${version} detected.` +
|
|
47
|
+
' When using npm 7 with the Angular CLI, npm version 7.5.6 or higher is recommended.');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// npm is not installed.
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Install a single package. */
|
|
55
|
+
async install(packageName, save = true, extraArgs = [], cwd) {
|
|
56
|
+
const packageManagerArgs = this.getArguments();
|
|
57
|
+
const installArgs = [
|
|
58
|
+
packageManagerArgs.install,
|
|
59
|
+
packageName,
|
|
60
|
+
packageManagerArgs.silent,
|
|
61
|
+
];
|
|
62
|
+
if (save === 'devDependencies') {
|
|
63
|
+
installArgs.push(packageManagerArgs.saveDev);
|
|
64
|
+
}
|
|
65
|
+
return this.run([...installArgs, ...extraArgs], cwd);
|
|
66
|
+
}
|
|
67
|
+
/** Install all packages. */
|
|
68
|
+
async installAll(extraArgs = [], cwd) {
|
|
69
|
+
const packageManagerArgs = this.getArguments();
|
|
70
|
+
const installArgs = [packageManagerArgs.silent];
|
|
71
|
+
if (packageManagerArgs.installAll) {
|
|
72
|
+
installArgs.push(packageManagerArgs.installAll);
|
|
73
|
+
}
|
|
74
|
+
return this.run([...installArgs, ...extraArgs], cwd);
|
|
75
|
+
}
|
|
76
|
+
/** Install a single package temporary. */
|
|
77
|
+
async installTemp(packageName, extraArgs) {
|
|
78
|
+
const tempPath = await fs_1.promises.mkdtemp((0, path_1.join)((0, fs_1.realpathSync)((0, os_1.tmpdir)()), 'angular-cli-packages-'));
|
|
79
|
+
// clean up temp directory on process exit
|
|
80
|
+
process.on('exit', () => {
|
|
81
|
+
try {
|
|
82
|
+
(0, fs_1.rmdirSync)(tempPath, { recursive: true, maxRetries: 3 });
|
|
83
|
+
}
|
|
84
|
+
catch { }
|
|
85
|
+
});
|
|
86
|
+
// NPM will warn when a `package.json` is not found in the install directory
|
|
87
|
+
// Example:
|
|
88
|
+
// npm WARN enoent ENOENT: no such file or directory, open '/tmp/.ng-temp-packages-84Qi7y/package.json'
|
|
89
|
+
// npm WARN .ng-temp-packages-84Qi7y No description
|
|
90
|
+
// npm WARN .ng-temp-packages-84Qi7y No repository field.
|
|
91
|
+
// npm WARN .ng-temp-packages-84Qi7y No license field.
|
|
92
|
+
// While we can use `npm init -y` we will end up needing to update the 'package.json' anyways
|
|
93
|
+
// because of missing fields.
|
|
94
|
+
await fs_1.promises.writeFile((0, path_1.join)(tempPath, 'package.json'), JSON.stringify({
|
|
95
|
+
name: 'temp-cli-install',
|
|
96
|
+
description: 'temp-cli-install',
|
|
97
|
+
repository: 'temp-cli-install',
|
|
98
|
+
license: 'MIT',
|
|
99
|
+
}));
|
|
100
|
+
// setup prefix/global modules path
|
|
101
|
+
const packageManagerArgs = this.getArguments();
|
|
102
|
+
const tempNodeModules = (0, path_1.join)(tempPath, 'node_modules');
|
|
103
|
+
// Yarn will not append 'node_modules' to the path
|
|
104
|
+
const prefixPath = this.name === workspace_schema_1.PackageManager.Yarn ? tempNodeModules : tempPath;
|
|
105
|
+
const installArgs = [
|
|
106
|
+
...(extraArgs !== null && extraArgs !== void 0 ? extraArgs : []),
|
|
107
|
+
`${packageManagerArgs.prefix}="${prefixPath}"`,
|
|
108
|
+
packageManagerArgs.noLockfile,
|
|
109
|
+
];
|
|
110
|
+
return {
|
|
111
|
+
success: await this.install(packageName, true, installArgs, tempPath),
|
|
112
|
+
tempNodeModules,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
getArguments() {
|
|
116
|
+
switch (this.name) {
|
|
117
|
+
case workspace_schema_1.PackageManager.Yarn:
|
|
118
|
+
return {
|
|
119
|
+
silent: '--silent',
|
|
120
|
+
saveDev: '--dev',
|
|
121
|
+
install: 'add',
|
|
122
|
+
prefix: '--modules-folder',
|
|
123
|
+
noLockfile: '--no-lockfile',
|
|
124
|
+
};
|
|
125
|
+
case workspace_schema_1.PackageManager.Pnpm:
|
|
126
|
+
return {
|
|
127
|
+
silent: '--silent',
|
|
128
|
+
saveDev: '--save-dev',
|
|
129
|
+
install: 'add',
|
|
130
|
+
installAll: 'install',
|
|
131
|
+
prefix: '--prefix',
|
|
132
|
+
noLockfile: '--no-lockfile',
|
|
133
|
+
};
|
|
134
|
+
default:
|
|
135
|
+
return {
|
|
136
|
+
silent: '--quiet',
|
|
137
|
+
saveDev: '--save-dev',
|
|
138
|
+
install: 'install',
|
|
139
|
+
installAll: 'install',
|
|
140
|
+
prefix: '--prefix',
|
|
141
|
+
noLockfile: '--no-package-lock',
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async run(args, cwd = process.cwd()) {
|
|
146
|
+
const spinner = new spinner_1.Spinner();
|
|
147
|
+
spinner.start('Installing packages...');
|
|
148
|
+
return new Promise((resolve) => {
|
|
149
|
+
var _a, _b;
|
|
150
|
+
const bufferedOutput = [];
|
|
151
|
+
const childProcess = (0, child_process_1.spawn)(this.name, args, {
|
|
152
|
+
stdio: 'pipe',
|
|
153
|
+
shell: true,
|
|
154
|
+
cwd,
|
|
155
|
+
}).on('close', (code) => {
|
|
156
|
+
if (code === 0) {
|
|
157
|
+
spinner.succeed('Packages successfully installed.');
|
|
158
|
+
resolve(true);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
spinner.stop();
|
|
162
|
+
bufferedOutput.forEach(({ stream, data }) => stream.write(data));
|
|
163
|
+
spinner.fail('Packages installation failed, see above.');
|
|
164
|
+
resolve(false);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
(_a = childProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => bufferedOutput.push({ stream: process.stdout, data: data }));
|
|
168
|
+
(_b = childProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => bufferedOutput.push({ stream: process.stderr, data: data }));
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
// TODO(alan-agius4): use the memoize decorator when it's merged.
|
|
172
|
+
getVersion(name) {
|
|
173
|
+
try {
|
|
174
|
+
return (0, child_process_1.execSync)(`${name} --version`, {
|
|
175
|
+
encoding: 'utf8',
|
|
176
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
177
|
+
env: {
|
|
178
|
+
...process.env,
|
|
179
|
+
// NPM updater notifier will prevents the child process from closing until it timeout after 3 minutes.
|
|
180
|
+
NO_UPDATE_NOTIFIER: '1',
|
|
181
|
+
NPM_CONFIG_UPDATE_NOTIFIER: 'false',
|
|
182
|
+
},
|
|
183
|
+
}).trim();
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// TODO(alan-agius4): use the memoize decorator when it's merged.
|
|
190
|
+
getName() {
|
|
191
|
+
const packageManager = this.getConfiguredPackageManager();
|
|
192
|
+
if (packageManager) {
|
|
193
|
+
return packageManager;
|
|
194
|
+
}
|
|
195
|
+
const hasNpmLock = this.hasLockfile(workspace_schema_1.PackageManager.Npm);
|
|
196
|
+
const hasYarnLock = this.hasLockfile(workspace_schema_1.PackageManager.Yarn);
|
|
197
|
+
const hasPnpmLock = this.hasLockfile(workspace_schema_1.PackageManager.Pnpm);
|
|
198
|
+
// PERF NOTE: `this.getVersion` spawns the package a the child_process which can take around ~300ms at times.
|
|
199
|
+
// Therefore, we should only call this method when needed. IE: don't call `this.getVersion(PackageManager.Pnpm)` unless truly needed.
|
|
200
|
+
// The result of this method is not stored in a variable because it's memoized.
|
|
201
|
+
if (hasNpmLock) {
|
|
202
|
+
// Has NPM lock file.
|
|
203
|
+
if (!hasYarnLock && !hasPnpmLock && this.getVersion(workspace_schema_1.PackageManager.Npm)) {
|
|
204
|
+
// Only NPM lock file and NPM binary is available.
|
|
205
|
+
return workspace_schema_1.PackageManager.Npm;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
// No NPM lock file.
|
|
210
|
+
if (hasYarnLock && this.getVersion(workspace_schema_1.PackageManager.Yarn)) {
|
|
211
|
+
// Yarn lock file and Yarn binary is available.
|
|
212
|
+
return workspace_schema_1.PackageManager.Yarn;
|
|
213
|
+
}
|
|
214
|
+
else if (hasPnpmLock && this.getVersion(workspace_schema_1.PackageManager.Pnpm)) {
|
|
215
|
+
// PNPM lock file and PNPM binary is available.
|
|
216
|
+
return workspace_schema_1.PackageManager.Pnpm;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (!this.getVersion(workspace_schema_1.PackageManager.Npm)) {
|
|
220
|
+
// Doesn't have NPM installed.
|
|
221
|
+
const hasYarn = !!this.getVersion(workspace_schema_1.PackageManager.Yarn);
|
|
222
|
+
const hasPnpm = !!this.getVersion(workspace_schema_1.PackageManager.Pnpm);
|
|
223
|
+
if (hasYarn && !hasPnpm) {
|
|
224
|
+
return workspace_schema_1.PackageManager.Yarn;
|
|
225
|
+
}
|
|
226
|
+
else if (!hasYarn && hasPnpm) {
|
|
227
|
+
return workspace_schema_1.PackageManager.Pnpm;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// TODO: This should eventually inform the user of ambiguous package manager usage.
|
|
231
|
+
// Potentially with a prompt to choose and optionally set as the default.
|
|
232
|
+
return workspace_schema_1.PackageManager.Npm;
|
|
233
|
+
}
|
|
234
|
+
hasLockfile(packageManager) {
|
|
235
|
+
let lockfileName;
|
|
236
|
+
switch (packageManager) {
|
|
237
|
+
case workspace_schema_1.PackageManager.Yarn:
|
|
238
|
+
lockfileName = 'yarn.lock';
|
|
239
|
+
break;
|
|
240
|
+
case workspace_schema_1.PackageManager.Pnpm:
|
|
241
|
+
lockfileName = 'pnpm-lock.yaml';
|
|
242
|
+
break;
|
|
243
|
+
case workspace_schema_1.PackageManager.Npm:
|
|
244
|
+
default:
|
|
245
|
+
lockfileName = 'package-lock.json';
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
return (0, fs_1.existsSync)((0, path_1.join)(this.context.root, lockfileName));
|
|
249
|
+
}
|
|
250
|
+
getConfiguredPackageManager() {
|
|
251
|
+
var _a;
|
|
252
|
+
const getPackageManager = (source) => {
|
|
253
|
+
if (source && (0, core_1.isJsonObject)(source)) {
|
|
254
|
+
const value = source['packageManager'];
|
|
255
|
+
if (typeof value === 'string') {
|
|
256
|
+
return value;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return undefined;
|
|
260
|
+
};
|
|
261
|
+
let result;
|
|
262
|
+
const { workspace: localWorkspace, globalConfiguration: globalWorkspace } = this.context;
|
|
263
|
+
if (localWorkspace) {
|
|
264
|
+
const project = (0, config_1.getProjectByCwd)(localWorkspace);
|
|
265
|
+
if (project) {
|
|
266
|
+
result = getPackageManager((_a = localWorkspace.projects.get(project)) === null || _a === void 0 ? void 0 : _a.extensions['cli']);
|
|
267
|
+
}
|
|
268
|
+
result !== null && result !== void 0 ? result : (result = getPackageManager(localWorkspace.extensions['cli']));
|
|
269
|
+
}
|
|
270
|
+
if (!result) {
|
|
271
|
+
result = getPackageManager(globalWorkspace === null || globalWorkspace === void 0 ? void 0 : globalWorkspace.extensions['cli']);
|
|
272
|
+
}
|
|
273
|
+
return result;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
exports.PackageManagerUtils = PackageManagerUtils;
|
|
@@ -6,24 +6,15 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { logging } from '@angular-devkit/core';
|
|
9
|
-
import {
|
|
10
|
-
export interface
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
description: string;
|
|
14
|
-
'dist-tags': {
|
|
15
|
-
[name: string]: string;
|
|
16
|
-
};
|
|
17
|
-
versions: {
|
|
18
|
-
[version: string]: JsonSchemaForNpmPackageJsonFiles;
|
|
19
|
-
};
|
|
20
|
-
time: {
|
|
21
|
-
modified: string;
|
|
22
|
-
created: string;
|
|
23
|
-
[version: string]: string;
|
|
24
|
-
};
|
|
9
|
+
import type { Manifest, Packument } from 'pacote';
|
|
10
|
+
export interface PackageMetadata extends Packument, NgPackageManifestProperties {
|
|
11
|
+
tags: Record<string, PackageManifest>;
|
|
12
|
+
versions: Record<string, PackageManifest>;
|
|
25
13
|
}
|
|
26
|
-
export
|
|
14
|
+
export interface NpmRepositoryPackageJson extends PackageMetadata {
|
|
15
|
+
requestedName?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare type NgAddSaveDependency = 'dependencies' | 'devDependencies' | boolean;
|
|
27
18
|
export interface PackageIdentifier {
|
|
28
19
|
type: 'git' | 'tag' | 'version' | 'range' | 'file' | 'directory' | 'remote';
|
|
29
20
|
name: string;
|
|
@@ -33,31 +24,18 @@ export interface PackageIdentifier {
|
|
|
33
24
|
fetchSpec: string;
|
|
34
25
|
rawSpec: string;
|
|
35
26
|
}
|
|
36
|
-
export interface
|
|
37
|
-
name: string;
|
|
38
|
-
version: string;
|
|
39
|
-
license?: string;
|
|
40
|
-
private?: boolean;
|
|
41
|
-
deprecated?: boolean;
|
|
42
|
-
dependencies: Record<string, string>;
|
|
43
|
-
devDependencies: Record<string, string>;
|
|
44
|
-
peerDependencies: Record<string, string>;
|
|
45
|
-
optionalDependencies: Record<string, string>;
|
|
27
|
+
export interface NgPackageManifestProperties {
|
|
46
28
|
'ng-add'?: {
|
|
47
|
-
save?:
|
|
29
|
+
save?: NgAddSaveDependency;
|
|
48
30
|
};
|
|
49
31
|
'ng-update'?: {
|
|
50
|
-
migrations
|
|
51
|
-
packageGroup
|
|
32
|
+
migrations?: string;
|
|
33
|
+
packageGroup?: string[] | Record<string, string>;
|
|
34
|
+
packageGroupName?: string;
|
|
35
|
+
requirements?: string[] | Record<string, string>;
|
|
52
36
|
};
|
|
53
37
|
}
|
|
54
|
-
export interface
|
|
55
|
-
name: string;
|
|
56
|
-
tags: {
|
|
57
|
-
[tag: string]: PackageManifest | undefined;
|
|
58
|
-
};
|
|
59
|
-
versions: Record<string, PackageManifest>;
|
|
60
|
-
'dist-tags'?: unknown;
|
|
38
|
+
export interface PackageManifest extends Manifest, NgPackageManifestProperties {
|
|
61
39
|
}
|
|
62
40
|
export declare function fetchPackageMetadata(name: string, logger: logging.LoggerApi, options?: {
|
|
63
41
|
registry?: string;
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
|
-
Object.
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
12
16
|
}) : (function(o, m, k, k2) {
|
|
13
17
|
if (k2 === undefined) k2 = k;
|
|
14
18
|
o[k2] = m[k];
|
|
@@ -31,10 +35,9 @@ const lockfile = __importStar(require("@yarnpkg/lockfile"));
|
|
|
31
35
|
const fs_1 = require("fs");
|
|
32
36
|
const ini = __importStar(require("ini"));
|
|
33
37
|
const os_1 = require("os");
|
|
34
|
-
const pacote = __importStar(require("pacote"));
|
|
35
38
|
const path = __importStar(require("path"));
|
|
36
|
-
const npmPackageJsonCache = new Map();
|
|
37
39
|
let npmrc;
|
|
40
|
+
const npmPackageJsonCache = new Map();
|
|
38
41
|
function ensureNpmrc(logger, usingYarn, verbose) {
|
|
39
42
|
if (!npmrc) {
|
|
40
43
|
try {
|
|
@@ -166,16 +169,6 @@ function normalizeOptions(rawOptions, location = process.cwd(), existingNormaliz
|
|
|
166
169
|
}
|
|
167
170
|
return options;
|
|
168
171
|
}
|
|
169
|
-
function normalizeManifest(rawManifest) {
|
|
170
|
-
// TODO: Fully normalize and sanitize
|
|
171
|
-
return {
|
|
172
|
-
dependencies: {},
|
|
173
|
-
devDependencies: {},
|
|
174
|
-
peerDependencies: {},
|
|
175
|
-
optionalDependencies: {},
|
|
176
|
-
...rawManifest,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
172
|
async function fetchPackageMetadata(name, logger, options) {
|
|
180
173
|
const { usingYarn, verbose, registry } = {
|
|
181
174
|
registry: undefined,
|
|
@@ -184,25 +177,18 @@ async function fetchPackageMetadata(name, logger, options) {
|
|
|
184
177
|
...options,
|
|
185
178
|
};
|
|
186
179
|
ensureNpmrc(logger, usingYarn, verbose);
|
|
187
|
-
const
|
|
180
|
+
const { packument } = await Promise.resolve().then(() => __importStar(require('pacote')));
|
|
181
|
+
const response = await packument(name, {
|
|
188
182
|
fullMetadata: true,
|
|
189
183
|
...npmrc,
|
|
190
184
|
...(registry ? { registry } : {}),
|
|
191
185
|
});
|
|
192
186
|
// Normalize the response
|
|
193
187
|
const metadata = {
|
|
194
|
-
|
|
188
|
+
...response,
|
|
195
189
|
tags: {},
|
|
196
|
-
versions: {},
|
|
197
190
|
};
|
|
198
|
-
if (response.versions) {
|
|
199
|
-
for (const [version, manifest] of Object.entries(response.versions)) {
|
|
200
|
-
metadata.versions[version] = normalizeManifest(manifest);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
191
|
if (response['dist-tags']) {
|
|
204
|
-
// Store this for use with other npm utility packages
|
|
205
|
-
metadata['dist-tags'] = response['dist-tags'];
|
|
206
192
|
for (const [tag, version] of Object.entries(response['dist-tags'])) {
|
|
207
193
|
const manifest = metadata.versions[version];
|
|
208
194
|
if (manifest) {
|
|
@@ -219,22 +205,24 @@ exports.fetchPackageMetadata = fetchPackageMetadata;
|
|
|
219
205
|
async function fetchPackageManifest(name, logger, options = {}) {
|
|
220
206
|
const { usingYarn = false, verbose = false, registry } = options;
|
|
221
207
|
ensureNpmrc(logger, usingYarn, verbose);
|
|
222
|
-
const
|
|
208
|
+
const { manifest } = await Promise.resolve().then(() => __importStar(require('pacote')));
|
|
209
|
+
const response = await manifest(name, {
|
|
223
210
|
fullMetadata: true,
|
|
224
211
|
...npmrc,
|
|
225
212
|
...(registry ? { registry } : {}),
|
|
226
213
|
});
|
|
227
|
-
return
|
|
214
|
+
return response;
|
|
228
215
|
}
|
|
229
216
|
exports.fetchPackageManifest = fetchPackageManifest;
|
|
230
|
-
function getNpmPackageJson(packageName, logger, options = {}) {
|
|
217
|
+
async function getNpmPackageJson(packageName, logger, options = {}) {
|
|
231
218
|
const cachedResponse = npmPackageJsonCache.get(packageName);
|
|
232
219
|
if (cachedResponse) {
|
|
233
220
|
return cachedResponse;
|
|
234
221
|
}
|
|
235
222
|
const { usingYarn = false, verbose = false, registry } = options;
|
|
236
223
|
ensureNpmrc(logger, usingYarn, verbose);
|
|
237
|
-
const
|
|
224
|
+
const { packument } = await Promise.resolve().then(() => __importStar(require('pacote')));
|
|
225
|
+
const resultPromise = packument(packageName, {
|
|
238
226
|
fullMetadata: true,
|
|
239
227
|
...npmrc,
|
|
240
228
|
...(registry ? { registry } : {}),
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { NgAddSaveDependency } from './package-metadata';
|
|
9
9
|
interface PackageJson {
|
|
10
10
|
name: string;
|
|
11
11
|
version: string;
|
|
@@ -17,7 +17,7 @@ interface PackageJson {
|
|
|
17
17
|
migrations?: string;
|
|
18
18
|
};
|
|
19
19
|
'ng-add'?: {
|
|
20
|
-
save?:
|
|
20
|
+
save?: NgAddSaveDependency;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
export interface PackageTreeNode {
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
|
-
Object.
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
12
16
|
}) : (function(o, m, k, k2) {
|
|
13
17
|
if (k2 === undefined) k2 = k;
|
|
14
18
|
o[k2] = m[k];
|
|
File without changes
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
|
-
Object.
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
12
16
|
}) : (function(o, m, k, k2) {
|
|
13
17
|
if (k2 === undefined) k2 = k;
|
|
14
18
|
o[k2] = m[k];
|
|
File without changes
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
|
-
Object.
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
12
16
|
}) : (function(o, m, k, k2) {
|
|
13
17
|
if (k2 === undefined) k2 = k;
|
|
14
18
|
o[k2] = m[k];
|
|
@@ -27,7 +31,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
27
31
|
};
|
|
28
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
33
|
exports.askConfirmation = void 0;
|
|
30
|
-
const inquirer = __importStar(require("inquirer"));
|
|
31
34
|
const tty_1 = require("./tty");
|
|
32
35
|
async function askConfirmation(message, defaultResponse, noTTYResponse) {
|
|
33
36
|
if (!(0, tty_1.isTTY)()) {
|
|
@@ -40,7 +43,8 @@ async function askConfirmation(message, defaultResponse, noTTYResponse) {
|
|
|
40
43
|
message,
|
|
41
44
|
default: defaultResponse,
|
|
42
45
|
};
|
|
43
|
-
const
|
|
46
|
+
const { prompt } = await Promise.resolve().then(() => __importStar(require('inquirer')));
|
|
47
|
+
const answers = await prompt([question]);
|
|
44
48
|
return answers['confirmation'];
|
|
45
49
|
}
|
|
46
50
|
exports.askConfirmation = askConfirmation;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
declare class Version {
|
|
9
9
|
readonly full: string;
|
|
10
10
|
readonly major: string;
|
|
11
11
|
readonly minor: string;
|
|
@@ -13,3 +13,4 @@ export declare class Version {
|
|
|
13
13
|
constructor(full: string);
|
|
14
14
|
}
|
|
15
15
|
export declare const VERSION: Version;
|
|
16
|
+
export {};
|
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.VERSION =
|
|
10
|
+
exports.VERSION = void 0;
|
|
11
11
|
const fs_1 = require("fs");
|
|
12
12
|
const path_1 = require("path");
|
|
13
13
|
// Same structure as used in framework packages
|
|
14
14
|
class Version {
|
|
15
15
|
constructor(full) {
|
|
16
16
|
this.full = full;
|
|
17
|
-
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
17
|
+
const [major, minor, patch] = full.split('-', 1)[0].split('.', 3);
|
|
18
|
+
this.major = major;
|
|
19
|
+
this.minor = minor;
|
|
20
|
+
this.patch = patch;
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
|
-
exports.Version = Version;
|
|
23
23
|
// TODO: Convert this to use build-time version stamping after flipping the build script to use bazel
|
|
24
24
|
// export const VERSION = new Version('0.0.0-PLACEHOLDER');
|
|
25
|
-
exports.VERSION = new Version(JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '
|
|
25
|
+
exports.VERSION = new Version(JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '../../package.json'), 'utf-8')).version);
|
|
@@ -1,27 +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
|
-
|
|
9
|
-
'use strict';
|
|
10
|
-
// This file is ES5 because it needs to be executed as is.
|
|
11
|
-
|
|
12
|
-
if ('NG_CLI_ANALYTICS' in process.env) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
var analytics = require('../../models/analytics');
|
|
18
|
-
|
|
19
|
-
analytics
|
|
20
|
-
.hasGlobalAnalyticsConfiguration()
|
|
21
|
-
.then((hasGlobalConfig) => {
|
|
22
|
-
if (!hasGlobalConfig) {
|
|
23
|
-
return analytics.promptGlobalAnalytics();
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
.catch(() => {});
|
|
27
|
-
} catch (_) {}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
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
|
-
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
// These should not fail but if they do they should not block installation of the package
|
|
13
|
-
try {
|
|
14
|
-
// eslint-disable-next-line import/no-unassigned-import
|
|
15
|
-
require('./analytics-prompt');
|
|
16
|
-
} catch (_) {}
|
package/commands/add-impl.d.ts
DELETED
|
@@ -1,21 +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 { Arguments } from '../models/interface';
|
|
9
|
-
import { SchematicCommand } from '../models/schematic-command';
|
|
10
|
-
import { Schema as AddCommandSchema } from './add';
|
|
11
|
-
export declare class AddCommand extends SchematicCommand<AddCommandSchema> {
|
|
12
|
-
readonly allowPrivateSchematics = true;
|
|
13
|
-
initialize(options: AddCommandSchema & Arguments): Promise<void>;
|
|
14
|
-
run(options: AddCommandSchema & Arguments): Promise<number | void>;
|
|
15
|
-
private isProjectVersionValid;
|
|
16
|
-
reportAnalytics(paths: string[], options: AddCommandSchema & Arguments, dimensions?: (boolean | number | string)[], metrics?: (boolean | number | string)[]): Promise<void>;
|
|
17
|
-
private isPackageInstalled;
|
|
18
|
-
private executeSchematic;
|
|
19
|
-
private findProjectVersion;
|
|
20
|
-
private hasMismatchedPeer;
|
|
21
|
-
}
|