Skip to content

Commit

Permalink
chore: deprecate node v12 support (#1795)
Browse files Browse the repository at this point in the history
Node v12 reaches end of life on April 30, 2022. This PR adds a warning that projen will be dropping support for old node releases.

We'll give this message a week to incubate before actually bumping the version we support (#1768).

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • Loading branch information
Chriscbr authored Apr 25, 2022
1 parent c50270c commit 6db1b04
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
This topic describes all the features of `NodeProject` projects and their
derivatives.

## Node versioning

You can specify the minimum version of node that your project supports, and the version of node used in GitHub workflows:

```js
const project = new javascript.NodeProject({
// ...
minNodeVersion: '16.0.0',
workflowNodeVersion: '16.1.0', // defaults to minNodeVersion
});
```

## Development Workflow

TODO
Expand Down
9 changes: 9 additions & 0 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { resolve } from "path";
import * as yargs from "yargs";
import { PROJEN_RC, PROJEN_VERSION } from "../common";
import * as logging from "../logging";
import { TaskRuntime } from "../task-runtime";
import { getNodeMajorVersion } from "../util";
import { synth } from "./synth";
import { discoverTaskCommands } from "./tasks";

Expand Down Expand Up @@ -53,6 +55,13 @@ async function main() {
process.env.DEBUG = "true";
}

const nodeVersion = getNodeMajorVersion();
if (nodeVersion && nodeVersion < 14) {
logging.warn(
`WARNING: You are using Node v${nodeVersion}, which reaches end of life on April 30, 2022. Support for EOL Node releases may be dropped by projen in the future. Please consider upgrading to Node >= 14 as soon as possible.`
);
}

// no command means synthesize
if (args._.length === 0) {
if (args.version) {
Expand Down
9 changes: 9 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,12 @@ function decamelize(s: string, sep: string = "_") {
return s;
}
}

export function getNodeMajorVersion(): number | undefined {
const match = process.version.match(/(\d+)\.(\d+)\.(\d+)/);
if (match) {
const [major] = match.slice(1).map((x) => parseInt(x));
return major;
}
return undefined;
}

0 comments on commit 6db1b04

Please sign in to comment.