@angular/cli 20.2.0-next.2 → 20.2.0-rc.0

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 (42) hide show
  1. package/lib/code-examples.db +0 -0
  2. package/lib/config/schema.json +18 -2
  3. package/lib/config/workspace-schema.d.ts +14 -0
  4. package/lib/config/workspace-schema.js +11 -1
  5. package/package.json +17 -17
  6. package/src/commands/mcp/cli.d.ts +5 -1
  7. package/src/commands/mcp/cli.js +25 -4
  8. package/src/commands/mcp/mcp-server.d.ts +13 -1
  9. package/src/commands/mcp/mcp-server.js +51 -27
  10. package/src/commands/mcp/{instructions → resources}/best-practices.md +0 -5
  11. package/src/commands/mcp/resources/instructions.d.ts +9 -0
  12. package/src/commands/mcp/resources/instructions.js +28 -0
  13. package/src/commands/mcp/tools/best-practices.d.ts +1 -2
  14. package/src/commands/mcp/tools/best-practices.js +30 -24
  15. package/src/commands/mcp/tools/doc-search.d.ts +5 -9
  16. package/src/commands/mcp/tools/doc-search.js +34 -37
  17. package/src/commands/mcp/tools/examples.d.ts +4 -11
  18. package/src/commands/mcp/tools/examples.js +68 -34
  19. package/src/commands/mcp/tools/modernize.d.ts +31 -0
  20. package/src/commands/mcp/tools/modernize.js +135 -0
  21. package/src/commands/mcp/tools/projects.d.ts +22 -5
  22. package/src/commands/mcp/tools/projects.js +37 -35
  23. package/src/commands/mcp/tools/tool-registry.d.ts +35 -0
  24. package/src/commands/mcp/tools/tool-registry.js +33 -0
  25. package/src/commands/version/cli.d.ts +24 -2
  26. package/src/commands/version/cli.js +74 -115
  27. package/src/commands/version/version-info.d.ts +33 -0
  28. package/src/commands/version/version-info.js +122 -0
  29. package/src/utilities/config.js +3 -0
  30. package/src/utilities/environment-options.d.ts +13 -0
  31. package/src/utilities/environment-options.js +43 -14
  32. package/src/utilities/eol.d.ts +12 -0
  33. package/src/utilities/eol.js +12 -0
  34. package/src/utilities/error.d.ts +8 -0
  35. package/src/utilities/error.js +24 -4
  36. package/src/utilities/json-file.d.ts +15 -2
  37. package/src/utilities/json-file.js +100 -27
  38. package/src/utilities/tty.d.ts +8 -0
  39. package/src/utilities/tty.js +10 -10
  40. package/src/utilities/version.js +1 -1
  41. package/src/utilities/load-esm.d.ts +0 -20
  42. package/src/utilities/load-esm.js +0 -30
@@ -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
+ }
@@ -220,6 +220,9 @@ async function getWorkspaceRaw(level = 'local') {
220
220
  }
