Skip to content

Commit 4567cb5

Browse files
authored
updating min node version, and bash declare (#132)
Signed-off-by: Derek Anderson <dmikey@users.noreply.github.com>
1 parent 7f851f3 commit 4567cb5

6 files changed

Lines changed: 41 additions & 37 deletions

File tree

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ jobs:
1010
runs-on: macos-latest
1111
steps:
1212
- uses: actions/checkout@v2
13-
- uses: actions/setup-node@v3
13+
- uses: actions/setup-node@v4
1414
with:
1515
node-version: 18
16+
- run: node -v
1617
- run: npm i -g yarn
1718
- run: yarn
1819
- run: yarn build

bin.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
#!/usr/bin/env node
2-
const compareVersions = require("compare-versions")
3-
const MIN_NODE_VERSION = '14.17.6'
4-
5-
if (compareVersions.compare(process.versions.node, MIN_NODE_VERSION, '<')) {
6-
console.error(
7-
`Bls CLI requires at least node.js v${MIN_NODE_VERSION}.\nYou are using v${process.versions.node}. Please update your version of node.js. Consider using Node.js version manager https://github.com/nvm-sh/nvm.`
8-
)
9-
process.exit(1)
10-
} else {
11-
const { main } = require("./dist/src/index");
12-
const { version } = require("./package.json");
13-
14-
main(process.argv.slice(2), { version });
15-
}
1+
#!/usr/bin/env node --no-warnings
2+
const compareVersions = require("compare-versions");
3+
4+
5+
const { main } = require("./dist/src/index");
6+
const { version } = require("./package.json");
7+
8+
main(process.argv.slice(2), { version });
9+

dev-bin.js

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
1-
#!/usr/bin/env node
1+
#!/usr/bin/env node --no-warnings
22
require("ts-node/register");
3-
const compareVersions = require("compare-versions");
4-
const MIN_NODE_VERSION = "14.17.6";
53

6-
if (compareVersions.compare(process.versions.node, MIN_NODE_VERSION, "<")) {
7-
console.error(
8-
`Bls CLI requires at least node.js v${MIN_NODE_VERSION}.\nYou are using v${process.versions.node}. Please update your version of node.js. Consider using Node.js version manager https://github.com/nvm-sh/nvm.`,
9-
);
10-
process.exit(1);
11-
} else {
12-
const { main } = require("./src/index");
13-
const { version } = require("./package.json");
4+
const { main } = require("./src/index");
5+
const { version } = require("./package.json");
146

15-
const runCLI = (args) => {
16-
main(args, { version });
17-
};
7+
const runCLI = (args) => {
8+
main(args, { version });
9+
};
1810

19-
// Export the runCLI function for testing
20-
module.exports = { runCLI };
11+
// Export the runCLI function for testing
12+
module.exports = { runCLI };
2113

22-
// Run the CLI if executed directly
23-
if (require.main === module) {
24-
runCLI(process.argv.slice(2));
25-
}
26-
}
14+
// Run the CLI if executed directly
15+
if (require.main === module) {
16+
runCLI(process.argv.slice(2));
17+
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"name": "@blockless/cli",
3+
"engines": {
4+
"node": ">=18.10.0"
5+
},
36
"version": "0.0.5-development",
47
"description": "blockless cli client, manage, interact with and deploy blockless applications.",
58
"main": "dist/src/index.js",

src/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import { openInBrowser } from './lib/browser'
1212
import { getGatewayUrl } from './lib/urls'
1313
import { logger } from './lib/logger'
1414
import { sitesCli } from './commands/sites'
15+
import * as compareVersions from "compare-versions";
16+
import { getNodeVersion } from './lib/npm'
17+
const MIN_NODE_VERSION = "18.10";
18+
1519

1620
/**
1721
* Yargs options included in every wrangler command.
@@ -166,6 +170,13 @@ export async function main(argv: string[], options: any) {
166170
blsCli.version(options.version)
167171
blsCli.epilogue(`Blockless CLI v${options.version}`)
168172

173+
if (compareVersions.compare(getNodeVersion(), MIN_NODE_VERSION, "<")) {
174+
console.error(
175+
`Bls CLI requires at least node.js v${MIN_NODE_VERSION}.\nYou are using v${process.versions.node}. Please update your version of node.js. Consider using Node.js version manager https://github.com/nvm-sh/nvm.`,
176+
);
177+
process.exit(1);
178+
}
179+
169180
if (argv.length > 0) {
170181
try {
171182
blsCli.parse(argv, parseCliResponse)

src/lib/npm.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export const getNpmVersion = (): string =>
1313
export const getNpmConfigInitVersion = (): string =>
1414
execSync("npm config get init-version").toString("utf-8")
1515

16+
// Node/npm config
17+
export const getNodeVersion = (): string =>
18+
execSync("echo $(node -v)").toString("utf-8").replace('v', '').trim()
19+
1620
/**
1721
* Check whether NPM is installed
1822
*

0 commit comments

Comments
 (0)