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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/bin/postinstall/analytics-prompt.js +2 -2
  2. package/lib/config/schema.json +4 -4
  3. package/lib/config/workspace-schema.d.ts +1 -1
  4. package/lib/init.js +5 -1
  5. package/package.json +13 -13
  6. package/src/analytics/analytics-collector.js +5 -1
  7. package/{models/interface.js → src/analytics/analytics-environment-options.d.ts} +2 -2
  8. package/src/analytics/analytics-environment-options.js +20 -0
  9. package/src/analytics/analytics.d.ts +10 -23
  10. package/src/analytics/analytics.js +96 -182
  11. package/src/command-builder/architect-base-command-module.js +3 -5
  12. package/src/command-builder/architect-command-module.js +4 -6
  13. package/src/command-builder/command-module.d.ts +4 -1
  14. package/src/command-builder/command-module.js +9 -3
  15. package/src/command-builder/command-runner.js +9 -20
  16. package/src/command-builder/schematics-command-module.d.ts +18 -5
  17. package/src/command-builder/schematics-command-module.js +207 -29
  18. package/src/command-builder/utilities/command.d.ts +13 -0
  19. package/src/command-builder/utilities/command.js +27 -0
  20. package/src/command-builder/utilities/json-help.d.ts +16 -14
  21. package/src/command-builder/utilities/json-help.js +26 -22
  22. package/{models → src/command-builder/utilities}/schematic-engine-host.d.ts +0 -0
  23. package/{models → src/command-builder/utilities}/schematic-engine-host.js +0 -0
  24. package/src/command-builder/utilities/schematic-workflow.d.ts +14 -0
  25. package/src/command-builder/utilities/schematic-workflow.js +68 -0
  26. package/src/commands/add/cli.d.ts +11 -1
  27. package/src/commands/add/cli.js +325 -6
  28. package/src/commands/analytics/cli.d.ts +5 -10
  29. package/src/commands/analytics/cli.js +15 -50
  30. package/src/commands/analytics/info/cli.d.ts +16 -0
  31. package/src/commands/analytics/info/cli.js +26 -0
  32. package/src/commands/analytics/settings/cli.d.ts +35 -0
  33. package/src/commands/analytics/settings/cli.js +61 -0
  34. package/src/commands/config/cli.d.ts +4 -1
  35. package/src/commands/config/cli.js +126 -4
  36. package/src/commands/doc/cli.js +5 -1
  37. package/src/commands/generate/cli.d.ts +4 -2
  38. package/src/commands/generate/cli.js +37 -21
  39. package/src/commands/new/cli.d.ts +5 -3
  40. package/src/commands/new/cli.js +36 -6
  41. package/src/commands/update/cli.d.ts +30 -5
  42. package/src/commands/update/cli.js +680 -9
  43. package/src/commands/update/schematic/index.js +5 -1
  44. package/src/commands/version/cli.js +18 -23
  45. package/src/utilities/color.js +5 -1
  46. package/src/utilities/config.d.ts +1 -0
  47. package/src/utilities/config.js +36 -2
  48. package/src/utilities/find-up.js +5 -1
  49. package/src/utilities/package-metadata.js +5 -1
  50. package/src/utilities/package-tree.js +5 -1
  51. package/src/utilities/project.js +5 -1
  52. package/src/utilities/prompt.js +5 -1
  53. package/models/command.d.ts +0 -29
  54. package/models/command.js +0 -50
  55. package/models/interface.d.ts +0 -19
  56. package/models/schematic-command.d.ts +0 -43
  57. package/models/schematic-command.js +0 -378
  58. package/src/commands/add/add-impl.d.ts +0 -22
  59. package/src/commands/add/add-impl.js +0 -331
  60. package/src/commands/analytics/long-description.md +0 -10
  61. package/src/commands/config/config-impl.d.ts +0 -17
  62. package/src/commands/config/config-impl.js +0 -151
  63. package/src/commands/generate/generate-impl.d.ts +0 -19
  64. package/src/commands/generate/generate-impl.js +0 -49
  65. package/src/commands/new/new-impl.d.ts +0 -18
  66. package/src/commands/new/new-impl.js +0 -38
  67. package/src/commands/update/update-impl.d.ts +0 -40
  68. package/src/commands/update/update-impl.js +0 -728
@@ -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];
@@ -16,7 +16,6 @@ const module_1 = __importDefault(require("module"));
16
16
  const path_1 = require("path");
17
17
  const command_module_1 = require("../../command-builder/command-module");
18
18
  const color_1 = require("../../utilities/color");
