@angular/cli 14.0.0-next.5 → 14.0.0-next.8

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 (108) 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 +26 -7
  4. package/lib/config/workspace-schema.d.ts +6 -1
  5. package/lib/init.js +7 -6
  6. package/package.json +17 -20
  7. package/src/analytics/analytics-collector.js +7 -1
  8. package/src/analytics/analytics.d.ts +10 -23
  9. package/src/analytics/analytics.js +99 -184
  10. package/src/command-builder/architect-base-command-module.d.ts +8 -1
  11. package/src/command-builder/architect-base-command-module.js +61 -7
  12. package/src/command-builder/architect-command-module.d.ts +0 -1
  13. package/src/command-builder/architect-command-module.js +16 -12
  14. package/src/command-builder/command-module.d.ts +5 -2
  15. package/src/command-builder/command-module.js +21 -8
  16. package/src/command-builder/command-runner.d.ts +1 -2
  17. package/src/command-builder/command-runner.js +54 -48
  18. package/src/command-builder/schematics-command-module.d.ts +19 -7
  19. package/src/command-builder/schematics-command-module.js +268 -50
  20. package/src/command-builder/utilities/command.d.ts +13 -0
  21. package/src/command-builder/utilities/command.js +27 -0
  22. package/src/command-builder/utilities/json-help.d.ts +16 -14
  23. package/src/command-builder/utilities/json-help.js +26 -22
  24. package/{models → src/command-builder/utilities}/schematic-engine-host.d.ts +0 -0
  25. package/{models → src/command-builder/utilities}/schematic-engine-host.js +0 -0
  26. package/src/command-builder/utilities/schematic-workflow.d.ts +14 -0
  27. package/src/command-builder/utilities/schematic-workflow.js +68 -0
  28. package/src/commands/add/cli.d.ts +11 -1
  29. package/src/commands/add/cli.js +325 -6
  30. package/src/commands/add/long-description.md +1 -4
  31. package/src/commands/analytics/cli.d.ts +5 -10
  32. package/src/commands/analytics/cli.js +15 -50
  33. package/src/commands/analytics/info/cli.d.ts +16 -0
  34. package/src/commands/analytics/info/cli.js +26 -0
  35. package/src/commands/analytics/settings/cli.d.ts +35 -0
  36. package/src/commands/analytics/settings/cli.js +61 -0
  37. package/src/commands/cache/clean/cli.d.ts +17 -0
  38. package/src/commands/cache/clean/cli.js +32 -0
  39. package/src/commands/cache/cli.d.ts +17 -0
  40. package/src/commands/cache/cli.js +38 -0
  41. package/src/commands/cache/info/cli.d.ts +20 -0
  42. package/src/commands/cache/info/cli.js +82 -0
  43. package/src/commands/cache/long-description.md +53 -0
  44. package/src/commands/cache/settings/cli.d.ts +27 -0
  45. package/src/commands/cache/settings/cli.js +42 -0
  46. package/src/commands/cache/utilities.d.ts +11 -0
  47. package/src/commands/cache/utilities.js +50 -0
  48. package/src/commands/config/cli.d.ts +5 -2
  49. package/src/commands/config/cli.js +128 -6
  50. package/src/commands/deploy/cli.d.ts +2 -1
  51. package/src/commands/deploy/cli.js +27 -13
  52. package/src/commands/doc/cli.d.ts +1 -1
  53. package/src/commands/doc/cli.js +5 -1
  54. package/src/commands/e2e/cli.d.ts +3 -2
  55. package/src/commands/e2e/cli.js +14 -13
  56. package/src/commands/generate/cli.d.ts +14 -2
  57. package/src/commands/generate/cli.js +83 -36
  58. package/src/commands/lint/cli.d.ts +2 -1
  59. package/src/commands/lint/cli.js +6 -9
  60. package/src/commands/new/cli.d.ts +7 -3
  61. package/src/commands/new/cli.js +52 -6
  62. package/src/commands/update/cli.d.ts +31 -5
  63. package/src/commands/update/cli.js +709 -8
  64. package/src/commands/update/schematic/index.js +32 -19
  65. package/src/commands/version/cli.d.ts +0 -1
  66. package/src/commands/version/cli.js +19 -43
  67. package/src/typings-bazel.d.ts +14 -0
  68. package/src/typings.d.ts +0 -13
  69. package/src/utilities/color.js +5 -1
  70. package/src/utilities/config.d.ts +1 -1
  71. package/src/utilities/config.js +22 -11
  72. package/src/utilities/environment-options.d.ts +12 -0
  73. package/src/utilities/environment-options.js +24 -0
  74. package/src/utilities/find-up.js +5 -1
  75. package/src/utilities/memoize.d.ts +15 -0
  76. package/src/utilities/memoize.js +69 -0
  77. package/src/utilities/package-manager.d.ts +33 -5
  78. package/src/utilities/package-manager.js +252 -71
  79. package/src/utilities/package-metadata.d.ts +15 -37
  80. package/src/utilities/package-metadata.js +15 -27
  81. package/src/utilities/package-tree.d.ts +2 -2
  82. package/src/utilities/package-tree.js +5 -1
  83. package/src/utilities/project.js +5 -1
  84. package/src/utilities/prompt.d.ts +2 -0
  85. package/src/utilities/prompt.js +25 -4
  86. package/bin/postinstall/analytics-prompt.js +0 -27
  87. package/bin/postinstall/script.js +0 -16
  88. package/models/command.d.ts +0 -29
  89. package/models/command.js +0 -50
  90. package/models/interface.d.ts +0 -19
  91. package/models/interface.js +0 -9
  92. package/models/schematic-command.d.ts +0 -43
  93. package/models/schematic-command.js +0 -378
  94. package/src/commands/add/add-impl.d.ts +0 -22
  95. package/src/commands/add/add-impl.js +0 -331
  96. package/src/commands/analytics/long-description.md +0 -10
  97. package/src/commands/config/config-impl.d.ts +0 -17
  98. package/src/commands/config/config-impl.js +0 -151
  99. package/src/commands/generate/generate-impl.d.ts +0 -19
  100. package/src/commands/generate/generate-impl.js +0 -49
  101. package/src/commands/new/new-impl.d.ts +0 -18
  102. package/src/commands/new/new-impl.js +0 -38
  103. package/src/commands/update/update-impl.d.ts +0 -40
  104. package/src/commands/update/update-impl.js +0 -728
  105. package/src/utilities/install-package.d.ts +0 -16
  106. package/src/utilities/install-package.js +0 -193
  107. package/src/utilities/package-json.d.ts +0 -249
  108. package/src/utilities/package-json.js +0 -9
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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];
@@ -282,6 +286,7 @@ function _getUpdateMetadata(packageJson, logger) {
282
286
  }