221
221
  async function validateWorkspace(data, isGlobal) {
222
222
  const schema = (0, json_file_1.readAndParseJson)(exports.workspaceSchemaPath);
223
+ if (!isJsonObject(schema)) {
224
+ throw new Error('Workspace schema is not a JSON object.');
225
+ }
223
226
  // We should eventually have a dedicated global config schema and use that to validate.
224
227
  const schemaToValidate = isGlobal
225
228
  ? {
@@ -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,16 @@
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
+ * Gets the end-of-line sequence from a string.
10
+ *
11
+ * This function analyzes the given string to determine the most frequent end-of-line (EOL)
12
+ * sequence. It counts the occurrences of carriage return line feed (`\r\n`) and
13
+ * line feed (`\n`).
14
+ *
15
+ * @param content The string to process.
16
+ * @returns The most frequent EOL sequence. If `\r\n` is more frequent, it returns `\r\n`.
17
+ * Otherwise (including ties), it returns `\n`. If no newlines are found, it falls back
18
+ * to the operating system's default EOL sequence.
19
+ */
8
20
  export declare function getEOL(content: string): string;
@@ -11,6 +11,18 @@ exports.getEOL = getEOL;
11
11
  const node_os_1 = require("node:os");
12
12
  const CRLF = '\r\n';
13
13
  const LF = '\n';
14
+ /**
15
+ * Gets the end-of-line sequence from a string.
16
+ *
17
+ * This function analyzes the given string to determine the most frequent end-of-line (EOL)
18
+ * sequence. It counts the occurrences of carriage return line feed (`\r\n`) and
19
+ * line feed (`\n`).
20
+ *
21
+ * @param content The string to process.
22
+ * @returns The most frequent EOL sequence. If `\r\n` is more frequent, it returns `\r\n`.
23
+ * Otherwise (including ties), it returns `\n`. If no newlines are found, it falls back
24
+ * to the operating system's default EOL sequence.
25
+ */
14
26
  function getEOL(content) {
15
27
  const newlines = content.match(/(?:\r?\n)/g);
16
28
  if (newlines?.length) {
@@ -5,6 +5,14 @@
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
+ * Asserts that a given value is an Error-like object.
10
+ *
11
+ * If the value is not an `Error` or an object with `name` and `message` properties,
12
+ * this function will throw an `AssertionError` with a descriptive message.
13
+ *
14
+ * @param value The value to check.
15
+ */
8
16
  export declare function assertIsError(value: unknown): asserts value is Error & {
9
17
  code?: string;
10
18
  };
@@ -12,9 +12,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.assertIsError = assertIsError;
14
14
  const node_assert_1 = __importDefault(require("node:assert"));
15
+ const node_util_1 = require("node:util");
16
+ /**
17
+ * Checks if a given value is an Error-like object.
18
+ *
19
+ * This type guard checks if the value is an instance of `Error` or if it's an object
20
+ * with `name` and `message` properties. This is useful for identifying error-like
21
+ * objects that may not be direct instances of `Error` (e.g., from RxJs).
22
+ *
23
+ * @param value The value to check.
24
+ * @returns `true` if the value is an Error-like object, `false` otherwise.
25
+ */
26
+ function isError(value) {
27
+ return (value instanceof Error ||
28
+ (typeof value === 'object' && value !== null && 'name' in value && 'message' in value));
29
+ }
30
+ /**
31
+ * Asserts that a given value is an Error-like object.
32
+ *
33
+ * If the value is not an `Error` or an object with `name` and `message` properties,
34
+ * this function will throw an `AssertionError` with a descriptive message.
35
+ *
36
+ * @param value The value to check.
37
+ */
15
38
  function assertIsError(value) {
16
- const isError = value instanceof Error ||
17
- // The following is needing to identify errors coming from RxJs.
18
- (typeof value === 'object' && value && 'name' in value && 'message' in value);
19
- (0, node_assert_1.default)(isError, 'catch clause variable is not an Error instance');
39
+ (0, node_assert_1.default)(isError(value), `Expected a value to be an Error-like object, but received: ${(0, node_util_1.inspect)(value)}`);
20
40
  }
@@ -5,7 +5,20 @@
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 { JsonValue } from '@angular-devkit/core';
9
+ /** A function that returns an index to insert a new property in a JSON object. */
8
10
  export type InsertionIndex = (properties: string[]) => number;
11
+ /** A JSON path. */
9
12
  export type JSONPath = (string | number)[];
10
- export declare function readAndParseJson(path: string): any;
11
- export declare function parseJson(content: string): any;
13
+ /**
14
+ * Reads and parses a JSON file, supporting comments and trailing commas.
15
+ * @param path The path to the JSON file.
16
+ * @returns The parsed JSON object.
17
+ */
18
+ export declare function readAndParseJson<T extends JsonValue>(path: string): T;
19
+ /**
20
+ * Parses a JSON string, supporting comments and trailing commas.
21
+ * @param content The JSON string to parse.
22
+ * @returns The parsed JSON object.
23
+ */
24
+ export declare function parseJson<T extends JsonValue>(content: string): T;