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
54 changes: 0 additions & 54 deletions .github/ISSUE_TEMPLATE/bug.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions .github/ISSUE_TEMPLATE/config.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/ISSUE_TEMPLATE/docs-request.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/pull_request_template.md

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
# postinstall builds preprocess, core-components and the evidence template
- run: pnpm install --frozen-lockfile
- run: pnpm run lint
- run: pnpm run changeset:check
- name: Unit tests
run: |
for p in lib/sdk lib/component-utilities ui/tailwind ui/core-components datasources/javascript; do
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"devDependencies": {
"@changesets/cli": "2.21.0",
"@changesets/read": "0.5.9",
"@duckdb/duckdb-wasm": "1.33.1-dev118.0",
"@evidence-dev/bigquery": "link:packages/datasources/bigquery",
"@evidence-dev/component-utilities": "link:packages/lib/component-utilities",
Expand Down Expand Up @@ -32,9 +33,9 @@
"@sveltejs/adapter-static": "3.0.11",
"@sveltejs/kit": "2.70.4",
"@sveltejs/vite-plugin-svelte": "7.3.1",
"autoprefixer": "^10.4.20",
"@tidyjs/tidy": "2.5.2",
"@uwdata/mosaic-sql": "^0.4.0",
"autoprefixer": "^10.4.20",
"blueimp-md5": "2.19.0",
"chroma-js": "^2.4.2",
"debounce": "^1.2.1",
Expand Down Expand Up @@ -72,9 +73,9 @@
"vite": "8.3.8"
},
"scripts": {
"release": "run-s package:core-components build:evidence release:otp-cache && pnpm changeset publish",
"release": "run-s package:core-components build:evidence release:otp-cache && pnpm changeset publish && node scripts/release-verify.mjs",
"release:otp-cache": "node scripts/release-otp-cache.mjs",
"release:version": "changeset version && prettier --write --log-level warn 'packages/**/CHANGELOG.md'",
"release:version": "node scripts/changeset-check.mjs && changeset version && prettier --write --log-level warn 'packages/**/CHANGELOG.md'",
"test": "pnpm -r test && pnpm -r test:unit",
"test:component-utilities:watch": "pnpm --filter ./packages/lib/component-utilities test:watch",
"postinstall": "run-s build:preprocess package:core-components build:evidence",
Expand All @@ -100,7 +101,8 @@
"package:evidence": "pnpm --filter ./packages/evidence package",
"build:evidence": "pnpm --filter ./packages/evidence build",
"build:preprocess": "pnpm --filter ./packages/lib/preprocess build",
"sources:core-components": "pnpm --filter ./packages/ui/core-components sources"
"sources:core-components": "pnpm --filter ./packages/ui/core-components sources",
"changeset:check": "node scripts/changeset-check.mjs"
},
"packageManager": "pnpm@12.16.1"
}
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions scripts/changeset-check.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env node
// Checks the pending changesets before `changeset version` consumes them:
// - each file parses, with changesets' own parser
// - each released package exists in the workspace and is published
// - a major release includes every published package depending on it: dependencies are
// npm aliases (workspace:@yolean/x@^), which changesets doesn't bump, and a dependent
// left out stays published against the previous major
import { execFileSync } from 'node:child_process';
import fs from 'node:fs';
import readChangesets from '@changesets/read';

const read = readChangesets.default ?? readChangesets;
const DEP_FIELDS = ['dependencies', 'peerDependencies', 'optionalDependencies'];

const packages = execFileSync('git', ['ls-files', '*package.json'], { encoding: 'utf8' })
.split('\n')
.filter((f) => f && !f.includes('node_modules'))
.map((f) => ({ file: f, ...JSON.parse(fs.readFileSync(f, 'utf8')) }))
.filter((p) => p.name);
const byName = new Map(packages.map((p) => [p.name, p]));

/** The workspace package a dependency spec points at, if any */
function workspaceTarget(key, spec) {
if (typeof spec !== 'string' || !spec.startsWith('workspace:')) return null;
const m = /^workspace:((?:@[^/@]+\/)?[^@]+)@/.exec(spec);
return m ? m[1] : key;
}

