nx 22.6.0 → 22.6.2

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 (201) hide show
  1. package/bin/nx.js +19 -11
  2. package/package.json +11 -12
  3. package/release/changelog-renderer/index.d.ts +2 -1
  4. package/release/changelog-renderer/index.d.ts.map +1 -1
  5. package/schemas/nx-schema.json +102 -0
  6. package/src/adapter/ngcli-adapter.d.ts +8 -5
  7. package/src/adapter/ngcli-adapter.d.ts.map +1 -1
  8. package/src/adapter/ngcli-adapter.js +33 -19
  9. package/src/ai/clone-ai-config-repo.d.ts.map +1 -1
  10. package/src/ai/clone-ai-config-repo.js +2 -0
  11. package/src/command-line/add/add.js +1 -1
  12. package/src/command-line/examples.d.ts +7 -0
  13. package/src/command-line/examples.d.ts.map +1 -1
  14. package/src/command-line/examples.js +29 -1
  15. package/src/command-line/exec/exec.js +3 -3
  16. package/src/command-line/format/format.js +3 -3
  17. package/src/command-line/generate/generate.d.ts.map +1 -1
  18. package/src/command-line/generate/generate.js +1 -1
  19. package/src/command-line/graph/graph.js +1 -1
  20. package/src/command-line/init/command-object.js +1 -21
  21. package/src/command-line/init/configure-plugins.js +1 -1
  22. package/src/command-line/init/implementation/angular/integrated-workspace.js +1 -1
  23. package/src/command-line/init/implementation/angular/legacy-angular-versions.js +2 -2
  24. package/src/command-line/init/implementation/deduce-default-base.js +5 -5
  25. package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +2 -2
  26. package/src/command-line/init/implementation/dot-nx/nxw.js +1 -1
  27. package/src/command-line/init/implementation/utils.d.ts +1 -2
  28. package/src/command-line/init/implementation/utils.d.ts.map +1 -1
  29. package/src/command-line/init/implementation/utils.js +1 -15
  30. package/src/command-line/init/init-v1.d.ts +0 -3
  31. package/src/command-line/init/init-v1.d.ts.map +1 -1
  32. package/src/command-line/init/init-v1.js +1 -27
  33. package/src/command-line/init/init-v2.d.ts +0 -1
  34. package/src/command-line/init/init-v2.d.ts.map +1 -1
  35. package/src/command-line/init/init-v2.js +7 -35
  36. package/src/command-line/mcp/mcp.d.ts.map +1 -1
  37. package/src/command-line/mcp/mcp.js +2 -0
  38. package/src/command-line/migrate/migrate-ui-api.d.ts.map +1 -1
  39. package/src/command-line/migrate/migrate-ui-api.js +13 -0
  40. package/src/command-line/migrate/migrate.d.ts.map +1 -1
  41. package/src/command-line/migrate/migrate.js +41 -23
  42. package/src/command-line/migrate/run-migration-process.js +2 -0
  43. package/src/command-line/nx-cloud/connect/view-logs.js +1 -1
  44. package/src/command-line/nx-commands.js +65 -65
  45. package/src/command-line/release/config/version-plans.js +1 -1
  46. package/src/command-line/release/utils/exec-command.js +1 -1
  47. package/src/command-line/release/utils/launch-editor.js +2 -2
  48. package/src/command-line/release/utils/remote-release-clients/github.d.ts +1 -0
  49. package/src/command-line/release/utils/remote-release-clients/github.d.ts.map +1 -1
  50. package/src/command-line/release/utils/remote-release-clients/github.js +39 -2
  51. package/src/command-line/release/utils/remote-release-clients/gitlab.d.ts.map +1 -1
  52. package/src/command-line/release/utils/remote-release-clients/gitlab.js +1 -0
  53. package/src/command-line/release/version/release-group-processor.d.ts.map +1 -1
  54. package/src/command-line/release/version/release-group-processor.js +2 -4
  55. package/src/command-line/release/version.js +1 -1
  56. package/src/command-line/run/run-one.d.ts.map +1 -1
  57. package/src/command-line/run/run-one.js +1 -1
  58. package/src/command-line/run/run.d.ts.map +1 -1
  59. package/src/command-line/run/run.js +2 -2
  60. package/src/command-line/show/target.js +5 -2
  61. package/src/command-line/watch/watch.js +1 -1
  62. package/src/core/graph/main.js +1 -1
  63. package/src/daemon/client/client.d.ts +2 -2
  64. package/src/daemon/client/client.d.ts.map +1 -1
  65. package/src/daemon/client/client.js +3 -2
  66. package/src/daemon/client/generate-help-output.js +1 -1
  67. package/src/daemon/server/handle-configure-ai-agents.js +11 -4
  68. package/src/daemon/server/handle-hash-tasks.d.ts +1 -0
  69. package/src/daemon/server/handle-hash-tasks.d.ts.map +1 -1
  70. package/src/daemon/server/handle-hash-tasks.js +1 -1
  71. package/src/daemon/server/project-graph-incremental-recomputation.d.ts +1 -1
  72. package/src/daemon/server/project-graph-incremental-recomputation.d.ts.map +1 -1
  73. package/src/daemon/server/project-graph-listener-sockets.d.ts +1 -1
  74. package/src/daemon/server/project-graph-listener-sockets.d.ts.map +1 -1
  75. package/src/daemon/server/shutdown-utils.js +1 -1
  76. package/src/devkit-internals.d.ts +3 -2
  77. package/src/devkit-internals.d.ts.map +1 -1
  78. package/src/devkit-internals.js +5 -4
  79. package/src/executors/run-commands/run-commands.impl.d.ts.map +1 -1
  80. package/src/executors/run-commands/run-commands.impl.js +60 -7
  81. package/src/executors/run-commands/running-tasks.d.ts.map +1 -1
  82. package/src/executors/run-commands/running-tasks.js +1 -5
  83. package/src/executors/run-script/run-script.impl.js +1 -1
  84. package/src/executors/utils/convert-nx-executor.js +2 -2
  85. package/src/generators/utils/project-configuration.js +4 -4
  86. package/src/hasher/hash-plan-inspector.d.ts.map +1 -1
  87. package/src/hasher/hash-plan-inspector.js +1 -1
  88. package/src/hasher/native-task-hasher-impl.d.ts +2 -2
  89. package/src/hasher/native-task-hasher-impl.d.ts.map +1 -1
  90. package/src/hasher/native-task-hasher-impl.js +6 -6
  91. package/src/hasher/task-hasher.d.ts +4 -4
  92. package/src/hasher/task-hasher.d.ts.map +1 -1
  93. package/src/hasher/task-hasher.js +9 -6
  94. package/src/native/index.d.ts +1 -1
  95. package/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  96. package/src/native/nx.wasm32-wasi.wasm +0 -0
  97. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +1 -1
  98. package/src/plugins/js/lock-file/bun-parser.js +1 -1
  99. package/src/plugins/js/lock-file/lock-file.d.ts.map +1 -1
  100. package/src/plugins/js/lock-file/lock-file.js +3 -1
  101. package/src/project-graph/build-project-graph.d.ts +1 -1
  102. package/src/project-graph/build-project-graph.d.ts.map +1 -1
  103. package/src/project-graph/build-project-graph.js +2 -2
  104. package/src/project-graph/error-types.d.ts +2 -1
  105. package/src/project-graph/error-types.d.ts.map +1 -1
  106. package/src/project-graph/file-utils.d.ts.map +1 -1
  107. package/src/project-graph/file-utils.js +4 -2
  108. package/src/project-graph/nx-deps-cache.d.ts +1 -1
  109. package/src/project-graph/nx-deps-cache.d.ts.map +1 -1
  110. package/src/project-graph/plugins/isolation/isolated-plugin.js +5 -5
  111. package/src/project-graph/project-graph.d.ts +2 -2
  112. package/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts +23 -18
  113. package/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts.map +1 -1
  114. package/src/project-graph/utils/project-configuration/name-substitution-manager.js +129 -87
  115. package/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +40 -0
  116. package/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts.map +1 -0
  117. package/src/project-graph/utils/project-configuration/project-nodes-manager.js +264 -0
  118. package/src/project-graph/utils/project-configuration/target-merging.d.ts +32 -0
  119. package/src/project-graph/utils/project-configuration/target-merging.d.ts.map +1 -0
  120. package/src/project-graph/utils/project-configuration/target-merging.js +332 -0
  121. package/src/project-graph/utils/project-configuration/target-normalization.d.ts +13 -0
  122. package/src/project-graph/utils/project-configuration/target-normalization.d.ts.map +1 -0
  123. package/src/project-graph/utils/project-configuration/target-normalization.js +177 -0
  124. package/src/project-graph/utils/project-configuration-utils.d.ts +16 -41
  125. package/src/project-graph/utils/project-configuration-utils.d.ts.map +1 -1
  126. package/src/project-graph/utils/project-configuration-utils.js +56 -734
  127. package/src/tasks-runner/cache.js +1 -1
  128. package/src/tasks-runner/default-tasks-runner.js +1 -1
  129. package/src/tasks-runner/life-cycle.d.ts +4 -0
  130. package/src/tasks-runner/life-cycle.d.ts.map +1 -1
  131. package/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts.map +1 -1
  132. package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +4 -0
  133. package/src/tasks-runner/task-orchestrator.d.ts +12 -4
  134. package/src/tasks-runner/task-orchestrator.d.ts.map +1 -1
  135. package/src/tasks-runner/task-orchestrator.js +123 -68
  136. package/src/tasks-runner/tasks-schedule.d.ts +1 -1
  137. package/src/tasks-runner/tasks-schedule.d.ts.map +1 -1
  138. package/src/tasks-runner/tasks-schedule.js +14 -3
  139. package/src/tasks-runner/utils.d.ts +2 -2
  140. package/src/tasks-runner/utils.d.ts.map +1 -1
  141. package/src/tasks-runner/utils.js +5 -7
  142. package/src/utils/ab-testing.js +1 -1
  143. package/src/utils/analytics-prompt.d.ts.map +1 -1
  144. package/src/utils/analytics-prompt.js +2 -0
  145. package/src/utils/child-process.d.ts.map +1 -1
  146. package/src/utils/child-process.js +1 -2
  147. package/src/utils/command-line-utils.js +3 -3
  148. package/src/utils/default-base.js +1 -1
  149. package/src/utils/git-utils.d.ts.map +1 -1
  150. package/src/utils/git-utils.index-filter.js +2 -2
  151. package/src/utils/git-utils.js +6 -5
  152. package/src/utils/git-utils.tree-filter.js +1 -1
  153. package/src/utils/machine-id-cache.d.ts.map +1 -1
  154. package/src/utils/machine-id-cache.js +72 -2
  155. package/src/utils/package-json.js +2 -2
  156. package/src/utils/package-manager.d.ts.map +1 -1
  157. package/src/utils/package-manager.js +8 -13
  158. package/src/utils/provenance.d.ts.map +1 -1
  159. package/src/utils/provenance.js +2 -2
  160. package/src/utils/require-nx-key.js +1 -1
  161. package/src/utils/serialize-overrides-into-command-line.d.ts.map +1 -1
  162. package/src/utils/serialize-overrides-into-command-line.js +3 -4
  163. package/src/utils/shell-quoting.d.ts +11 -0
  164. package/src/utils/shell-quoting.d.ts.map +1 -0
  165. package/src/utils/shell-quoting.js +41 -0
  166. package/src/utils/split-target.d.ts +13 -2
  167. package/src/utils/split-target.d.ts.map +1 -1
  168. package/src/utils/split-target.js +180 -31
  169. package/src/command-line/init/implementation/react/add-craco-commands-to-package-scripts.d.ts +0 -2
  170. package/src/command-line/init/implementation/react/add-craco-commands-to-package-scripts.d.ts.map +0 -1
  171. package/src/command-line/init/implementation/react/add-craco-commands-to-package-scripts.js +0 -21
  172. package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.d.ts +0 -2
  173. package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.d.ts.map +0 -1
  174. package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.js +0 -20
  175. package/src/command-line/init/implementation/react/check-for-custom-webpack-setup.d.ts +0 -2
  176. package/src/command-line/init/implementation/react/check-for-custom-webpack-setup.d.ts.map +0 -1
  177. package/src/command-line/init/implementation/react/check-for-custom-webpack-setup.js +0 -17
  178. package/src/command-line/init/implementation/react/check-for-uncommitted-changes.d.ts +0 -2
  179. package/src/command-line/init/implementation/react/check-for-uncommitted-changes.d.ts.map +0 -1
  180. package/src/command-line/init/implementation/react/check-for-uncommitted-changes.js +0 -20
  181. package/src/command-line/init/implementation/react/clean-up-files.d.ts +0 -2
  182. package/src/command-line/init/implementation/react/clean-up-files.d.ts.map +0 -1
  183. package/src/command-line/init/implementation/react/clean-up-files.js +0 -30
  184. package/src/command-line/init/implementation/react/index.d.ts +0 -5
  185. package/src/command-line/init/implementation/react/index.d.ts.map +0 -1
  186. package/src/command-line/init/implementation/react/index.js +0 -77
  187. package/src/command-line/init/implementation/react/read-name-from-package-json.d.ts +0 -2
  188. package/src/command-line/init/implementation/react/read-name-from-package-json.d.ts.map +0 -1
  189. package/src/command-line/init/implementation/react/read-name-from-package-json.js +0 -16
  190. package/src/command-line/init/implementation/react/rename-js-to-jsx.d.ts +0 -2
  191. package/src/command-line/init/implementation/react/rename-js-to-jsx.d.ts.map +0 -1
  192. package/src/command-line/init/implementation/react/rename-js-to-jsx.js +0 -22
  193. package/src/command-line/init/implementation/react/tsconfig-setup.d.ts +0 -2
  194. package/src/command-line/init/implementation/react/tsconfig-setup.d.ts.map +0 -1
  195. package/src/command-line/init/implementation/react/tsconfig-setup.js +0 -108
  196. package/src/command-line/init/implementation/react/write-vite-config.d.ts +0 -2
  197. package/src/command-line/init/implementation/react/write-vite-config.d.ts.map +0 -1
  198. package/src/command-line/init/implementation/react/write-vite-config.js +0 -53
  199. package/src/command-line/init/implementation/react/write-vite-index-html.d.ts +0 -2
  200. package/src/command-line/init/implementation/react/write-vite-index-html.d.ts.map +0 -1
  201. package/src/command-line/init/implementation/react/write-vite-index-html.js +0 -24
