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
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeResult = exports.killSocketOrPath = exports.FULL_OS_SOCKET_PATH = exports.isWindows = void 0;
3
+ exports.serializeResult = exports.killSocketOrPath = exports.FORKED_PROCESS_OS_SOCKET_PATH = exports.FULL_OS_SOCKET_PATH = exports.isWindows = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const os_1 = require("os");
6
6
  const path_1 = require("path");
7
7
  const tmp_dir_1 = require("./tmp-dir");
8
+ const daemon_project_graph_error_1 = require("./daemon-project-graph-error");
8
9
  exports.isWindows = (0, os_1.platform)() === 'win32';
9
10
  /**
10
11
  * For IPC with the daemon server we use unix sockets or windows named pipes, depending on the user's operating system.
@@ -15,6 +16,11 @@ exports.isWindows = (0, os_1.platform)() === 'win32';
15
16
  exports.FULL_OS_SOCKET_PATH = exports.isWindows
16
17
  ? '\\\\.\\pipe\\nx\\' + (0, path_1.resolve)(tmp_dir_1.DAEMON_SOCKET_PATH)
17
18
  : (0, path_1.resolve)(tmp_dir_1.DAEMON_SOCKET_PATH);
19
+ const FORKED_PROCESS_OS_SOCKET_PATH = (id) => {
20
+ let path = (0, path_1.resolve)((0, path_1.join)(tmp_dir_1.socketDir, 'fp' + id + '.sock'));
21
+ return exports.isWindows ? '\\\\.\\pipe\\nx\\' + (0, path_1.resolve)(path) : (0, path_1.resolve)(path);
22
+ };
23
+ exports.FORKED_PROCESS_OS_SOCKET_PATH = FORKED_PROCESS_OS_SOCKET_PATH;
18
24
  function killSocketOrPath() {
19
25
  try {
20
26
  (0, fs_1.unlinkSync)(exports.FULL_OS_SOCKET_PATH);
@@ -27,11 +33,16 @@ function serializeError(error) {
27
33
  if (!error) {
28
34
  return null;
29
35
  }
30
- return JSON.stringify(error, Object.getOwnPropertyNames(error));
36
+ if (error instanceof daemon_project_graph_error_1.DaemonProjectGraphError) {
37
+ error.errors = error.errors.map((e) => JSON.parse(serializeError(e)));
38
+ }
39
+ return `{${Object.getOwnPropertyNames(error)
40
+ .map((k) => `"${k}": ${JSON.stringify(error[k])}`)
41
+ .join(',')}}`;
31
42
  }
32
43
  // Prepare a serialized project graph result for sending over IPC from the server to the client
33
- function serializeResult(error, serializedProjectGraph) {
44
+ function serializeResult(error, serializedProjectGraph, serializedSourceMaps) {
34
45
  // We do not want to repeat work `JSON.stringify`ing an object containing the potentially large project graph so merge as strings
35
- return `{ "error": ${serializeError(error)}, "projectGraph": ${serializedProjectGraph} }`;
46
+ return `{ "error": ${serializeError(error)}, "projectGraph": ${serializedProjectGraph}, "sourceMaps": ${serializedSourceMaps} }`;
36
47
  }
37
48
  exports.serializeResult = serializeResult;
@@ -1,5 +1,6 @@
1
1
  export declare const DAEMON_DIR_FOR_CURRENT_WORKSPACE: string;
2
2
  export declare const DAEMON_OUTPUT_LOG_FILE: string;
3
+ export declare const socketDir: string;
3
4
  export declare const DAEMON_SOCKET_PATH: string;
4
5
  export declare function writeDaemonLogs(error?: string): string;
5
6
  export declare function markDaemonAsDisabled(): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeSocketDir = exports.isDaemonDisabled = exports.markDaemonAsDisabled = exports.writeDaemonLogs = exports.DAEMON_SOCKET_PATH = exports.DAEMON_OUTPUT_LOG_FILE = exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE = void 0;
3
+ exports.removeSocketDir = exports.isDaemonDisabled = exports.markDaemonAsDisabled = exports.writeDaemonLogs = exports.DAEMON_SOCKET_PATH = exports.socketDir = exports.DAEMON_OUTPUT_LOG_FILE = exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE = void 0;
4
4
  /**
5
5
  * Per workspace (to avoid subtle differences and issues), we want to have a deterministic
6
6
  * location within the OS's tmp directory where we write log files for background processes
@@ -15,8 +15,8 @@ const tmp_1 = require("tmp");
15
15
  const workspace_root_1 = require("../utils/workspace-root");
16
16
  exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'd');
17
17
  exports.DAEMON_OUTPUT_LOG_FILE = (0, path_1.join)(exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE, 'daemon.log');
18
- const socketDir = process.env.NX_DAEMON_SOCKET_DIR || createSocketDir();
19
- exports.DAEMON_SOCKET_PATH = (0, path_1.join)(socketDir,
18
+ exports.socketDir = process.env.NX_DAEMON_SOCKET_DIR || createSocketDir();
19
+ exports.DAEMON_SOCKET_PATH = (0, path_1.join)(exports.socketDir,
20
20
  // As per notes above on socket/named pipe length limitations, we keep this intentionally short
21
21
  'd.sock');
22
22
  function writeDaemonLogs(error) {
@@ -61,7 +61,7 @@ function createSocketDir() {
61
61
  }
62
62
  function removeSocketDir() {
63
63
  try {
64
- (0, fs_extra_1.rmdirSync)(socketDir);
64
+ (0, fs_extra_1.rmSync)(exports.socketDir, { recursive: true, force: true });
65
65
  }
66
66
  catch (e) { }
67
67
  }
@@ -19,7 +19,7 @@ export type { Generator, GeneratorCallback, Executor, ExecutorContext, TaskGraph
19
19
  */
