Skip to content
Open
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
3 changes: 2 additions & 1 deletion .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
uses: changesets/action@v1
timeout-minutes: 10
with:
publish: nix develop --accept-flake-config -c bash -c "export CI=true; pnpm changeset publish"
publish: nix develop --accept-flake-config -c bash -c "export CI=true; pnpm changeset:verify-publish-manifests; pnpm changeset publish"
createGithubReleases: ${{ github.ref == 'refs/heads/main' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -107,6 +107,7 @@ jobs:
patch -p0 --forward < patches/snapshot_version.patch || true
cd ../..

pnpm changeset:verify-publish-manifests
pnpm build
pnpm build:reactnative
pnpm changeset publish --no-git-tag --snapshot canary --tag canary
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
patch -p0 --forward < patches/snapshot_version.patch || true
cd ../..

pnpm changeset:verify-publish-manifests
pnpm build
pnpm build:reactnative
pnpm changeset publish --no-git-tag --snapshot \$snapshot --tag snapshot
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"preview": "pnpm --filter vite-core preview",
"reset": "pnpm clean && pnpm build && pnpm preview",
"changeset": "changeset",
"changeset:verify-publish-manifests": "node scripts/verify-publish-manifests.mjs",
"version": "changeset version",
"typecheck": "pnpm run --r --parallel --filter \"!@fedimint/react-native\" --filter \"!@fedimint/react-native-bindings\" typecheck",
"coverage": "vitest run --coverage",
Expand Down
62 changes: 62 additions & 0 deletions scripts/verify-publish-manifests.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { readdirSync, readFileSync } from 'node:fs'
import { join } from 'node:path'

const rootDir = process.cwd()
const packagesDir = join(rootDir, 'packages')
const dependencyFields = [
'dependencies',
'optionalDependencies',
'peerDependencies',
]

const packageDirs = readdirSync(packagesDir, { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.map((entry) => join(packagesDir, entry.name))

const failures = []

for (const packageDir of packageDirs) {
const packageJsonPath = join(packageDir, 'package.json')
const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf8'))

if (pkg.private) {
continue
}

const workspaceProtocolEntries = dependencyFields.flatMap((field) => {
const dependencies = pkg[field] ?? {}
return Object.entries(dependencies)
.filter(
([, version]) =>
typeof version === 'string' && version.startsWith('workspace:'),
)
.map(([name, version]) => `${field}.${name}=${version}`)
})

if (workspaceProtocolEntries.length > 0) {
failures.push({
name: pkg.name,
entries: workspaceProtocolEntries,
})
}
}

if (failures.length > 0) {
console.error(
[
'Refusing to publish: one or more publishable package manifests still contain workspace protocol references.',
'This check must run after `changeset version` has rewritten internal dependency ranges.',
'',
...failures.flatMap(({ name, entries }) => [
`${name}:`,
...entries.map((entry) => `- ${entry}`),
'',
]),
]
.join('\n')
.trim(),
)
process.exit(1)
}

console.log('Verified all publishable package manifests are publish-safe.')
Loading