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
6 changes: 6 additions & 0 deletions .github/workflows/DeveloperDistribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,16 @@ jobs:
elif [ "$result" != 2 ]; then
exit "$result"
fi
# A CNAME left over from a custom domain must not outlive a base URL that returns to github.io: remove it, which the
# commit below records as a deletion. The script refuses a site that still has one.
host=$(jq -r '.baseUrl | sub("^https://"; "") | sub("[/:].*$"; "")' js/developer/tools/distribution.json)
case "$host" in *.github.io) git -C "$site" rm -q --ignore-unmatch CNAME ;; esac
wf run site build-distribution "$site"
git -C "$site" config user.name "$GITHUB_ACTOR"
git -C "$site" config user.email "$GITHUB_ACTOR@users.noreply.github.com"
git -C "$site" add .nojekyll index.html developer
# The custom domain of the base URL, when it has one.
if [ -e "$site/CNAME" ]; then git -C "$site" add CNAME; fi
if ! git -C "$site" diff --cached --quiet; then
version=$(jq -r .version js/developer/tools/distribution.json)
git -C "$site" commit -m "Publish developer packages $version [#288]"
Expand Down
7 changes: 7 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Unreleased

- Developer environment: the distribution is served from `https://dist.webfront.fr/` (#478, ADR-021). The sources advance to 0.6.5, the
first version published under that address; `site.mjs` writes the `CNAME` file of the Pages branch and `wf run pin`
checks the pinned archive where it is served now. Libraries and environments up to 0.6.4 pin the former
`ambroise-leclerc.github.io/WebFront/` address, which redirects to the new domain without the CORS headers a browser
needs: their developer bootstrap no longer starts and they must be rebuilt with a pin on `dist.webfront.fr`. The pin
stays on 0.6.4 until 0.6.5 is published.

## 0.8.0 - 2026-11-01

- Run authorized native programs from the specs of `webfront_add_jasmine_test` (#445): `PROGRAMS` is the owner's grant and
Expand Down
2 changes: 2 additions & 0 deletions docs/DEVELOPER_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ an exact versioned environment URL and the trusted digest. The 0.6.4 release pin
`https://ambroise-leclerc.github.io/WebFront/developer/0.6.4/environment.tgz`; the
[publication gate](validation/developer-0.6.4-release.md) requires deployed verification before that pin is merged
(the 0.6.3 gate is kept in [its report](validation/developer-0.6.3-release.md)).
The sources advance to 0.6.5, which is served from `https://dist.webfront.fr/` (ADR-021); it is not published yet and the pin
stays on 0.6.4, whose former address redirects to the new domain without CORS headers, so a browser cannot follow it.
Published 0.6.2 introduced installation of the archives of `@types` packages and the manifest directory;
0.6.1, 0.6.0, 0.5.0 and 0.4.1 stay immutable, while 0.4.0 and earlier target the former include layout.
The configuration pins one version and its SHA-512 rather than resolving a mutable `latest` channel. An explicit
Expand Down
6 changes: 3 additions & 3 deletions js/developer/environment/bundles.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
"js/developer/environment/embed.mjs": "3e6bc10200939fa30d5f60a96f01eb33ddf3da87661390ad433a18366bf52547",
"examples/life/ui/main.tsx": "7b1ff285d2a6b8f897ef12df872886e61ef4b24e2358a9423b76b38ab75c85d3",
"examples/life/ui/style.css": "9bb55eb0f0a3287e5b7dc78af9d69608b87ff42c4d9c8a653bc83a52fe293c44",
"js/developer/tools/distribution.json": "35b7806b2d47841f7e01715b9338fb0a55c164fec77260d2267c7d433073354b",
"js/developer/tools/distribution.json": "783e75ba3bc01513e2497a0c6d4d54dbc4fd3e160989916eebcb6d378a9e4180",
"js/developer/tools/archive.mjs": "da63bb9d796ddfd24ed945b15c53f66a0400eb177886fd4f1c8fd10cafb5a91b",
"js/developer/tools/distribution.mjs": "1108b61bc659dd945ba1417aa84337bca03039842d342c95815b5463d87a136e",
"js/developer/tools/distribution.mjs": "43dfdccc912693db46fd095fd78ae79325abab672d99f89fd569914ef3499cad",
"js/developer/scripts/build.mjs": "7aa0358dbd8555ab83bf0380f67892e96b7e9806d4968de18e1a8eaf6e91c080",
"js/developer/webfront.project.json": "2acbc698cf93d66c4da29030179151211d8d313632dac421683c018a296b5c05",
"js/developer/webfront.project.json": "8984debb97ec09ffa768e910567adb2f642de99088549c6bfaa16287568ed1b8",
"js/core/bootstrap/bootstrap.bundle.mjs": "536831257f0fc92e31911841750e1e59247f7c64e756b0fcb878efd9860a741f",
"js/developer/environment/packages.bundle.mjs": "2d62f3fcdece8e898f15814d7e80fc3a27ea062f45514cf8e5c3ae32fd9d26c5",
"include/webfront/system/DeveloperReleaseData.hpp": "aec3b6ce948861fce49a481784cf61ef1bc7d30e3fbb23f2d41d3a561cb3a241"
Expand Down
18 changes: 14 additions & 4 deletions js/developer/scripts/pin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// wf run js/developer/scripts/pin.mjs
//
// The header must be exactly the one generated for its version, and the archive at its URL must have its integrity.
import {bootstrapHeader, sriOf} from '../tools/distribution.mjs';
import {baseUrl, bootstrapHeader, sriOf} from '../tools/distribution.mjs';

export default async function (context) {
const {project} = context;
Expand All @@ -17,9 +17,19 @@ export default async function (context) {
const marker = `developer/${version}/environment.tgz`;
if (!url.endsWith('/' + marker) || header !== bootstrapHeader(version, url.slice(0, -marker.length), integrity))
throw new Error(`DeveloperReleaseData.hpp is not the header generated for the published ${version}`);
const response = await context.fetch(url, {signal: context.signal});
if (!response.ok) throw new Error(`The pinned environment ${url} is not published (${response.status})`);
// The archive is fetched where the distribution is served now. A version pinned under a previous address (the
// github.io one, which redirects to the custom domain without CORS headers, so that a browser cannot follow it) is the
// same file there: the pinned integrity is what proves it.
const current = baseUrl(JSON.parse(await project.readText('js/developer/tools/distribution.json')).baseUrl);
const served = new URL(marker, current).href;
const response = await context.fetch(served, {signal: context.signal});
if (!response.ok) throw new Error(`The pinned environment ${served} is not published (${response.status})`);
if (await sriOf(new Uint8Array(await response.arrayBuffer())) !== integrity)
throw new Error(`The published ${url} does not have the pinned integrity`);
throw new Error(`The published ${served} does not have the pinned integrity`);
context.console.log(`DeveloperReleaseData.hpp pins the published ${version}.`);
// The check above proves the bytes, not that a browser can start from the pinned address: when that address is not
// the one the distribution is served from, the pinned URL redirects without CORS headers and an application built with
// this header cannot start its developer environment until a version pinned on the current address is published.
if (new URL(url).origin !== new URL(current).origin)
context.console.log(`WARNING: the pinned ${url} is not on ${new URL(current).origin}; its redirect carries no CORS headers, so a browser cannot start the developer environment from this pin.`);
}
18 changes: 17 additions & 1 deletion js/developer/scripts/site.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
// A published version is immutable: staging may only repeat identical bytes. Nothing is modified before every byte of
// an existing version has been compared.
import {versionName, versionPath, distributionFiles, sriOf} from '../tools/distribution.mjs';
import {baseUrl, customDomain, versionName, versionPath, distributionFiles, sriOf} from '../tools/distribution.mjs';

const same = (a, b) => a.length === b.length && a.every((byte, index) => byte === b[index]);

Expand Down Expand Up @@ -52,9 +52,25 @@ async function versionRow(project, site, version) {
return `<li>${version}: ${links}</li>`;
}

// The custom domain of the base URL, written as the CNAME file of the Pages branch so that no publication depends on a
// setting made once in the repository's Pages page. A project site served at the github.io address has none. A script
// cannot delete a file, so a CNAME left over from a custom domain is refused: the workflow removes it before staging
// (a Pages site that keeps it would still redirect to the former domain).
async function writeDomain(project, site) {
const distribution = JSON.parse(await project.readText('js/developer/tools/distribution.json'));
const domain = customDomain(baseUrl(distribution.baseUrl));
if (domain) {
await project.write(`${site}/CNAME`, `${domain}\n`);
return;
}
if ((await entries(project, site)).includes('CNAME'))
throw new Error('The base URL has no custom domain but the site still has a CNAME file: remove it from the Pages branch');
}

async function writeIndex(project, site) {
const versions = (await entries(project, `${site}/developer`)).filter(name => versionName.test(name)).sort();
await project.write(`${site}/.nojekyll`, '');
await writeDomain(project, site);
const rows = [];
for (const version of versions) rows.push(await versionRow(project, site, version));
await project.write(`${site}/index.html`, `<!doctype html>\n<html lang="en"><meta charset="utf-8"><title>WebFront developer packages</title><h1>WebFront developer packages</h1><p>Use a version-pinned bootstrap header and SHA-512. React and its dependencies are downloaded separately from npm.</p><ul>${rows.join('')}</ul></html>\n`);
Expand Down
4 changes: 2 additions & 2 deletions js/developer/tools/distribution.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "0.6.4",
"baseUrl": "https://ambroise-leclerc.github.io/WebFront/"
"version": "0.6.5",
"baseUrl": "https://dist.webfront.fr/"
}
12 changes: 12 additions & 0 deletions js/developer/tools/distribution.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ export function baseUrl(value) {
return url.href;
}

/**
* The custom domain a base URL is served from, or '' for a github.io project address. A custom domain is the root of the
* Pages site, so the base URL must be that root: a path would be a directory of the site, not of the domain.
*/
export function customDomain(base) {
const url = new URL(baseUrl(base));
if (url.hostname.endsWith('.github.io')) return '';
if (url.port) throw new Error('A distribution custom domain cannot have a port');
if (url.pathname !== '/') throw new Error('A distribution custom domain must serve the site root');
return url.hostname;
}

export const versionName = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;

export function versionPath(version) {
Expand Down
3 changes: 2 additions & 1 deletion js/developer/webfront.project.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"include/webfront/system/DeveloperReleaseData.hpp"
],
"fetch": [
"https://ambroise-leclerc.github.io"
"https://ambroise-leclerc.github.io",
"https://dist.webfront.fr"
]
}
}
49 changes: 48 additions & 1 deletion test/developer/specs/distribution-specs.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Specs of the developer distribution: the starters, the Pages staging and the pinned bootstrap header.
import {tar} from '../../../js/developer/tools/archive.mjs';
import {bootstrapHeader, versionPath, distributionFiles} from '../../../js/developer/tools/distribution.mjs';
import {bootstrapHeader, versionPath, distributionFiles, customDomain} from '../../../js/developer/tools/distribution.mjs';
import stageSite from '../../../js/developer/scripts/site.mjs';
import {compress} from '../../../js/developer/environment/embed.mjs';
import {createStarter} from '../../../js/developer/environment/starter.mjs';
Expand Down Expand Up @@ -75,6 +75,7 @@ describe('The developer distribution', () => {

it('Pages staging retains older versions and refuses different bytes under an existing version', async () => {
const project = memoryProject();
await project.write('js/developer/tools/distribution.json', JSON.stringify({version: '0.1.0', baseUrl: 'https://owner.github.io/WebFront/'}));
const environment = encode('environment');
const starterBytes = encode('starter');
const write = async version => {
Expand All @@ -93,6 +94,7 @@ describe('The developer distribution', () => {
await write('0.2.0');
await stage();
expect(await project.readText('site/developer/0.1.0/environment.tgz')).toBe('environment');
expect(project.storage.has('site/CNAME')).toBe(false);
expect(await project.readText('site/index.html')).toMatch(/developer\/0.2.0\/life-starter.tgz/);
expect(await project.readText('site/developer/0.2.0/life-starter.tgz')).toBe('starter');
await write('0.3.0');
Expand All @@ -111,6 +113,51 @@ describe('The developer distribution', () => {
await rejects(stage(), /checksum mismatch/);
});

it('Pages staging writes the CNAME file of a custom domain on every publication', async () => {
const project = memoryProject();
await project.write('js/developer/tools/distribution.json', JSON.stringify({version: '0.1.0', baseUrl: 'https://dist.example.test/'}));
const environment = encode('environment');
const starterBytes = encode('starter');
const manifest = {version: '0.1.0', integrity: await integrity(environment), starters: {life: {archive: 'life-starter.tgz', integrity: await integrity(starterBytes)}}};
await project.write('distribution/environment.tgz', environment);
await project.write('distribution/life-starter.tgz', starterBytes);
await project.write('distribution/provision.json', JSON.stringify(manifest));
await project.write('distribution/DeveloperReleaseData.hpp', bootstrapHeader('0.1.0', 'https://dist.example.test/', manifest.integrity));
const stage = () => stageSite({args: ['distribution', 'site'], project, console: {log() {}}});
await stage();
expect(await project.readText('site/CNAME')).toBe('dist.example.test\n');
// A publication from a checkout that lost the file restores it.
project.storage.delete('site/CNAME');
await stage();
expect(await project.readText('site/CNAME')).toBe('dist.example.test\n');
});

it('Pages staging refuses to keep the CNAME of a former custom domain when the base URL returns to github.io', async () => {
const project = memoryProject();
await project.write('js/developer/tools/distribution.json', JSON.stringify({version: '0.1.0', baseUrl: 'https://owner.github.io/WebFront/'}));
const environment = encode('environment');
const starterBytes = encode('starter');
const manifest = {version: '0.1.0', integrity: await integrity(environment), starters: {life: {archive: 'life-starter.tgz', integrity: await integrity(starterBytes)}}};
await project.write('distribution/environment.tgz', environment);
await project.write('distribution/life-starter.tgz', starterBytes);
await project.write('distribution/provision.json', JSON.stringify(manifest));
await project.write('distribution/DeveloperReleaseData.hpp', bootstrapHeader('0.1.0', 'https://owner.github.io/WebFront/', manifest.integrity));
await project.write('site/CNAME', 'dist.example.test\n');
const stage = () => stageSite({args: ['distribution', 'site'], project, console: {log() {}}});
await rejects(stage(), /still has a CNAME file/);
project.storage.delete('site/CNAME');
await stage();
expect(project.storage.has('site/CNAME')).toBe(false);
});

it('a custom domain is the root of the site and a github.io address has none', () => {
expect(customDomain('https://dist.example.test')).toBe('dist.example.test');
expect(customDomain('https://owner.github.io/WebFront/')).toBe('');
throws(() => customDomain('https://dist.example.test/developer/'));
throws(() => customDomain('https://dist.example.test:8443/'));
throws(() => customDomain('http://dist.example.test/'));
});

it('bootstrap configuration is pinned and rejects unsafe version/base inputs', async () => {
const digest = await integrity(encode('environment'));
const header = bootstrapHeader('0.1.0', 'https://owner.github.io/WebFront/', digest);
Expand Down
Loading