20
20
  export { Workspaces } from './config/workspaces';
21
21
  export { workspaceLayout } from './config/configuration';
22
- export type { NxPlugin, NxPluginV1, NxPluginV2, ProjectTargetConfigurator, CreateNodes, CreateNodesFunction, CreateNodesContext, CreateDependencies, CreateDependenciesContext, } from './utils/nx-plugin';
22
+ export type { NxPlugin, NxPluginV1, NxPluginV2, ProjectTargetConfigurator, CreateNodes, CreateNodesFunction, CreateNodesResult, CreateNodesContext, CreateDependencies, CreateDependenciesContext, } from './utils/nx-plugin';
23
23
  /**
24
24
  * @category Workspace
25
25
  */
@@ -43,7 +43,7 @@ export type { PackageManager } from './utils/package-manager';
43
43
  /**
44
44
  * @category Package Manager
45
45
  */
46
- export { getPackageManagerCommand, detectPackageManager, getPackageManagerVersion, } from './utils/package-manager';
46
+ export { getPackageManagerCommand, detectPackageManager, getPackageManagerVersion, isWorkspacesEnabled, } from './utils/package-manager';
47
47
  /**
48
48
  * @category Commands
49
49
  */
@@ -4,8 +4,8 @@
4
4
  * Try hard to not add to this API to reduce the surface area we need to maintain.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.appRootPath = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.ProjectGraphBuilder = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.glob = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.workspaceLayout = exports.Workspaces = void 0;
8
- // TODO(v18): Remove this export
7
+ exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.appRootPath = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.ProjectGraphBuilder = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.glob = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.isWorkspacesEnabled = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.workspaceLayout = exports.Workspaces = void 0;
8
+ // TODO(v19): Remove this export
9
9
  /**
10
10
  * @category Workspace
11
11
  */
@@ -30,6 +30,7 @@ var package_manager_1 = require("./utils/package-manager");
30
30
  Object.defineProperty(exports, "getPackageManagerCommand", { enumerable: true, get: function () { return package_manager_1.getPackageManagerCommand; } });
31
31
  Object.defineProperty(exports, "detectPackageManager", { enumerable: true, get: function () { return package_manager_1.detectPackageManager; } });
32
32
  Object.defineProperty(exports, "getPackageManagerVersion", { enumerable: true, get: function () { return package_manager_1.getPackageManagerVersion; } });
