diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml index 2c73af0e43..feed28784a 100644 --- a/.github/workflows/integrate.yml +++ b/.github/workflows/integrate.yml @@ -69,8 +69,8 @@ jobs: env: SLS_AWS_SDK_V3: '1' - windowsNode16: - name: '[Windows] Node 16: Unit tests' + windowsNode18: + name: '[Windows] Node 18: Unit tests' runs-on: windows-latest steps: - name: Checkout repository @@ -83,13 +83,13 @@ jobs: path: | ~/.npm node_modules - key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} - restore-keys: npm-v16-${{ runner.os }}-${{ github.ref }}- + key: npm-v18-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + restore-keys: npm-v18-${{ runner.os }}-${{ github.ref }}- - name: Install Node.js and npm uses: actions/setup-node@v4 with: - node-version: 16.x + node-version: 18.x - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' @@ -99,8 +99,8 @@ jobs: - name: Unit tests run: npm test -- -b - linuxNode16: - name: '[Linux] Node 16: Isolated unit tests' + linuxNode18: + name: '[Linux] Node 18: Isolated unit tests' runs-on: ubuntu-latest steps: - name: Checkout repository @@ -113,13 +113,13 @@ jobs: path: | ~/.npm node_modules - key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} - restore-keys: npm-v16-${{ runner.os }}-${{ github.ref }}- + key: npm-v18-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + restore-keys: npm-v18-${{ runner.os }}-${{ github.ref }}- - name: Install Node.js and npm uses: actions/setup-node@v4 with: - node-version: 16.x + node-version: 18.x - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' @@ -134,7 +134,7 @@ jobs: integrate: name: Integrate runs-on: ubuntu-latest - needs: [linuxNode22, windowsNode16, linuxNode16] + needs: [linuxNode22, windowsNode18, linuxNode18] timeout-minutes: 30 # Default is 360 env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 7729baf84a..deac612164 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -82,8 +82,8 @@ jobs: env: SLS_AWS_SDK_V3: '1' - windowsNode16: - name: '[Windows] Node 16: Unit tests' + windowsNode18: + name: '[Windows] Node 18: Unit tests' runs-on: windows-latest steps: - name: Checkout repository @@ -96,15 +96,15 @@ jobs: path: | ~/.npm node_modules - key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + key: npm-v18-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} restore-keys: | - npm-v16-${{ runner.os }}-${{ github.ref }}- - npm-v16-${{ runner.os }}-refs/heads/main- + npm-v18-${{ runner.os }}-${{ github.ref }}- + npm-v18-${{ runner.os }}-refs/heads/main- - name: Install Node.js and npm uses: actions/setup-node@v4 with: - node-version: 16.x + node-version: 18.x - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' @@ -114,8 +114,8 @@ jobs: - name: Unit tests run: npm test -- -b - linuxNode16: - name: '[Linux] Node 16: Isolated unit tests' + linuxNode18: + name: '[Linux] Node 18: Isolated unit tests' runs-on: ubuntu-latest steps: - name: Checkout repository @@ -128,15 +128,15 @@ jobs: path: | ~/.npm node_modules - key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + key: npm-v18-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} restore-keys: | - npm-v16-${{ runner.os }}-${{ github.ref }}- - npm-v16-${{ runner.os }}-refs/heads/main- + npm-v18-${{ runner.os }}-${{ github.ref }}- + npm-v18-${{ runner.os }}-refs/heads/main- - name: Install Node.js and npm uses: actions/setup-node@v4 with: - node-version: 16.x + node-version: 18.x - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' diff --git a/lib/classes/yaml-parser.js b/lib/classes/yaml-parser.js index 4f66ca40b1..e95e21c829 100644 --- a/lib/classes/yaml-parser.js +++ b/lib/classes/yaml-parser.js @@ -1,7 +1,8 @@ 'use strict'; +const $RefParser = require('@apidevtools/json-schema-ref-parser'); const yaml = require('js-yaml'); -const resolve = require('json-refs').resolveRefs; +const cloudformationSchema = require('@serverless/utils/cloudformation-schema'); class YamlParser { constructor(serverless) { @@ -9,17 +10,23 @@ class YamlParser { } async parse(yamlFilePath) { - const root = this.serverless.utils.readFileSync(yamlFilePath); - const options = { - filter: ['relative', 'remote'], - loaderOptions: { - processContent: (res, callback) => { - callback(null, yaml.load(res.text)); + return $RefParser.dereference(yamlFilePath, { + parse: { + yaml: { + parse(file) { + const contents = file.data.toString(); + try { + return yaml.load(contents, { + filename: file.url, + schema: cloudformationSchema, + }); + } catch (err) { + return yaml.load(contents, { filename: file.url }); + } + }, }, }, - location: yamlFilePath, - }; - return resolve(root, options).then((res) => res.resolved); + }); } } diff --git a/package.json b/package.json index 732e70976f..838bb9d87d 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "osls": "./bin/serverless.js" }, "dependencies": { + "@apidevtools/json-schema-ref-parser": "^14.2.1", "@aws-sdk/client-api-gateway": "^3.588.0", "@aws-sdk/client-apigatewayv2": "^3.588.0", "@aws-sdk/client-cloudformation": "^3.588.0", @@ -41,9 +42,9 @@ "@aws-sdk/client-sqs": "^3.588.0", "@aws-sdk/client-ssm": "^3.588.0", "@aws-sdk/client-sts": "^3.588.0", + "@aws-sdk/credential-providers": "^3.588.0", "@aws-sdk/lib-dynamodb": "^3.588.0", "@aws-sdk/lib-storage": "^3.588.0", - "@aws-sdk/credential-providers": "^3.588.0", "@serverless/utils": "^6.13.1", "ajv": "^8.12.0", "ajv-formats": "^2.1.1", @@ -72,7 +73,6 @@ "is-docker": "^2.2.1", "js-yaml": "^4.1.0", "json-cycle": "^1.5.0", - "json-refs": "^3.0.15", "lodash": "^4.17.21", "memoizee": "^0.4.15", "micromatch": "^4.0.5", @@ -206,7 +206,7 @@ "test:isolated": "mocha-isolated \"test/unit/**/*.test.js\"" }, "engines": { - "node": ">=12.0" + "node": ">=18.0" }, "license": "MIT" } diff --git a/scripts/pkg/build.js b/scripts/pkg/build.js index 91fa85ff76..008b9da703 100755 --- a/scripts/pkg/build.js +++ b/scripts/pkg/build.js @@ -31,7 +31,7 @@ const spawnOptions = { cwd: serverlessPath, stdio: 'inherit' }; '-c', 'scripts/pkg/config.js', '--targets', - 'node16-linux-x64,node16-mac-x64,node16-win-x64', + 'node18-linux-x64,node18-mac-x64,node18-win-x64', '--out-path', 'dist', 'bin/serverless.js',