Skip to content

Commit d21fd01

Browse files
MaxKlessFrozenPandaz
authored andcommitted
feat(core): load native files from tmp location instead of node_modules (#22648)
(cherry picked from commit da1808d)
1 parent 7ac5ca5 commit d21fd01

File tree

16 files changed

+508
-377
lines changed

16 files changed

+508
-377
lines changed

.eslintrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
{
1818
"group": ["nx/src/plugins/js*"],
1919
"message": "Imports from 'nx/src/plugins/js' are not allowed. Use '@nx/js' instead"
20+
},
21+
{
22+
"group": ["**/native-bindings", "**/native-bindings.js", ""],
23+
"message": "Direct imports from native-bindings.js are not allowed. Import from index.js instead."
2024
}
2125
]
2226
}

packages/nx/.eslintrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
{
2626
"group": ["nx/*"],
2727
"message": "Circular import in 'nx' found. Use relative path."
28+
},
29+
{
30+
"group": ["**/native-bindings", "**/native-bindings.js"],
31+
"message": "Direct imports from native-bindings.js are not allowed. Import from index.js instead."
2832
}
2933
]
3034
}

packages/nx/bin/nx.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ function main() {
2525
if (
2626
process.argv[2] !== 'report' &&
2727
process.argv[2] !== '--version' &&
28-
process.argv[2] !== '--help'
28+
process.argv[2] !== '--help' &&
29+
process.argv[2] !== 'reset'
2930
) {
3031
assertSupportedPlatform();
3132
}

packages/nx/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"executor": "@monodon/rust:napi",
1111
"options": {
1212
"dist": "packages/nx/src/native",
13-
"jsFile": "packages/nx/src/native/index.js",
13+
"jsFile": "packages/nx/src/native/native-bindings.js",
1414
"release": true
1515
},
1616
"configurations": {

packages/nx/src/command-line/init/implementation/react/check-for-uncommitted-changes.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import { execSync } from 'child_process';
22

33
export function checkForUncommittedChanges() {
4-
const gitResult = execSync(`git status --porcelain`);
5-
if (gitResult.length > 0) {
4+
const gitResult = execSync('git status --porcelain').toString();
5+
6+
const filteredResults = gitResult
7+
.split('\n')
8+
.filter((line) => !line.includes('.nx') && line.trim().length > 0);
9+
10+
if (filteredResults.length > 0) {
611
console.log('❗️ Careful!');
712
console.log('You have uncommitted changes in your repository.');
813
console.log('');
9-
console.log(gitResult.toString());
14+
console.log(filteredResults.join('\n').toString());
1015
console.log('Please commit your changes before running the migrator!');
1116
process.exit(1);
1217
}

packages/nx/src/daemon/cache.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ export async function safelyCleanUpExistingProcess(): Promise<void> {
4343
if (daemonProcessJson && daemonProcessJson.processId) {
4444
try {
4545
process.kill(daemonProcessJson.processId);
46+
// we wait for the process to actually shut down before returning
47+
await new Promise<void>((resolve, reject) => {
48+
let count = 0;
49+
const interval = setInterval(() => {
50+
try {
51+
// sending a signal 0 to a process checks if the process is running instead of actually killing it
52+
process.kill(daemonProcessJson.processId, 0);
53+
} catch (e) {
54+
clearInterval(interval);
55+
resolve();
56+
}
57+
if ((count += 1) > 200) {
58+
clearInterval(interval);
59+
reject(
60+
`Daemon process ${daemonProcessJson.processId} didn't exit after 2 seconds.`
61+
);
62+
}
63+
}, 10);
64+
});
4665
} catch {}
4766
}
4867
deleteDaemonJsonProcessCache();

packages/nx/src/daemon/client/client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ import { safelyCleanUpExistingProcess } from '../cache';
2525
import { Hash } from '../../hasher/task-hasher';
2626
import { Task, TaskGraph } from '../../config/task-graph';
2727
import { ConfigurationSourceMaps } from '../../project-graph/utils/project-configuration-utils';
28-
import { DaemonProjectGraphError } from '../daemon-project-graph-error';
29-
import { ProjectGraphError } from '../../project-graph/project-graph';
28+
import {
29+
DaemonProjectGraphError,
30+
ProjectGraphError,
31+
} from '../../project-graph/error-types';
3032

3133
const DAEMON_ENV_SETTINGS = {
3234
NX_PROJECT_GLOB_CACHE: 'false',

packages/nx/src/daemon/daemon-project-graph-error.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/nx/src/daemon/server/handle-hash-tasks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Task, TaskGraph } from '../../config/task-graph';
22
import { getCachedSerializedProjectGraphPromise } from './project-graph-incremental-recomputation';
33
import { InProcessTaskHasher } from '../../hasher/task-hasher';
44
import { readNxJson } from '../../config/configuration';
5-
import { DaemonProjectGraphError } from '../daemon-project-graph-error';
5+
import { DaemonProjectGraphError } from '../../project-graph/error-types';
66

77
/**
88
* We use this not to recreated hasher for every hash operation

packages/nx/src/daemon/server/project-graph-incremental-recomputation.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ import { notifyFileWatcherSockets } from './file-watching/file-watcher-sockets';
3333
import { serverLogger } from './logger';
3434
import { NxWorkspaceFilesExternals } from '../../native';
3535
import { ConfigurationResult } from '../../project-graph/utils/project-configuration-utils';
36-
import { DaemonProjectGraphError } from '../daemon-project-graph-error';
3736
import { LoadedNxPlugin } from '../../project-graph/plugins/internal-api';
3837
import { getPlugins } from './plugins';
39-
import { ProjectConfigurationsError } from '../../project-graph/error-types';
38+
import {
39+
DaemonProjectGraphError,
40+
ProjectConfigurationsError,
41+
} from '../../project-graph/error-types';
4042

4143
interface SerializedProjectGraph {
4244
error: Error | null;

packages/nx/src/daemon/socket-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { unlinkSync } from 'fs';
22
import { platform } from 'os';
33
import { join, resolve } from 'path';
44
import { DAEMON_SOCKET_PATH, socketDir } from './tmp-dir';
5-
import { DaemonProjectGraphError } from './daemon-project-graph-error';
5+
import { DaemonProjectGraphError } from '../project-graph/error-types';
66

77
export const isWindows = platform() === 'win32';
88

0 commit comments

Comments
 (0)