@angular/cli 20.2.0-next.2 → 20.2.0-next.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/cli",
3
- "version": "20.2.0-next.2",
3
+ "version": "20.2.0-next.3",
4
4
  "description": "CLI tool for Angular",
5
5
  "main": "lib/cli/index.js",
6
6
  "bin": {
@@ -25,15 +25,15 @@
25
25
  },
26
26
  "homepage": "https://github.com/angular/angular-cli",
27
27
  "dependencies": {
28
- "@angular-devkit/architect": "0.2002.0-next.2",
29
- "@angular-devkit/core": "20.2.0-next.2",
30
- "@angular-devkit/schematics": "20.2.0-next.2",
31
- "@inquirer/prompts": "7.7.1",
28
+ "@angular-devkit/architect": "0.2002.0-next.3",
29
+ "@angular-devkit/core": "20.2.0-next.3",
30
+ "@angular-devkit/schematics": "20.2.0-next.3",
31
+ "@inquirer/prompts": "7.8.0",
32
32
  "@listr2/prompt-adapter-inquirer": "3.0.1",
33
- "@modelcontextprotocol/sdk": "1.17.0",
34
- "@schematics/angular": "20.2.0-next.2",
33
+ "@modelcontextprotocol/sdk": "1.17.1",
34
+ "@schematics/angular": "20.2.0-next.3",
35
35
  "@yarnpkg/lockfile": "1.1.0",
36
- "algoliasearch": "5.34.1",
36
+ "algoliasearch": "5.35.0",
37
37
  "ini": "5.0.0",
38
38
  "jsonc-parser": "3.3.1",
39
39
  "listr2": "9.0.1",
@@ -47,14 +47,14 @@
47
47
  "ng-update": {
48
48
  "migrations": "@schematics/angular/migrations/migration-collection.json",
49
49
  "packageGroup": {
50
- "@angular/cli": "20.2.0-next.2",
51
- "@angular/build": "20.2.0-next.2",
52
- "@angular/ssr": "20.2.0-next.2",
53
- "@angular-devkit/architect": "0.2002.0-next.2",
54
- "@angular-devkit/build-angular": "20.2.0-next.2",
55
- "@angular-devkit/build-webpack": "0.2002.0-next.2",
56
- "@angular-devkit/core": "20.2.0-next.2",
57
- "@angular-devkit/schematics": "20.2.0-next.2"
50
+ "@angular/cli": "20.2.0-next.3",
51
+ "@angular/build": "20.2.0-next.3",
52
+ "@angular/ssr": "20.2.0-next.3",
53
+ "@angular-devkit/architect": "0.2002.0-next.3",
54
+ "@angular-devkit/build-angular": "20.2.0-next.3",
55
+ "@angular-devkit/build-webpack": "0.2002.0-next.3",
56
+ "@angular-devkit/core": "20.2.0-next.3",
57
+ "@angular-devkit/schematics": "20.2.0-next.3"
58
58
  }
59
59
  },
60
60
  "packageManager": "pnpm@9.15.9",
@@ -18,7 +18,7 @@ To start using the Angular CLI MCP Server, add this configuration to your host:
18
18
  "mcpServers": {
19
19
  "angular-cli": {
20
20
  "command": "npx",
21
- "args": ["@angular/cli", "mcp"]
21
+ "args": ["-y", "@angular/cli", "mcp"]
22
22
  }
23
23
  }
24
24
  }