19
- const package_manager_1 = require("../../utilities/package-manager");
20
19
  /**
21
20
  * Major versions of Node.js that are officially supported by Angular.
22
21
  */
@@ -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: ${this.getPackageManagerVersion()}
109
104
  OS: ${process.platform} ${process.arch}
110
105
 
111
106
  Angular: ${angularCoreVersion}
@@ -162,9 +157,9 @@ class VersionCommandModule extends command_module_1.CommandModule {
162
157
  }
163
158
  return '<error>';
164
159
  }
165
- async getPackageManagerVersion() {
160
+ getPackageManagerVersion() {
166
161
  try {
167
- const manager = await (0, package_manager_1.getPackageManager)(this.context.root);
162
+ const manager = this.context.packageManager;
168
163
  const version = (0, child_process_1.execSync)(`${manager} --version`, {
169
164
  encoding: 'utf8',
170
165
  stdio: ['ignore', 'pipe', 'ignore'],
@@ -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];
@@ -28,3 +28,4 @@ export declare function getProjectByCwd(workspace: AngularWorkspace): string | n
28
28
  export declare function getConfiguredPackageManager(): Promise<PackageManager | null>;
29
29
  export declare function getSchematicDefaults(collection: string, schematic: string, project?: string | null): Promise<{}>;
30
30
  export declare function isWarningEnabled(warning: string): Promise<boolean>;
31
+ export declare function getProjectsByPath(workspace: workspaces.WorkspaceDefinition, cwd: string, root: string): 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.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];
@@ -26,7 +30,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
30
  return result;
27
31
  };
28
32
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.isWarningEnabled = exports.getSchematicDefaults = exports.getConfiguredPackageManager = exports.getProjectByCwd = exports.validateWorkspace = exports.getWorkspaceRaw = exports.createGlobalSettings = exports.getWorkspace = exports.AngularWorkspace = exports.workspaceSchemaPath = void 0;
33
+ exports.getProjectsByPath = exports.isWarningEnabled = exports.getSchematicDefaults = exports.getConfiguredPackageManager = exports.getProjectByCwd = exports.validateWorkspace = exports.getWorkspaceRaw = exports.createGlobalSettings = exports.getWorkspace = exports.AngularWorkspace = exports.workspaceSchemaPath = void 0;
30
34
  const core_1 = require("@angular-devkit/core");
31
35
  const fs_1 = require("fs");
32
36
  const os = __importStar(require("os"));
@@ -337,3 +341,33 @@ async function isWarningEnabled(warning) {
337
341
  return result !== null && result !== void 0 ? result : true;
338
342
  }
339
343
  exports.isWarningEnabled = isWarningEnabled;
344
+ function getProjectsByPath(workspace, cwd, root) {
345
+ if (workspace.projects.size === 1) {
346
+ return Array.from(workspace.projects.keys());
347
+ }
348
+ const isInside = (base, potential) => {
349
+ const absoluteBase = path.resolve(root, base);
350
+ const absolutePotential = path.resolve(root, potential);
351
+ const relativePotential = path.relative(absoluteBase, absolutePotential);
352
+ if (!relativePotential.startsWith('..') && !path.isAbsolute(relativePotential)) {
353
+ return true;
354
+ }
355
+ return false;
356
+ };
357
+ const projects = Array.from(workspace.projects.entries())
358
+ .map(([name, project]) => [path.resolve(root, project.root), name])
359
+ .filter((tuple) => isInside(tuple[0], cwd))
360
+ // Sort tuples by depth, with the deeper ones first. Since the first member is a path and
361
+ // we filtered all invalid paths, the longest will be the deepest (and in case of equality
362
+ // the sort is stable and the first declared project will win).
363
+ .sort((a, b) => b[0].length - a[0].length);
364
+ if (projects.length === 1) {
365
+ return [projects[0][1]];
366
+ }
367
+ else if (projects.length > 1) {
368
+ const firstPath = projects[0][0];
369
+ return projects.filter((v) => v[0] === firstPath).map((v) => v[1]);
370
+ }
371
+ return [];
372
+ }
373
+ exports.getProjectsByPath = getProjectsByPath;
@@ -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];
@@ -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];
@@ -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];
@@ -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];
@@ -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];
@@ -1,29 +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 { analytics, logging } from '@angular-devkit/core';
9
- import { Option } from '../src/command-builder/utilities/json-schema';
10
- import { AngularWorkspace } from '../src/utilities/config';
11
- import { CommandContext } from './interface';
12
- export interface BaseCommandOptions {
13
- jsonHelp?: boolean;
14
- }
15
- export declare abstract class Command<T = {}> {
16
- protected readonly context: CommandContext;
17
- protected readonly commandName: string;
18
- protected allowMissingWorkspace: boolean;
19
- protected useReportAnalytics: boolean;
20
- readonly workspace?: AngularWorkspace;
21
- protected readonly analytics: analytics.Analytics;
22
- protected readonly commandOptions: Option[];
23
- protected readonly logger: logging.Logger;
24
- constructor(context: CommandContext, commandName: string);
25
- initialize(options: T): Promise<number | void>;
26
- reportAnalytics(paths: string[], options: T, dimensions?: (boolean | number | string)[], metrics?: (boolean | number | string)[]): Promise<void>;
27
- abstract run(options: T): Promise<number | void>;
28
- validateAndRun(options: T): Promise<number | void>;
29
- }
package/models/command.js DELETED
@@ -1,50 +0,0 @@
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.Command = void 0;
11
- const core_1 = require("@angular-devkit/core");
12
- class Command {
13
- constructor(context, commandName) {
14
- this.context = context;
15
- this.commandName = commandName;
16
- this.allowMissingWorkspace = false;
17
- this.useReportAnalytics = true;
18
- this.commandOptions = [];
19
- this.workspace = context.workspace;
20
- this.logger = context.logger;
21
- this.analytics = context.analytics || new core_1.analytics.NoopAnalytics();
22
- }
23
- async initialize(options) { }
24
- async reportAnalytics(paths, options, dimensions = [], metrics = []) {
25
- for (const option of this.commandOptions) {
26
- const ua = option.userAnalytics;
27
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
- const v = options[option.name];
29
- if (v !== undefined && !Array.isArray(v) && ua) {
30
- dimensions[ua] = v;
31
- }
32
- }
33
- this.analytics.pageview('/command/' + paths.join('/'), { dimensions, metrics });
34
- }
35
- async validateAndRun(options) {
36
- let result = await this.initialize(options);
37
- if (typeof result === 'number' && result !== 0) {
38
- return result;
39
- }
40
- const startTime = +new Date();
41
- if (this.useReportAnalytics) {
42
- await this.reportAnalytics([this.commandName], options);
43
- }
44
- result = await this.run(options);
45
- const endTime = +new Date();
46
- this.analytics.timing(this.commandName, 'duration', endTime - startTime);
47
- return result;
48
- }
49
- }
50
- exports.Command = Command;
@@ -1,19 +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 { analytics, logging } from '@angular-devkit/core';
9
- import { AngularWorkspace } from '../src/utilities/config';
10
- /**
11
- * A command runner context.
12
- */
13
- export interface CommandContext {
14
- currentDirectory: string;
15
- root: string;
16
- workspace?: AngularWorkspace;
17
- analytics?: analytics.Analytics;
18
- logger: logging.Logger;
19
- }
@@ -1,43 +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 { FileSystemCollection, FileSystemEngine, FileSystemSchematic, NodeWorkflow } from '@angular-devkit/schematics/tools';
9
- import { BaseCommandOptions, Command } from './command';
10
- import { CommandContext } from './interface';
11
- export interface BaseSchematicSchema {
12
- debug?: boolean;
13
- dryRun?: boolean;
14
- force?: boolean;
15
- interactive?: boolean;
16
- defaults?: boolean;
17
- registry?: string;
18
- }
19
- export interface RunSchematicOptions extends BaseSchematicSchema {
20
- collectionName: string;
21
- schematicName: string;
22
- schematicOptions?: Record<string, unknown>;
23
- showNothingDone?: boolean;
24
- }
25
- export declare class UnknownCollectionError extends Error {
26
- constructor(collectionName: string);
27
- }
28
- export declare abstract class SchematicCommand<T extends BaseSchematicSchema & BaseCommandOptions> extends Command<T> {
29
- protected readonly allowPrivateSchematics: boolean;
30
- protected readonly useReportAnalytics = false;
31
- protected _workflow: NodeWorkflow;
32
- protected defaultCollectionName: string;
33
- protected collectionName: string;
34
- protected schematicName?: string;
35
- constructor(context: CommandContext, commandName: string);
36
- initialize(options: T): Promise<void>;
37
- protected getEngine(): FileSystemEngine;
38
- protected getCollection(collectionName: string): FileSystemCollection;
39
- protected getSchematic(collection: FileSystemCollection, schematicName: string, allowPrivate?: boolean): FileSystemSchematic;
40
- protected createWorkflow(options: BaseSchematicSchema): Promise<NodeWorkflow>;
41
- protected getDefaultSchematicCollection(): Promise<string>;
42
- protected runSchematic(options: RunSchematicOptions): Promise<number | void>;
43
- }