Skip to content

Commit

Permalink
feat: Bump minimum node.js version from 12 to 14.14.0
Browse files Browse the repository at this point in the history
With nodecg-io 0.3.0 node.js 14 or higher is required for development
installations. This minimum version is required by the husky
dependency but I think some other dependencies also want node.js 14+.

I think it is reasonable to bump the minimum supported node.js version
to 14 now. Most people should be able to upgrade to node.js 14 without
any problems.

Updates the check at cli startup to require node.js 14 and also updates
node.js version in the GitHub Actions CI configuration.
  • Loading branch information
hlxid committed Oct 5, 2022
1 parent 255238e commit ff8808a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-2019]
node: [12, 14, 16, 17]
node: [14, 16, 18]

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -31,7 +31,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-2019]
version: ['0.1', '0.2', 'development']
node: [14, 16]
node: [14, 18]

runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- name: Install dependencies
run: npm ci
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import yargs from "yargs";
import { installModule } from "./install";
import { uninstallModule } from "./uninstall";
import { version } from "../package.json";
import { checkForCliUpdate, ensureNode12 } from "./utils/cli";
import { checkForCliUpdate, ensureMinimumNodeVersion } from "./utils/cli";
import { generateModule } from "./generate";

// This file gets imported by the index.js file of the repository root.
Expand All @@ -22,7 +22,7 @@ const args = yargs(process.argv.slice(2))
})
.parse();

ensureNode12();
ensureMinimumNodeVersion();
(async () => {
const opts = await args;
if (!opts["disable-updates"]) {
Expand Down
23 changes: 14 additions & 9 deletions src/utils/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,25 @@ import * as semver from "semver";
import { SemVer } from "semver";

/**
* Ensures that the cli is executed with at least node 12. This is the minimum version that is required
* and if it is older the cli will exit.
* Minimum node.js version that is required to use nodecg-io and this cli.
*/
export function ensureNode12(): void {
const minimumNodeVersion = "14.14.0";

/**
* Ensures that the node.js installation that is used to execute the cli
* meets the required minimum node.js version for nodecg-io,
* If it is older the cli will log an error about it and exit.
*/
export function ensureMinimumNodeVersion(): void {
const nodeVersion = process.versions.node;
const range = new semver.Range(">=12");
const range = new semver.Range(`>=${minimumNodeVersion}`);

if (!semver.satisfies(nodeVersion, range)) {
logger.error("Please update your node installation.");
logger.error(
`nodecg-io-cli requires at least node ${chalk.yellowBright("12")}. You have ${chalk.yellowBright(
nodeVersion,
)}`,
);

const minVer = chalk.yellowBright(minimumNodeVersion);
const curVer = chalk.yellowBright(nodeVersion);
logger.error(`nodecg-io-cli requires at least node ${minVer}. You have ${curVer}`);
process.exit(1);
}
}
Expand Down

0 comments on commit ff8808a

Please sign in to comment.