Skip to content

Commit

Permalink
updating min node version, and bash declare (#132)
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Anderson <[email protected]>
  • Loading branch information
dmikey authored Sep 19, 2024
1 parent 7f851f3 commit 4567cb5
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
- run: node -v
- run: npm i -g yarn
- run: yarn
- run: yarn build
Expand Down
24 changes: 9 additions & 15 deletions bin.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#!/usr/bin/env node
const compareVersions = require("compare-versions")
const MIN_NODE_VERSION = '14.17.6'

if (compareVersions.compare(process.versions.node, MIN_NODE_VERSION, '<')) {
console.error(
`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.`
)
process.exit(1)
} else {
const { main } = require("./dist/src/index");
const { version } = require("./package.json");

main(process.argv.slice(2), { version });
}
#!/usr/bin/env node --no-warnings
const compareVersions = require("compare-versions");


const { main } = require("./dist/src/index");
const { version } = require("./package.json");

main(process.argv.slice(2), { version });

33 changes: 12 additions & 21 deletions dev-bin.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
#!/usr/bin/env node
#!/usr/bin/env node --no-warnings
require("ts-node/register");
const compareVersions = require("compare-versions");
const MIN_NODE_VERSION = "14.17.6";

if (compareVersions.compare(process.versions.node, MIN_NODE_VERSION, "<")) {
console.error(
`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.`,
);
process.exit(1);
} else {
const { main } = require("./src/index");
const { version } = require("./package.json");
const { main } = require("./src/index");
const { version } = require("./package.json");

const runCLI = (args) => {
main(args, { version });
};
const runCLI = (args) => {
main(args, { version });
};

// Export the runCLI function for testing
module.exports = { runCLI };
// Export the runCLI function for testing
module.exports = { runCLI };

// Run the CLI if executed directly
if (require.main === module) {
runCLI(process.argv.slice(2));
}
}
// Run the CLI if executed directly
if (require.main === module) {
runCLI(process.argv.slice(2));
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"name": "@blockless/cli",
"engines": {
"node": ">=18.10.0"
},
"version": "0.0.5-development",
"description": "blockless cli client, manage, interact with and deploy blockless applications.",
"main": "dist/src/index.js",
Expand Down
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import { openInBrowser } from './lib/browser'
import { getGatewayUrl } from './lib/urls'
import { logger } from './lib/logger'
import { sitesCli } from './commands/sites'
import * as compareVersions from "compare-versions";
import { getNodeVersion } from './lib/npm'
const MIN_NODE_VERSION = "18.10";


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

if (compareVersions.compare(getNodeVersion(), MIN_NODE_VERSION, "<")) {
console.error(
`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.`,
);
process.exit(1);
}

if (argv.length > 0) {
try {
blsCli.parse(argv, parseCliResponse)
Expand Down
4 changes: 4 additions & 0 deletions src/lib/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export const getNpmVersion = (): string =>
export const getNpmConfigInitVersion = (): string =>
execSync("npm config get init-version").toString("utf-8")

// Node/npm config
export const getNodeVersion = (): string =>
execSync("echo $(node -v)").toString("utf-8").replace('v', '').trim()

/**
* Check whether NPM is installed
*
Expand Down

0 comments on commit 4567cb5

Please sign in to comment.