nx 17.0.3 → 17.0.5

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 (320) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +9 -4
  3. package/bin/init-local.js +10 -60
  4. package/bin/nx-cloud.js +6 -0
  5. package/bin/nx.js +1 -9
  6. package/bin/post-install.js +5 -1
  7. package/bin/run-executor.js +1 -1
  8. package/migrations.json +18 -0
  9. package/package.json +21 -18
  10. package/plugins/package-json.js +1 -1
  11. package/{changelog-renderer → release/changelog-renderer}/index.d.ts +18 -3
  12. package/{changelog-renderer → release/changelog-renderer}/index.js +78 -34
  13. package/release/index.d.ts +4 -0
  14. package/release/index.js +11 -0
  15. package/schemas/nx-schema.json +203 -19
  16. package/schemas/project-schema.json +20 -0
  17. package/src/adapter/angular-json.js +28 -18
  18. package/src/adapter/compat.d.ts +2 -2
  19. package/src/adapter/compat.js +6 -1
  20. package/src/adapter/ngcli-adapter.d.ts +16 -4
  21. package/src/adapter/ngcli-adapter.js +85 -28
  22. package/src/command-line/add/add.d.ts +2 -0
  23. package/src/command-line/add/add.js +169 -0
  24. package/src/command-line/add/command-object.d.ts +7 -0
  25. package/src/command-line/add/command-object.js +24 -0
  26. package/src/command-line/affected/affected.js +0 -3
  27. package/src/command-line/affected/command-object.d.ts +4 -4
  28. package/src/command-line/affected/command-object.js +53 -26
  29. package/src/command-line/affected/print-affected.js +10 -1
  30. package/src/command-line/connect/command-object.d.ts +1 -2
  31. package/src/command-line/connect/command-object.js +3 -7
  32. package/src/command-line/connect/connect-to-nx-cloud.d.ts +4 -5
  33. package/src/command-line/connect/connect-to-nx-cloud.js +43 -31
  34. package/src/command-line/connect/view-logs.js +5 -21
  35. package/src/command-line/examples.js +18 -0
  36. package/src/command-line/exec/command-object.js +2 -1
  37. package/src/command-line/exec/exec.d.ts +1 -1
  38. package/src/command-line/exec/exec.js +78 -35
  39. package/src/command-line/format/format.js +13 -4
  40. package/src/command-line/generate/generate.js +9 -9
  41. package/src/command-line/generate/generator-utils.d.ts +3 -2
  42. package/src/command-line/generate/generator-utils.js +5 -5
  43. package/src/command-line/graph/graph.d.ts +1 -1
  44. package/src/command-line/graph/graph.js +82 -37
  45. package/src/command-line/init/command-object.js +70 -43
  46. package/src/command-line/init/implementation/add-nx-to-monorepo.d.ts +4 -2
  47. package/src/command-line/init/implementation/add-nx-to-monorepo.js +11 -2
  48. package/src/command-line/init/implementation/add-nx-to-nest.d.ts +1 -1
  49. package/src/command-line/init/implementation/add-nx-to-nest.js +9 -6
  50. package/src/command-line/init/implementation/add-nx-to-npm-repo.d.ts +4 -2
  51. package/src/command-line/init/implementation/add-nx-to-npm-repo.js +14 -4
  52. package/src/command-line/init/implementation/angular/index.js +4 -1
  53. package/src/command-line/init/implementation/angular/legacy-angular-versions.js +10 -5
  54. package/src/command-line/init/implementation/angular/standalone-workspace.js +1 -1
  55. package/src/command-line/init/implementation/angular/types.d.ts +1 -1
  56. package/src/command-line/init/implementation/dot-nx/nxw.js +47 -16
  57. package/src/command-line/init/implementation/react/index.d.ts +1 -1
  58. package/src/command-line/init/implementation/react/index.js +4 -2
  59. package/src/command-line/init/implementation/react/rename-js-to-jsx.js +4 -2
  60. package/src/command-line/init/implementation/utils.d.ts +5 -5
  61. package/src/command-line/init/implementation/utils.js +46 -44
  62. package/src/command-line/init/{init.js → init-v1.js} +5 -13
  63. package/src/command-line/init/init-v2.d.ts +7 -0
  64. package/src/command-line/init/init-v2.js +201 -0
  65. package/src/command-line/list/list.js +6 -5
  66. package/src/command-line/migrate/command-object.js +19 -4
  67. package/src/command-line/migrate/migrate.js +21 -17
  68. package/src/command-line/new/new.js +1 -1
  69. package/src/command-line/nx-commands.js +4 -1
  70. package/src/command-line/release/changelog.d.ts +22 -1
  71. package/src/command-line/release/changelog.js +459 -257
  72. package/src/command-line/release/command-object.d.ts +29 -7
  73. package/src/command-line/release/command-object.js +120 -20
  74. package/src/command-line/release/config/config.d.ts +26 -21
  75. package/src/command-line/release/config/config.js +416 -59
  76. package/src/command-line/release/config/conventional-commits.d.ts +2 -0
  77. package/src/command-line/release/config/conventional-commits.js +98 -0
  78. package/src/command-line/release/config/filter-release-groups.d.ts +1 -2
  79. package/src/command-line/release/config/filter-release-groups.js +38 -1
  80. package/src/command-line/release/index.d.ts +16 -0
  81. package/src/command-line/release/index.js +23 -0
  82. package/src/command-line/release/publish.d.ts +7 -3
  83. package/src/command-line/release/publish.js +89 -37
  84. package/src/command-line/release/release.d.ts +4 -0
  85. package/src/command-line/release/release.js +176 -0
  86. package/src/command-line/release/utils/batch-projects-by-generator-config.d.ts +7 -0
  87. package/src/command-line/release/utils/batch-projects-by-generator-config.js +37 -0
  88. package/src/command-line/release/utils/exec-command.d.ts +1 -0
  89. package/src/command-line/release/utils/exec-command.js +34 -0
  90. package/src/command-line/release/utils/git.d.ts +34 -1
  91. package/src/command-line/release/utils/git.js +238 -34
  92. package/src/command-line/release/utils/github.d.ts +5 -5
  93. package/src/command-line/release/utils/github.js +155 -8
  94. package/src/command-line/release/utils/markdown.js +6 -1
  95. package/src/command-line/release/utils/print-changes.d.ts +1 -1
  96. package/src/command-line/release/utils/print-changes.js +3 -3
  97. package/src/command-line/release/utils/resolve-nx-json-error-message.js +4 -1
  98. package/src/command-line/release/utils/resolve-semver-specifier.d.ts +4 -0
  99. package/src/command-line/release/utils/resolve-semver-specifier.js +58 -0
  100. package/src/command-line/release/utils/semver.d.ts +8 -0
  101. package/src/command-line/release/utils/semver.js +30 -1
  102. package/src/command-line/release/utils/shared.d.ts +39 -0
  103. package/src/command-line/release/utils/shared.js +213 -0
  104. package/src/command-line/release/version.d.ts +37 -3
  105. package/src/command-line/release/version.js +312 -117
  106. package/src/command-line/repair/repair.js +13 -9
  107. package/src/command-line/report/report.d.ts +3 -0
  108. package/src/command-line/report/report.js +22 -5
  109. package/src/command-line/run/command-object.d.ts +4 -0
  110. package/src/command-line/run/command-object.js +18 -2
  111. package/src/command-line/run/executor-utils.d.ts +2 -1
  112. package/src/command-line/run/executor-utils.js +4 -4
  113. package/src/command-line/run/run-one.js +3 -6
  114. package/src/command-line/run/run.js +34 -9
  115. package/src/command-line/run-many/command-object.js +4 -1
  116. package/src/command-line/run-many/run-many.js +0 -3
  117. package/src/command-line/show/command-object.d.ts +3 -0
  118. package/src/command-line/show/command-object.js +29 -2
  119. package/src/command-line/show/show.js +9 -0
  120. package/src/command-line/yargs-utils/shared-options.d.ts +4 -1
  121. package/src/command-line/yargs-utils/shared-options.js +23 -9
  122. package/src/commands-runner/command-graph.d.ts +13 -0
  123. package/src/commands-runner/command-graph.js +2 -0
  124. package/src/commands-runner/create-command-graph.d.ts +4 -0
  125. package/src/commands-runner/create-command-graph.js +44 -0
  126. package/src/commands-runner/get-command-projects.d.ts +3 -0
  127. package/src/commands-runner/get-command-projects.js +19 -0
  128. package/src/config/nx-json.d.ts +160 -25
  129. package/src/config/project-graph.d.ts +3 -3
  130. package/src/config/workspace-json-project-json.d.ts +23 -1
  131. package/src/config/workspaces.d.ts +1 -1
  132. package/src/config/workspaces.js +4 -6
  133. package/src/core/graph/3rdpartylicenses.txt +144 -74
  134. package/src/core/graph/environment.js +1 -1
  135. package/src/core/graph/index.html +4 -6
  136. package/src/core/graph/main.js +1 -1
  137. package/src/core/graph/runtime.js +1 -1
  138. package/src/core/graph/styles.css +3 -3
  139. package/src/core/graph/styles.js +1 -1
  140. package/src/daemon/client/client.d.ts +5 -1
  141. package/src/daemon/client/client.js +27 -8
  142. package/src/daemon/client/{socket-messenger.d.ts → daemon-socket-messenger.d.ts} +1 -1
  143. package/src/daemon/client/{socket-messenger.js → daemon-socket-messenger.js} +3 -3
  144. package/src/daemon/daemon-project-graph-error.d.ts +8 -0
  145. package/src/daemon/daemon-project-graph-error.js +13 -0
  146. package/src/daemon/server/handle-hash-tasks.js +12 -2
  147. package/src/daemon/server/handle-request-project-graph.js +1 -1
  148. package/src/daemon/server/project-graph-incremental-recomputation.d.ts +14 -13
  149. package/src/daemon/server/project-graph-incremental-recomputation.js +98 -33
  150. package/src/daemon/server/shutdown-utils.js +2 -4
  151. package/src/daemon/server/watcher.js +0 -3
  152. package/src/daemon/socket-utils.d.ts +2 -1
  153. package/src/daemon/socket-utils.js +15 -4
  154. package/src/daemon/tmp-dir.d.ts +1 -0
  155. package/src/daemon/tmp-dir.js +4 -4
  156. package/src/devkit-exports.d.ts +2 -2
  157. package/src/devkit-exports.js +3 -2
  158. package/src/devkit-internals.d.ts +3 -0
  159. package/src/devkit-internals.js +7 -1
  160. package/src/executors/noop/schema.json +1 -1
  161. package/src/executors/run-commands/run-commands.impl.d.ts +10 -2
  162. package/src/executors/run-commands/run-commands.impl.js +152 -48
  163. package/src/executors/run-commands/schema.json +11 -1
  164. package/src/executors/run-script/run-script.impl.js +43 -11
  165. package/src/executors/utils/convert-nx-executor.js +1 -1
  166. package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +3 -1
  167. package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +4 -2
  168. package/src/generators/testing-utils/create-tree-with-empty-workspace.js +0 -6
  169. package/src/generators/tree.d.ts +1 -0
  170. package/src/generators/utils/glob.js +2 -2
  171. package/src/generators/utils/project-configuration.js +28 -9
  172. package/src/hasher/create-task-hasher.d.ts +4 -0
  173. package/src/hasher/create-task-hasher.js +16 -0
  174. package/src/hasher/hash-task.js +9 -3
  175. package/src/hasher/native-task-hasher-impl.d.ts +19 -0
  176. package/src/hasher/native-task-hasher-impl.js +37 -0
  177. package/src/hasher/node-task-hasher-impl.d.ts +49 -0
  178. package/src/hasher/node-task-hasher-impl.js +431 -0
  179. package/src/hasher/task-hasher.d.ts +33 -21
  180. package/src/hasher/task-hasher.js +30 -428
  181. package/src/migrations/update-15-0-0/migrate-to-inputs.js +5 -5
  182. package/src/migrations/update-15-1-0/set-project-names.js +2 -1
  183. package/src/migrations/update-15-8-2/update-nxw.js +2 -6
  184. package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +3 -3
  185. package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +49 -13
  186. package/src/migrations/update-17-2-0/move-default-base.d.ts +5 -0
  187. package/src/migrations/update-17-2-0/move-default-base.js +21 -0
  188. package/src/migrations/update-17-3-0/nx-release-path.d.ts +3 -0
  189. package/src/migrations/update-17-3-0/nx-release-path.js +48 -0
  190. package/src/migrations/update-17-3-0/update-nxw.d.ts +2 -0
  191. package/src/migrations/update-17-3-0/update-nxw.js +7 -0
  192. package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +2 -0
  193. package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +9 -0
  194. package/src/native/index.d.ts +65 -15
  195. package/src/native/index.js +6 -2
  196. package/src/native/transform-objects.js +2 -0
  197. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +1 -0
  198. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +13 -12
  199. package/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +6 -1
  200. package/src/nx-cloud/update-manager.js +2 -1
  201. package/src/plugins/js/index.d.ts +1 -1
  202. package/src/plugins/js/index.js +3 -3
  203. package/src/plugins/js/lock-file/lock-file.d.ts +2 -2
  204. package/src/plugins/js/lock-file/lock-file.js +15 -3
  205. package/src/plugins/js/package-json/create-package-json.js +1 -1
  206. package/src/plugins/js/project-graph/build-dependencies/strip-source-code.d.ts +1 -1
  207. package/src/plugins/js/project-graph/build-dependencies/strip-source-code.js +1 -1
  208. package/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.d.ts +1 -1
  209. package/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.js +1 -1
  210. package/src/plugins/js/utils/register.d.ts +1 -1
  211. package/src/plugins/js/utils/register.js +28 -8
  212. package/src/plugins/js/versions.d.ts +1 -1
  213. package/src/plugins/js/versions.js +1 -1
  214. package/{plugins/package-json-workspaces.d.ts → src/plugins/package-json-workspaces/create-nodes.d.ts} +4 -4
  215. package/{plugins/package-json-workspaces.js → src/plugins/package-json-workspaces/create-nodes.js} +34 -12
  216. package/src/plugins/package-json-workspaces/index.d.ts +1 -0
  217. package/src/plugins/package-json-workspaces/index.js +4 -0
  218. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +2 -0
  219. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +47 -0
  220. package/src/plugins/project-json/build-nodes/project-json.d.ts +2 -5
  221. package/src/plugins/project-json/build-nodes/project-json.js +6 -44
  222. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +66 -0
  223. package/src/plugins/target-defaults/target-defaults-plugin.js +182 -0
  224. package/src/project-graph/affected/locators/project-glob-changes.js +3 -3
  225. package/src/project-graph/affected/locators/workspace-projects.d.ts +0 -2
  226. package/src/project-graph/affected/locators/workspace-projects.js +16 -29
  227. package/src/project-graph/build-project-graph.d.ts +20 -1
  228. package/src/project-graph/build-project-graph.js +91 -33
  229. package/src/project-graph/file-map-utils.d.ts +9 -5
  230. package/src/project-graph/file-map-utils.js +16 -63
  231. package/src/project-graph/file-utils.d.ts +1 -1
  232. package/src/project-graph/file-utils.js +44 -2
  233. package/src/project-graph/nx-deps-cache.js +1 -1
  234. package/src/project-graph/project-graph-builder.d.ts +1 -1
  235. package/src/project-graph/project-graph-builder.js +1 -1
  236. package/src/project-graph/project-graph.d.ts +32 -1
  237. package/src/project-graph/project-graph.js +147 -23
  238. package/src/project-graph/utils/build-all-workspace-files.d.ts +2 -0
  239. package/src/project-graph/utils/build-all-workspace-files.js +15 -0
  240. package/src/project-graph/utils/normalize-project-nodes.d.ts +2 -3
  241. package/src/project-graph/utils/normalize-project-nodes.js +7 -33
  242. package/src/project-graph/utils/project-configuration-utils.d.ts +66 -4
  243. package/src/project-graph/utils/project-configuration-utils.js +509 -62
  244. package/src/project-graph/utils/retrieve-workspace-files.d.ts +12 -31
  245. package/src/project-graph/utils/retrieve-workspace-files.js +27 -90
  246. package/src/tasks-runner/batch/run-batch.js +3 -3
  247. package/src/tasks-runner/cache.js +6 -3
  248. package/src/tasks-runner/create-task-graph.js +1 -1
  249. package/src/tasks-runner/fork.d.ts +1 -0
  250. package/src/tasks-runner/fork.js +23 -0
  251. package/src/tasks-runner/forked-process-task-runner.d.ts +13 -5
  252. package/src/tasks-runner/forked-process-task-runner.js +112 -21
  253. package/src/tasks-runner/init-tasks-runner.js +1 -1
  254. package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +28 -28
  255. package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +19 -22
  256. package/src/tasks-runner/life-cycles/empty-terminal-output-life-cycle.js +1 -3
  257. package/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +1 -3
  258. package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +2 -4
  259. package/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +1 -0
  260. package/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +11 -5
  261. package/src/tasks-runner/life-cycles/view-logs-utils.js +1 -1
  262. package/src/tasks-runner/pseudo-ipc.d.ts +49 -0
  263. package/src/tasks-runner/pseudo-ipc.js +140 -0
  264. package/src/tasks-runner/pseudo-terminal.d.ts +43 -0
  265. package/src/tasks-runner/pseudo-terminal.js +159 -0
  266. package/src/tasks-runner/run-command.d.ts +1 -1
  267. package/src/tasks-runner/run-command.js +13 -19
  268. package/src/tasks-runner/task-env.js +1 -2
  269. package/src/tasks-runner/task-graph-utils.d.ts +7 -3
  270. package/src/tasks-runner/task-graph-utils.js +15 -15
  271. package/src/tasks-runner/task-orchestrator.js +68 -12
  272. package/src/tasks-runner/tasks-schedule.js +3 -3
  273. package/src/tasks-runner/utils.d.ts +16 -7
  274. package/src/tasks-runner/utils.js +30 -16
  275. package/src/utils/ab-testing.d.ts +36 -2
  276. package/src/utils/ab-testing.js +34 -16
  277. package/src/utils/assert-workspace-validity.js +1 -1
  278. package/src/utils/cache-directory.d.ts +1 -0
  279. package/src/utils/cache-directory.js +5 -1
  280. package/src/utils/child-process.d.ts +15 -1
  281. package/src/utils/child-process.js +91 -1
  282. package/src/utils/command-line-utils.js +2 -1
  283. package/src/utils/exit-codes.d.ts +6 -0
  284. package/src/utils/exit-codes.js +20 -0
  285. package/src/utils/fileutils.d.ts +1 -0
  286. package/src/utils/find-matching-projects.js +5 -5
  287. package/src/utils/find-workspace-root.js +1 -0
  288. package/src/utils/ignore.js +8 -1
  289. package/src/utils/json-diff.d.ts +1 -0
  290. package/src/utils/json-diff.js +2 -1
  291. package/src/utils/json.js +3 -1
  292. package/src/utils/logger.js +1 -1
  293. package/src/utils/nx-cloud-utils.d.ts +1 -1
  294. package/src/utils/nx-cloud-utils.js +9 -4
  295. package/src/utils/nx-plugin.d.ts +32 -15
  296. package/src/utils/nx-plugin.deprecated.d.ts +10 -5
  297. package/src/utils/nx-plugin.deprecated.js +23 -0
  298. package/src/utils/nx-plugin.js +71 -80
  299. package/src/utils/output.d.ts +4 -2
  300. package/src/utils/output.js +44 -9
  301. package/src/utils/package-json.d.ts +4 -4
  302. package/src/utils/package-json.js +18 -12
  303. package/src/utils/package-manager.d.ts +7 -0
  304. package/src/utils/package-manager.js +24 -4
  305. package/src/utils/params.d.ts +12 -4
  306. package/src/utils/params.js +37 -4
  307. package/src/utils/plugins/core-plugins.js +8 -0
  308. package/src/utils/plugins/installed-plugins.d.ts +2 -1
  309. package/src/utils/plugins/installed-plugins.js +2 -2
  310. package/src/utils/plugins/local-plugins.js +1 -1
  311. package/src/utils/plugins/plugin-capabilities.d.ts +3 -2
  312. package/src/utils/plugins/plugin-capabilities.js +7 -7
  313. package/src/utils/typescript.js +1 -1
  314. package/src/utils/update-nxw.d.ts +2 -0
  315. package/src/utils/update-nxw.js +12 -0
  316. package/src/utils/workspace-configuration-check.js +1 -1
  317. package/src/utils/workspace-context.d.ts +6 -4
  318. package/src/utils/workspace-context.js +19 -9
  319. package/src/core/graph/polyfills.js +0 -1
  320. /package/src/command-line/init/{init.d.ts → init-v1.d.ts} +0 -0
