@angular/cli 14.0.0-next.6 → 14.0.0-next.9

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