@angular/cli 21.1.0-next.1 → 21.1.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.
Files changed (63) hide show
  1. package/lib/code-examples.db +0 -0
  2. package/lib/config/schema.json +1 -2
  3. package/package.json +17 -17
  4. package/src/commands/add/cli.js +129 -87
  5. package/src/commands/add/cli.js.map +1 -1
  6. package/src/commands/mcp/cli.js +4 -1
  7. package/src/commands/mcp/cli.js.map +1 -1
  8. package/src/commands/mcp/{dev-server.d.ts → devserver.d.ts} +4 -4
  9. package/src/commands/mcp/{dev-server.js → devserver.js} +14 -14
  10. package/src/commands/mcp/devserver.js.map +1 -0
  11. package/src/commands/mcp/mcp-server.d.ts +30 -0
  12. package/src/commands/mcp/mcp-server.js +22 -7
  13. package/src/commands/mcp/mcp-server.js.map +1 -1
  14. package/src/commands/mcp/resources/ai-tutor.md +16 -15
  15. package/src/commands/mcp/tools/best-practices.js.map +1 -1
  16. package/src/commands/mcp/tools/build.js +2 -2
  17. package/src/commands/mcp/tools/build.js.map +1 -1
  18. package/src/commands/mcp/tools/devserver/{start-devserver.d.ts → devserver-start.d.ts} +6 -7
  19. package/src/commands/mcp/tools/devserver/{start-devserver.js → devserver-start.js} +26 -27
  20. package/src/commands/mcp/tools/devserver/devserver-start.js.map +1 -0
  21. package/src/commands/mcp/tools/devserver/{stop-devserver.d.ts → devserver-stop.d.ts} +6 -6
  22. package/src/commands/mcp/tools/devserver/{stop-devserver.js → devserver-stop.js} +13 -13
  23. package/src/commands/mcp/tools/devserver/{stop-devserver.js.map → devserver-stop.js.map} +1 -1
  24. package/src/commands/mcp/tools/devserver/{wait-for-devserver-build.d.ts → devserver-wait-for-build.d.ts} +6 -6
  25. package/src/commands/mcp/tools/devserver/{wait-for-devserver-build.js → devserver-wait-for-build.js} +16 -16
  26. package/src/commands/mcp/tools/devserver/{wait-for-devserver-build.js.map → devserver-wait-for-build.js.map} +1 -1
  27. package/src/commands/mcp/tools/modernize.js +1 -1
  28. package/src/commands/mcp/tools/modernize.js.map +1 -1
  29. package/src/commands/mcp/tools/projects.js +47 -8
  30. package/src/commands/mcp/tools/projects.js.map +1 -1
  31. package/src/commands/mcp/tools/tool-registry.d.ts +2 -2
  32. package/src/commands/mcp/tools/tool-registry.js.map +1 -1
  33. package/src/commands/update/cli.d.ts +0 -24
  34. package/src/commands/update/cli.js +39 -447
  35. package/src/commands/update/cli.js.map +1 -1
  36. package/src/commands/update/schematic/index.js +0 -12
  37. package/src/commands/update/schematic/index.js.map +1 -1
  38. package/src/commands/update/utilities/cli-version.d.ts +48 -0
  39. package/src/commands/update/utilities/cli-version.js +196 -0
  40. package/src/commands/update/utilities/cli-version.js.map +1 -0
  41. package/src/commands/update/utilities/constants.d.ts +12 -0
  42. package/src/commands/update/utilities/constants.js +16 -0
  43. package/src/commands/update/utilities/constants.js.map +1 -0
  44. package/src/commands/update/utilities/git.d.ts +36 -0
  45. package/src/commands/update/utilities/git.js +148 -0
  46. package/src/commands/update/utilities/git.js.map +1 -0
  47. package/src/commands/update/utilities/migration.d.ts +32 -0
  48. package/src/commands/update/utilities/migration.js +257 -0
  49. package/src/commands/update/utilities/migration.js.map +1 -0
  50. package/src/package-managers/error.d.ts +12 -0
  51. package/src/package-managers/host.js +7 -3
  52. package/src/package-managers/host.js.map +1 -1
  53. package/src/package-managers/package-manager-descriptor.d.ts +28 -4
  54. package/src/package-managers/package-manager-descriptor.js +24 -4
  55. package/src/package-managers/package-manager-descriptor.js.map +1 -1
  56. package/src/package-managers/package-manager.js +71 -8
  57. package/src/package-managers/package-manager.js.map +1 -1
  58. package/src/package-managers/parsers.d.ts +69 -4
  59. package/src/package-managers/parsers.js +231 -32
  60. package/src/package-managers/parsers.js.map +1 -1
  61. package/src/utilities/version.js +1 -1
  62. package/src/commands/mcp/dev-server.js.map +0 -1
  63. package/src/commands/mcp/tools/devserver/start-devserver.js.map +0 -1