33
+ Object.defineProperty(exports, "isWorkspacesEnabled", { enumerable: true, get: function () { return package_manager_1.isWorkspacesEnabled; } });
33
34
  /**
34
35
  * @category Commands
35
36
  */
@@ -14,4 +14,7 @@ export { sortObjectByKeys } from './utils/object-sort';
14
14
  export { stripIndent } from './utils/logger';
15
15
  export { readModulePackageJson } from './utils/package-json';
16
16
  export { splitByColons } from './utils/split-target';
17
+ export { hashObject } from './hasher/file-hasher';
18
+ export { hashWithWorkspaceContext } from './utils/workspace-context';
17
19
  export { createProjectRootMappingsFromProjectConfigurations, findProjectForPath, } from './project-graph/utils/find-project-for-path';
20
+ export { registerTsProject } from './plugins/js/utils/register';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
3
+ exports.registerTsProject = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
4
4
  /**
5
5
  * Note to developers: STOP! These exports are available via requireNx in @nx/devkit.
6
6
  *
@@ -28,6 +28,12 @@ var package_json_1 = require("./utils/package-json");
28
28
  Object.defineProperty(exports, "readModulePackageJson", { enumerable: true, get: function () { return package_json_1.readModulePackageJson; } });
29
29
  var split_target_2 = require("./utils/split-target");
30
30
  Object.defineProperty(exports, "splitByColons", { enumerable: true, get: function () { return split_target_2.splitByColons; } });
31
+ var file_hasher_1 = require("./hasher/file-hasher");
32
+ Object.defineProperty(exports, "hashObject", { enumerable: true, get: function () { return file_hasher_1.hashObject; } });
33
+ var workspace_context_1 = require("./utils/workspace-context");
34
+ Object.defineProperty(exports, "hashWithWorkspaceContext", { enumerable: true, get: function () { return workspace_context_1.hashWithWorkspaceContext; } });
31
35
  var find_project_for_path_1 = require("./project-graph/utils/find-project-for-path");
32
36
  Object.defineProperty(exports, "createProjectRootMappingsFromProjectConfigurations", { enumerable: true, get: function () { return find_project_for_path_1.createProjectRootMappingsFromProjectConfigurations; } });
33
37
  Object.defineProperty(exports, "findProjectForPath", { enumerable: true, get: function () { return find_project_for_path_1.findProjectForPath; } });
38
+ var register_1 = require("./plugins/js/utils/register");
39
+ Object.defineProperty(exports, "registerTsProject", { enumerable: true, get: function () { return register_1.registerTsProject; } });
@@ -6,5 +6,5 @@
6
6
  "cli": "nx",
7
7
  "outputCapture": "pipe",
8
8
  "properties": {},
9
- "additionalProperties": false
9
+ "additionalProperties": true
10
10
  }
@@ -21,20 +21,28 @@ export interface RunCommandsOptions extends Json {
21
21
  parallel?: boolean;
22
22
  readyWhen?: string;
23
23
  cwd?: string;
24
- args?: string;
24
+ env?: Record<string, string>;
25
+ args?: string | string[];
25
26
  envFile?: string;
26
27
  __unparsed__: string[];
28
+ usePty?: boolean;
29
+ streamOutput?: boolean;
27
30
  }
28
31
  export interface NormalizedRunCommandsOptions extends RunCommandsOptions {
29
32
  commands: {
30
33
  command: string;
31
34
  forwardAllArgs?: boolean;
32
35
  }[];
36
+ unknownOptions?: {
37
+ [k: string]: any;
38
+ };
33
39
  parsedArgs: {
34
40
  [k: string]: any;
35
41
  };
42
+ args?: string;
36
43
  }
37
44
  export default function (options: RunCommandsOptions, context: ExecutorContext): Promise<{
38
45
  success: boolean;
46
+ terminalOutput: string;
39
47
  }>;
40
- export declare function interpolateArgsIntoCommand(command: string, opts: Pick<NormalizedRunCommandsOptions, 'parsedArgs' | '__unparsed__'>, forwardAllArgs: boolean): string;
48
+ export declare function interpolateArgsIntoCommand(command: string, opts: Pick<NormalizedRunCommandsOptions, 'args' | 'parsedArgs' | '__unparsed__' | 'unknownOptions'>, forwardAllArgs: boolean): string;
@@ -6,6 +6,7 @@ const path = require("path");
6
6
  const yargsParser = require("yargs-parser");
7
7
  const npm_run_path_1 = require("npm-run-path");
8
8
  const chalk = require("chalk");
9
+ const pseudo_terminal_1 = require("../../tasks-runner/pseudo-terminal");
9
10
  exports.LARGE_BUFFER = 1024 * 1000000;
10
11
  async function loadEnvVars(path) {
11
12
  if (path) {
@@ -30,6 +31,11 @@ const propKeys = [
30
31
  'cwd',
31
32
  'args',
32
33
  'envFile',
34
+ '__unparsed__',
35
+ 'env',
36
+ 'usePty',
37
+ 'streamOutput',
38
+ 'verbose',
33
39
  ];
34
40
  async function default_1(options, context) {
35
41
  await loadEnvVars(options.envFile);
@@ -42,10 +48,10 @@ async function default_1(options, context) {
42
48
  throw new Error('ERROR: Bad executor config for run-commands - "prefix", "color" and "bgColor" can only be set when "parallel=true".');
43
49
  }
44
50
  try {
45
- const success = options.parallel
51
+ const result = options.parallel
46
52
  ? await runInParallel(normalized, context)
47
53
  : await runSerially(normalized, context);
48
- return { success };
54
+ return result;
49
55
  }
50
56
  catch (e) {
51
57
  if (process.env.NX_VERBOSE_LOGGING === 'true') {
@@ -56,36 +62,52 @@ async function default_1(options, context) {
56
62
  }
57
63
  exports.default = default_1;
58
64
  async function runInParallel(options, context) {
59
- const procs = options.commands.map((c) => createProcess(c, options.readyWhen, options.color, calculateCwd(options.cwd, context)).then((result) => ({
65
+ const procs = options.commands.map((c) => createProcess(null, c, options.readyWhen, options.color, calculateCwd(options.cwd, context), options.env ?? {}, true, options.usePty, options.streamOutput).then((result) => ({
60
66
  result,
61
67
  command: c.command,
62
68
  })));
69
+ let terminalOutput = '';
63
70
  if (options.readyWhen) {
64
71
  const r = await Promise.race(procs);
65
- if (!r.result) {
66
- process.stderr.write(`Warning: run-commands command "${r.command}" exited with non-zero status code`);
67
- return false;
72
+ terminalOutput += r.result.terminalOutput;
73
+ if (!r.result.success) {
74
+ const output = `Warning: command "${r.command}" exited with non-zero status code`;
75
+ terminalOutput += output;
76
+ if (options.streamOutput) {
77
+ process.stderr.write(output);
78
+ }
79
+ return { success: false, terminalOutput };
68
80
  }
69
81
  else {
70
- return true;
82
+ return { success: true, terminalOutput };
71
83
  }
72
84
  }
73
85
  else {
74
86
  const r = await Promise.all(procs);
75
- const failed = r.filter((v) => !v.result);
87
+ terminalOutput += r.map((f) => f.result.terminalOutput).join('');
88
+ const failed = r.filter((v) => !v.result.success);
76
89
  if (failed.length > 0) {
77
- failed.forEach((f) => {
78
- process.stderr.write(`Warning: run-commands command "${f.command}" exited with non-zero status code`);
79
- });
80
- return false;
90
+ const output = failed
91
+ .map((f) => `Warning: command "${f.command}" exited with non-zero status code`)
92
+ .join('\r\n');
93
+ terminalOutput += output;
94
+ if (options.streamOutput) {
95
+ process.stderr.write(output);
96
+ }
97
+ return {
98
+ success: false,
99
+ terminalOutput,
100
+ };
81
101
  }
82
102
  else {
83
- return true;
103
+ return {
104
+ success: true,
105
+ terminalOutput,
106
+ };
84
107
  }
85
108
  }
86
109
  }
87
110
  function normalizeOptions(options) {
88
- options.parsedArgs = parseArgs(options);
89
111
  if (options.command) {
90
112
  options.commands = [{ command: options.command }];
91
113
  options.parallel = !!options.readyWhen;
@@ -93,55 +115,125 @@ function normalizeOptions(options) {
93
115
  else {
94
116
  options.commands = options.commands.map((c) => typeof c === 'string' ? { command: c } : c);
95
117
  }
118
+ if (options.args && Array.isArray(options.args)) {
119
+ options.args = options.args.join(' ');
120
+ }
121
+ const unparsedCommandArgs = yargsParser(options.__unparsed__, {
122
+ configuration: {
123
+ 'parse-numbers': false,
124
+ 'parse-positional-numbers': false,
125
+ 'dot-notation': false,
126
+ },
127
+ });
128
+ options.unknownOptions = Object.keys(options)
129
+ .filter((p) => propKeys.indexOf(p) === -1 && unparsedCommandArgs[p] === undefined)
130
+ .reduce((m, c) => ((m[c] = options[c]), m), {});
131
+ options.parsedArgs = parseArgs(unparsedCommandArgs, options.unknownOptions, options.args);
96
132
  options.commands.forEach((c) => {
97
133
  c.command = interpolateArgsIntoCommand(c.command, options, c.forwardAllArgs ?? true);
98
134
  });
99
135
  return options;
100
136
  }
101
137
  async function runSerially(options, context) {
138
+ const pseudoTerminal = pseudo_terminal_1.PseudoTerminal.isSupported()
139
+ ? (0, pseudo_terminal_1.getPseudoTerminal)()
140
+ : null;
141
+ let terminalOutput = '';
102
142
  for (const c of options.commands) {
103
- const success = await createProcess(c, undefined, options.color, calculateCwd(options.cwd, context));
104
- if (!success) {
105
- process.stderr.write(`Warning: run-commands command "${c.command}" exited with non-zero status code`);
106
- return false;
143
+ const result = await createProcess(pseudoTerminal, c, undefined, options.color, calculateCwd(options.cwd, context), options.env ?? {}, false, options.usePty, options.streamOutput);
144
+ terminalOutput += result.terminalOutput;
145
+ if (!result.success) {
146
+ const output = `Warning: command "${c.command}" exited with non-zero status code`;
147
+ result.terminalOutput += output;
148
+ if (options.streamOutput) {
149
+ process.stderr.write(output);
150
+ }
151
+ return { success: false, terminalOutput };
107
152
  }
108
153
  }
109
- return true;
154
+ return { success: true, terminalOutput };
155
+ }
156
+ async function createProcess(pseudoTerminal, commandConfig, readyWhen, color, cwd, env, isParallel, usePty = true, streamOutput = true) {
157
+ env = processEnv(color, cwd, env);
158
+ // The rust runCommand is always a tty, so it will not look nice in parallel and if we need prefixes
159
+ // currently does not work properly in windows
160
+ if (pseudoTerminal &&
161
+ process.env.NX_NATIVE_COMMAND_RUNNER !== 'false' &&
162
+ !commandConfig.prefix &&
163
+ !isParallel &&
164
+ usePty) {
165
+ const cp = pseudoTerminal.runCommand(commandConfig.command, {
166
+ cwd,
167
+ jsEnv: env,
168
+ quiet: !streamOutput,
169
+ });
170
+ let terminalOutput = '';
171
+ return new Promise((res) => {
172
+ cp.onOutput((output) => {
173
+ terminalOutput += output;
174
+ if (readyWhen && output.indexOf(readyWhen) > -1) {
175
+ res({ success: true, terminalOutput });
176
+ }
177
+ });
178
+ cp.onExit((code) => {
179
+ if (code >= 128) {
180
+ process.exit(code);
181
+ }
182
+ else {
183
+ res({ success: code === 0, terminalOutput });
184
+ }
185
+ });
186
+ });
187
+ }
188
+ return nodeProcess(commandConfig, cwd, env, readyWhen, streamOutput);
110
189
  }
111
- function createProcess(commandConfig, readyWhen, color, cwd) {
190
+ function nodeProcess(commandConfig, cwd, env, readyWhen, streamOutput = true) {
191
+ let terminalOutput = '';
112
192
  return new Promise((res) => {
113
193
  const childProcess = (0, child_process_1.exec)(commandConfig.command, {
114
194
  maxBuffer: exports.LARGE_BUFFER,
115
- env: processEnv(color, cwd),
195
+ env,
116
196
  cwd,
117
197
  });
118
198
  /**
119
199
  * Ensure the child process is killed when the parent exits
120
200
  */
