nx 21.0.3 → 21.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/migrations.json +35 -0
  2. package/package.json +11 -14
  3. package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +3 -0
  4. package/src/command-line/init/init-v1.js +1 -1
  5. package/src/core/graph/main.js +1 -1
  6. package/src/daemon/client/client.js +1 -1
  7. package/src/migrations/update-17-0-0/move-cache-directory.d.ts +2 -0
  8. package/src/migrations/update-17-0-0/move-cache-directory.js +35 -0
  9. package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.d.ts +2 -0
  10. package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +72 -0
  11. package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.d.ts +2 -0
  12. package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +122 -0
  13. package/src/migrations/update-17-2-0/move-default-base.d.ts +5 -0
  14. package/src/migrations/update-17-2-0/move-default-base.js +21 -0
  15. package/src/migrations/update-17-3-0/nx-release-path.d.ts +3 -0
  16. package/src/migrations/update-17-3-0/nx-release-path.js +47 -0
  17. package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +2 -0
  18. package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +11 -0
  19. package/src/native/index.d.ts +4 -0
  20. package/src/native/native-bindings.js +2 -0
  21. package/src/native/nx.wasi-browser.js +41 -37
  22. package/src/native/nx.wasi.cjs +41 -37
  23. package/src/native/nx.wasm32-wasi.wasm +0 -0
  24. package/src/tasks-runner/run-command.js +15 -4
  25. package/src/tasks-runner/running-tasks/node-child-process.js +2 -2
  26. package/src/utils/find-matching-projects.js +1 -1
@@ -277,7 +277,7 @@ class DaemonClient {
277
277
  type: task_history_1.RECORD_TASK_RUNS,
278
278
  taskRuns,
279
279
  };
280
- return this.sendMessageToDaemon(message);
280
+ return this.sendToDaemonViaQueue(message);
281
281
  }
