@depup/angular__cli 21.2.1-depup.1

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 (364) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/bin/bootstrap.js +33 -0
  4. package/bin/ng.js +71 -0
  5. package/bin/package.json +3 -0
  6. package/changes.json +30 -0
  7. package/lib/cli/index.d.ts +11 -0
  8. package/lib/cli/index.js +109 -0
  9. package/lib/cli/index.js.map +1 -0
  10. package/lib/code-examples.db +0 -0
  11. package/lib/config/schema.json +6150 -0
  12. package/lib/config/workspace-schema.d.ts +1025 -0
  13. package/lib/config/workspace-schema.js +133 -0
  14. package/lib/config/workspace-schema.js.map +1 -0
  15. package/lib/init.d.ts +8 -0
  16. package/lib/init.js +162 -0
  17. package/lib/init.js.map +1 -0
  18. package/package.json +103 -0
  19. package/src/analytics/analytics-collector.d.ts +35 -0
  20. package/src/analytics/analytics-collector.js +195 -0
  21. package/src/analytics/analytics-collector.js.map +1 -0
  22. package/src/analytics/analytics-parameters.d.ts +101 -0
  23. package/src/analytics/analytics-parameters.js +107 -0
  24. package/src/analytics/analytics-parameters.js.map +1 -0
  25. package/src/analytics/analytics.d.ts +27 -0
  26. package/src/analytics/analytics.js +183 -0
  27. package/src/analytics/analytics.js.map +1 -0
  28. package/src/command-builder/architect-base-command-module.d.ts +30 -0
  29. package/src/command-builder/architect-base-command-module.js +244 -0
  30. package/src/command-builder/architect-base-command-module.js.map +1 -0
  31. package/src/command-builder/architect-command-module.d.ts +28 -0
  32. package/src/command-builder/architect-command-module.js +218 -0
  33. package/src/command-builder/architect-command-module.js.map +1 -0
  34. package/src/command-builder/command-module.d.ts +73 -0
  35. package/src/command-builder/command-module.js +245 -0
  36. package/src/command-builder/command-module.js.map +1 -0
  37. package/src/command-builder/command-runner.d.ts +9 -0
  38. package/src/command-builder/command-runner.js +195 -0
  39. package/src/command-builder/command-runner.js.map +1 -0
  40. package/src/command-builder/definitions.d.ts +41 -0
  41. package/src/command-builder/definitions.js +20 -0
  42. package/src/command-builder/definitions.js.map +1 -0
  43. package/src/command-builder/schematics-command-module.d.ts +41 -0
  44. package/src/command-builder/schematics-command-module.js +408 -0
  45. package/src/command-builder/schematics-command-module.js.map +1 -0
  46. package/src/command-builder/utilities/command.d.ts +13 -0
  47. package/src/command-builder/utilities/command.js +39 -0
  48. package/src/command-builder/utilities/command.js.map +1 -0
  49. package/src/command-builder/utilities/json-help.d.ts +37 -0
  50. package/src/command-builder/utilities/json-help.js +92 -0
  51. package/src/command-builder/utilities/json-help.js.map +1 -0
  52. package/src/command-builder/utilities/json-schema.d.ts +64 -0
  53. package/src/command-builder/utilities/json-schema.js +349 -0
  54. package/src/command-builder/utilities/json-schema.js.map +1 -0
  55. package/src/command-builder/utilities/normalize-options-middleware.d.ts +18 -0
  56. package/src/command-builder/utilities/normalize-options-middleware.js +37 -0
  57. package/src/command-builder/utilities/normalize-options-middleware.js.map +1 -0
  58. package/src/command-builder/utilities/schematic-engine-host.d.ts +15 -0
  59. package/src/command-builder/utilities/schematic-engine-host.js +179 -0
  60. package/src/command-builder/utilities/schematic-engine-host.js.map +1 -0
  61. package/src/command-builder/utilities/schematic-workflow.d.ts +14 -0
  62. package/src/command-builder/utilities/schematic-workflow.js +70 -0
  63. package/src/command-builder/utilities/schematic-workflow.js.map +1 -0
  64. package/src/commands/add/cli.d.ts +38 -0
  65. package/src/commands/add/cli.js +623 -0
  66. package/src/commands/add/cli.js.map +1 -0
  67. package/src/commands/add/long-description.md +7 -0
  68. package/src/commands/analytics/cli.d.ts +16 -0
  69. package/src/commands/analytics/cli.js +34 -0
  70. package/src/commands/analytics/cli.js.map +1 -0
  71. package/src/commands/analytics/info/cli.d.ts +16 -0
  72. package/src/commands/analytics/info/cli.js +25 -0
  73. package/src/commands/analytics/info/cli.js.map +1 -0
  74. package/src/commands/analytics/long-description.md +20 -0
  75. package/src/commands/analytics/settings/cli.d.ts +35 -0
  76. package/src/commands/analytics/settings/cli.js +54 -0
  77. package/src/commands/analytics/settings/cli.js.map +1 -0
  78. package/src/commands/build/cli.d.ts +16 -0
  79. package/src/commands/build/cli.js +21 -0
  80. package/src/commands/build/cli.js.map +1 -0
  81. package/src/commands/build/long-description.md +18 -0
  82. package/src/commands/cache/clean/cli.d.ts +17 -0
  83. package/src/commands/cache/clean/cli.js +32 -0
  84. package/src/commands/cache/clean/cli.js.map +1 -0
  85. package/src/commands/cache/cli.d.ts +17 -0
  86. package/src/commands/cache/cli.js +36 -0
  87. package/src/commands/cache/cli.js.map +1 -0
  88. package/src/commands/cache/info/cli.d.ts +20 -0
  89. package/src/commands/cache/info/cli.js +139 -0
  90. package/src/commands/cache/info/cli.js.map +1 -0
  91. package/src/commands/cache/long-description.md +53 -0
  92. package/src/commands/cache/settings/cli.d.ts +27 -0
  93. package/src/commands/cache/settings/cli.js +41 -0
  94. package/src/commands/cache/settings/cli.js.map +1 -0
  95. package/src/commands/cache/utilities.d.ts +11 -0
  96. package/src/commands/cache/utilities.js +47 -0
  97. package/src/commands/cache/utilities.js.map +1 -0
  98. package/src/commands/command-config.d.ts +17 -0
  99. package/src/commands/command-config.js +116 -0
  100. package/src/commands/command-config.js.map +1 -0
  101. package/src/commands/completion/cli.d.ts +16 -0
  102. package/src/commands/completion/cli.js +61 -0
  103. package/src/commands/completion/cli.js.map +1 -0
  104. package/src/commands/completion/long-description.md +67 -0
  105. package/src/commands/config/cli.d.ts +24 -0
  106. package/src/commands/config/cli.js +150 -0
  107. package/src/commands/config/cli.js.map +1 -0
  108. package/src/commands/config/long-description.md +13 -0
  109. package/src/commands/deploy/cli.d.ts +17 -0
  110. package/src/commands/deploy/cli.js +38 -0
  111. package/src/commands/deploy/cli.js.map +1 -0
  112. package/src/commands/deploy/long-description.md +22 -0
  113. package/src/commands/e2e/cli.d.ts +18 -0
  114. package/src/commands/e2e/cli.js +42 -0
  115. package/src/commands/e2e/cli.js.map +1 -0
  116. package/src/commands/extract-i18n/cli.d.ts +17 -0
  117. package/src/commands/extract-i18n/cli.js +48 -0
  118. package/src/commands/extract-i18n/cli.js.map +1 -0
  119. package/src/commands/generate/cli.d.ts +47 -0
  120. package/src/commands/generate/cli.js +189 -0
  121. package/src/commands/generate/cli.js.map +1 -0
  122. package/src/commands/lint/cli.d.ts +17 -0
  123. package/src/commands/lint/cli.js +25 -0
  124. package/src/commands/lint/cli.js.map +1 -0
  125. package/src/commands/lint/long-description.md +20 -0
  126. package/src/commands/make-this-awesome/cli.d.ts +17 -0
  127. package/src/commands/make-this-awesome/cli.js +36 -0
  128. package/src/commands/make-this-awesome/cli.js.map +1 -0
  129. package/src/commands/mcp/cli.d.ts +20 -0
  130. package/src/commands/mcp/cli.js +74 -0
  131. package/src/commands/mcp/cli.js.map +1 -0
  132. package/src/commands/mcp/constants.d.ts +10 -0
  133. package/src/commands/mcp/constants.js +16 -0
  134. package/src/commands/mcp/constants.js.map +1 -0
  135. package/src/commands/mcp/devserver.d.ts +85 -0
  136. package/src/commands/mcp/devserver.js +112 -0
  137. package/src/commands/mcp/devserver.js.map +1 -0
  138. package/src/commands/mcp/host.d.ts +97 -0
  139. package/src/commands/mcp/host.js +118 -0
  140. package/src/commands/mcp/host.js.map +1 -0
  141. package/src/commands/mcp/mcp-server.d.ts +192 -0
  142. package/src/commands/mcp/mcp-server.js +155 -0
  143. package/src/commands/mcp/mcp-server.js.map +1 -0
  144. package/src/commands/mcp/resources/ai-tutor.md +824 -0
  145. package/src/commands/mcp/resources/best-practices.md +54 -0
  146. package/src/commands/mcp/resources/instructions.d.ts +9 -0
  147. package/src/commands/mcp/resources/instructions.js +26 -0
  148. package/src/commands/mcp/resources/instructions.js.map +1 -0
  149. package/src/commands/mcp/shared-options.d.ts +12 -0
  150. package/src/commands/mcp/shared-options.js +22 -0
  151. package/src/commands/mcp/shared-options.js.map +1 -0
  152. package/src/commands/mcp/tools/ai-tutor.d.ts +12 -0
  153. package/src/commands/mcp/tools/ai-tutor.js +59 -0
  154. package/src/commands/mcp/tools/ai-tutor.js.map +1 -0
  155. package/src/commands/mcp/tools/best-practices.d.ts +13 -0
  156. package/src/commands/mcp/tools/best-practices.js +187 -0
  157. package/src/commands/mcp/tools/best-practices.js.map +1 -0
  158. package/src/commands/mcp/tools/build.d.ts +37 -0
  159. package/src/commands/mcp/tools/build.js +89 -0
  160. package/src/commands/mcp/tools/build.js.map +1 -0
  161. package/src/commands/mcp/tools/devserver/devserver-start.d.ts +31 -0
  162. package/src/commands/mcp/tools/devserver/devserver-start.js +91 -0
  163. package/src/commands/mcp/tools/devserver/devserver-start.js.map +1 -0
  164. package/src/commands/mcp/tools/devserver/devserver-stop.d.ts +31 -0
  165. package/src/commands/mcp/tools/devserver/devserver-stop.js +68 -0
  166. package/src/commands/mcp/tools/devserver/devserver-stop.js.map +1 -0
  167. package/src/commands/mcp/tools/devserver/devserver-wait-for-build.d.ts +41 -0
  168. package/src/commands/mcp/tools/devserver/devserver-wait-for-build.js +104 -0
  169. package/src/commands/mcp/tools/devserver/devserver-wait-for-build.js.map +1 -0
  170. package/src/commands/mcp/tools/doc-search.d.ts +21 -0
  171. package/src/commands/mcp/tools/doc-search.js +324 -0
  172. package/src/commands/mcp/tools/doc-search.js.map +1 -0
  173. package/src/commands/mcp/tools/e2e.d.ts +44 -0
  174. package/src/commands/mcp/tools/e2e.js +87 -0
  175. package/src/commands/mcp/tools/e2e.js.map +1 -0
  176. package/src/commands/mcp/tools/examples/database-discovery.d.ts +34 -0
  177. package/src/commands/mcp/tools/examples/database-discovery.js +87 -0
  178. package/src/commands/mcp/tools/examples/database-discovery.js.map +1 -0
  179. package/src/commands/mcp/tools/examples/database.d.ts +35 -0
  180. package/src/commands/mcp/tools/examples/database.js +125 -0
  181. package/src/commands/mcp/tools/examples/database.js.map +1 -0
  182. package/src/commands/mcp/tools/examples/index.d.ts +26 -0
  183. package/src/commands/mcp/tools/examples/index.js +149 -0
  184. package/src/commands/mcp/tools/examples/index.js.map +1 -0
  185. package/src/commands/mcp/tools/examples/query-escaper.d.ts +20 -0
  186. package/src/commands/mcp/tools/examples/query-escaper.js +68 -0
  187. package/src/commands/mcp/tools/examples/query-escaper.js.map +1 -0
  188. package/src/commands/mcp/tools/examples/runtime-database.d.ts +10 -0
  189. package/src/commands/mcp/tools/examples/runtime-database.js +192 -0
  190. package/src/commands/mcp/tools/examples/runtime-database.js.map +1 -0
  191. package/src/commands/mcp/tools/examples/schemas.d.ts +29 -0
  192. package/src/commands/mcp/tools/examples/schemas.js +101 -0
  193. package/src/commands/mcp/tools/examples/schemas.js.map +1 -0
  194. package/src/commands/mcp/tools/examples/utils.d.ts +14 -0
  195. package/src/commands/mcp/tools/examples/utils.js +31 -0
  196. package/src/commands/mcp/tools/examples/utils.js.map +1 -0
  197. package/src/commands/mcp/tools/modernize.d.ts +43 -0
  198. package/src/commands/mcp/tools/modernize.js +165 -0
  199. package/src/commands/mcp/tools/modernize.js.map +1 -0
  200. package/src/commands/mcp/tools/onpush-zoneless-migration/analyze-for-unsupported-zone-uses.d.ts +17 -0
  201. package/src/commands/mcp/tools/onpush-zoneless-migration/analyze-for-unsupported-zone-uses.js +62 -0
  202. package/src/commands/mcp/tools/onpush-zoneless-migration/analyze-for-unsupported-zone-uses.js.map +1 -0
  203. package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-single-file.d.ts +12 -0
  204. package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-single-file.js +73 -0
  205. package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-single-file.js.map +1 -0
  206. package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-test-file.d.ts +11 -0
  207. package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-test-file.js +60 -0
  208. package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-test-file.js.map +1 -0
  209. package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.d.ts +15 -0
  210. package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.js +238 -0
  211. package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.js.map +1 -0
  212. package/src/commands/mcp/tools/onpush-zoneless-migration/send-debug-message.d.ts +10 -0
  213. package/src/commands/mcp/tools/onpush-zoneless-migration/send-debug-message.js +20 -0
  214. package/src/commands/mcp/tools/onpush-zoneless-migration/send-debug-message.js.map +1 -0
  215. package/src/commands/mcp/tools/onpush-zoneless-migration/ts-utils.d.ts +35 -0
  216. package/src/commands/mcp/tools/onpush-zoneless-migration/ts-utils.js +136 -0
  217. package/src/commands/mcp/tools/onpush-zoneless-migration/ts-utils.js.map +1 -0
  218. package/src/commands/mcp/tools/onpush-zoneless-migration/types.d.ts +13 -0
  219. package/src/commands/mcp/tools/onpush-zoneless-migration/types.js +10 -0
  220. package/src/commands/mcp/tools/onpush-zoneless-migration/types.js.map +1 -0
  221. package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.d.ts +16 -0
  222. package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js +224 -0
  223. package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js.map +1 -0
  224. package/src/commands/mcp/tools/projects.d.ts +47 -0
  225. package/src/commands/mcp/tools/projects.js +523 -0
  226. package/src/commands/mcp/tools/projects.js.map +1 -0
  227. package/src/commands/mcp/tools/test.d.ts +35 -0
  228. package/src/commands/mcp/tools/test.js +79 -0
  229. package/src/commands/mcp/tools/test.js.map +1 -0
  230. package/src/commands/mcp/tools/tool-registry.d.ts +39 -0
  231. package/src/commands/mcp/tools/tool-registry.js +35 -0
  232. package/src/commands/mcp/tools/tool-registry.js.map +1 -0
  233. package/src/commands/mcp/utils.d.ts +25 -0
  234. package/src/commands/mcp/utils.js +44 -0
  235. package/src/commands/mcp/utils.js.map +1 -0
  236. package/src/commands/mcp/workspace-utils.d.ts +53 -0
  237. package/src/commands/mcp/workspace-utils.js +138 -0
  238. package/src/commands/mcp/workspace-utils.js.map +1 -0
  239. package/src/commands/new/cli.d.ts +27 -0
  240. package/src/commands/new/cli.js +76 -0
  241. package/src/commands/new/cli.js.map +1 -0
  242. package/src/commands/new/long-description.md +15 -0
  243. package/src/commands/run/cli.d.ts +25 -0
  244. package/src/commands/run/cli.js +89 -0
  245. package/src/commands/run/cli.js.map +1 -0
  246. package/src/commands/run/long-description.md +10 -0
  247. package/src/commands/serve/cli.d.ts +16 -0
  248. package/src/commands/serve/cli.js +20 -0
  249. package/src/commands/serve/cli.js.map +1 -0
  250. package/src/commands/test/cli.d.ts +16 -0
  251. package/src/commands/test/cli.js +21 -0
  252. package/src/commands/test/cli.js.map +1 -0
  253. package/src/commands/test/long-description.md +2 -0
  254. package/src/commands/update/cli.d.ts +34 -0
  255. package/src/commands/update/cli.js +531 -0
  256. package/src/commands/update/cli.js.map +1 -0
  257. package/src/commands/update/long-description.md +22 -0
  258. package/src/commands/update/schematic/collection.json +9 -0
  259. package/src/commands/update/schematic/index.d.ts +11 -0
  260. package/src/commands/update/schematic/index.js +715 -0
  261. package/src/commands/update/schematic/index.js.map +1 -0
  262. package/src/commands/update/schematic/schema.d.ts +51 -0
  263. package/src/commands/update/schematic/schema.js +16 -0
  264. package/src/commands/update/schematic/schema.js.map +1 -0
  265. package/src/commands/update/schematic/schema.json +64 -0
  266. package/src/commands/update/utilities/cli-version.d.ts +48 -0
  267. package/src/commands/update/utilities/cli-version.js +196 -0
  268. package/src/commands/update/utilities/cli-version.js.map +1 -0
  269. package/src/commands/update/utilities/constants.d.ts +12 -0
  270. package/src/commands/update/utilities/constants.js +16 -0
  271. package/src/commands/update/utilities/constants.js.map +1 -0
  272. package/src/commands/update/utilities/git.d.ts +36 -0
  273. package/src/commands/update/utilities/git.js +148 -0
  274. package/src/commands/update/utilities/git.js.map +1 -0
  275. package/src/commands/update/utilities/migration.d.ts +32 -0
  276. package/src/commands/update/utilities/migration.js +267 -0
  277. package/src/commands/update/utilities/migration.js.map +1 -0
  278. package/src/commands/version/cli.d.ts +36 -0
  279. package/src/commands/version/cli.js +117 -0
  280. package/src/commands/version/cli.js.map +1 -0
  281. package/src/commands/version/version-info.d.ts +46 -0
  282. package/src/commands/version/version-info.js +107 -0
  283. package/src/commands/version/version-info.js.map +1 -0
  284. package/src/package-managers/discovery.d.ts +23 -0
  285. package/src/package-managers/discovery.js +104 -0
  286. package/src/package-managers/discovery.js.map +1 -0
  287. package/src/package-managers/error.d.ts +43 -0
  288. package/src/package-managers/error.js +41 -0
  289. package/src/package-managers/error.js.map +1 -0
  290. package/src/package-managers/factory.d.ts +30 -0
  291. package/src/package-managers/factory.js +137 -0
  292. package/src/package-managers/factory.js.map +1 -0
  293. package/src/package-managers/host.d.ts +86 -0
  294. package/src/package-managers/host.js +80 -0
  295. package/src/package-managers/host.js.map +1 -0
  296. package/src/package-managers/index.d.ts +13 -0
  297. package/src/package-managers/index.js +17 -0
  298. package/src/package-managers/index.js.map +1 -0
  299. package/src/package-managers/logger.d.ts +27 -0
  300. package/src/package-managers/logger.js +10 -0
  301. package/src/package-managers/logger.js.map +1 -0
  302. package/src/package-managers/package-manager-descriptor.d.ts +245 -0
  303. package/src/package-managers/package-manager-descriptor.js +175 -0
  304. package/src/package-managers/package-manager-descriptor.js.map +1 -0
  305. package/src/package-managers/package-manager.d.ts +191 -0
  306. package/src/package-managers/package-manager.js +496 -0
  307. package/src/package-managers/package-manager.js.map +1 -0
  308. package/src/package-managers/package-metadata.d.ts +91 -0
  309. package/src/package-managers/package-metadata.js +10 -0
  310. package/src/package-managers/package-metadata.js.map +1 -0
  311. package/src/package-managers/package-tree.d.ts +23 -0
  312. package/src/package-managers/package-tree.js +10 -0
  313. package/src/package-managers/package-tree.js.map +1 -0
  314. package/src/package-managers/parsers.d.ts +170 -0
  315. package/src/package-managers/parsers.js +467 -0
  316. package/src/package-managers/parsers.js.map +1 -0
  317. package/src/utilities/color.d.ts +9 -0
  318. package/src/utilities/color.js +28 -0
  319. package/src/utilities/color.js.map +1 -0
  320. package/src/utilities/completion.d.ts +30 -0
  321. package/src/utilities/completion.js +270 -0
  322. package/src/utilities/completion.js.map +1 -0
  323. package/src/utilities/config.d.ts +38 -0
  324. package/src/utilities/config.js +369 -0
  325. package/src/utilities/config.js.map +1 -0
  326. package/src/utilities/environment-options.d.ts +25 -0
  327. package/src/utilities/environment-options.js +60 -0
  328. package/src/utilities/environment-options.js.map +1 -0
  329. package/src/utilities/eol.d.ts +20 -0
  330. package/src/utilities/eol.js +35 -0
  331. package/src/utilities/eol.js.map +1 -0
  332. package/src/utilities/error.d.ts +18 -0
  333. package/src/utilities/error.js +41 -0
  334. package/src/utilities/error.js.map +1 -0
  335. package/src/utilities/find-up.d.ts +21 -0
  336. package/src/utilities/find-up.js +67 -0
  337. package/src/utilities/find-up.js.map +1 -0
  338. package/src/utilities/json-file.d.ts +24 -0
  339. package/src/utilities/json-file.js +179 -0
  340. package/src/utilities/json-file.js.map +1 -0
  341. package/src/utilities/log-file.d.ts +13 -0
  342. package/src/utilities/log-file.js +28 -0
  343. package/src/utilities/log-file.js.map +1 -0
  344. package/src/utilities/memoize.d.ts +15 -0
  345. package/src/utilities/memoize.js +64 -0
  346. package/src/utilities/memoize.js.map +1 -0
  347. package/src/utilities/package-metadata.d.ts +58 -0
  348. package/src/utilities/package-metadata.js +265 -0
  349. package/src/utilities/package-metadata.js.map +1 -0
  350. package/src/utilities/prettier.d.ts +13 -0
  351. package/src/utilities/prettier.js +46 -0
  352. package/src/utilities/prettier.js.map +1 -0
  353. package/src/utilities/project.d.ts +8 -0
  354. package/src/utilities/project.js +81 -0
  355. package/src/utilities/project.js.map +1 -0
  356. package/src/utilities/prompt.d.ts +17 -0
  357. package/src/utilities/prompt.js +90 -0
  358. package/src/utilities/prompt.js.map +1 -0
  359. package/src/utilities/tty.d.ts +16 -0
  360. package/src/utilities/tty.js +23 -0
  361. package/src/utilities/tty.js.map +1 -0
  362. package/src/utilities/version.d.ts +16 -0
  363. package/src/utilities/version.js +26 -0
  364. package/src/utilities/version.js.map +1 -0