const parseFailed = (e) => {
console.error(`changeset check failed, a .changeset file doesn't parse:\n ${e.message}`);
process.exit(1);
};
// @changesets/read leaves a parse error as an unhandled rejection
process.on('unhandledRejection', parseFailed);
const changesets = await read(process.cwd()).catch(parseFailed);
const problems = [];
/** @type {Map<string, string>} */
const releases = new Map();
for (const cs of changesets) {
for (const r of cs.releases) {
const pkg = byName.get(r.name);
if (!pkg) problems.push(`.changeset/${cs.id}.md: ${r.name} is not a workspace package`);
else if (pkg.private) problems.push(`.changeset/${cs.id}.md: ${r.name} is private`);
const rank = ['patch', 'minor', 'major'];
if (rank.indexOf(r.type) > rank.indexOf(releases.get(r.name) ?? 'none'))
releases.set(r.name, r.type);
}
}

for (const [name, type] of releases) {
if (type !== 'major') continue;
for (const p of packages) {
if (p.private || releases.has(p.name)) continue;
const deps = DEP_FIELDS.flatMap((f) => Object.entries(p[f] ?? {}));
if (deps.some(([k, v]) => workspaceTarget(k, v) === name)) {
problems.push(`${name} has a major release, add ${p.name} (${p.file}) to the changeset too`);
}
}
}

if (problems.length) {
console.error(`changeset check failed:\n ${problems.join('\n ')}`);
process.exit(1);
}
console.log(
`changeset check: ${changesets.length} changesets, ${releases.size} packages${releases.size ? `: ${[...releases].map(([n, t]) => `${n} ${t}`).join(', ')}` : ''}`
);
64 changes: 64 additions & 0 deletions scripts/release-verify.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env node
// After `changeset publish`: waits until every published package's current version has a
// downloadable tarball, since the registry's CDN lags a publish by up to ~10 minutes, then
// pushes the release tags changeset publish created locally.
import { execFileSync, spawnSync } from 'node:child_process';
import fs from 'node:fs';

const TIMEOUT_MS = 20 * 60 * 1000;

const packages = execFileSync('git', ['ls-files', 'packages/**/package.json'], { encoding: 'utf8' })
.split('\n')
.filter((f) => f && !f.includes('node_modules'))
.map((f) => JSON.parse(fs.readFileSync(f, 'utf8')))
.filter((p) => !p.private && p.name?.startsWith('@yolean/'));

async function available(pkg) {
const view = spawnSync(
'npm',
['view', `${pkg.name}@${pkg.version}`, 'dist.tarball', '--prefer-online'],
{
encoding: 'utf8'
}
);
const tarball = view.status === 0 ? view.stdout.trim() : '';
if (!tarball) return false;
const res = await fetch(tarball, { method: 'HEAD' });
return res.ok;
}

let pending = packages;
const until = Date.now() + TIMEOUT_MS;
while (pending.length) {
const next = [];
for (const pkg of pending) if (!(await available(pkg))) next.push(pkg);
pending = next;
if (!pending.length) break;
if (Date.now() > until) {
console.error(
`Not downloadable after ${TIMEOUT_MS / 60000} minutes: ${pending.map((p) => `${p.name}@${p.version}`).join(' ')}`
);
process.exit(1);
}
console.log(`Waiting for tarballs: ${pending.map((p) => `${p.name}@${p.version}`).join(' ')}`);
await new Promise((r) => setTimeout(r, 30_000));
}
console.log(`All ${packages.length} packages are downloadable at their current versions`);

const tags = execFileSync('git', ['tag', '--points-at', 'HEAD'], { encoding: 'utf8' })
.split('\n')
.filter(Boolean);
if (!tags.length) {
console.log('No tags at HEAD to push');
process.exit(0);
}
const onOrigin = execFileSync('git', ['branch', '-r', '--contains', 'HEAD'], {
encoding: 'utf8'
}).trim();
if (!onOrigin) {
console.log(
`HEAD isn't on origin yet; after pushing it, run:\n git push origin ${tags.join(' ')}`
);
process.exit(0);
}
execFileSync('git', ['push', 'origin', ...tags], { stdio: 'inherit' });
Loading