Skip to content

Commit e263d2c

Browse files
committed
Migrate toolchain: tsup→tsdown, ESLint→Biome 2.x, Jest→Vitest, update all deps
- Build: tsup → tsdown (keeping CJS + ESM dual output) - Linting: ESLint → Biome 2.x (tab formatting, import organization) - Testing: Jest → Vitest (removed edge-runtime jest environment) - CI: pinned action SHAs, shared labd/gh-actions-typescript/pnpm-install, Node 20/22/24 matrix, npm provenance support - TypeScript 5.8→6.0, moduleResolution bundler, .ts import extensions - Fixed package.json exports.require (was .js, now .cjs) - Cleaned repository URL for npm provenance - Bumped next 15.3.2→15.5.15 (critical RCE vulnerability) - Added minimum-release-age=14d to .npmrc - Updated example to Next.js 15 App Router with React 19
1 parent 93f1ecf commit e263d2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3452
-7354
lines changed

.eslintrc.cjs

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 26 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: Main
22

3-
43
on:
54
push:
65
branches: ['main']
@@ -13,35 +12,10 @@ jobs:
1312
runs-on: ubuntu-latest
1413
steps:
1514
- name: Checkout
16-
uses: actions/checkout@v3
17-
18-
- name: Setup Node
19-
uses: actions/setup-node@v3
20-
with:
21-
node-version: 18
22-
23-
- uses: pnpm/action-setup@v2
24-
name: Install pnpm
25-
with:
26-
version: 7
27-
run_install: false
15+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2816

29-
- name: Get pnpm store directory
30-
id: pnpm-cache
31-
shell: bash
32-
run: |
33-
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
34-
35-
- uses: actions/cache@v3
36-
name: Setup pnpm cache
37-
with:
38-
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
39-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
40-
restore-keys: |
41-
${{ runner.os }}-pnpm-store-
42-
43-
- name: Install dependencies
44-
run: pnpm install --frozen-lockfile
17+
- name: Set up Node.js
18+
uses: labd/gh-actions-typescript/pnpm-install@4d7a6c7088328753fdbacbb9204aae4e2b9b00e2 # 1.0.0
4519

4620
- name: Lint
4721
run: pnpm lint
@@ -51,35 +25,10 @@ jobs:
5125
runs-on: ubuntu-latest
5226
steps:
5327
- name: Checkout
54-
uses: actions/checkout@v3
28+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5529

56-
- name: Setup Node
57-
uses: actions/setup-node@v3
58-
with:
59-
node-version: 18
60-
61-
- uses: pnpm/action-setup@v2
62-
name: Install pnpm
63-
with:
64-
version: 7
65-
run_install: false
66-
67-
- name: Get pnpm store directory
68-
id: pnpm-cache
69-
shell: bash
70-
run: |
71-
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
72-
73-
- uses: actions/cache@v3
74-
name: Setup pnpm cache
75-
with:
76-
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
77-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
78-
restore-keys: |
79-
${{ runner.os }}-pnpm-store-
80-
81-
- name: Install dependencies
82-
run: pnpm install --frozen-lockfile
30+
- name: Set up Node.js
31+
uses: labd/gh-actions-typescript/pnpm-install@4d7a6c7088328753fdbacbb9204aae4e2b9b00e2 # 1.0.0
8332

8433
- name: Check types
8534
run: pnpm tsc
@@ -89,37 +38,12 @@ jobs:
8938
runs-on: ubuntu-latest
9039
steps:
9140
- name: Checkout
92-
uses: actions/checkout@v3
93-
94-
- name: Setup Node
95-
uses: actions/setup-node@v3
96-
with:
97-
node-version: 18
98-
99-
- uses: pnpm/action-setup@v2
100-
name: Install pnpm
101-
with:
102-
version: 7
103-
run_install: false
41+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
10442

105-
- name: Get pnpm store directory
106-
id: pnpm-cache
107-
shell: bash
108-
run: |
109-
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
43+
- name: Set up Node.js
44+
uses: labd/gh-actions-typescript/pnpm-install@4d7a6c7088328753fdbacbb9204aae4e2b9b00e2 # 1.0.0
11045

111-
- uses: actions/cache@v3
112-
name: Setup pnpm cache
113-
with:
114-
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
115-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
116-
restore-keys: |
117-
${{ runner.os }}-pnpm-store-
118-
119-
- name: Install dependencies
120-
run: pnpm install --frozen-lockfile
121-
122-
- name: Check types
46+
- name: Test
12347
run: pnpm test
12448

12549
build:
@@ -128,39 +52,16 @@ jobs:
12852
runs-on: ${{ matrix.os }}
12953
strategy:
13054
matrix:
131-
node: ["16.x", "18.x"]
132-
os: [ubuntu-latest, windows-latest, macOS-latest]
55+
node: ["20.x", "22.x", "24.x"]
56+
os: [ubuntu-latest, macOS-latest]
13357
steps:
13458
- name: Checkout
135-
uses: actions/checkout@v3
136-
137-
- name: Setup Node
138-
uses: actions/setup-node@v3
139-
with:
140-
node-version: 18
141-
142-
- uses: pnpm/action-setup@v2
143-
name: Install pnpm
144-
with:
145-
version: 7
146-
run_install: false
147-
148-
- name: Get pnpm store directory
149-
id: pnpm-cache
150-
shell: bash
151-
run: |
152-
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
59+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
15360