@@ -0,0 +1,46 @@
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 { CommandContext } from '../../command-builder/definitions';
9
+ /**
10
+ * An object containing version information for a single package.
11
+ */
12
+ export interface PackageVersionInfo {
13
+ requested: string;
14
+ installed: string;
15
+ }
16
+ /**
17
+ * An object containing all the version information that will be displayed by the command.
18
+ */
19
+ export interface VersionInfo {
20
+ cli: {
21
+ version: string;
22
+ };
23
+ framework: {
24
+ version: string | undefined;
25
+ };
26
+ system: {
27
+ node: {
28
+ version: string;
29
+ unsupported: boolean;
30
+ };
31
+ os: {
32
+ platform: string;
33
+ architecture: string;
34
+ };
35
+ packageManager: {
36
+ name: string;
37
+ version: string | undefined;
38
+ };
39
+ };
40
+ packages: Record<string, PackageVersionInfo>;
41
+ }
42
+ /**
43
+ * Gathers all the version information from the environment and workspace.
44
+ * @returns An object containing all the version information.
45
+ */
46
+ export declare function gatherVersionInfo(context: CommandContext): Promise<VersionInfo>;
@@ -0,0 +1,107 @@
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 version_1 = require("../../utilities/version");
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
+ /^vitest$/,
31
+ /^webpack$/,
32
+ /^zone\.js$/,
33
+ ];
34
+ /**
35
+ * Gathers all the version information from the environment and workspace.
36
+ * @returns An object containing all the version information.
37
+ */
38
+ async function gatherVersionInfo(context) {
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
+ let workspacePackage;
42
+ try {
43
+ workspacePackage = workspaceRequire('./package.json');
44
+ }
45
+ catch { }
46
+ const [nodeMajor] = process.versions.node.split('.').map((part) => Number(part));
47
+ const unsupportedNodeVersion = !SUPPORTED_NODE_MAJORS.includes(nodeMajor);
48
+ const allDependencies = {
49
+ ...workspacePackage?.dependencies,
50
+ ...workspacePackage?.devDependencies,
51
+ };
52
+ const packageNames = new Set(Object.keys(allDependencies));
53
+ const packages = {};
54
+ for (const name of packageNames) {
55
+ if (PACKAGE_PATTERNS.some((p) => p.test(name))) {
56
+ packages[name] = {
57
+ requested: allDependencies[name] ?? 'error',
58
+ installed: getVersion(name, workspaceRequire),
59
+ };
60
+ }
61
+ }
62
+ const angularCoreVersion = packages['@angular/core'];
63
+ return {
64
+ cli: {
65
+ version: version_1.VERSION.full,
66
+ },
67
+ framework: {
68
+ version: angularCoreVersion?.installed,
69
+ },
70
+ system: {
71
+ node: {
72
+ version: process.versions.node,
73
+ unsupported: unsupportedNodeVersion,
74
+ },
75
+ os: {
76
+ platform: process.platform,
77
+ architecture: process.arch,
78
+ },
79
+ packageManager: {
80
+ name: context.packageManager.name,
81
+ version: await context.packageManager.getVersion(),
82
+ },
83
+ },
84
+ packages,
85
+ };
86
+ }
87
+ /**
88
+ * Gets the version of a package.
89
+ * @param moduleName The name of the package.
90
+ * @param workspaceRequire A `require` function for the workspace.
91
+ * @param localRequire A `require` function for the CLI.
92
+ * @returns The version of the package, or `<error>` if it could not be found.
93
+ */
94
+ function getVersion(moduleName, workspaceRequire) {
95
+ let packageInfo;
96
+ // Try to find the package in the workspace
97
+ try {
98
+ packageInfo = workspaceRequire(`${moduleName}/package.json`);
99
+ }
100
+ catch { }
101
+ // If found, attempt to get the version
102
+ if (packageInfo) {
103
+ return packageInfo.version;
104
+ }
105
+ return '<error>';
106
+ }
107
+ //# sourceMappingURL=version-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-info.js","sourceRoot":"","sources":["version-info.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AA+EH,8CAqDC;AAlID,6CAA4C;AAG5C,qDAAkD;AA+ClD;;;GAGG;AACH,MAAM,qBAAqB,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAE3C;;;GAGG;AACH,MAAM,gBAAgB,GAAG;IACvB,eAAe;IACf,sBAAsB;IACtB,eAAe;IACf,kBAAkB;IAClB,QAAQ;IACR,cAAc;IACd,cAAc;IACd,UAAU;IACV,WAAW;IACX,YAAY;CACb,CAAC;AAEF;;;GAGG;AACI,KAAK,UAAU,iBAAiB,CAAC,OAAuB;IAC7D,wEAAwE;IACxE,MAAM,gBAAgB,GAAG,IAAA,2BAAa,EAAC,OAAO,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;IAE3D,IAAI,gBAAgD,CAAC;IACrD,IAAI,CAAC;QACH,gBAAgB,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IAEV,MAAM,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACjF,MAAM,sBAAsB,GAAG,CAAC,qBAAqB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAE1E,MAAM,eAAe,GAAG;QACtB,GAAG,gBAAgB,EAAE,YAAY;QACjC,GAAG,gBAAgB,EAAE,eAAe;KACrC,CAAC;IACF,MAAM,YAAY,GA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AC/D,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IAEV,uCAAuC;IACvC,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC,OAAO,CAAC;IAC7B,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -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
+ import { Host } from './host';
9
+ import { Logger } from './logger';
10
+ import { PackageManagerName } from './package-manager-descriptor';
11
+ /**
12
+ * Discovers the package manager used in a project by searching for lockfiles.
13
+ *
14
+ * This function searches for lockfiles in the given directory and its ancestors.
15
+ * If multiple lockfiles are found, it uses the precedence array to determine
16
+ * which package manager to use. The search is bounded by the git repository root.
17
+ *
18
+ * @param host A `Host` instance for interacting with the file system.
19
+ * @param startDir The directory to start the search from.
20
+ * @param logger An optional logger instance.
21
+ * @returns A promise that resolves to the name of the discovered package manager, or null if none is found.
22
+ */
23
+ export declare function discover(host: Host, startDir: string, logger?: Logger): Promise<PackageManagerName | null>;
@@ -0,0 +1,104 @@
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.discover = discover;
11
+ /**
12
+ * @fileoverview This file contains the logic for discovering the package manager
13
+ * used in a project by searching for lockfiles. It is designed to be efficient
14
+ * and to correctly handle monorepo structures.
15
+ */
16
+ const node_path_1 = require("node:path");
17
+ const package_manager_descriptor_1 = require("./package-manager-descriptor");
18
+ /**
19
+ * Searches a directory for lockfiles and returns a set of package managers that correspond to them.
20
+ * @param host A `Host` instance for interacting with the file system.
21
+ * @param directory The directory to search.
22
+ * @param logger An optional logger instance.
23
+ * @returns A promise that resolves to a set of package manager names.
24
+ */
25
+ async function findLockfiles(host, directory, logger) {
26
+ logger?.debug(`Searching for lockfiles in '${directory}'...`);
27
+ const foundPackageManagers = new Set();
28
+ const checks = [];
29
+ for (const [name, descriptor] of Object.entries(package_manager_descriptor_1.SUPPORTED_PACKAGE_MANAGERS)) {
30
+ const manager = name;
31
+ for (const lockfile of descriptor.lockfiles) {
32
+ checks.push((async () => {
33
+ try {
34
+ const path = (0, node_path_1.join)(directory, lockfile);
35
+ const stats = await host.stat(path);
36
+ if (stats.isFile()) {
37
+ logger?.debug(` Found '${lockfile}'.`);
38
+ foundPackageManagers.add(manager);
39
+ }
40
+ }
41
+ catch {
42
+ // File does not exist or cannot be accessed.
43
+ }
44
+ })());
45
+ }
46
+ }
47
+ await Promise.all(checks);
48
+ return foundPackageManagers;
49
+ }
50
+ /**
51
+ * Checks if a given path is a directory.
52
+ * @param host A `Host` instance for interacting with the file system.
53
+ * @param path The path to check.
54
+ * @returns A promise that resolves to true if the path is a directory, false otherwise.
55
+ */
56
+ async function isDirectory(host, path) {
57
+ try {
58
+ return (await host.stat(path)).isDirectory();
59
+ }
60
+ catch {
61
+ return false;
62
+ }
63
+ }
64
+ /**
65
+ * Discovers the package manager used in a project by searching for lockfiles.
66
+ *
67
+ * This function searches for lockfiles in the given directory and its ancestors.
68
+ * If multiple lockfiles are found, it uses the precedence array to determine
69
+ * which package manager to use. The search is bounded by the git repository root.
70
+ *
71
+ * @param host A `Host` instance for interacting with the file system.
72
+ * @param startDir The directory to start the search from.
73
+ * @param logger An optional logger instance.
74
+ * @returns A promise that resolves to the name of the discovered package manager, or null if none is found.
75
+ */
76
+ async function discover(host, startDir, logger) {
77
+ logger?.debug(`Starting package manager discovery in '${startDir}'...`);
78
+ let currentDir = startDir;
79
+ while (true) {
80
+ const found = await findLockfiles(host, currentDir, logger);
81
+ if (found.size > 0) {
82
+ logger?.debug(`Found lockfile(s): [${[...found].join(', ')}]. Applying precedence...`);
83
+ for (const packageManager of package_manager_descriptor_1.PACKAGE_MANAGER_PRECEDENCE) {
84
+ if (found.has(packageManager)) {
85
+ logger?.debug(`Selected '${packageManager}' based on precedence.`);
86
+ return packageManager;
87
+ }
88
+ }
89
+ }
90
+ // Stop searching if we reach the git repository root.
91
+ if (await isDirectory(host, (0, node_path_1.join)(currentDir, '.git'))) {
92
+ logger?.debug(`Reached repository root at '${currentDir}'. Stopping search.`);
93
+ return null;
94
+ }
95
+ const parentDir = (0, node_path_1.dirname)(currentDir);
96
+ if (parentDir === currentDir) {
97
+ // We have reached the filesystem root.
98
+ logger?.debug('Reached filesystem root. No lockfile found.');
99
+ return null;
100
+ }
101
+ currentDir = parentDir;
102
+ }
103
+ }
104
+ //# sourceMappingURL=discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.js","sourceRoot":"","sources":["discovery.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAqFH,4BAuCC;AA1HD;;;;GAIG;AAEH,yCAA0C;AAG1C,6EAIsC;AAEtC;;;;;;GAMG;AACH,KAAK,UAAU,aAAa,CAC1B,IAAU,EACV,SAAiB,EACjB,MAAe;IAEf,MAAM,EAAE,KAAK,CAAC,+BAA+B,SAAS,MAAM,CAAC,CAAC;IAE9D,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC3D,MAAM,MAAM,GAAoB,EAAE,CAAC;IAEnC,KAAK,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,uDAA0B,CAAC,EAAE,CAAC;QAC5E,MAAM,OAAO,GAAG,IAA0B,CAAC;QAC3C,KAAK,MAAM,QAAQ,IAAI,UAAU,CAAC,SAAS,EAAE,CAAC;YAC5C,MAAM,CAAC,IAAI,CACT,CAAC,KAAK,IAAI,EAAE;gBACV,IAAI,CAAC;oBACH,MAAM,IAAI,GAAG,IAAA,gBAAI,EAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;oBACvC,MAAM,KAAK,GAAG,MAA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C,cAAc,CAAC,EAAE,CAAC;oBAC9B,MAAM,EAAE,KAAK,CAAC,aAAa,cAAc,wBAAwB,CAAC,CAAC;oBAEnE,OAAO,cAAc,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;QAED,sDAAsD;QACtD,IAAI,MAAM,WAAW,CAAC,IAAI,EAAE,IAAA,gBAAI,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;YACtD,MAAM,EAAE,KAAK,CAAC,+BAA+B,UAAU,qBAAqB,CAAC,CAAC;YAE9E,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,SAAS,GAAG,IAAA,mBAAO,EAAC,UAAU,CAAC,CAAC;QACtC,IAAI,SAAS,KAAK,UAAU,EAAE,CAAC;YAC7B,uCAAuC;YACvC,MAAM,EAAE,KAAK,CAAC,6CAA6C,CAAC,CAAC;YAE7D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,UAAU,GAAG,SAAS,CAAC;IACzB,CAAC;AACH,CAAC"}
@@ -0,0 +1,43 @@
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 defines a custom error class for the package manager
10
+ * abstraction. This allows for structured error handling and provides consumers
11
+ * with detailed information about the process failure.
12
+ */
13
+ /**
14
+ * A custom error class for package manager-related errors.
15
+ *
16
+ * This error class provides structured data about the failed process,
17
+ * including stdout, stderr, and the exit code.
18
+ */
19
+ export declare class PackageManagerError extends Error {
20
+ readonly stdout: string;
21
+ readonly stderr: string;
22
+ readonly exitCode: number | null;
23
+ /**
24
+ * Creates a new `PackageManagerError` instance.
25
+ * @param message The error message.
26
+ * @param stdout The standard output of the failed process.
27
+ * @param stderr The standard error of the failed process.
28
+ * @param exitCode The exit code of the failed process.
29
+ */
30
+ constructor(message: string, stdout: string, stderr: string, exitCode: number | null);
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
+ }
@@ -0,0 +1,41 @@
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.PackageManagerError = void 0;
11
+ /**
12
+ * @fileoverview This file defines a custom error class for the package manager
13
+ * abstraction. This allows for structured error handling and provides consumers
14
+ * with detailed information about the process failure.
15
+ */
16
+ /**
17
+ * A custom error class for package manager-related errors.
18
+ *
19
+ * This error class provides structured data about the failed process,
20
+ * including stdout, stderr, and the exit code.
21
+ */
22
+ class PackageManagerError extends Error {
23
+ stdout;
24
+ stderr;
25
+ exitCode;
26
+ /**
27
+ * Creates a new `PackageManagerError` instance.
28
+ * @param message The error message.
29
+ * @param stdout The standard output of the failed process.
30
+ * @param stderr The standard error of the failed process.
31
+ * @param exitCode The exit code of the failed process.
32
+ */
33
+ constructor(message, stdout, stderr, exitCode) {
34
+ super(message);
35
+ this.stdout = stdout;
36
+ this.stderr = stderr;
37
+ this.exitCode = exitCode;
38
+ }
39
+ }
40
+ exports.PackageManagerError = PackageManagerError;
41
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["error.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH;;;;GAIG;AAEH;;;;;GAKG;AACH,MAAa,mBAAoB,SAAQ,KAAK;IAU1B;IACA;IACA;IAXlB;;;;;;OAMG;IACH,YACE,OAAe,EACC,MAAc,EACd,MAAc,EACd,QAAuB;QAEvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAQ;QACd,aAAQ,GAAR,QAAQ,CAAe;IAGzC,CAAC;CACF;AAhBD,kDAgBC"}
@@ -0,0 +1,30 @@
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 { Logger } from './logger';
9
+ import { PackageManager } from './package-manager';
10
+ import { PackageManagerName } from './package-manager-descriptor';
11
+ /**
12
+ * Information about the package manager to use for a given project.
13
+ */
14
+ export type ConfiguredPackageManagerInfo = [name?: PackageManagerName, version?: string];
15
+ /**
16
+ * Creates a new `PackageManager` instance for a given project.
17
+ *
18
+ * This function is the main entry point for the package manager abstraction.
19
+ * It will determine, verify, and instantiate the correct package manager.
20
+ *
21
+ * @param options An object containing the options for creating the package manager.
22
+ * @returns A promise that resolves to a new `PackageManager` instance.
23
+ */
24
+ export declare function createPackageManager(options: {
25
+ cwd: string;
26
+ configuredPackageManager?: ConfiguredPackageManagerInfo;
27
+ logger?: Logger;
28
+ dryRun?: boolean;
29
+ tempDirectory?: string;
30
+ }): Promise<PackageManager>;
@@ -0,0 +1,137 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.createPackageManager = createPackageManager;
14
+ const strict_1 = __importDefault(require("node:assert/strict"));
15
+ const semver_1 = require("semver");
16
+ const discovery_1 = require("./discovery");
17
+ const host_1 = require("./host");
18
+ const package_manager_1 = require("./package-manager");
19
+ const package_manager_descriptor_1 = require("./package-manager-descriptor");
20
+ /**
21
+ * The default package manager to use when none is discovered or configured.
22
+ */
23
+ const DEFAULT_PACKAGE_MANAGER = 'npm';
24
+ /**
25
+ * Gets the version of the package manager.
26
+ * @param host A `Host` instance for running commands.
27
+ * @param cwd The absolute path to the working directory.
28
+ * @param name The name of the package manager.
29
+ * @param logger An optional logger instance.
30
+ * @returns A promise that resolves to the version string.
31
+ */
32
+ async function getPackageManagerVersion(host, cwd, name, logger) {
33
+ const descriptor = package_manager_descriptor_1.SUPPORTED_PACKAGE_MANAGERS[name];
34
+ logger?.debug(`Getting ${name} version...`);
35
+ const { stdout } = await host.runCommand(descriptor.binary, descriptor.versionCommand, { cwd });
36
+ const version = stdout.trim();
37
+ logger?.debug(`${name} version is '${version}'.`);
38
+ return version;
39
+ }
40
+ /**
41
+ * Determines the package manager to use for a given project.
42
+ *
43
+ * This function will determine the package manager by checking for a configured
44
+ * package manager, discovering the package manager from lockfiles, or falling
45
+ * back to a default. It also handles differentiation between yarn classic and modern.
46
+ *
47
+ * @param host A `Host` instance for interacting with the file system and running commands.
48
+ * @param cwd The directory to start the search from.
49
+ * @param configured An optional, explicitly configured package manager.
50
+ * @param logger An optional logger instance.
51
+ * @returns A promise that resolves to an object containing the name and source of the package manager.
52
+ */
53
+ async function determinePackageManager(host, cwd, configured = [], logger, dryRun) {
54
+ let [name, version] = configured;
55
+ let source;
56
+ if (name) {
57
+ source = 'configured';
58
+ logger?.debug(`Using configured package manager: '${name}'.`);
59
+ }
60
+ else {
61
+ const discovered = await (0, discovery_1.discover)(host, cwd, logger);
62
+ if (discovered) {
63
+ name = discovered;
64
+ source = 'discovered';
65
+ logger?.debug(`Discovered package manager: '${name}'.`);
66
+ }
67
+ else {
68
+ name = DEFAULT_PACKAGE_MANAGER;
69
+ source = 'default';
70
+ logger?.debug(`No lockfile found. Using default package manager: '${DEFAULT_PACKAGE_MANAGER}'.`);
71
+ }
72
+ }
73
+ if (name === 'yarn' && !dryRun) {
74
+ strict_1.default.deepStrictEqual(package_manager_descriptor_1.SUPPORTED_PACKAGE_MANAGERS.yarn.versionCommand, package_manager_descriptor_1.SUPPORTED_PACKAGE_MANAGERS['yarn-classic'].versionCommand, 'Yarn and Yarn Classic version commands must match for detection logic to be valid.');
75
+ try {
76
+ version ??= await getPackageManagerVersion(host, cwd, name, logger);
77
+ if (version && (0, semver_1.major)(version) < 2) {
78
+ name = 'yarn-classic';
79
+ logger?.debug(`Detected yarn classic. Using 'yarn-classic'.`);
80
+ }
81
+ }
82
+ catch {
83
+ logger?.debug('Failed to get yarn version.');
84
+ }
85
+ }
86
+ else if (name === 'yarn') {
87
+ logger?.debug('Skipping yarn version check due to dry run. Assuming modern yarn.');
88
+ }
89
+ return { name, source, version };
90
+ }
91
+ /**
92
+ * Creates a new `PackageManager` instance for a given project.
93
+ *
94
+ * This function is the main entry point for the package manager abstraction.
95
+ * It will determine, verify, and instantiate the correct package manager.
96
+ *
97
+ * @param options An object containing the options for creating the package manager.
98
+ * @returns A promise that resolves to a new `PackageManager` instance.
99
+ */
100
+ async function createPackageManager(options) {
101
+ const { cwd, configuredPackageManager, logger, dryRun, tempDirectory } = options;
102
+ const host = host_1.NodeJS_HOST;
103
+ const result = await determinePackageManager(host, cwd, configuredPackageManager, logger, dryRun);
104
+ const { name, source } = result;
105
+ let { version } = result;
106
+ const descriptor = package_manager_descriptor_1.SUPPORTED_PACKAGE_MANAGERS[name];
107
+ if (!descriptor) {
108
+ throw new Error(`Unsupported package manager: "${name}"`);
109
+ }
110
+ // Do not verify if the package manager is installed during a dry run.
111
+ let initializationError;
112
+ if (!dryRun && !version) {
113
+ try {
114
+ version = await getPackageManagerVersion(host, cwd, name, logger);
115
+ }
116
+ catch {
117
+ if (source === 'default') {
118
+ initializationError = new Error(`'${DEFAULT_PACKAGE_MANAGER}' was selected as the default package manager, but it is not installed or` +
119
+ ` cannot be found in the PATH. Please install '${DEFAULT_PACKAGE_MANAGER}' to continue.`);
120
+ }
121
+ else {
122
+ initializationError = new Error(`The project is configured to use '${name}', but it is not installed or cannot be` +
123
+ ` found in the PATH. Please install '${name}' to continue.`);
124
+ }
125
+ }
126
+ }
127
+ const packageManager = new package_manager_1.PackageManager(host, cwd, descriptor, {
128
+ dryRun,
129
+ logger,
130
+ tempDirectory,
131
+ version,
132
+ initializationError,
133
+ });
134
+ logger?.debug(`Successfully created PackageManager for '${name}'.`);
135
+ return packageManager;
136
+ }
137
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["factory.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;AAyHH,oDAkDC;AAzKD,gEAAwC;AACxC,mCAA+B;AAC/B,2CAAuC;AACvC,iCAA2C;AAE3C,uDAAmD;AACnD,6EAA8F;AAO9F;;GAEG;AACH,MAAM,uBAAuB,GAAuB,KAAK,CAAC;AAE1D;;;;;;;GAOG;AACH,KAAK,UAAU,wBAAwB,CACrC,IAAU,EACV,GAAW,EACX,IAAwB,EACxB,MAAe;IAEf,MAAM,UAAU,GAAG,uDAA0B,CAAC,IAAI,CAAC,CAAC;IACpD,MAAM,EAAE,KAAK,CAAC,WAAW,IAAI,aAAa,CAAC,CAAC;IAE5C,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,cAAc,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAChG,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9B,MAAM,EAAE,KAAK,CAAC,GAAG,IAAI,gBAAgB,OAAO,IAAI,CAAC,CAAC;IAElD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,KAAK,UAAU,uBAAuB,CACpC,IAAU,EACV,GAAW,EACX,aAA2C,EAAE,EAC7C,MAAe,EACf,MAAgB;IAMhB,IAAI,CAAC,IAAI,EAAE,OAA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C9D,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,cAAc,GAAG,IAAI,gCAAc,CAAC,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE;QAC/D,MAAM;QACN,MAAM;QACN,aAAa;QACb,OAAO;QACP,mBAAmB;KACpB,CAAC,CAAC;IAEH,MAAM,EAAE,KAAK,CAAC,4CAA4C,IAAI,IAAI,CAAC,CAAC;IAEpE,OAAO,cAAc,CAAC;AACxB,CAAC"}
@@ -0,0 +1,86 @@
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 { Stats } from 'node:fs';
9
+ /**
10
+ * An abstraction layer for side-effectful operations.
11
+ */
12
+ export interface Host {
13
+ /**
14
+ * Whether shell quoting is required for package manager specifiers.
15
+ * This is typically true on Windows, where commands are executed in a shell.
16
+ */
17
+ readonly requiresQuoting?: boolean;
18
+ /**
19
+ * Creates a directory.
20
+ * @param path The path to the directory.
21
+ * @param options Options for the directory creation.
22
+ * @returns A promise that resolves when the directory is created.
23
+ */
24
+ mkdir(path: string, options?: {
25
+ recursive?: boolean;
26
+ }): Promise<string | undefined>;
27
+ /**
28
+ * Gets the stats of a file or directory.
29
+ * @param path The path to the file or directory.
30
+ * @returns A promise that resolves to the stats.
31
+ */
32
+ stat(path: string): Promise<Stats>;
33
+ /**
34
+ * Reads the content of a file.
35
+ * @param path The path to the file.
36
+ * @returns A promise that resolves to the file content as a string.
37
+ */
38
+ readFile(path: string): Promise<string>;
39
+ /**
40
+ * Copies a file from the source path to the destination path.
41
+ * @param src The path to the source file.
42
+ * @param dest The path to the destination file.
43
+ * @returns A promise that resolves when the copy is complete.
44
+ */
45
+ copyFile(src: string, dest: string): Promise<void>;
46
+ /**
47
+ * Creates a new, unique temporary directory.
48
+ * @param baseDir The base directory in which to create the temporary directory.
49
+ * @returns A promise that resolves to the absolute path of the created directory.
50
+ */
51
+ createTempDirectory(baseDir?: string): Promise<string>;
52
+ /**
53
+ * Deletes a directory recursively.
54
+ * @param path The path to the directory to delete.
55
+ * @returns A promise that resolves when the deletion is complete.
56
+ */
57
+ deleteDirectory(path: string): Promise<void>;
58
+ /**
59
+ * Writes content to a file.
60
+ * @param path The path to the file.
61
+ * @param content The content to write.
62
+ * @returns A promise that resolves when the write is complete.
63
+ */
64
+ writeFile(path: string, content: string): Promise<void>;
65
+ /**
66
+ * Spawns a child process and returns a promise that resolves with the process's
67
+ * output or rejects with a structured error.
68
+ * @param command The command to run.
69
+ * @param args The arguments to pass to the command.
70
+ * @param options Options for the child process.
71
+ * @returns A promise that resolves with the standard output and standard error of the command.
72
+ */
73
+ runCommand(command: string, args: readonly string[], options?: {
74
+ timeout?: number;
75
+ stdio?: 'pipe' | 'ignore';
76
+ cwd?: string;
77
+ env?: Record<string, string>;
78
+ }): Promise<{
79
+ stdout: string;
80
+ stderr: string;
81
+ }>;
82
+ }
83
+ /**
84
+ * A concrete implementation of the `Host` interface that uses the Node.js APIs.
85
+ */
86
+ export declare const NodeJS_HOST: Host;