diff --git a/.github/workflows/draft_new_hotfix.yml b/.github/workflows/draft_new_hotfix.yml deleted file mode 100644 index ff77ceb..0000000 --- a/.github/workflows/draft_new_hotfix.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: 'Draft new hotfix' - -on: - workflow_dispatch: - inputs: - version: - description: 'The version you want to hotfix.' - required: true - -jobs: - draft-new-hotfix: - name: 'Draft a new hotfix' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - - name: Install Node modules - run: npm ci - - - name: Create hotfix branch - run: git checkout -b hotfix/${{ github.event.inputs.version }} - - - name: Update changelog - uses: thomaseizinger/keep-a-changelog-new-release@3.1.0 - with: - tag: v${{ github.event.inputs.version }} - - - name: Format changelog - run: npx prettier -w ./CHANGELOG.md - - # In order to make a commit, we need to initialize a user. - - name: Initialize mandatory git config - run: | - git config user.name "GitHub Actions" - git config user.email noreply@github.com - - # This step will differ depending on your project setup - # Fortunately, yarn has a built-in command for doing this! - - name: Bump version in package.json - run: npm version ${{ github.event.inputs.version }} --no-git-tag-version - - - name: Commit changelog and manifest files - id: make-commit - run: | - git add CHANGELOG.md package.json - git commit --message "chore: prepare hotfix ${{ github.event.inputs.version }}" --no-verify - - echo "::set-output name=commit::$(git rev-parse HEAD)" - - - name: Push new branch - run: git push origin hotfix/${{ github.event.inputs.version }} - - - name: Create pull request - uses: thomaseizinger/create-pull-request@1.4.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - head: hotfix/${{ github.event.inputs.version }} - base: main - title: Hotfix version ${{ github.event.inputs.version }} - reviewers: ${{ github.actor }} - body: | - Hi @${{ github.actor }}! - - This PR was created in response to a manual trigger of the hotfix workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}. - I've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}. - - Merging this PR will create a GitHub release and upload any assets that are created as part of the release build. diff --git a/.github/workflows/publish_new_release.yml b/.github/workflows/publish_new_release.yml index e3df90d..e7b1b83 100644 --- a/.github/workflows/publish_new_release.yml +++ b/.github/workflows/publish_new_release.yml @@ -11,27 +11,18 @@ jobs: release: name: Publish new release runs-on: ubuntu-latest - # only merged pull requests that begin with 'release/' or 'hotfix/' must trigger this job + # only merged pull requests that begin with 'release/' must trigger this job if: github.event.pull_request.merged == true && - (startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix/')) + startsWith(github.event.pull_request.head.ref, 'release/') steps: - - name: Extract version from branch name (for release branches) - if: startsWith(github.event.pull_request.head.ref, 'release/') + - name: Extract version from branch name run: | BRANCH_NAME="${{ github.event.pull_request.head.ref }}" VERSION=${BRANCH_NAME#release/} echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV - - name: Extract version from branch name (for hotfix branches) - if: startsWith(github.event.pull_request.head.ref, 'hotfix/') - run: | - BRANCH_NAME="${{ github.event.pull_request.head.ref }}" - VERSION=${BRANCH_NAME#hotfix/} - - echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV - - uses: actions/checkout@v7 - name: Use Node.js 24.x diff --git a/.storybook/main.ts b/.storybook/main.ts index ed30a62..6218ddb 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -1,7 +1,21 @@ -import { mergeConfig } from 'vite' +import { readdirSync } from 'node:fs' +import { dirname, join } from 'node:path' +import { fileURLToPath } from 'node:url' +import { InlineConfig, mergeConfig } from 'vite' import type { StorybookConfig } from '@storybook/react-vite' +const publicDir = join(dirname(fileURLToPath(import.meta.url)), '../public') + +// Mirror `public/` into the Storybook build, minus `index.html` — that file +// is a dev-only placeholder page (served by `vite preview`), and copying it +// here would overwrite Storybook's own generated `index.html` in the build +// output. Reading the directory (rather than hardcoding names) keeps this in +// sync automatically as files are added to/removed from `public/`. +const staticDirs = readdirSync(publicDir) + .filter((name) => name !== 'index.html') + .map((name) => ({ from: join(publicDir, name), to: name })) + const config: StorybookConfig = { stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'], @@ -16,14 +30,97 @@ const config: StorybookConfig = { options: {}, }, - staticDirs: ['../public'], + staticDirs, - viteFinal: (config) => - mergeConfig(config, { - resolve: { - tsconfigPaths: true, - }, - }), + viteFinal: (config) => { + // Plugin entries can themselves be arrays (e.g. `@vitejs/plugin-react` + // and `vite-plugin-css-injected-by-js` each return one), so a + // shallow filter over `config.plugins` wouldn't see the plugins + // nested inside those - recurse into them instead. + const excludeCssInjectedByJs = ( + plugins: typeof config.plugins + ): typeof config.plugins => + plugins + ?.map((plugin) => + Array.isArray(plugin) + ? excludeCssInjectedByJs(plugin) + : plugin + ) + .filter( + (plugin) => + !( + plugin && + !Array.isArray(plugin) && + !(plugin instanceof Promise) && + plugin.name?.startsWith( + 'vite-plugin-css-injected-by-js' + ) + ) + ) + + return mergeConfig( + { + ...config, + // The root vite.config.mts adds this plugin so the userscript + // build (a single injected