@@ -5,7 +5,7 @@ const crypto_1 = require("crypto");
5
5
  const fs_1 = require("fs");
6
6
  const fs_extra_1 = require("fs-extra");
7
7
  const http = require("http");
8
- const minimatch = require("minimatch");
8
+ const minimatch_1 = require("minimatch");
9
9
  const node_url_1 = require("node:url");
10
10
  const open = require("open");
11
11
  const path_1 = require("path");
@@ -15,7 +15,6 @@ const fileutils_1 = require("../../utils/fileutils");
15
15
  const output_1 = require("../../utils/output");
16
16
  const workspace_root_1 = require("../../utils/workspace-root");
17
17
  const client_1 = require("../../daemon/client/client");
18
- const task_hasher_1 = require("../../hasher/task-hasher");
19
18
  const typescript_1 = require("../../plugins/js/utils/typescript");
20
19
  const operators_1 = require("../../project-graph/operators");
21
20
  const project_graph_1 = require("../../project-graph/project-graph");
@@ -26,6 +25,8 @@ const native_1 = require("../../native");
26
25
  const transform_objects_1 = require("../../native/transform-objects");
27
26
  const affected_1 = require("../affected/affected");
28
27
  const nx_deps_cache_1 = require("../../project-graph/nx-deps-cache");