283
287
  else if (typeof packageGroup == 'object' &&
284
288
  packageGroup &&
289
+ !Array.isArray(packageGroup) &&
285
290
  Object.values(packageGroup).every((x) => typeof x == 'string')) {
286
291
  result.packageGroup = packageGroup;
287
292
  }
@@ -358,23 +363,26 @@ function _usageMessage(options, infoMap, logger) {
358
363
  })
359
364
  .filter(({ info, version, target }) => (target === null || target === void 0 ? void 0 : target['ng-update']) && semver.compare(info.installed.version, version) < 0)
360
365
  .map(({ name, info, version, tag, target }) => {
361
- var _a;
366
+ var _a, _b, _c;
362
367
  // Look for packageGroup.
363
- const packageGroup = target['ng-update']['packageGroup'];
368
+ const packageGroup = (_a = target['ng-update']) === null || _a === void 0 ? void 0 : _a['packageGroup'];
364
369
  if (packageGroup) {
365
- const packageGroupName = target['ng-update']['packageGroupName'] || packageGroup[0];
370
+ const packageGroupNames = Array.isArray(packageGroup)
371
+ ? packageGroup
372
+ : Object.keys(packageGroup);
373
+ const packageGroupName = ((_b = target['ng-update']) === null || _b === void 0 ? void 0 : _b['packageGroupName']) || packageGroupNames[0];
366
374
  if (packageGroupName) {
367
375
  if (packageGroups.has(name)) {
368
376
  return null;
369
377
  }
370
- packageGroup.forEach((x) => packageGroups.set(x, packageGroupName));
378
+ packageGroupNames.forEach((x) => packageGroups.set(x, packageGroupName));
371
379
  packageGroups.set(packageGroupName, packageGroupName);
372
380
  name = packageGroupName;
373
381
  }
374
382
  }
375
383
  let command = `ng update ${name}`;
376
384
  if (!tag) {
377
- command += `@${((_a = semver.parse(version)) === null || _a === void 0 ? void 0 : _a.major) || version}`;
385
+ command += `@${((_c = semver.parse(version)) === null || _c === void 0 ? void 0 : _c.major) || version}`;
378
386
  }
379
387
  else if (tag == 'next') {
380
388
  command += ' --next';
@@ -504,29 +512,34 @@ function _addPackageGroup(tree, packages, allDependencies, npmPackageJson, logge
504
512
  if (!ngUpdateMetadata) {
505
513
  return;
506
514
  }
507
- let packageGroup = ngUpdateMetadata['packageGroup'];
515
+ const packageGroup = ngUpdateMetadata['packageGroup'];
508
516
  if (!packageGroup) {
509
517
  return;
510
518
  }
519
+ let packageGroupNormalized = {};
511
520
  if (Array.isArray(packageGroup) && !packageGroup.some((x) => typeof x != 'string')) {
512
- packageGroup = packageGroup.reduce((acc, curr) => {
521
+ packageGroupNormalized = packageGroup.reduce((acc, curr) => {
513
522
  acc[curr] = maybePackage;
514
523
  return acc;
515
524
  }, {});
516
525
  }
517
- // Only need to check if it's an object because we set it right the time before.
518
- if (typeof packageGroup != 'object' ||
519
- packageGroup === null ||
520
- Object.values(packageGroup).some((v) => typeof v != 'string')) {
521
- logger.warn(`packageGroup metadata of package ${npmPackageJson.name} is malformed.`);
526
+ else if (typeof packageGroup == 'object' &&
527
+ packageGroup &&
528
+ !Array.isArray(packageGroup) &&
529
+ Object.values(packageGroup).every((x) => typeof x == 'string')) {
530
+ packageGroupNormalized = packageGroup;
531
+ }
532
+ else {
533
+ logger.warn(`packageGroup metadata of package ${npmPackageJson.name} is malformed. Ignoring.`);
522
534
  return;
523
535
  }
524
- Object.keys(packageGroup)
525
- .filter((name) => !packages.has(name)) // Don't override names from the command line.
526
- .filter((name) => allDependencies.has(name)) // Remove packages that aren't installed.
527
- .forEach((name) => {
528
- packages.set(name, packageGroup[name]);
529
- });
536
+ for (const [name, value] of Object.entries(packageGroupNormalized)) {
537
+ // Don't override names from the command line.
538
+ // Remove packages that aren't installed.
539
+ if (!packages.has(name) && allDependencies.has(name)) {
540
+ packages.set(name, value);
541
+ }
542
+ }
530
543
  }
531
544
  /**
532
545
  * Add peer dependencies of packages on the command line to the list of packages to update.
@@ -15,5 +15,4 @@ export declare class VersionCommandModule extends CommandModule implements Comma
15
15
  builder(localYargs: Argv): Argv;
16
16
  run(): Promise<void>;
17
17
  private getVersion;
18
- private getPackageManagerVersion;
19
18
  }
@@ -11,12 +11,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.VersionCommandModule = void 0;
14
- const child_process_1 = require("child_process");
15
14
  const module_1 = __importDefault(require("module"));
16
15
  const path_1 = require("path");
17
16
  const command_module_1 = require("../../command-builder/command-module");
18
17
  const color_1 = require("../../utilities/color");
19
- const package_manager_1 = require("../../utilities/package-manager");
20
18
  /**
21
19
  * Major versions of Node.js that are officially supported by Angular.
22
20
  */
@@ -44,10 +42,11 @@ class VersionCommandModule extends command_module_1.CommandModule {
44
42
  return localYargs;
45
43
  }
46
44
  async run() {
47
- const logger = this.context.logger;
45
+ var _a;
46
+ const { packageManager, logger, root } = this.context;
48
47
  const localRequire = module_1.default.createRequire((0, path_1.resolve)(__filename, '../../../'));
49
48
  // Trailing slash is used to allow the path to be treated as a directory
50
- const workspaceRequire = module_1.default.createRequire(this.context.root + '/');
49
+ const workspaceRequire = module_1.default.createRequire(root + '/');
51
50
  const cliPackage = localRequire('./package.json');
52
51
  let workspacePackage;
53
52
  try {
@@ -56,21 +55,18 @@ class VersionCommandModule extends command_module_1.CommandModule {
56
55
  catch { }
57
56
  const [nodeMajor] = process.versions.node.split('.').map((part) => Number(part));
58
57
  const unsupportedNodeVersion = !SUPPORTED_NODE_MAJORS.includes(nodeMajor);
59
- const packageNames = [
60
- ...Object.keys(cliPackage.dependencies || {}),
61
- ...Object.keys(cliPackage.devDependencies || {}),
62
- ...Object.keys((workspacePackage === null || workspacePackage === void 0 ? void 0 : workspacePackage.dependencies) || {}),
63
- ...Object.keys((workspacePackage === null || workspacePackage === void 0 ? void 0 : workspacePackage.devDependencies) || {}),
64
- ];
65
- const versions = packageNames
66
- .filter((x) => PACKAGE_PATTERNS.some((p) => p.test(x)))
67
- .reduce((acc, name) => {
68
- if (name in acc) {
69
- return acc;
58
+ const packageNames = new Set(Object.keys({
59
+ ...cliPackage.dependencies,
60
+ ...cliPackage.devDependencies,
61
+ ...workspacePackage === null || workspacePackage === void 0 ? void 0 : workspacePackage.dependencies,
62
+ ...workspacePackage === null || workspacePackage === void 0 ? void 0 : workspacePackage.devDependencies,
63
+ }));
64
+ const versions = {};
65
+ for (const name of packageNames) {
66
+ if (PACKAGE_PATTERNS.some((p) => p.test(name))) {
67
+ versions[name] = this.getVersion(name, workspaceRequire, localRequire);
70
68
  }
71
- acc[name] = this.getVersion(name, workspaceRequire, localRequire);
72
- return acc;
73
- }, {});
69
+ }
74
70
  const ngCliVersion = cliPackage.version;
75
71
  let angularCoreVersion = '';
76
72
  const angularSameAsCore = [];
@@ -78,11 +74,10 @@ class VersionCommandModule extends command_module_1.CommandModule {
78
74
  // Filter all angular versions that are the same as core.
79
75
  angularCoreVersion = versions['@angular/core'];
80
76
  if (angularCoreVersion) {
81
- for (const angularPackage of Object.keys(versions)) {
82
- if (versions[angularPackage] == angularCoreVersion &&
83
- angularPackage.startsWith('@angular/')) {
84
- angularSameAsCore.push(angularPackage.replace(/^@angular\//, ''));
85
- delete versions[angularPackage];
77
+ for (const [name, version] of Object.entries(versions)) {
78
+ if (version === angularCoreVersion && name.startsWith('@angular/')) {
79
+ angularSameAsCore.push(name.replace(/^@angular\//, ''));
80
+ delete versions[name];
86
81
  }
87
82
  }
88
83
  // Make sure we list them in alphabetical order.
@@ -105,7 +100,7 @@ class VersionCommandModule extends command_module_1.CommandModule {
105
100
  logger.info(`
106
101
  Angular CLI: ${ngCliVersion}
107
102
  Node: ${process.versions.node}${unsupportedNodeVersion ? ' (Unsupported)' : ''}
108
- Package Manager: ${await this.getPackageManagerVersion()}
103
+ Package Manager: ${packageManager.name} ${(_a = packageManager.version) !== null && _a !== void 0 ? _a : '<error>'}
109
104
  OS: ${process.platform} ${process.arch}
110
105
 
111
106
  Angular: ${angularCoreVersion}
@@ -162,24 +157,5 @@ class VersionCommandModule extends command_module_1.CommandModule {
162
157
  }
163
158
  return '<error>';
164
159
  }
165
- async getPackageManagerVersion() {
166
- try {
167
- const manager = await (0, package_manager_1.getPackageManager)(this.context.root);
168
- const version = (0, child_process_1.execSync)(`${manager} --version`, {
169
- encoding: 'utf8',
170
- stdio: ['ignore', 'pipe', 'ignore'],
171
- env: {
172
- ...process.env,
173
- // NPM updater notifier will prevents the child process from closing until it timeout after 3 minutes.
174
- NO_UPDATE_NOTIFIER: '1',
175
- NPM_CONFIG_UPDATE_NOTIFIER: 'false',
176
- },
177
- }).trim();
178
- return `${manager} ${version}`;
179
- }
180
- catch {
181
- return '<error>';
182
- }
183
- }
184
160
  }
185
161
  exports.VersionCommandModule = VersionCommandModule;
@@ -0,0 +1,14 @@
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
+ /* eslint-disable import/no-extraneous-dependencies */
10
+ // Workaround for https://github.com/bazelbuild/rules_nodejs/issues/1033
11
+ // Alternative approach instead of https://github.com/angular/angular/pull/33226
12
+ declare module '@yarnpkg/lockfile' {
13
+ export * from '@types/yarnpkg__lockfile';
14
+ }
package/src/typings.d.ts CHANGED
@@ -5,20 +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
- declare module '@yarnpkg/lockfile' {
9
- function parse(data: string): Record<string, any>;
10
- }
11
- declare module 'ini' {
12
- function parse(data: string): Record<string, any>;
13
- }
14
8
  declare module 'npm-pick-manifest' {
15
9
  function pickManifest(metadata: import('./utilities/package-metadata').PackageMetadata, selector: string): import('./utilities/package-metadata').PackageManifest;
16
10
  export = pickManifest;
17
11
  }
18
- declare module 'pacote' {
19
- function manifest(specifier: string, options: Record<string, unknown>): Promise<{
20
- name: string;
21
- version: string;
22
- }>;
23
- function packument(specifier: string, options: Record<string, unknown>): Promise<import('./utilities/package-metadata').NpmRepositoryPackageJson>;
24
- }
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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];
@@ -20,7 +20,7 @@ export declare class AngularWorkspace {
20
20
  getProjectCli(projectName: string): Record<string, any>;
21
21
  static load(workspaceFilePath: string): Promise<AngularWorkspace>;
22
22
  }
23
- export declare function getWorkspace(level?: 'local' | 'global'): Promise<AngularWorkspace | null>;
23
+ export declare function getWorkspace(level?: 'local' | 'global'): Promise<AngularWorkspace | undefined>;
24
24
  export declare function createGlobalSettings(): string;
25
25
  export declare function getWorkspaceRaw(level?: 'local' | 'global'): [JSONFile | null, string | null];
26
26
  export declare function validateWorkspace(data: json.JsonObject): Promise<void>;
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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];
@@ -38,15 +42,16 @@ function isJsonObject(value) {
38
42
  }
39
43
  function createWorkspaceHost() {
40
44
  return {
41
- async readFile(path) {
42
- return (0, fs_1.readFileSync)(path, 'utf-8');
45
+ readFile(path) {
46
+ return fs_1.promises.readFile(path, 'utf-8');
43
47
  },
44
48
  async writeFile(path, data) {
45
- (0, fs_1.writeFileSync)(path, data);
49
+ await fs_1.promises.writeFile(path, data);
46
50
  },
47
51
  async isDirectory(path) {
48
52
  try {
49
- return (0, fs_1.statSync)(path).isDirectory();
53
+ const stats = await fs_1.promises.stat(path);
54
+ return stats.isDirectory();
50
55
  }
51
56
  catch {
52
57
  return false;
@@ -54,7 +59,8 @@ function createWorkspaceHost() {
54
59
  },
55
60
  async isFile(path) {
56
61
  try {
57
- return (0, fs_1.statSync)(path).isFile();
62
+ const stats = await fs_1.promises.stat(path);
63
+ return stats.isFile();
58
64
  }
59
65
  catch {
60
66
  return false;
@@ -143,14 +149,13 @@ class AngularWorkspace {
143
149
  exports.AngularWorkspace = AngularWorkspace;
144
150
  const cachedWorkspaces = new Map();
145
151
  async function getWorkspace(level = 'local') {
146
- const cached = cachedWorkspaces.get(level);
147
- if (cached !== undefined) {
148
- return cached;
152
+ if (cachedWorkspaces.has(level)) {
153
+ return cachedWorkspaces.get(level);
149
154
  }
150
155
  const configPath = level === 'local' ? projectFilePath() : globalFilePath();
151
156
  if (!configPath) {
152
- cachedWorkspaces.set(level, null);
153
- return null;
157
+ cachedWorkspaces.set(level, undefined);
158
+ return undefined;
154
159
  }
155
160
  try {
156
161
  const workspace = await AngularWorkspace.load(configPath);
@@ -233,6 +238,7 @@ function findProjectByPath(workspace, location) {
233
238
  }
234
239
  return projects[0][1];
235
240
  }
241
+ let defaultProjectDeprecationWarningShown = false;
236
242
  function getProjectByCwd(workspace) {
237
243
  if (workspace.projects.size === 1) {
238
244
  // If there is only one project, return that one.
@@ -245,6 +251,11 @@ function getProjectByCwd(workspace) {
245
251
  const defaultProject = workspace.extensions['defaultProject'];
246
252
  if (defaultProject && typeof defaultProject === 'string') {
247
253
  // If there is a default project name, return it.
254
+ if (!defaultProjectDeprecationWarningShown) {
255
+ console.warn(`DEPRECATED: The 'defaultProject' workspace option has been deprecated. ` +
256
+ `The project to use will be determined from the current working directory.`);
257
+ defaultProjectDeprecationWarningShown = true;
258
+ }
248
259
  return defaultProject;
249
260
  }
250
261
  return null;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ export declare const analyticsDisabled: boolean;
9
+ export declare const analyticsShareDisabled: boolean;
10
+ export declare const isCI: boolean;
11
+ export declare const disableVersionCheck: boolean;
12
+ export declare const ngDebug: boolean;
@@ -0,0 +1,24 @@
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.ngDebug = exports.disableVersionCheck = exports.isCI = exports.analyticsShareDisabled = exports.analyticsDisabled = void 0;
11
+ function isPresent(variable) {
12
+ return typeof variable === 'string' && variable !== '';
13
+ }
14
+ function isDisabled(variable) {
15
+ return isPresent(variable) && (variable === '0' || variable.toLowerCase() === 'false');
16
+ }
17
+ function isEnabled(variable) {
18
+ return isPresent(variable) && (variable === '1' || variable.toLowerCase() === 'true');
19
+ }
20
+ exports.analyticsDisabled = isDisabled(process.env['NG_CLI_ANALYTICS']);
21
+ exports.analyticsShareDisabled = isDisabled(process.env['NG_CLI_ANALYTICS_SHARE']);
22
+ exports.isCI = isEnabled(process.env['CI']);
23
+ exports.disableVersionCheck = isEnabled(process.env['NG_DISABLE_VERSION_CHECK']);
24
+ exports.ngDebug = isEnabled(process.env['NG_DEBUG']);
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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];
@@ -0,0 +1,15 @@
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
+ * A decorator that memoizes methods and getters.
10
+ *
11
+ * **Note**: Be cautious where and how to use this decorator as the size of the cache will grow unbounded.
12
+ *
13
+ * @see https://en.wikipedia.org/wiki/Memoization
14
+ */
15
+ export declare function memoize<T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
@@ -0,0 +1,69 @@
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.memoize = void 0;
11
+ /**
12
+ * A decorator that memoizes methods and getters.
13
+ *
14
+ * **Note**: Be cautious where and how to use this decorator as the size of the cache will grow unbounded.
15
+ *
16
+ * @see https://en.wikipedia.org/wiki/Memoization
17
+ */
18
+ function memoize(target, propertyKey, descriptor) {
19
+ const descriptorPropertyName = descriptor.get ? 'get' : 'value';
20
+ const originalMethod = descriptor[descriptorPropertyName];
21
+ if (typeof originalMethod !== 'function') {
22
+ throw new Error('Memoize decorator can only be used on methods or get accessors.');
23
+ }
24
+ const cache = new Map();
25
+ return {
26
+ ...descriptor,
27
+ [descriptorPropertyName]: function (...args) {
28
+ for (const arg of args) {
29
+ if (!isJSONSerializable(arg)) {
30
+ throw new Error(`Argument ${isNonPrimitive(arg) ? arg.toString() : arg} is JSON serializable.`);
31
+ }
32
+ }
33
+ const key = JSON.stringify(args);
34
+ if (cache.has(key)) {
35
+ return cache.get(key);
36
+ }
37
+ const result = originalMethod.apply(this, args);
38
+ cache.set(key, result);
39
+ return result;
40
+ },
41
+ };
42
+ }
43
+ exports.memoize = memoize;
44
+ /** Method to check if value is a non primitive. */
45
+ function isNonPrimitive(value) {
46
+ return ((value !== null && typeof value === 'object') ||
47
+ typeof value === 'function' ||
48
+ typeof value === 'symbol');
49
+ }
50
+ /** Method to check if the values are JSON serializable */
51
+ function isJSONSerializable(value) {
52
+ if (!isNonPrimitive(value)) {
53
+ // Can be seralized since it's a primitive.
54
+ return true;
55
+ }
56
+ let nestedValues;
57
+ if (Array.isArray(value)) {
58
+ // It's an array, check each item.
59
+ nestedValues = value;
60
+ }
61
+ else if (Object.prototype.toString.call(value) === '[object Object]') {
62
+ // It's a plain object, check each value.
63
+ nestedValues = Object.values(value);
64
+ }
65
+ if (!nestedValues || nestedValues.some((v) => !isJSONSerializable(v))) {
66
+ return false;
67
+ }
68
+ return true;
69
+ }
@@ -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
+ }