@@ -23,10 +23,14 @@ async function createMcpServer(context, logger) {
23
23
  const server = new mcp_js_1.McpServer({
24
24
  name: 'angular-cli-server',
25
25
  version: version_1.VERSION.full,
26
+ }, {
26
27
  capabilities: {
27
28
  resources: {},
28
29
  tools: {},
30
+ logging: {},
29
31
  },
32
+ instructions: 'For Angular development, this server provides tools to adhere to best practices, search documentation, and find code examples. ' +
33
+ 'When writing or modifying Angular code, use the MCP server and its tools instead of direct shell commands where possible.',
30
34
  });
31
35
  server.registerResource('instructions', 'instructions://best-practices', {
32
36
  title: 'Angular Best Practices and Code Generation Guide',
@@ -41,8 +45,7 @@ async function createMcpServer(context, logger) {
41
45
  });
42
46
  (0, best_practices_1.registerBestPracticesTool)(server);
43
47
  // If run outside an Angular workspace (e.g., globally) skip the workspace specific tools.
44
- // Currently only the `list_projects` tool.
45
- if (!context.workspace) {
48
+ if (context.workspace) {
46
49
  (0, projects_1.registerListProjectsTool)(server, context);
47
50
  }
48
51
  await (0, doc_search_1.registerDocSearchTool)(server);
@@ -54,7 +57,7 @@ async function createMcpServer(context, logger) {
54
57
  ' Registration of this tool has been skipped.');
55
58
  }
56
59
  else {
57
- (0, examples_1.registerFindExampleTool)(server, node_path_1.default.join(__dirname, '../../../lib/code-examples.db'));
60
+ await (0, examples_1.registerFindExampleTool)(server, node_path_1.default.join(__dirname, '../../../lib/code-examples.db'));
58
61
  }
59
62
  }
60
63
  return server;
@@ -14,6 +14,7 @@ exports.registerBestPracticesTool = registerBestPracticesTool;
14
14
  const promises_1 = require("node:fs/promises");
15
15
  const node_path_1 = __importDefault(require("node:path"));
16
16
  function registerBestPracticesTool(server) {
17
+ let bestPracticesText;
17
18
  server.registerTool('get_best_practices', {
18
19
  title: 'Get Angular Coding Best Practices Guide',
19
20
  description: 'You **MUST** use this tool to retrieve the Angular Best Practices Guide ' +
@@ -26,12 +27,16 @@ function registerBestPracticesTool(server) {
26
27
  openWorldHint: false,
27
28
  },
28
29
  }, async () => {
29
- const text = await (0, promises_1.readFile)(node_path_1.default.join(__dirname, '..', 'instructions', 'best-practices.md'), 'utf-8');
30
+ bestPracticesText ??= await (0, promises_1.readFile)(node_path_1.default.join(__dirname, '..', 'instructions', 'best-practices.md'), 'utf-8');
30
31
  return {
31
32
  content: [
32
33
  {
33
34
  type: 'text',
34
- text,
35
+ text: bestPracticesText,
36
+ annotations: {
37
+ audience: ['assistant'],
38
+ priority: 0.9,
39
+ },
35
40
  },
36
41
  ],
37
42
  };
@@ -15,7 +15,7 @@ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
15
15
  * @param server The MCP server instance.
16
16
  * @param exampleDatabasePath The path to the SQLite database file containing the examples.
17
17
  */
18
- export declare function registerFindExampleTool(server: McpServer, exampleDatabasePath: string): void;
18
+ export declare function registerFindExampleTool(server: McpServer, exampleDatabasePath: string): Promise<void>;
19
19
  /**
20
20
  * Escapes a search query for FTS5 by tokenizing and quoting terms.
21
21
  *
@@ -39,9 +39,14 @@ var __importStar = (this && this.__importStar) || (function () {
39
39
  return result;
40
40
  };
41
41
  })();
42
+ var __importDefault = (this && this.__importDefault) || function (mod) {
43
+ return (mod && mod.__esModule) ? mod : { "default": mod };
44
+ };
42
45
  Object.defineProperty(exports, "__esModule", { value: true });
43
46
  exports.registerFindExampleTool = registerFindExampleTool;
44
47
  exports.escapeSearchQuery = escapeSearchQuery;
48
+ const promises_1 = require("node:fs/promises");
49
+ const node_path_1 = __importDefault(require("node:path"));
45
50
  const zod_1 = require("zod");
46
51
  /**
47
52
  * Registers the `find_examples` tool with the MCP server.
@@ -52,9 +57,14 @@ const zod_1 = require("zod");
52
57
  * @param server The MCP server instance.
53
58
  * @param exampleDatabasePath The path to the SQLite database file containing the examples.
54
59
  */
55
- function registerFindExampleTool(server, exampleDatabasePath) {
60
+ async function registerFindExampleTool(server, exampleDatabasePath) {
56
61
  let db;
57
62
  let queryStatement;
63
+ // Runtime directory of examples uses an in-memory database
64
+ if (process.env['NG_MCP_EXAMPLES_DIR']) {
65
+ db = await setupRuntimeExamples(process.env['NG_MCP_EXAMPLES_DIR']);
66
+ }
67
+ suppressSqliteWarning();
58
68
  server.registerTool('find_examples', {
59
69
  title: 'Find Angular Code Examples',
60
70
  description: 'Before writing or modifying any Angular code including templates, ' +
@@ -94,10 +104,11 @@ Examples of queries:
94
104
  openWorldHint: false,
95
105
  },
96
106
  }, async ({ query }) => {
97
- if (!db || !queryStatement) {
98
- suppressSqliteWarning();
107
+ if (!db) {
99
108
  const { DatabaseSync } = await Promise.resolve().then(() => __importStar(require('node:sqlite')));
100
109
  db = new DatabaseSync(exampleDatabasePath, { readOnly: true });
110
+ }
111
+ if (!queryStatement) {
101
112
  queryStatement = db.prepare('SELECT * from examples WHERE examples MATCH ? ORDER BY rank;');
102
113
  }
103
114
  const sanitizedQuery = escapeSearchQuery(query);
@@ -188,3 +199,19 @@ function suppressSqliteWarning() {
188
199
  return originalProcessEmit.apply(process, arguments);
189
200
  };
190
201
  }
202
+ async function setupRuntimeExamples(examplesPath) {
203
+ const { DatabaseSync } = await Promise.resolve().then(() => __importStar(require('node:sqlite')));
204
+ const db = new DatabaseSync(':memory:');
205
+ db.exec(`CREATE VIRTUAL TABLE examples USING fts5(content, tokenize = 'porter ascii');`);
206
+ const insertStatement = db.prepare('INSERT INTO examples(content) VALUES(?);');
207
+ db.exec('BEGIN TRANSACTION');
208
+ for await (const entry of (0, promises_1.glob)('*.md', { cwd: examplesPath, withFileTypes: true })) {
209
+ if (!entry.isFile()) {
210
+ continue;
211
+ }
212
+ const example = await (0, promises_1.readFile)(node_path_1.default.join(entry.parentPath, entry.name), 'utf-8');
213
+ insertStatement.run(example);
214
+ }
215
+ db.exec('END TRANSACTION');
216
+ return db;
217
+ }
@@ -5,14 +5,36 @@
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.dev/license
7
7
  */
8
- import { Argv } from 'yargs';
8
+ import type { Argv } from 'yargs';
9
9
  import { CommandModule, CommandModuleImplementation } from '../../command-builder/command-module';
10
+ /**
11
+ * The command-line module for the `ng version` command.
12
+ */
10
13
  export default class VersionCommandModule extends CommandModule implements CommandModuleImplementation {
11
14
  command: string;
12
15
  aliases: string[] | undefined;
13
16
  describe: string;
14
17
  longDescriptionPath?: string | undefined;
18
+ /**
19
+ * Builds the command-line options for the `ng version` command.
20
+ * @param localYargs The `yargs` instance to configure.
21
+ * @returns The configured `yargs` instance.
22
+ */
15
23
  builder(localYargs: Argv): Argv;
24
+ /**
25
+ * The main execution logic for the `ng version` command.
26
+ */
16
27
  run(): Promise<void>;
17
- private getVersion;
28
+ /**
29
+ * Formats the Angular packages section of the version output.
30
+ * @param versionInfo An object containing the version information.
31
+ * @returns A string containing the formatted Angular packages information.
32
+ */
33
+ private formatAngularPackages;
34
+ /**
35
+ * Formats the package table section of the version output.
36
+ * @param versions A map of package names to their versions.
37
+ * @returns A string containing the formatted package table.
38
+ */
39
+ private formatPackageTable;
18
40
  }
@@ -6,104 +6,74 @@
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.dev/license
8
8
  */
9
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
9
  Object.defineProperty(exports, "__esModule", { value: true });
13
- const node_module_1 = __importDefault(require("node:module"));
14
- const node_path_1 = require("node:path");
15
10
  const command_module_1 = require("../../command-builder/command-module");
16
11
  const color_1 = require("../../utilities/color");
17
12
  const command_config_1 = require("../command-config");
13
+ const version_info_1 = require("./version-info");
18
14
  /**
19
- * Major versions of Node.js that are officially supported by Angular.
15
+ * The Angular CLI logo, displayed as ASCII art.
16
+ */
17
+ const ASCII_ART = `
18
+ _ _ ____ _ ___
19
+ / \\ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
20
+ / △ \\ | '_ \\ / _\` | | | | |/ _\` | '__| | | | | | |
21
+ / ___ \\| | | | (_| | |_| | | (_| | | | |___| |___ | |
22
+ /_/ \\_\\_| |_|\\__, |\\__,_|_|\\__,_|_| \\____|_____|___|
23
+ |___/
24
+ `
25
+ .split('\n')
26
+ .map((x) => color_1.colors.red(x))
27
+ .join('\n');
28
+ /**
29
+ * The command-line module for the `ng version` command.
20
30
  */
21
- const SUPPORTED_NODE_MAJORS = [20, 22, 24];
22
- const PACKAGE_PATTERNS = [
23
- /^@angular\/.*/,
24
- /^@angular-devkit\/.*/,
25
- /^@ngtools\/.*/,
26
- /^@schematics\/.*/,
27
- /^rxjs$/,
28
- /^typescript$/,
29
- /^ng-packagr$/,
30
- /^webpack$/,
31
- /^zone\.js$/,
32
- ];
33
31
  class VersionCommandModule extends command_module_1.CommandModule {
34
32
  command = 'version';
35
33
  aliases = command_config_1.RootCommands['version'].aliases;
36
34
  describe = 'Outputs Angular CLI version.';
37
35
  longDescriptionPath;
36
+ /**
37
+ * Builds the command-line options for the `ng version` command.
38
+ * @param localYargs The `yargs` instance to configure.
39
+ * @returns The configured `yargs` instance.
40
+ */
38
41
  builder(localYargs) {
39
42
  return localYargs;
40
43
  }
44
+ /**
45
+ * The main execution logic for the `ng version` command.
46
+ */
41
47
  async run() {
42
- const { packageManager, logger, root } = this.context;
43
- const localRequire = node_module_1.default.createRequire((0, node_path_1.resolve)(__filename, '../../../'));
44
- // Trailing slash is used to allow the path to be treated as a directory
45
- const workspaceRequire = node_module_1.default.createRequire(root + '/');
46
- const cliPackage = localRequire('./package.json');
47
- let workspacePackage;
48
- try {
49
- workspacePackage = workspaceRequire('./package.json');
50
- }
51
- catch { }
52
- const [nodeMajor] = process.versions.node.split('.').map((part) => Number(part));
53
- const unsupportedNodeVersion = !SUPPORTED_NODE_MAJORS.includes(nodeMajor);
54
- const packageNames = new Set(Object.keys({
55
- ...cliPackage.dependencies,
56
- ...cliPackage.devDependencies,
57
- ...workspacePackage?.dependencies,
58
- ...workspacePackage?.devDependencies,
59
- }));
60
- const versions = {};
61
- for (const name of packageNames) {
62
- if (PACKAGE_PATTERNS.some((p) => p.test(name))) {
63
- versions[name] = this.getVersion(name, workspaceRequire, localRequire);
64
- }
48
+ const { logger } = this.context;
49
+ const versionInfo = (0, version_info_1.gatherVersionInfo)(this.context);
50
+ const { ngCliVersion, nodeVersion, unsupportedNodeVersion, packageManagerName, packageManagerVersion, os, arch, versions, } = versionInfo;
51
+ const header = `
52
+ Angular CLI: ${ngCliVersion}
53
+ Node: ${nodeVersion}${unsupportedNodeVersion ? ' (Unsupported)' : ''}
54
+ Package Manager: ${packageManagerName} ${packageManagerVersion ?? '<error>'}
55
+ OS: ${os} ${arch}
56
+ `.replace(/^ {6}/gm, '');
57
+ const angularPackages = this.formatAngularPackages(versionInfo);
58
+ const packageTable = this.formatPackageTable(versions);
59
+ logger.info([ASCII_ART, header, angularPackages, packageTable].join('\n\n'));
60
+ if (unsupportedNodeVersion) {
61
+ logger.warn(`Warning: The current version of Node (${nodeVersion}) is not supported by Angular.`);
65
62
  }
66
- const ngCliVersion = cliPackage.version;
67
- let angularCoreVersion = '';
68
- const angularSameAsCore = [];
69
- if (workspacePackage) {
70
- // Filter all angular versions that are the same as core.
71
- angularCoreVersion = versions['@angular/core'];
72
- if (angularCoreVersion) {
73
- for (const [name, version] of Object.entries(versions)) {
74
- if (version === angularCoreVersion && name.startsWith('@angular/')) {
75
- angularSameAsCore.push(name.replace(/^@angular\//, ''));
76
- delete versions[name];
77
- }
78
- }
79
- // Make sure we list them in alphabetical order.
80
- angularSameAsCore.sort();
81
- }
63
+ }
64
+ /**
65
+ * Formats the Angular packages section of the version output.
66
+ * @param versionInfo An object containing the version information.
67
+ * @returns A string containing the formatted Angular packages information.
68
+ */
69
+ formatAngularPackages(versionInfo) {
70
+ const { angularCoreVersion, angularSameAsCore } = versionInfo;
71
+ if (!angularCoreVersion) {
72
+ return 'Angular: <error>';
82
73
  }
83
- const namePad = ' '.repeat(Object.keys(versions).sort((a, b) => b.length - a.length)[0].length + 3);
84
- const asciiArt = `
85
- _ _ ____ _ ___
86
- / \\ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
87
- / △ \\ | '_ \\ / _\` | | | | |/ _\` | '__| | | | | | |
88
- / ___ \\| | | | (_| | |_| | | (_| | | | |___| |___ | |
89
- /_/ \\_\\_| |_|\\__, |\\__,_|_|\\__,_|_| \\____|_____|___|
90
- |___/
91
- `
92
- .split('\n')
93
- .map((x) => color_1.colors.red(x))
94
- .join('\n');
95
- logger.info(asciiArt);
96
- logger.info(`
97
- Angular CLI: ${ngCliVersion}
98
- Node: ${process.versions.node}${unsupportedNodeVersion ? ' (Unsupported)' : ''}
99
- Package Manager: ${packageManager.name} ${packageManager.version ?? '<error>'}
100
- OS: ${process.platform} ${process.arch}
101
-
102
- Angular: ${angularCoreVersion}
103
- ... ${angularSameAsCore
74
+ const wrappedPackages = angularSameAsCore
104
75
  .reduce((acc, name) => {
105
- // Perform a simple word wrap around 60.
106
- if (acc.length == 0) {
76
+ if (acc.length === 0) {
107
77
  return [name];
108
78
  }
109
79
  const line = acc[acc.length - 1] + ', ' + name;
@@ -115,43 +85,32 @@ class VersionCommandModule extends command_module_1.CommandModule {
115
85
  }
116
86
  return acc;
117
87
  }, [])
118
- .join('\n... ')}
119
-
120
- Package${namePad.slice(7)}Version
121
- -------${namePad.replace(/ /g, '-')}------------------
122
- ${Object.keys(versions)
123
- .map((module) => `${module}${namePad.slice(module.length)}${versions[module]}`)
124
- .sort()
125
- .join('\n')}
126
- `.replace(/^ {6}/gm, ''));
127
- if (unsupportedNodeVersion) {
128
- logger.warn(`Warning: The current version of Node (${process.versions.node}) is not supported by Angular.`);
129
- }
88
+ .join('\n... ');
89
+ return `Angular: ${angularCoreVersion}\n... ${wrappedPackages}`;
130
90
  }
131
- getVersion(moduleName, workspaceRequire, localRequire) {
132
- let packageInfo;
133
- let cliOnly = false;
134
- // Try to find the package in the workspace
135
- try {
136
- packageInfo = workspaceRequire(`${moduleName}/package.json`);
137
- }
138
- catch { }
139
- // If not found, try to find within the CLI
140
- if (!packageInfo) {
141
- try {
142
- packageInfo = localRequire(`${moduleName}/package.json`);
143
- cliOnly = true;
144
- }
145
- catch { }
91
+ /**
92
+ * Formats the package table section of the version output.
93
+ * @param versions A map of package names to their versions.
94
+ * @returns A string containing the formatted package table.
95
+ */
96
+ formatPackageTable(versions) {
97
+ const versionKeys = Object.keys(versions);
98
+ if (versionKeys.length === 0) {
99
+ return '';
146
100
  }
147
- // If found, attempt to get the version
148
- if (packageInfo) {
149
- try {
150
- return packageInfo.version + (cliOnly ? ' (cli-only)' : '');
151
- }
152
- catch { }
153
- }
154
- return '<error>';
101
+ const header = 'Package';
102
+ const maxNameLength = Math.max(...versionKeys.map((key) => key.length));
103
+ const namePad = ' '.repeat(Math.max(0, maxNameLength - header.length) + 3);
104
+ const tableHeader = `${header}${namePad}Version`;
105
+ const separator = '-'.repeat(tableHeader.length);
106
+ const tableRows = versionKeys
107
+ .map((module) => {
108
+ const padding = ' '.repeat(maxNameLength - module.length + 3);
109
+ return `${module}${padding}${versions[module]}`;
110
+ })
111
+ .sort()
112
+ .join('\n');
113
+ return `${tableHeader}\n${separator}\n${tableRows}`;
155
114
  }
156
115
  }
157
116
  exports.default = VersionCommandModule;
@@ -0,0 +1,33 @@
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.dev/license
7
+ */
8
+ /**
9
+ * An object containing all the version information that will be displayed by the command.
10
+ */
11
+ export interface VersionInfo {
12
+ ngCliVersion: string;
13
+ angularCoreVersion: string;
14
+ angularSameAsCore: string[];
15
+ versions: Record<string, string>;
16
+ unsupportedNodeVersion: boolean;
17
+ nodeVersion: string;
18
+ packageManagerName: string;
19
+ packageManagerVersion: string | undefined;
20
+ os: string;
21
+ arch: string;
22
+ }
23
+ /**
24
+ * Gathers all the version information from the environment and workspace.
25
+ * @returns An object containing all the version information.
26
+ */
27
+ export declare function gatherVersionInfo(context: {
28
+ packageManager: {
29
+ name: string;
30
+ version: string | undefined;
31
+ };
32
+ root: string;
33
+ }): VersionInfo;
@@ -0,0 +1,122 @@
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.dev/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.gatherVersionInfo = gatherVersionInfo;
11
+ const node_module_1 = require("node:module");
12
+ const node_path_1 = require("node:path");
13
+ /**
14
+ * Major versions of Node.js that are officially supported by Angular.
15
+ * @see https://angular.dev/reference/versions#supported-node-js-versions
16
+ */
17
+ const SUPPORTED_NODE_MAJORS = [20, 22, 24];
18
+ /**
19
+ * A list of regular expression patterns that match package names that should be included in the
20
+ * version output.
21
+ */
22
+ const PACKAGE_PATTERNS = [
23
+ /^@angular\/.*/,
24
+ /^@angular-devkit\/.*/,
25
+ /^@ngtools\/.*/,
26
+ /^@schematics\/.*/,
27
+ /^rxjs$/,
28
+ /^typescript$/,
29
+ /^ng-packagr$/,
30
+ /^webpack$/,
31
+ /^zone\.js$/,
32
+ ];
33
+ /**
34
+ * Gathers all the version information from the environment and workspace.
35
+ * @returns An object containing all the version information.
36
+ */
37
+ function gatherVersionInfo(context) {
38
+ const localRequire = (0, node_module_1.createRequire)((0, node_path_1.resolve)(__filename, '../../../'));
39
+ // Trailing slash is used to allow the path to be treated as a directory
40
+ const workspaceRequire = (0, node_module_1.createRequire)(context.root + '/');
41
+ const cliPackage = localRequire('./package.json');
42
+ let workspacePackage;
43
+ try {
44
+ workspacePackage = workspaceRequire('./package.json');
45
+ }
46
+ catch { }
47
+ const [nodeMajor] = process.versions.node.split('.').map((part) => Number(part));
48
+ const unsupportedNodeVersion = !SUPPORTED_NODE_MAJORS.includes(nodeMajor);
49
+ const packageNames = new Set(Object.keys({
50
+ ...cliPackage.dependencies,
51
+ ...cliPackage.devDependencies,
52
+ ...workspacePackage?.dependencies,
53
+ ...workspacePackage?.devDependencies,
54
+ }));
55
+ const versions = {};
56
+ for (const name of packageNames) {
57
+ if (PACKAGE_PATTERNS.some((p) => p.test(name))) {
58
+ versions[name] = getVersion(name, workspaceRequire, localRequire);
59
+ }
60
+ }
61
+ const ngCliVersion = cliPackage.version;
62
+ let angularCoreVersion = '';
63
+ const angularSameAsCore = [];
64
+ if (workspacePackage) {
65
+ // Filter all angular versions that are the same as core.
66
+ angularCoreVersion = versions['@angular/core'];
67
+ if (angularCoreVersion) {
68
+ for (const [name, version] of Object.entries(versions)) {
69
+ if (version === angularCoreVersion && name.startsWith('@angular/')) {
70
+ angularSameAsCore.push(name.replace(/^@angular\//, ''));
71
+ delete versions[name];
72
+ }
73
+ }
74
+ // Make sure we list them in alphabetical order.
75
+ angularSameAsCore.sort();
76
+ }
77
+ }
78
+ return {
79
+ ngCliVersion,
80
+ angularCoreVersion,
81
+ angularSameAsCore,
82
+ versions,
83
+ unsupportedNodeVersion,
84
+ nodeVersion: process.versions.node,
85
+ packageManagerName: context.packageManager.name,
86
+ packageManagerVersion: context.packageManager.version,
87
+ os: process.platform,
88
+ arch: process.arch,
89
+ };
90
+ }
91
+ /**
92
+ * Gets the version of a package.
93
+ * @param moduleName The name of the package.
94
+ * @param workspaceRequire A `require` function for the workspace.
95
+ * @param localRequire A `require` function for the CLI.
96
+ * @returns The version of the package, or `<error>` if it could not be found.
97
+ */
98
+ function getVersion(moduleName, workspaceRequire, localRequire) {
99
+ let packageInfo;
100
+ let cliOnly = false;
101
+ // Try to find the package in the workspace
102
+ try {
103
+ packageInfo = workspaceRequire(`${moduleName}/package.json`);
104
+ }
105
+ catch { }
106
+ // If not found, try to find within the CLI
107
+ if (!packageInfo) {
108
+ try {
109
+ packageInfo = localRequire(`${moduleName}/package.json`);
110
+ cliOnly = true;
111
+ }
112
+ catch { }
113
+ }
114
+ // If found, attempt to get the version
115
+ if (packageInfo) {
116
+ try {
117
+ return packageInfo.version + (cliOnly ? ' (cli-only)' : '');
118
+ }
119
+ catch { }
120
+ }
121
+ return '<error>';
122
+ }
@@ -5,8 +5,21 @@
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.dev/license
7
7
  */
8
+ /** Disables all analytics reporting when the `NG_CLI_ANALYTICS` environment variable is set to '0' or 'false'. */
8
9
  export declare const analyticsDisabled: boolean;
10
+ /** Identifies when the CLI is running in a Continuous Integration environment. */
9
11
  export declare const isCI: boolean;
12
+ /** Disables the automatic version check when the `NG_DISABLE_VERSION_CHECK` environment variable is enabled. */
10
13
  export declare const disableVersionCheck: boolean;
14
+ /** Enables debugging messages when the `NG_DEBUG` environment variable is enabled. */
11
15
  export declare const ngDebug: boolean;
16
+ /**
17
+ * Forces the autocomplete script to be generated.
18
+ * The `NG_FORCE_AUTOCOMPLETE` environment variable can be 'true', 'false', or undefined (for default behavior).
19
+ */
12
20
  export declare const forceAutocomplete: boolean | undefined;
21
+ /**
22
+ * When enabled, forces TTY mode.
23
+ * The `NG_FORCE_TTY` environment variable can be 'true', 'false', or undefined (for default behavior).
24
+ */
25
+ export declare const forceTty: boolean | undefined;
@@ -7,24 +7,53 @@
7
7
  * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.forceAutocomplete = exports.ngDebug = exports.disableVersionCheck = exports.isCI = exports.analyticsDisabled = void 0;
10
+ exports.forceTty = exports.forceAutocomplete = exports.ngDebug = exports.disableVersionCheck = exports.isCI = exports.analyticsDisabled = void 0;
11
+ /** A set of strings that are considered "truthy" when parsing environment variables. */
12
+ const TRUTHY_VALUES = new Set(['1', 'true']);
13
+ /** A set of strings that are considered "falsy" when parsing environment variables. */
14
+ const FALSY_VALUES = new Set(['0', 'false']);
15
+ /**
16
+ * Checks if an environment variable is present and has a non-empty value.
17
+ * @param variable The environment variable to check.
18
+ * @returns `true` if the variable is a non-empty string.
19
+ */
11
20
  function isPresent(variable) {
12
21
  return typeof variable === 'string' && variable !== '';
13
22
  }
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
- function optional(variable) {
23
+ /**
24
+ * Parses an environment variable into a boolean or undefined.
25
+ * @returns `true` if the variable is truthy ('1', 'true').
26
+ * @returns `false` if the variable is falsy ('0', 'false').
27
+ * @returns `undefined` if the variable is not present or has an unknown value.
28
+ */
29
+ function parseTristate(variable) {
21
30
  if (!isPresent(variable)) {
22
31
  return undefined;
23
32
  }
24
- return isEnabled(variable);
33
+ const value = variable.toLowerCase();
34
+ if (TRUTHY_VALUES.has(value)) {
35
+ return true;
36
+ }
37
+ if (FALSY_VALUES.has(value)) {
38
+ return false;
39
+ }
40
+ return undefined;
25
41
  }
26
- exports.analyticsDisabled = isDisabled(process.env['NG_CLI_ANALYTICS']);
27
- exports.isCI = isEnabled(process.env['CI']);
28
- exports.disableVersionCheck = isEnabled(process.env['NG_DISABLE_VERSION_CHECK']);
29
- exports.ngDebug = isEnabled(process.env['NG_DEBUG']);
30
- exports.forceAutocomplete = optional(process.env['NG_FORCE_AUTOCOMPLETE']);
42
+ /** Disables all analytics reporting when the `NG_CLI_ANALYTICS` environment variable is set to '0' or 'false'. */
43
+ exports.analyticsDisabled = parseTristate(process.env['NG_CLI_ANALYTICS']) === false;
44
+ /** Identifies when the CLI is running in a Continuous Integration environment. */
45
+ exports.isCI = parseTristate(process.env['CI']) === true;
46
+ /** Disables the automatic version check when the `NG_DISABLE_VERSION_CHECK` environment variable is enabled. */
47
+ exports.disableVersionCheck = parseTristate(process.env['NG_DISABLE_VERSION_CHECK']) === true;
48
+ /** Enables debugging messages when the `NG_DEBUG` environment variable is enabled. */
49
+ exports.ngDebug = parseTristate(process.env['NG_DEBUG']) === true;
50
+ /**
51
+ * Forces the autocomplete script to be generated.
52
+ * The `NG_FORCE_AUTOCOMPLETE` environment variable can be 'true', 'false', or undefined (for default behavior).
53
+ */
54
+ exports.forceAutocomplete = parseTristate(process.env['NG_FORCE_AUTOCOMPLETE']);
55
+ /**
56
+ * When enabled, forces TTY mode.
57
+ * The `NG_FORCE_TTY` environment variable can be 'true', 'false', or undefined (for default behavior).
58
+ */
59
+ exports.forceTty = parseTristate(process.env['NG_FORCE_TTY']);
@@ -5,4 +5,12 @@
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.dev/license
7
7
  */
8
+ /**
9
+ * Determines if the `stream` is a TTY.
10
+ *
11
+ * @param stream A NodeJS stream to check. Defaults to `process.stdout`.
12
+ * @returns `true` if the `stream` is a TTY, `false` otherwise. This detection is overridden
13
+ * by the `NG_FORCE_TTY` environment variable. In a CI environment, this will also be `false`
14
+ * unless `NG_FORCE_TTY` is set.
15
+ */
8
16
  export declare function isTTY(stream?: NodeJS.WriteStream): boolean;
@@ -8,15 +8,15 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.isTTY = isTTY;
11
- function _isTruthy(value) {
12
- // Returns true if value is a string that is anything but 0 or false.
13
- return value !== undefined && value !== '0' && value.toUpperCase() !== 'FALSE';
14
- }
11
+ const environment_options_1 = require("./environment-options");
12
+ /**
13
+ * Determines if the `stream` is a TTY.
14
+ *
15
+ * @param stream A NodeJS stream to check. Defaults to `process.stdout`.
16
+ * @returns `true` if the `stream` is a TTY, `false` otherwise. This detection is overridden
17
+ * by the `NG_FORCE_TTY` environment variable. In a CI environment, this will also be `false`
18
+ * unless `NG_FORCE_TTY` is set.
19
+ */
15
20
  function isTTY(stream = process.stdout) {
16
- // If we force TTY, we always return true.
17
- const force = process.env['NG_FORCE_TTY'];
18
- if (force !== undefined) {
19
- return _isTruthy(force);
20
- }
21
- return !!stream.isTTY && !_isTruthy(process.env['CI']);
21
+ return environment_options_1.forceTty ?? (!!stream.isTTY && !environment_options_1.isCI);
22
22
  }
@@ -22,4 +22,4 @@ class Version {
22
22
  this.patch = patch;
23
23
  }
24
24
  }
25
- exports.VERSION = new Version('20.2.0-next.2');
25
+ exports.VERSION = new Version('20.2.0-next.3');
@@ -1,20 +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.dev/license
7
- */
8
- /**
9
- * This uses a dynamic import to load a module which may be ESM.
10
- * CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
11
- * will currently, unconditionally downlevel dynamic import into a require call.
12
- * require calls cannot load ESM code and will result in a runtime error. To workaround
13
- * this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
14
- * Once TypeScript provides support for keeping the dynamic import this workaround can
15
- * be dropped.
16
- *
17
- * @param modulePath The path of the module to load.
18
- * @returns A Promise that resolves to the dynamically imported module.
19
- */
20
- export declare function loadEsmModule<T>(modulePath: string | URL): Promise<T>;
@@ -1,30 +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.dev/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.loadEsmModule = loadEsmModule;
11
- /**
12
- * Lazily compiled dynamic import loader function.
13
- */
14
- let load;
15
- /**
16
- * This uses a dynamic import to load a module which may be ESM.
17
- * CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
18
- * will currently, unconditionally downlevel dynamic import into a require call.
19
- * require calls cannot load ESM code and will result in a runtime error. To workaround
20
- * this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
21
- * Once TypeScript provides support for keeping the dynamic import this workaround can
22
- * be dropped.
23
- *
24
- * @param modulePath The path of the module to load.
25
- * @returns A Promise that resolves to the dynamically imported module.
26
- */
27
- function loadEsmModule(modulePath) {
28
- load ??= new Function('modulePath', `return import(modulePath);`);
29
- return load(modulePath);
30
- }