28
+ const task_hasher_1 = require("../../hasher/task-hasher");
29
+ const create_task_hasher_1 = require("../../hasher/create-task-hasher");
29
30
  // maps file extention to MIME types
30
31
  const mimeType = {
31
32
  '.ico': 'image/x-icon',
@@ -43,7 +44,7 @@ const mimeType = {
43
44
  '.eot': 'appliaction/vnd.ms-fontobject',
44
45
  '.ttf': 'aplication/font-sfnt',
45
46
  };
46
- function buildEnvironmentJs(exclude, watchMode, localMode, depGraphClientResponse, taskGraphClientResponse, expandedTaskInputsReponse) {
47
+ function buildEnvironmentJs(exclude, watchMode, localMode, depGraphClientResponse, taskGraphClientResponse, expandedTaskInputsReponse, sourceMapsResponse) {
47
48
  let environmentJs = `window.exclude = ${JSON.stringify(exclude)};
48
49
  window.watch = ${!!watchMode};
49
50
  window.environment = 'release';
@@ -59,6 +60,7 @@ function buildEnvironmentJs(exclude, watchMode, localMode, depGraphClientRespons
59
60
  projectGraphUrl: 'project-graph.json',
60
61
  taskGraphUrl: 'task-graph.json',
61
62
  taskInputsUrl: 'task-inputs.json',
63
+ sourceMapsUrl: 'source-maps.json'
62
64
  }
63
65
  ],
64
66
  defaultWorkspaceId: 'local',
@@ -70,11 +72,13 @@ function buildEnvironmentJs(exclude, watchMode, localMode, depGraphClientRespons
70
72
  environmentJs += `window.taskGraphResponse = ${JSON.stringify(taskGraphClientResponse)};
71
73
  `;
72
74
  environmentJs += `window.expandedTaskInputsResponse = ${JSON.stringify(expandedTaskInputsReponse)};`;
75
+ environmentJs += `window.sourceMapsResponse = ${JSON.stringify(sourceMapsResponse)};`;
73
76
  }
74
77
  else {
75
78
  environmentJs += `window.projectGraphResponse = null;`;
76
79
  environmentJs += `window.taskGraphResponse = null;`;
77
80
  environmentJs += `window.expandedTaskInputsResponse = null;`;
81
+ environmentJs += `window.sourceMapsResponse = null;`;
78
82
  }
79
83
  return environmentJs;
80
84
  }
@@ -133,11 +137,28 @@ async function generateGraph(args, affectedProjects) {
133
137
  ],
134
138
  });
135
139
  }
140
+ if (args.view === 'project-details' && !args.focus) {
141
+ output_1.output.error({
142
+ title: `The project details view requires the --focus option.`,
143
+ });
144
+ process.exit(1);
145
+ }
146
+ if (args.view === 'project-details' && (args.targets || args.affected)) {
147
+ output_1.output.error({
148
+ title: `The project details view can only be used with the --focus option.`,
149
+ bodyLines: [
150
+ `You passed ${args.targets ? '--targets ' : ''}${args.affected ? '--affected ' : ''}`,
151
+ ],
152
+ });
153
+ process.exit(1);
154
+ }
136
155
  // TODO: Graph Client should support multiple targets
137
156
  const target = Array.isArray(args.targets && args.targets.length >= 1)
138
157
  ? args.targets[0]
139
158
  : args.targets;
140
- const rawGraph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
159
+ const { projectGraph: rawGraph, sourceMaps } = await (0, project_graph_1.createProjectGraphAndSourceMapsAsync)({
160
+ exitOnError: true,
161
+ });
141
162
  let prunedGraph = (0, operators_1.pruneExternalNodes)(rawGraph);
142
163
  const projects = Object.values(prunedGraph.nodes);
143
164
  projects.sort((a, b) => {
@@ -175,7 +196,7 @@ async function generateGraph(args, affectedProjects) {
175
196
  if (args.file) {
176
197
  // stdout is a magical constant that doesn't actually write a file
177
198
  if (args.file === 'stdout') {
178
- console.log(JSON.stringify(createJsonOutput(prunedGraph, args.projects, args.targets), null, 2));
199
+ console.log(JSON.stringify(await createJsonOutput(prunedGraph, rawGraph, args.projects, args.targets), null, 2));
179
200
  process.exit(0);
180
201
  }
181
202
  const workspaceFolder = workspace_root_1.workspaceRoot;
@@ -196,10 +217,10 @@ async function generateGraph(args, affectedProjects) {
196
217
  return isntHtml;
197
218
  },
198
219
  });
199
- const depGraphClientResponse = await createDepGraphClientResponse(affectedProjects);
220
+ const { projectGraphClientResponse } = await createProjectGraphAndSourceMapClientResponse(affectedProjects);
200
221
  const taskGraphClientResponse = await createTaskGraphClientResponse();
201
- const taskInputsReponse = await createExpandedTaskInputResponse(taskGraphClientResponse, depGraphClientResponse);
202
- const environmentJs = buildEnvironmentJs(args.exclude || [], args.watch, !!args.file && args.file.endsWith('html') ? 'build' : 'serve', depGraphClientResponse, taskGraphClientResponse, taskInputsReponse);
222
+ const taskInputsReponse = await createExpandedTaskInputResponse(taskGraphClientResponse, projectGraphClientResponse);
223
+ const environmentJs = buildEnvironmentJs(args.exclude || [], args.watch, !!args.file && args.file.endsWith('html') ? 'build' : 'serve', projectGraphClientResponse, taskGraphClientResponse, taskInputsReponse, sourceMaps);
203
224
  html = html.replace(/src="/g, 'src="static/');
204
225
  html = html.replace(/href="styles/g, 'href="static/styles');
205
226
  html = html.replace('<base href="/" />', '');
@@ -213,7 +234,7 @@ async function generateGraph(args, affectedProjects) {
213
234
  }
214
235
  else if (ext === '.json') {
215
236
  (0, fs_extra_1.ensureDirSync)((0, path_1.dirname)(fullFilePath));
216
- const json = createJsonOutput(prunedGraph, args.projects, args.targets);
237
+ const json = await createJsonOutput(prunedGraph, rawGraph, args.projects, args.targets);
217
238
  json.affectedProjects = affectedProjects;
218
239
  json.criticalPath = affectedProjects;
219
240
  (0, fileutils_1.writeJsonFile)(fullFilePath, json);
@@ -223,7 +244,7 @@ async function generateGraph(args, affectedProjects) {
223
244
  '- affectedProjects',
224
245
  '- criticalPath',
225
246
  '',
226
- 'These fields will be removed in Nx 18. If you need to see which projects were affected, use `nx show projects --affected`.',
247
+ 'These fields will be removed in Nx 19. If you need to see which projects were affected, use `nx show projects --affected`.',
227
248
  ],
228
249
  });
229
250
  output_1.output.success({
@@ -245,7 +266,7 @@ async function generateGraph(args, affectedProjects) {
245
266
  const { app, url } = await startServer(html, environmentJs, args.host || '127.0.0.1', args.port || 4211, args.watch, affectedProjects, args.focus, args.groupByFolder, args.exclude);
246
267
  url.pathname = args.view;
247
268
  if (args.focus) {
248
- url.pathname += '/' + args.focus;
269
+ url.pathname += '/' + encodeURIComponent(args.focus);
249
270
  }
250
271
  if (target) {
251
272
  url.pathname += '/' + target;
@@ -279,10 +300,12 @@ async function startServer(html, environmentJs, host, port = 4211, watchForchang
279
300
  if (watchForchanges) {
280
301
  unregisterFileWatcher = await createFileWatcher();
281
302
  }
282
- currentDepGraphClientResponse = await createDepGraphClientResponse(affected);
283
- currentDepGraphClientResponse.focus = focus;
284
- currentDepGraphClientResponse.groupByFolder = groupByFolder;
285
- currentDepGraphClientResponse.exclude = exclude;
303
+ const { projectGraphClientResponse, sourceMapResponse } = await createProjectGraphAndSourceMapClientResponse(affected);
304
+ currentProjectGraphClientResponse = projectGraphClientResponse;
305
+ currentProjectGraphClientResponse.focus = focus;
306
+ currentProjectGraphClientResponse.groupByFolder = groupByFolder;
307
+ currentProjectGraphClientResponse.exclude = exclude;
308
+ currentSourceMapsClientResponse = sourceMapResponse;
286
309
  const app = http.createServer(async (req, res) => {
287
310
  // parse URL
288
311
  const parsedUrl = new node_url_1.URL(req.url, `http://${host}:${port}`);
@@ -290,10 +313,11 @@ async function startServer(html, environmentJs, host, port = 4211, watchForchang
290
313
  // Avoid https://en.wikipedia.org/wiki/Directory_traversal_attack
291
314
  // e.g curl --path-as-is http://localhost:9000/../fileInDanger.txt
292
315
  // by limiting the path to current directory only
316
+ res.setHeader('Access-Control-Allow-Origin', '*');
293
317
  const sanitizePath = (0, path_1.basename)(parsedUrl.pathname);
294
318
  if (sanitizePath === 'project-graph.json') {
295
319
  res.writeHead(200, { 'Content-Type': 'application/json' });
296
- res.end(JSON.stringify(currentDepGraphClientResponse));
320
+ res.end(JSON.stringify(currentProjectGraphClientResponse));
297
321
  return;
298
322
  }
299
323
  if (sanitizePath === 'task-graph.json') {
@@ -311,9 +335,14 @@ async function startServer(html, environmentJs, host, port = 4211, watchForchang
311
335
  perf_hooks_1.performance.measure('task input generation', 'task input generation:start', 'task input generation:end');
312
336
  return;
313
337
  }
338
+ if (sanitizePath === 'source-maps.json') {
339
+ res.writeHead(200, { 'Content-Type': 'application/json' });
340
+ res.end(JSON.stringify(currentSourceMapsClientResponse));
341
+ return;
342
+ }
314
343
  if (sanitizePath === 'currentHash') {
315
344
  res.writeHead(200, { 'Content-Type': 'application/json' });
316
- res.end(JSON.stringify({ hash: currentDepGraphClientResponse.hash }));
345
+ res.end(JSON.stringify({ hash: currentProjectGraphClientResponse.hash }));
317
346
  return;
318
347
  }
319
348
  if (sanitizePath === 'environment.js') {
@@ -353,7 +382,7 @@ async function startServer(html, environmentJs, host, port = 4211, watchForchang
353
382
  });
354
383
  });
355
384
  }
356
- let currentDepGraphClientResponse = {
385
+ let currentProjectGraphClientResponse = {
357
386
  hash: null,
358
387
  projects: [],
359
388
  dependencies: {},
@@ -367,6 +396,7 @@ let currentDepGraphClientResponse = {
367
396
  groupByFolder: false,
368
397
  exclude: [],
369
398
  };
399
+ let currentSourceMapsClientResponse = {};
370
400
  function debounce(fn, time) {
371
401
  let timeout;
372
402
  return (...args) => {
@@ -387,10 +417,13 @@ function createFileWatcher() {
387
417
  }
388
418
  else if (changes !== null && changes.changedFiles.length > 0) {
389
419
  output_1.output.note({ title: 'Recalculating project graph...' });
390
- const newGraphClientResponse = await createDepGraphClientResponse();
391
- if (newGraphClientResponse.hash !== currentDepGraphClientResponse.hash) {
420
+ const { projectGraphClientResponse, sourceMapResponse } = await createProjectGraphAndSourceMapClientResponse();
421
+ if (projectGraphClientResponse.hash !==
422
+ currentProjectGraphClientResponse.hash &&
423
+ sourceMapResponse) {
392
424
  output_1.output.note({ title: 'Graph changes updated.' });
393
- currentDepGraphClientResponse = newGraphClientResponse;
425
+ currentProjectGraphClientResponse = projectGraphClientResponse;
426
+ currentSourceMapsClientResponse = sourceMapResponse;
394
427
  }
395
428
  else {
396
429
  output_1.output.note({ title: 'No graph changes found.' });
@@ -398,9 +431,10 @@ function createFileWatcher() {
398
431
  }
399
432
  }, 500));
400
433
  }
401
- async function createDepGraphClientResponse(affected = []) {
434
+ async function createProjectGraphAndSourceMapClientResponse(affected = []) {
402
435
  perf_hooks_1.performance.mark('project graph watch calculation:start');
403
- let graph = (0, operators_1.pruneExternalNodes)(await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true }));
436
+ const { projectGraph, sourceMaps } = await (0, project_graph_1.createProjectGraphAndSourceMapsAsync)({ exitOnError: true });
437
+ let graph = (0, operators_1.pruneExternalNodes)(projectGraph);
404
438
  let fileMap = (0, nx_deps_cache_1.readFileMapCache)().fileMap.projectFileMap;
405
439
  perf_hooks_1.performance.mark('project graph watch calculation:end');
406
440
  perf_hooks_1.performance.mark('project graph response generation:start');
@@ -408,19 +442,22 @@ async function createDepGraphClientResponse(affected = []) {
408
442
  const projects = Object.values(graph.nodes);
409
443
  const dependencies = graph.dependencies;
410
444
  const hasher = (0, crypto_1.createHash)('sha256');
411
- hasher.update(JSON.stringify({ layout, projects, dependencies }));
445
+ hasher.update(JSON.stringify({ layout, projects, dependencies, sourceMaps }));
412
446
  const hash = hasher.digest('hex');
413
447
  perf_hooks_1.performance.mark('project graph response generation:end');
414
448
  perf_hooks_1.performance.measure('project graph watch calculation', 'project graph watch calculation:start', 'project graph watch calculation:end');
415
449
  perf_hooks_1.performance.measure('project graph response generation', 'project graph response generation:start', 'project graph response generation:end');
416
450
  return {
417
- ...currentDepGraphClientResponse,
418
- hash,
419
- layout,
420
- projects,
421
- dependencies,
422
- affected,
423
- fileMap,
451
+ projectGraphClientResponse: {
452
+ ...currentProjectGraphClientResponse,
453
+ hash,
454
+ layout,
455
+ projects,
456
+ dependencies,
457
+ affected,
458
+ fileMap,
459
+ },
460
+ sourceMapResponse: sourceMaps,
424
461
  };
425
462
  }
426
463
  async function createTaskGraphClientResponse(pruneExternal = false) {
@@ -435,7 +472,7 @@ async function createTaskGraphClientResponse(pruneExternal = false) {
435
472
  perf_hooks_1.performance.mark('task graph generation:start');
436
473
  const taskGraphs = getAllTaskGraphsForWorkspace(nxJson, graph);
437
474
  perf_hooks_1.performance.mark('task graph generation:end');
438
- const planner = new native_1.HashPlanner(workspace_root_1.workspaceRoot, nxJson, (0, transform_objects_1.transformProjectGraphForRust)(graph));
475
+ const planner = new native_1.HashPlanner(nxJson, (0, native_1.transferProjectGraph)((0, transform_objects_1.transformProjectGraphForRust)(graph)));
439
476
  perf_hooks_1.performance.mark('task hash plan generation:start');
440
477
  const plans = {};
441
478
  for (const individualTaskGraph of Object.values(taskGraphs.taskGraphs)) {
@@ -523,7 +560,7 @@ async function getExpandedTaskInputs(taskId) {
523
560
  const allWorkspaceFiles = await (0, all_file_data_1.allFileData)();
524
561
  const inputs = taskGraphResponse.plans[taskId];
525
562
  if (inputs) {
526
- return expandInputs(inputs, currentDepGraphClientResponse.projects.find((p) => p.name === project), allWorkspaceFiles, currentDepGraphClientResponse);
563
+ return expandInputs(inputs, currentProjectGraphClientResponse.projects.find((p) => p.name === project), allWorkspaceFiles, currentProjectGraphClientResponse);
527
564
  }
528
565
  return {};
529
566
  }
@@ -564,7 +601,7 @@ function expandInputs(inputs, project, allWorkspaceFiles, depGraphClientResponse
564
601
  }
565
602
  else {
566
603
  allWorkspaceFiles
567
- .filter((f) => minimatch(f.file, withoutWorkspaceRoot))
604
+ .filter((f) => (0, minimatch_1.minimatch)(f.file, withoutWorkspaceRoot))
568
605
  .forEach((f) => {
569
606
  matches.push(f.file);
570
607
  });
@@ -603,14 +640,22 @@ function expandInputs(inputs, project, allWorkspaceFiles, depGraphClientResponse
603
640
  external: externalInputs,
604
641
  };
605
642
  }
606
- function createJsonOutput(graph, projects, targets) {
643
+ async function createJsonOutput(prunedGraph, rawGraph, projects, targets) {
607
644
  const response = {
608
- graph,
645
+ graph: prunedGraph,
609
646
  };
610
647
  if (targets?.length) {
611
648
  const nxJson = (0, configuration_1.readNxJson)();
612
649
  const defaultDependencyConfigs = (0, create_task_graph_1.mapTargetDefaultsToDependencies)(nxJson.targetDefaults);
613
- response.tasks = (0, create_task_graph_1.createTaskGraph)(graph, defaultDependencyConfigs, projects, targets, undefined, {});
650
+ const taskGraph = (0, create_task_graph_1.createTaskGraph)(rawGraph, defaultDependencyConfigs, projects, targets, undefined, {});
651
+ const hasher = (0, create_task_hasher_1.createTaskHasher)(rawGraph, (0, configuration_1.readNxJson)());
652
+ let tasks = Object.values(taskGraph.tasks);
653
+ const hashes = await hasher.hashTasks(tasks, taskGraph);
654
+ response.tasks = taskGraph;
655
+ response.taskPlans = tasks.reduce((acc, task, index) => {
656
+ acc[task.id] = Object.keys(hashes[index].details.nodes).sort();
657
+ return acc;
658
+ }, {});
614
659
  }
615
660
  return response;
616
661
  }
@@ -2,55 +2,82 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.yargsInitCommand = void 0;
4
4
  const shared_options_1 = require("../yargs-utils/shared-options");
5
+ const nx_json_1 = require("../../config/nx-json");
6
+ const useV2 = process.env['NX_ADD_PLUGINS'] !== 'false' &&
7
+ (0, nx_json_1.readNxJson)().useInferencePlugins !== false;
5
8
  exports.yargsInitCommand = {
6
9
  command: 'init',
7
- describe: 'Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up distributed caching. For more info, check https://nx.dev/recipes/adopting-nx.',
10
+ describe: 'Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up remote caching. For more info, check https://nx.dev/recipes/adopting-nx.',
8
11
  builder: (yargs) => withInitOptions(yargs),
9
12
  handler: async (args) => {
10
- await (await Promise.resolve().then(() => require('./init'))).initHandler(args);
13
+ if (useV2) {
14
+ await require('./init-v2').initHandler(args);
15
+ }
16
+ else {
17
+ await require('./init-v1').initHandler(args);
18
+ }
11
19
  process.exit(0);
12
20
  },
13
21
  };
14
22
  function withInitOptions(yargs) {
15
- return yargs
16
- .option('nxCloud', {
17
- type: 'boolean',
18
- description: 'Set up distributed caching with Nx Cloud.',
19
- })
20
- .option('interactive', {
21
- describe: 'When false disables interactive input prompts for options.',
22
- type: 'boolean',
23
- default: true,
24
- })
25
- .option('integrated', {
26
- type: 'boolean',
27
- description: 'Migrate to an Nx integrated layout workspace. Only for Angular CLI workspaces and CRA projects.',
28
- default: false,
29
- })
30
- .option('addE2e', {
31
- describe: 'Set up Cypress E2E tests in integrated workspaces. Only for CRA projects.',
32
- type: 'boolean',
33
- default: false,
34
- })
35
- .option('useDotNxInstallation', {
36
- type: 'boolean',
37
- description: 'Initialize an Nx workspace setup in the .nx directory of the current repository.',
38
- default: false,
39
- })
40
- .option('force', {
41
- describe: 'Force the migration to continue and ignore custom webpack setup or uncommitted changes. Only for CRA projects.',
42
- type: 'boolean',
43
- default: false,
44
- })
45
- .option('vite', {
46
- type: 'boolean',
47
- description: 'Use Vite as the bundler. Only for CRA projects.',
48
- default: true,
49
- })
50
- .option('cacheable', {
51
- type: 'string',
52
- description: 'Comma-separated list of cacheable operations. Only used for internal testing.',
53
- coerce: shared_options_1.parseCSV,
54
- hidden: true,
55
- });
23
+ if (useV2) {
24
+ return yargs
25
+ .option('nxCloud', {
26
+ type: 'boolean',
27
+ description: 'Set up distributed caching with Nx Cloud.',
28
+ })
29
+ .option('interactive', {
30
+ describe: 'When false disables interactive input prompts for options.',
31
+ type: 'boolean',
32
+ default: true,
33
+ })
34
+ .option('useDotNxInstallation', {
35
+ type: 'boolean',
36
+ description: 'Initialize an Nx workspace setup in the .nx directory of the current repository.',
37
+ default: false,
38
+ });
39
+ }
40
+ else {
41
+ return yargs
42
+ .option('nxCloud', {
43
+ type: 'boolean',
44
+ description: 'Set up remote caching with Nx Cloud.',
45
+ })
46
+ .option('interactive', {
47
+ describe: 'When false disables interactive input prompts for options.',
48
+ type: 'boolean',
49
+ default: true,
50
+ })
51
+ .option('integrated', {
52
+ type: 'boolean',
53
+ description: 'Migrate to an Nx integrated layout workspace. Only for Angular CLI workspaces and CRA projects.',
54
+ default: false,
55
+ })
56
+ .option('addE2e', {
57
+ describe: 'Set up Cypress E2E tests in integrated workspaces. Only for CRA projects.',
58
+ type: 'boolean',
59
+ default: false,
60
+ })
61
+ .option('useDotNxInstallation', {
62
+ type: 'boolean',
63
+ description: 'Initialize an Nx workspace setup in the .nx directory of the current repository.',
64
+ default: false,
65
+ })
66
+ .option('force', {
67
+ describe: 'Force the migration to continue and ignore custom webpack setup or uncommitted changes. Only for CRA projects.',
68
+ type: 'boolean',
69
+ default: false,
70
+ })
71
+ .option('vite', {
72
+ type: 'boolean',
73
+ description: 'Use Vite as the bundler. Only for CRA projects.',
74
+ default: true,
75
+ })
76
+ .option('cacheable', {
77
+ type: 'string',
78
+ description: 'Comma-separated list of cacheable operations. Only used for internal testing.',
79
+ coerce: shared_options_1.parseCSV,
80
+ hidden: true,
81
+ });
82
+ }
56
83
  }
@@ -1,4 +1,6 @@
1
- import { InitArgs } from '../init';
2
- type Options = Pick<InitArgs, 'nxCloud' | 'interactive' | 'cacheable'>;
1
+ import { InitArgs } from '../init-v1';
2
+ type Options = Pick<InitArgs, 'nxCloud' | 'interactive' | 'cacheable'> & {
3
+ legacy?: boolean;
4
+ };
3
5
  export declare function addNxToMonorepo(options: Options): Promise<void>;
4
6
  export {};
@@ -9,6 +9,7 @@ const fileutils_1 = require("../../../utils/fileutils");
9
9
  const output_1 = require("../../../utils/output");
10
10
  const package_manager_1 = require("../../../utils/package-manager");
11
11
  const utils_1 = require("./utils");
12
+ const connect_to_nx_cloud_1 = require("../../connect/connect-to-nx-cloud");
12
13
  async function addNxToMonorepo(options) {
13
14
  const repoRoot = process.cwd();
14
15
  output_1.output.log({ title: '🐳 Nx initialization' });
@@ -47,16 +48,24 @@ async function addNxToMonorepo(options) {
47
48
  },
48
49
  ]))[scriptName];
49
50
  }
50
- useNxCloud = options.nxCloud ?? (await (0, utils_1.askAboutNxCloud)());
51
+ useNxCloud =
52
+ options.nxCloud ?? (await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)());
51
53
  }
52
54
  else {
53
55
  targetDefaults = [];
54
56
  cacheableOperations = options.cacheable ?? [];
55
57
  useNxCloud =
56
58
  options.nxCloud ??
57
- (options.interactive ? await (0, utils_1.askAboutNxCloud)() : false);
59
+ (options.interactive
60
+ ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)()
61
+ : false);
58
62
  }
59
63
  (0, utils_1.createNxJsonFile)(repoRoot, targetDefaults, cacheableOperations, scriptOutputs);
64
+ if (!options.legacy) {
65
+ packageJsonFiles.forEach((packageJsonPath) => {
66
+ (0, utils_1.markPackageJsonAsNxProject)((0, path_1.join)(repoRoot, packageJsonPath), cacheableOperations);
67
+ });
68
+ }
60
69
  (0, utils_1.updateGitIgnore)(repoRoot);
61
70
  (0, utils_1.addDepsToPackageJson)(repoRoot);
62
71
  output_1.output.log({ title: '📦 Installing dependencies' });
@@ -1,4 +1,4 @@
1
- import { InitArgs } from '../init';
1
+ import { InitArgs } from '../init-v1';
2
2
  import { PackageJson } from '../../../utils/package-json';
3
3
  type Options = Pick<InitArgs, 'nxCloud' | 'interactive' | 'cacheable'>;
4
4
  export declare function addNxToNest(options: Options, packageJson: PackageJson): Promise<void>;
@@ -9,6 +9,7 @@ const output_1 = require("../../../utils/output");
9
9
  const package_manager_1 = require("../../../utils/package-manager");
10
10
  const utils_1 = require("./utils");
11
11
  const versions_1 = require("../../../utils/versions");
12
+ const connect_to_nx_cloud_1 = require("../../connect/connect-to-nx-cloud");
12
13
  async function addNxToNest(options, packageJson) {
13
14
  const repoRoot = process.cwd();
14
15
  output_1.output.log({ title: '🐳 Nx initialization' });
@@ -61,20 +62,23 @@ async function addNxToNest(options, packageJson) {
61
62
  },
62
63
  ]))[scriptName];
63
64
  }