@@ -0,0 +1,148 @@
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = 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);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.checkCleanGit = checkCleanGit;
44
+ exports.hasChangesToCommit = hasChangesToCommit;
45
+ exports.createCommit = createCommit;
46
+ exports.findCurrentGitSha = findCurrentGitSha;
47
+ exports.getShortHash = getShortHash;
48
+ const node_child_process_1 = require("node:child_process");
49
+ const path = __importStar(require("node:path"));
50
+ /**
51
+ * Execute a git command.
52
+ * @param args Arguments to pass to the git command.
53
+ * @param input Optional input to pass to the command via stdin.
54
+ * @returns The output of the command.
55
+ */
56
+ function execGit(args, input) {
57
+ return (0, node_child_process_1.execFileSync)('git', args, { encoding: 'utf8', stdio: 'pipe', input });
58
+ }
59
+ /**
60
+ * Checks if the git repository is clean.
61
+ * This function only checks for changes that are within the specified root directory.
62
+ * Changes outside the root directory are ignored.
63
+ * @param root The root directory of the project to check.
64
+ * @returns True if the repository is clean within the root, false otherwise.
65
+ */
66
+ function checkCleanGit(root) {
67
+ try {
68
+ const topLevel = execGit(['rev-parse', '--show-toplevel']);
69
+ const result = execGit(['status', '--porcelain', '-z']);
70
+ if (result.length === 0) {
71
+ return true;
72
+ }
73
+ const entries = result.split('\0');
74
+ for (let i = 0; i < entries.length; i++) {
75
+ const line = entries[i];
76
+ if (!line) {
77
+ continue;
78
+ }
79
+ // Status is the first 2 characters.
80
+ // If the status is a rename ('R'), the next entry in the split array is the target path.
81
+ let filePath = line.slice(3);
82
+ const status = line.slice(0, 2);
83
+ if (status[0] === 'R') {
84
+ // Check the source path (filePath)
85
+ if (isPathInsideRoot(filePath, root, topLevel.trim())) {
86
+ return false;
87
+ }
88
+ // The next entry is the target path of the rename.
89
+ i++;
90
+ filePath = entries[i];
91
+ }
92
+ if (isPathInsideRoot(filePath, root, topLevel.trim())) {
93
+ return false;
94
+ }
95
+ }
96
+ }
97
+ catch { } // eslint-disable-line no-empty
98
+ return true;
99
+ }
100
+ function isPathInsideRoot(filePath, root, topLevel) {
101
+ const relativeEntry = path.relative(path.resolve(root), path.resolve(topLevel, filePath));
102
+ return !relativeEntry.startsWith('..') && !path.isAbsolute(relativeEntry);
103
+ }
104
+ /**
105
+ * Checks if the working directory has pending changes to commit.
106
+ * @returns Whether or not the working directory has Git changes to commit. Returns false if not in a Git repository.
107
+ */
108
+ function hasChangesToCommit() {
109
+ try {
110
+ // List all modified files not covered by .gitignore.
111
+ // If any files are returned, then there must be something to commit.
112
+ return execGit(['ls-files', '-m', '-d', '-o', '--exclude-standard']).trim() !== '';
113
+ }
114
+ catch {
115
+ return false;
116
+ }
117
+ }
118
+ /**
119
+ * Stages all changes in the Git working tree and creates a new commit.
120
+ * @param message The commit message to use.
121
+ */
122
+ function createCommit(message) {
123
+ // Stage entire working tree for commit.
124
+ execGit(['add', '-A']);
125
+ // Commit with the message passed via stdin to avoid bash escaping issues.
126
+ execGit(['commit', '--no-verify', '-F', '-'], message);
127
+ }
128
+ /**
129
+ * Finds the full Git SHA hash of the HEAD commit.
130
+ * @returns The full Git SHA hash of the HEAD commit. Returns null if unable to retrieve the hash.
131
+ */
132
+ function findCurrentGitSha() {
133
+ try {
134
+ return execGit(['rev-parse', 'HEAD']).trim();
135
+ }
136
+ catch {
137
+ return null;
138
+ }
139
+ }
140
+ /**
141
+ * Gets the short hash of a commit.
142
+ * @param commitHash The full commit hash.
143
+ * @returns The short hash (first 9 characters).
144
+ */
145
+ function getShortHash(commitHash) {
146
+ return commitHash.slice(0, 9);
147
+ }
148
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["git.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBH,sCAqCC;AAYD,gDAQC;AAMD,oCAMC;AAMD,8CAMC;AAOD,oCAEC;AA9GD,2DAAkD;AAClD,gDAAkC;AAElC;;;;;GAKG;AACH,SAAS,OAAO,CAAC,IAAc,EAAE,KAAc;IAC7C,OAAO,IAAA,iCAAY,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,IAAY;IACxC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC;QAC3D,MAAM,MAAM,GAAG,OAAO,CA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I,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE1F,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAC5E,CAAC;AAED;;;GAGG;AACH,SAAgB,kBAAkB;IAChC,IAAI,CAAC;QACH,qDAAqD;QACrD,qEAAqE;QACrE,OAAO,OAAO,CAAC,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAoB,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;IACrF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAC,OAAe;IAC1C,wCAAwC;IACxC,OAAO,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IAEvB,0EAA0E;IAC1E,OAAO,CAAC,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AACzD,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB;IAC/B,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,UAAkB;IAC7C,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,32 @@
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
+ import { logging } from '@angular-devkit/core';
9
+ import { SchematicDescription } from '@angular-devkit/schematics';
10
+ import { FileSystemCollectionDescription, FileSystemSchematicDescription, NodeWorkflow } from '@angular-devkit/schematics/tools';
11
+ export interface MigrationSchematicDescription extends SchematicDescription<FileSystemCollectionDescription, FileSystemSchematicDescription> {
12
+ version?: string;
13
+ optional?: boolean;
14
+ recommended?: boolean;
15
+ documentation?: string;
16
+ }
17
+ export declare function executeSchematic(workflow: NodeWorkflow, logger: logging.Logger, collection: string, schematic: string, options?: Record<string, unknown>): Promise<{
18
+ success: boolean;
19
+ files: Set<string>;
20
+ }>;
21
+ /**
22
+ * @return Whether or not the migration was performed successfully.
23
+ */
24
+ export declare function executeMigration(workflow: NodeWorkflow, logger: logging.Logger, packageName: string, collectionPath: string, migrationName: string, commit?: boolean): Promise<number>;
25
+ /**
26
+ * @return Whether or not the migrations were performed successfully.
27
+ */
28
+ export declare function executeMigrations(workflow: NodeWorkflow, logger: logging.Logger, packageName: string, collectionPath: string, from: string, to: string, commit?: boolean): Promise<number>;
29
+ /**
30
+ * @return Whether or not the commit was successful.
31
+ */
32
+ export declare function commitChanges(logger: logging.Logger, message: string): boolean;
@@ -0,0 +1,257 @@
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = 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);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.executeSchematic = executeSchematic;
44
+ exports.executeMigration = executeMigration;
45
+ exports.executeMigrations = executeMigrations;
46
+ exports.commitChanges = commitChanges;
47
+ const schematics_1 = require("@angular-devkit/schematics");
48
+ const semver = __importStar(require("semver"));
49
+ const schematic_workflow_1 = require("../../../command-builder/utilities/schematic-workflow");
50
+ const color_1 = require("../../../utilities/color");
51
+ const error_1 = require("../../../utilities/error");
52
+ const log_file_1 = require("../../../utilities/log-file");
53
+ const prompt_1 = require("../../../utilities/prompt");
54
+ const tty_1 = require("../../../utilities/tty");
55
+ const cli_version_1 = require("./cli-version");
56
+ const git_1 = require("./git");
57
+ async function executeSchematic(workflow, logger, collection, schematic, options = {}) {
58
+ const workflowSubscription = (0, schematic_workflow_1.subscribeToWorkflow)(workflow, logger);
59
+ // TODO: Allow passing a schematic instance directly
60
+ try {
61
+ await workflow
62
+ .execute({
63
+ collection,
64
+ schematic,
65
+ options,
66
+ logger,
67
+ })
68
+ .toPromise();
69
+ return { success: !workflowSubscription.error, files: workflowSubscription.files };
70
+ }
71
+ catch (e) {
72
+ if (e instanceof schematics_1.UnsuccessfulWorkflowExecution) {
73
+ logger.error(`${color_1.figures.cross} Migration failed. See above for further details.\n`);
74
+ }
75
+ else {
76
+ (0, error_1.assertIsError)(e);
77
+ const logPath = (0, log_file_1.writeErrorToLogFile)(e);
78
+ logger.fatal(`${color_1.figures.cross} Migration failed: ${e.message}\n` +
79
+ ` See "${logPath}" for further details.\n`);
80
+ }
81
+ return { success: false, files: workflowSubscription.files };
82
+ }
83
+ finally {
84
+ workflowSubscription.unsubscribe();
85
+ }
86
+ }
87
+ /**
88
+ * @return Whether or not the migration was performed successfully.
89
+ */
90
+ async function executeMigration(workflow, logger, packageName, collectionPath, migrationName, commit = false) {
91
+ const collection = workflow.engine.createCollection(collectionPath);
92
+ const name = collection.listSchematicNames().find((name) => name === migrationName);
93
+ if (!name) {
94
+ logger.error(`Cannot find migration '${migrationName}' in '${packageName}'.`);
95
+ return 1;
96
+ }
97
+ logger.info(color_1.colors.cyan(`** Executing '${migrationName}' of package '${packageName}' **\n`));
98
+ const schematic = workflow.engine.createSchematic(name, collection);
99
+ return executePackageMigrations(workflow, logger, [schematic.description], packageName, commit);
100
+ }
101
+ /**
102
+ * @return Whether or not the migrations were performed successfully.
103
+ */
104
+ async function executeMigrations(workflow, logger, packageName, collectionPath, from, to, commit = false) {
105
+ const collection = workflow.engine.createCollection(collectionPath);
106
+ const migrationRange = new semver.Range('>' + (semver.prerelease(from) ? from.split('-')[0] + '-0' : from) + ' <=' + to.split('-')[0]);
107
+ const requiredMigrations = [];
108
+ const optionalMigrations = [];
109
+ for (const name of collection.listSchematicNames()) {
110
+ const schematic = workflow.engine.createSchematic(name, collection);
111
+ const description = schematic.description;
112
+ description.version = (0, cli_version_1.coerceVersionNumber)(description.version);
113
+ if (!description.version) {
114
+ continue;
115
+ }
116
+ if (semver.satisfies(description.version, migrationRange, { includePrerelease: true })) {
117
+ (description.optional ? optionalMigrations : requiredMigrations).push(description);
118
+ }
119
+ }
120
+ if (requiredMigrations.length === 0 && optionalMigrations.length === 0) {
121
+ return 0;
122
+ }
123
+ // Required migrations
124
+ if (requiredMigrations.length) {
125
+ logger.info(color_1.colors.cyan(`** Executing migrations of package '${packageName}' **\n`));
126
+ requiredMigrations.sort((a, b) => semver.compare(a.version, b.version) || a.name.localeCompare(b.name));
127
+ const result = await executePackageMigrations(workflow, logger, requiredMigrations, packageName, commit);
128
+ if (result === 1) {
129
+ return 1;
130
+ }
131
+ }
132
+ // Optional migrations
133
+ if (optionalMigrations.length) {
134
+ logger.info(color_1.colors.magenta(`** Optional migrations of package '${packageName}' **\n`));
135
+ optionalMigrations.sort((a, b) => semver.compare(a.version, b.version) || a.name.localeCompare(b.name));
136
+ const migrationsToRun = await getOptionalMigrationsToRun(logger, optionalMigrations, packageName);
137
+ if (migrationsToRun?.length) {
138
+ return executePackageMigrations(workflow, logger, migrationsToRun, packageName, commit);
139
+ }
140
+ }
141
+ return 0;
142
+ }
143
+ async function executePackageMigrations(workflow, logger, migrations, packageName, commit = false) {
144
+ for (const migration of migrations) {
145
+ const { title, description } = getMigrationTitleAndDescription(migration);
146
+ logger.info(color_1.colors.cyan(color_1.figures.pointer) + ' ' + color_1.colors.bold(title));
147
+ if (description) {
148
+ logger.info(' ' + description);
149
+ }
150
+ const { success, files } = await executeSchematic(workflow, logger, migration.collection.name, migration.name);
151
+ if (!success) {
152
+ return 1;
153
+ }
154
+ let modifiedFilesText;
155
+ switch (files.size) {
156
+ case 0:
157
+ modifiedFilesText = 'No changes made';
158
+ break;
159
+ case 1:
160
+ modifiedFilesText = '1 file modified';
161
+ break;
162
+ default:
163
+ modifiedFilesText = `${files.size} files modified`;
164
+ break;
165
+ }
166
+ logger.info(` Migration completed (${modifiedFilesText}).`);
167
+ // Commit migration
168
+ if (commit) {
169
+ const commitPrefix = `${packageName} migration - ${migration.name}`;
170
+ const commitMessage = migration.description
171
+ ? `${commitPrefix}\n\n${migration.description}`
172
+ : commitPrefix;
173
+ const committed = commitChanges(logger, commitMessage);
174
+ if (!committed) {
175
+ // Failed to commit, something went wrong. Abort the update.
176
+ return 1;
177
+ }
178
+ }
179
+ logger.info(''); // Extra trailing newline.
180
+ }
181
+ return 0;
182
+ }
183
+ /**
184
+ * @return Whether or not the commit was successful.
185
+ */
186
+ function commitChanges(logger, message) {
187
+ // Check if a commit is needed.
188
+ let commitNeeded;
189
+ try {
190
+ commitNeeded = (0, git_1.hasChangesToCommit)();
191
+ }
192
+ catch (err) {
193
+ logger.error(` Failed to read Git tree:\n${err.stderr}`);
194
+ return false;
195
+ }
196
+ if (!commitNeeded) {
197
+ logger.info(' No changes to commit after migration.');
198
+ return true;
199
+ }
200
+ // Commit changes and abort on error.
201
+ try {
202
+ (0, git_1.createCommit)(message);
203
+ }
204
+ catch (err) {
205
+ logger.error(`Failed to commit update (${message}):\n${err.stderr}`);
206
+ return false;
207
+ }
208
+ // Notify user of the commit.
209
+ const hash = (0, git_1.findCurrentGitSha)();
210
+ const shortMessage = message.split('\n')[0];
211
+ if (hash) {
212
+ logger.info(` Committed migration step (${(0, git_1.getShortHash)(hash)}): ${shortMessage}.`);
213
+ }
214
+ else {
215
+ // Commit was successful, but reading the hash was not. Something weird happened,
216
+ // but nothing that would stop the update. Just log the weirdness and continue.
217
+ logger.info(` Committed migration step: ${shortMessage}.`);
218
+ logger.warn(' Failed to look up hash of most recent commit, continuing anyways.');
219
+ }
220
+ return true;
221
+ }
222
+ async function getOptionalMigrationsToRun(logger, optionalMigrations, packageName) {
223
+ const numberOfMigrations = optionalMigrations.length;
224
+ logger.info(`This package has ${numberOfMigrations} optional migration${numberOfMigrations > 1 ? 's' : ''} that can be executed.`);
225
+ if (!(0, tty_1.isTTY)()) {
226
+ for (const migration of optionalMigrations) {
227
+ const { title } = getMigrationTitleAndDescription(migration);
228
+ logger.info(color_1.colors.cyan(color_1.figures.pointer) + ' ' + color_1.colors.bold(title));
229
+ logger.info(color_1.colors.gray(` ng update ${packageName} --name ${migration.name}`));
230
+ logger.info(''); // Extra trailing newline.
231
+ }
232
+ return undefined;
233
+ }
234
+ logger.info('Optional migrations may be skipped and executed after the update process, if preferred.');
235
+ logger.info(''); // Extra trailing newline.
236
+ const answer = await (0, prompt_1.askChoices)(`Select the migrations that you'd like to run`, optionalMigrations.map((migration) => {
237
+ const { title, documentation } = getMigrationTitleAndDescription(migration);
238
+ return {
239
+ name: `[${color_1.colors.white(migration.name)}] ${title}${documentation ? ` (${documentation})` : ''}`,
240
+ value: migration.name,
241
+ checked: migration.recommended,
242
+ };
243
+ }), null);
244
+ logger.info(''); // Extra trailing newline.
245
+ return optionalMigrations.filter(({ name }) => answer?.includes(name));
246
+ }
247
+ function getMigrationTitleAndDescription(migration) {
248
+ const [title, ...description] = migration.description.split('. ');
249
+ return {
250
+ title: title.endsWith('.') ? title : title + '.',
251
+ description: description.join('.\n '),
252
+ documentation: migration.documentation
253
+ ? new URL(migration.documentation, 'https://angular.dev').href
254
+ : undefined,
255
+ };
256
+ }
257
+ //# sourceMappingURL=migration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration.js","sourceRoot":"","sources":["migration.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCH,4CAqCC;AAKD,4CA0BC;AAKD,8CA8EC;AAiED,sCAyCC;AAhSD,2DAAiG;AAOjG,+CAAiC;AACjC,8FAA4F;AAC5F,oDAA2D;AAC3D,oDAAyD;AACzD,0DAAkE;AAClE,sDAAuD;AACvD,gDAA+C;AAC/C,+CAAoD;AACpD,+BAA0F;AAgBnF,KAAK,UAAU,gBAAgB,CACpC,QAAsB,EACtB,MAAsB,EACtB,UAAkB,EAClB,SAAiB,EACjB,UAAmC,EAAE;IAErC,MAAM,oBAAoB,GAAG,IAAA,wCAAmB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAEnE,oDAAoD;IACpD,IAAI,CAAC;QACH,MAAM,QAAQ;aACX,OAAO,CAAC;YACP,UAAU;YACV,SAAS;YACT,OAAO;YACP,MAAM;S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AW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAElE,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG;QAChD,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC;QACtC,aAAa,EAAE,SAAS,CAAC,aAAa;YACpC,CAAC,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC,IAAI;YAC9D,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC"}
@@ -29,3 +29,15 @@ export declare class PackageManagerError extends Error {
29
29
  */
30
30
  constructor(message: string, stdout: string, stderr: string, exitCode: number | null);
31
31
  }
