@angular/cli 21.0.0-next.0 → 21.0.0-next.10

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 (226) hide show
  1. package/lib/cli/index.js +1 -0
  2. package/lib/cli/index.js.map +1 -0
  3. package/lib/code-examples.db +0 -0
  4. package/lib/config/schema.json +276 -51
  5. package/lib/config/workspace-schema.d.ts +57 -2
  6. package/lib/config/workspace-schema.js +23 -2
  7. package/lib/config/workspace-schema.js.map +1 -0
  8. package/lib/init.js +1 -0
  9. package/lib/init.js.map +1 -0
  10. package/package.json +24 -23
  11. package/src/analytics/analytics-collector.js +1 -0
  12. package/src/analytics/analytics-collector.js.map +1 -0
  13. package/src/analytics/analytics-parameters.js +1 -0
  14. package/src/analytics/analytics-parameters.js.map +1 -0
  15. package/src/analytics/analytics.js +1 -0
  16. package/src/analytics/analytics.js.map +1 -0
  17. package/src/command-builder/architect-base-command-module.js +1 -0
  18. package/src/command-builder/architect-base-command-module.js.map +1 -0
  19. package/src/command-builder/architect-command-module.js +21 -7
  20. package/src/command-builder/architect-command-module.js.map +1 -0
  21. package/src/command-builder/command-module.js +1 -0
  22. package/src/command-builder/command-module.js.map +1 -0
  23. package/src/command-builder/command-runner.js +2 -2
  24. package/src/command-builder/command-runner.js.map +1 -0
  25. package/src/command-builder/schematics-command-module.js +8 -2
  26. package/src/command-builder/schematics-command-module.js.map +1 -0
  27. package/src/command-builder/utilities/command.js +1 -0
  28. package/src/command-builder/utilities/command.js.map +1 -0
  29. package/src/command-builder/utilities/json-help.js +1 -0
  30. package/src/command-builder/utilities/json-help.js.map +1 -0
  31. package/src/command-builder/utilities/json-schema.d.ts +13 -1
  32. package/src/command-builder/utilities/json-schema.js +180 -96
  33. package/src/command-builder/utilities/json-schema.js.map +1 -0
  34. package/src/command-builder/utilities/normalize-options-middleware.js +1 -0
  35. package/src/command-builder/utilities/normalize-options-middleware.js.map +1 -0
  36. package/src/command-builder/utilities/schematic-engine-host.js +5 -6
  37. package/src/command-builder/utilities/schematic-engine-host.js.map +1 -0
  38. package/src/command-builder/utilities/schematic-workflow.js +1 -0
  39. package/src/command-builder/utilities/schematic-workflow.js.map +1 -0
  40. package/src/commands/add/cli.d.ts +2 -1
  41. package/src/commands/add/cli.js +179 -94
  42. package/src/commands/add/cli.js.map +1 -0
  43. package/src/commands/analytics/cli.js +1 -0
  44. package/src/commands/analytics/cli.js.map +1 -0
  45. package/src/commands/analytics/info/cli.js +1 -0
  46. package/src/commands/analytics/info/cli.js.map +1 -0
  47. package/src/commands/analytics/settings/cli.js +1 -0
  48. package/src/commands/analytics/settings/cli.js.map +1 -0
  49. package/src/commands/build/cli.js +1 -0
  50. package/src/commands/build/cli.js.map +1 -0
  51. package/src/commands/cache/clean/cli.js +1 -0
  52. package/src/commands/cache/clean/cli.js.map +1 -0
  53. package/src/commands/cache/cli.js +1 -0
  54. package/src/commands/cache/cli.js.map +1 -0
  55. package/src/commands/cache/info/cli.js +36 -11
  56. package/src/commands/cache/info/cli.js.map +1 -0
  57. package/src/commands/cache/settings/cli.js +1 -0
  58. package/src/commands/cache/settings/cli.js.map +1 -0
  59. package/src/commands/cache/utilities.js +1 -0
  60. package/src/commands/cache/utilities.js.map +1 -0
  61. package/src/commands/command-config.js +1 -0
  62. package/src/commands/command-config.js.map +1 -0
  63. package/src/commands/completion/cli.js +1 -0
  64. package/src/commands/completion/cli.js.map +1 -0
  65. package/src/commands/config/cli.js +1 -0
  66. package/src/commands/config/cli.js.map +1 -0
  67. package/src/commands/deploy/cli.js +1 -0
  68. package/src/commands/deploy/cli.js.map +1 -0
  69. package/src/commands/e2e/cli.js +1 -0
  70. package/src/commands/e2e/cli.js.map +1 -0
  71. package/src/commands/extract-i18n/cli.js +1 -0
  72. package/src/commands/extract-i18n/cli.js.map +1 -0
  73. package/src/commands/generate/cli.js +1 -0
  74. package/src/commands/generate/cli.js.map +1 -0
  75. package/src/commands/lint/cli.js +1 -0
  76. package/src/commands/lint/cli.js.map +1 -0
  77. package/src/commands/make-this-awesome/cli.js +1 -0
  78. package/src/commands/make-this-awesome/cli.js.map +1 -0
  79. package/src/commands/mcp/cli.js +1 -0
  80. package/src/commands/mcp/cli.js.map +1 -0
  81. package/src/commands/mcp/constants.d.ts +1 -1
  82. package/src/commands/mcp/constants.js +2 -1
  83. package/src/commands/mcp/constants.js.map +1 -0
  84. package/src/commands/mcp/mcp-server.d.ts +3 -3
  85. package/src/commands/mcp/mcp-server.js +40 -4
  86. package/src/commands/mcp/mcp-server.js.map +1 -0
  87. package/src/commands/mcp/resources/ai-tutor.md +627 -0
  88. package/src/commands/mcp/resources/instructions.js +1 -0
  89. package/src/commands/mcp/resources/instructions.js.map +1 -0
  90. package/src/commands/mcp/tools/ai-tutor.d.ts +8 -0
  91. package/src/commands/mcp/tools/ai-tutor.js +62 -0
  92. package/src/commands/mcp/tools/ai-tutor.js.map +1 -0
  93. package/src/commands/mcp/tools/best-practices.d.ts +4 -1
  94. package/src/commands/mcp/tools/best-practices.js +167 -22
  95. package/src/commands/mcp/tools/best-practices.js.map +1 -0
  96. package/src/commands/mcp/tools/doc-search.d.ts +20 -1
  97. package/src/commands/mcp/tools/doc-search.js +186 -67
  98. package/src/commands/mcp/tools/doc-search.js.map +1 -0
  99. package/src/commands/mcp/tools/examples.d.ts +35 -1
  100. package/src/commands/mcp/tools/examples.js +414 -56
  101. package/src/commands/mcp/tools/examples.js.map +1 -0
  102. package/src/commands/mcp/tools/modernize.js +29 -27
  103. package/src/commands/mcp/tools/modernize.js.map +1 -0
  104. package/src/commands/mcp/tools/onpush-zoneless-migration/analyze_for_unsupported_zone_uses.d.ts +17 -0
  105. package/src/commands/mcp/tools/onpush-zoneless-migration/analyze_for_unsupported_zone_uses.js +62 -0
  106. package/src/commands/mcp/tools/onpush-zoneless-migration/analyze_for_unsupported_zone_uses.js.map +1 -0
  107. package/src/commands/mcp/tools/onpush-zoneless-migration/migrate_single_file.d.ts +12 -0
  108. package/src/commands/mcp/tools/onpush-zoneless-migration/migrate_single_file.js +73 -0
  109. package/src/commands/mcp/tools/onpush-zoneless-migration/migrate_single_file.js.map +1 -0
  110. package/src/commands/mcp/tools/onpush-zoneless-migration/migrate_test_file.d.ts +11 -0
  111. package/src/commands/mcp/tools/onpush-zoneless-migration/migrate_test_file.js +106 -0
  112. package/src/commands/mcp/tools/onpush-zoneless-migration/migrate_test_file.js.map +1 -0
  113. package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.d.ts +15 -0
  114. package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.js +238 -0
  115. package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.js.map +1 -0
  116. package/src/commands/mcp/tools/onpush-zoneless-migration/send_debug_message.d.ts +10 -0
  117. package/src/commands/mcp/tools/onpush-zoneless-migration/send_debug_message.js +20 -0
  118. package/src/commands/mcp/tools/onpush-zoneless-migration/send_debug_message.js.map +1 -0
  119. package/src/commands/mcp/tools/onpush-zoneless-migration/ts_utils.d.ts +36 -0
  120. package/src/commands/mcp/tools/onpush-zoneless-migration/ts_utils.js +136 -0
  121. package/src/commands/mcp/tools/onpush-zoneless-migration/ts_utils.js.map +1 -0
  122. package/src/commands/mcp/tools/onpush-zoneless-migration/types.d.ts +13 -0
  123. package/src/commands/mcp/tools/onpush-zoneless-migration/types.js +10 -0
  124. package/src/commands/mcp/tools/onpush-zoneless-migration/types.js.map +1 -0
  125. package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.d.ts +14 -0
  126. package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js +228 -0
  127. package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js.map +1 -0
  128. package/src/commands/mcp/tools/projects.d.ts +75 -16
  129. package/src/commands/mcp/tools/projects.js +427 -30
  130. package/src/commands/mcp/tools/projects.js.map +1 -0
  131. package/src/commands/mcp/tools/tool-registry.d.ts +2 -1
  132. package/src/commands/mcp/tools/tool-registry.js +4 -2
  133. package/src/commands/mcp/tools/tool-registry.js.map +1 -0
  134. package/src/commands/new/cli.js +2 -0
  135. package/src/commands/new/cli.js.map +1 -0
  136. package/src/commands/run/cli.js +1 -0
  137. package/src/commands/run/cli.js.map +1 -0
  138. package/src/commands/serve/cli.js +1 -0
  139. package/src/commands/serve/cli.js.map +1 -0
  140. package/src/commands/test/cli.js +1 -0
  141. package/src/commands/test/cli.js.map +1 -0
  142. package/src/commands/update/cli.js +1 -0
  143. package/src/commands/update/cli.js.map +1 -0
  144. package/src/commands/update/schematic/index.js +1 -0
  145. package/src/commands/update/schematic/index.js.map +1 -0
  146. package/src/commands/update/schematic/schema.d.ts +0 -1
  147. package/src/commands/update/schematic/schema.js +1 -1
  148. package/src/commands/update/schematic/schema.js.map +1 -0
  149. package/src/commands/update/schematic/schema.json +1 -1
  150. package/src/commands/version/cli.d.ts +3 -7
  151. package/src/commands/version/cli.js +50 -49
  152. package/src/commands/version/cli.js.map +1 -0
  153. package/src/commands/version/version-info.d.ts +28 -10
  154. package/src/commands/version/version-info.js +34 -50
  155. package/src/commands/version/version-info.js.map +1 -0
  156. package/src/package-managers/discovery.d.ts +23 -0
  157. package/src/package-managers/discovery.js +110 -0
  158. package/src/package-managers/discovery.js.map +1 -0
  159. package/src/package-managers/error.d.ts +31 -0
  160. package/src/package-managers/error.js +41 -0
  161. package/src/package-managers/error.js.map +1 -0
  162. package/src/package-managers/factory.d.ts +25 -0
  163. package/src/package-managers/factory.js +123 -0
  164. package/src/package-managers/factory.js.map +1 -0
  165. package/src/package-managers/host.d.ts +64 -0
  166. package/src/package-managers/host.js +69 -0
  167. package/src/package-managers/host.js.map +1 -0
  168. package/src/package-managers/index.d.ts +12 -0
  169. package/src/package-managers/index.js +15 -0
  170. package/src/package-managers/index.js.map +1 -0
  171. package/src/package-managers/logger.d.ts +27 -0
  172. package/src/package-managers/logger.js +10 -0
  173. package/src/package-managers/logger.js.map +1 -0
  174. package/src/package-managers/package-manager-descriptor.d.ts +204 -0
  175. package/src/package-managers/package-manager-descriptor.js +147 -0
  176. package/src/package-managers/package-manager-descriptor.js.map +1 -0
  177. package/src/package-managers/package-manager.d.ts +144 -0
  178. package/src/package-managers/package-manager.js +304 -0
  179. package/src/package-managers/package-manager.js.map +1 -0
  180. package/src/package-managers/package-metadata.d.ts +87 -0
  181. package/src/package-managers/package-metadata.js +10 -0
  182. package/src/package-managers/package-metadata.js.map +1 -0
  183. package/src/package-managers/package-tree.d.ts +23 -0
  184. package/src/package-managers/package-tree.js +10 -0
  185. package/src/package-managers/package-tree.js.map +1 -0
  186. package/src/package-managers/parsers.d.ts +92 -0
  187. package/src/package-managers/parsers.js +234 -0
  188. package/src/package-managers/parsers.js.map +1 -0
  189. package/src/package-managers/testing/mock-host.d.ts +26 -0
  190. package/src/package-managers/testing/mock-host.js +53 -0
  191. package/src/package-managers/testing/mock-host.js.map +1 -0
  192. package/src/utilities/color.js +1 -0
  193. package/src/utilities/color.js.map +1 -0
  194. package/src/utilities/completion.js +1 -0
  195. package/src/utilities/completion.js.map +1 -0
  196. package/src/utilities/config.js +1 -0
  197. package/src/utilities/config.js.map +1 -0
  198. package/src/utilities/environment-options.js +1 -0
  199. package/src/utilities/environment-options.js.map +1 -0
  200. package/src/utilities/eol.js +1 -0
  201. package/src/utilities/eol.js.map +1 -0
  202. package/src/utilities/error.js +1 -0
  203. package/src/utilities/error.js.map +1 -0
  204. package/src/utilities/find-up.js +1 -0
  205. package/src/utilities/find-up.js.map +1 -0
  206. package/src/utilities/json-file.js +1 -0
  207. package/src/utilities/json-file.js.map +1 -0
  208. package/src/utilities/log-file.js +1 -0
  209. package/src/utilities/log-file.js.map +1 -0
  210. package/src/utilities/memoize.js +1 -0
  211. package/src/utilities/memoize.js.map +1 -0
  212. package/src/utilities/package-manager.d.ts +12 -0
  213. package/src/utilities/package-manager.js +52 -35
  214. package/src/utilities/package-manager.js.map +1 -0
  215. package/src/utilities/package-metadata.js +1 -0
  216. package/src/utilities/package-metadata.js.map +1 -0
  217. package/src/utilities/package-tree.js +1 -0
  218. package/src/utilities/package-tree.js.map +1 -0
  219. package/src/utilities/project.js +1 -0
  220. package/src/utilities/project.js.map +1 -0
  221. package/src/utilities/prompt.js +1 -0
  222. package/src/utilities/prompt.js.map +1 -0
  223. package/src/utilities/tty.js +1 -0
  224. package/src/utilities/tty.js.map +1 -0
  225. package/src/utilities/version.js +2 -1
  226. package/src/utilities/version.js.map +1 -0