154-
- uses: actions/cache@v3
155-
name: Setup pnpm cache
61+
- name: Set up Node.js
62+
uses: labd/gh-actions-typescript/pnpm-install@4d7a6c7088328753fdbacbb9204aae4e2b9b00e2 # 1.0.0
15663
with:
157-
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
158-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
159-
restore-keys: |
160-
${{ runner.os }}-pnpm-store-
161-
162-
- name: Install dependencies
163-
run: pnpm install --frozen-lockfile
64+
node-version: ${{ matrix.node }}
16465

16566
- name: Build
16667
run: pnpm build
@@ -170,37 +71,19 @@ jobs:
17071
needs: [build]
17172
if: github.ref == 'refs/heads/main'
17273
runs-on: ubuntu-latest
74+
environment: release
75+
permissions:
76+
id-token: write
77+
contents: write
78+
pull-requests: write
17379
steps:
17480
- name: Checkout
175-
uses: actions/checkout@v3
176-
177-
- name: Setup Node
178-
uses: actions/setup-node@v3
81+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17982
with:
180-
node-version: 18
83+
fetch-depth: 0
18184

182-
- uses: pnpm/action-setup@v2
183-
name: Install pnpm
184-
with:
185-
version: 7
186-
run_install: false
187-
188-
- name: Get pnpm store directory
189-
id: pnpm-cache
190-
shell: bash
191-
run: |
192-
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
193-
194-
- uses: actions/cache@v3
195-
name: Setup pnpm cache
196-
with:
197-
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
198-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
199-
restore-keys: |
200-
${{ runner.os }}-pnpm-store-
201-
202-
- name: Install dependencies
203-
run: pnpm install --frozen-lockfile
85+
- name: Set up Node.js
86+
uses: labd/gh-actions-typescript/pnpm-install@4d7a6c7088328753fdbacbb9204aae4e2b9b00e2 # 1.0.0
20487

20588
- name: Build
20689
run: pnpm build
@@ -210,10 +93,8 @@ jobs:
21093
with:
21194
title: "Release new version"
21295
commit: "update version"
213-
publish: pnpm publish
96+
publish: pnpm publish --provenance
21497
env:
21598
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21699
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
217100
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
218-
219-

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
node_modules
44
dist
55
coverage/
6+
.claude/

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
save-prefix=""
22
auto-install-peers=true
33
strict-peer-dependencies=false
4+
minimum-release-age=14d

biome.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.4.12/schema.json",
3+
"files": {
4+
"includes": ["src/**", "test/**", "*.config.ts", "*.json", ".github/**"]
5+
},
6+
"formatter": {
7+
"enabled": true,
8+
"indentStyle": "tab",
9+
"indentWidth": 2
10+
},
11+
"linter": {
12+
"enabled": true,
13+
"rules": {
14+
"recommended": true,
15+
"suspicious": {
16+
"noExplicitAny": "off"
17+
},
18+
"correctness": {
19+
"noUnusedImports": "error"
20+
}
21+
}
22+
},
23+
"assist": {
24+
"actions": {
25+
"source": {
26+
"organizeImports": "on"
27+
}
28+
}
29+
}
30+
}

examples/basic/.eslintrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/basic/README.md

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,16 @@
1-
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
1+
# Basic Auth Middleware Example
22

3-
## Getting Started
3+
A minimal [Next.js](https://nextjs.org/) example using `nextjs-basic-auth-middleware`.
44

5-
First, run the development server:
5+
## Getting Started
66

77
```bash
8-
npm run dev
9-
# or
10-
yarn dev
8+
pnpm install
9+
pnpm dev
1110
```
1211

13-
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
14-
15-
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
16-
17-
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
18-
19-
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
20-
21-
## Learn More
22-
23-
To learn more about Next.js, take a look at the following resources:
24-
25-
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26-
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
27-
28-
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
29-
30-
## Deploy on Vercel
12+
Open [http://localhost:3000](http://localhost:3000) and authenticate with `test:test`.
3113

32-
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
14+
## How it works
3315

34-
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
16+
The `middleware.ts` file in the project root uses `createNextAuthMiddleware` to protect all routes with basic authentication.

examples/basic/app/layout.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const metadata = {
2+
title: "Basic Auth Example",
3+
description: "Example of nextjs-basic-auth-middleware",
4+
};
5+
6+
export default function RootLayout({
7+
children,
8+
}: {
9+
children: React.ReactNode;
10+
}) {
11+
return (
12+
<html lang="en">
13+
<body>{children}</body>
14+
</html>
15+
);
16+
}

examples/basic/app/page.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default function Home() {
2+
return (
3+
<main>
4+
<h1>Welcome to Next.js with Basic Auth!</h1>
5+
<p>You are authenticated.</p>
6+
</main>
7+
);
8+
}

examples/basic/middleware.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { createNextAuthMiddleware } from 'nextjs-basic-auth-middleware'
1+
import { createNextAuthMiddleware } from "nextjs-basic-auth-middleware";
22

33
export const middleware = createNextAuthMiddleware({
4-
users: [{ name: 'test', password: 'test' }],
5-
})
4+
users: [{ name: "test", password: "test" }],
5+
});
66

77
export const config = {
8-
matcher: ['/(.*)', '/_next/static/chunks/(.*)'],
9-
}
8+
matcher: ["/(.*)", "/_next/static/chunks/(.*)"],
9+
};

0 commit comments

Comments
 (0)