Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ name: Publish to npm
on:
release:
types: [published]
# Called directly by release.yml after it cuts the tag/release. A reusable
# workflow_call is a direct invocation, so it runs even though the release
# was created with GITHUB_TOKEN (whose events don't trigger other workflows).
workflow_call:
inputs:
dry-run:
description: 'Dry run (skip actual publish)'
type: boolean
default: false
workflow_dispatch:
inputs:
dry-run:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
changed: ${{ steps.version.outputs.changed }}
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -41,3 +44,13 @@ jobs:
gh release create "$TAG" \
--title "$TAG" \
--generate-notes

# Publish straight after the release is cut. Called as a reusable workflow
# (not via the `release: published` event, which GITHUB_TOKEN-created releases
# never fire) so a version bump on main now auto-publishes to npm with no
# manual dispatch and no PAT. Skipped when the version didn't change.
publish:
needs: release
if: needs.release.outputs.changed == 'true'
uses: ./.github/workflows/publish.yml
secrets: inherit
9 changes: 7 additions & 2 deletions src/plugin/__tests__/transform-react.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import { globSync, readFileSync } from 'node:fs'
import { readdirSync, readFileSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import ts from 'typescript'
Expand Down Expand Up @@ -354,7 +354,12 @@ describe('transformJSX', () => {
path.dirname(fileURLToPath(import.meta.url)),
'../../../playgrounds/simple/react-vite'
)
const files = globSync('src/**/*.{tsx,jsx}', { cwd: playgroundRoot })
// Recursive readdir (Node 18.17+/20) — NOT fs.globSync, which is Node 22+
// and would throw on CI's Node 20.
const files = readdirSync(path.join(playgroundRoot, 'src'), { recursive: true })
.map(String)
.filter((f) => f.endsWith('.tsx') || f.endsWith('.jsx'))
.map((f) => path.join('src', f))
expect(files.length).toBeGreaterThan(0)
for (const rel of files) {
const file = path.join(playgroundRoot, rel)
Expand Down
9 changes: 7 additions & 2 deletions src/plugin/__tests__/transform-svelte.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import { globSync, readFileSync } from 'node:fs'
import { readdirSync, readFileSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { compile } from 'svelte/compiler'
Expand Down Expand Up @@ -287,7 +287,12 @@ describe('transformSvelte', () => {
path.dirname(fileURLToPath(import.meta.url)),
'../../../playgrounds/simple/svelte-vite'
)
const files = globSync('src/**/*.svelte', { cwd: playgroundRoot })
// Recursive readdir (Node 18.17+/20) — NOT fs.globSync, which is Node 22+
// and would throw on CI's Node 20.
const files = readdirSync(path.join(playgroundRoot, 'src'), { recursive: true })
.map(String)
.filter((f) => f.endsWith('.svelte'))
.map((f) => path.join('src', f))
expect(files.length).toBeGreaterThan(0)
for (const rel of files) {
const file = path.join(playgroundRoot, rel)
Expand Down
Loading