From 31f9ba84fcc2cdf35a3987a0fdc3e78b157c375c Mon Sep 17 00:00:00 2001 From: solufa Date: Thu, 14 Nov 2024 21:58:54 +0900 Subject: [PATCH 1/2] fix: update parseStringArrayTypeQueryParams test --- servers/all/$server.ts | 4 +--- src/buildServerFile.ts | 4 +--- tests/index.spec.ts | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/servers/all/$server.ts b/servers/all/$server.ts index fb4d3a2..b08b15b 100644 --- a/servers/all/$server.ts +++ b/servers/all/$server.ts @@ -113,9 +113,7 @@ const parseStringArrayTypeQueryParams = (stringArrayTypeParams: [string, boolean if (!isOptional && param === undefined) { query[key] = []; } else if (!isOptional || param !== undefined) { - const vals = (Array.isArray(param) ? param : [param]); - - query[key] = vals; + query[key] = Array.isArray(param) ? param : [param]; } delete query[`${key}[]`]; diff --git a/src/buildServerFile.ts b/src/buildServerFile.ts index f64f3e5..c05d30f 100644 --- a/src/buildServerFile.ts +++ b/src/buildServerFile.ts @@ -144,9 +144,7 @@ const parseStringArrayTypeQueryParams = (stringArrayTypeParams: [string, boolean if (!isOptional && param === undefined) { query[key] = []; } else if (!isOptional || param !== undefined) { - const vals = (Array.isArray(param) ? param : [param]); - - query[key] = vals; + query[key] = Array.isArray(param) ? param : [param]; } delete query[\`\${key}[]\`]; diff --git a/tests/index.spec.ts b/tests/index.spec.ts index 2f9a91f..9d21609 100644 --- a/tests/index.spec.ts +++ b/tests/index.spec.ts @@ -215,12 +215,12 @@ test('PUT: zod validations', async () => { fetchClient.put({ query: { requiredNum: 0, - requiredNumArr: [], + requiredNumArr: [1], id: '1', strArray: [], disable: 'true', bool: 1 as any, - boolArray: [], + boolArray: [true], }, body: { port }, }), From 164b3c80b2d03c4f151ee94b8b190b7eac893cd4 Mon Sep 17 00:00:00 2001 From: solufa Date: Thu, 14 Nov 2024 21:59:37 +0900 Subject: [PATCH 2/2] chore: publish to npm with provenance --- .github/workflows/nodejs.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 28f4e1e..3d3ec8b 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -4,15 +4,15 @@ on: [push, pull_request] jobs: test: - name: "Test on Node:${{ matrix.node-version }} OS:${{ matrix.os }}" + name: 'Test on Node:${{ matrix.node-version }} OS:${{ matrix.os }}' runs-on: ${{ matrix.os }} strategy: matrix: - node-version: [18, 20] + node-version: [20, 22] os: [ubuntu-latest] include: - os: windows-latest - node-version: 20 + node-version: 22 steps: - uses: actions/checkout@v3 - name: setup Node.js ${{ matrix.node-version }} @@ -22,7 +22,7 @@ jobs: - uses: actions/cache@v2 id: npm-cache with: - path: "node_modules" + path: 'node_modules' key: ${{ runner.os }}-node-v${{ matrix.node-version }}-npm-${{ hashFiles('package-lock.json') }} - run: npm install if: steps.npm-cache.outputs.cache-hit != 'true' @@ -35,18 +35,21 @@ jobs: release: runs-on: ubuntu-latest needs: test + permissions: + contents: read + id-token: write if: startsWith(github.ref, 'refs/tags/v') steps: - uses: actions/checkout@v3 - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: 20 - registry-url: "https://registry.npmjs.org" + node-version: 22 + registry-url: 'https://registry.npmjs.org' - uses: actions/cache@v2 id: npm-cache with: - path: "node_modules" + path: 'node_modules' key: ${{ runner.os }}-node-v20-npm-${{ hashFiles('package-lock.json') }} - run: npm install if: steps.npm-cache.outputs.cache-hit != 'true' @@ -55,6 +58,6 @@ jobs: VERSION="$(node -e 'console.log(process.argv[1].match(/^refs\/tags\/v(\d+\.\d+\.\d+)$/)[1])' "${{ github.ref }}")" node -e 'console.log(JSON.stringify({...require("./package.json"),version:process.argv[1]}, null, 2))' "$VERSION" | tee ./tmp-package.json mv ./tmp-package.json ./package.json - - run: npm publish + - run: npm publish --provenance env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}