@nx/js 24.1.0-beta.1 → 24.1.0-beta.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.
- package/dist/internal.d.ts +2 -1
- package/dist/internal.js +8 -5
- package/dist/src/executors/copy-workspace-modules/copy-workspace-modules.js +40 -32
- package/dist/src/executors/prune-lockfile/prune-lockfile.js +105 -8
- package/dist/src/migrations/update-23-2-0/add-pnpm-deploy-output-cache-inputs.d.ts +1 -6
- package/dist/src/migrations/update-23-2-0/add-pnpm-deploy-output-cache-inputs.js +4 -224
- package/dist/src/migrations/update-23-2-0/add-pnpm-prune-lockfile-cache-config.js +18 -297
- package/dist/src/migrations/update-24-1-0/add-bun-deploy-output-cache-inputs.d.ts +8 -0
- package/dist/src/migrations/update-24-1-0/add-bun-deploy-output-cache-inputs.js +21 -0
- package/dist/src/migrations/update-24-1-0/add-bun-deploy-output-cache-inputs.md +49 -0
- package/dist/src/migrations/update-24-1-0/add-bun-prune-lockfile-cache-config.d.ts +2 -0
- package/dist/src/migrations/update-24-1-0/add-bun-prune-lockfile-cache-config.js +28 -0
- package/dist/src/migrations/update-24-1-0/add-bun-prune-lockfile-cache-config.md +44 -0
- package/dist/src/release/version-actions.js +6 -0
- package/dist/src/utils/bun-install-settings-inputs.d.ts +20 -0
- package/dist/src/utils/bun-install-settings-inputs.js +31 -0
- package/dist/src/utils/deploy-output-cache-inputs.d.ts +35 -0
- package/dist/src/utils/deploy-output-cache-inputs.js +400 -0
- package/dist/src/utils/pnpm-install-settings-inputs.d.ts +0 -6
- package/dist/src/utils/pnpm-install-settings-inputs.js +0 -6
- package/dist/src/utils/prune-lockfile-cache-config.d.ts +18 -0
- package/dist/src/utils/prune-lockfile-cache-config.js +288 -0
- package/dist/src/utils/target-defaults-matching.d.ts +3 -0
- package/dist/src/utils/target-defaults-matching.js +7 -0
- package/dist/src/utils/workspace-module-sections.d.ts +10 -5
- package/dist/src/utils/workspace-module-sections.js +15 -6
- package/migrations.json +12 -0
- package/package.json +11 -11
- package/dist/src/utils/pnpm-deploy-output-cache-inputs.d.ts +0 -29
- package/dist/src/utils/pnpm-deploy-output-cache-inputs.js +0 -177
package/dist/internal.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export { findProjectsNpmDependencies } from '@nx/devkit/internal';
|
|
|
4
4
|
export { walkTsconfigExtendsChain, type RawTsconfigJsonCache, } from './src/utils/typescript/raw-tsconfig';
|
|
5
5
|
export { isEsmProject } from './src/utils/module-format/is-esm-project';
|
|
6
6
|
export { PNPM_INSTALL_SETTINGS_INPUTS, PNPM_MAJOR_RUNTIME_INPUT, pnpmInstallSettingsInputsForInferredTarget, shouldIncludePnpmMajorRuntimeInput, } from './src/utils/pnpm-install-settings-inputs';
|
|
7
|
-
export {
|
|
7
|
+
export { BUN_INSTALL_SETTINGS_INPUTS, shouldIncludeBunInstallSettingsInputs, } from './src/utils/bun-install-settings-inputs';
|
|
8
|
+
export { addDeployOutputCacheInputs, type DeployOutputSettingsInput, } from './src/utils/deploy-output-cache-inputs';
|
|
8
9
|
export { readRuntimeDependencies } from './src/utils/package-json/runtime-dependencies';
|
|
9
10
|
export type { MatchedTargetRef } from './src/utils/target-defaults-matching';
|
|
10
11
|
export { TS_SOLUTION_SETUP_TSCONFIG_INPUT, addProjectToTsSolutionWorkspace, assertNotUsingTsSolutionSetup, findRuntimeTsConfigName, getDefinedCustomConditionName, getProjectSourceRoot, getProjectType, isUsingTsSolutionSetup, shouldConfigureTsSolutionSetup, updateTsconfigFiles, } from './src/utils/typescript/ts-solution-setup';
|
package/dist/internal.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// internal consumers and may change without semver protection. Consider it
|
|
6
6
|
// the @nx/js equivalent of `@nx/devkit/internal`.
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
9
|
-
exports.typescriptVersion = exports.typesNodeVersion = exports.tsLibVersion = exports.swcNodeVersion = exports.swcHelpersVersion = exports.swcCoreVersion = exports.swcCliVersion = exports.prettierVersion = exports.esbuildVersion = exports.nxVersion = exports.releaseTasks = exports.addReleaseConfigForTsSolution = exports.addReleaseConfigForNonTsSolution = exports.addLocalRegistryScripts = exports.stripGlobToBaseDir = exports.getImportPath = exports.createGlobPatternsForDependencies = exports.addLintingToProject = exports.detectLinters = exports.normalizeUnitTestRunnerOption = exports.normalizeLinterOption = exports.selectTypecheckTsConfig = exports.createTypecheckTarget = exports.isValidPackageJsonBuildConfig = exports.addBuildAndWatchDepsTargets = exports.findNpmDependencies = void 0;
|
|
8
|
+
exports.getNpmScope = exports.sortPackageJsonFields = exports.CopyAssetsHandler = exports.addSwcRegisterDependencies = exports.addSwcDependencies = exports.acknowledgeSwcBuildScripts = exports.addSwcTestConfig = exports.addSwcConfig = exports.createTmpTsConfig = exports.computeCompilerOptionsPaths = exports.calculateProjectDependencies = exports.calculateProjectBuildableDependencies = exports.compileTypeScript = exports.getNeededCompilerOptionOverrides = exports.isTypescriptVersionAtLeast = exports.getTsConfigModuleResolution = exports.getRangeMinimum = exports.ensureTypescript = exports.createTreeParseConfigHost = exports.getTsConfigBaseOptions = exports.registerTypescriptPluginForTypecheck = exports.ensureTypescriptPlugin = exports.updateTsconfigFiles = exports.shouldConfigureTsSolutionSetup = exports.isUsingTsSolutionSetup = exports.getProjectType = exports.getProjectSourceRoot = exports.getDefinedCustomConditionName = exports.findRuntimeTsConfigName = exports.assertNotUsingTsSolutionSetup = exports.addProjectToTsSolutionWorkspace = exports.TS_SOLUTION_SETUP_TSCONFIG_INPUT = exports.readRuntimeDependencies = exports.addDeployOutputCacheInputs = exports.shouldIncludeBunInstallSettingsInputs = exports.BUN_INSTALL_SETTINGS_INPUTS = exports.shouldIncludePnpmMajorRuntimeInput = exports.pnpmInstallSettingsInputsForInferredTarget = exports.PNPM_MAJOR_RUNTIME_INPUT = exports.PNPM_INSTALL_SETTINGS_INPUTS = exports.isEsmProject = exports.walkTsconfigExtendsChain = exports.findProjectsNpmDependencies = exports.isBuiltinModuleImport = exports.TargetProjectLocator = exports.requireWithTsconfigFallback = exports.registerTsConfigPaths = exports.registerTsProject = exports.loadTsFile = exports.forceRegisterEsmLoader = void 0;
|
|
9
|
+
exports.typescriptVersion = exports.typesNodeVersion = exports.tsLibVersion = exports.swcNodeVersion = exports.swcHelpersVersion = exports.swcCoreVersion = exports.swcCliVersion = exports.prettierVersion = exports.esbuildVersion = exports.nxVersion = exports.releaseTasks = exports.addReleaseConfigForTsSolution = exports.addReleaseConfigForNonTsSolution = exports.addLocalRegistryScripts = exports.stripGlobToBaseDir = exports.getImportPath = exports.createGlobPatternsForDependencies = exports.addLintingToProject = exports.detectLinters = exports.normalizeUnitTestRunnerOption = exports.normalizeLinterOption = exports.selectTypecheckTsConfig = exports.createTypecheckTarget = exports.isValidPackageJsonBuildConfig = exports.addBuildAndWatchDepsTargets = exports.findNpmDependencies = exports.getProjectPackageManagerWorkspaceStateWarningTask = exports.getProjectPackageManagerWorkspaceState = void 0;
|
|
10
10
|
// Re-exports of nx-source internals.
|
|
11
11
|
var internal_1 = require("@nx/devkit/internal");
|
|
12
12
|
Object.defineProperty(exports, "forceRegisterEsmLoader", { enumerable: true, get: function () { return internal_1.forceRegisterEsmLoader; } });
|
|
@@ -26,14 +26,17 @@ Object.defineProperty(exports, "walkTsconfigExtendsChain", { enumerable: true, g
|
|
|
26
26
|
// TS solution awareness; mirrors Node's nearest-package.json semantics).
|
|
27
27
|
var is_esm_project_1 = require("./src/utils/module-format/is-esm-project");
|
|
28
28
|
Object.defineProperty(exports, "isEsmProject", { enumerable: true, get: function () { return is_esm_project_1.isEsmProject; } });
|
|
29
|
-
// Inputs for build targets that emit a pruned pnpm deploy output
|
|
29
|
+
// Inputs for build targets that emit a pruned pnpm or Bun deploy output
|
|
30
30
|
var pnpm_install_settings_inputs_1 = require("./src/utils/pnpm-install-settings-inputs");
|
|
31
31
|
Object.defineProperty(exports, "PNPM_INSTALL_SETTINGS_INPUTS", { enumerable: true, get: function () { return pnpm_install_settings_inputs_1.PNPM_INSTALL_SETTINGS_INPUTS; } });
|
|
32
32
|
Object.defineProperty(exports, "PNPM_MAJOR_RUNTIME_INPUT", { enumerable: true, get: function () { return pnpm_install_settings_inputs_1.PNPM_MAJOR_RUNTIME_INPUT; } });
|
|
33
33
|
Object.defineProperty(exports, "pnpmInstallSettingsInputsForInferredTarget", { enumerable: true, get: function () { return pnpm_install_settings_inputs_1.pnpmInstallSettingsInputsForInferredTarget; } });
|
|
34
34
|
Object.defineProperty(exports, "shouldIncludePnpmMajorRuntimeInput", { enumerable: true, get: function () { return pnpm_install_settings_inputs_1.shouldIncludePnpmMajorRuntimeInput; } });
|
|
35
|
-
var
|
|
36
|
-
Object.defineProperty(exports, "
|
|
35
|
+
var bun_install_settings_inputs_1 = require("./src/utils/bun-install-settings-inputs");
|
|
36
|
+
Object.defineProperty(exports, "BUN_INSTALL_SETTINGS_INPUTS", { enumerable: true, get: function () { return bun_install_settings_inputs_1.BUN_INSTALL_SETTINGS_INPUTS; } });
|
|
37
|
+
Object.defineProperty(exports, "shouldIncludeBunInstallSettingsInputs", { enumerable: true, get: function () { return bun_install_settings_inputs_1.shouldIncludeBunInstallSettingsInputs; } });
|
|
38
|
+
var deploy_output_cache_inputs_1 = require("./src/utils/deploy-output-cache-inputs");
|
|
39
|
+
Object.defineProperty(exports, "addDeployOutputCacheInputs", { enumerable: true, get: function () { return deploy_output_cache_inputs_1.addDeployOutputCacheInputs; } });
|
|
37
40
|
var runtime_dependencies_1 = require("./src/utils/package-json/runtime-dependencies");
|
|
38
41
|
Object.defineProperty(exports, "readRuntimeDependencies", { enumerable: true, get: function () { return runtime_dependencies_1.readRuntimeDependencies; } });
|
|
39
42
|
// TS solution setup detection
|
|
@@ -8,18 +8,6 @@ const path_1 = require("path");
|
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
9
|
const strip_glob_to_base_dir_1 = require("../../utils/strip-glob-to-base-dir");
|
|
10
10
|
const workspace_module_sections_1 = require("../../utils/workspace-module-sections");
|
|
11
|
-
// Sections of a copied module's own manifest whose workspace-module deps are
|
|
12
|
-
// rewritten to file: and recursed into. pnpm installs a transitive dependency's
|
|
13
|
-
// regular, optional, and auto-installed peer deps (a workspace peer is linked
|
|
14
|
-
// and recorded under the depending importer's dependencies in the lockfile), but
|
|
15
|
-
// never its devDependencies. A workspace-module peer is moved into dependencies,
|
|
16
|
-
// since pnpm rejects a file: spec under peerDependencies (mirrors the app-level
|
|
17
|
-
// move in prune-lockfile).
|
|
18
|
-
const TRANSITIVE_INSTALL_SECTIONS = [
|
|
19
|
-
'dependencies',
|
|
20
|
-
'optionalDependencies',
|
|
21
|
-
'peerDependencies',
|
|
22
|
-
];
|
|
23
11
|
// Resolve `catalog:` references in a copied module manifest to the version the
|
|
24
12
|
// workspace pinned. Only the sections pnpm installs for a `file:` directory
|
|
25
13
|
// dependency are resolved: a copied module's devDependencies are never
|
|
@@ -31,7 +19,7 @@ function resolveCatalogReferences(packageJson, manager) {
|
|
|
31
19
|
return false;
|
|
32
20
|
}
|
|
33
21
|
let modified = false;
|
|
34
|
-
for (const section of TRANSITIVE_INSTALL_SECTIONS) {
|
|
22
|
+
for (const section of workspace_module_sections_1.TRANSITIVE_INSTALL_SECTIONS) {
|
|
35
23
|
const deps = packageJson[section];
|
|
36
24
|
if (!deps) {
|
|
37
25
|
continue;
|
|
@@ -54,20 +42,30 @@ async function copyWorkspaceModules(schema, context) {
|
|
|
54
42
|
devkit_1.logger.log('Copying Workspace Modules to Build Directory...');
|
|
55
43
|
const outputDirectory = getOutputDir(schema, context);
|
|
56
44
|
const packageJson = getPackageJson(schema, context);
|
|
45
|
+
const { project } = (0, devkit_1.parseTargetString)(schema.buildTarget, context);
|
|
57
46
|
createWorkspaceModules(outputDirectory);
|
|
58
|
-
handleWorkspaceModules(outputDirectory, packageJson, context.projectGraph);
|
|
47
|
+
handleWorkspaceModules(outputDirectory, packageJson, context.projectGraph, context.projectGraph.nodes[project].data.root);
|
|
59
48
|
devkit_1.logger.log('Success!');
|
|
60
49
|
return { success: true };
|
|
61
50
|
}
|
|
62
|
-
function handleWorkspaceModules(outputDirectory, packageJson, projectGraph) {
|
|
51
|
+
function handleWorkspaceModules(outputDirectory, packageJson, projectGraph, projectRoot) {
|
|
63
52
|
if (!workspace_module_sections_1.WORKSPACE_MODULE_INSTALL_SECTIONS.some((section) => packageJson[section])) {
|
|
64
53
|
return;
|
|
65
54
|
}
|
|
66
55
|
const workspaceModules = (0, internal_1.getWorkspacePackagesFromGraph)(projectGraph);
|
|
67
56
|
const catalogManager = (0, internal_1.getCatalogManager)(devkit_1.workspaceRoot);
|
|
68
|
-
// Only the pnpm prune
|
|
69
|
-
//
|
|
70
|
-
|
|
57
|
+
// Only the pnpm and Bun prune paths tell a vendored package from a workspace
|
|
58
|
+
// package of the same name. They also ship non-workspace local-path targets,
|
|
59
|
+
// so their manifests get their file:/link: specs relocated, except for Bun
|
|
60
|
+
// without the text bun.lock, whose output ships the manifest alone.
|
|
61
|
+
const packageManager = (0, devkit_1.detectPackageManager)(devkit_1.workspaceRoot);
|
|
62
|
+
const isPnpmWorkspace = packageManager === 'pnpm';
|
|
63
|
+
const resolvesLocalPaths = isPnpmWorkspace || packageManager === 'bun';
|
|
64
|
+
const relocatesLocalPaths = isPnpmWorkspace ||
|
|
65
|
+
(packageManager === 'bun' && (0, internal_1.hasTextBunLockfile)(devkit_1.workspaceRoot));
|
|
66
|
+
const resolveModule = (name, spec, dependentRoot) => resolvesLocalPaths
|
|
67
|
+
? (0, internal_1.resolveWorkspaceModuleDependency)(workspaceModules, name, spec, dependentRoot, devkit_1.workspaceRoot)
|
|
68
|
+
: workspaceModules.get(name);
|
|
71
69
|
const processedModules = new Set();
|
|
72
70
|
const workspaceModulesDir = (0, path_1.join)(outputDirectory, 'workspace_modules');
|
|
73
71
|
function calculateRelativePath(fromPkgName, toPkgName) {
|
|
@@ -77,17 +75,13 @@ function handleWorkspaceModules(outputDirectory, packageJson, projectGraph) {
|
|
|
77
75
|
// Ensure forward slashes for file: protocol (Windows compatibility)
|
|
78
76
|
return relativePath.split(path_1.sep).join('/');
|
|
79
77
|
}
|
|
80
|
-
function processModule(pkgName) {
|
|
78
|
+
function processModule(pkgName, workspaceModuleProject) {
|
|
81
79
|
if (processedModules.has(pkgName)) {
|
|
82
80
|
devkit_1.logger.verbose(`Skipping ${pkgName} (already processed).`);
|
|
83
81
|
return;
|
|
84
82
|
}
|
|
85
|
-
if (!workspaceModules.has(pkgName)) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
83
|
processedModules.add(pkgName);
|
|
89
84
|
devkit_1.logger.verbose(`Copying ${pkgName}.`);
|
|
90
|
-
const workspaceModuleProject = workspaceModules.get(pkgName);
|
|
91
85
|
const workspaceModuleRoot = workspaceModuleProject.data.root;
|
|
92
86
|
// data.root is workspace-root-relative in the graph, but may arrive
|
|
93
87
|
// absolute; normalize so the local-path relocation math is in
|
|
@@ -120,13 +114,14 @@ function handleWorkspaceModules(outputDirectory, packageJson, projectGraph) {
|
|
|
120
114
|
// Rewrite sibling workspace-module deps to file: paths and recurse. A peer
|
|
121
115
|
// is moved into dependencies (pnpm rejects a file: spec under
|
|
122
116
|
// peerDependencies), dropping its now-orphaned optional/required marker.
|
|
123
|
-
for (const section of TRANSITIVE_INSTALL_SECTIONS) {
|
|
117
|
+
for (const section of workspace_module_sections_1.TRANSITIVE_INSTALL_SECTIONS) {
|
|
124
118
|
const deps = copiedPackageJson[section];
|
|
125
119
|
if (!deps) {
|
|
126
120
|
continue;
|
|
127
121
|
}
|
|
128
122
|
for (const depName of Object.keys(deps)) {
|
|
129
|
-
|
|
123
|
+
const depModule = resolveModule(depName, deps[depName], moduleWsRelativeRoot);
|
|
124
|
+
if (depModule) {
|
|
130
125
|
const fileSpec = `file:${calculateRelativePath(pkgName, depName)}`;
|
|
131
126
|
if (section === 'peerDependencies') {
|
|
132
127
|
(0, internal_1.movePeerDependencyToDependencies)(copiedPackageJson, depName, fileSpec);
|
|
@@ -135,25 +130,28 @@ function handleWorkspaceModules(outputDirectory, packageJson, projectGraph) {
|
|
|
135
130
|
deps[depName] = fileSpec;
|
|
136
131
|
}
|
|
137
132
|
packageJsonModified = true;
|
|
138
|
-
processModule(depName);
|
|
133
|
+
processModule(depName, depModule);
|
|
139
134
|
continue;
|
|
140
135
|
}
|
|
141
136
|
// A non-workspace file:/link: dep must keep resolving after the module
|
|
142
137
|
// moves. pnpm reads a non-importer manifest file: spec relative to the
|
|
143
138
|
// package dir but a link: spec relative to the install root, so each
|
|
144
|
-
// rebases onto a different base
|
|
145
|
-
|
|
139
|
+
// rebases onto a different base. Bun reads both relative to the
|
|
140
|
+
// package dir.
|
|
141
|
+
if (!relocatesLocalPaths) {
|
|
146
142
|
continue;
|
|
147
143
|
}
|
|
148
144
|
const spec = deps[depName];
|
|
149
|
-
const relocation = (0, internal_1.relocatePrunedLocalPathSpec)(spec, moduleWsRelativeRoot, spec.startsWith('link:')
|
|
145
|
+
const relocation = (0, internal_1.relocatePrunedLocalPathSpec)(spec, moduleWsRelativeRoot, isPnpmWorkspace && spec.startsWith('link:')
|
|
146
|
+
? ''
|
|
147
|
+
: `workspace_modules/${pkgName}`);
|
|
150
148
|
if (!relocation) {
|
|
151
149
|
continue;
|
|
152
150
|
}
|
|
153
151
|
if (relocation.reason) {
|
|
154
152
|
(0, internal_1.warnUnshippableLocalPathSpec)(`"${spec}" in ${pkgName}`, relocation.reason);
|
|
155
153
|
}
|
|
156
|
-
if (section === 'peerDependencies') {
|
|
154
|
+
if (section === 'peerDependencies' && isPnpmWorkspace) {
|
|
157
155
|
// Moved even when the target cannot ship: pnpm rejects the spec here
|
|
158
156
|
// either way.
|
|
159
157
|
(0, internal_1.movePeerDependencyToDependencies)(copiedPackageJson, depName, relocation.spec);
|
|
@@ -166,6 +164,13 @@ function handleWorkspaceModules(outputDirectory, packageJson, projectGraph) {
|
|
|
166
164
|
}
|
|
167
165
|
}
|
|
168
166
|
(0, internal_1.dropEmptyPeerDependencySections)(copiedPackageJson);
|
|
167
|
+
// Bun resolves the devDependencies of a folder dependency the output
|
|
168
|
+
// manifest lists, but the pruned lockfile leaves them out and a
|
|
169
|
+
// `workspace:` one cannot resolve outside the workspace.
|
|
170
|
+
if (packageManager === 'bun' && copiedPackageJson.devDependencies) {
|
|
171
|
+
delete copiedPackageJson.devDependencies;
|
|
172
|
+
packageJsonModified = true;
|
|
173
|
+
}
|
|
169
174
|
if (packageJsonModified) {
|
|
170
175
|
(0, node_fs_1.writeFileSync)(copiedPackageJsonPath, JSON.stringify(copiedPackageJson, null, 2));
|
|
171
176
|
devkit_1.logger.verbose(`Updated package.json for ${pkgName}.`);
|
|
@@ -180,8 +185,11 @@ function handleWorkspaceModules(outputDirectory, packageJson, projectGraph) {
|
|
|
180
185
|
if (!deps) {
|
|
181
186
|
continue;
|
|
182
187
|
}
|
|
183
|
-
for (const pkgName of Object.
|
|
184
|
-
|
|
188
|
+
for (const [pkgName, spec] of Object.entries(deps)) {
|
|
189
|
+
const workspaceModule = resolveModule(pkgName, spec, projectRoot);
|
|
190
|
+
if (workspaceModule) {
|
|
191
|
+
processModule(pkgName, workspaceModule);
|
|
192
|
+
}
|
|
185
193
|
}
|
|
186
194
|
}
|
|
187
195
|
}
|
|
@@ -16,12 +16,15 @@ async function pruneLockfileExecutor(schema, context) {
|
|
|
16
16
|
const packageManager = (0, devkit_1.detectPackageManager)(devkit_1.workspaceRoot);
|
|
17
17
|
const { project } = (0, devkit_1.parseTargetString)(schema.buildTarget, context);
|
|
18
18
|
const projectRoot = context.projectGraph.nodes[project].data.root;
|
|
19
|
+
if (packageManager === 'bun') {
|
|
20
|
+
declareTransitiveFolderDependencies(packageJson, context.projectGraph, projectRoot);
|
|
21
|
+
}
|
|
19
22
|
(0, internal_1.generatePrunedDeployOutput)(packageJson, context.projectGraph, projectRoot, {
|
|
20
23
|
outputDirectory,
|
|
21
24
|
packageManager,
|
|
22
25
|
workspaceRoot: devkit_1.workspaceRoot,
|
|
23
26
|
});
|
|
24
|
-
rewriteWorkspaceModuleSpecifiers(packageJson, context.projectGraph);
|
|
27
|
+
rewriteWorkspaceModuleSpecifiers(packageJson, context.projectGraph, projectRoot, packageManager);
|
|
25
28
|
(0, fs_1.writeFileSync)((0, path_1.join)(outputDirectory, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
26
29
|
devkit_1.logger.log(`Pruned deploy output written to ${outputDirectory}`);
|
|
27
30
|
return {
|
|
@@ -32,19 +35,22 @@ async function pruneLockfileExecutor(schema, context) {
|
|
|
32
35
|
// standalone output installs them as pnpm `file:` directory dependencies.
|
|
33
36
|
// pnpm rejects a `file:` spec under peerDependencies, so a peer-declared
|
|
34
37
|
// workspace module is moved into dependencies instead (an optional peer
|
|
35
|
-
// becomes required, which is moot since the module is always copied in).
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
function rewriteWorkspaceModuleSpecifiers(packageJson, graph) {
|
|
38
|
+
// becomes required, which is moot since the module is always copied in). For
|
|
39
|
+
// pnpm and Bun, as in copy-workspace-modules, a `file:`/`link:` spec to another
|
|
40
|
+
// directory is a vendored package even when a workspace package has its name.
|
|
41
|
+
function rewriteWorkspaceModuleSpecifiers(packageJson, graph, projectRoot, packageManager) {
|
|
40
42
|
const workspacePackages = (0, internal_1.getWorkspacePackagesFromGraph)(graph);
|
|
43
|
+
const resolvesLocalPaths = packageManager === 'pnpm' || packageManager === 'bun';
|
|
41
44
|
for (const section of workspace_module_sections_1.WORKSPACE_MODULE_INSTALL_SECTIONS) {
|
|
42
45
|
const deps = packageJson[section];
|
|
43
46
|
if (!deps) {
|
|
44
47
|
continue;
|
|
45
48
|
}
|
|
46
|
-
for (const pkgName of Object.
|
|
47
|
-
|
|
49
|
+
for (const [pkgName, spec] of Object.entries(deps)) {
|
|
50
|
+
const isWorkspaceModule = resolvesLocalPaths
|
|
51
|
+
? (0, internal_1.resolveWorkspaceModuleDependency)(workspacePackages, pkgName, spec, projectRoot, devkit_1.workspaceRoot)
|
|
52
|
+
: workspacePackages.has(pkgName);
|
|
53
|
+
if (!isWorkspaceModule) {
|
|
48
54
|
continue;
|
|
49
55
|
}
|
|
50
56
|
const fileSpec = `file:./workspace_modules/${pkgName}`;
|
|
@@ -75,6 +81,97 @@ function mergeAllowScripts(packageJson) {
|
|
|
75
81
|
...packageJson.allowScripts,
|
|
76
82
|
};
|
|
77
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Bun never installs the dependencies of a `file:` dependency declared by
|
|
86
|
+
* another `file:` dependency, so a Bun output declares every workspace module
|
|
87
|
+
* the app reaches through other modules. With the text bun.lock it also
|
|
88
|
+
* declares each vendored `file:` package those modules declare, unless the
|
|
89
|
+
* manifest already declares that name. Without the text bun.lock, the output
|
|
90
|
+
* ships no vendored copy for that declaration to point at.
|
|
91
|
+
* A package a production section reaches goes to dependencies, one only
|
|
92
|
+
* devDependencies reach to devDependencies. A vendored package the modules
|
|
93
|
+
* declare only as optional goes to optionalDependencies instead, and is left
|
|
94
|
+
* out when only devDependencies reach them, since no section holds an
|
|
95
|
+
* optional devDependency. A vendored package is declared relative to
|
|
96
|
+
* `projectRoot`, like the app's own.
|
|
97
|
+
*/
|
|
98
|
+
function declareTransitiveFolderDependencies(packageJson, graph, projectRoot) {
|
|
99
|
+
const workspacePackages = (0, internal_1.getWorkspacePackagesFromGraph)(graph);
|
|
100
|
+
const shipsVendoredPackages = (0, internal_1.hasTextBunLockfile)(devkit_1.workspaceRoot);
|
|
101
|
+
const productionSections = workspace_module_sections_1.WORKSPACE_MODULE_INSTALL_SECTIONS.filter((section) => section !== 'devDependencies');
|
|
102
|
+
const resolveModule = (name, spec, dependentRoot) => (0, internal_1.resolveWorkspaceModuleDependency)(workspacePackages, name, spec, dependentRoot, devkit_1.workspaceRoot);
|
|
103
|
+
const visited = new Set();
|
|
104
|
+
const visit = (name, project, section) => {
|
|
105
|
+
if (visited.has(name)) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
visited.add(name);
|
|
109
|
+
const declaredForProduction = productionSections.some((declared) => packageJson[declared]?.[name]);
|
|
110
|
+
if (!declaredForProduction &&
|
|
111
|
+
(section === 'dependencies' || !packageJson.devDependencies?.[name])) {
|
|
112
|
+
if (packageJson.devDependencies?.[name]) {
|
|
113
|
+
delete packageJson.devDependencies[name];
|
|
114
|
+
if (!Object.keys(packageJson.devDependencies).length) {
|
|
115
|
+
delete packageJson.devDependencies;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
(packageJson[section] ??= {})[name] = 'workspace:*';
|
|
119
|
+
}
|
|
120
|
+
const manifest = (0, devkit_1.readJsonFile)((0, path_1.join)(devkit_1.workspaceRoot, project.data.root, 'package.json'));
|
|
121
|
+
for (const transitiveSection of workspace_module_sections_1.TRANSITIVE_INSTALL_SECTIONS) {
|
|
122
|
+
for (const [dep, spec] of Object.entries(manifest[transitiveSection] ?? {})) {
|
|
123
|
+
const workspaceModule = resolveModule(dep, spec, project.data.root);
|
|
124
|
+
if (workspaceModule) {
|
|
125
|
+
visit(dep, workspaceModule, section);
|
|
126
|
+
}
|
|
127
|
+
else if (shipsVendoredPackages && spec.startsWith('file:')) {
|
|
128
|
+
if (transitiveSection !== 'optionalDependencies') {
|
|
129
|
+
declareVendored(dep, spec, project.data.root, section);
|
|
130
|
+
}
|
|
131
|
+
else if (section === 'dependencies') {
|
|
132
|
+
declareVendored(dep, spec, project.data.root, 'optionalDependencies');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
// Optional declarations made here, which a module requiring the same
|
|
139
|
+
// package promotes to dependencies.
|
|
140
|
+
const declaredOptional = new Set();
|
|
141
|
+
const declareVendored = (name, spec, moduleRoot, section) => {
|
|
142
|
+
if (section !== 'optionalDependencies' && declaredOptional.delete(name)) {
|
|
143
|
+
(packageJson.dependencies ??= {})[name] =
|
|
144
|
+
packageJson.optionalDependencies[name];
|
|
145
|
+
delete packageJson.optionalDependencies[name];
|
|
146
|
+
if (!Object.keys(packageJson.optionalDependencies).length) {
|
|
147
|
+
delete packageJson.optionalDependencies;
|
|
148
|
+
}
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (workspace_module_sections_1.WORKSPACE_MODULE_INSTALL_SECTIONS.some((declared) => packageJson[declared]?.[name])) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const path = (0, devkit_1.normalizePath)(spec.slice('file:'.length));
|
|
155
|
+
(packageJson[section] ??= {})[name] = (0, path_1.isAbsolute)(path)
|
|
156
|
+
? spec
|
|
157
|
+
: `file:${path_1.posix.relative(projectRoot, path_1.posix.join(moduleRoot, path))}`;
|
|
158
|
+
if (section === 'optionalDependencies') {
|
|
159
|
+
declaredOptional.add(name);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const visitDeclared = (section, visitAs) => {
|
|
163
|
+
for (const [name, spec] of Object.entries(packageJson[section] ?? {})) {
|
|
164
|
+
const workspaceModule = resolveModule(name, spec, projectRoot);
|
|
165
|
+
if (workspaceModule) {
|
|
166
|
+
visit(name, workspaceModule, visitAs);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
for (const section of productionSections) {
|
|
171
|
+
visitDeclared(section, 'dependencies');
|
|
172
|
+
}
|
|
173
|
+
visitDeclared('devDependencies', 'devDependencies');
|
|
174
|
+
}
|
|
78
175
|
function resolveCatalogReferences(packageJson) {
|
|
79
176
|
const manager = (0, internal_1.getCatalogManager)(devkit_1.workspaceRoot);
|
|
80
177
|
if (!manager) {
|
|
@@ -4,11 +4,6 @@ import { type Tree } from '@nx/devkit';
|
|
|
4
4
|
* build targets that emit the pruned pnpm deploy output. The build approvals
|
|
5
5
|
* and `supportedArchitectures` those outputs carry reach no lockfile, so
|
|
6
6
|
* without these a revoked approval leaves the task hash unchanged and a cached
|
|
7
|
-
* run replays an output that still grants it.
|
|
8
|
-
* the `@nx/webpack` and `@nx/rspack` plugins themselves; this migration covers
|
|
9
|
-
* the explicitly configured executor targets, plus overlays of inferred
|
|
10
|
-
* targets (a project-level entry, under the exact name or a glob-pattern key
|
|
11
|
-
* matching it, or a matching `targetDefaults` entry) whose replacing `inputs`
|
|
12
|
-
* array discards the plugin-generated one.
|
|
7
|
+
* run replays an output that still grants it.
|
|
13
8
|
*/
|
|
14
9
|
export default function update(tree: Tree): Promise<void>;
|
|
@@ -2,50 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = update;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const pnpm_deploy_output_cache_inputs_1 = require("../../utils/pnpm-deploy-output-cache-inputs");
|
|
8
|
-
const target_defaults_matching_1 = require("../../utils/target-defaults-matching");
|
|
9
|
-
// The executors that emit the pruned pnpm deploy output (lockfile,
|
|
10
|
-
// settings-only pnpm-workspace.yaml, patches, vendored local paths), each with
|
|
11
|
-
// the option that turns the emission on. webpack, rspack, vite and esbuild
|
|
12
|
-
// gate it on `generatePackageJson`; next, remix, tsc and swc emit the manifest
|
|
13
|
-
// regardless and gate only the deploy output on `generateLockfile`.
|
|
14
|
-
const DEPLOY_OUTPUT_EXECUTORS = {
|
|
15
|
-
'@nx/webpack:webpack': 'generatePackageJson',
|
|
16
|
-
'@nx/rspack:rspack': 'generatePackageJson',
|
|
17
|
-
'@nx/vite:build': 'generatePackageJson',
|
|
18
|
-
'@nx/esbuild:esbuild': 'generatePackageJson',
|
|
19
|
-
'@nx/next:build': 'generateLockfile',
|
|
20
|
-
'@nx/remix:build': 'generateLockfile',
|
|
21
|
-
'@nx/js:tsc': 'generateLockfile',
|
|
22
|
-
'@nx/js:swc': 'generateLockfile',
|
|
23
|
-
};
|
|
24
|
-
// The config-file plugins whose inferred build target can emit the deploy
|
|
25
|
-
// output (NxAppWebpackPlugin/NxAppRspackPlugin with generatePackageJson).
|
|
26
|
-
// The globs mirror each plugin's own createNodes pattern; the commands are
|
|
27
|
-
// what each plugin sets on the build target it creates.
|
|
28
|
-
const INFERRED_DEPLOY_PLUGINS = {
|
|
29
|
-
'@nx/webpack/plugin': {
|
|
30
|
-
configGlob: '**/webpack.config.{js,ts,mjs,cjs}',
|
|
31
|
-
command: 'webpack-cli build',
|
|
32
|
-
},
|
|
33
|
-
'@nx/rspack/plugin': {
|
|
34
|
-
configGlob: '**/rspack.config.{js,ts,mjs,mts,cjs,cts}',
|
|
35
|
-
command: 'rspack build',
|
|
36
|
-
},
|
|
37
|
-
};
|
|
5
|
+
const deploy_output_cache_inputs_1 = require("../../utils/deploy-output-cache-inputs");
|
|
6
|
+
const pnpm_install_settings_inputs_1 = require("../../utils/pnpm-install-settings-inputs");
|
|
38
7
|
/**
|
|
39
8
|
* Adds the workspace-root pnpm install settings sources to the `inputs` of
|
|
40
9
|
* build targets that emit the pruned pnpm deploy output. The build approvals
|
|
41
10
|
* and `supportedArchitectures` those outputs carry reach no lockfile, so
|
|
42
11
|
* without these a revoked approval leaves the task hash unchanged and a cached
|
|
43
|
-
* run replays an output that still grants it.
|
|
44
|
-
* the `@nx/webpack` and `@nx/rspack` plugins themselves; this migration covers
|
|
45
|
-
* the explicitly configured executor targets, plus overlays of inferred
|
|
46
|
-
* targets (a project-level entry, under the exact name or a glob-pattern key
|
|
47
|
-
* matching it, or a matching `targetDefaults` entry) whose replacing `inputs`
|
|
48
|
-
* array discards the plugin-generated one.
|
|
12
|
+
* run replays an output that still grants it.
|
|
49
13
|
*/
|
|
50
14
|
async function update(tree) {
|
|
51
15
|
// The deploy output's install settings are pnpm-specific; other package
|
|
@@ -53,190 +17,6 @@ async function update(tree) {
|
|
|
53
17
|
if (!tree.exists('pnpm-lock.yaml')) {
|
|
54
18
|
return;
|
|
55
19
|
}
|
|
56
|
-
|
|
57
|
-
const targetDefaults = nxJson?.targetDefaults;
|
|
58
|
-
const projects = new Map();
|
|
59
|
-
const changedProjects = new Set();
|
|
60
|
-
let defaultsChanged = false;
|
|
61
|
-
for (const [projectName, project] of (0, devkit_1.getProjects)(tree)) {
|
|
62
|
-
projects.set(projectName, project);
|
|
63
|
-
const projectNode = {
|
|
64
|
-
name: projectName,
|
|
65
|
-
type: 'lib',
|
|
66
|
-
data: { root: project.root, tags: project.tags },
|
|
67
|
-
};
|
|
68
|
-
for (const [targetName, target] of Object.entries(project.targets ?? {})) {
|
|
69
|
-
// The executor may come from a matching targetDefaults entry rather
|
|
70
|
-
// than the target itself. A `command` target resolves to nx:run-commands
|
|
71
|
-
// before defaults apply, so a default can never re-identify it.
|
|
72
|
-
const executor = target.executor ??
|
|
73
|
-
(target.command
|
|
74
|
-
? 'nx:run-commands'
|
|
75
|
-
: (0, target_defaults_matching_1.resolveDefaultsExecutor)(targetName, projectName, projectNode, targetDefaults));
|
|
76
|
-
if (!executor || !DEPLOY_OUTPUT_EXECUTORS[executor]) {
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
const ref = {
|
|
80
|
-
targetName,
|
|
81
|
-
projectName,
|
|
82
|
-
projectNode,
|
|
83
|
-
matcherExecutor: target.executor,
|
|
84
|
-
target,
|
|
85
|
-
};
|
|
86
|
-
const selectedKey = targetDefaults
|
|
87
|
-
? (0, target_defaults_matching_1.selectDefaultsKey)(ref, targetDefaults, executor)
|
|
88
|
-
: null;
|
|
89
|
-
const entries = (0, target_defaults_matching_1.compatibleDefaultsEntries)(ref, selectedKey, targetDefaults);
|
|
90
|
-
const defaults = entries.length
|
|
91
|
-
? (0, internal_1.readTargetDefaultsForTarget)(targetName, { [selectedKey]: entries }, ref.matcherExecutor, { projectName, projectNode })
|
|
92
|
-
: null;
|
|
93
|
-
// The effective view, not the target's own: the gating option may be
|
|
94
|
-
// supplied by a matching defaults entry or set only in a configuration.
|
|
95
|
-
const effective = (0, internal_1.mergeTargetConfigurations)(target, defaults ?? {});
|
|
96
|
-
if (!emitsDeployOutput(effective, DEPLOY_OUTPUT_EXECUTORS[executor])) {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
const changed = (0, pnpm_deploy_output_cache_inputs_1.addPnpmDeployOutputCacheInputs)(ref, targetDefaults, executor);
|
|
100
|
-
if (changed === 'target') {
|
|
101
|
-
changedProjects.add(projectName);
|
|
102
|
-
}
|
|
103
|
-
else if (changed === 'defaults') {
|
|
104
|
-
defaultsChanged = true;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
// Overlays of plugin-inferred build targets carry no executor, so the loop
|
|
109
|
-
// above cannot see them, yet a replacing `inputs` array in one discards the
|
|
110
|
-
// settings inputs the plugin generates. The plugin adds those inputs without
|
|
111
|
-
// knowing whether the config enables generatePackageJson (that lives inside
|
|
112
|
-
// the user's config file), so the overlay repair is equally unconditional.
|
|
113
|
-
// It appends the runtime probe even where the plugin omits it under a valid
|
|
114
|
-
// pnpm pin: the repair runs once and the pin can be removed later.
|
|
115
|
-
for (const ref of await inferredDeployTargetOverlayRefs(tree, nxJson, projects)) {
|
|
116
|
-
const changed = (0, pnpm_deploy_output_cache_inputs_1.addPnpmDeployOutputCacheInputsToInferredTargetOverlay)(ref, targetDefaults);
|
|
117
|
-
if (changed === 'target') {
|
|
118
|
-
changedProjects.add(ref.projectName);
|
|
119
|
-
}
|
|
120
|
-
else if (changed === 'defaults') {
|
|
121
|
-
defaultsChanged = true;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
for (const projectName of changedProjects) {
|
|
125
|
-
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projects.get(projectName));
|
|
126
|
-
}
|
|
127
|
-
if (defaultsChanged) {
|
|
128
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
129
|
-
}
|
|
20
|
+
await (0, deploy_output_cache_inputs_1.addDeployOutputCacheInputsToBuildTargets)(tree, pnpm_install_settings_inputs_1.PNPM_INSTALL_SETTINGS_INPUTS);
|
|
130
21
|
await (0, devkit_1.formatFiles)(tree);
|
|
131
22
|
}
|
|
132
|
-
/**
|
|
133
|
-
* One ref per (project, inferred build target) the registered `@nx/webpack` or
|
|
134
|
-
* `@nx/rspack` config-file plugins would create, resolved the way the plugins
|
|
135
|
-
* do: their createNodes glob filtered by each registration's include/exclude,
|
|
136
|
-
* the config file's directory as the project root, and the registration's
|
|
137
|
-
* `buildTargetName` option. The overlaying project-level entry may sit under
|
|
138
|
-
* the exact target name or a glob-pattern key matching it; one that replaces
|
|
139
|
-
* what the target runs disqualifies the target instead.
|
|
140
|
-
*/
|
|
141
|
-
async function inferredDeployTargetOverlayRefs(tree, nxJson, projects) {
|
|
142
|
-
const rootToProject = new Map();
|
|
143
|
-
for (const [projectName, project] of projects) {
|
|
144
|
-
rootToProject.set(project.root, projectName);
|
|
145
|
-
}
|
|
146
|
-
const refs = [];
|
|
147
|
-
for (const registration of nxJson?.plugins ?? []) {
|
|
148
|
-
const pluginName = typeof registration === 'string' ? registration : registration.plugin;
|
|
149
|
-
const inferredPlugin = INFERRED_DEPLOY_PLUGINS[pluginName];
|
|
150
|
-
if (!inferredPlugin) {
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
const options = typeof registration === 'string'
|
|
154
|
-
? undefined
|
|
155
|
-
: registration.options;
|
|
156
|
-
const targetName = options?.buildTargetName ?? 'build';
|
|
157
|
-
const configFiles = (0, internal_1.findMatchingConfigFiles)(await (0, devkit_1.globAsync)(tree, [inferredPlugin.configGlob]), typeof registration === 'string' ? undefined : registration.include, typeof registration === 'string' ? undefined : registration.exclude);
|
|
158
|
-
for (const configFile of configFiles) {
|
|
159
|
-
const projectName = rootToProject.get((0, path_1.dirname)(configFile));
|
|
160
|
-
if (!projectName) {
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
const project = projects.get(projectName);
|
|
164
|
-
const target = inferredTargetOverlayEntry(project.targets, targetName);
|
|
165
|
-
// An entry that changes what the target runs is not an overlay; the
|
|
166
|
-
// executor loop covers the deploy executors among those.
|
|
167
|
-
if (target &&
|
|
168
|
-
replacesInferredRunCommandsIdentity(target, inferredPlugin.command, project.root)) {
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
refs.push({
|
|
172
|
-
targetName,
|
|
173
|
-
projectName,
|
|
174
|
-
projectNode: {
|
|
175
|
-
name: projectName,
|
|
176
|
-
type: 'lib',
|
|
177
|
-
data: { root: project.root, tags: project.tags },
|
|
178
|
-
},
|
|
179
|
-
// the runtime matcher sees the plugin target's effective identity:
|
|
180
|
-
// its `command` payload resolves to nx:run-commands
|
|
181
|
-
matcherExecutor: 'nx:run-commands',
|
|
182
|
-
// the runtime drops the plugin attribution as soon as the project
|
|
183
|
-
// entry authors an executor or command, restated or not, so a
|
|
184
|
-
// plugin-filtered defaults entry no longer applies to the target
|
|
185
|
-
sourcePlugin: target?.executor !== undefined || target?.command !== undefined
|
|
186
|
-
? undefined
|
|
187
|
-
: pluginName,
|
|
188
|
-
target: target ?? {},
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return refs;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* The project-level entry that overlays the inferred `targetName`. Its key is
|
|
196
|
-
* the exact name or a glob pattern the name matches; the inferred target
|
|
197
|
-
* exists before any project-level entry merges, so a matching glob key
|
|
198
|
-
* overlays it too. When several keys match, each entry merges against the
|
|
199
|
-
* inferred target independently and the last write wins, so only the last
|
|
200
|
-
* one applies. A glob key matching an earlier same-file sibling never
|
|
201
|
-
* surfaces here: the project read already collapsed it onto that sibling and
|
|
202
|
-
* dropped the key.
|
|
203
|
-
*/
|
|
204
|
-
function inferredTargetOverlayEntry(targets, targetName) {
|
|
205
|
-
const matching = Object.entries(targets ?? {}).filter(([key]) => key === targetName ||
|
|
206
|
-
(0, internal_1.findMatchingTargetNames)(key, [targetName]).length > 0);
|
|
207
|
-
return matching[matching.length - 1]?.[1];
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Whether the entry changes what the inferred run-commands target runs when
|
|
211
|
-
* merged, resolved with nx's own merge so `"..."` placement and restated
|
|
212
|
-
* identities land the way the runtime lands them: a merged executor other
|
|
213
|
-
* than nx:run-commands, an effective command differing from the plugin's, or
|
|
214
|
-
* a `command`/`commands` clash the run-commands schema rejects. An entry
|
|
215
|
-
* restating the identity the plugin infers is still an overlay.
|
|
216
|
-
*/
|
|
217
|
-
function replacesInferredRunCommandsIdentity(target, inferredCommand, projectRoot) {
|
|
218
|
-
// `command` alongside `executor` fails graph construction outright;
|
|
219
|
-
// there is nothing running to repair.
|
|
220
|
-
if (target.command && target.executor) {
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
const merged = (0, internal_1.mergeTargetConfigurations)((0, internal_1.resolveCommandSyntacticSugar)(target, projectRoot), { executor: 'nx:run-commands', options: { command: inferredCommand } });
|
|
224
|
-
if (merged.executor !== 'nx:run-commands') {
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
// Both present fails the run-commands schema's oneOf; the target cannot run.
|
|
228
|
-
if (merged.options?.command && merged.options?.commands) {
|
|
229
|
-
return true;
|
|
230
|
-
}
|
|
231
|
-
const command = merged.options?.command ?? merged.options?.commands?.join(' && ');
|
|
232
|
-
return command !== inferredCommand;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Whether the target ships the deploy output in any of its runs: the gating
|
|
236
|
-
* option can sit in `options` or in any configuration, and `inputs` cannot
|
|
237
|
-
* vary per configuration, so one enabled configuration is enough.
|
|
238
|
-
*/
|
|
239
|
-
function emitsDeployOutput(effective, gate) {
|
|
240
|
-
return (Boolean(effective.options?.[gate]) ||
|
|
241
|
-
Object.values(effective.configurations ?? {}).some((configuration) => Boolean(configuration?.[gate])));
|
|
242
|
-
}
|