32
+ /**
33
+ * Represents structured information about an error returned by a package manager command.
34
+ * This is a data interface, not an `Error` subclass.
35
+ */
36
+ export interface ErrorInfo {
37
+ /** A specific error code (e.g. 'E404', 'EACCES'). */
38
+ readonly code: string;
39
+ /** A short, human-readable summary of the error. */
40
+ readonly summary: string;
41
+ /** An optional, detailed description of the error. */
42
+ readonly detail?: string;
43
+ }
@@ -31,9 +31,10 @@ exports.NodeJS_HOST = {
31
31
  deleteDirectory: (path) => (0, promises_1.rm)(path, { recursive: true, force: true }),
32
32
  runCommand: async (command, args, options = {}) => {
33
33
  const signal = options.timeout ? AbortSignal.timeout(options.timeout) : undefined;
34
+ const isWin32 = (0, node_os_1.platform)() === 'win32';
34
35
  return new Promise((resolve, reject) => {
35
- const childProcess = (0, node_child_process_1.spawn)(command, args, {
36
- shell: false,
36
+ const spawnOptions = {
37
+ shell: isWin32,
37
38
  stdio: options.stdio ?? 'pipe',
38
39
  signal,
39
40
  cwd: options.cwd,
@@ -41,7 +42,10 @@ exports.NodeJS_HOST = {
41
42
  ...process.env,
42
43
  ...options.env,
43
44
  },
44
- });
45
+ };
46
+ const childProcess = isWin32
47
+ ? (0, node_child_process_1.spawn)(`${command} ${args.join(' ')}`, spawnOptions)
48
+ : (0, node_child_process_1.spawn)(command, args, spawnOptions);
45
49
  let stdout = '';
46
50
  childProcess.stdout?.on('data', (data) => (stdout += data.toString()));
47
51
  let stderr = '';
@@ -1 +1 @@
1
- {"version":3,"file":"host.js","sourceRoot":"","sources":["host.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH;;;;;GAKG;AAEH,2DAA2C;AAE3C,+CAAmF;AACnF,qCAAiC;AACjC,yCAAiC;AACjC,mCAA8C;AAoE9C;;GAEG;AACU,QAAA,WAAW,GAAS;IAC/B,IAAI,EAAJ,eAAI;IACJ,OAAO,EAAP,kBAAO;IACP,QAAQ,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,mBAAQ,EAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAChE,SAAS,EAAT,oBAAS;IACT,mBAAmB,EAAE,GAAG,EAAE,CAAC,IAAA,kBAAO,EAAC,IAAA,gBAAI,EAAC,IAAA,gBAAM,GAAE,EAAE,cAAc,CAAC,CAAC;IAClE,eAAe,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,aAAE,EAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC7E,UAAU,EAAE,KAAK,EACf,OAAe,EACf,IAAuB,EACvB,UAKI,EAAE,EACuC,EAAE;QAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAElF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,YAAY,GAAG,IAAA,0BAAK,EAAC,OAAO,EAAE,IAAI,EAAE;gBACxC,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,MAAM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,EAAE,CAAC,GAAG,EAAE,EAAE;gBAC/B,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBAC9B,MAAM,OAAO,GAAG,oBAAoB,CAAC;oBACrC,MAAM,CAAC,IAAI,2BAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;oBAE/D,OAAO;gBACT,CAAC;gBACD,MAAM,OAAO,GAAG,8BAA8B,GAAG,CAAC,OAAO,EAAE,CAAC;gBAC5D,MAAM,CAAC,IAAI,2BAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;YACjE,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
@@ -10,10 +10,11 @@
10
10
  * supported package managers. It is the single source of truth for all
11
11
  * package-manager-specific commands, flags, and output parsing.
12
12
  */
13
+ import { ErrorInfo } from './error';
13
14
  import { Logger } from './logger';
14
15
  import { PackageManifest, PackageMetadata } from './package-metadata';
15
16
  import { InstalledPackage } from './package-tree';
16
- import { parseNpmLikeDependencies, parseNpmLikeManifest, parseNpmLikeMetadata, parseYarnClassicDependencies, parseYarnLegacyManifest, parseYarnModernDependencies } from './parsers';
17
+ import { parseNpmLikeDependencies, parseNpmLikeError, parseNpmLikeManifest, parseNpmLikeMetadata, parseYarnClassicDependencies, parseYarnClassicError, parseYarnClassicManifest, parseYarnClassicMetadata, parseYarnModernDependencies } from './parsers';
17
18
  /**
18
19
  * An interface that describes the commands and properties of a package manager.
19
20
  */
@@ -49,6 +50,8 @@ export interface PackageManagerDescriptor {
49
50
  readonly listDependenciesCommand: readonly string[];
50
51
  /** The command to fetch the registry manifest of a package. */
51
52
  readonly getManifestCommand: readonly string[];
53
+ /** Whether a specific version lookup is needed prior to fetching a registry manifest. */
54
+ readonly requiresManifestVersionLookup?: boolean;
52
55
  /** A function that formats the arguments for field-filtered registry views. */
53
56
  readonly viewCommandFieldArgFormatter?: (fields: readonly string[]) => string[];
54
57
  /** A collection of functions to parse the output of specific commands. */
@@ -59,10 +62,20 @@ export interface PackageManagerDescriptor {
59
62
  getRegistryManifest: (stdout: string, logger?: Logger) => PackageManifest | null;
60
63
  /** A function to parse the output of `getManifestCommand` for the full package metadata. */
61
64
  getRegistryMetadata: (stdout: string, logger?: Logger) => PackageMetadata | null;
65
+ /** A function to parse the output when a command fails. */
66
+ getError?: (output: string, logger?: Logger) => ErrorInfo | null;
62
67
  };
68
+ /** A function that checks if a structured error represents a "package not found" error. */
69
+ readonly isNotFound: (error: ErrorInfo) => boolean;
63
70
  }
64
71
  /** A type that represents the name of a supported package manager. */
65
72
  export type PackageManagerName = keyof typeof SUPPORTED_PACKAGE_MANAGERS;
73
+ /**
74
+ * A shared function to check if a structured error represents a "package not found" error.
75
+ * @param error The structured error to check.
76
+ * @returns True if the error code is a known "not found" code, false otherwise.
77
+ */
78
+ declare function isKnownNotFound(error: ErrorInfo): boolean;
66
79
  /**
67
80
  * A map of supported package managers to their descriptors.
68
81
  * This is the single source of truth for all package-manager-specific
@@ -97,7 +110,9 @@ export declare const SUPPORTED_PACKAGE_MANAGERS: {
97
110
  listDependencies: typeof parseNpmLikeDependencies;
98
111
  getRegistryManifest: typeof parseNpmLikeManifest;
99
112
  getRegistryMetadata: typeof parseNpmLikeMetadata;
113
+ getError: typeof parseNpmLikeError;
100
114
  };
115
+ isNotFound: typeof isKnownNotFound;
101
116
  };
102
117
  yarn: {
103
118
  binary: string;
@@ -123,7 +138,9 @@ export declare const SUPPORTED_PACKAGE_MANAGERS: {
123
138
  listDependencies: typeof parseYarnModernDependencies;
124
139
  getRegistryManifest: typeof parseNpmLikeManifest;
125
140
  getRegistryMetadata: typeof parseNpmLikeMetadata;
141
+ getError: typeof parseNpmLikeError;
126
142
  };
143
+ isNotFound: typeof isKnownNotFound;
127
144
  };
128
145
  'yarn-classic': {
129
146
  binary: string;
@@ -142,11 +159,14 @@ export declare const SUPPORTED_PACKAGE_MANAGERS: {
142
159
  versionCommand: string[];
143
160
  listDependenciesCommand: string[];
144
161
  getManifestCommand: string[];
162
+ requiresManifestVersionLookup: true;
145
163
  outputParsers: {
146
164
  listDependencies: typeof parseYarnClassicDependencies;
147
- getRegistryManifest: typeof parseYarnLegacyManifest;
148
- getRegistryMetadata: typeof parseNpmLikeMetadata;
165
+ getRegistryManifest: typeof parseYarnClassicManifest;
166
+ getRegistryMetadata: typeof parseYarnClassicMetadata;
167
+ getError: typeof parseYarnClassicError;
149
168
  };
169
+ isNotFound: typeof isKnownNotFound;
150
170
  };
151
171
  pnpm: {
152
172
  binary: string;
@@ -170,7 +190,9 @@ export declare const SUPPORTED_PACKAGE_MANAGERS: {
170
190
  listDependencies: typeof parseNpmLikeDependencies;
171
191
  getRegistryManifest: typeof parseNpmLikeManifest;
172
192
  getRegistryMetadata: typeof parseNpmLikeMetadata;
193
+ getError: typeof parseNpmLikeError;
173
194
  };
195
+ isNotFound: typeof isKnownNotFound;
174
196
  };
175
197
  bun: {
176
198
  binary: string;
@@ -189,12 +211,13 @@ export declare const SUPPORTED_PACKAGE_MANAGERS: {
189
211
  versionCommand: string[];
190
212
  listDependenciesCommand: string[];
191
213
  getManifestCommand: string[];
192
- viewCommandFieldArgFormatter: (fields: readonly string[]) => string[];
193
214
  outputParsers: {
194
215
  listDependencies: typeof parseNpmLikeDependencies;
195
216
  getRegistryManifest: typeof parseNpmLikeManifest;
196
217
  getRegistryMetadata: typeof parseNpmLikeMetadata;
218
+ getError: typeof parseNpmLikeError;
197
219
  };
220
+ isNotFound: typeof isKnownNotFound;
198
221
  };
199
222
  };
200
223
  /**
@@ -202,3 +225,4 @@ export declare const SUPPORTED_PACKAGE_MANAGERS: {
202
225
  * This is a best-effort ordering based on estimated Angular community usage and default presence.
203
226
  */
204
227
  export declare const PACKAGE_MANAGER_PRECEDENCE: readonly PackageManagerName[];
228
+ export {};