121
- const processExitListener = (signal) => () => childProcess.kill(signal);
201
+ const processExitListener = (signal) => childProcess.kill(signal);
122
202
  process.on('exit', processExitListener);
123
203
  process.on('SIGTERM', processExitListener);
124
204
  process.on('SIGINT', processExitListener);
125
205
  process.on('SIGQUIT', processExitListener);
126
206
  childProcess.stdout.on('data', (data) => {
127
- process.stdout.write(addColorAndPrefix(data, commandConfig));
207
+ const output = addColorAndPrefix(data, commandConfig);
208
+ terminalOutput += output;
209
+ if (streamOutput) {
210
+ process.stdout.write(output);
211
+ }
128
212
  if (readyWhen && data.toString().indexOf(readyWhen) > -1) {
129
- res(true);
213
+ res({ success: true, terminalOutput });
130
214
  }
131
215
  });
132
216
  childProcess.stderr.on('data', (err) => {
133
- process.stderr.write(addColorAndPrefix(err, commandConfig));
217
+ const output = addColorAndPrefix(err, commandConfig);
218
+ terminalOutput += output;
219
+ if (streamOutput) {
220
+ process.stderr.write(output);
221
+ }
134
222
  if (readyWhen && err.toString().indexOf(readyWhen) > -1) {
135
- res(true);
223
+ res({ success: true, terminalOutput });
136
224
  }
137
225
  });
