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
16 changes: 12 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
- package-ecosystem: npm
directory: /
schedule:
interval: 'monthly'
interval: monthly
groups:
all:
npm-all:
patterns:
- '*'
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
groups:
actions-all:
patterns:
- '*'
78 changes: 78 additions & 0 deletions .github/scripts/publish.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env bun
import { $ } from 'bun';

type Package = {
name?: string;
version?: string;
private?: boolean;
workspaces?: Array<string> | { packages?: Array<string> };
publishConfig?: { registry?: string; access: string };
};

const root = (await Bun.file('package.json').json()) as Package;
const patterns = Array.isArray(root.workspaces)
? root.workspaces
: (root.workspaces?.packages ?? []);

const dirs = new Set<string>();

for (const p of patterns) {
if (typeof p !== 'string' || p.startsWith('!')) continue;

const base = p.replace(/\/+$/u, '');
const glob =
base === '' || base === '.'
? 'package.json'
: base.endsWith('package.json')
? base
: `${base}/package.json`;

for await (const found of new Bun.Glob(glob).scan('.')) {
const path = found.replaceAll('\\', '/');
if (path.includes('node_modules/')) continue;
dirs.add(path === 'package.json' ? '.' : path.slice(0, -'/package.json'.length));
}
}

const npmName = (name: string) =>
name.startsWith('@') ? `@${encodeURIComponent(name.slice(1))}` : encodeURIComponent(name);

await Promise.all(
[...dirs].map(async (dir) => {
const pkg = (await Bun.file(`${dir}/package.json`).json()) as Package;

if (!pkg.name || !pkg.version || pkg.private) return;

const registry = (
pkg.publishConfig?.registry ??
root.publishConfig?.registry ??
'https://registry.npmjs.org/'
).replace(/\/+$/u, '');

const res = await fetch(
`${registry}/${npmName(pkg.name)}/${encodeURIComponent(pkg.version)}`,
);

if (res.ok) return;
if (res.status !== 404)
throw new Error(`Registry check failed for ${pkg.name}: ${res.status}`);

const out = await $`bun pm pack`.cwd(dir).text();

let tar = /[^\s"']+\.tgz/u.exec(out)?.[0]?.replaceAll('\\', '/').replace(/^\.\//u, '');

if (!tar) {
const { value } = new Bun.Glob('*.tgz').scanSync(dir).next() as { value: string };
if (value) tar = value.replaceAll('\\', '/').replace(/^\.\//u, '');
}

if (!tar) throw new Error(`No tarball produced for ${pkg.name}`);

const local = `${dir}/${tar}`;
const tarPath = (await Bun.file(local).exists()) ? local : tar;

await (pkg.publishConfig?.access
? $`bunx npm@latest publish ${tarPath} --access ${pkg.publishConfig.access}`
: $`bunx npm@latest publish ${tarPath}`);
}),
);
33 changes: 18 additions & 15 deletions .github/workflows/ci-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ on:

permissions:
contents: write
pages: write
id-token: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -22,30 +24,31 @@ concurrency:
jobs:
ci:
runs-on: ubuntu-slim
environment:
name: docs
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Set up pnpm
uses: pnpm/action-setup@v4.2.0

- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: latest
cache: 'pnpm'
- name: Set up Bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: pnpm install
run: bun install

- name: Build Docs
run: pnpm build -F docs
- name: Build docs
run: bun run build -F docs

- name: Deploy (push to main)
uses: JamesIves/github-pages-deploy-action@v4
- name: Upload artifact
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/upload-pages-artifact@v5
with:
folder: docs/.vitepress/dist
path: 'docs/dist'

- name: Deploy to GitHub Pages
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/deploy-pages@v5
18 changes: 6 additions & 12 deletions .github/workflows/ci-routine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,18 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Set up pnpm
uses: pnpm/action-setup@v4.2.0

- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: latest
cache: 'pnpm'
- name: Set up Bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: pnpm install
run: bun install

- name: Run checks
run: pnpm check
run: bun check

- name: Run test build
run: pnpm build -F "!docs"
run: bun run build -F "!docs"
18 changes: 6 additions & 12 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,23 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Set up pnpm
uses: pnpm/action-setup@v4.2.0

- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: latest
cache: 'pnpm'
- name: Set up Bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: pnpm install
run: bun install

- name: Run tests (pull requests)
if: github.event_name == 'pull_request'
run: pnpm test
run: bun tests

- name: Run coverage tests (push to main)
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: pnpm test:coverage
run: bun tests:coverage

- name: Upload coverage reports to Codecov (push to main)
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
Expand Down
23 changes: 9 additions & 14 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,19 @@ jobs:
runs-on: ubuntu-slim

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Set up pnpm
uses: pnpm/action-setup@v4.2.0

- name: Set up Node.js
uses: actions/setup-node@v6
- name: Checkout
uses: actions/checkout@v7
with:
node-version: latest
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
fetch-depth: 0

- name: Set up Bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: pnpm install
run: bun install

- name: Build
run: pnpm build -F "!docs"
run: bun run build -F "!docs"

- name: Publish to npm
run: pnpm publish -r --no-git-checks
run: bun .github/scripts/publish.ts
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ coverage
docs/.vitepress/cache

# dist
dist
docs/.vitepress/dist
dist
Loading