From 927e32563b4162c49ffb05fb6853b5fd242d53cd Mon Sep 17 00:00:00 2001 From: Matteo Pietro Dazzi Date: Fri, 6 Dec 2024 21:10:54 +0100 Subject: [PATCH 1/6] BREAKING CHANGE: node test runner --- .github/workflows/ci.yml | 3 +-- package.json | 4 +--- test/client.test.js | 25 ++++++++++++++++--------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78cbe7d..109723c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,6 @@ jobs: strategy: matrix: node-version: - - 18 - 20 - 22 steps: @@ -28,7 +27,7 @@ jobs: with: role-to-assume: ${{ vars.AWS_ROLE_TO_ASSUME }} aws-region: ${{ vars.AWS_REGION }} - - run: npm run test:ci + - run: npm run test automerge: needs: build runs-on: ubuntu-latest diff --git a/package.json b/package.json index 0f28c11..2148a7d 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,7 @@ "lint": "eslint .", "lint:fix": "npm run lint -- --fix", "lint:staged": "lint-staged", - "test": "tap --reporter=spec --coverage-report=html --coverage-report=text --100 --no-browser test/*.test.js test/**/*.test.js", - "test:ci": "tap --no-color --reporter=spec --coverage-report=json --coverage-report=text --100 test/*.test.js test/**/*.test.js", + "test": "node --test", "prepare": "husky" }, "repository": { @@ -45,7 +44,6 @@ "prettier": "^3.0.1", "proxyquire": "^2.1.3", "sinon": "^19.0.2", - "tap": "^16.0.1", "uuid": "^11.0.2" }, "lint-staged": { diff --git a/test/client.test.js b/test/client.test.js index d803ebf..df72542 100644 --- a/test/client.test.js +++ b/test/client.test.js @@ -1,6 +1,7 @@ 'use strict' -const { test, beforeEach } = require('tap') +const { test, beforeEach } = require('node:test') + const sinon = require('sinon') const proxyquire = require('proxyquire') @@ -37,10 +38,13 @@ test('get', (t) => { SMStub.resolves({ SecretString: 'secret payload' }) const secret = await client.get('secret/name') - t.ok(GSVCStub.call, 'new instance of GetSecretValueCommand') - t.ok(SMStub.called, 'calls send') - t.ok(SMStub.calledWith(sinon.match({ input: { SecretId: 'secret/name' } })), 'provides name as SecretId to send') - t.equal(secret, 'secret payload', 'extracts SecretString') + t.assert.ok(GSVCStub.call, 'new instance of GetSecretValueCommand') + t.assert.ok(SMStub.called, 'calls send') + t.assert.ok( + SMStub.calledWith(sinon.match({ input: { SecretId: 'secret/name' } })), + 'provides name as SecretId to send' + ) + t.assert.equal(secret, 'secret payload', 'extracts SecretString') }) t.test('SecretBinary', async (t) => { @@ -50,9 +54,12 @@ test('get', (t) => { SecretBinary: Buffer.from('secret payload').toString('base64') }) const secret = await client.get('secret/name') - t.ok(SMStub.called, 'calls send') - t.ok(SMStub.calledWith(sinon.match({ input: { SecretId: 'secret/name' } })), 'provides name as SecretId to send') - t.equal(secret, 'secret payload', 'extracts SecretBinary') + t.assert.ok(SMStub.called, 'calls send') + t.assert.ok( + SMStub.calledWith(sinon.match({ input: { SecretId: 'secret/name' } })), + 'provides name as SecretId to send' + ) + t.assert.equal(secret, 'secret payload', 'extracts SecretBinary') }) t.test('sdk error', async (t) => { @@ -63,6 +70,6 @@ test('get', (t) => { const promise = client.get('secret/name') - await t.rejects(promise, 'throws error') + await t.assert.rejects(promise, 'throws error') }) }) From b2e654b5b07745164b539441e4fe88bbd4b033a9 Mon Sep 17 00:00:00 2001 From: Matteo Pietro Dazzi Date: Fri, 6 Dec 2024 21:12:08 +0100 Subject: [PATCH 2/6] chore: deps --- package.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 2148a7d..5a76da2 100644 --- a/package.json +++ b/package.json @@ -31,20 +31,20 @@ }, "devDependencies": { "eslint": "^8.18.0", - "eslint-config-prettier": "^9.0.0", - "eslint-config-standard": "^17.0.0", - "eslint-plugin-import": "^2.26.0", - "eslint-plugin-n": "^16.0.0", - "eslint-plugin-prettier": "^5.0.0", - "eslint-plugin-promise": "^6.0.0", + "eslint-config-prettier": "^9.1.0", + "eslint-config-standard": "^17.1.0", + "eslint-plugin-import": "^2.31.0", + "eslint-plugin-n": "^17.14.0", + "eslint-plugin-prettier": "^5.2.1", + "eslint-plugin-promise": "^7.2.1", "eslint-plugin-standard": "^5.0.0", "fastify": "^4.0.3", - "husky": "^9.0.11", - "lint-staged": "^15.0.1", - "prettier": "^3.0.1", + "husky": "^9.1.7", + "lint-staged": "^15.2.10", + "prettier": "^3.4.2", "proxyquire": "^2.1.3", "sinon": "^19.0.2", - "uuid": "^11.0.2" + "uuid": "^11.0.3" }, "lint-staged": { "*.js": [ From bb7158d9d802b7496d0f9c6b64f4a6de63ae1ada Mon Sep 17 00:00:00 2001 From: Matteo Pietro Dazzi Date: Fri, 6 Dec 2024 21:13:43 +0100 Subject: [PATCH 3/6] BREAKING CHANGE: fastify v5 --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 5a76da2..351d727 100644 --- a/package.json +++ b/package.json @@ -32,13 +32,12 @@ "devDependencies": { "eslint": "^8.18.0", "eslint-config-prettier": "^9.1.0", - "eslint-config-standard": "^17.1.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-n": "^17.14.0", "eslint-plugin-prettier": "^5.2.1", "eslint-plugin-promise": "^7.2.1", "eslint-plugin-standard": "^5.0.0", - "fastify": "^4.0.3", + "fastify": "^5.1.0", "husky": "^9.1.7", "lint-staged": "^15.2.10", "prettier": "^3.4.2", From 12c6c29b2749c154706e80184d679d1a38c9999b Mon Sep 17 00:00:00 2001 From: Matteo Pietro Dazzi Date: Fri, 6 Dec 2024 21:15:18 +0100 Subject: [PATCH 4/6] fix: removed standard --- .eslintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index 427b291..2f3a04b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,5 +1,5 @@ { - "extends": ["standard", "plugin:prettier/recommended"], + "extends": ["plugin:prettier/recommended"], "env": { "browser": false, "commonjs": true, From a40c1eb7de787e5a692dcbd4aca28b38fdced58e Mon Sep 17 00:00:00 2001 From: Matteo Pietro Dazzi Date: Fri, 6 Dec 2024 21:17:25 +0100 Subject: [PATCH 5/6] feat: eslint 9 --- .eslintrc | 19 ------------------- eslint.config.js | 17 +++++++++++++++++ lib/client.js | 2 +- package.json | 2 +- 4 files changed, 19 insertions(+), 21 deletions(-) delete mode 100644 .eslintrc create mode 100644 eslint.config.js diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 2f3a04b..0000000 --- a/.eslintrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": ["plugin:prettier/recommended"], - "env": { - "browser": false, - "commonjs": true, - "es2021": true - }, - "parserOptions": { - "ecmaVersion": 12 - }, - "rules": { - "import/order": [ - "error", - { - "newlines-between": "always" - } - ] - } -} diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..68247b7 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,17 @@ +import js from '@eslint/js' +import prettierRecommended from 'eslint-plugin-prettier/recommended' +import globals from 'globals' + +export default [ + js.configs.recommended, + prettierRecommended, + { + languageOptions: { + globals: { + ...globals.node + }, + ecmaVersion: 'latest', + sourceType: 'module' + } + } +] diff --git a/lib/client.js b/lib/client.js index f5f926a..58dfd50 100644 --- a/lib/client.js +++ b/lib/client.js @@ -16,7 +16,7 @@ class AwsClient { } else { return Buffer.from(data.SecretBinary, 'base64').toString('utf8') } - } catch (err) { + } catch { throw new Error(`Secret not found: ${name}`) } } diff --git a/package.json b/package.json index 351d727..faa4bb7 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "node": ">=18" }, "devDependencies": { - "eslint": "^8.18.0", + "eslint": "^9.16.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-n": "^17.14.0", From b16ed1e8d229fdcaa1ba2b0f7845ba2711712c9d Mon Sep 17 00:00:00 2001 From: Matteo Pietro Dazzi Date: Fri, 6 Dec 2024 21:19:30 +0100 Subject: [PATCH 6/6] fix: commonjs --- .eslintignore | 2 -- eslint.config.js | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) delete mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index c1cb757..0000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -.nyc_output/ -coverage/ diff --git a/eslint.config.js b/eslint.config.js index 68247b7..4b9510f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,8 +1,8 @@ -import js from '@eslint/js' -import prettierRecommended from 'eslint-plugin-prettier/recommended' -import globals from 'globals' +const js = require('@eslint/js') +const prettierRecommended = require('eslint-plugin-prettier/recommended') +const globals = require('globals') -export default [ +module.exports = [ js.configs.recommended, prettierRecommended, {