64
- useNxCloud = options.nxCloud ?? (await (0, utils_1.askAboutNxCloud)());
65
+ useNxCloud =
66
+ options.nxCloud ?? (await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)());
65
67
  }
66
68
  else {
67
69
  cacheableOperations = options.cacheable ?? [];
68
70
  useNxCloud =
69
71
  options.nxCloud ??
70
- (options.interactive ? await (0, utils_1.askAboutNxCloud)() : false);
72
+ (options.interactive
73
+ ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)()
74
+ : false);
71
75
  }
72
- (0, utils_1.createNxJsonFile)(repoRoot, [], [...cacheableOperations, ...nestCacheableScripts], {});
76
+ (0, utils_1.createNxJsonFile)(repoRoot, [], [...cacheableOperations, ...nestCacheableScripts], scriptOutputs);
73
77
  const pmc = (0, package_manager_1.getPackageManagerCommand)();
74
78
  (0, utils_1.updateGitIgnore)(repoRoot);
75
79
  (0, utils_1.addDepsToPackageJson)(repoRoot);
76
80
  addNestPluginToPackageJson(repoRoot);
77
- (0, utils_1.markRootPackageJsonAsNxProject)(repoRoot, cacheableOperations, scriptOutputs, pmc);
81
+ (0, utils_1.markRootPackageJsonAsNxProjectLegacy)(repoRoot, cacheableOperations, pmc);
78
82
  createProjectJson(repoRoot, packageJson, nestCLIConfiguration);