138
226
  childProcess.on('error', (err) => {
139
- process.stderr.write(addColorAndPrefix(err.toString(), commandConfig));
140
- res(false);
227
+ const ouptput = addColorAndPrefix(err.toString(), commandConfig);
228
+ terminalOutput += ouptput;
229
+ if (streamOutput) {
230
+ process.stderr.write(ouptput);
231
+ }
232
+ res({ success: false, terminalOutput });
141
233
  });
142
234
  childProcess.on('exit', (code) => {
143
235
  if (!readyWhen) {
144
- res(code === 0);
236
+ res({ success: code === 0, terminalOutput });
145
237
  }
146
238
  });
147
239
  });
@@ -168,15 +260,22 @@ function calculateCwd(cwd, context) {
168
260
  return cwd;
169
261
  return path.join(context.root, cwd);
170
262
  }
171
- function processEnv(color, cwd) {
172
- const env = {
263
+ function processEnv(color, cwd, env) {
264
+ const localEnv = (0, npm_run_path_1.env)({ cwd: cwd ?? process.cwd() });
265
+ const res = {
173
266
  ...process.env,
174
- ...(0, npm_run_path_1.env)({ cwd: cwd ?? process.cwd() }),
267
+ ...localEnv,
268
+ ...env,
175
269
  };
270
+ // need to override PATH to make sure we are using the local node_modules
271
+ if (localEnv.PATH)
272
+ res.PATH = localEnv.PATH; // UNIX-like
273
+ if (localEnv.Path)
274
+ res.Path = localEnv.Path; // Windows
176
275
  if (color) {
177
- env.FORCE_COLOR = `${color}`;
276
+ res.FORCE_COLOR = `${color}`;
178
277
  }
179
- return env;
278
+ return res;
180
279
  }
181
280
  function interpolateArgsIntoCommand(command, opts, forwardAllArgs) {
182
281
  if (command.indexOf('{args.') > -1) {
@@ -184,27 +283,32 @@ function interpolateArgsIntoCommand(command, opts, forwardAllArgs) {
184
283
  return command.replace(regex, (_, group) => opts.parsedArgs[group] !== undefined ? opts.parsedArgs[group] : '');
185
284
  }
186
285
  else if (forwardAllArgs) {
187
- return `${command}${opts.__unparsed__.length > 0 ? ' ' + opts.__unparsed__.join(' ') : ''}`;
286
+ let args = '';
287
+ if (Object.keys(opts.unknownOptions ?? {}).length > 0) {
288
+ args +=
289
+ ' ' +
290
+ Object.keys(opts.unknownOptions)
291
+ .filter((k) => typeof opts.unknownOptions[k] !== 'object' &&
292
+ opts.parsedArgs[k] === opts.unknownOptions[k])
293
+ .map((k) => `--${k} ${opts.unknownOptions[k]}`)
294
+ .join(' ');
295
+ }
296
+ if (opts.args) {
297
+ args += ` ${opts.args}`;
298
+ }
299
+ if (opts.__unparsed__?.length > 0) {
300
+ args += ` ${opts.__unparsed__.join(' ')}`;
301
+ }
302
+ return `${command}${args}`;
188
303
  }
189
304
  else {
190
305
  return command;
191
306
  }
192
307
  }
193
308
  exports.interpolateArgsIntoCommand = interpolateArgsIntoCommand;
194
- function parseArgs(options) {
195
- const args = options.args;
309
+ function parseArgs(unparsedCommandArgs, unknownOptions, args) {
196
310
  if (!args) {
197
- const unknownOptionsTreatedAsArgs = Object.keys(options)
198
- .filter((p) => propKeys.indexOf(p) === -1)
199
- .reduce((m, c) => ((m[c] = options[c]), m), {});
200
- const unparsedCommandArgs = yargsParser(options.__unparsed__, {
201
- configuration: {
202
- 'parse-numbers': false,
203
- 'parse-positional-numbers': false,
204
- 'dot-notation': false,
205
- },
206
- });
207
- return { ...unknownOptionsTreatedAsArgs, ...unparsedCommandArgs };
311
+ return { ...unknownOptions, ...unparsedCommandArgs };
208
312
  }
209
313
  return yargsParser(args.replace(/(^"|"$)/g, ''), {
210
314
  configuration: { 'camel-case-expansion': false },
@@ -99,7 +99,10 @@
99
99
  "description": "String to appear in `stdout` or `stderr` that indicates that the task is done. When running multiple commands, this option can only be used when `parallel` is set to `true`. If not specified, the task is done when all the child processes complete."
100
100
  },
101
101
  "args": {
102
- "type": "string",
102
+ "oneOf": [
103
+ { "type": "array", "items": { "type": "string" } },
104
+ { "type": "string" }
105
+ ],
103
106
  "description": "Extra arguments. You can pass them as follows: nx run project:target --args='--wait=100'. You can then use {args.wait} syntax to interpolate them in the workspace config file. See example [above](#chaining-commands-interpolating-args-and-setting-the-cwd)"
104
107
  },
105
108
  "envFile": {
@@ -115,6 +118,13 @@
115
118
  "type": "string",
116
119
  "description": "Current working directory of the commands. If it's not specified the commands will run in the workspace root, if a relative path is specified the commands will run in that path relative to the workspace root and if it's an absolute path the commands will run in that path."
117
120
  },
121
+ "env": {
122
+ "type": "object",
123
+ "description": "Environment variables that will be made available to the commands. This property has priority over the `.env` files.",
124
+ "additionalProperties": {
125
+ "type": "string"
126
+ }
127
+ },
118
128
  "__unparsed__": {
119
129
  "hidden": true,
120
130
  "type": "array",
@@ -1,20 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const child_process_1 = require("child_process");
4
- const package_manager_1 = require("../../utils/package-manager");
5
3
  const path = require("path");
6
- const npm_run_path_1 = require("npm-run-path");
4
+ const package_manager_1 = require("../../utils/package-manager");
5
+ const child_process_1 = require("child_process");
6
+ const pseudo_terminal_1 = require("../../tasks-runner/pseudo-terminal");
7
7
  async function default_1(options, context) {
8
8
  const pm = (0, package_manager_1.getPackageManagerCommand)();
9
9
  try {
10
- (0, child_process_1.execSync)(pm.run(options.script, options.__unparsed__.join(' ')), {
11
- stdio: ['inherit', 'inherit', 'inherit'],
12
- cwd: path.join(context.root, context.projectsConfigurations.projects[context.projectName].root),
13
- env: {
14
- ...process.env,
15
- ...(0, npm_run_path_1.env)(),
16
- },
17
- });
10
+ let command = pm.run(options.script, options.__unparsed__.join(' '));
11
+ let cwd = path.join(context.root, context.projectsConfigurations.projects[context.projectName].root);
12
+ let env = process.env;
13
+ // when running nx through npx with node_modules installed with npm, the path gets modified to include the full workspace path with the node_modules folder
14
+ // This causes issues when running in a pty process, so we filter out the node_modules paths from the PATH
15
+ // Since the command here will be run with the package manager script command, the path will be modified again within the PTY process itself.
16
+ let filteredPath = env.PATH?.split(path.delimiter)
17
+ .filter((p) => !p.startsWith(path.join(context.root, 'node_modules')))
18
+ .join(path.delimiter) ?? '';
19
+ env.PATH = filteredPath;
20
+ if (pseudo_terminal_1.PseudoTerminal.isSupported()) {
21
+ await ptyProcess(command, cwd, env);
22
+ }
23
+ else {
24
+ nodeProcess(command, cwd, env);
25
+ }
18
26
  return { success: true };
19
27
  }
20
28
  catch (e) {
@@ -22,3 +30,27 @@ async function default_1(options, context) {
22
30
  }
23
31
  }
24
32
  exports.default = default_1;
33
+ function nodeProcess(command, cwd, env) {
34
+ (0, child_process_1.execSync)(command, {
35
+ stdio: ['inherit', 'inherit', 'inherit'],
36
+ cwd,
37
+ env,
38
+ });
39
+ }
40
+ async function ptyProcess(command, cwd, env) {
41
+ const terminal = (0, pseudo_terminal_1.getPseudoTerminal)();
42
+ return new Promise((res, rej) => {
43
+ const cp = terminal.runCommand(command, { cwd, jsEnv: env });
44
+ cp.onExit((code) => {
45
+ if (code === 0) {
46
+ res();
47
+ }
48
+ else if (code >= 128) {
49
+ process.exit(code);
50
+ }
51
+ else {
52
+ rej();
53
+ }
54
+ });
55
+ });
56
+ }
@@ -17,7 +17,7 @@ function convertNxExecutor(executor) {
17
17
  const nxJsonConfiguration = (0, nx_json_1.readNxJson)(builderContext.workspaceRoot);
18
18
  const projectsConfigurations = {
19
19
  version: 2,
20
- projects: (await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(builderContext.workspaceRoot, nxJsonConfiguration)).projectNodes,
20
+ projects: (await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(builderContext.workspaceRoot, nxJsonConfiguration)).projects,
21
21
  };
22
22
  const context = {
23
23
  root: builderContext.workspaceRoot,
@@ -3,4 +3,6 @@ import type { Tree } from '../tree';
3
3
  * Formats all the created or updated files using Prettier
4
4
  * @param tree - the file system tree
5
5
  */
6
- export declare function formatChangedFilesWithPrettierIfAvailable(tree: Tree): Promise<void>;
6
+ export declare function formatChangedFilesWithPrettierIfAvailable(tree: Tree, options?: {
7
+ silent?: boolean;
8
+ }): Promise<void>;
@@ -6,7 +6,7 @@ const path = require("path");
6
6
  * Formats all the created or updated files using Prettier
7
7
  * @param tree - the file system tree
8
8
  */
9
- async function formatChangedFilesWithPrettierIfAvailable(tree) {
9
+ async function formatChangedFilesWithPrettierIfAvailable(tree, options) {
10
10
  let prettier;
11
11
  try {
12
12
  prettier = await Promise.resolve().then(() => require('prettier'));
@@ -40,7 +40,9 @@ async function formatChangedFilesWithPrettierIfAvailable(tree) {
40
40
  await prettier.format(file.content.toString('utf-8'), options));
41
41
  }
42
42
  catch (e) {
43
- console.warn(`Could not format ${file.path}. Error: "${e.message}"`);
43
+ if (!options?.silent) {
44
+ console.warn(`Could not format ${file.path}. Error: "${e.message}"`);
45
+ }
44
46
  }
45
47
  }));
46
48
  }