Skip to content

Commit 92aff57

Browse files
committed
feat: Port to Storybook 10
BREAKING CHANGE: This addon is now an ESM-only package, and requires Storybook 10 or newer. Signed-off-by: Steve Dodier-Lazaro <sidnioulz@gmail.com>
1 parent b7fe1c8 commit 92aff57

30 files changed

+6667
-7314
lines changed

.github/dco.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require:
2+
members: false

.github/dependabot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: 'npm'
4+
directories:
5+
- '/'
6+
schedule:
7+
interval: 'weekly'
8+
versioning-strategy: increase
9+
assignees:
10+
- 'sidnioulz'
11+
reviewers:
12+
- 'sidnioulz'
13+
groups:
14+
all:
15+
patterns:
16+
- '*'
17+
ignore:
18+
- dependency-name: '@storybook/*'
19+
- dependency-name: 'storybook'
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Inspired by https://github.com/vercel/turborepo/blob/main/.github/workflows/examples-autoapprove-and-automerge.yml
2+
# Auto-approves and auto-merges Dependabot PRs.
3+
name: Dependabot automerge
4+
on: pull_request
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
jobs:
11+
dependabot-approve:
12+
runs-on: ubuntu-latest
13+
if: |
14+
always() &&
15+
!contains(needs.*.result, 'failure') &&
16+
!contains(needs.*.result, 'cancelled') &&
17+
github.actor == 'dependabot[bot]'
18+
steps:
19+
- name: Dependabot metadata
20+
id: metadata
21+
uses: dependabot/fetch-metadata@v2
22+
with:
23+
github-token: '${{ secrets.GITHUB_TOKEN }}'
24+
- name: Approve a PR
25+
run: gh pr review --approve "$PR_URL"
26+
env:
27+
PR_URL: ${{github.event.pull_request.html_url}}
28+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
29+
dependabot-merge:
30+
needs: [dependabot-approve]
31+
runs-on: ubuntu-latest
32+
if: github.actor == 'dependabot[bot]'
33+
steps:
34+
- name: Dependabot metadata
35+
id: metadata
36+
uses: dependabot/fetch-metadata@v2
37+
with:
38+
github-token: '${{ secrets.GITHUB_TOKEN }}'
39+
- name: Enable auto-merge for Dependabot PRs
40+
run: gh pr merge --auto --rebase "$PR_URL"
41+
env:
42+
PR_URL: ${{github.event.pull_request.html_url}}
43+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/build.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Build
2+
3+
on: [push]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
9+
strategy:
10+
matrix:
11+
node-version: [20.19, 22.12]
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Install pnpm
19+
uses: pnpm/action-setup@v4
20+
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'pnpm'
26+
27+
- name: Install dependencies
28+
run: pnpm install
29+
30+
- name: Check for linter errors
31+
run: pnpm lint
32+
33+
build:
34+
runs-on: ubuntu-latest
35+
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
36+
strategy:
37+
matrix:
38+
node-version: [20.19, 22.12]
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
with:
43+
fetch-depth: 0
44+
45+
- name: Install pnpm
46+
uses: pnpm/action-setup@v4
47+
48+
- name: Use Node.js ${{ matrix.node-version }}
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: ${{ matrix.node-version }}
52+
cache: 'pnpm'
53+
54+
- name: Install dependencies
55+
run: pnpm install
56+
57+
- name: Build addon
58+
run: pnpm build
59+
60+
- name: Build Storybook
61+
run: pnpm build-storybook
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
node-version: [22]
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- name: Install pnpm
17+
uses: pnpm/action-setup@v4
18+
- name: Use Node.js ${{ matrix.node-version }}
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
cache: 'pnpm'
23+
- name: Install dependencies
24+
run: pnpm install
25+
- name: Check for linter errors
26+
run: pnpm lint
27+
28+
test:
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
node-version: [22]
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
with:
37+
fetch-depth: 0
38+
- name: Install pnpm
39+
uses: pnpm/action-setup@v4
40+
- name: Use Node.js ${{ matrix.node-version }}
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: ${{ matrix.node-version }}
44+
cache: 'pnpm'
45+
- name: Install dependencies
46+
run: pnpm install
47+
- name: Run tests
48+
run: pnpm test:coverage
49+
- name: Upload coverage reports to Codecov
50+
uses: codecov/codecov-action@v4
51+
with:
52+
token: ${{ secrets.CODECOV_TOKEN }}
53+
54+
build:
55+
runs-on: ubuntu-latest
56+
strategy:
57+
matrix:
58+
node-version: [22]
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v4
62+
with:
63+
fetch-depth: 0
64+
- name: Install pnpm
65+
uses: pnpm/action-setup@v4
66+
- name: Use Node.js ${{ matrix.node-version }}
67+
uses: actions/setup-node@v4
68+
with:
69+
node-version: ${{ matrix.node-version }}
70+
cache: 'pnpm'
71+
- name: Install dependencies
72+
run: pnpm install
73+
- name: Run build
74+
run: pnpm build

.github/workflows/release.yml

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,58 @@
11
name: Release
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: write
11+
issues: write
12+
pull-requests: write
13+
id-token: write
414

515
jobs:
616
release:
717
runs-on: ubuntu-latest
8-
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
18+
if: |
19+
(github.event_name == 'push' && !contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')) ||
20+
(github.event_name == 'pull_request')
21+
strategy:
22+
matrix:
23+
node-version: [22]
924
steps:
10-
- uses: actions/checkout@v4
25+
- name: Checkout
26+
uses: actions/checkout@v4
1127

1228
- name: Prepare repository
1329
run: git fetch --unshallow --tags
1430

15-
- name: Use Node.js 20.x
16-
uses: actions/setup-node@v3
31+
- name: Install pnpm
32+
uses: pnpm/action-setup@v4
33+
34+
- name: Use Node.js ${{ matrix.node-version }}
35+
uses: actions/setup-node@v4
1736
with:
18-
node-version: 20.x
37+
node-version: ${{ matrix.node-version }}
38+
cache: 'pnpm'
1939

2040
- name: Install dependencies
21-
run: yarn install
41+
run: pnpm install --ignore-scripts
42+
43+
- name: Audit dependencies
44+
run: pnpm audit
45+
46+
- name: Create production release
47+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
51+
run: pnpm release
2252

23-
- name: Create Release
53+
- name: Create canary release
54+
if: github.event_name == 'pull_request'
2455
env:
2556
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2657
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
27-
run: |
28-
yarn release
58+
run: pnpm release:canary

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ storybook-static/
44
build-storybook.log
55
.DS_Store
66
.env
7-
8-
.yarn/install-state.gz
7+
.eslintcache

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
dist
2+
pnpm-lock.yaml
3+
node_modules
4+
storybook-static

.prettierrc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
{}
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"arrowParens": "always",
5+
"printWidth": 120,
6+
"tabWidth": 2,
7+
"useTabs": false
8+
}

.storybook/local-preset.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { fileURLToPath } from 'node:url';
2+
3+
/**
4+
* to load the built addon in this test Storybook
5+
*/
6+
export function previewAnnotations(entry = []) {
7+
return [...entry, fileURLToPath(import.meta.resolve('../dist/preview.js'))];
8+
}

0 commit comments

Comments
 (0)