@@ -0,0 +1,304 @@
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.PackageManager = void 0;
11
+ /**
12
+ * @fileoverview This file contains the `PackageManager` class, which is the
13
+ * core execution engine for all package manager commands. It is designed to be
14
+ * a flexible and secure abstraction over the various package managers.
15
+ */
16
+ const node_path_1 = require("node:path");
17
+ const error_1 = require("./error");
18
+ /**
19
+ * The fields to request from the registry for package metadata.
20
+ * This is a performance optimization to avoid downloading the full manifest
21
+ * when only summary data (like versions and tags) is needed.
22
+ */
23
+ const METADATA_FIELDS = ['name', 'dist-tags', 'versions', 'time'];
24
+ /**
25
+ * The fields to request from the registry for a package's manifest.
26
+ * This is a performance optimization to avoid downloading unnecessary data.
27
+ * These fields are the ones required by the CLI for operations like `ng add` and `ng update`.
28
+ */
29
+ const MANIFEST_FIELDS = [
30
+ 'name',
31
+ 'version',
32
+ 'deprecated',
33
+ 'dependencies',
34
+ 'peerDependencies',
35
+ 'devDependencies',
36
+ 'homepage',
37
+ 'schematics',
38
+ 'ng-add',
39
+ 'ng-update',
40
+ ];
41
+ /**
42
+ * A class that provides a high-level, package-manager-agnostic API for
43
+ * interacting with a project's dependencies.
44
+ *
45
+ * This class is an implementation of the Strategy design pattern. It is
46
+ * instantiated with a `PackageManagerDescriptor` that defines the specific
47
+ * commands and flags for a given package manager.
48
+ */
49
+ class PackageManager {
50
+ host;
51
+ cwd;
52
+ descriptor;
53
+ options;
54
+ #manifestCache = new Map();
55
+ #metadataCache = new Map();
56
+ #dependencyCache = null;
57
+ /**
58
+ * Creates a new `PackageManager` instance.
59
+ * @param host A `Host` instance for interacting with the file system and running commands.
60
+ * @param cwd The absolute path to the project's working directory.
61
+ * @param descriptor A `PackageManagerDescriptor` that defines the commands for a specific package manager.
62
+ * @param options An options object to configure the instance.
63
+ */
64
+ constructor(host, cwd, descriptor, options = {}) {
65
+ this.host = host;
66
+ this.cwd = cwd;
67
+ this.descriptor = descriptor;
68
+ this.options = options;
69
+ if (this.options.dryRun && !this.options.logger) {
70
+ throw new Error('A logger must be provided when dryRun is enabled.');
71
+ }
72
+ }
73
+ /**
74
+ * The name of the package manager's binary.
75
+ */
76
+ get name() {
77
+ return this.descriptor.binary;
78
+ }
79
+ /**
80
+ * A private method to lazily populate the dependency cache.
81
+ * This is a performance optimization to avoid running `npm list` multiple times.
82
+ * @returns A promise that resolves to the dependency cache map.
83
+ */
84
+ async #populateDependencyCache() {
85
+ if (this.#dependencyCache !== null) {
86
+ return this.#dependencyCache;
87
+ }
88
+ const args = this.descriptor.listDependenciesCommand;
89
+ const dependencies = await this.#fetchAndParse(args, (stdout, logger) => this.descriptor.outputParsers.listDependencies(stdout, logger));
90
+ return (this.#dependencyCache = dependencies ?? new Map());
91
+ }
92
+ /**
93
+ * A private method to run a command using the package manager's binary.
94
+ * @param args The arguments to pass to the command.
95
+ * @param options Options for the child process.
96
+ * @returns A promise that resolves with the standard output and standard error of the command.
97
+ */
98
+ async #run(args, options = {}) {
99
+ const { registry, cwd, ...runOptions } = options;
100
+ const finalArgs = [...args];
101
+ let finalEnv;
102
+ if (registry) {
103
+ const registryOptions = this.descriptor.getRegistryOptions?.(registry);
104
+ if (!registryOptions) {
105
+ throw new Error(`The configured package manager, '${this.descriptor.binary}', does not support a custom registry.`);
106
+ }
107
+ if (registryOptions.args) {
108
+ finalArgs.push(...registryOptions.args);
109
+ }
110
+ if (registryOptions.env) {
111
+ finalEnv = registryOptions.env;
112
+ }
113
+ }
114
+ const executionDirectory = cwd ?? this.cwd;
115
+ if (this.options.dryRun) {
116
+ this.options.logger?.info(`[DRY RUN] Would execute in [${executionDirectory}]: ${this.descriptor.binary} ${finalArgs.join(' ')}`);
117
+ return { stdout: '', stderr: '' };
118
+ }
119
+ return this.host.runCommand(this.descriptor.binary, finalArgs, {
120
+ ...runOptions,
121
+ cwd: executionDirectory,
122
+ stdio: 'pipe',
123
+ env: finalEnv,
124
+ });
125
+ }
126
+ /**
127
+ * A private, generic method to encapsulate the common logic of running a command,
128
+ * handling errors, and parsing the output.
129
+ * @param args The arguments to pass to the command.
130
+ * @param parser A function that parses the command's stdout.
131
+ * @param options Options for the command, including caching.
132
+ * @returns A promise that resolves to the parsed data, or null if not found.
133
+ */
134
+ async #fetchAndParse(args, parser, options = {}) {
135
+ const { cache, cacheKey, bypassCache, ...runOptions } = options;
136
+ if (!bypassCache && cache && cacheKey && cache.has(cacheKey)) {
137
+ return cache.get(cacheKey);
138
+ }
139
+ let stdout;
140
+ let stderr;
141
+ try {
142
+ ({ stdout, stderr } = await this.#run(args, runOptions));
143
+ }
144
+ catch (e) {
145
+ if (e instanceof error_1.PackageManagerError && typeof e.exitCode === 'number' && e.exitCode !== 0) {
146
+ // Some package managers exit with a non-zero code when the package is not found.
147
+ if (cache && cacheKey) {
148
+ cache.set(cacheKey, null);
149
+ }
150
+ return null;
151
+ }
152
+ throw e;
153
+ }
154
+ try {
155
+ const result = parser(stdout, this.options.logger);
156
+ if (cache && cacheKey) {
157
+ cache.set(cacheKey, result);
158
+ }
159
+ return result;
160
+ }
161
+ catch (e) {
162
+ const message = `Failed to parse package manager output: ${e instanceof Error ? e.message : ''}`;
163
+ throw new error_1.PackageManagerError(message, stdout, stderr, 0);
164
+ }
165
+ }
166
+ /**
167
+ * Adds a package to the project's dependencies.
168
+ * @param packageName The name of the package to add.
169
+ * @param save The save strategy to use.
170
+ * - `exact`: The package will be saved with an exact version.
171
+ * - `tilde`: The package will be saved with a tilde version range (`~`).
172
+ * - `none`: The package will be saved with the default version range (`^`).
173
+ * @param asDevDependency Whether to install the package as a dev dependency.
174
+ * @param noLockfile Whether to skip updating the lockfile.
175
+ * @param options Extra options for the command.
176
+ * @returns A promise that resolves when the command is complete.
177
+ */
178
+ async add(packageName, save, asDevDependency, noLockfile, ignoreScripts, options = {}) {
179
+ const flags = [
180
+ asDevDependency ? this.descriptor.saveDevFlag : '',
181
+ save === 'exact' ? this.descriptor.saveExactFlag : '',
182
+ save === 'tilde' ? this.descriptor.saveTildeFlag : '',
183
+ noLockfile ? this.descriptor.noLockfileFlag : '',
184
+ ignoreScripts ? this.descriptor.ignoreScriptsFlag : '',
185
+ ].filter((flag) => flag);
186
+ const args = [this.descriptor.addCommand, packageName, ...flags];
187
+ await this.#run(args, options);
188
+ this.#dependencyCache = null;
189
+ }
190
+ /**
191
+ * Installs all dependencies in the project.
192
+ * @param options Options for the installation.
193
+ * @param options.timeout The maximum time in milliseconds to wait for the command to complete.
194
+ * @param options.force If true, forces a clean install, potentially overwriting existing modules.
195
+ * @param options.registry The registry to use for the installation.
196
+ * @param options.ignoreScripts If true, prevents lifecycle scripts from being executed.
197
+ * @returns A promise that resolves when the command is complete.
198
+ */
199
+ async install(options = { ignoreScripts: true }) {
200
+ const flags = [
201
+ options.force ? this.descriptor.forceFlag : '',
202
+ options.ignoreScripts ? this.descriptor.ignoreScriptsFlag : '',
203
+ ].filter((flag) => flag);
204
+ const args = [...this.descriptor.installCommand, ...flags];
205
+ await this.#run(args, options);
206
+ this.#dependencyCache = null;
207
+ }
208
+ /**
209
+ * Gets the version of the package manager binary.
210
+ * @returns A promise that resolves to the trimmed version string.
211
+ */
212
+ async getVersion() {
213
+ const { stdout } = await this.#run(this.descriptor.versionCommand);
214
+ return stdout.trim();
215
+ }
216
+ /**
217
+ * Gets the installed details of a package from the project's dependencies.
218
+ * @param packageName The name of the package to check.
219
+ * @returns A promise that resolves to the installed package details, or `null` if the package is not installed.
220
+ */
221
+ async getInstalledPackage(packageName) {
222
+ const cache = await this.#populateDependencyCache();
223
+ return cache.get(packageName) ?? null;
224
+ }
225
+ /**
226
+ * Gets a map of all top-level dependencies installed in the project.
227
+ * @returns A promise that resolves to a map of package names to their installed package details.
228
+ */
229
+ async getProjectDependencies() {
230
+ const cache = await this.#populateDependencyCache();
231
+ // Return a copy to prevent external mutations of the cache.
232
+ return new Map(cache);
233
+ }
234
+ /**
235
+ * Fetches the registry metadata for a package. This is the full metadata,
236
+ * including all versions and distribution tags.
237
+ * @param packageName The name of the package to fetch the metadata for.
238
+ * @param options Options for the fetch.
239
+ * @param options.timeout The maximum time in milliseconds to wait for the command to complete.
240
+ * @param options.registry The registry to use for the fetch.
241
+ * @param options.bypassCache If true, ignores the in-memory cache and fetches fresh data.
242
+ * @returns A promise that resolves to the `PackageMetadata` object, or `null` if the package is not found.
243
+ */
244
+ async getRegistryMetadata(packageName, options = {}) {
245
+ const commandArgs = [...this.descriptor.getManifestCommand, packageName];
246
+ const formatter = this.descriptor.viewCommandFieldArgFormatter;
247
+ if (formatter) {
248
+ commandArgs.push(...formatter(METADATA_FIELDS));
249
+ }
250
+ const cacheKey = options.registry ? `${packageName}|${options.registry}` : packageName;
251
+ return this.#fetchAndParse(commandArgs, (stdout, logger) => this.descriptor.outputParsers.getRegistryMetadata(stdout, logger), { ...options, cache: this.#metadataCache, cacheKey });
252
+ }
253
+ /**
254
+ * Fetches the registry manifest for a specific version of a package.
255
+ * The manifest is similar to the package's `package.json` file.
256
+ * @param packageName The name of the package to fetch the manifest for.
257
+ * @param version The version of the package to fetch the manifest for.
258
+ * @param options Options for the fetch.
259
+ * @param options.timeout The maximum time in milliseconds to wait for the command to complete.
260
+ * @param options.registry The registry to use for the fetch.
261
+ * @param options.bypassCache If true, ignores the in-memory cache and fetches fresh data.
262
+ * @returns A promise that resolves to the `PackageManifest` object, or `null` if the package is not found.
263
+ */
264
+ async getPackageManifest(packageName, version, options = {}) {
265
+ const specifier = `${packageName}@${version}`;
266
+ const commandArgs = [...this.descriptor.getManifestCommand, specifier];
267
+ const formatter = this.descriptor.viewCommandFieldArgFormatter;
268
+ if (formatter) {
269
+ commandArgs.push(...formatter(MANIFEST_FIELDS));
270
+ }
271
+ const cacheKey = options.registry ? `${specifier}|${options.registry}` : specifier;
272
+ return this.#fetchAndParse(commandArgs, (stdout, logger) => this.descriptor.outputParsers.getPackageManifest(stdout, logger), { ...options, cache: this.#manifestCache, cacheKey });
273
+ }
274
+ /**
275
+ * Acquires a package by installing it into a temporary directory. The caller is
276
+ * responsible for managing the lifecycle of the temporary directory by calling
277
+ * the returned `cleanup` function.
278
+ *
279
+ * @param packageName The name of the package to install.
280
+ * @param options Options for the installation.
281
+ * @returns A promise that resolves to an object containing the temporary path
282
+ * and a cleanup function.
283
+ */
284
+ async acquireTempPackage(packageName, options = {}) {
285
+ const workingDirectory = await this.host.createTempDirectory();
286
+ const cleanup = () => this.host.deleteDirectory(workingDirectory);
287
+ // Some package managers, like yarn classic, do not write a package.json when adding a package.
288
+ // This can cause issues with subsequent `require.resolve` calls.
289
+ // Writing an empty package.json file beforehand prevents this.
290
+ await this.host.writeFile((0, node_path_1.join)(workingDirectory, 'package.json'), '{}');
291
+ const args = [this.descriptor.addCommand, packageName];
292
+ try {
293
+ await this.#run(args, { ...options, cwd: workingDirectory });
294
+ }
295
+ catch (e) {
296
+ // If the command fails, clean up the temporary directory immediately.
297
+ await cleanup();
298
+ throw e;
299
+ }
300
+ return { workingDirectory, cleanup };
301
+ }
302
+ }
303
+ exports.PackageManager = PackageManager;
304
+ //# sourceMappingURL=package-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-manager.js","sourceRoot":"","sources":["package-manager.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH;;;;GAIG;AAEH,yCAAiC;AACjC,mCAA8C;AAO9C;;;;GAIG;AACH,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU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+ *
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
+ * @fileoverview
10
+ * This file defines the core interfaces for package metadata and manifests,
11
+ * providing a strongly-typed representation of the data returned by a package
12
+ * manager registry. These interfaces are crucial for features like `ng add`
13
+ * and `ng update`.
14
+ */
15
+ /**
16
+ * Defines how a package's dependencies should be saved to `package.json`
17
+ * after being installed by the `ng add` command.
18
+ *
19
+ * - `dependencies`: Save to the `dependencies` section.
20
+ * - `devDependencies`: Save to the `devDependencies` section.
21
+ * - `false`: Do not save to `package.json`.
22
+ */
23
+ export type NgAddSaveDependency = 'dependencies' | 'devDependencies' | false;
24
+ /**
25
+ * Represents the configuration for `ng add` found in a package's manifest.
26
+ */
27
+ export interface NgAdd {
28
+ /**
29
+ * Specifies how the package should be saved to `package.json`.
30
+ * @see NgAddSaveDependency
31
+ */
32
+ save?: NgAddSaveDependency;
33
+ }
34
+ /**
35
+ * Represents the configuration for `ng update` found in a package's manifest.
36
+ */
37
+ export interface NgUpdate {
38
+ /**
39
+ * The path to the schematics collection for migrations.
40
+ */
41
+ migrations?: string;
42
+ /**
43
+ * A list of package names that should be updated together.
44
+ */
45
+ packageGroup?: string[];
46
+ }
47
+ /**
48
+ * Represents the full metadata for a package available in the registry.
49
+ * This includes a list of all available versions and distribution tags.
50
+ */
51
+ export interface PackageMetadata {
52
+ /** The name of the package. */
53
+ name: string;
54
+ /** A mapping of distribution tags (e.g., 'latest', 'next') to version numbers. */
55
+ 'dist-tags': Record<string, string>;
56
+ /** An array of all available version strings for the package. */
57
+ versions: string[];
58
+ /** A mapping of version numbers to their ISO 8601 publication time string. */
59
+ time?: Record<string, string>;
60
+ }
61
+ /**
62
+ * Represents the manifest (similar to `package.json`) for a specific version of a package.
63
+ * It contains metadata essential for the Angular CLI to perform operations like
64
+ * `ng add` and `ng update`.
65
+ */
66
+ export interface PackageManifest {
67
+ /** The name of the package. */
68
+ name: string;
69
+ /** The version of the package. */
70
+ version: string;
71
+ /** A message indicating that the package version is deprecated. */
72
+ deprecated?: string;
73
+ /** A mapping of production dependencies. */
74
+ dependencies?: Record<string, string>;
75
+ /** A mapping of peer dependencies. */
76
+ peerDependencies?: Record<string, string>;
77
+ /** A mapping of development dependencies. */
78
+ devDependencies?: Record<string, string>;
79
+ /** The URL to the package's homepage. */
80
+ homepage?: string;
81
+ /** The path to the schematics collection definition, used by `ng generate`. */
82
+ schematics?: string;
83
+ /** Configuration for the `ng add` command. */
84
+ 'ng-add'?: NgAdd;
85
+ /** Configuration for the `ng update` command. */
86
+ 'ng-update'?: NgUpdate;
87
+ }
@@ -0,0 +1,10 @@
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
+ //# sourceMappingURL=package-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-metadata.js","sourceRoot":"","sources":["package-metadata.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
@@ -0,0 +1,23 @@
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
+ * @fileoverview
10
+ * This file defines the interfaces for representing a project's installed
11
+ * package dependency tree.
12
+ */
13
+ /**
14
+ * Represents a package that is installed in the project's node_modules.
15
+ */
16
+ export interface InstalledPackage {
17
+ /** The name of the package. */
18
+ readonly name: string;
19
+ /** The installed version of the package. */
20
+ readonly version: string;
21
+ /** The absolute path to the package's directory on disk, if available. */
22
+ readonly path?: string;
23
+ }
@@ -0,0 +1,10 @@
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
+ //# sourceMappingURL=package-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-tree.js","sourceRoot":"","sources":["package-tree.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
@@ -0,0 +1,92 @@
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
+ * @fileoverview This file contains the parser functions that are used to
10
+ * interpret the output of various package manager commands. Separating these
11
+ * into their own file improves modularity and allows for focused testing.
12
+ */
13
+ import { Logger } from './logger';
14
+ import { PackageManifest, PackageMetadata } from './package-metadata';
15
+ import { InstalledPackage } from './package-tree';
16
+ /**
17
+ * Parses the output of `npm list` or a compatible command.
18
+ *
19
+ * The expected JSON structure is:
20
+ * ```json
21
+ * {
22
+ * "dependencies": {
23
+ * "@angular/cli": {
24
+ * "version": "18.0.0",
25
+ * "path": "/path/to/project/node_modules/@angular/cli", // path is optional
26
+ * ... (other package.json properties)
27
+ * }
28
+ * }
29
+ * }
30
+ * ```
31
+ *
32
+ * @param stdout The standard output of the command.
33
+ * @param logger An optional logger instance.
34
+ * @returns A map of package names to their installed package details.
35
+ */
36
+ export declare function parseNpmLikeDependencies(stdout: string, logger?: Logger): Map<string, InstalledPackage>;
37
+ /**
38
+ * Parses the output of `yarn list` (classic).
39
+ *
40
+ * The expected output is a JSON stream (JSONL), where each line is a JSON object.
41
+ * The relevant object has a `type` of `'tree'`.
42
+ * Yarn classic does not provide a path, so the `path` property will be `undefined`.
43
+ *
44
+ * ```json
45
+ * {"type":"tree","data":{"trees":[{"name":"@angular/cli@18.0.0","children":[]}]}}
46
+ * ```
47
+ *
48
+ * @param stdout The standard output of the command.
49
+ * @param logger An optional logger instance.
50
+ * @returns A map of package names to their installed package details.
51
+ */
52
+ export declare function parseYarnClassicDependencies(stdout: string, logger?: Logger): Map<string, InstalledPackage>;
53
+ /**
54
+ * Parses the output of `yarn list` (modern).
55
+ *
56
+ * The expected JSON structure is a single object.
57
+ * Yarn modern does not provide a path, so the `path` property will be `undefined`.
58
+ *
59
+ * ```json
60
+ * {
61
+ * "trees": [
62
+ * { "name": "@angular/cli@18.0.0", "children": [] }
63
+ * ]
64
+ * }
65
+ * ```
66
+ *
67
+ * @param stdout The standard output of the command.
68
+ * @param logger An optional logger instance.
69
+ * @returns A map of package names to their installed package details.
70
+ */
71
+ export declare function parseYarnModernDependencies(stdout: string, logger?: Logger): Map<string, InstalledPackage>;
72
+ /**
73
+ * Parses the output of `npm view` or a compatible command to get a package manifest.
74
+ * @param stdout The standard output of the command.
75
+ * @param logger An optional logger instance.
76
+ * @returns The package manifest object.
77
+ */
78
+ export declare function parseNpmLikeManifest(stdout: string, logger?: Logger): PackageManifest | null;
79
+ /**
80
+ * Parses the output of `npm view` or a compatible command to get package metadata.
81
+ * @param stdout The standard output of the command.
82
+ * @param logger An optional logger instance.
83
+ * @returns The package metadata object.
84
+ */
85
+ export declare function parseNpmLikeMetadata(stdout: string, logger?: Logger): PackageMetadata | null;
86
+ /**
87
+ * Parses the output of `yarn info` (classic).
88
+ * @param stdout The standard output of the command.
89
+ * @param logger An optional logger instance.
90
+ * @returns The package manifest object.
91
+ */
92
+ export declare function parseYarnLegacyManifest(stdout: string, logger?: Logger): PackageManifest | null;