79
83
  removeFile(repoRoot, 'nest-cli.json');
80
84
  updatePackageJsonScripts(repoRoot, isJS);
@@ -171,9 +175,8 @@ function createProjectJson(repoRoot, packageJson, nestCLIOptions) {
171
175
  // lint
172
176
  json.targets['lint'] = {
173
177
  executor: '@nx/eslint:lint',
174
- outputs: ['{options.outputFile}'],
175
178
  options: {
176
- lintFilePatterns: ['src/**/*.ts', 'test/**/*.ts'],
179
+ lintFilePatterns: ['./src', './test'],
177
180
  },
178
181
  };
179
182
  // test and e2e
@@ -1,4 +1,6 @@
1
- import { InitArgs } from '../init';
2
- type Options = Pick<InitArgs, 'nxCloud' | 'interactive' | 'cacheable'>;
1
+ import { InitArgs } from '../init-v1';
2
+ type Options = Pick<InitArgs, 'nxCloud' | 'interactive' | 'cacheable'> & {
3
+ legacy?: boolean;
4
+ };
3
5
  export declare function addNxToNpmRepo(options: Options): Promise<void>;
4
6
  export {};
@@ -2,10 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addNxToNpmRepo = void 0;
4
4
  const enquirer = require("enquirer");
5
+ const path_1 = require("path");
5
6
  const fileutils_1 = require("../../../utils/fileutils");
6
7
  const output_1 = require("../../../utils/output");
7
8
  const package_manager_1 = require("../../../utils/package-manager");
8
9
  const utils_1 = require("./utils");
10
+ const connect_to_nx_cloud_1 = require("../../connect/connect-to-nx-cloud");
9
11
  async function addNxToNpmRepo(options) {
10
12
  const repoRoot = process.cwd();
11
13
  output_1.output.log({ title: '🐳 Nx initialization' });
@@ -36,19 +38,27 @@ async function addNxToNpmRepo(options) {
36
38
  },
37
39
  ]))[scriptName];
