Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

chore(cli): drop Node.js `v18` support (#4583)

James Georgea08c6f6b3eb7
diff --git a/packages/hoppscotch-cli/bin/hopp.js b/packages/hoppscotch-cli/bin/hopp.js
index 2a5e91a60..57212501d 100755
--- a/packages/hoppscotch-cli/bin/hopp.js
+++ b/packages/hoppscotch-cli/bin/hopp.js
@@ -2,27 +2,57 @@
// * The entry point of the CLI
// @ts-check
-import { cli } from "../dist/index.js";
-
+import chalk from "chalk";
import { spawnSync } from "child_process";
+import fs from "fs";
import { cloneDeep } from "lodash-es";
+import semver from "semver";
+import { fileURLToPath } from "url";
+
+const highlightVersion = (version) => chalk.black.bgYellow(`v${version}`);
+
+const packageJsonPath = fileURLToPath(
+ new URL("../package.json", import.meta.url)
+);
+const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
+
+const requiredNodeVersionRange = packageJson.engines?.node || ">=20";
-const nodeVersion = parseInt(process.versions.node.split(".")[0]);
+// Extract the major version from the start of the range
+const requiredNodeVersion = semver.major(
+ semver.minVersion(requiredNodeVersionRange) ?? "20"
+);
+
+const currentNodeVersion = process.versions.node;
+
+// Last supported version of the CLI for Node.js v18
+const lastSupportedVersion = "0.11.1";
+
+if (!semver.satisfies(currentNodeVersion, requiredNodeVersionRange)) {
+ console.error(
+ `${chalk.greenBright("Hoppscotch CLI")} requires Node.js ${highlightVersion(requiredNodeVersion)} or higher and you're on Node.js ${highlightVersion(currentNodeVersion)}.`
+ );
+
+ console.error(
+ `\nIf you prefer staying on Node.js ${highlightVersion("18")}, you can install the last supported version of the CLI:\n` +
+ `${chalk.green(`npm install -g @hoppscotch/cli@${lastSupportedVersion}`)}`
+ );
+ process.exit(1);
+}
+
+// Dynamically importing the module after the Node.js version check prevents errors due to unrecognized APIs in older Node.js versions
+const { cli } = await import("../dist/index.js");
// As per isolated-vm documentation, we need to supply `--no-node-snapshot` for node >= 20
// src: https://github.com/laverdet/isolated-vm?tab=readme-ov-file#requirements
-if (nodeVersion >= 20 && !process.execArgv.includes("--no-node-snapshot")) {
+if (!process.execArgv.includes("--no-node-snapshot")) {
const argCopy = cloneDeep(process.argv);
// Replace first argument with --no-node-snapshot
// We can get argv[0] from process.argv0
argCopy[0] = "--no-node-snapshot";
- const result = spawnSync(
- process.argv0,
- argCopy,
- { stdio: "inherit" }
- );
+ const result = spawnSync(process.argv0, argCopy, { stdio: "inherit" });
// Exit with the same status code as the spawned process
process.exit(result.status ?? 0);
diff --git a/packages/hoppscotch-cli/package.json b/packages/hoppscotch-cli/package.json
index 3f957b930..45b9aa53d 100644
--- a/packages/hoppscotch-cli/package.json
+++ b/packages/hoppscotch-cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@hoppscotch/cli",
- "version": "0.13.0",
+ "version": "0.20.0",
"description": "A CLI to run Hoppscotch test scripts in CI environments.",
"homepage": "https://hoppscotch.io",
"type": "module",
@@ -12,7 +12,7 @@
"access": "public"
},
"engines": {
- "node": ">=18"
+ "node": ">=20"
},
"scripts": {
"build": "pnpm exec tsup",
@@ -48,24 +48,25 @@
"isolated-vm": "5.0.1",
"js-md5": "0.8.3",
"lodash-es": "4.17.21",
+ "papaparse": "5.4.1",
"qs": "6.13.0",
"verzod": "0.2.3",
"xmlbuilder2": "3.1.1",
- "zod": "3.23.8",
- "papaparse": "5.4.1"
+ "zod": "3.23.8"
},
"devDependencies": {
"@hoppscotch/data": "workspace:^",
"@hoppscotch/js-sandbox": "workspace:^",
"@relmify/jest-fp-ts": "2.1.1",
"@types/lodash-es": "4.17.12",
+ "@types/papaparse": "5.3.14",
"@types/qs": "6.9.16",
"fp-ts": "2.16.9",
"prettier": "3.3.3",
"qs": "6.11.2",
+ "semver": "7.6.3",
"tsup": "8.3.0",
"typescript": "5.6.3",
- "vitest": "2.1.2",
- "@types/papaparse": "5.3.14"
+ "vitest": "2.1.2"
}
}
diff --git a/packages/hoppscotch-cli/tsup.config.ts b/packages/hoppscotch-cli/tsup.config.ts
index 126507ad0..d6e19c127 100644
--- a/packages/hoppscotch-cli/tsup.config.ts
+++ b/packages/hoppscotch-cli/tsup.config.ts
@@ -1,7 +1,7 @@
import { defineConfig } from "tsup";
export default defineConfig({
- entry: [ "./src/index.ts" ],
+ entry: ["./src/index.ts"],
outDir: "./dist/",
format: ["esm"],
platform: "node",
@@ -10,7 +10,7 @@ export default defineConfig({
target: "esnext",
skipNodeModulesBundle: false,
esbuildOptions(options) {
- options.bundle = true
+ options.bundle = true;
},
clean: true,
});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f703b2c1a..44a193c9e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -141,10 +141,10 @@ importers:
version: 4.11.0([email protected])
'@nestjs-modules/mailer':
specifier: 2.0.2
'@nestjs/apollo':
specifier: 12.2.0
'@nestjs/common':
specifier: 10.4.4
@@ -156,7 +156,7 @@ importers:
'@nestjs/graphql':
specifier: 12.2.0
'@nestjs/jwt':
specifier: 10.2.0
@@ -168,16 +168,16 @@ importers:
'@nestjs/schedule':
specifier: 4.1.1
'@nestjs/swagger':
specifier: 7.4.2
'@nestjs/terminus':
specifier: 10.2.3
'@nestjs/throttler':
specifier: 6.2.1
'@prisma/client':
specifier: 5.20.0
version: 5.20.0([email protected])
@@ -277,7 +277,7 @@ importers:
'@nestjs/testing':
specifier: 10.4.4
'@relmify/jest-fp-ts':
specifier: 2.1.1
@@ -435,6 +435,9 @@ importers:
prettier:
specifier: 3.3.3
version: 3.3.3
+ semver:
+ specifier: 7.6.3
+ version: 7.6.3
tsup:
specifier: 8.3.0
@@ -864,7 +867,7 @@ importers:
vite-plugin-checker:
specifier: 0.6.4
vite-plugin-fonts:
specifier: 0.7.0
@@ -1167,7 +1170,7 @@ importers:
version: 0.14.9(@vue/[email protected])([email protected])
unplugin-vue-components:
specifier: 0.21.0
vite:
specifier: 4.5.0
@@ -1176,7 +1179,7 @@ importers:
vite-plugin-inspect:
specifier: 0.7.38
vite-plugin-pages:
specifier: 0.26.0
@@ -1342,7 +1345,7 @@ importers:
unplugin-vue-components:
specifier: 0.27.4
vite:
specifier: 5.4.9
@@ -1354,7 +1357,7 @@ importers:
vite-plugin-inspect:
specifier: 0.8.7
vite-plugin-pages:
specifier: 0.32.3
@@ -1396,7 +1399,7 @@ importers:
'@intlify/unplugin-vue-i18n':
specifier: 5.2.0
'@types/cors':
specifier: 2.8.17
version: 2.8.17
@@ -1453,7 +1456,7 @@ importers:
unplugin-vue-components:
specifier: 0.27.4
vue:
specifier: 3.5.12
version: 3.5.12([email protected])
@@ -3898,8 +3901,8 @@ packages:
resolution: {integrity: sha512-AFbhEo10DP095/45EauinQJ5hJ3rJUmuuqltGguvc3WsvezZN+g8qNHLGWKu60FHQVizMrQY7VJ+zVlBXlQQkQ==}
engines: {node: '>= 16'}
- '@intlify/[email protected]':
- resolution: {integrity: sha512-yMXfN4hg/EeSdtWfmoMrwB9X4TXwkBoZlTIpNydQaW9y0tSJHGnUPRoahtkbsyACCm9leSJINLY4jQ0rK6BK0Q==}
+ '@intlify/[email protected]':
+ resolution: {integrity: sha512-/cJHP1n45Zlf9tbm/hudLrUwXzJZngR9OMTQk32H1S4lBjM2996wzKTHuLbaJJlJZNTTjnfWZUHPb+F6sE6p1Q==}
engines: {node: '>= 16'}
'@intlify/[email protected]':
@@ -3910,8 +3913,8 @@ packages:
resolution: {integrity: sha512-ukFn0I01HsSgr3VYhYcvkTCLS7rGa0gw4A4AMpcy/A9xx/zRJy7PS2BElMXLwUazVFMAr5zuiTk3MQeoeGXaJg==}
engines: {node: '>= 16'}
- '@intlify/[email protected]':
- resolution: {integrity: sha512-Md/4T/QOx7wZ7zqVzSsMx2M/9Mx/1nsgsjXS5SFIowFKydqUhMz7K+y7pMFh781aNYz+rGXYwad8E9/+InK9SA==}
+ '@intlify/[email protected]':
+ resolution: {integrity: sha512-N6ngJfFaVA0l2iLtx/SymgHOBW4wiS5Pyue7YmY/G+mrGjesi+S+U+u/Xlv6pZa/YIBfeM4QB07lI7rz1YqKLg==}
engines: {node: '>= 16'}
'@intlify/[email protected]':
@@ -15619,8 +15622,8 @@ snapshots:
dependencies:
- '@intlify/message-compiler': 11.0.0-beta.1
- '@intlify/shared': 11.0.0-beta.1
+ '@intlify/message-compiler': 11.0.0-beta.2
+ '@intlify/shared': 11.0.0-beta.2
jsonc-eslint-parser: 1.4.1
source-map: 0.6.1
yaml-eslint-parser: 0.3.2
@@ -15644,8 +15647,8 @@ snapshots:
dependencies:
- '@intlify/message-compiler': 11.0.0-beta.1
- '@intlify/shared': 11.0.0-beta.1
+ '@intlify/message-compiler': 11.0.0-beta.2
+ '@intlify/shared': 11.0.0-beta.2
acorn: 8.12.1
escodegen: 2.1.0
estree-walker: 2.0.2
@@ -15666,9 +15669,9 @@ snapshots:
'@intlify/shared': 10.0.4
source-map-js: 1.2.1
- '@intlify/[email protected]':
+ '@intlify/[email protected]':
dependencies:
- '@intlify/shared': 11.0.0-beta.1
+ '@intlify/shared': 11.0.0-beta.2
source-map-js: 1.2.1
'@intlify/[email protected]':
@@ -15678,17 +15681,17 @@ snapshots:
'@intlify/[email protected]': {}
- '@intlify/[email protected]': {}
+ '@intlify/[email protected]': {}
'@intlify/[email protected]': {}
dependencies:
'@eslint-community/eslint-utils': 4.4.0([email protected]([email protected]))
'@intlify/bundle-utils': 9.0.0-beta.0([email protected]([email protected]([email protected])))
- '@intlify/shared': 11.0.0-beta.1
- '@rollup/pluginutils': 5.1.2([email protected])
+ '@intlify/shared': 11.0.0-beta.2
+ '@rollup/pluginutils': 5.1.2([email protected])
'@typescript-eslint/scope-manager': 7.18.0
'@typescript-eslint/typescript-estree': 7.18.0([email protected])
debug: 4.3.7
@@ -15713,7 +15716,7 @@ snapshots:
dependencies:
'@intlify/bundle-utils': 7.0.0([email protected]([email protected]([email protected])))
- '@intlify/shared': 11.0.0-beta.1
+ '@intlify/shared': 11.0.0-beta.2
'@rollup/pluginutils': 4.2.1
debug: 4.3.7
fast-glob: 3.3.2
@@ -15727,7 +15730,7 @@ snapshots:
dependencies:
'@intlify/bundle-utils': 3.4.0([email protected]([email protected]([email protected])))
- '@intlify/shared': 11.0.0-beta.1
+ '@intlify/shared': 11.0.0-beta.2
'@rollup/pluginutils': 4.2.1
debug: 4.3.7
fast-glob: 3.3.2
@@ -15741,7 +15744,7 @@ snapshots:
dependencies:
'@intlify/bundle-utils': 3.4.0([email protected]([email protected]([email protected])))
- '@intlify/shared': 11.0.0-beta.1
+ '@intlify/shared': 11.0.0-beta.2
'@rollup/pluginutils': 4.2.1
debug: 4.3.7
fast-glob: 3.3.2
@@ -15752,11 +15755,11 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@babel/parser': 7.25.7
optionalDependencies:
- '@intlify/shared': 11.0.0-beta.1
+ '@intlify/shared': 11.0.0-beta.2
'@vue/compiler-dom': 3.5.12
vue: 3.5.12([email protected])
@@ -16042,7 +16045,7 @@ snapshots:
'@microsoft/[email protected]': {}
dependencies:
'@css-inline/css-inline': 0.14.1
@@ -16069,13 +16072,13 @@ snapshots:
- typescript
- uncss
dependencies:
'@apollo/server': 4.11.0([email protected])
'@apollo/server-plugin-landing-page-graphql-playground': 4.0.0(@apollo/[email protected]([email protected]))
graphql: 16.9.0
iterall: 1.3.0
lodash.omit: 4.5.0
@@ -16144,7 +16147,7 @@ snapshots:
transitivePeerDependencies:
- encoding
dependencies:
'@graphql-tools/merge': 9.0.4([email protected])
'@graphql-tools/schema': 10.0.4([email protected])
@@ -16202,7 +16205,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
@@ -16231,7 +16234,7 @@ snapshots:
transitivePeerDependencies:
- chokidar
dependencies:
'@microsoft/tsdoc': 0.15.0
@@ -16246,7 +16249,7 @@ snapshots:
class-transformer: 0.5.1
class-validator: 0.14.1
dependencies:
@@ -16257,7 +16260,7 @@ snapshots:
optionalDependencies:
'@prisma/client': 5.20.0([email protected])
dependencies:
@@ -16265,7 +16268,7 @@ snapshots:
optionalDependencies:
dependencies:
@@ -25762,7 +25765,7 @@ snapshots:
- supports-color
- webpack-sources
dependencies:
'@antfu/utils': 0.5.2
'@rollup/pluginutils': 4.2.1
@@ -25773,7 +25776,7 @@ snapshots:
magic-string: 0.26.7
minimatch: 5.1.6
resolve: 1.22.8
vue: 3.5.12([email protected])
optionalDependencies:
'@babel/parser': 7.25.7
@@ -25784,10 +25787,10 @@ snapshots:
- vite
- webpack
dependencies:
'@antfu/utils': 0.7.10
- '@rollup/pluginutils': 5.1.2([email protected])
+ '@rollup/pluginutils': 5.1.2([email protected])
chokidar: 3.6.0
debug: 4.3.7
fast-glob: 3.3.2
@@ -25804,10 +25807,10 @@ snapshots:
- supports-color
- webpack-sources
dependencies:
'@antfu/utils': 0.7.10
- '@rollup/pluginutils': 5.1.2([email protected])
+ '@rollup/pluginutils': 5.1.2([email protected])
chokidar: 3.6.0
debug: 4.3.7
fast-glob: 3.3.2
@@ -25824,7 +25827,27 @@ snapshots:
- supports-color
- webpack-sources
+ dependencies:
+ '@antfu/utils': 0.7.10
+ '@rollup/pluginutils': 5.1.2([email protected])
+ chokidar: 3.6.0
+ debug: 4.3.7
+ fast-glob: 3.3.2
+ local-pkg: 0.5.0
+ magic-string: 0.30.11
+ minimatch: 9.0.5
+ mlly: 1.7.2
+ unplugin: 1.14.1([email protected])
+ vue: 3.5.12([email protected])
+ optionalDependencies:
+ '@babel/parser': 7.25.7
+ transitivePeerDependencies:
+ - rollup
+ - supports-color
+ - webpack-sources
+
dependencies:
acorn: 8.12.1
chokidar: 3.6.0
@@ -25832,7 +25855,7 @@ snapshots:
webpack-virtual-modules: 0.4.6
optionalDependencies:
esbuild: 0.24.0
- rollup: 2.79.2
+ rollup: 3.29.4
webpack: 5.94.0(@swc/[email protected])([email protected])
@@ -25995,7 +26018,7 @@ snapshots:
- supports-color
- terser
dependencies:
'@babel/code-frame': 7.25.7
ansi-escapes: 4.3.2
@@ -26015,6 +26038,7 @@ snapshots:
vscode-uri: 3.0.8
optionalDependencies:
eslint: 8.57.0
+ meow: 13.2.0
optionator: 0.9.4
typescript: 5.3.3
vue-tsc: 1.8.24([email protected])
@@ -26073,10 +26097,10 @@ snapshots:
dependencies:
dependencies:
'@antfu/utils': 0.7.10
- '@rollup/pluginutils': 5.1.2([email protected])
+ '@rollup/pluginutils': 5.1.2([email protected])
debug: 4.3.7
error-stack-parser-es: 0.1.5
fs-extra: 11.2.0
@@ -26088,10 +26112,10 @@ snapshots:
- rollup
- supports-color
dependencies:
'@antfu/utils': 0.7.10
- '@rollup/pluginutils': 5.1.2([email protected])
+ '@rollup/pluginutils': 5.1.2([email protected])
debug: 4.3.7
error-stack-parser-es: 0.1.5
fs-extra: 11.2.0