@@ -1,56 +1,205 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.splitTargetFromNodes = splitTargetFromNodes;
4
+ exports.splitTargetFromConfigurations = splitTargetFromConfigurations;
4
5
  exports.splitTarget = splitTarget;
5
6
  exports.splitByColons = splitByColons;
6
- function findMatchingSegments(s, nodes) {
7
- const projectNames = Object.keys(nodes);
8
- // return project if matching
9
- if (projectNames.includes(s)) {
10
- return [s];
11
- }
12
- if (!s.includes(':')) {
13
- return;
7
+ const output_1 = require("../utils/output");
8
+ function nodeLookup(nodes) {
9
+ return {
10
+ has: (name) => !!nodes[name],
11
+ getTargets: (name) => nodes[name]?.data?.targets,
12
+ };
13
+ }
14
+ function configLookup(configs) {
15
+ return {
16
+ has: (name) => !!configs[name],
17
+ getTargets: (name) => configs[name]?.targets,
18
+ };
19
+ }
20
+ /**
21
+ * Collects all valid [project, target?, config?] interpretations of a
22
+ * colon-delimited string by iterating over the *segments* of the string
23
+ * (O(k²) where k = number of segments) rather than over every project in the
24
+ * graph.
25
+ *
26
+ * When `currentProject` is provided, bare-target interpretations (the string
27
+ * is `target` or `target:config` on that project) are also collected.
28
+ */
29
+ function findAllMatchingSegments(segments, lookup, currentProject) {
30
+ const matches = [];
31
+ // --- Bare-target matches (currentProject context) ---
32
+ if (currentProject && lookup.has(currentProject)) {
33
+ const targets = lookup.getTargets(currentProject) || {};
34
+ for (let j = 1; j <= segments.length; j++) {
35
+ const candidateTarget = segments.slice(0, j).join(':');
36
+ if (!(candidateTarget in targets)) {
37
+ continue;
38
+ }
39
+ const configSegments = segments.slice(j);
40
+ if (configSegments.length === 0) {
41
+ matches.push([currentProject, candidateTarget]);
42
+ }
43
+ else {
44
+ const candidateConfig = configSegments.join(':');
45
+ const configurations = targets[candidateTarget]?.configurations;
46
+ if (configurations && candidateConfig in configurations) {
47
+ matches.push([currentProject, candidateTarget, candidateConfig]);
48
+ }
49
+ }
50
+ }
14
51
  }
15
- for (const projectName of projectNames) {
16
- for (const [targetName, targetConfig] of Object.entries(nodes[projectName].data.targets || {})) {
17
- if (s === `${projectName}:${targetName}`) {
18
- return [projectName, targetName];
52
+ // --- Project-based matches ---
53
+ for (let i = 1; i <= segments.length; i++) {
54
+ const candidateProject = segments.slice(0, i).join(':');
55
+ if (!lookup.has(candidateProject)) {
56
+ continue;
57
+ }
58
+ const remaining = segments.slice(i);
59
+ if (remaining.length === 0) {
60
+ matches.push([candidateProject]);
61
+ continue;
62
+ }
63
+ const targets = lookup.getTargets(candidateProject) || {};
64
+ for (let j = 1; j <= remaining.length; j++) {
65
+ const candidateTarget = remaining.slice(0, j).join(':');
66
+ if (!(candidateTarget in targets)) {
67
+ continue;
68
+ }
69
+ const configSegments = remaining.slice(j);
70
+ if (configSegments.length === 0) {
71
+ matches.push([candidateProject, candidateTarget]);
19
72
  }
20
- if (targetConfig.configurations) {
21
- for (const configurationName of Object.keys(targetConfig.configurations)) {
22
- if (s === `${projectName}:${targetName}:${configurationName}`) {
23
- return [projectName, targetName, configurationName];
24
- }
73
+ else {
74
+ const candidateConfig = configSegments.join(':');
75
+ const configurations = targets[candidateTarget]?.configurations;
76
+ if (configurations && candidateConfig in configurations) {
77
+ matches.push([candidateProject, candidateTarget, candidateConfig]);
25
78
  }
26
79
  }
27
80
  }
28
81
  }
82
+ return matches;
83
+ }
84
+ /**
85
+ * Returns whether `a` should be preferred over `b` using deterministic
86
+ * precedence rules:
87
+ *
88
+ * 1. Bare-target matches (currentProject) rank highest.
89
+ * 2. Longest (most-specific) project name.
90
+ * 3. Longest target name.
91
+ * 4. Longest configuration name.
92
+ */
93
+ function isHigherPrecedence(a, b, currentProject) {
94
+ const aIsBare = currentProject && a[0] === currentProject ? 1 : 0;
95
+ const bIsBare = currentProject && b[0] === currentProject ? 1 : 0;
96
+ if (aIsBare !== bIsBare)
97
+ return aIsBare > bIsBare;
98
+ if (a[0].length !== b[0].length)
99
+ return a[0].length > b[0].length;
100
+ const aTarget = (a[1] ?? '').length;
101
+ const bTarget = (b[1] ?? '').length;
102
+ if (aTarget !== bTarget)
103
+ return aTarget > bTarget;
104
+ return (a[2] ?? '').length > (b[2] ?? '').length;
105
+ }
106
+ /**
107
+ * Single-pass selection of the highest-precedence match.
108
+ */
109
+ function bestMatch(matches, currentProject) {
110
+ let best = matches[0];
111
+ for (let i = 1; i < matches.length; i++) {
112
+ if (isHigherPrecedence(matches[i], best, currentProject)) {
113
+ best = matches[i];
114
+ }
115
+ }
116
+ return best;
29
117
  }
30
- function splitTargetFromNodes(s, nodes) {
31
- const matchingSegments = findMatchingSegments(s, nodes);
32
- if (matchingSegments) {
33
- return matchingSegments;
118
+ function formatMatch(match) {
119
+ return match.filter(Boolean).join(':');
120
+ }
121
+ /**
122
+ * Internal implementation shared by splitTargetFromNodes and
123
+ * splitTargetFromConfigurations.
124
+ */
125
+ function splitTargetImpl(s, lookup, options) {
126
+ const silent = options?.silent ?? false;
127
+ const currentProject = options?.currentProject;
128
+ const segments = splitByColons(s);
129
+ const matches = findAllMatchingSegments(segments, lookup, currentProject);
130
+ if (matches.length > 0) {
131
+ const best = bestMatch(matches, currentProject);
132
+ if (matches.length > 1 && !silent) {
133
+ output_1.output.warn({
134
+ title: `Ambiguous target specifier "${s}"`,
135
+ bodyLines: [
136
+ `This string can be interpreted in multiple ways:`,
137
+ ...matches.map((m) => ` ${m === best ? '→' : ' '} ${formatMatch(m)}${m === best ? ' (selected)' : ''}`),
138
+ ``,
139
+ `The most specific match was selected. To avoid ambiguity, use a unique target specifier.`,
140
+ ],
141
+ });
142
+ }
143
+ return best;
144
+ }
145
+ // --- Fallback: no exact match found in the graph ---
146
+ let colonIndex = s.indexOf(':');
147
+ if (colonIndex === 0) {
148
+ // first colon can't be at the beginning of the string, try to find the next one
149
+ colonIndex = s.indexOf(':', 1);
34
150
  }
35
- if (s.indexOf(':') > 0) {
36
- let [project, ...segments] = splitByColons(s);
151
+ if (colonIndex > 0) {
152
+ let [project, ...remainingSegments] = segments;
153
+ // splitByColons splits on every ':', so a leading colon (e.g. ":pkg:build")
154
+ // produces an empty first element. Greedily absorb segments to reconstruct
155
+ // the longest known colon-prefixed project name (e.g. ":utils:common").
156
+ if (project === '' && remainingSegments.length > 0) {
157
+ let absorbed = 1; // absorb at least one segment
158
+ for (let k = remainingSegments.length - 1; k >= 1; k--) {
159
+ const candidate = ':' + remainingSegments.slice(0, k).join(':');
160
+ if (lookup.has(candidate)) {
161
+ absorbed = k;
162
+ break;
163
+ }
164
+ }
165
+ project = ':' + remainingSegments.slice(0, absorbed).join(':');
166
+ remainingSegments = remainingSegments.slice(absorbed);
167
+ }
37
168
  // if only configuration cannot be matched, try to match project and target
38
- const configuration = segments[segments.length - 1];
169
+ const configuration = remainingSegments[remainingSegments.length - 1];
39
170
  const rest = s.slice(0, -(configuration.length + 1));
40
- const matchingSegments = findMatchingSegments(rest, nodes);
41
- if (matchingSegments && matchingSegments.length === 2) {
42
- return [...matchingSegments, configuration];
171
+ const restSegments = splitByColons(rest);
172
+ const restMatches = findAllMatchingSegments(restSegments, lookup, currentProject);
173
+ if (restMatches.length > 0) {
174
+ const best = bestMatch(restMatches, currentProject);
175
+ if (best.length === 2) {
176
+ return [...best, configuration];
177
+ }
43
178
  }
44
179
  // no project-target pair found, do the naive matching
45
- const validTargets = nodes[project] ? nodes[project].data.targets : {};
180
+ const validTargets = lookup.getTargets(project);
46
181
  const validTargetNames = new Set(Object.keys(validTargets ?? {}));
47
- return [project, ...groupJointSegments(segments, validTargetNames)];
182
+ return [
183
+ project,
184
+ ...groupJointSegments(remainingSegments, validTargetNames),
185
+ ];
48
186
  }
49
187
  // we don't know what to do with the string, return as is
50
188
  return [s];
51
189
  }
52
- function splitTarget(s, projectGraph) {
53
- return splitTargetFromNodes(s, projectGraph.nodes);
190
+ function splitTargetFromNodes(s, nodes, options) {
191
+ return splitTargetImpl(s, nodeLookup(nodes), options);
192
+ }
193
+ /**
194
+ * Splits a colon-delimited target specifier using a name-keyed
195
+ * `Record<string, ProjectConfiguration>` — the format used during
196
+ * the merge phase before the full project graph is available.
197
+ */
198
+ function splitTargetFromConfigurations(s, configs, options) {
199
+ return splitTargetImpl(s, configLookup(configs), options);
200
+ }
201
+ function splitTarget(s, projectGraph, options) {
202
+ return splitTargetFromNodes(s, projectGraph.nodes, options);
54
203
  }
55
204
  function groupJointSegments(segments, validTargetNames) {
56
205
  for (let endingSegmentIdx = segments.length; endingSegmentIdx > 0; endingSegmentIdx--) {
@@ -1,2 +0,0 @@
1
- export declare function addCracoCommandsToPackageScripts(appName: string, isStandalone: boolean): void;
2
- //# sourceMappingURL=add-craco-commands-to-package-scripts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"add-craco-commands-to-package-scripts.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/add-craco-commands-to-package-scripts.ts"],"names":[],"mappings":"AAEA,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,OAAO,QAiBtB"}
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addCracoCommandsToPackageScripts = addCracoCommandsToPackageScripts;
4
- const fileutils_1 = require("../../../../utils/fileutils");
5
- function addCracoCommandsToPackageScripts(appName, isStandalone) {
6
- const packageJsonPath = isStandalone
7
- ? 'package.json'
8
- : `apps/${appName}/package.json`;
9
- const distPath = isStandalone
10
- ? `dist/${appName}`
11
- : `../../dist/apps/${appName}`;
12
- const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
13
- packageJson.scripts = {
14
- ...packageJson.scripts,
15
- start: 'nx exec -- craco start',
16
- serve: 'npm start',
17
- build: `cross-env BUILD_PATH=${distPath} nx exec -- craco build`,
18
- test: 'nx exec -- craco test',
19
- };
20
- (0, fileutils_1.writeJsonFile)(packageJsonPath, packageJson);
21
- }
@@ -1,2 +0,0 @@
1
- export declare function addViteCommandsToPackageScripts(appName: string, isStandalone: boolean): void;
2
- //# sourceMappingURL=add-vite-commands-to-package-scripts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"add-vite-commands-to-package-scripts.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.ts"],"names":[],"mappings":"AAEA,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,OAAO,QAgBtB"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addViteCommandsToPackageScripts = addViteCommandsToPackageScripts;
4
- const fileutils_1 = require("../../../../utils/fileutils");
5
- function addViteCommandsToPackageScripts(appName, isStandalone) {
6
- const packageJsonPath = isStandalone
7
- ? 'package.json'
8
- : `apps/${appName}/package.json`;
9
- const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
10
- packageJson.scripts = {
11
- ...packageJson.scripts,
12
- // These should be replaced by the vite init generator later.
13
- start: 'vite',
14
- test: 'vitest',
15
- dev: 'vite',
16
- build: 'vite build',
17
- eject: undefined,
18
- };
19
- (0, fileutils_1.writeJsonFile)(packageJsonPath, packageJson, { spaces: 2 });
20
- }
@@ -1,2 +0,0 @@
1
- export declare function checkForCustomWebpackSetup(): void;
2
- //# sourceMappingURL=check-for-custom-webpack-setup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"check-for-custom-webpack-setup.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/check-for-custom-webpack-setup.ts"],"names":[],"mappings":"AAEA,wBAAgB,0BAA0B,SAczC"}
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkForCustomWebpackSetup = checkForCustomWebpackSetup;
4
- const fileutils_1 = require("../../../../utils/fileutils");
5
- function checkForCustomWebpackSetup() {
6
- const packageJson = (0, fileutils_1.readJsonFile)('package.json');
7
- const combinedDeps = {
8
- ...packageJson.dependencies,
9
- ...packageJson.devDependencies,
10
- };
11
- ['react-app-rewired', '@craco/craco'].forEach((pkg) => {
12
- if (combinedDeps[pkg]) {
13
- console.log(`Skipping migration due to custom webpack setup. Found "${pkg}" usage. Use --force to continue anyway.`);
14
- process.exit(1);
15
- }
16
- });
17
- }
@@ -1,2 +0,0 @@
1
- export declare function checkForUncommittedChanges(): void;
2
- //# sourceMappingURL=check-for-uncommitted-changes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"check-for-uncommitted-changes.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/check-for-uncommitted-changes.ts"],"names":[],"mappings":"AAEA,wBAAgB,0BAA0B,SAiBzC"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkForUncommittedChanges = checkForUncommittedChanges;
4
- const child_process_1 = require("child_process");
5
- function checkForUncommittedChanges() {
6
- const gitResult = (0, child_process_1.execSync)('git status --porcelain', {
7
- windowsHide: false,
8
- }).toString();
9
- const filteredResults = gitResult
10
- .split('\n')
11
- .filter((line) => !line.includes('.nx') && line.trim().length > 0);
12
- if (filteredResults.length > 0) {
13
- console.log('❗️ Careful!');
14
- console.log('You have uncommitted changes in your repository.');
15
- console.log('');
16
- console.log(filteredResults.join('\n').toString());
17
- console.log('Please commit your changes before running the migrator!');
18
- process.exit(1);
19
- }
20
- }
@@ -1,2 +0,0 @@
1
- export declare function cleanUpFiles(appName: string, isStandalone: boolean): void;
2
- //# sourceMappingURL=clean-up-files.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clean-up-files.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/clean-up-files.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,QA6BlE"}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanUpFiles = cleanUpFiles;
4
- const node_fs_1 = require("node:fs");
5
- const fileutils_1 = require("../../../../utils/fileutils");
6
- function cleanUpFiles(appName, isStandalone) {
7
- // Delete targets from project since we delegate to npm scripts.
8
- const projectJsonPath = isStandalone
9
- ? 'project.json'
10
- : `apps/${appName}/project.json`;
11
- const json = (0, fileutils_1.readJsonFile)(projectJsonPath);
12
- delete json.targets;
13
- if (isStandalone) {
14
- if (json.sourceRoot) {
15
- json.sourceRoot = json.sourceRoot.replace(`apps/${appName}/`, '');
16
- }
17
- if (json['$schema']) {
18
- json['$schema'] = json['$schema'].replace('../../node_modules', 'node_modules');
19
- }
20
- }
21
- (0, fileutils_1.writeJsonFile)(projectJsonPath, json);
22
- (0, node_fs_1.rmSync)('temp-workspace', { recursive: true, force: true });
23
- if (isStandalone) {
24
- (0, node_fs_1.rmSync)('babel.config.json', { recursive: true, force: true });
25
- (0, node_fs_1.rmSync)('jest.preset.js', { recursive: true, force: true });
26
- (0, node_fs_1.rmSync)('jest.config.ts', { recursive: true, force: true });
27
- (0, node_fs_1.rmSync)('libs', { recursive: true, force: true });
28
- (0, node_fs_1.rmSync)('tools', { recursive: true, force: true });
29
- }
30
- }
@@ -1,5 +0,0 @@
1
- import { InitArgs } from '../../init-v1';
2
- type Options = InitArgs;
3
- export declare function addNxToCraRepo(_options: Options): Promise<void>;
4
- export {};
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAczC,KAAK,OAAO,GAAG,QAAQ,CAAC;AAUxB,wBAAsB,cAAc,CAAC,QAAQ,EAAE,OAAO,iBA8BrD"}
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addNxToCraRepo = addNxToCraRepo;
4
- const child_process_1 = require("child_process");
5
- const path_1 = require("path");
6
- const fs_1 = require("fs");
7
- const fileutils_1 = require("../../../../utils/fileutils");
8
- const output_1 = require("../../../../utils/output");
9
- const package_manager_1 = require("../../../../utils/package-manager");
10
- const check_for_custom_webpack_setup_1 = require("./check-for-custom-webpack-setup");
11
- const read_name_from_package_json_1 = require("./read-name-from-package-json");
12
- const rename_js_to_jsx_1 = require("./rename-js-to-jsx");
13
- const write_vite_config_1 = require("./write-vite-config");
14
- const write_vite_index_html_1 = require("./write-vite-index-html");
15
- async function addNxToCraRepo(_options) {
16
- if (!_options.force) {
17
- (0, check_for_custom_webpack_setup_1.checkForCustomWebpackSetup)();
18
- }
19
- const options = await normalizeOptions(_options);
20
- await addBundler(options);
21
- (0, fs_1.appendFileSync)(`.gitignore`, '\nnode_modules');
22
- (0, fs_1.appendFileSync)(`.gitignore`, '\ndist');
23
- installDependencies(options);
24
- // Vite expects index.html to be in the root as the main entry point.
25
- const indexPath = options.isStandalone
26
- ? 'index.html'
27
- : (0, path_1.join)('apps', options.reactAppName, 'index.html');
28
- const oldIndexPath = options.isStandalone
29
- ? (0, path_1.join)('public', 'index.html')
30
- : (0, path_1.join)('apps', options.reactAppName, 'public', 'index.html');
31
- output_1.output.note({
32
- title: `A new ${indexPath} has been created. Compare it to the previous ${oldIndexPath} file and make any changes needed, then delete the previous file.`,
33
- });
34
- if (_options.force) {
35
- output_1.output.note({
36
- title: `Using --force converts projects with custom Webpack setup. You will need to manually update your vite.config.js file to match the plugins used in your old Webpack configuration.`,
37
- });
38
- }
39
- }
40
- function installDependencies(options) {
41
- const dependencies = [
42
- '@rollup/plugin-replace',
43
- '@testing-library/jest-dom',
44
- '@vitejs/plugin-react',
45
- 'eslint-config-react-app',
46
- 'web-vitals',
47
- 'jest-watch-typeahead',
48
- 'vite',
49
- 'vitest',
50
- ];
51
- (0, child_process_1.execSync)(`${options.pmc.addDev} ${dependencies.join(' ')}`, {
52
- stdio: [0, 1, 2],
53
- windowsHide: false,
54
- });
55
- }
56
- async function normalizeOptions(options) {
57
- const packageManager = (0, package_manager_1.detectPackageManager)();
58
- const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
59
- const appIsJs = !(0, fileutils_1.fileExists)(`tsconfig.json`);
60
- const reactAppName = (0, read_name_from_package_json_1.readNameFromPackageJson)();
61
- const isStandalone = !options.integrated;
62
- return {
63
- ...options,
64
- packageManager,
65
- pmc,
66
- appIsJs,
67
- reactAppName,
68
- isStandalone,
69
- };
70
- }
71
- async function addBundler(options) {
72
- const { addViteCommandsToPackageScripts } = await Promise.resolve().then(() => require('./add-vite-commands-to-package-scripts'));
73
- addViteCommandsToPackageScripts(options.reactAppName, options.isStandalone);
74
- (0, write_vite_config_1.writeViteConfig)(options.reactAppName, options.isStandalone, options.appIsJs);
75
- (0, write_vite_index_html_1.writeViteIndexHtml)(options.reactAppName, options.isStandalone, options.appIsJs);
76
- await (0, rename_js_to_jsx_1.renameJsToJsx)(options.reactAppName, options.isStandalone);
77
- }
@@ -1,2 +0,0 @@
1
- export declare function readNameFromPackageJson(): string;
2
- //# sourceMappingURL=read-name-from-package-json.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"read-name-from-package-json.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/read-name-from-package-json.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB,IAAI,MAAM,CAahD"}
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readNameFromPackageJson = readNameFromPackageJson;
4
- const fileutils_1 = require("../../../../utils/fileutils");
5
- function readNameFromPackageJson() {
6
- let appName = 'webapp';
7
- if ((0, fileutils_1.fileExists)('package.json')) {
8
- const json = (0, fileutils_1.readJsonFile)('package.json');
9
- if (json['name'] &&
10
- json['name'].length &&
11
- json['name'].replace(/\s/g, '').length) {
12
- appName = json['name'].replace(/\s/g, '');
13
- }
14
- }
15
- return appName;
16
- }
@@ -1,2 +0,0 @@
1
- export declare function renameJsToJsx(appName: string, isStandalone: boolean): Promise<void>;
2
- //# sourceMappingURL=rename-js-to-jsx.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rename-js-to-jsx.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/rename-js-to-jsx.ts"],"names":[],"mappings":"AAKA,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,iBAezE"}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renameJsToJsx = renameJsToJsx;
4
- const node_fs_1 = require("node:fs");
5
- const workspace_context_1 = require("../../../../utils/workspace-context");
6
- const fileutils_1 = require("../../../../utils/fileutils");
7
- // Vite cannot process JSX like <div> or <Header> unless the file is named .jsx or .tsx
8
- async function renameJsToJsx(appName, isStandalone) {
9
- const files = await (0, workspace_context_1.globWithWorkspaceContext)(process.cwd(), [
10
- isStandalone ? 'src/**/*.js' : `apps/${appName}/src/**/*.js`,
11
- ]);
12
- files.forEach((file) => {
13
- if ((0, fileutils_1.fileExists)(file)) {
14
- const content = (0, node_fs_1.readFileSync)(file).toString();
15
- // Try to detect JSX before renaming to .jsx
16
- // Files like setupTests.js from CRA should not be renamed
17
- if (/<[a-zA-Z0-9]+/.test(content)) {
18
- (0, node_fs_1.renameSync)(file, `${file}x`);
19
- }
20
- }
21
- });
22
- }
@@ -1,2 +0,0 @@
1
- export declare function setupTsConfig(appName: string, isStandalone: boolean): void;
2
- //# sourceMappingURL=tsconfig-setup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tsconfig-setup.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/tsconfig-setup.ts"],"names":[],"mappings":"AA+DA,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,QA+CnE"}