38
40
  }
39
- useNxCloud = options.nxCloud ?? (await (0, utils_1.askAboutNxCloud)());
41
+ useNxCloud =
42
+ options.nxCloud ?? (await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)());
40
43
  }
41
44
  else {
42
45
  cacheableOperations = options.cacheable ?? [];
43
46
  useNxCloud =
44
47
  options.nxCloud ??
45
- (options.interactive ? await (0, utils_1.askAboutNxCloud)() : false);
48
+ (options.interactive
49
+ ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)()
50
+ : false);
46
51
  }
47
- (0, utils_1.createNxJsonFile)(repoRoot, [], cacheableOperations, {});
52
+ (0, utils_1.createNxJsonFile)(repoRoot, [], cacheableOperations, scriptOutputs);
48
53
  const pmc = (0, package_manager_1.getPackageManagerCommand)();
49
54
  (0, utils_1.updateGitIgnore)(repoRoot);
50
55
  (0, utils_1.addDepsToPackageJson)(repoRoot);
51
- (0, utils_1.markRootPackageJsonAsNxProject)(repoRoot, cacheableOperations, scriptOutputs, pmc);
56
+ if (options.legacy) {
57
+ (0, utils_1.markRootPackageJsonAsNxProjectLegacy)(repoRoot, cacheableOperations, pmc);
58
+ }
59
+ else {
60
+ (0, utils_1.markPackageJsonAsNxProject)((0, path_1.join)(repoRoot, 'package.json'), cacheableOperations);
61
+ }
52
62
  output_1.output.log({ title: '📦 Installing dependencies' });
