From 69dd4b97453a7ca34b541313d1063a1e0c1c7876 Mon Sep 17 00:00:00 2001 From: Mariusz Nowak Date: Tue, 25 Aug 2020 16:49:43 +0200 Subject: [PATCH] feat: Drop support for Node.js versions below v10 BREAKING CHANGE: Node.js versions below v10 are no longer supported --- .github/workflows/integrate.yml | 70 ++----------------------------- .github/workflows/validate.yml | 74 ++------------------------------- bin/serverless.js | 37 +++++++---------- package.json | 2 +- scripts/serverless.js | 19 +++++---- 5 files changed, 34 insertions(+), 168 deletions(-) diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml index 5c8b99eab6b..9b86883e9cf 100644 --- a/.github/workflows/integrate.yml +++ b/.github/workflows/integrate.yml @@ -12,7 +12,7 @@ env: jobs: linuxNode14: - name: '[Linux] Node.js 14: Unit tests & Publish canary' + name: '[Linux] Node.js 14: Publish canary, Unit & packaging tests ' runs-on: ubuntu-latest steps: - name: Resolve last validated commit hash (for `git diff` purposes) @@ -67,6 +67,8 @@ jobs: # Some tests depend on TTY support, which is missing in GA runner # Workaround taken from https://github.com/actions/runner/issues/241#issuecomment-577360161 run: script -e -c "npm test -- -b" + - name: Packaging tests + run: npm run integration-test-run-package windowsNode14: name: '[Windows] Node.js v14: Unit tests' @@ -168,72 +170,6 @@ jobs: CODECOV_TOKEN: 3898f3e1-f317-453e-a3a9-0462390f93c5 run: npx codecov - linuxNode8: - name: '[Linux] Node.js v8: Unit & packaging tests' - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Retrieve dependencies from cache - id: cacheNpm - uses: actions/cache@v2 - with: - path: | - ~/.npm - node_modules - key: npm-v8-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} - restore-keys: npm-v8-${{ runner.os }}-${{ github.ref }}- - - - name: Install Node.js and npm - uses: actions/setup-node@v1 - with: - node-version: 8.x - - - name: Install dependencies - if: steps.cacheNpm.outputs.cache-hit != 'true' - run: | - npm update --no-save - npm update --save-dev --no-save - - name: Unit tests - # Some tests depend on TTY support, which is missing in GA runner - # Workaround taken from https://github.com/actions/runner/issues/241#issuecomment-577360161 - run: script -e -c "npm test -- -b" - - name: Packaging tests - run: npm run integration-test-run-package - - linuxNode6: - name: '[Linux] Node.js v6: Unit tests' - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Retrieve dependencies from cache - id: cacheNpm - uses: actions/cache@v2 - with: - path: | - ~/.npm - node_modules - key: npm-v6-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} - restore-keys: npm-v6-${{ runner.os }}-${{ github.ref }}- - - - name: Install Node.js and npm - uses: actions/setup-node@v1 - with: - node-version: 6.x - - - name: Install dependencies - if: steps.cacheNpm.outputs.cache-hit != 'true' - run: | - npm update --no-save - npm update --save-dev --no-save - - name: Unit tests - # Some tests depend on TTY support, which is missing in GA runner - # Workaround taken from https://github.com/actions/runner/issues/241#issuecomment-577360161 - run: script -e -c "npm test -- -b" - integrate: name: Integrate runs-on: ubuntu-latest diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 54aa9a45914..0e1be5766a9 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -12,7 +12,7 @@ env: jobs: linuxNode14: - name: '[Linux] Node.js 14: Lint, Formatting, Eventual Commitlint, Eventual Changelog & Unit tests' + name: '[Linux] Node.js 14: Lint, Formatting, Eventual Commitlint, Eventual Changelog, Unit & packaging tests' runs-on: ubuntu-latest steps: - name: Checkout repository @@ -69,6 +69,8 @@ jobs: # Some tests depend on TTY support, which is missing in GA runner # Workaround taken from https://github.com/actions/runner/issues/241#issuecomment-577360161 run: script -e -c "npm test -- -b" + - name: Packaging tests + run: npm run integration-test-run-package windowsNode14: name: '[Windows] Node.js v14: Unit tests' @@ -175,73 +177,3 @@ jobs: env: CODECOV_TOKEN: 3898f3e1-f317-453e-a3a9-0462390f93c5 run: npx codecov - - linuxNode8: - name: '[Linux] Node.js v8: Unit & packaging tests' - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Retrieve dependencies from cache - id: cacheNpm - uses: actions/cache@v2 - with: - path: | - ~/.npm - node_modules - key: npm-v8-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} - restore-keys: | - npm-v8-${{ runner.os }}-${{ github.ref }}- - npm-v8-${{ runner.os }}-refs/heads/master- - - - name: Install Node.js and npm - uses: actions/setup-node@v1 - with: - node-version: 8.x - - - name: Install dependencies - if: steps.cacheNpm.outputs.cache-hit != 'true' - run: | - npm update --no-save - npm update --save-dev --no-save - - name: Unit tests - # Some tests depend on TTY support, which is missing in GA runner - # Workaround taken from https://github.com/actions/runner/issues/241#issuecomment-577360161 - run: script -e -c "npm test -- -b" - - name: Packaging tests - run: npm run integration-test-run-package - - linuxNode6: - name: '[Linux] Node.js v6: Unit tests' - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Retrieve dependencies from cache - id: cacheNpm - uses: actions/cache@v2 - with: - path: | - ~/.npm - node_modules - key: npm-v6-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} - restore-keys: | - npm-v6-${{ runner.os }}-${{ github.ref }}- - npm-v6-${{ runner.os }}-refs/heads/master- - - - name: Install Node.js and npm - uses: actions/setup-node@v1 - with: - node-version: 6.x - - - name: Install dependencies - if: steps.cacheNpm.outputs.cache-hit != 'true' - run: | - npm update --no-save - npm update --save-dev --no-save - - name: Unit tests - # Some tests depend on TTY support, which is missing in GA runner - # Workaround taken from https://github.com/actions/runner/issues/241#issuecomment-577360161 - run: script -e -c "npm test -- -b" diff --git a/bin/serverless.js b/bin/serverless.js index f8b796ae3b8..c1ce1b281c4 100755 --- a/bin/serverless.js +++ b/bin/serverless.js @@ -10,30 +10,25 @@ if (require('../lib/utils/isStandaloneExecutable')) { } } -const nodeVersion = Number(process.version.split('.')[0].slice(1)); - // CLI Triage -// Serverless Components work only in Node.js v8+ -if (nodeVersion >= 8) { - try { - const componentsV1 = require('@serverless/cli'); - const componentsV2 = require('@serverless/components'); +try { + const componentsV1 = require('@serverless/cli'); + const componentsV2 = require('@serverless/components'); - if (componentsV1.runningComponents()) { - // Serverless Components v1 CLI (deprecated) - componentsV1.runComponents(); - return; - } + if (componentsV1.runningComponents()) { + // Serverless Components v1 CLI (deprecated) + componentsV1.runComponents(); + return; + } - if (componentsV2.runningComponents()) { - // Serverless Components CLI - componentsV2.runComponents(); - return; - } - } catch (error) { - if (process.env.SLS_DEBUG) { - require('../lib/classes/Error').logWarning(`CLI triage crashed with: ${error.stack}`); - } + if (componentsV2.runningComponents()) { + // Serverless Components CLI + componentsV2.runComponents(); + return; + } +} catch (error) { + if (process.env.SLS_DEBUG) { + require('../lib/classes/Error').logWarning(`CLI triage crashed with: ${error.stack}`); } } diff --git a/package.json b/package.json index 046c6d6f377..192cc2f7835 100644 --- a/package.json +++ b/package.json @@ -219,7 +219,7 @@ "test:isolated": "mocha-isolated \"!(test|node_modules)/**/*.test.js\"" }, "engines": { - "node": ">=6.0" + "node": ">=10.0" }, "license": "MIT" } diff --git a/scripts/serverless.js b/scripts/serverless.js index b6465fda943..b68d4f78d36 100755 --- a/scripts/serverless.js +++ b/scripts/serverless.js @@ -4,6 +4,17 @@ require('essentials'); +const nodeVersion = Number(process.version.split('.')[0].slice(1)); + +if (nodeVersion < 10) { + const serverlessVersion = Number(require('../package.json').version.split('.')[0]); + process.stdout.write( + `Serverless: \x1b[91mInitialization error: Node.js v${nodeVersion} is not supported by ` + + `Serverless Framework v${serverlessVersion}. Please upgrade\x1b[39m\n` + ); + process.exit(1); +} + // global graceful-fs patch // https://github.com/isaacs/node-graceful-fs#global-patching require('graceful-fs').gracefulify(require('fs')); @@ -17,7 +28,6 @@ const BbPromise = require('bluebird'); const logError = require('../lib/classes/Error').logError; const uuid = require('uuid'); -const nodeVersion = Number(process.version.split('.')[0].slice(1)); const invocationId = uuid.v4(); let serverless; @@ -31,13 +41,6 @@ if (process.env.SLS_DEBUG) { }); } -if (nodeVersion < 10) { - require('../lib/utils/logDeprecation')( - 'OUTDATED_NODEJS', - 'Support for Node.js versions below v10 will be dropped with next major release. Please upgrade at https://nodejs.org/en/' - ); -} - const Serverless = require('../lib/Serverless'); serverless = new Serverless();