282
282
  getSyncGeneratorChanges(generators) {
283
283
  const message = {
@@ -0,0 +1,2 @@
1
+ import { Tree } from '../../generators/tree';
2
+ export default function moveCacheDirectory(tree: Tree): void;
@@ -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,2 @@
1
+ import { Tree } from '../../generators/tree';
2
+ export default function update(tree: Tree): Promise<void>;
@@ -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,2 @@
1
+ import { Tree } from '../../generators/tree';
2
+ export default function migrate(tree: Tree): Promise<void>;
@@ -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,5 @@
1
+ import { Tree } from '../../generators/tree';
2
+ /**
3
+ * Updates existing workspaces to move nx.json's affected.defaultBase to nx.json's base.
4
+ */
5
+ export default function update(host: Tree): Promise<void>;
@@ -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,3 @@
1
+ import { Tree } from '../../generators/tree';
2
+ export default function nxReleasePath(tree: Tree): void;
3
+ export declare function visitNotIgnoredFiles(tree: Tree, dirPath: string, visitor: (path: string) => void): void;
@@ -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,2 @@
1
+ import { Tree } from '../../generators/tree';
2
+ export default function migrate(tree: Tree): Promise<void>;
@@ -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
+ }
@@ -237,6 +237,10 @@ export interface InputsInput {
237
237
 
238
238
  export const IS_WASM: boolean
239
239
 
240
+ export declare export declare function logError(message: string): void
241
+
242
+ export declare export declare function logInfo(message: string): void
243
+
240
244
  /** Stripped version of the NxJson interface for use in rust */
241
245
  export interface NxJson {
242
246
  namedInputs?: Record<string, Array<JsInputs>>
@@ -388,6 +388,8 @@ module.exports.getTransformableOutputs = nativeBinding.getTransformableOutputs
388
388
  module.exports.hashArray = nativeBinding.hashArray
389
389
  module.exports.hashFile = nativeBinding.hashFile
390
390
  module.exports.IS_WASM = nativeBinding.IS_WASM
391
+ module.exports.logError = nativeBinding.logError
392
+ module.exports.logInfo = nativeBinding.logInfo
391
393
  module.exports.parseTaskStatus = nativeBinding.parseTaskStatus
392
394
  module.exports.remove = nativeBinding.remove
393
395
  module.exports.restoreTerminal = nativeBinding.restoreTerminal
@@ -59,43 +59,45 @@ function __napi_rs_initialize_modules(__napiInstance) {
59
59
  __napiInstance.exports['__napi_register__get_transformable_outputs_5']?.()
60
60
  __napiInstance.exports['__napi_register__hash_array_6']?.()
61
61
  __napiInstance.exports['__napi_register__hash_file_7']?.()
62
- __napiInstance.exports['__napi_register__IS_WASM_8']?.()
63
- __napiInstance.exports['__napi_register__get_binary_target_9']?.()
64
- __napiInstance.exports['__napi_register__ImportResult_struct_10']?.()
65
- __napiInstance.exports['__napi_register__find_imports_11']?.()
66
- __napiInstance.exports['__napi_register__transfer_project_graph_12']?.()
67
- __napiInstance.exports['__napi_register__ExternalNode_struct_13']?.()
68
- __napiInstance.exports['__napi_register__Target_struct_14']?.()
69
- __napiInstance.exports['__napi_register__Project_struct_15']?.()
70
- __napiInstance.exports['__napi_register__ProjectGraph_struct_16']?.()
71
- __napiInstance.exports['__napi_register__HashPlanner_struct_17']?.()
72
- __napiInstance.exports['__napi_register__HashPlanner_impl_21']?.()
73
- __napiInstance.exports['__napi_register__HashDetails_struct_22']?.()
74
- __napiInstance.exports['__napi_register__HasherOptions_struct_23']?.()
75
- __napiInstance.exports['__napi_register__TaskHasher_struct_24']?.()
76
- __napiInstance.exports['__napi_register__TaskHasher_impl_27']?.()
77
- __napiInstance.exports['__napi_register__Task_struct_28']?.()
78
- __napiInstance.exports['__napi_register__TaskTarget_struct_29']?.()
79
- __napiInstance.exports['__napi_register__TaskResult_struct_30']?.()
80
- __napiInstance.exports['__napi_register__TaskGraph_struct_31']?.()
81
- __napiInstance.exports['__napi_register__FileData_struct_32']?.()
82
- __napiInstance.exports['__napi_register__InputsInput_struct_33']?.()
83
- __napiInstance.exports['__napi_register__FileSetInput_struct_34']?.()
84
- __napiInstance.exports['__napi_register__RuntimeInput_struct_35']?.()
85
- __napiInstance.exports['__napi_register__EnvironmentInput_struct_36']?.()
86
- __napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_37']?.()
87
- __napiInstance.exports['__napi_register__DepsOutputsInput_struct_38']?.()
88
- __napiInstance.exports['__napi_register__NxJson_struct_39']?.()
89
- __napiInstance.exports['__napi_register__FileLock_struct_40']?.()
90
- __napiInstance.exports['__napi_register__FileLock_impl_42']?.()
91
- __napiInstance.exports['__napi_register__WorkspaceContext_struct_43']?.()
92
- __napiInstance.exports['__napi_register__WorkspaceContext_impl_54']?.()
93
- __napiInstance.exports['__napi_register__WorkspaceErrors_55']?.()
94
- __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_56']?.()
95
- __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_57']?.()
96
- __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_58']?.()
97
- __napiInstance.exports['__napi_register__FileMap_struct_59']?.()
98
- __napiInstance.exports['__napi_register____test_only_transfer_file_map_60']?.()
62
+ __napiInstance.exports['__napi_register__log_info_8']?.()
63
+ __napiInstance.exports['__napi_register__log_error_9']?.()
64
+ __napiInstance.exports['__napi_register__IS_WASM_10']?.()
65
+ __napiInstance.exports['__napi_register__get_binary_target_11']?.()
66
+ __napiInstance.exports['__napi_register__ImportResult_struct_12']?.()
67
+ __napiInstance.exports['__napi_register__find_imports_13']?.()
68
+ __napiInstance.exports['__napi_register__transfer_project_graph_14']?.()
69
+ __napiInstance.exports['__napi_register__ExternalNode_struct_15']?.()
70
+ __napiInstance.exports['__napi_register__Target_struct_16']?.()
71
+ __napiInstance.exports['__napi_register__Project_struct_17']?.()
72
+ __napiInstance.exports['__napi_register__ProjectGraph_struct_18']?.()
73
+ __napiInstance.exports['__napi_register__HashPlanner_struct_19']?.()
74
+ __napiInstance.exports['__napi_register__HashPlanner_impl_23']?.()
75
+ __napiInstance.exports['__napi_register__HashDetails_struct_24']?.()
76
+ __napiInstance.exports['__napi_register__HasherOptions_struct_25']?.()
77
+ __napiInstance.exports['__napi_register__TaskHasher_struct_26']?.()
78
+ __napiInstance.exports['__napi_register__TaskHasher_impl_29']?.()
79
+ __napiInstance.exports['__napi_register__Task_struct_30']?.()
80
+ __napiInstance.exports['__napi_register__TaskTarget_struct_31']?.()
81
+ __napiInstance.exports['__napi_register__TaskResult_struct_32']?.()
82
+ __napiInstance.exports['__napi_register__TaskGraph_struct_33']?.()
83
+ __napiInstance.exports['__napi_register__FileData_struct_34']?.()
84
+ __napiInstance.exports['__napi_register__InputsInput_struct_35']?.()
85
+ __napiInstance.exports['__napi_register__FileSetInput_struct_36']?.()
86
+ __napiInstance.exports['__napi_register__RuntimeInput_struct_37']?.()
87
+ __napiInstance.exports['__napi_register__EnvironmentInput_struct_38']?.()
88
+ __napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_39']?.()
89
+ __napiInstance.exports['__napi_register__DepsOutputsInput_struct_40']?.()
90
+ __napiInstance.exports['__napi_register__NxJson_struct_41']?.()
91
+ __napiInstance.exports['__napi_register__FileLock_struct_42']?.()
92
+ __napiInstance.exports['__napi_register__FileLock_impl_44']?.()
93
+ __napiInstance.exports['__napi_register__WorkspaceContext_struct_45']?.()
94
+ __napiInstance.exports['__napi_register__WorkspaceContext_impl_56']?.()
95
+ __napiInstance.exports['__napi_register__WorkspaceErrors_57']?.()
96
+ __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_58']?.()
97
+ __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_59']?.()
98
+ __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_60']?.()
99
+ __napiInstance.exports['__napi_register__FileMap_struct_61']?.()
100
+ __napiInstance.exports['__napi_register____test_only_transfer_file_map_62']?.()
99
101
  }
100
102
  export const FileLock = __napiModule.exports.FileLock
101
103
  export const HashPlanner = __napiModule.exports.HashPlanner
@@ -111,6 +113,8 @@ export const getTransformableOutputs = __napiModule.exports.getTransformableOutp
111
113
  export const hashArray = __napiModule.exports.hashArray
112
114
  export const hashFile = __napiModule.exports.hashFile
113
115
  export const IS_WASM = __napiModule.exports.IS_WASM
116
+ export const logError = __napiModule.exports.logError
117
+ export const logInfo = __napiModule.exports.logInfo
114
118
  export const remove = __napiModule.exports.remove
115
119
  export const testOnlyTransferFileMap = __napiModule.exports.testOnlyTransferFileMap
116
120
  export const transferProjectGraph = __napiModule.exports.transferProjectGraph
@@ -90,43 +90,45 @@ function __napi_rs_initialize_modules(__napiInstance) {
90
90
  __napiInstance.exports['__napi_register__get_transformable_outputs_5']?.()
91
91
  __napiInstance.exports['__napi_register__hash_array_6']?.()
92
92
  __napiInstance.exports['__napi_register__hash_file_7']?.()
93
- __napiInstance.exports['__napi_register__IS_WASM_8']?.()
94
- __napiInstance.exports['__napi_register__get_binary_target_9']?.()
95
- __napiInstance.exports['__napi_register__ImportResult_struct_10']?.()
96
- __napiInstance.exports['__napi_register__find_imports_11']?.()
97
- __napiInstance.exports['__napi_register__transfer_project_graph_12']?.()
98
- __napiInstance.exports['__napi_register__ExternalNode_struct_13']?.()
99
- __napiInstance.exports['__napi_register__Target_struct_14']?.()
100
- __napiInstance.exports['__napi_register__Project_struct_15']?.()
101
- __napiInstance.exports['__napi_register__ProjectGraph_struct_16']?.()
102
- __napiInstance.exports['__napi_register__HashPlanner_struct_17']?.()
103
- __napiInstance.exports['__napi_register__HashPlanner_impl_21']?.()
104
- __napiInstance.exports['__napi_register__HashDetails_struct_22']?.()
105
- __napiInstance.exports['__napi_register__HasherOptions_struct_23']?.()
106
- __napiInstance.exports['__napi_register__TaskHasher_struct_24']?.()
107
- __napiInstance.exports['__napi_register__TaskHasher_impl_27']?.()
108
- __napiInstance.exports['__napi_register__Task_struct_28']?.()
109
- __napiInstance.exports['__napi_register__TaskTarget_struct_29']?.()
110
- __napiInstance.exports['__napi_register__TaskResult_struct_30']?.()
111
- __napiInstance.exports['__napi_register__TaskGraph_struct_31']?.()
112
- __napiInstance.exports['__napi_register__FileData_struct_32']?.()
113
- __napiInstance.exports['__napi_register__InputsInput_struct_33']?.()
114
- __napiInstance.exports['__napi_register__FileSetInput_struct_34']?.()
115
- __napiInstance.exports['__napi_register__RuntimeInput_struct_35']?.()
116
- __napiInstance.exports['__napi_register__EnvironmentInput_struct_36']?.()
117
- __napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_37']?.()
118
- __napiInstance.exports['__napi_register__DepsOutputsInput_struct_38']?.()
119
- __napiInstance.exports['__napi_register__NxJson_struct_39']?.()
120
- __napiInstance.exports['__napi_register__FileLock_struct_40']?.()
121
- __napiInstance.exports['__napi_register__FileLock_impl_42']?.()
122
- __napiInstance.exports['__napi_register__WorkspaceContext_struct_43']?.()
123
- __napiInstance.exports['__napi_register__WorkspaceContext_impl_54']?.()
124
- __napiInstance.exports['__napi_register__WorkspaceErrors_55']?.()
125
- __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_56']?.()
126
- __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_57']?.()
127
- __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_58']?.()
128
- __napiInstance.exports['__napi_register__FileMap_struct_59']?.()
129
- __napiInstance.exports['__napi_register____test_only_transfer_file_map_60']?.()
93
+ __napiInstance.exports['__napi_register__log_info_8']?.()
94
+ __napiInstance.exports['__napi_register__log_error_9']?.()
95
+ __napiInstance.exports['__napi_register__IS_WASM_10']?.()
96
+ __napiInstance.exports['__napi_register__get_binary_target_11']?.()
97
+ __napiInstance.exports['__napi_register__ImportResult_struct_12']?.()
98
+ __napiInstance.exports['__napi_register__find_imports_13']?.()
99
+ __napiInstance.exports['__napi_register__transfer_project_graph_14']?.()
100
+ __napiInstance.exports['__napi_register__ExternalNode_struct_15']?.()
101
+ __napiInstance.exports['__napi_register__Target_struct_16']?.()
102
+ __napiInstance.exports['__napi_register__Project_struct_17']?.()
103
+ __napiInstance.exports['__napi_register__ProjectGraph_struct_18']?.()
104
+ __napiInstance.exports['__napi_register__HashPlanner_struct_19']?.()
105
+ __napiInstance.exports['__napi_register__HashPlanner_impl_23']?.()
106
+ __napiInstance.exports['__napi_register__HashDetails_struct_24']?.()
107
+ __napiInstance.exports['__napi_register__HasherOptions_struct_25']?.()
108
+ __napiInstance.exports['__napi_register__TaskHasher_struct_26']?.()
109
+ __napiInstance.exports['__napi_register__TaskHasher_impl_29']?.()
110
+ __napiInstance.exports['__napi_register__Task_struct_30']?.()
111
+ __napiInstance.exports['__napi_register__TaskTarget_struct_31']?.()
112
+ __napiInstance.exports['__napi_register__TaskResult_struct_32']?.()
113
+ __napiInstance.exports['__napi_register__TaskGraph_struct_33']?.()
114
+ __napiInstance.exports['__napi_register__FileData_struct_34']?.()
115
+ __napiInstance.exports['__napi_register__InputsInput_struct_35']?.()
116
+ __napiInstance.exports['__napi_register__FileSetInput_struct_36']?.()
117
+ __napiInstance.exports['__napi_register__RuntimeInput_struct_37']?.()
118
+ __napiInstance.exports['__napi_register__EnvironmentInput_struct_38']?.()
119
+ __napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_39']?.()
120
+ __napiInstance.exports['__napi_register__DepsOutputsInput_struct_40']?.()
121
+ __napiInstance.exports['__napi_register__NxJson_struct_41']?.()
122
+ __napiInstance.exports['__napi_register__FileLock_struct_42']?.()
123
+ __napiInstance.exports['__napi_register__FileLock_impl_44']?.()
124
+ __napiInstance.exports['__napi_register__WorkspaceContext_struct_45']?.()
125
+ __napiInstance.exports['__napi_register__WorkspaceContext_impl_56']?.()
126
+ __napiInstance.exports['__napi_register__WorkspaceErrors_57']?.()
127
+ __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_58']?.()
128
+ __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_59']?.()
129
+ __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_60']?.()
130
+ __napiInstance.exports['__napi_register__FileMap_struct_61']?.()
131
+ __napiInstance.exports['__napi_register____test_only_transfer_file_map_62']?.()
130
132
  }
131
133
  module.exports.FileLock = __napiModule.exports.FileLock
132
134
  module.exports.HashPlanner = __napiModule.exports.HashPlanner
@@ -142,6 +144,8 @@ module.exports.getTransformableOutputs = __napiModule.exports.getTransformableOu
142
144
  module.exports.hashArray = __napiModule.exports.hashArray
143
145
  module.exports.hashFile = __napiModule.exports.hashFile
144
146
  module.exports.IS_WASM = __napiModule.exports.IS_WASM
147
+ module.exports.logError = __napiModule.exports.logError
148
+ module.exports.logInfo = __napiModule.exports.logInfo
145
149
  module.exports.remove = __napiModule.exports.remove
146
150
  module.exports.testOnlyTransferFileMap = __napiModule.exports.testOnlyTransferFileMap
147
151
  module.exports.transferProjectGraph = __napiModule.exports.transferProjectGraph
Binary file
@@ -15,6 +15,7 @@ const nx_json_1 = require("../config/nx-json");
15
15
  const client_1 = require("../daemon/client/client");
16
16
  const create_task_hasher_1 = require("../hasher/create-task-hasher");
17
17
  const hash_task_1 = require("../hasher/hash-task");
18
+ const native_1 = require("../native");
18
19
  const tasks_execution_hooks_1 = require("../project-graph/plugins/tasks-execution-hooks");
19
20
  const project_graph_1 = require("../project-graph/project-graph");
20
21
  const handle_errors_1 = require("../utils/handle-errors");
@@ -39,8 +40,8 @@ const task_timings_life_cycle_1 = require("./life-cycles/task-timings-life-cycle
39
40
  const tui_summary_life_cycle_1 = require("./life-cycles/tui-summary-life-cycle");
40
41
  const task_graph_utils_1 = require("./task-graph-utils");
41
42
  const utils_1 = require("./utils");
42
- const chalk = require("chalk");
43
43
  const exit_codes_1 = require("../utils/exit-codes");
44
+ const chalk = require("chalk");
44
45
  const originalStdoutWrite = process.stdout.write.bind(process.stdout);
45
46
  const originalStderrWrite = process.stderr.write.bind(process.stderr);
46
47
  const originalConsoleLog = console.log.bind(console);
@@ -132,9 +133,19 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
132
133
  /**
133
134
  * Patch stdout.write and stderr.write methods to pass Nx Cloud client logs to the TUI via the lifecycle
134
135
  */
135
- const createPatchedLogWrite = (originalWrite) => {
136
+ const createPatchedLogWrite = (originalWrite, isError) => {
136
137
  // @ts-ignore
137
138
  return (chunk, encoding, callback) => {
139
+ if (isError) {
140
+ (0, native_1.logError)(Buffer.isBuffer(chunk)
141
+ ? chunk.toString(encoding)
142
+ : chunk.toString());
143
+ }
144
+ else {
145
+ (0, native_1.logInfo)(Buffer.isBuffer(chunk)
146
+ ? chunk.toString(encoding)
147
+ : chunk.toString());
148
+ }
138
149
  // Check if the log came from the Nx Cloud client, otherwise invoke the original write method
139
150
  const stackTrace = new Error().stack;
140
151
  const isNxCloudLog = stackTrace.includes((0, node_path_1.join)(workspace_root_1.workspaceRoot, '.nx', 'cache', 'cloud'));
@@ -165,8 +176,8 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
165
176
  // No-op the Nx Cloud client logs
166
177
  };
167
178
  };
168
- process.stdout.write = createPatchedLogWrite(originalStdoutWrite);
169
- process.stderr.write = createPatchedLogWrite(originalStderrWrite);
179
+ process.stdout.write = createPatchedLogWrite(originalStdoutWrite, false);
180
+ process.stderr.write = createPatchedLogWrite(originalStderrWrite, true);
170
181
  // The cloud client calls console.log when NX_VERBOSE_LOGGING is set to true
171
182
  console.log = createPatchedConsoleMethod(originalConsoleLog);
172
183
  console.error = createPatchedConsoleMethod(originalConsoleError);
@@ -96,8 +96,8 @@ function addPrefixTransformer(prefix) {
96
96
  const colors = [
97
97
  chalk.green,
98
98
  chalk.greenBright,
99
- chalk.red,
100
- chalk.redBright,
99
+ chalk.blue,
100
+ chalk.blueBright,
101
101
  chalk.cyan,
102
102
  chalk.cyanBright,
103
103
  chalk.yellow,
@@ -113,7 +113,7 @@ function addMatchingProjectsByName(projectNames, projects, pattern, matchedProje
113
113
  }
114
114
  if (!(0, globs_1.isGlobPattern)(pattern.value)) {
115
115
  // Custom regex that is basically \b but includes hyphens (-) and excludes underscores (_), so "foo" pattern matches "foo_bar" but not "foo-e2e".
116
- const regex = new RegExp(`(?<![a-zA-Z0-9-])${pattern.value}(?![a-zA-Z0-9-])`, 'i');
116
+ const regex = new RegExp(`(?<![@a-zA-Z0-9-])${pattern.value}(?![@a-zA-Z0-9-])`, 'i');
117
117
  const matchingProjects = Object.keys(projects).filter((name) => regex.test(name));
118
118
  for (const projectName of matchingProjects) {
119
119
  if (pattern.exclude) {