Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): load native files from tmp location instead of node_modules #22648

Merged
merged 4 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
{
"group": ["nx/src/plugins/js*"],
"message": "Imports from 'nx/src/plugins/js' are not allowed. Use '@nx/js' instead"
},
{
"group": ["**/native-bindings", "**/native-bindings.js", ""],
"message": "Direct imports from native-bindings.js are not allowed. Import from index.js instead."
}
]
}
Expand Down
4 changes: 4 additions & 0 deletions packages/nx/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
{
"group": ["nx/*"],
"message": "Circular import in 'nx' found. Use relative path."
},
{
"group": ["**/native-bindings", "**/native-bindings.js"],
"message": "Direct imports from native-bindings.js are not allowed. Import from index.js instead."
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion packages/nx/bin/nx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ function main() {
if (
process.argv[2] !== 'report' &&
process.argv[2] !== '--version' &&
process.argv[2] !== '--help'
process.argv[2] !== '--help' &&
process.argv[2] !== 'reset'
) {
assertSupportedPlatform();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"executor": "@monodon/rust:napi",
"options": {
"dist": "packages/nx/src/native",
"jsFile": "packages/nx/src/native/index.js",
"jsFile": "packages/nx/src/native/native-bindings.js",
"release": true
},
"configurations": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { execSync } from 'child_process';

export function checkForUncommittedChanges() {
const gitResult = execSync(`git status --porcelain`);
if (gitResult.length > 0) {
const gitResult = execSync('git status --porcelain').toString();

const filteredResults = gitResult
.split('\n')
.filter((line) => !line.includes('.nx') && line.trim().length > 0);

if (filteredResults.length > 0) {
console.log('❗️ Careful!');
console.log('You have uncommitted changes in your repository.');
console.log('');
console.log(gitResult.toString());
console.log(filteredResults.join('\n').toString());
console.log('Please commit your changes before running the migrator!');
process.exit(1);
}
Expand Down
17 changes: 17 additions & 0 deletions packages/nx/src/daemon/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ export async function safelyCleanUpExistingProcess(): Promise<void> {
if (daemonProcessJson && daemonProcessJson.processId) {
try {
process.kill(daemonProcessJson.processId);
await new Promise<void>((resolve, reject) => {
let count = 0;
const interval = setInterval(() => {
try {
process.kill(daemonProcessJson.processId, 0);
} catch (e) {
clearInterval(interval);
resolve();
}
if ((count += 1) > 200) {
clearInterval(interval);
reject(
`Daemon process ${daemonProcessJson.processId} didn't exit after 2 seconds.`
);
}
}, 10);
});
MaxKless marked this conversation as resolved.
Show resolved Hide resolved
} catch {}
}
deleteDaemonJsonProcessCache();
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/daemon/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { Hash } from '../../hasher/task-hasher';
import { Task, TaskGraph } from '../../config/task-graph';
import { ConfigurationSourceMaps } from '../../project-graph/utils/project-configuration-utils';
import { DaemonProjectGraphError } from '../daemon-project-graph-error';
import { ProjectGraphError } from '../../project-graph/project-graph';
import { ProjectGraphError } from '../../project-graph/project-graph-error';
MaxKless marked this conversation as resolved.
Show resolved Hide resolved

const DAEMON_ENV_SETTINGS = {
NX_PROJECT_GLOB_CACHE: 'false',
Expand Down
Loading