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
13 changes: 12 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
with:
Expand All @@ -41,11 +43,20 @@ jobs:
with:
registry-url: https://registry.npmjs.org
- name: Version PR or publish
id: changesets
uses: changesets/action@v2
with:
version-script: pnpm run version
publish-script: pnpm run release
create-github-releases: true
create-github-releases: false
push-git-tags: false
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create the Orbit GitHub release
if: steps.changesets.outputs.has-changesets == 'false'
run: bash scripts/publish-github-release.sh
env:
GH_TOKEN: ${{ github.token }}
BEFORE_SHA: ${{ github.event.before }}
PUBLISHED: ${{ steps.changesets.outputs.published }}
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ Remove the root compatibility compiler when both tools support TypeScript 7.

Versioning is [changesets](https://github.com/changesets/changesets)-based —
add a changeset with your PR when a package's public behavior changes. All
five packages release in lockstep.
five packages release in lockstep. When the version PR merges, the release
workflow publishes the packages to npm and creates one GitHub release tagged
`v<version>`. Its notes combine the package changelogs and link to each
published npm version.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ All five packages release in lockstep. See

| Package | Role |
|---|---|
| `@modernrelay/orbit-core` | Headless core: validation, reconciliation, projection, the instance + store. Subpaths: `/engine` (the `GraphEngine` contract), `/testing` (`FakeEngine`, worker double). No React or engine imports. |
| `@modernrelay/orbit-react` | `<Graph/>`, `GraphProvider`, 14 packaged UI components, hooks, ref API. React 18+ peer. |
| `@modernrelay/orbit-engine-cosmos` | The default rendering engine: WebGL drawing and GPU force simulation, built on [cosmos.gl](https://github.com/cosmosgl/graph). Loaded lazily when the graph mounts. |
| `@modernrelay/orbit-data` | Prepared-data adapters: rows/CSV/JSON in the root entry; Arrow and Parquet as isolated subpath entries that never reach the root bundle. |
| `@modernrelay/orbit-omnigraph` | Omnigraph server adapter: streamed export loader, `.pg` schema tooling, search service. |
| [@modernrelay/orbit-core](https://www.npmjs.com/package/@modernrelay/orbit-core) | Headless core: validation, reconciliation, projection, the instance + store. Subpaths: `/engine` (the `GraphEngine` contract), `/testing` (`FakeEngine`, worker double). No React or engine imports. |
| [@modernrelay/orbit-react](https://www.npmjs.com/package/@modernrelay/orbit-react) | `<Graph/>`, `GraphProvider`, 14 packaged UI components, hooks, ref API. React 18+ peer. |
| [@modernrelay/orbit-engine-cosmos](https://www.npmjs.com/package/@modernrelay/orbit-engine-cosmos) | The default rendering engine: WebGL drawing and GPU force simulation, built on [cosmos.gl](https://github.com/cosmosgl/graph). Loaded lazily when the graph mounts. |
| [@modernrelay/orbit-data](https://www.npmjs.com/package/@modernrelay/orbit-data) | Prepared-data adapters: rows/CSV/JSON in the root entry; Arrow and Parquet as isolated subpath entries that never reach the root bundle. |
| [@modernrelay/orbit-omnigraph](https://www.npmjs.com/package/@modernrelay/orbit-omnigraph) | Omnigraph server adapter: streamed export loader, `.pg` schema tooling, search service. |

## UI components

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"scripts": {
"build": "pnpm -r --filter \"./packages/*\" run build",
"test": "pnpm -r run test",
"test": "pnpm -r run test && node --test scripts/orbit-release-notes.test.mjs",
"typecheck": "pnpm -r run typecheck",
"lint": "eslint .",
"boundaries": "node scripts/check-boundaries.mjs",
Expand Down
132 changes: 132 additions & 0 deletions scripts/orbit-release-notes.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#!/usr/bin/env node
/**
* Combine the checked-out fixed release group's Changesets changelogs.
* Usage: node scripts/orbit-release-notes.mjs > release-notes.md
* No network, build output, or third-party packages are needed.
*/
import { readFileSync } from 'node:fs';
import path from 'node:path';
import { pathToFileURL } from 'node:url';

import { readReleasePackages, RELEASE_VERSION } from './orbit-release-packages.mjs';

// Recognize fences so examples containing headings or bullets stay intact.
function nextFence(line, fence) {
const match = /^\s*(`{3,}|~{3,})(.*)$/.exec(line);
if (!match) return fence;
if (!fence) return match[1];
return match[1][0] === fence[0] && match[1].length >= fence.length && !match[2].trim()
? null
: fence;
}

function releaseSection(changelog, version, name) {
const sections = [];
let current;
let fence = null;
for (const line of changelog.replace(/\r\n/g, '\n').split('\n')) {
const heading = !fence && /^##\s+(\S+)\s*$/.exec(line);
if (heading && RELEASE_VERSION.test(heading[1])) {
current = heading[1] === version ? [] : undefined;
if (current) sections.push(current);
} else if (current) {
current.push(line);
}
fence = nextFence(line, fence);
}
if (sections.length !== 1) {
throw new Error(`${name}: expected one changelog section for ${version}, found ${sections.length}`);
}
return sections[0];
}

function entries(section) {
const result = [];
let current = [];
let fence = null;
const flush = () => {
// Normalize whitespace-only blank lines, retaining Markdown hard breaks.
const text = current.map((line) => line.trim() ? line : '').join('\n').trim();
if (text) result.push(text);
current = [];
};
for (const line of section) {
if (!fence && /^### (Major|Minor|Patch) Changes\s*$/.test(line)) {
flush();
} else {
if (!fence && /^- /.test(line)) flush();
current.push(line);
}
fence = nextFence(line, fence);
}
flush();
return result;
}

function humanChange(entry, packageNames) {
const lines = entry.replace(/^(- )[\da-f]{7,40}:[ \t]+/i, '$1').split('\n');
const internalBump = (line) => {
const dependency = /^\s*- (\S+)@(\S+)\s*$/.exec(line);
return dependency && packageNames.has(dependency[1]) && RELEASE_VERSION.test(dependency[2]);
};
if (entry === 'No changes in this release.') return null;
if (lines.length === 1 && internalBump(lines[0])) return null;
if (/^- Updated dependencies(?: \[[\da-f, ]+\])?:?$/i.test(lines[0])) {
// Remove only known internal bumps; external updates and prose survive.
let fence = null;
const remaining = lines.slice(1).filter((line) => {
const keep = fence || !internalBump(line);
fence = nextFence(line, fence);
return keep;
});
if (remaining.every((line) => !line.trim())) return null;
return ['- Updated dependencies', ...remaining].join('\n').trimEnd();
}
return lines.join('\n');
}

/** Generate Markdown from manifests and changelogs under an Orbit checkout. */
export function generateReleaseNotes(root) {
const packages = readReleasePackages(root);
const packageNames = new Set(packages.map((pkg) => pkg.name));
const version = packages[0].version;
const changes = new Map();
for (const pkg of packages) {
const name = pkg.name;
const changelog = readFileSync(path.join(pkg.dir, 'CHANGELOG.md'), 'utf8');
for (const entry of entries(releaseSection(changelog, version, name))) {
const text = humanChange(entry, packageNames);
if (!text) continue;
if (!changes.has(text)) changes.set(text, new Set());
changes.get(text).add(name);
}
}

// A repeated Changeset can be minor in one package and patch in another.
// Group by affected packages rather than emitting contradictory bump labels.
const groups = new Map();
for (const [text, names] of changes) {
const heading = names.size === packageNames.size ? 'Across Orbit' : [...names].join(', ');
if (!groups.has(heading)) groups.set(heading, []);
groups.get(heading).push(text);
}
const output = [`# Orbit ${version}`];
for (const [heading, notes] of groups) output.push(`## ${heading}`, notes.join('\n\n'));
if (!groups.size) {
output.push(`This release aligns the Orbit packages at version **${version}**. No user-facing changes were recorded in the package changelogs.`);
}
output.push('## Packages', [...packageNames].map((name) =>
`- [${name}@${version}](https://www.npmjs.com/package/${name}/v/${version})`,
).join('\n'));
return output.join('\n\n') + '\n';
}

if (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) {
try {
if (process.argv.length !== 2) throw new Error('Usage: node scripts/orbit-release-notes.mjs');
process.stdout.write(generateReleaseNotes());
} catch (error) {
console.error(`orbit-release-notes: ${error.message}`);
process.exitCode = 1;
}
}
140 changes: 140 additions & 0 deletions scripts/orbit-release-notes.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import assert from 'node:assert/strict';
import { execFileSync, spawnSync } from 'node:child_process';
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { test } from 'node:test';
import { fileURLToPath } from 'node:url';

import { generateReleaseNotes } from './orbit-release-notes.mjs';

const ROOT = fileURLToPath(new URL('../', import.meta.url));
const SCRIPT = path.join(ROOT, 'scripts/orbit-release-notes.mjs');
const FIXED = JSON.parse(readFileSync(path.join(ROOT, '.changeset/config.json'), 'utf8')).fixed[0];

function fixture(t, packages, fixed = packages.map((pkg) => pkg.name)) {
const root = mkdtempSync(path.join(tmpdir(), 'orbit-release-notes-'));
t.after(() => rmSync(root, { recursive: true, force: true }));
mkdirSync(path.join(root, '.changeset'));
mkdirSync(path.join(root, 'packages'));
writeFileSync(path.join(root, '.changeset/config.json'), JSON.stringify({ fixed: [fixed] }));
packages.forEach(({ name, version = '1.2.3', changelog = '## 1.2.3\n\n- A change.' }, i) => {
const dir = path.join(root, 'packages', `package-${i}`);
mkdirSync(dir);
writeFileSync(path.join(dir, 'package.json'), JSON.stringify({ name, version }));
writeFileSync(path.join(dir, 'CHANGELOG.md'), changelog);
});
return root;
}

// Exercise real Changesets output, including older releases without hashes.
function historicalFixture(t, version) {
return fixture(t, FIXED.map((name) => ({
name,
version,
changelog: readFileSync(path.join(ROOT, 'packages', name.replace('@modernrelay/orbit-', ''), 'CHANGELOG.md'), 'utf8'),
})));
}

test('0.20.1 keeps the OmniGraph change and links every package, including version-only bumps', (t) => {
const notes = generateReleaseNotes(historicalFixture(t, '0.20.1'));
assert.match(notes, /^# Orbit 0\.20\.1\n/);
assert.match(notes, /## @modernrelay\/orbit-omnigraph\n/);
assert.match(notes, /Upgrade the OmniGraph SDK to 0\.17\.1/);
assert.doesNotMatch(notes, /779b19a|No changes in this release|Updated dependencies|^- @modernrelay\//m);
for (const name of FIXED) {
assert.ok(notes.includes(`[${name}@0.20.1](https://www.npmjs.com/package/${name}/v/0.20.1)`));
}
assert.doesNotMatch(notes, /Add bounded, cancellable graph preparation/);
});

test('0.20.0 dedupes a complete shared change across minor and patch sections', (t) => {
const notes = generateReleaseNotes(historicalFixture(t, '0.20.0'));
assert.equal(notes.match(/Add bounded, cancellable graph preparation/g)?.length, 1);
assert.match(notes, /artifact format\.\n\n Expose live overview subscriptions/);
assert.match(notes, /\n\n Add a guided CSV import flow/);
assert.doesNotMatch(notes, /11c4b4e|Updated dependencies|### (Minor|Patch) Changes/);
});

test('historical multiline nested lists and unprefixed human changes survive', (t) => {
const notes = generateReleaseNotes(historicalFixture(t, '0.16.0'));
assert.equal(notes.match(/Fit zoom clamp: small graphs no longer balloon\./g)?.length, 1);
assert.match(notes, / - \*\*Settle camera\*\* — new `fitViewOnSettle` option/);
assert.match(notes, / timers, no extra rAF\) and a final fit at first quiescence/);
assert.doesNotMatch(notes, /212b31f|893a1d2|Updated dependencies/);
const firstPublic = generateReleaseNotes(historicalFixture(t, '0.14.0'));
assert.equal(firstPublic.match(/First public release\./g)?.length, 1);
assert.match(firstPublic, /\[github\.com\/ModernRelay\/orbit\]\(https:\/\/github\.com\/ModernRelay\/orbit\)/);
});

test('strips only fixed-package bump noise, retaining external updates and human prose', (t) => {
const root = fixture(t, [{ name: '@test/core', changelog: `## 1.2.3

### Patch Changes

- abc1234: Updated dependencies to support newer browsers.
- Updated dependencies [abc1234]
- @test/core@1.2.3
- some-external-package@4.5.6
- @test/core@1.2.3
- @test/core@1.2.3 now supports an additional option.
- Updated dependencies
- @test/core@1.2.3
` }]);
const notes = generateReleaseNotes(root);
assert.match(notes, /- Updated dependencies to support newer browsers\./);
assert.match(notes, /- Updated dependencies\n - some-external-package@4\.5\.6/);
assert.match(notes, /- @test\/core@1\.2\.3 now supports an additional option\./);
assert.doesNotMatch(notes, /abc1234|^\s*- @test\/core@1\.2\.3$/m);
});

test('preserves fenced Markdown, hard breaks and headings without treating examples as releases', (t) => {
const changelog = ['## 1.2.3', '', '### Minor Changes', '', '- abc1234: Example. ', ' Next line.', '',
' ```md', '## 1.2.3', '### Patch Changes', '- keep this example', ' ```', '', '## 1.2.2', '', '- Old change.'].join('\r\n');
const notes = generateReleaseNotes(fixture(t, [{ name: '@test/core', changelog }]));
assert.match(notes, /- Example\. \n Next line\./);
assert.match(notes, / ```md\n## 1\.2\.3\n### Patch Changes\n- keep this example\n ```/);
assert.doesNotMatch(notes, /Old change|abc1234/);
const example = '## 1.2.3\n\n- Updated dependencies\n\n Example:\n\n ```md\n - @test/core@1.2.3\n ```';
const exampleNotes = generateReleaseNotes(fixture(t, [{ name: '@test/core', changelog: example }]));
assert.match(exampleNotes, / ```md\n - @test\/core@1\.2\.3\n ```/);
});

test('version-only releases have useful fallback text and all fixed package links', (t) => {
const root = fixture(t, [
{ name: '@test/core', changelog: '## 1.2.3\n\nNo changes in this release.' },
{ name: '@test/react', changelog: '## 1.2.3\n\n### Patch Changes\n\n- @test/core@1.2.3' },
]);
const notes = generateReleaseNotes(root);
assert.match(notes, /aligns the Orbit packages at version \*\*1\.2\.3\*\*/);
assert.match(notes, /No user-facing changes were recorded/);
assert.equal(notes.match(/https:\/\/www\.npmjs\.com\/package\//g)?.length, 2);
assert.doesNotMatch(notes, /### Patch Changes|^- @test\/core/m);
});

test('rejects missing fixed packages and mismatched release versions', (t) => {
assert.throws(() => generateReleaseNotes(fixture(t, [{ name: '@test/core' }], ['@test/core', '@test/react'])), /Missing fixed package: @test\/react/);
assert.throws(() => generateReleaseNotes(fixture(t, [{ name: '@test/core' }, { name: '@test/react', version: '1.2.4' }])), /version 1\.2\.4 does not match fixed release 1\.2\.3/);
assert.throws(() => generateReleaseNotes(fixture(t, [{ name: '@test/core', version: 'latest' }])), /invalid release version/);
});

test('rejects absent or ambiguous matching changelog sections', (t) => {
for (const changelog of ['## 1.2.2\n\n- Old change.', '## 1.2.3\n\n- One.\n\n## 1.2.3\n\n- Two.']) {
assert.throws(() => generateReleaseNotes(fixture(t, [{ name: '@test/core', changelog }])), /expected one changelog section for 1\.2\.3, found [02]/);
}
});

test('rejects ambiguous fixed groups', (t) => {
for (const fixed of [[], ['@test/core', '@test/core']]) {
assert.throws(() => generateReleaseNotes(fixture(t, [{ name: '@test/core' }], fixed)), /one nonempty fixed package group with unique names/);
}
});

test('CLI emits only current-checkout Markdown, independently of the working directory', (t) => {
const cwd = fixture(t, [{ name: '@test/unrelated' }]);
const child = spawnSync(process.execPath, [SCRIPT], { cwd, encoding: 'utf8' });
assert.equal(child.status, 0, child.stderr);
assert.equal(child.stderr, '');
assert.equal(child.stdout, generateReleaseNotes(ROOT));
assert.equal(execFileSync(process.execPath, ['--input-type=module', '-e', `await import(${JSON.stringify(new URL('./orbit-release-notes.mjs', import.meta.url).href)})`], { encoding: 'utf8' }), '');
});
42 changes: 42 additions & 0 deletions scripts/orbit-release-packages.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { existsSync, readdirSync, readFileSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const ROOT = fileURLToPath(new URL('../', import.meta.url));
export const RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-[\da-z.-]+)?(?:\+[\da-z.-]+)?$/i;
const readJson = (file) => JSON.parse(readFileSync(file, 'utf8'));

export function readReleasePackages(root = ROOT) {
const { fixed } = readJson(path.join(root, '.changeset/config.json'));
if (!Array.isArray(fixed) || fixed.length !== 1 || !Array.isArray(fixed[0]) ||
!fixed[0].length || fixed[0].some((name) => typeof name !== 'string' || !name) ||
new Set(fixed[0]).size !== fixed[0].length) {
throw new Error('Expected one nonempty fixed package group with unique names in .changeset/config.json');
}
const packageNames = new Set(fixed[0]);
const packages = new Map();
for (const dir of readdirSync(path.join(root, 'packages'), { withFileTypes: true })) {
if (!dir.isDirectory()) continue;
const packageDir = path.join(root, 'packages', dir.name);
const manifestFile = path.join(packageDir, 'package.json');
if (!existsSync(manifestFile)) continue;
const manifest = readJson(manifestFile);
if (!packageNames.has(manifest.name)) continue;
if (packages.has(manifest.name)) throw new Error(`Duplicate package: ${manifest.name}`);
packages.set(manifest.name, { name: manifest.name, version: manifest.version, dir: packageDir });
}

let version;
for (const name of packageNames) {
const pkg = packages.get(name);
if (!pkg) throw new Error(`Missing fixed package: ${name}`);
if (typeof pkg.version !== 'string' || !RELEASE_VERSION.test(pkg.version)) {
throw new Error(`${name}: invalid release version ${JSON.stringify(pkg.version)}`);
}
version ??= pkg.version;
if (pkg.version !== version) {
throw new Error(`${name}: version ${pkg.version} does not match fixed release ${version}`);
}
}
return [...packageNames].map((name) => packages.get(name));
}
Loading
Loading