53
63
  (0, utils_1.runInstall)(repoRoot, pmc);
54
64
  if (useNxCloud) {
@@ -11,6 +11,7 @@ const utils_1 = require("../utils");
11
11
  const integrated_workspace_1 = require("./integrated-workspace");
12
12
  const legacy_angular_versions_1 = require("./legacy-angular-versions");
13
13
  const standalone_workspace_1 = require("./standalone-workspace");
14
+ const connect_to_nx_cloud_1 = require("../../../connect/connect-to-nx-cloud");
14
15
  const defaultCacheableOperations = [
15
16
  'build',
16
17
  'server',
@@ -35,7 +36,8 @@ async function addNxToAngularCliRepo(options) {
35
36
  const cacheableOperations = !options.integrated
36
37
  ? await collectCacheableOperations(options)
37
38
  : [];
38
- const useNxCloud = options.nxCloud ?? (options.interactive ? await (0, utils_1.askAboutNxCloud)() : false);
39
+ const useNxCloud = options.nxCloud ??
40
+ (options.interactive ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)() : false);
39
41
  output_1.output.log({ title: '📦 Installing dependencies' });
40
42
  installDependencies();
41
43
  output_1.output.log({ title: '📝 Setting up workspace' });
@@ -106,6 +108,7 @@ function addPluginDependencies() {
106
108
  (0, fileutils_1.writeJsonFile)(packageJsonPath, packageJson);
107
109
  }
108
110
  async function setupWorkspace(cacheableOperations, isIntegratedMigration) {
111
+ (0, utils_1.updateGitIgnore)(repoRoot);
109
112
  if (isIntegratedMigration) {
110
113
  (0, integrated_workspace_1.setupIntegratedWorkspace)();
111
114
  }