nx 23.2.0-beta.7 → 23.2.0-beta.9
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.
- package/dist/bin/init-local.js +3 -5
- package/dist/release/changelog-renderer/index.js +4 -5
- package/dist/src/adapter/ngcli-adapter.js +60 -1
- package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +2 -2
- package/dist/src/command-line/completion/command-object.js +7 -12
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +17 -23
- package/dist/src/command-line/format/format.js +84 -101
- package/dist/src/command-line/generate/generate.js +35 -35
- package/dist/src/command-line/import/import.js +30 -40
- package/dist/src/command-line/init/ai-agent-prompts.js +5 -11
- package/dist/src/command-line/init/command-object.js +4 -2
- package/dist/src/command-line/init/configure-plugins.js +4 -1
- package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +12 -32
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +17 -21
- package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +8 -21
- package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +3 -17
- package/dist/src/command-line/init/implementation/angular/index.js +10 -15
- package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +2 -0
- package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +8 -2
- package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +2 -0
- package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +5 -0
- package/dist/src/command-line/init/implementation/format.d.ts +18 -0
- package/dist/src/command-line/init/implementation/format.js +114 -0
- package/dist/src/command-line/init/implementation/utils.js +8 -0
- package/dist/src/command-line/init/init-v1.js +15 -18
- package/dist/src/command-line/init/init-v2.js +37 -56
- package/dist/src/command-line/migrate/agentic/definitions.js +35 -8
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +22 -3
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +13 -10
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +3 -1
- package/dist/src/command-line/migrate/agentic/handoff.js +4 -2
- package/dist/src/command-line/migrate/agentic/run-step.js +1 -0
- package/dist/src/command-line/migrate/agentic/runner.js +24 -24
- package/dist/src/command-line/migrate/agentic/select.js +20 -30
- package/dist/src/command-line/migrate/agentic/types.d.ts +19 -3
- package/dist/src/command-line/migrate/agentic/types.js +13 -4
- package/dist/src/command-line/migrate/command-object.d.ts +3 -0
- package/dist/src/command-line/migrate/command-object.js +13 -0
- package/dist/src/command-line/migrate/execute-migration.d.ts +14 -0
- package/dist/src/command-line/migrate/execute-migration.js +30 -9
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +28 -0
- package/dist/src/command-line/migrate/migrate-analytics.js +51 -1
- package/dist/src/command-line/migrate/migrate-commits.d.ts +8 -2
- package/dist/src/command-line/migrate/migrate-commits.js +66 -19
- package/dist/src/command-line/migrate/migrate-config.d.ts +4 -2
- package/dist/src/command-line/migrate/migrate-config.js +12 -4
- package/dist/src/command-line/migrate/migrate.d.ts +13 -2
- package/dist/src/command-line/migrate/migrate.js +243 -80
- package/dist/src/command-line/migrate/multi-major.js +7 -10
- package/dist/src/command-line/migrate/resolve-package-version.js +4 -8
- package/dist/src/command-line/migrate/run/agent-output.d.ts +20 -0
- package/dist/src/command-line/migrate/run/agent-output.js +65 -0
- package/dist/src/command-line/migrate/run/index.d.ts +7 -0
- package/dist/src/command-line/migrate/run/index.js +19 -1
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +20 -0
- package/dist/src/command-line/migrate/run/orchestrator.js +1200 -0
- package/dist/src/command-line/migrate/run/run-id.d.ts +16 -0
- package/dist/src/command-line/migrate/run/run-id.js +56 -0
- package/dist/src/command-line/migrate/run/run-state.d.ts +157 -0
- package/dist/src/command-line/migrate/run/run-state.js +438 -0
- package/dist/src/command-line/migrate/run/state-lock.d.ts +25 -0
- package/dist/src/command-line/migrate/run/state-lock.js +76 -0
- package/dist/src/command-line/migrate/run/state-machine.d.ts +84 -0
- package/dist/src/command-line/migrate/run/state-machine.js +315 -0
- package/dist/src/command-line/migrate/run/util.d.ts +58 -0
- package/dist/src/command-line/migrate/run/util.js +139 -7
- package/dist/src/command-line/migrate/run/worker.d.ts +1 -0
- package/dist/src/command-line/migrate/run/worker.js +308 -45
- package/dist/src/command-line/migrate/safe-prompt.d.ts +14 -26
- package/dist/src/command-line/migrate/safe-prompt.js +32 -43
- package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
- package/dist/src/command-line/migrate/step-actions.js +12 -0
- package/dist/src/command-line/migrate/text.d.ts +18 -0
- package/dist/src/command-line/migrate/text.js +26 -0
- package/dist/src/command-line/migrate/version-skew-guard.d.ts +6 -4
- package/dist/src/command-line/migrate/version-skew-guard.js +34 -14
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +16 -20
- package/dist/src/command-line/release/changelog.js +6 -17
- package/dist/src/command-line/release/plan.js +15 -28
- package/dist/src/command-line/release/release.js +6 -17
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +16 -22
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +13 -22
- package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
- package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
- package/dist/src/command-line/release/version.js +2 -2
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/daemon/client/client.js +11 -2
- package/dist/src/devkit-internals.d.ts +7 -2
- package/dist/src/devkit-internals.js +22 -6
- package/dist/src/generators/internal-utils/{format-changed-files-with-prettier-if-available.d.ts → format-changed-files.d.ts} +6 -6
- package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
- package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
- package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
- package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
- package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
- package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
- package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
- package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
- package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
- package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
- package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
- package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
- package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
- package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
- package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
- package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
- package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
- package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
- package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
- package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
- package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
- package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
- package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
- package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +128 -2
- package/dist/src/tasks-runner/run-command.js +17 -32
- package/dist/src/tasks-runner/task-env.js +5 -2
- package/dist/src/tasks-runner/utils.js +2 -6
- package/dist/src/utils/analytics-prompt.js +4 -7
- package/dist/src/utils/chunkify.d.ts +7 -1
- package/dist/src/utils/chunkify.js +10 -3
- package/dist/src/utils/exit-codes.d.ts +9 -0
- package/dist/src/utils/exit-codes.js +19 -0
- package/dist/src/utils/fileutils.d.ts +5 -0
- package/dist/src/utils/fileutils.js +7 -2
- package/dist/src/utils/formatters/index.d.ts +13 -0
- package/dist/src/utils/formatters/index.js +74 -0
- package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
- package/dist/src/utils/formatters/oxfmt.js +764 -0
- package/dist/src/utils/formatters/prettier.d.ts +26 -0
- package/dist/src/utils/formatters/prettier.js +201 -0
- package/dist/src/utils/formatters/shared.d.ts +5 -0
- package/dist/src/utils/formatters/shared.js +8 -0
- package/dist/src/utils/git-utils.d.ts +33 -2
- package/dist/src/utils/git-utils.js +156 -8
- package/dist/src/utils/ignore.d.ts +47 -5
- package/dist/src/utils/ignore.js +93 -11
- package/dist/src/utils/long-running-target.d.ts +10 -0
- package/dist/src/utils/long-running-target.js +19 -0
- package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
- package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
- package/dist/src/utils/min-release-age/packument.js +1 -1
- package/dist/src/utils/nx-console-prompt.js +3 -6
- package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
- package/dist/src/utils/package-manager-config/bunfig.js +49 -0
- package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
- package/dist/src/utils/package-manager-config/npmrc.js +124 -0
- package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
- package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
- package/dist/src/utils/package-manager.d.ts +21 -2
- package/dist/src/utils/package-manager.js +244 -47
- package/dist/src/utils/params.d.ts +7 -1
- package/dist/src/utils/params.js +64 -6
- package/dist/src/utils/prompt-helpers.d.ts +53 -0
- package/dist/src/utils/prompt-helpers.js +111 -0
- package/dist/src/utils/provenance.js +6 -14
- package/dist/src/utils/registry-config/bun.d.ts +2 -0
- package/dist/src/utils/registry-config/bun.js +257 -0
- package/dist/src/utils/registry-config/index.d.ts +13 -0
- package/dist/src/utils/registry-config/index.js +102 -0
- package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
- package/dist/src/utils/registry-config/pnpm.js +1551 -0
- package/dist/src/utils/registry-config/utils.d.ts +195 -0
- package/dist/src/utils/registry-config/utils.js +496 -0
- package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
- package/dist/src/utils/registry-config/yarn-berry.js +612 -0
- package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
- package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
- package/dist/src/utils/safe-spawn.d.ts +24 -0
- package/dist/src/utils/safe-spawn.js +104 -0
- package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
- package/dist/src/utils/write-formatted-json-file.js +5 -4
- package/migrations.json +6 -0
- package/package.json +17 -13
- package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -88
- package/dist/src/utils/is-using-prettier.d.ts +0 -3
- package/dist/src/utils/is-using-prettier.js +0 -62
- package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
- package/dist/src/utils/min-release-age/npmrc.js +0 -45
|
@@ -8,7 +8,7 @@ const pc = tslib_1.__importStar(require("picocolors"));
|
|
|
8
8
|
const git_utils_1 = require("../../utils/git-utils");
|
|
9
9
|
const promises_1 = require("node:fs/promises");
|
|
10
10
|
const tmp_1 = require("tmp");
|
|
11
|
-
const
|
|
11
|
+
const prompt_helpers_1 = require("../../utils/prompt-helpers");
|
|
12
12
|
const output_1 = require("../../utils/output");
|
|
13
13
|
const createSpinner = require('ora');
|
|
14
14
|
const init_v2_1 = require("../init/init-v2");
|
|
@@ -23,10 +23,10 @@ const prepare_source_repo_1 = require("./utils/prepare-source-repo");
|
|
|
23
23
|
const merge_remote_source_1 = require("./utils/merge-remote-source");
|
|
24
24
|
const minimatch_1 = require("minimatch");
|
|
25
25
|
const configure_plugins_1 = require("../init/configure-plugins");
|
|
26
|
+
const format_1 = require("../init/implementation/format");
|
|
26
27
|
const check_compatible_with_plugins_1 = require("../init/implementation/check-compatible-with-plugins");
|
|
27
28
|
const native_1 = require("../../native");
|
|
28
29
|
const ai_output_1 = require("./utils/ai-output");
|
|
29
|
-
const init_v2_2 = require("../init/init-v2");
|
|
30
30
|
const importRemoteName = '__tmp_nx_import__';
|
|
31
31
|
async function importHandler(options) {
|
|
32
32
|
process.env.NX_RUNNING_NX_IMPORT = 'true';
|
|
@@ -77,14 +77,10 @@ async function importHandler(options) {
|
|
|
77
77
|
}
|
|
78
78
|
const tempImportDirectory = (0, path_1.join)(tmp_1.tmpdir, 'nx-import');
|
|
79
79
|
if (!sourceRepository) {
|
|
80
|
-
sourceRepository =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
message: 'What is the URL of the repository you want to import? (This can be a local git repository or a git remote URL)',
|
|
85
|
-
required: true,
|
|
86
|
-
},
|
|
87
|
-
])).sourceRepository;
|
|
80
|
+
sourceRepository = await (0, prompt_helpers_1.textPrompt)({
|
|
81
|
+
message: 'What is the URL of the repository you want to import? (This can be a local git repository or a git remote URL)',
|
|
82
|
+
validate: (value) => (value ? undefined : 'A repository is required'),
|
|
83
|
+
});
|
|
88
84
|
}
|
|
89
85
|
try {
|
|
90
86
|
const maybeLocalDirectory = await (0, promises_1.stat)(sourceRepository);
|
|
@@ -132,19 +128,10 @@ async function importHandler(options) {
|
|
|
132
128
|
throw new Error('The --ref option is required when running in agent mode.');
|
|
133
129
|
}
|
|
134
130
|
const branchChoices = await sourceGitClient.listBranches();
|
|
135
|
-
ref =
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
message: `Which branch do you want to import?`,
|
|
140
|
-
choices: branchChoices,
|
|
141
|
-
/**
|
|
142
|
-
* Limit the number of choices so that it fits on screen
|
|
143
|
-
*/
|
|
144
|
-
limit: process.stdout.rows - 3,
|
|
145
|
-
required: true,
|
|
146
|
-
},
|
|
147
|
-
])).ref;
|
|
131
|
+
ref = await (0, prompt_helpers_1.selectPrompt)({
|
|
132
|
+
message: `Which branch do you want to import?`,
|
|
133
|
+
choices: branchChoices,
|
|
134
|
+
});
|
|
148
135
|
}
|
|
149
136
|
if (!source) {
|
|
150
137
|
if (aiMode) {
|
|
@@ -152,28 +139,20 @@ async function importHandler(options) {
|
|
|
152
139
|
source = '.';
|
|
153
140
|
}
|
|
154
141
|
else {
|
|
155
|
-
source =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
name: 'source',
|
|
159
|
-
message: `Which directory do you want to import into this workspace? (leave blank to import the entire repository)`,
|
|
160
|
-
},
|
|
161
|
-
])).source;
|
|
142
|
+
source = await (0, prompt_helpers_1.textPrompt)({
|
|
143
|
+
message: `Which directory do you want to import into this workspace? (leave blank to import the entire repository)`,
|
|
144
|
+
});
|
|
162
145
|
}
|
|
163
146
|
}
|
|
164
147
|
if (!destination) {
|
|
165
148
|
if (aiMode) {
|
|
166
149
|
throw new Error('The --destination option is required when running in agent mode.');
|
|
167
150
|
}
|
|
168
|
-
destination =
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
required: true,
|
|
174
|
-
initial: source ? source : undefined,
|
|
175
|
-
},
|
|
176
|
-
])).destination;
|
|
151
|
+
destination = await (0, prompt_helpers_1.textPrompt)({
|
|
152
|
+
message: 'Where in this workspace should the code be imported into?',
|
|
153
|
+
initialValue: source ? source : undefined,
|
|
154
|
+
validate: (value) => (value ? undefined : 'A destination is required'),
|
|
155
|
+
});
|
|
177
156
|
}
|
|
178
157
|
const absSource = (0, path_1.join)(sourceTempRepoPath, source);
|
|
179
158
|
if ((0, path_1.isAbsolute)(destination)) {
|
|
@@ -282,6 +261,7 @@ async function importHandler(options) {
|
|
|
282
261
|
const incompatiblePlugins = await (0, check_compatible_with_plugins_1.checkCompatibleWithPlugins)();
|
|
283
262
|
if (Object.keys(incompatiblePlugins).length > 0) {
|
|
284
263
|
(0, check_compatible_with_plugins_1.updatePluginsInNxJson)(workspace_root_1.workspaceRoot, incompatiblePlugins);
|
|
264
|
+
await (0, format_1.formatInitWrites)(workspace_root_1.workspaceRoot, 'nx import');
|
|
285
265
|
await destinationGitClient.amendCommit();
|
|
286
266
|
}
|
|
287
267
|
}
|
|
@@ -290,6 +270,7 @@ async function importHandler(options) {
|
|
|
290
270
|
if (installed) {
|
|
291
271
|
const { succeededPlugins } = await (0, configure_plugins_1.configurePlugins)(plugins, updatePackageScripts, pmc, workspace_root_1.workspaceRoot, verbose);
|
|
292
272
|
if (succeededPlugins.length > 0) {
|
|
273
|
+
await (0, format_1.formatInitWrites)(workspace_root_1.workspaceRoot, 'nx import');
|
|
293
274
|
await destinationGitClient.amendCommit();
|
|
294
275
|
}
|
|
295
276
|
}
|
|
@@ -361,7 +342,7 @@ async function importHandler(options) {
|
|
|
361
342
|
(0, ai_output_1.writeAiOutput)((0, ai_output_1.buildImportNeedsPluginSelectionResult)({
|
|
362
343
|
detectedPlugins: detectedButNotInstalled.map((name) => ({
|
|
363
344
|
name,
|
|
364
|
-
reason: (0,
|
|
345
|
+
reason: (0, init_v2_1.getPluginReason)(name),
|
|
365
346
|
})),
|
|
366
347
|
sourceRepository,
|
|
367
348
|
ref,
|
|
@@ -456,6 +437,7 @@ async function handlePluginOnlyMode(options, destinationGitClient, verbose) {
|
|
|
456
437
|
if (installed) {
|
|
457
438
|
const { succeededPlugins } = await (0, configure_plugins_1.configurePlugins)(plugins, updatePackageScripts, pmc, workspace_root_1.workspaceRoot, verbose);
|
|
458
439
|
if (succeededPlugins.length > 0) {
|
|
440
|
+
await (0, format_1.formatInitWrites)(workspace_root_1.workspaceRoot, 'nx import');
|
|
459
441
|
await destinationGitClient.amendCommit();
|
|
460
442
|
}
|
|
461
443
|
}
|
|
@@ -490,6 +472,7 @@ async function runInstallDestinationRepo(packageManager, destinationGitClient) {
|
|
|
490
472
|
title: 'Installing dependencies for imported code',
|
|
491
473
|
});
|
|
492
474
|
(0, utils_1.runInstall)(workspace_root_1.workspaceRoot, packageManager, (0, package_manager_1.getPackageManagerCommand)(packageManager));
|
|
475
|
+
await (0, format_1.formatInitWrites)(workspace_root_1.workspaceRoot, 'nx import');
|
|
493
476
|
await destinationGitClient.amendCommit();
|
|
494
477
|
}
|
|
495
478
|
catch (e) {
|
|
@@ -506,6 +489,7 @@ async function runPluginsInstall(plugins, pmc, destinationGitClient) {
|
|
|
506
489
|
output_1.output.log({ title: 'Installing Plugins' });
|
|
507
490
|
try {
|
|
508
491
|
(0, configure_plugins_1.installPluginPackages)(workspace_root_1.workspaceRoot, pmc, plugins);
|
|
492
|
+
await (0, format_1.formatInitWrites)(workspace_root_1.workspaceRoot, 'nx import');
|
|
509
493
|
await destinationGitClient.amendCommit();
|
|
510
494
|
}
|
|
511
495
|
catch (e) {
|
|
@@ -583,6 +567,12 @@ async function handleMissingWorkspacesEntry(pm, pmc, pkgPath, destinationGitClie
|
|
|
583
567
|
return;
|
|
584
568
|
}
|
|
585
569
|
(0, package_manager_1.addPackagePathToWorkspaces)(pkgPath, pm, workspaces, workspace_root_1.workspaceRoot);
|
|
570
|
+
// That helper is shared, so it does not record for us - without this the
|
|
571
|
+
// drain below has nothing to do and the rewritten file ships unformatted.
|
|
572
|
+
// It writes pnpm-workspace.yaml for pnpm and package.json for the rest, so
|
|
573
|
+
// recording package.json unconditionally records a file it never touched.
|
|
574
|
+
(0, format_1.recordInitWrite)((0, path_1.join)(workspace_root_1.workspaceRoot, pm === 'pnpm' ? 'pnpm-workspace.yaml' : 'package.json'));
|
|
575
|
+
await (0, format_1.formatInitWrites)(workspace_root_1.workspaceRoot, 'nx import');
|
|
586
576
|
await destinationGitClient.amendCommit();
|
|
587
577
|
output_1.output.success({
|
|
588
578
|
title: `Project added in workspaces`,
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.determineAiAgents = determineAiAgents;
|
|
4
|
-
const
|
|
5
|
-
const enquirer_1 = require("enquirer");
|
|
4
|
+
const prompt_helpers_1 = require("../../utils/prompt-helpers");
|
|
6
5
|
const is_ci_1 = require("../../utils/is-ci");
|
|
7
6
|
const utils_1 = require("../../ai/utils");
|
|
8
7
|
const detect_ai_agent_1 = require("../../ai/detect-ai-agent");
|
|
9
|
-
const pc = tslib_1.__importStar(require("picocolors"));
|
|
10
8
|
async function determineAiAgents(aiAgents, interactive) {
|
|
11
9
|
if (aiAgents) {
|
|
12
10
|
const filtered = aiAgents.filter((a) => a !== 'none');
|
|
@@ -22,15 +20,11 @@ async function determineAiAgents(aiAgents, interactive) {
|
|
|
22
20
|
return await aiAgentsPrompt();
|
|
23
21
|
}
|
|
24
22
|
async function aiAgentsPrompt() {
|
|
25
|
-
|
|
26
|
-
name: 'agents',
|
|
23
|
+
return (0, prompt_helpers_1.multiselectPrompt)({
|
|
27
24
|
message: 'Which AI agents, if any, would you like to set up?',
|
|
28
|
-
type: 'multiselect',
|
|
29
25
|
choices: utils_1.supportedAgents.map((a) => ({
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
value: a,
|
|
27
|
+
label: utils_1.agentDisplayMap[a],
|
|
32
28
|
})),
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
return (await (0, enquirer_1.prompt)([promptConfig])).agents;
|
|
29
|
+
});
|
|
36
30
|
}
|
|
@@ -17,8 +17,10 @@ exports.yargsInitCommand = {
|
|
|
17
17
|
return withInitOptions(yargs);
|
|
18
18
|
},
|
|
19
19
|
handler: async (args) => {
|
|
20
|
-
// Node 24
|
|
21
|
-
//
|
|
20
|
+
// Node 24's stricter readline throws ERR_USE_AFTER_CLOSE when a prompt
|
|
21
|
+
// library operates on a closed interface. Added for enquirer, which nx no
|
|
22
|
+
// longer uses; verify against Node 24 before removing.
|
|
23
|
+
// TODO(v24): drop if @clack/prompts proves not to need it.
|
|
22
24
|
process.on('uncaughtException', (error) => {
|
|
23
25
|
if (error &&
|
|
24
26
|
typeof error === 'object' &&
|
|
@@ -19,6 +19,7 @@ const configuration_1 = require("../../config/configuration");
|
|
|
19
19
|
const versions_1 = require("../../utils/versions");
|
|
20
20
|
const child_process_1 = require("../../utils/child-process");
|
|
21
21
|
const fileutils_1 = require("../../utils/fileutils");
|
|
22
|
+
const format_1 = require("./implementation/format");
|
|
22
23
|
const spinner_1 = require("../../utils/spinner");
|
|
23
24
|
function installPluginPackages(repoRoot, pmc = (0, package_manager_1.getPackageManagerCommand)(), plugins) {
|
|
24
25
|
if (plugins.length === 0) {
|
|
@@ -35,7 +36,9 @@ function installPluginPackages(repoRoot, pmc = (0, package_manager_1.getPackageM
|
|
|
35
36
|
for (const plugin of plugins) {
|
|
36
37
|
nxJson.installation.plugins[plugin] = versions_1.nxVersion;
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
const nxJsonPath = (0, path_1.join)(repoRoot, 'nx.json');
|
|
40
|
+
(0, fileutils_1.writeJsonFile)(nxJsonPath, nxJson);
|
|
41
|
+
(0, format_1.recordInitWrite)(nxJsonPath);
|
|
39
42
|
try {
|
|
40
43
|
(0, child_process_1.runNxSync)('--version', { stdio: 'pipe' });
|
|
41
44
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addNxToMonorepo = addNxToMonorepo;
|
|
4
|
-
const
|
|
4
|
+
const prompt_helpers_1 = require("../../../utils/prompt-helpers");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const ignore = require("ignore");
|
|
7
7
|
const path_1 = require("path");
|
|
@@ -23,38 +23,18 @@ async function addNxToMonorepo(options, guided = true) {
|
|
|
23
23
|
output_1.output.log({
|
|
24
24
|
title: '🧑🔧 Please answer the following questions about the scripts found in your workspace in order to generate task runner configuration',
|
|
25
25
|
});
|
|
26
|
-
targetDefaults =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*/
|
|
35
|
-
limit: process.stdout.rows - 4, // 4 leaves room for the header above, the prompt and some whitespace
|
|
36
|
-
},
|
|
37
|
-
])).targetDefaults;
|
|
38
|
-
cacheableOperations = (await (0, enquirer_1.prompt)([
|
|
39
|
-
{
|
|
40
|
-
type: 'multiselect',
|
|
41
|
-
name: 'cacheableOperations',
|
|
42
|
-
message: 'Which scripts are cacheable? (Produce the same output given the same input, e.g. build, test and lint usually are, serve and start are not)',
|
|
43
|
-
choices: scripts,
|
|
44
|
-
/**
|
|
45
|
-
* limit is missing from the interface but it limits the amount of options shown
|
|
46
|
-
*/
|
|
47
|
-
limit: process.stdout.rows - 4, // 4 leaves room for the header above, the prompt and some whitespace
|
|
48
|
-
},
|
|
49
|
-
])).cacheableOperations;
|
|
26
|
+
targetDefaults = await (0, prompt_helpers_1.multiselectPrompt)({
|
|
27
|
+
message: 'Which scripts need to be run in order? (e.g. before building a project, dependent projects must be built)',
|
|
28
|
+
choices: scripts,
|
|
29
|
+
});
|
|
30
|
+
cacheableOperations = await (0, prompt_helpers_1.multiselectPrompt)({
|
|
31
|
+
message: 'Which scripts are cacheable? (Produce the same output given the same input, e.g. build, test and lint usually are, serve and start are not)',
|
|
32
|
+
choices: scripts,
|
|
33
|
+
});
|
|
50
34
|
for (const scriptName of cacheableOperations) {
|
|
51
|
-
scriptOutputs[scriptName] =
|
|
52
|
-
{
|
|
53
|
-
|
|
54
|
-
name: scriptName,
|
|
55
|
-
message: `Does the "${scriptName}" script create any outputs? If not, leave blank, otherwise provide a path relative to a project root (e.g. dist, lib, build, coverage)`,
|
|
56
|
-
},
|
|
57
|
-
]))[scriptName];
|
|
35
|
+
scriptOutputs[scriptName] = await (0, prompt_helpers_1.textPrompt)({
|
|
36
|
+
message: `Does the "${scriptName}" script create any outputs? If not, leave blank, otherwise provide a path relative to a project root (e.g. dist, lib, build, coverage)`,
|
|
37
|
+
});
|
|
58
38
|
}
|
|
59
39
|
nxCloudChoice =
|
|
60
40
|
options.nxCloud === true
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addNxToNest = addNxToNest;
|
|
4
|
-
const
|
|
5
|
-
const enquirer = tslib_1.__importStar(require("enquirer"));
|
|
4
|
+
const prompt_helpers_1 = require("../../../utils/prompt-helpers");
|
|
6
5
|
const node_fs_1 = require("node:fs");
|
|
7
6
|
const path_1 = require("path");
|
|
7
|
+
const format_1 = require("./format");
|
|
8
8
|
const fileutils_1 = require("../../../utils/fileutils");
|
|
9
9
|
const output_1 = require("../../../utils/output");
|
|
10
10
|
const package_manager_1 = require("../../../utils/package-manager");
|
|
@@ -46,26 +46,14 @@ async function addNxToNest(options, packageJson) {
|
|
|
46
46
|
output_1.output.log({
|
|
47
47
|
title: '🧑🔧 Please answer the following questions about the scripts found in your package.json in order to generate task runner configuration',
|
|
48
48
|
});
|
|
49
|
-
cacheableOperations =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
message: 'Which of the following scripts are cacheable? (Produce the same output given the same input, e.g. build, test and lint usually are, serve and start are not)',
|
|
54
|
-
choices: scripts,
|
|
55
|
-
/**
|
|
56
|
-
* limit is missing from the interface but it limits the amount of options shown
|
|
57
|
-
*/
|
|
58
|
-
limit: process.stdout.rows - 4, // 4 leaves room for the header above, the prompt and some whitespace
|
|
59
|
-
},
|
|
60
|
-
])).cacheableOperations;
|
|
49
|
+
cacheableOperations = await (0, prompt_helpers_1.multiselectPrompt)({
|
|
50
|
+
message: 'Which of the following scripts are cacheable? (Produce the same output given the same input, e.g. build, test and lint usually are, serve and start are not)',
|
|
51
|
+
choices: scripts,
|
|
52
|
+
});
|
|
61
53
|
for (const scriptName of cacheableOperations) {
|
|
62
|
-
scriptOutputs[scriptName] =
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
name: scriptName,
|
|
66
|
-
message: `Does the "${scriptName}" script create any outputs? If not, leave blank, otherwise provide a path (e.g. dist, lib, build, coverage)`,
|
|
67
|
-
},
|
|
68
|
-
]))[scriptName];
|
|
54
|
+
scriptOutputs[scriptName] = await (0, prompt_helpers_1.textPrompt)({
|
|
55
|
+
message: `Does the "${scriptName}" script create any outputs? If not, leave blank, otherwise provide a path (e.g. dist, lib, build, coverage)`,
|
|
56
|
+
});
|
|
69
57
|
}
|
|
70
58
|
nxCloudChoice =
|
|
71
59
|
options.nxCloud === true
|
|
@@ -114,6 +102,7 @@ function addNestPluginToPackageJson(repoRoot) {
|
|
|
114
102
|
json.devDependencies['@nx/nest'] = versions_1.nxVersion;
|
|
115
103
|
json.devDependencies['@nx/jest'] = versions_1.nxVersion;
|
|
116
104
|
(0, fileutils_1.writeJsonFile)(path, json);
|
|
105
|
+
(0, format_1.recordInitWrite)(path);
|
|
117
106
|
}
|
|
118
107
|
function createProjectJson(repoRoot, packageJson, nestCLIOptions) {
|
|
119
108
|
const packageName = packageJson.name;
|
|
@@ -194,6 +183,7 @@ function createProjectJson(repoRoot, packageJson, nestCLIOptions) {
|
|
|
194
183
|
addJestTargets(repoRoot, packageName, json, packageJson);
|
|
195
184
|
}
|
|
196
185
|
(0, fileutils_1.writeJsonFile)(path, json);
|
|
186
|
+
(0, format_1.recordInitWrite)(path);
|
|
197
187
|
}
|
|
198
188
|
function getJestOptions(isE2E, repoRoot, packageName, existingOptions) {
|
|
199
189
|
// try get the e2e json if we find it
|
|
@@ -230,6 +220,7 @@ function tryCreateJestPreset(repoRoot) {
|
|
|
230
220
|
const nxPreset = require('@nx/jest/preset').default;
|
|
231
221
|
module.exports = {...nxPreset};
|
|
232
222
|
`, 'utf8');
|
|
223
|
+
(0, format_1.recordInitWrite)(jestPresetPath);
|
|
233
224
|
return true;
|
|
234
225
|
}
|
|
235
226
|
return false;
|
|
@@ -244,7 +235,9 @@ function addJestTargets(repoRoot, packageName, projectJson, packageJson) {
|
|
|
244
235
|
unitTestOptions['preset'] = e2eTestOptions['preset'] = './jest.preset.js';
|
|
245
236
|
}
|
|
246
237
|
(0, node_fs_1.writeFileSync)(unitTestConfigPath, `export default ${JSON.stringify(unitTestOptions, null, 2)}`, 'utf8');
|
|
238
|
+
(0, format_1.recordInitWrite)(unitTestConfigPath);
|
|
247
239
|
(0, node_fs_1.writeFileSync)(e2eTestConfigPath, `export default ${JSON.stringify(e2eTestOptions, null, 2)}`, 'utf8');
|
|
240
|
+
(0, format_1.recordInitWrite)(e2eTestConfigPath);
|
|
248
241
|
projectJson.targets['test'] = {
|
|
249
242
|
executor: '@nx/jest:jest',
|
|
250
243
|
outputs: [`{workspaceRoot}/coverage/${packageName}`],
|
|
@@ -274,6 +267,7 @@ function addNrwlJsPluginsConfig(repoRoot) {
|
|
|
274
267
|
};
|
|
275
268
|
}
|
|
276
269
|
(0, fileutils_1.writeJsonFile)(path, json);
|
|
270
|
+
(0, format_1.recordInitWrite)(path);
|
|
277
271
|
}
|
|
278
272
|
function updatePackageJsonScripts(repoRoot, isJS) {
|
|
279
273
|
const path = (0, path_1.join)(repoRoot, `package.json`);
|
|
@@ -310,6 +304,7 @@ function updatePackageJsonScripts(repoRoot, isJS) {
|
|
|
310
304
|
}
|
|
311
305
|
}
|
|
312
306
|
(0, fileutils_1.writeJsonFile)(path, json);
|
|
307
|
+
(0, format_1.recordInitWrite)(path);
|
|
313
308
|
}
|
|
314
309
|
function updateTsConfig(repoRoot, sourceRoot) {
|
|
315
310
|
const path = (0, path_1.join)(repoRoot, `tsconfig.build.json`);
|
|
@@ -321,6 +316,7 @@ function updateTsConfig(repoRoot, sourceRoot) {
|
|
|
321
316
|
json.include = [];
|
|
322
317
|
json.include.push(`${sourceRoot}/**/*.ts`);
|
|
323
318
|
(0, fileutils_1.writeJsonFile)(path, json);
|
|
319
|
+
(0, format_1.recordInitWrite)(path);
|
|
324
320
|
}
|
|
325
321
|
function removeFile(repoRoot, file) {
|
|
326
322
|
const path = (0, path_1.join)(repoRoot, file);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addNxToNpmRepo = addNxToNpmRepo;
|
|
4
|
-
const
|
|
5
|
-
const enquirer = tslib_1.__importStar(require("enquirer"));
|
|
4
|
+
const prompt_helpers_1 = require("../../../utils/prompt-helpers");
|
|
6
5
|
const path_1 = require("path");
|
|
7
6
|
const fileutils_1 = require("../../../utils/fileutils");
|
|
8
7
|
const output_1 = require("../../../utils/output");
|
|
@@ -21,26 +20,14 @@ async function addNxToNpmRepo(options, guided = true) {
|
|
|
21
20
|
output_1.output.log({
|
|
22
21
|
title: '🧑🔧 Please answer the following questions about the scripts found in your package.json in order to generate task runner configuration',
|
|
23
22
|
});
|
|
24
|
-
cacheableOperations =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
message: 'Which of the following scripts are cacheable? (Produce the same output given the same input, e.g. build, test and lint usually are, serve and start are not). You can use spacebar to select one or more scripts.',
|
|
29
|
-
choices: scripts,
|
|
30
|
-
/**
|
|
31
|
-
* limit is missing from the interface but it limits the amount of options shown
|
|
32
|
-
*/
|
|
33
|
-
limit: process.stdout.rows - 4, // 4 leaves room for the header above, the prompt and some whitespace
|
|
34
|
-
},
|
|
35
|
-
])).cacheableOperations;
|
|
23
|
+
cacheableOperations = await (0, prompt_helpers_1.multiselectPrompt)({
|
|
24
|
+
message: 'Which of the following scripts are cacheable? (Produce the same output given the same input, e.g. build, test and lint usually are, serve and start are not). You can use spacebar to select one or more scripts.',
|
|
25
|
+
choices: scripts,
|
|
26
|
+
});
|
|
36
27
|
for (const scriptName of cacheableOperations) {
|
|
37
|
-
scriptOutputs[scriptName] =
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
name: scriptName,
|
|
41
|
-
message: `Does the "${scriptName}" script create any outputs? If not, leave blank, otherwise provide a path (e.g. dist, lib, build, coverage)`,
|
|
42
|
-
},
|
|
43
|
-
]))[scriptName];
|
|
28
|
+
scriptOutputs[scriptName] = await (0, prompt_helpers_1.textPrompt)({
|
|
29
|
+
message: `Does the "${scriptName}" script create any outputs? If not, leave blank, otherwise provide a path (e.g. dist, lib, build, coverage)`,
|
|
30
|
+
});
|
|
44
31
|
}
|
|
45
32
|
nxCloudChoice =
|
|
46
33
|
options.nxCloud === true
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addNxToTurborepo = addNxToTurborepo;
|
|
4
|
-
const node_fs_1 = require("node:fs");
|
|
5
4
|
const node_path_1 = require("node:path");
|
|
6
5
|
const fileutils_1 = require("../../../utils/fileutils");
|
|
7
|
-
const handle_import_1 = require("../../../utils/handle-import");
|
|
8
6
|
const output_1 = require("../../../utils/output");
|
|
9
7
|
const package_manager_1 = require("../../../utils/package-manager");
|
|
8
|
+
const format_1 = require("./format");
|
|
10
9
|
const utils_1 = require("./utils");
|
|
11
10
|
async function addNxToTurborepo(_options) {
|
|
12
11
|
const repoRoot = process.cwd();
|
|
@@ -27,21 +26,8 @@ async function addNxToTurborepo(_options) {
|
|
|
27
26
|
});
|
|
28
27
|
let nxJson = (0, utils_1.createNxJsonFromTurboJson)((0, fileutils_1.readJsonFile)('turbo.json'));
|
|
29
28
|
const nxJsonPath = (0, node_path_1.join)(repoRoot, 'nx.json');
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const prettier = await (0, handle_import_1.handleImport)('prettier');
|
|
33
|
-
const config = await prettier.resolveConfig(repoRoot);
|
|
34
|
-
(0, node_fs_1.writeFileSync)(nxJsonPath,
|
|
35
|
-
// @ts-ignore - Always await prettier.format, in modern versions it's async
|
|
36
|
-
await prettier.format(JSON.stringify(nxJson, null, 2), {
|
|
37
|
-
...(config ?? {}),
|
|
38
|
-
parser: 'json',
|
|
39
|
-
}));
|
|
40
|
-
}
|
|
41
|
-
catch (err) {
|
|
42
|
-
// Apply fallback JSON write
|
|
43
|
-
(0, fileutils_1.writeJsonFile)(nxJsonPath, nxJson);
|
|
44
|
-
}
|
|
29
|
+
(0, fileutils_1.writeJsonFile)(nxJsonPath, nxJson);
|
|
30
|
+
(0, format_1.recordInitWrite)(nxJsonPath);
|
|
45
31
|
const packageManager = (0, package_manager_1.detectPackageManager)(repoRoot);
|
|
46
32
|
const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
|
47
33
|
(0, utils_1.updateGitIgnore)(repoRoot);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addNxToAngularCliRepo = addNxToAngularCliRepo;
|
|
4
|
-
const
|
|
4
|
+
const prompt_helpers_1 = require("../../../../utils/prompt-helpers");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const fileutils_1 = require("../../../../utils/fileutils");
|
|
7
7
|
const versions_1 = require("../../../../utils/versions");
|
|
@@ -14,6 +14,7 @@ const integrated_workspace_1 = require("./integrated-workspace");
|
|
|
14
14
|
const legacy_angular_versions_1 = require("./legacy-angular-versions");
|
|
15
15
|
const standalone_workspace_1 = require("./standalone-workspace");
|
|
16
16
|
const connect_to_nx_cloud_1 = require("../../../nx-cloud/connect/connect-to-nx-cloud");
|
|
17
|
+
const format_1 = require("../format");
|
|
17
18
|
const defaultCacheableOperations = [
|
|
18
19
|
'build',
|
|
19
20
|
'server',
|
|
@@ -29,6 +30,8 @@ async function addNxToAngularCliRepo(options) {
|
|
|
29
30
|
if (legacyMigrationFn) {
|
|
30
31
|
output_1.output.log({ title: '💽 Running migration for a legacy Angular version' });
|
|
31
32
|
await legacyMigrationFn();
|
|
33
|
+
// The exit skips the caller's drain, so format the recorded writes here.
|
|
34
|
+
await (0, format_1.formatInitWrites)(repoRoot);
|
|
32
35
|
process.exit(0);
|
|
33
36
|
}
|
|
34
37
|
output_1.output.success({
|
|
@@ -65,20 +68,11 @@ async function collectCacheableOperations(options) {
|
|
|
65
68
|
output_1.output.log({
|
|
66
69
|
title: '🧑🔧 Please answer the following questions about the targets found in your angular.json in order to generate task runner configuration',
|
|
67
70
|
});
|
|
68
|
-
cacheableOperations =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
message: 'Which of the following targets are cacheable? (Produce the same output given the same input, e.g. build, test and lint usually are, serve and start are not)',
|
|
74
|
-
// enquirer mutates the array below, create a new one to avoid it
|
|
75
|
-
choices: [...workspaceTargets],
|
|
76
|
-
/**
|
|
77
|
-
* limit is missing from the interface but it limits the amount of options shown
|
|
78
|
-
*/
|
|
79
|
-
limit: process.stdout.rows - 4, // 4 leaves room for the header above, the prompt and some whitespace
|
|
80
|
-
},
|
|
81
|
-
])).cacheableOperations;
|
|
71
|
+
cacheableOperations = await (0, prompt_helpers_1.multiselectPrompt)({
|
|
72
|
+
message: 'Which of the following targets are cacheable? (Produce the same output given the same input, e.g. build, test and lint usually are, serve and start are not)',
|
|
73
|
+
choices: workspaceTargets,
|
|
74
|
+
initialValues: defaultCacheableTargetsInWorkspace,
|
|
75
|
+
});
|
|
82
76
|
}
|
|
83
77
|
else {
|
|
84
78
|
cacheableOperations =
|
|
@@ -113,6 +107,7 @@ function addPluginDependencies() {
|
|
|
113
107
|
}
|
|
114
108
|
packageJson.devDependencies = (0, object_sort_1.sortObjectByKeys)(packageJson.devDependencies);
|
|
115
109
|
(0, fileutils_1.writeJsonFile)(packageJsonPath, packageJson);
|
|
110
|
+
(0, format_1.recordInitWrite)(packageJsonPath);
|
|
116
111
|
}
|
|
117
112
|
async function setupWorkspace(cacheableOperations, isIntegratedMigration) {
|
|
118
113
|
(0, utils_1.updateGitIgnore)(repoRoot);
|
|
@@ -12,6 +12,7 @@ const package_json_1 = require("../../../../utils/package-json");
|
|
|
12
12
|
const package_manager_1 = require("../../../../utils/package-manager");
|
|
13
13
|
const connect_to_nx_cloud_1 = require("../../../nx-cloud/connect/connect-to-nx-cloud");
|
|
14
14
|
const utils_1 = require("../utils");
|
|
15
|
+
const format_1 = require("../format");
|
|
15
16
|
// map of Angular major versions to Nx versions to use for legacy `nx init` migrations,
|
|
16
17
|
// key is major Angular version and value is Nx version to use
|
|
17
18
|
const nxAngularLegacyVersionMap = {
|
|
@@ -141,6 +142,7 @@ async function installDependencies(repoRoot, pkgInfo, pmc) {
|
|
|
141
142
|
json.dependencies = (0, object_sort_1.sortObjectByKeys)(json.dependencies);
|
|
142
143
|
}
|
|
143
144
|
(0, fileutils_1.writeJsonFile)(`package.json`, json);
|
|
145
|
+
(0, format_1.recordInitWrite)('package.json');
|
|
144
146
|
(0, child_process_1.execSync)(pmc.install, { stdio: [0, 1, 2], windowsHide: true });
|
|
145
147
|
}
|
|
146
148
|
async function resolvePackageVersion(packageName, version) {
|
|
@@ -7,6 +7,7 @@ const angular_json_1 = require("../../../../adapter/angular-json");
|
|
|
7
7
|
const fileutils_1 = require("../../../../utils/fileutils");
|
|
8
8
|
const path_1 = require("../../../../utils/path");
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
|
+
const format_1 = require("../format");
|
|
10
11
|
async function setupStandaloneWorkspace(repoRoot, cacheableOperations, workspaceTargets) {
|
|
11
12
|
const angularJsonPath = (0, node_path_1.join)(repoRoot, 'angular.json');
|
|
12
13
|
const angularJson = (0, fileutils_1.readJsonFile)(angularJsonPath);
|
|
@@ -25,12 +26,14 @@ async function setupStandaloneWorkspace(repoRoot, cacheableOperations, workspace
|
|
|
25
26
|
const projects = (0, angular_json_1.toNewFormat)(angularJson).projects;
|
|
26
27
|
for (const [projectName, project] of Object.entries(projects ?? {})) {
|
|
27
28
|
updateProjectOutputs(repoRoot, projectName, project, cacheableOperations);
|
|
28
|
-
|
|
29
|
+
const projectJsonPath = (0, node_path_1.join)(project.root, 'project.json');
|
|
30
|
+
(0, fileutils_1.writeJsonFile)(projectJsonPath, {
|
|
29
31
|
$schema: (0, path_1.normalizePath)((0, node_path_1.relative)((0, node_path_1.join)(repoRoot, project.root), (0, node_path_1.join)(repoRoot, 'node_modules/nx/schemas/project-schema.json'))),
|
|
30
32
|
name: projectName,
|
|
31
33
|
...project,
|
|
32
34
|
root: undefined,
|
|
33
35
|
});
|
|
36
|
+
(0, format_1.recordInitWrite)(projectJsonPath);
|
|
34
37
|
}
|
|
35
38
|
(0, fs_1.unlinkSync)(angularJsonPath);
|
|
36
39
|
}
|
|
@@ -91,7 +94,9 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
|
|
|
91
94
|
if (Object.keys(defaults).length > 0) {
|
|
92
95
|
nxJson.targetDefaults = defaults;
|
|
93
96
|
}
|
|
94
|
-
|
|
97
|
+
const nxJsonPath = (0, node_path_1.join)(repoRoot, 'nx.json');
|
|
98
|
+
(0, fileutils_1.writeJsonFile)(nxJsonPath, nxJson);
|
|
99
|
+
(0, format_1.recordInitWrite)(nxJsonPath);
|
|
95
100
|
}
|
|
96
101
|
function updateProjectOutputs(repoRoot, projectName, project, cacheableOperations) {
|
|
97
102
|
Object.entries(project.targets ?? {}).forEach(([targetName, target]) => {
|
|
@@ -195,4 +200,5 @@ function replaceNgWithNxInPackageJsonScripts(repoRoot) {
|
|
|
195
200
|
.replace(/ ng /g, ' nx ');
|
|
196
201
|
});
|
|
197
202
|
(0, fileutils_1.writeJsonFile)(packageJsonPath, packageJson);
|
|
203
|
+
(0, format_1.recordInitWrite)(packageJsonPath);
|
|
198
204
|
}
|
|
@@ -8,6 +8,7 @@ const picocolors_1 = require("picocolors");
|
|
|
8
8
|
const error_types_1 = require("../../../project-graph/error-types");
|
|
9
9
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
10
10
|
const fileutils_1 = require("../../../utils/fileutils");
|
|
11
|
+
const format_1 = require("./format");
|
|
11
12
|
const output_1 = require("../../../utils/output");
|
|
12
13
|
const project_graph_1 = require("../../../project-graph/project-graph");
|
|
13
14
|
/**
|
|
@@ -131,4 +132,5 @@ function updatePluginsInNxJson(root = workspace_root_1.workspaceRoot, pluginToEx
|
|
|
131
132
|
nxJson.plugins[pluginIndex] = plugin;
|
|
132
133
|
});
|
|
133
134
|
(0, fileutils_1.writeJsonFile)(nxJsonPath, nxJson);
|
|
135
|
+
(0, format_1.recordInitWrite)(nxJsonPath);
|
|
134
136
|
}
|
|
@@ -12,6 +12,7 @@ exports.getBatchScriptContents = getBatchScriptContents;
|
|
|
12
12
|
exports.sanitizeWrapperScript = sanitizeWrapperScript;
|
|
13
13
|
const tslib_1 = require("tslib");
|
|
14
14
|
const child_process_1 = require("child_process");
|
|
15
|
+
const format_1 = require("../format");
|
|
15
16
|
const fs_1 = require("fs");
|
|
16
17
|
const path = tslib_1.__importStar(require("path"));
|
|
17
18
|
const semver_1 = require("semver");
|
|
@@ -101,6 +102,10 @@ function writeMinimalNxJson(host, version) {
|
|
|
101
102
|
version: normalizeVersionForNxJson('nx', version),
|
|
102
103
|
},
|
|
103
104
|
});
|
|
105
|
+
(0, format_1.recordInitWrite)('nx.json');
|
|
106
|
+
// Only this file. The wrapper scripts written by `generateDotNxSetup`
|
|
107
|
+
// above (`.nx/nxw.js`, `nx`, `nx.bat`) are deliberately left out: they are
|
|
108
|
+
// vendored artifacts, and two of them have no formatter at all.
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
111
|
function updateGitIgnore(host) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Records a file for `formatInitWrites`. Only for files a formatter handles -
|
|
3
|
+
* `.gitignore` and the vendored `.nx` scripts are left out rather than
|
|
4
|
+
* filtered later.
|
|
5
|
+
*
|
|
6
|
+
* Two recording helpers are shared with `nx import`, which drains before each
|
|
7
|
+
* commit amend; draining after one would leave the formatting uncommitted.
|
|
8
|
+
* The drain is a no-op when empty.
|
|
9
|
+
*/
|
|
10
|
+
export declare function recordInitWrite(filePath: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Formats what init just wrote and nothing else: an existing repo's other
|
|
13
|
+
* files are not init's to reformat.
|
|
14
|
+
*
|
|
15
|
+
* Never fatal - the repo is already initialised, so a formatter that cannot
|
|
16
|
+
* run costs a `nx format` the user can run themselves, not their setup.
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatInitWrites(repoRoot: string, command?: string): Promise<void>;
|