nx 21.1.0-beta.0 → 21.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/migrations.json +40 -0
- package/package.json +11 -14
- package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +3 -0
- package/src/command-line/init/implementation/utils.js +14 -0
- package/src/core/graph/main.js +1 -1
- package/src/daemon/client/client.js +1 -1
- package/src/migrations/update-17-0-0/move-cache-directory.d.ts +2 -0
- package/src/migrations/update-17-0-0/move-cache-directory.js +35 -0
- package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.d.ts +2 -0
- package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +72 -0
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.d.ts +2 -0
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +122 -0
- package/src/migrations/update-17-2-0/move-default-base.d.ts +5 -0
- package/src/migrations/update-17-2-0/move-default-base.js +21 -0
- package/src/migrations/update-17-3-0/nx-release-path.d.ts +3 -0
- package/src/migrations/update-17-3-0/nx-release-path.js +47 -0
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +2 -0
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +11 -0
- package/src/migrations/update-21-1-0/add-gitignore-entry.d.ts +2 -0
- package/src/migrations/update-21-1-0/add-gitignore-entry.js +24 -0
- package/src/native/index.d.ts +1 -1
- package/src/native/index.js +8 -3
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/project-graph/affected/lock-file-changes.d.ts +1 -0
- package/src/plugins/js/project-graph/affected/lock-file-changes.js +51 -11
- package/src/project-graph/file-utils.js +11 -0
- package/src/tasks-runner/run-command.js +1 -1
- package/src/tasks-runner/running-tasks/node-child-process.js +2 -2
@@ -0,0 +1,35 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = moveCacheDirectory;
|
4
|
+
const ignore_1 = require("ignore");
|
5
|
+
function moveCacheDirectory(tree) {
|
6
|
+
// If nx.json doesn't exist the repo can't utilize
|
7
|
+
// caching, so .nx/cache is less relevant. Lerna users
|
8
|
+
// that don't want to fully opt in to Nx at this time
|
9
|
+
// may also be caught off guard by the appearance of
|
10
|
+
// a .nx directory, so we are going to special case
|
11
|
+
// this for the time being.
|
12
|
+
if (tree.exists('lerna.json') && !tree.exists('nx.json')) {
|
13
|
+
return;
|
14
|
+
}
|
15
|
+
updateGitIgnore(tree);
|
16
|
+
if (tree.exists('.prettierignore')) {
|
17
|
+
const ignored = tree.read('.prettierignore', 'utf-8');
|
18
|
+
if (!ignored.includes('.nx/cache')) {
|
19
|
+
tree.write('.prettierignore', [ignored, '/.nx/cache'].join('\n'));
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
function updateGitIgnore(tree) {
|
24
|
+
const gitignore = tree.exists('.gitignore')
|
25
|
+
? tree.read('.gitignore', 'utf-8')
|
26
|
+
: '';
|
27
|
+
const ig = (0, ignore_1.default)();
|
28
|
+
ig.add(gitignore);
|
29
|
+
if (!ig.ignores('.nx/cache')) {
|
30
|
+
const updatedLines = gitignore.length
|
31
|
+
? [gitignore, '.nx/cache']
|
32
|
+
: ['.nx/cache'];
|
33
|
+
tree.write('.gitignore', updatedLines.join('\n'));
|
34
|
+
}
|
35
|
+
}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = update;
|
4
|
+
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
5
|
+
const nx_json_1 = require("../../generators/utils/nx-json");
|
6
|
+
const json_1 = require("../../generators/utils/json");
|
7
|
+
const output_1 = require("../../utils/output");
|
8
|
+
const path_1 = require("../../utils/path");
|
9
|
+
async function update(tree) {
|
10
|
+
if (!tree.exists('nx.json')) {
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
const nxJson = (0, nx_json_1.readNxJson)(tree);
|
14
|
+
delete nxJson.cli?.['defaultCollection'];
|
15
|
+
if (nxJson?.cli && Object.keys(nxJson.cli).length < 1) {
|
16
|
+
delete nxJson.cli;
|
17
|
+
}
|
18
|
+
warnNpmScopeHasChanged(tree, nxJson);
|
19
|
+
delete nxJson['npmScope'];
|
20
|
+
(0, nx_json_1.updateNxJson)(tree, nxJson);
|
21
|
+
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
|
22
|
+
}
|
23
|
+
function warnNpmScopeHasChanged(tree, nxJson) {
|
24
|
+
const originalScope = nxJson['npmScope'];
|
25
|
+
// There was no original scope
|
26
|
+
if (!originalScope) {
|
27
|
+
return false;
|
28
|
+
}
|
29
|
+
// package.json does not exist
|
30
|
+
if (!tree.exists('package.json')) {
|
31
|
+
return false;
|
32
|
+
}
|
33
|
+
const newScope = getNpmScopeFromPackageJson(tree);
|
34
|
+
// New and Original scope are the same.
|
35
|
+
if (originalScope === newScope) {
|
36
|
+
return false;
|
37
|
+
}
|
38
|
+
const packageJsonName = (0, json_1.readJson)(tree, 'package.json').name;
|
39
|
+
if (newScope) {
|
40
|
+
output_1.output.warn({
|
41
|
+
title: 'npmScope has been removed from nx.json',
|
42
|
+
bodyLines: [
|
43
|
+
'This will now be read from package.json',
|
44
|
+
`Old value which was in nx.json: ${originalScope}`,
|
45
|
+
`New value from package.json: ${newScope}`,
|
46
|
+
`Typescript path mappings for new libraries will now be generated as such: @${newScope}/new-lib instead of @${originalScope}/new-lib`,
|
47
|
+
`If you would like to change this back, change the name in package.json to ${packageJsonName.replace(newScope, originalScope)}`,
|
48
|
+
],
|
49
|
+
});
|
50
|
+
}
|
51
|
+
else {
|
52
|
+
// There is no scope in package.json
|
53
|
+
output_1.output.warn({
|
54
|
+
title: 'npmScope has been removed from nx.json',
|
55
|
+
bodyLines: [
|
56
|
+
'This will now be read from package.json',
|
57
|
+
`Old value which was in nx.json: ${originalScope}`,
|
58
|
+
`New value from package.json: null`,
|
59
|
+
`Typescript path mappings for new libraries will now be generated as such: new-lib instead of @${originalScope}/new-lib`,
|
60
|
+
`If you would like to change this back, change the name in package.json to ${(0, path_1.joinPathFragments)(`@${originalScope}`, packageJsonName)}`,
|
61
|
+
],
|
62
|
+
});
|
63
|
+
}
|
64
|
+
}
|
65
|
+
function getNpmScopeFromPackageJson(tree) {
|
66
|
+
const { name } = tree.exists('package.json')
|
67
|
+
? (0, json_1.readJson)(tree, 'package.json')
|
68
|
+
: { name: null };
|
69
|
+
if (name?.startsWith('@')) {
|
70
|
+
return name.split('/')[0].substring(1);
|
71
|
+
}
|
72
|
+
}
|
@@ -0,0 +1,122 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = migrate;
|
4
|
+
const json_1 = require("../../generators/utils/json");
|
5
|
+
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
6
|
+
const nx_json_1 = require("../../generators/utils/nx-json");
|
7
|
+
const update_manager_1 = require("../../nx-cloud/update-manager");
|
8
|
+
const run_command_1 = require("../../tasks-runner/run-command");
|
9
|
+
const output_1 = require("../../utils/output");
|
10
|
+
async function migrate(tree) {
|
11
|
+
if (!tree.exists('nx.json')) {
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
const nxJson = (0, nx_json_1.readNxJson)(tree);
|
15
|
+
// Already migrated
|
16
|
+
if (!nxJson.tasksRunnerOptions?.default) {
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
const nxCloudClientSupported = await isNxCloudClientSupported(nxJson);
|
20
|
+
(0, json_1.updateJson)(tree, 'nx.json', (nxJson) => {
|
21
|
+
const { runner, options } = nxJson.tasksRunnerOptions.default;
|
22
|
+
// This property shouldn't ever be part of tasks runner options.
|
23
|
+
if (options.useDaemonProcess !== undefined) {
|
24
|
+
nxJson.useDaemonProcess = options.useDaemonProcess;
|
25
|
+
delete options.useDaemonProcess;
|
26
|
+
}
|
27
|
+
// Remaining keys may be specific to a given runner, so leave them alone if there are multiple runners.
|
28
|
+
if (Object.keys(nxJson.tasksRunnerOptions ?? {}).length > 1) {
|
29
|
+
return nxJson;
|
30
|
+
}
|
31
|
+
// These options can only be moved for nx-cloud.
|
32
|
+
if (runner === 'nx-cloud' || runner === '@nrwl/nx-cloud') {
|
33
|
+
nxJson.nxCloudAccessToken = options.accessToken;
|
34
|
+
delete options.accessToken;
|
35
|
+
if (options.url) {
|
36
|
+
nxJson.nxCloudUrl = options.url;
|
37
|
+
delete options.url;
|
38
|
+
}
|
39
|
+
if (nxCloudClientSupported) {
|
40
|
+
removeNxCloudDependency(tree);
|
41
|
+
}
|
42
|
+
else {
|
43
|
+
options.useLightClient = false;
|
44
|
+
}
|
45
|
+
if (options.encryptionKey) {
|
46
|
+
nxJson.nxCloudEncryptionKey = options.encryptionKey;
|
47
|
+
delete options.encryptionKey;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
// These options should be safe to move for all tasks runners:
|
51
|
+
if (options.parallel !== undefined) {
|
52
|
+
nxJson.parallel = options.parallel;
|
53
|
+
delete options.parallel;
|
54
|
+
}
|
55
|
+
if (options.cacheDirectory !== undefined) {
|
56
|
+
nxJson.cacheDirectory = options.cacheDirectory;
|
57
|
+
delete options.cacheDirectory;
|
58
|
+
}
|
59
|
+
if (Array.isArray(options.cacheableOperations)) {
|
60
|
+
nxJson.targetDefaults ??= {};
|
61
|
+
for (const target of options.cacheableOperations) {
|
62
|
+
nxJson.targetDefaults[target] ??= {};
|
63
|
+
nxJson.targetDefaults[target].cache ??= true;
|
64
|
+
}
|
65
|
+
delete options.cacheableOperations;
|
66
|
+
}
|
67
|
+
if (['nx-cloud', '@nrwl/nx-cloud', 'nx/tasks-runners/default'].includes(runner)) {
|
68
|
+
delete nxJson.tasksRunnerOptions.default.runner;
|
69
|
+
if (Object.values(options).length === 0) {
|
70
|
+
delete nxJson.tasksRunnerOptions;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
return nxJson;
|
74
|
+
});
|
75
|
+
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
|
76
|
+
}
|
77
|
+
async function isNxCloudClientSupported(nxJson) {
|
78
|
+
const nxCloudOptions = (0, run_command_1.getRunnerOptions)('default', nxJson, {}, true);
|
79
|
+
// Non enterprise workspaces support the Nx Cloud Client
|
80
|
+
if (!isNxCloudEnterpriseWorkspace(nxJson)) {
|
81
|
+
return true;
|
82
|
+
}
|
83
|
+
// If we can get the nx cloud client, it's supported
|
84
|
+
try {
|
85
|
+
await (0, update_manager_1.verifyOrUpdateNxCloudClient)(nxCloudOptions);
|
86
|
+
return true;
|
87
|
+
}
|
88
|
+
catch (e) {
|
89
|
+
if (e instanceof update_manager_1.NxCloudEnterpriseOutdatedError) {
|
90
|
+
output_1.output.warn({
|
91
|
+
title: 'Nx Cloud Instance is outdated.',
|
92
|
+
bodyLines: [
|
93
|
+
'If you are an Nx Enterprise customer, please reach out to your assigned Developer Productivity Engineer.',
|
94
|
+
'If you are NOT an Nx Enterprise customer but are seeing this message, please reach out to cloud-support@nrwl.io.',
|
95
|
+
],
|
96
|
+
});
|
97
|
+
}
|
98
|
+
return false;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
function isNxCloudEnterpriseWorkspace(nxJson) {
|
102
|
+
const { runner, options } = nxJson.tasksRunnerOptions.default;
|
103
|
+
return ((runner === 'nx-cloud' || runner === '@nrwl/nx-cloud') &&
|
104
|
+
options.url &&
|
105
|
+
![
|
106
|
+
'https://nx.app',
|
107
|
+
'https://cloud.nx.app',
|
108
|
+
'https://staging.nx.app',
|
109
|
+
'https://snapshot.nx.app',
|
110
|
+
].includes(options.url));
|
111
|
+
}
|
112
|
+
function removeNxCloudDependency(tree) {
|
113
|
+
if (tree.exists('package.json')) {
|
114
|
+
(0, json_1.updateJson)(tree, 'package.json', (packageJson) => {
|
115
|
+
delete packageJson.dependencies?.['nx-cloud'];
|
116
|
+
delete packageJson.devDependencies?.['nx-cloud'];
|
117
|
+
delete packageJson.dependencies?.['@nrwl/nx-cloud'];
|
118
|
+
delete packageJson.devDependencies?.['@nrwl/nx-cloud'];
|
119
|
+
return packageJson;
|
120
|
+
});
|
121
|
+
}
|
122
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = update;
|
4
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
5
|
+
const nx_json_1 = require("../../generators/utils/nx-json");
|
6
|
+
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
7
|
+
/**
|
8
|
+
* Updates existing workspaces to move nx.json's affected.defaultBase to nx.json's base.
|
9
|
+
*/
|
10
|
+
async function update(host) {
|
11
|
+
const nxJson = (0, nx_json_1.readNxJson)(host);
|
12
|
+
if (nxJson?.affected?.defaultBase) {
|
13
|
+
nxJson.defaultBase = nxJson.affected.defaultBase;
|
14
|
+
delete nxJson.affected.defaultBase;
|
15
|
+
if (Object.keys(nxJson.affected).length === 0) {
|
16
|
+
delete nxJson.affected;
|
17
|
+
}
|
18
|
+
(0, nx_json_1.updateNxJson)(host, nxJson);
|
19
|
+
}
|
20
|
+
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(host);
|
21
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = nxReleasePath;
|
4
|
+
exports.visitNotIgnoredFiles = visitNotIgnoredFiles;
|
5
|
+
const node_path_1 = require("node:path");
|
6
|
+
const ignore_1 = require("../../utils/ignore");
|
7
|
+
function nxReleasePath(tree) {
|
8
|
+
visitNotIgnoredFiles(tree, '', (file) => {
|
9
|
+
const contents = tree.read(file).toString('utf-8');
|
10
|
+
if (
|
11
|
+
// the deep import usage should be replaced by the new location
|
12
|
+
contents.includes('nx/src/command-line/release') ||
|
13
|
+
// changelog-renderer has moved into nx/release
|
14
|
+
contents.includes('nx/changelog-renderer')) {
|
15
|
+
const finalContents = contents
|
16
|
+
// replace instances of old changelog renderer location
|
17
|
+
.replace(/nx\/changelog-renderer/g, 'nx/release/changelog-renderer')
|
18
|
+
// replace instances of deep import for programmatic API (only perform the replacement if an actual import by checking for trailing ' or ")
|
19
|
+
.replace(/nx\/src\/command-line\/release(['"])/g, 'nx/release$1');
|
20
|
+
tree.write(file, finalContents);
|
21
|
+
}
|
22
|
+
});
|
23
|
+
}
|
24
|
+
// Adapted from devkit
|
25
|
+
function visitNotIgnoredFiles(tree, dirPath = tree.root, visitor) {
|
26
|
+
const ig = (0, ignore_1.getIgnoreObject)();
|
27
|
+
dirPath = normalizePathRelativeToRoot(dirPath, tree.root);
|
28
|
+
if (dirPath !== '' && ig?.ignores(dirPath)) {
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
for (const child of tree.children(dirPath)) {
|
32
|
+
const fullPath = (0, node_path_1.join)(dirPath, child);
|
33
|
+
if (ig?.ignores(fullPath)) {
|
34
|
+
continue;
|
35
|
+
}
|
36
|
+
if (tree.isFile(fullPath)) {
|
37
|
+
visitor(fullPath);
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
visitNotIgnoredFiles(tree, fullPath, visitor);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
// Copied from devkit
|
45
|
+
function normalizePathRelativeToRoot(path, root) {
|
46
|
+
return (0, node_path_1.relative)(root, (0, node_path_1.join)(root, path)).split(node_path_1.sep).join('/');
|
47
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = migrate;
|
4
|
+
const nx_json_1 = require("../../generators/utils/nx-json");
|
5
|
+
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
6
|
+
async function migrate(tree) {
|
7
|
+
const nxJson = (0, nx_json_1.readNxJson)(tree);
|
8
|
+
nxJson.useInferencePlugins = false;
|
9
|
+
(0, nx_json_1.updateNxJson)(tree, nxJson);
|
10
|
+
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
|
11
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = addGitignoreEntry;
|
4
|
+
const ignore_1 = require("ignore");
|
5
|
+
async function addGitignoreEntry(tree) {
|
6
|
+
if (!tree.exists('nx.json')) {
|
7
|
+
return;
|
8
|
+
}
|
9
|
+
const GITIGNORE_ENTRIES = [
|
10
|
+
'.cursor/rules/nx-rules.mdc',
|
11
|
+
'.github/instructions/nx.instructions.md',
|
12
|
+
];
|
13
|
+
if (!tree.exists('.gitignore')) {
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
let content = tree.read('.gitignore', 'utf-8') || '';
|
17
|
+
const ig = (0, ignore_1.default)().add(content);
|
18
|
+
for (const entry of GITIGNORE_ENTRIES) {
|
19
|
+
if (!ig.ignores(entry)) {
|
20
|
+
content = content.trimEnd() + '\n' + entry + '\n';
|
21
|
+
}
|
22
|
+
}
|
23
|
+
tree.write('.gitignore', content);
|
24
|
+
}
|
package/src/native/index.d.ts
CHANGED
@@ -8,7 +8,7 @@ export declare class ExternalObject<T> {
|
|
8
8
|
}
|
9
9
|
}
|
10
10
|
export declare class AppLifeCycle {
|
11
|
-
constructor(tasks: Array<Task>, initiatingTasks: Array<string>, runMode: RunMode, pinnedTasks: Array<string>, tuiCliArgs: TuiCliArgs, tuiConfig: TuiConfig, titleText: string)
|
11
|
+
constructor(tasks: Array<Task>, initiatingTasks: Array<string>, runMode: RunMode, pinnedTasks: Array<string>, tuiCliArgs: TuiCliArgs, tuiConfig: TuiConfig, titleText: string, workspaceRoot: string)
|
12
12
|
startCommand(threadCount?: number | undefined | null): void
|
13
13
|
scheduleTask(task: Task): void
|
14
14
|
startTasks(tasks: Array<Task>, metadata: object): void
|
package/src/native/index.js
CHANGED
@@ -62,10 +62,15 @@ const originalLoad = Module._load;
|
|
62
62
|
// Will only be called once because the require cache takes over afterwards.
|
63
63
|
Module._load = function (request, parent, isMain) {
|
64
64
|
const modulePath = request;
|
65
|
-
if (
|
65
|
+
// Check if we should use the native file cache (enabled by default)
|
66
|
+
const useNativeFileCache = process.env.NX_SKIP_NATIVE_FILE_CACHE !== 'true';
|
67
|
+
// Check if this is an Nx native module (either from npm or local file)
|
68
|
+
const isNxNativeModule =
|
66
69
|
nxPackages.has(modulePath) ||
|
67
|
-
localNodeFiles.some((
|
68
|
-
|
70
|
+
localNodeFiles.some((file) => modulePath.endsWith(file));
|
71
|
+
|
72
|
+
// Only use the file cache for Nx native modules when caching is enabled
|
73
|
+
if (useNativeFileCache && isNxNativeModule) {
|
69
74
|
const nativeLocation = require.resolve(modulePath);
|
70
75
|
const fileName = basename(nativeLocation);
|
71
76
|
|
Binary file
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { TouchedProjectLocator } from '../../../../project-graph/affected/affected-project-graph-models';
|
2
2
|
import { WholeFileChange } from '../../../../project-graph/file-utils';
|
3
3
|
import { JsonChange } from '../../../../utils/json-diff';
|
4
|
+
export declare const PNPM_LOCK_FILES: string[];
|
4
5
|
export declare const getTouchedProjectsFromLockFile: TouchedProjectLocator<WholeFileChange | JsonChange>;
|
@@ -1,29 +1,69 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getTouchedProjectsFromLockFile = void 0;
|
3
|
+
exports.getTouchedProjectsFromLockFile = exports.PNPM_LOCK_FILES = void 0;
|
4
4
|
const configuration_1 = require("../../../../config/configuration");
|
5
|
+
const json_diff_1 = require("../../../../utils/json-diff");
|
5
6
|
const config_1 = require("../../utils/config");
|
6
7
|
const find_matching_projects_1 = require("../../../../utils/find-matching-projects");
|
8
|
+
exports.PNPM_LOCK_FILES = ['pnpm-lock.yaml', 'pnpm-lock.yml'];
|
9
|
+
const ALL_LOCK_FILES = [
|
10
|
+
...exports.PNPM_LOCK_FILES,
|
11
|
+
'package-lock.json',
|
12
|
+
'yarn.lock',
|
13
|
+
'bun.lockb',
|
14
|
+
'bun.lock',
|
15
|
+
];
|
7
16
|
const getTouchedProjectsFromLockFile = (fileChanges, projectGraphNodes) => {
|
8
17
|
const nxJson = (0, configuration_1.readNxJson)();
|
9
18
|
const { projectsAffectedByDependencyUpdates } = (0, config_1.jsPluginConfig)(nxJson);
|
19
|
+
const changedLockFile = fileChanges.find((f) => ALL_LOCK_FILES.includes(f.file));
|
10
20
|
if (projectsAffectedByDependencyUpdates === 'auto') {
|
11
|
-
|
21
|
+
const changedProjectPaths = getProjectPathsAffectedByDependencyUpdates(changedLockFile);
|
22
|
+
const changedProjectNames = getProjectsNamesFromPaths(projectGraphNodes, changedProjectPaths);
|
23
|
+
return changedProjectNames;
|
12
24
|
}
|
13
25
|
else if (Array.isArray(projectsAffectedByDependencyUpdates)) {
|
14
26
|
return (0, find_matching_projects_1.findMatchingProjects)(projectsAffectedByDependencyUpdates, projectGraphNodes);
|
15
27
|
}
|
16
|
-
|
17
|
-
'package-lock.json',
|
18
|
-
'yarn.lock',
|
19
|
-
'pnpm-lock.yaml',
|
20
|
-
'pnpm-lock.yml',
|
21
|
-
'bun.lockb',
|
22
|
-
'bun.lock',
|
23
|
-
];
|
24
|
-
if (fileChanges.some((f) => lockFiles.includes(f.file))) {
|
28
|
+
if (changedLockFile) {
|
25
29
|
return Object.values(projectGraphNodes).map((p) => p.name);
|
26
30
|
}
|
27
31
|
return [];
|
28
32
|
};
|
29
33
|
exports.getTouchedProjectsFromLockFile = getTouchedProjectsFromLockFile;
|
34
|
+
/**
|
35
|
+
* For pnpm projects, check lock file for changes to importers and return the project paths that have changes.
|
36
|
+
*/
|
37
|
+
const getProjectPathsAffectedByDependencyUpdates = (changedLockFile) => {
|
38
|
+
if (!changedLockFile) {
|
39
|
+
return [];
|
40
|
+
}
|
41
|
+
const changedProjectPaths = new Set();
|
42
|
+
if (exports.PNPM_LOCK_FILES.includes(changedLockFile.file)) {
|
43
|
+
for (const change of changedLockFile.getChanges()) {
|
44
|
+
if ((0, json_diff_1.isJsonChange)(change) &&
|
45
|
+
change.path[0] === 'importers' &&
|
46
|
+
change.path[1] !== undefined) {
|
47
|
+
changedProjectPaths.add(change.path[1]);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
return Array.from(changedProjectPaths);
|
52
|
+
};
|
53
|
+
const getProjectsNamesFromPaths = (projectGraphNodes, projectPaths) => {
|
54
|
+
const lookup = new RootPathLookup(projectGraphNodes);
|
55
|
+
return projectPaths.map((path) => {
|
56
|
+
return lookup.findNodeNameByRoot(path);
|
57
|
+
});
|
58
|
+
};
|
59
|
+
class RootPathLookup {
|
60
|
+
constructor(nodes) {
|
61
|
+
this.rootToNameMap = new Map();
|
62
|
+
Object.entries(nodes).forEach(([name, node]) => {
|
63
|
+
this.rootToNameMap.set(node.data.root, name);
|
64
|
+
});
|
65
|
+
}
|
66
|
+
findNodeNameByRoot(root) {
|
67
|
+
return this.rootToNameMap.get(root);
|
68
|
+
}
|
69
|
+
}
|
@@ -61,6 +61,17 @@ function calculateFileChanges(files, allWorkspaceFiles, nxArgs, readFileAtRevisi
|
|
61
61
|
catch (e) {
|
62
62
|
return [new WholeFileChange()];
|
63
63
|
}
|
64
|
+
case '.yml':
|
65
|
+
case '.yaml':
|
66
|
+
const { load } = require('@zkochan/js-yaml');
|
67
|
+
try {
|
68
|
+
const atBase = readFileAtRevision(f, nxArgs.base);
|
69
|
+
const atHead = readFileAtRevision(f, nxArgs.head);
|
70
|
+
return (0, json_diff_1.jsonDiff)(load(atBase), load(atHead));
|
71
|
+
}
|
72
|
+
catch (e) {
|
73
|
+
return [new WholeFileChange()];
|
74
|
+
}
|
64
75
|
default:
|
65
76
|
return [new WholeFileChange()];
|
66
77
|
}
|
@@ -128,7 +128,7 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
|
|
128
128
|
const lifeCycles = [tsLifeCycle];
|
129
129
|
// Only run the TUI if there are tasks to run
|
130
130
|
if (tasks.length > 0) {
|
131
|
-
appLifeCycle = new AppLifeCycle(tasks, initiatingTasks.map((t) => t.id), isRunOne ? 0 /* RunMode.RunOne */ : 1 /* RunMode.RunMany */, pinnedTasks, nxArgs ?? {}, nxJson.tui ?? {}, titleText);
|
131
|
+
appLifeCycle = new AppLifeCycle(tasks, initiatingTasks.map((t) => t.id), isRunOne ? 0 /* RunMode.RunOne */ : 1 /* RunMode.RunMany */, pinnedTasks, nxArgs ?? {}, nxJson.tui ?? {}, titleText, workspace_root_1.workspaceRoot);
|
132
132
|
lifeCycles.unshift(appLifeCycle);
|
133
133
|
/**
|
134
134
|
* Patch stdout.write and stderr.write methods to pass Nx Cloud client logs to the TUI via the lifecycle
|