Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "2.0.0",
"description": "Opinionated macOS development environment setup tool with beautiful TUI",
"type": "module",
"engines": {
"node": ">=18.0.0"
},
"scripts": {
"start": "node src/cli.js",
"setup": "node src/cli.js setup",
Expand Down
3 changes: 3 additions & 0 deletions src/cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env node

import { checkNodeVersion } from "./utils/node-version.js";
checkNodeVersion();

import { runSetup } from "./setup.js";
import { runAppend } from "./append.js";
import { runVerify } from "./verify.js";
Expand Down
3 changes: 2 additions & 1 deletion src/utils/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
copyFileSync,
} from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { homedir } from "node:os";

/**
Expand Down Expand Up @@ -94,5 +95,5 @@ export function expandHome(p) {
* Get the suitup project root (where configs/ lives).
*/
export function projectRoot() {
return join(import.meta.dirname, "..", "..");
return join(dirname(fileURLToPath(import.meta.url)), "..", "..");
}
33 changes: 33 additions & 0 deletions src/utils/node-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Validates that the current Node.js runtime meets the minimum version
* required for native ESM support (including stable top-level await).
*
* Minimum supported version: Node.js 18.0.0 (Active LTS)
*/

const MIN_MAJOR = 18;

/**
* Parse the major version number from a Node.js version string.
* @param {string} version - e.g. "v18.17.0"
* @returns {number}
*/
function parseMajor(version) {
return parseInt(version.replace(/^v/, "").split(".")[0], 10);
}

/**
* Check that Node.js is new enough to support native ESM.
* Exits the process with a helpful message if not.
*/
export function checkNodeVersion() {
const major = parseMajor(process.version);
if (major < MIN_MAJOR) {
console.error(
`suitup requires Node.js ${MIN_MAJOR} or later for native ESM support.\n` +
`You are running Node.js ${process.version}.\n` +
`Please upgrade: https://nodejs.org/en/download`
);
process.exit(1);
}
}
Loading