From 942f2f85abf2037ebad50336e78babc813e8ecbd Mon Sep 17 00:00:00 2001 From: "K.Utsunomiya" Date: Thu, 6 Nov 2025 09:22:31 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=E5=88=A9=E7=94=A8=E3=81=97=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=82=8BGitHub=20Actions=E3=81=AE=E3=83=90=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=83=A7=E3=83=B3=E3=82=A2=E3=83=83=E3=83=97=E3=83=87?= =?UTF-8?q?=E3=83=BC=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 10 +++++----- .github/workflows/release.yml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f68785b..cca2cd7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,9 +5,9 @@ name: Node.js CI on: push: - branches: ['main'] + branches: ["main"] pull_request: - branches: ['main'] + branches: ["main"] jobs: build: @@ -19,12 +19,12 @@ jobs: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 + uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 with: node-version: ${{ matrix.node-version }} - cache: 'npm' + cache: "npm" - run: npm ci - run: npm run build - run: npm test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e86041c..a9ef0e2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,17 +3,17 @@ name: release on: push: tags: - - 'v*' + - "v*" jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 with: - node-version: '18.x' - registry-url: 'https://registry.npmjs.org' + node-version: "18.x" + registry-url: "https://registry.npmjs.org" - name: release on npm run: | npm ci From 63f1559c450f0452176666e191d4f90ef6083e28 Mon Sep 17 00:00:00 2001 From: "K.Utsunomiya" Date: Thu, 6 Nov 2025 09:24:23 +0900 Subject: [PATCH 2/6] =?UTF-8?q?release.yml:=20setup-node=E3=81=A7.node-ver?= =?UTF-8?q?sion=E3=81=AE=E3=82=82=E3=81=AE=E3=82=92=E8=AA=AD=E3=82=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a9ef0e2..fac5398 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 with: - node-version: "18.x" + node-version-file: ".node-version" registry-url: "https://registry.npmjs.org" - name: release on npm run: | From fbcd81e6b3fc2e28822f38dcbc2ef032b2015890 Mon Sep 17 00:00:00 2001 From: "K.Utsunomiya" Date: Thu, 6 Nov 2025 09:28:54 +0900 Subject: [PATCH 3/6] =?UTF-8?q?ci.yml:=20strategy.matrix=E3=81=AB22.x?= =?UTF-8?q?=E3=81=A824.x=E3=82=92=E8=BF=BD=E8=A8=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cca2cd7..32c3871 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: - node-version: [18.x, 20.x] + node-version: [18.x, 20.x, 22.x, 24.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: From aae6889af6ac4d8d7f91c5b31a12588e7857c95c Mon Sep 17 00:00:00 2001 From: "K.Utsunomiya" Date: Thu, 6 Nov 2025 10:11:50 +0900 Subject: [PATCH 4/6] =?UTF-8?q?npm-scripts=E3=81=ABformat,=20typecheck?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0,=20eslint=E3=81=ABtests=E3=83=87=E3=82=A3?= =?UTF-8?q?=E3=83=AC=E3=82=AF=E3=83=88=E3=83=AA=E3=82=92=E5=AF=BE=E8=B1=A1?= =?UTF-8?q?=E3=81=AB=E5=8A=A0=E3=81=88=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9441209..ede0c67 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,11 @@ "scripts": { "build": "tsup", "postbuild": "mkdir -p ./dist/umd/ && cp -pR ./dist/iife/* ./dist/umd", - "lint": "eslint ./src", - "lint:fix": "eslint --fix ./src", + "lint": "eslint ./src ./tests", + "lint:fix": "eslint --fix ./src ./tests", + "format": "prettier --check ./src ./tests", + "format:fix": "prettier --write ./src ./tests", + "typecheck": "tsc --noEmit", "test": "jest --coverage=false", "test:coverage": "jest --coverage=true" }, From 46576761300d1205ea031a904a55615166e7bf1e Mon Sep 17 00:00:00 2001 From: "K.Utsunomiya" Date: Thu, 6 Nov 2025 10:12:25 +0900 Subject: [PATCH 5/6] =?UTF-8?q?format:=20tests=E3=83=87=E3=82=A3=E3=83=AC?= =?UTF-8?q?=E3=82=AF=E3=83=88=E3=83=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/get.test.ts | 17 +++- tests/getAllContentIds.test.ts | 176 +++++++++++++++++++++++---------- tests/getAllContents.test.ts | 106 ++++++++++++++------ 3 files changed, 210 insertions(+), 89 deletions(-) diff --git a/tests/get.test.ts b/tests/get.test.ts index 1fb1be8..8bb7335 100644 --- a/tests/get.test.ts +++ b/tests/get.test.ts @@ -58,15 +58,22 @@ describe('get', () => { test('Return error message in case of server error', () => { // Create temporary server error server.use( - http.get(`${testBaseUrl}/list-type`, () => { - return HttpResponse.json({ message: 'Internal Server Error' }, { status: 500 }); - }, { once: true }) + http.get( + `${testBaseUrl}/list-type`, + () => { + return HttpResponse.json( + { message: 'Internal Server Error' }, + { status: 500 }, + ); + }, + { once: true }, + ), ); expect(client.get({ endpoint: 'list-type' })).rejects.toThrow( new Error( - 'fetch API response status: 500\n message is `Internal Server Error`' - ) + 'fetch API response status: 500\n message is `Internal Server Error`', + ), ); }); }); diff --git a/tests/getAllContentIds.test.ts b/tests/getAllContentIds.test.ts index a30d4aa..1c62e90 100644 --- a/tests/getAllContentIds.test.ts +++ b/tests/getAllContentIds.test.ts @@ -15,18 +15,32 @@ describe('getAllContentIds', () => { test('should fetch all content ids', async () => { server.use( - http.get(`${testBaseUrl}/getAllContentIds-list-type`, () => { - return HttpResponse.json({ + http.get( + `${testBaseUrl}/getAllContentIds-list-type`, + () => { + return HttpResponse.json( + { totalCount: 100, - }, { status: 200 }); - }, { once: true }), - http.get(`${testBaseUrl}/getAllContentIds-list-type`, () => { - return HttpResponse.json({ + }, + { status: 200 }, + ); + }, + { once: true }, + ), + http.get( + `${testBaseUrl}/getAllContentIds-list-type`, + () => { + return HttpResponse.json( + { contents: Array(100) - .fill(null) - .map((_, index) => ({ id: `id${index}` })), - }, { status: 200 }); - }, { once: true }), + .fill(null) + .map((_, index) => ({ id: `id${index}` })), + }, + { status: 200 }, + ); + }, + { once: true }, + ), ); const result = await client.getAllContentIds({ @@ -40,32 +54,60 @@ describe('getAllContentIds', () => { test('should handle pagination and fetch more than limit', async () => { server.use( - http.get(`${testBaseUrl}/getAllContentIds-list-type`, () => { - return HttpResponse.json({ + http.get( + `${testBaseUrl}/getAllContentIds-list-type`, + () => { + return HttpResponse.json( + { totalCount: 250, - }, { status: 200 }); - }, { once: true }), - http.get(`${testBaseUrl}/getAllContentIds-list-type`, () => { - return HttpResponse.json({ + }, + { status: 200 }, + ); + }, + { once: true }, + ), + http.get( + `${testBaseUrl}/getAllContentIds-list-type`, + () => { + return HttpResponse.json( + { contents: Array(100) - .fill(null) - .map((_, index) => ({ id: `id${index}` })), - }, { status: 200 }); - }, { once: true }), - http.get(`${testBaseUrl}/getAllContentIds-list-type`, () => { - return HttpResponse.json({ + .fill(null) + .map((_, index) => ({ id: `id${index}` })), + }, + { status: 200 }, + ); + }, + { once: true }, + ), + http.get( + `${testBaseUrl}/getAllContentIds-list-type`, + () => { + return HttpResponse.json( + { contents: Array(100) - .fill(null) - .map((_, index) => ({ id: `id${index + 100}` })), - }, { status: 200 }); - }, { once: true }), - http.get(`${testBaseUrl}/getAllContentIds-list-type`, () => { - return HttpResponse.json({ + .fill(null) + .map((_, index) => ({ id: `id${index + 100}` })), + }, + { status: 200 }, + ); + }, + { once: true }, + ), + http.get( + `${testBaseUrl}/getAllContentIds-list-type`, + () => { + return HttpResponse.json( + { contents: Array(50) - .fill(null) - .map((_, index) => ({ id: `id${index + 200}` })), - }, { status: 200 }); - }, { once: true }), + .fill(null) + .map((_, index) => ({ id: `id${index + 200}` })), + }, + { status: 200 }, + ); + }, + { once: true }, + ), ); const result = await client.getAllContentIds({ @@ -79,18 +121,32 @@ describe('getAllContentIds', () => { test('should fetch all content ids with alternateField field', async () => { server.use( - http.get(`${testBaseUrl}/getAllContentIds-list-type`, () => { - return HttpResponse.json({ + http.get( + `${testBaseUrl}/getAllContentIds-list-type`, + () => { + return HttpResponse.json( + { totalCount: 100, - }, { status: 200 }); - }, { once: true }), - http.get(`${testBaseUrl}/getAllContentIds-list-type`, () => { - return HttpResponse.json({ + }, + { status: 200 }, + ); + }, + { once: true }, + ), + http.get( + `${testBaseUrl}/getAllContentIds-list-type`, + () => { + return HttpResponse.json( + { contents: Array(100) - .fill(null) - .map((_, index) => ({ url: `id${index}` })), - }, { status: 200 }); - }, { once: true }), + .fill(null) + .map((_, index) => ({ url: `id${index}` })), + }, + { status: 200 }, + ); + }, + { once: true }, + ), ); const result = await client.getAllContentIds({ @@ -105,18 +161,34 @@ describe('getAllContentIds', () => { test('should throw error when alternateField field is not string', async () => { server.use( - http.get(`${testBaseUrl}/getAllContentIds-list-type`, () => { - return HttpResponse.json({ + http.get( + `${testBaseUrl}/getAllContentIds-list-type`, + () => { + return HttpResponse.json( + { totalCount: 100, - }, { status: 200 }); - }, { once: true }), - http.get(`${testBaseUrl}/getAllContentIds-list-type`, () => { - return HttpResponse.json({ + }, + { status: 200 }, + ); + }, + { once: true }, + ), + http.get( + `${testBaseUrl}/getAllContentIds-list-type`, + () => { + return HttpResponse.json( + { contents: Array(100) - .fill(null) - .map(() => ({ image: { url: 'url', width: 100, height: 100 } })), - }, { status: 200 }); - }, { once: true }), + .fill(null) + .map(() => ({ + image: { url: 'url', width: 100, height: 100 }, + })), + }, + { status: 200 }, + ); + }, + { once: true }, + ), ); await expect( diff --git a/tests/getAllContents.test.ts b/tests/getAllContents.test.ts index 159bcf5..b4ca587 100644 --- a/tests/getAllContents.test.ts +++ b/tests/getAllContents.test.ts @@ -15,18 +15,32 @@ describe('getAllContents', () => { test('should fetch all contents', async () => { server.use( - http.get(`${testBaseUrl}/getAllContents-list-type`, () => { - return HttpResponse.json({ + http.get( + `${testBaseUrl}/getAllContents-list-type`, + () => { + return HttpResponse.json( + { totalCount: 100, - }, { status: 200 }); - }, { once: true }), - http.get(`${testBaseUrl}/getAllContents-list-type`, () => { - return HttpResponse.json({ + }, + { status: 200 }, + ); + }, + { once: true }, + ), + http.get( + `${testBaseUrl}/getAllContents-list-type`, + () => { + return HttpResponse.json( + { contents: Array(100) - .fill(null) - .map((_, index) => ({ id: `id${index}` })), - }, { status: 200 }); - }, { once: true }), + .fill(null) + .map((_, index) => ({ id: `id${index}` })), + }, + { status: 200 }, + ); + }, + { once: true }, + ), ); const result = await client.getAllContents({ @@ -40,32 +54,60 @@ describe('getAllContents', () => { test('should handle pagination and fetch more than limit', async () => { server.use( - http.get(`${testBaseUrl}/getAllContents-list-type`, () => { - return HttpResponse.json({ + http.get( + `${testBaseUrl}/getAllContents-list-type`, + () => { + return HttpResponse.json( + { totalCount: 250, - }, { status: 200 }); - }, { once: true }), - http.get(`${testBaseUrl}/getAllContents-list-type`, () => { - return HttpResponse.json({ + }, + { status: 200 }, + ); + }, + { once: true }, + ), + http.get( + `${testBaseUrl}/getAllContents-list-type`, + () => { + return HttpResponse.json( + { contents: Array(100) - .fill(null) - .map((_, index) => ({ id: `id${index}` })), - }, { status: 200 }); - }, { once: true }), - http.get(`${testBaseUrl}/getAllContents-list-type`, () => { - return HttpResponse.json({ + .fill(null) + .map((_, index) => ({ id: `id${index}` })), + }, + { status: 200 }, + ); + }, + { once: true }, + ), + http.get( + `${testBaseUrl}/getAllContents-list-type`, + () => { + return HttpResponse.json( + { contents: Array(100) - .fill(null) - .map((_, index) => ({ id: `id${index + 100}` })), - }, { status: 200 }); - }, { once: true }), - http.get(`${testBaseUrl}/getAllContents-list-type`, () => { - return HttpResponse.json({ + .fill(null) + .map((_, index) => ({ id: `id${index + 100}` })), + }, + { status: 200 }, + ); + }, + { once: true }, + ), + http.get( + `${testBaseUrl}/getAllContents-list-type`, + () => { + return HttpResponse.json( + { contents: Array(50) - .fill(null) - .map((_, index) => ({ id: `id${index + 200}` })), - }, { status: 200 }); - }, { once: true }), + .fill(null) + .map((_, index) => ({ id: `id${index + 200}` })), + }, + { status: 200 }, + ); + }, + { once: true }, + ), ); const result = await client.getAllContents({ From bba69ae51fb086d81e8c7a8d1ed318ddc3c3dc64 Mon Sep 17 00:00:00 2001 From: "K.Utsunomiya" Date: Thu, 6 Nov 2025 10:13:20 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=E3=83=AF=E3=83=BC=E3=82=AF=E3=83=95?= =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=81=A7=E9=9D=99=E7=9A=84=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E3=81=AE=E3=82=B8=E3=83=A7=E3=83=96=E3=82=92=E7=94=A8=E6=84=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 25 ++++++++++++++++++++++--- .github/workflows/release.yml | 1 + 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32c3871..d448ea1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,24 @@ on: branches: ["main"] jobs: - build: + static-check: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 + with: + node-version-file: ".node-version" + cache: "npm" + - run: npm ci + - name: Format Check + run: npm run format + - name: Lint + run: npm run lint + - name: Type Check + run: npm run typecheck + + build-and-test: runs-on: ubuntu-latest strategy: @@ -26,5 +43,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: "npm" - run: npm ci - - run: npm run build - - run: npm test + - name: Build + run: npm run build + - name: Unit Tests + run: npm run test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fac5398..f1f8d76 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,7 @@ jobs: run: | npm ci npm run lint + npm run typecheck npm run test npm run build - run: npm publish