nx/scripts/preinstall.js
Jason Jean 022789202e
chore(repo): fix publish workflow (#31510)
## Current Behavior

The publish workflow was failing because the preinstall script was
exiting with code 1 when detecting an older Node.js version, causing the
entire publishing process to fail.

## Expected Behavior  

The preinstall script should warn about Node.js version requirements but
not exit with an error code during publishing, allowing the workflow to
continue.

## Related Issue(s)

This fixes a critical issue preventing package publishing due to Node.js
version check failures in CI environments.

The fix changes:
- `console.error()` to `console.warn()` for better log categorization
- Removes `process.exit(1)` to prevent workflow termination  
- Adds the actual Node.js version to the warning message for better
debugging

This ensures the publish workflow can complete successfully while still
providing visibility into Node.js version mismatches.
2025-06-09 14:39:06 -04:00

58 lines
1.6 KiB
JavaScript

/*
This pre-install script will check that the necessary dependencies are installed
Checks for:
* Node 20+
* pnpm 10+
* Rust
*/
if (process.env.CI) {
process.exit(0);
}
const childProcess = require('child_process');
const semverLessThan = require('semver/functions/lt');
// Check node version
if (semverLessThan(process.version, '20.19.0')) {
console.warn(
`Please make sure that your installed Node version (${process.version}) is greater than v20.19.0`
);
}
// Check for pnpm version
try {
let pnpmVersion = childProcess.execSync('pnpm --version', {
encoding: 'utf8',
});
const version = pnpmVersion.trim();
if (semverLessThan(version, '10.0.0')) {
console.error(
`Found pnpm ${version}. Please make sure that your installed pnpm version is 10.0.0 or greater. You can update with: npm install -g pnpm@10`
);
process.exit(1);
}
} catch {
console.error(
'Could not find pnpm on this system. Please make sure it is installed with: npm install -g pnpm@10'
);
process.exit(1);
}
// Check for rust
try {
let rustVersion = childProcess.execSync('rustc --version');
if (semverLessThan(rustVersion.toString().split(' ')[1], '1.70.0')) {
console.log(`Found ${rustVersion}`);
console.error(
'Please make sure that your installed Rust version is greater than v1.70. You can update your installed Rust version with `rustup update`'
);
process.exit(1);
}
} catch {
console.error(
'Could not find the Rust compiler on this system. Please make sure that it is installed with https://rustup.rs'
);
process.exit(1);
}