@runeditrun/rer 0.2.24 → 0.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -7
- package/cli/browser-runtime.mjs +65 -0
- package/cli/demo-host.mjs +31 -5
- package/cli/deploy-claim-request.mjs +5 -4
- package/cli/deploy-command.mjs +3 -3
- package/cli/deploy-inputs.mjs +2 -1
- package/cli/deploy.mjs +16 -4
- package/cli/export.mjs +1 -1
- package/cli/hosted-mail.mjs +23 -0
- package/cli/hosted-output.mjs +6 -2
- package/cli/hydration/browser.mjs +3 -9
- package/cli/inspect.mjs +3 -1
- package/cli/lifecycle.mjs +4 -1
- package/global/CHANGELOG.md +36 -0
- package/global/README.md +16 -7
- package/global/browser-runtime.mjs +45 -0
- package/global/cli/layout.mjs +8 -4
- package/global/main.mjs +13 -3
- package/install.sh +56 -3
- package/modules/container/README.md +11 -0
- package/modules/container/build.mjs +2 -1
- package/modules/container/demo-egress.mjs +15 -2
- package/modules/container/image-variables.mjs +27 -0
- package/modules/container/worker-engine.mjs +2 -2
- package/modules/delivery-producer/declarations.mjs +6 -1
- package/modules/delivery-producer/mail.mjs +66 -0
- package/modules/demo/label.mjs +5 -2
- package/modules/demo-host/README.md +9 -2
- package/modules/demo-host/certificate.mjs +56 -0
- package/modules/demo-host/measurement.mjs +19 -0
- package/modules/demo-host/operator.mjs +11 -6
- package/modules/demo-host/plan.mjs +1 -1
- package/modules/demo-host/worker.mjs +2 -0
- package/modules/deploy-kit/README.md +6 -4
- package/modules/deploy-kit/asset-health.mjs +28 -0
- package/modules/deploy-kit/d1-import.mjs +22 -4
- package/modules/deploy-kit/diagnostics.mjs +30 -0
- package/modules/deploy-kit/health.mjs +2 -23
- package/modules/deploy-kit/migration-ledger.mjs +6 -2
- package/modules/deploy-kit/migration-retry.mjs +91 -0
- package/modules/deploy-kit/migrations.mjs +9 -5
- package/modules/deploy-kit/owner-cli.mjs +6 -3
- package/modules/deploy-kit/owner-remove.mjs +87 -65
- package/modules/deploy-kit/provider-transport.mjs +28 -5
- package/modules/deploy-kit/provider.mjs +9 -6
- package/modules/deploy-kit/worker.mjs +5 -2
- package/modules/mail/README.md +18 -2
- package/modules/mail/src/adapters/rer/contract.mjs +5 -2
- package/modules/mail/src/adapters/rer/list-headers.mjs +44 -0
- package/modules/mail/src/core/validation.mjs +5 -2
- package/modules/mail/src/sender.mjs +1 -1
- package/modules/mail/src/unsubscribe/index.mjs +5 -5
- package/modules/operator-auth/README.md +10 -2
- package/modules/operator-auth/config.mjs +1 -0
- package/modules/operator-auth/conformance/presentation.mjs +2 -2
- package/modules/operator-auth/identity/email-link/confirmation.mjs +2 -1
- package/modules/operator-auth/identity/email-link/expiry.mjs +8 -0
- package/modules/operator-auth/identity/email-link/index.mjs +2 -1
- package/modules/operator-auth/identity/email-link/message.mjs +3 -2
- package/modules/operator-auth/index.d.mts +2 -0
- package/modules/portability/README.md +7 -2
- package/modules/portability/import-staging.mjs +45 -0
- package/modules/portability/import.mjs +8 -8
- package/modules/portability/storage.mjs +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,13 +22,19 @@ refuses archives with absolute paths, `..` entries, links or devices, then runs
|
|
|
22
22
|
the package's own `rer cli install`. A failed or refused download leaves the
|
|
23
23
|
version you had selected.
|
|
24
24
|
|
|
25
|
+
With no Node 22 or later on PATH, the script installs Node 22.20.0 from
|
|
26
|
+
`nodejs.org` into `~/.local/share/rer/runtimes` (under `XDG_DATA_HOME` when set),
|
|
27
|
+
verifies the tarball against that release's published `SHASUMS256.txt`, and
|
|
28
|
+
prints its location. The launcher uses this private runtime on later runs.
|
|
29
|
+
System Node and other PATH directories are left alone.
|
|
30
|
+
|
|
25
31
|
No installer edits shell profiles. The canonical launcher is `~/.local/bin/rer`.
|
|
26
32
|
Installation creates that directory if needed and never writes into another
|
|
27
33
|
PATH directory. It names any existing `rer` elsewhere on PATH and leaves it
|
|
28
34
|
unchanged. If `~/.local/bin` is absent from PATH or another command shadows it,
|
|
29
35
|
it prints one activation line to run in the current shell:
|
|
30
|
-
`export PATH="$HOME/.local/bin:$PATH"` (with fish syntax for fish).
|
|
31
|
-
|
|
36
|
+
`export PATH="$HOME/.local/bin:$PATH"` (with fish syntax for fish). Without a
|
|
37
|
+
private runtime, the launcher uses `node` from PATH. A re-run with the same build changes
|
|
32
38
|
nothing; a different build is installed beside the current one, the previous one
|
|
33
39
|
is kept and older ones are removed. It refuses to replace a `~/.local/bin/rer`
|
|
34
40
|
that it did not write.
|
|
@@ -47,11 +53,14 @@ install in place.
|
|
|
47
53
|
### Requirements
|
|
48
54
|
|
|
49
55
|
- macOS or Linux, on x64 or arm64. WSL2 counts as Linux.
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
- For
|
|
53
|
-
-
|
|
54
|
-
|
|
56
|
+
- For `install.sh`: `curl`, `tar`, and `shasum` or `sha256sum` when it installs
|
|
57
|
+
Node. macOS includes these tools.
|
|
58
|
+
- For the npm/npx install alternatives: Node 22 or later on PATH.
|
|
59
|
+
- Checkout commands acquire the checkout's pinned Node and pnpm when needed.
|
|
60
|
+
`rer install` also downloads the checkout's Playwright Chromium and headless
|
|
61
|
+
shell for verification; `rer verify` installs missing browser files on first
|
|
62
|
+
need. Downloads print progress. `rer doctor` reports a missing browser and
|
|
63
|
+
directs you to `rer install`, without downloading anything itself.
|
|
55
64
|
|
|
56
65
|
Not supported: native Windows (`install.sh` and `rer` say to use WSL2), and
|
|
57
66
|
`OPERATIONS.json` version 1 projects.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Browser prerequisites come from the checkout's Playwright, including its
|
|
2
|
+
// platform/revision and PLAYWRIGHT_BROWSERS_PATH handling. Inspection never
|
|
3
|
+
// launches a browser or downloads anything.
|
|
4
|
+
import { access, constants } from 'node:fs/promises';
|
|
5
|
+
import { createRequire } from 'node:module';
|
|
6
|
+
import { dirname, join } from 'node:path';
|
|
7
|
+
import { RerError } from './errors.mjs';
|
|
8
|
+
import { shared } from './shared.mjs';
|
|
9
|
+
|
|
10
|
+
export const browserRepair = 'rer install';
|
|
11
|
+
|
|
12
|
+
export function checkoutPlaywright(root, { required = true } = {}) {
|
|
13
|
+
const require = createRequire(join(root, 'package.json'));
|
|
14
|
+
for (const name of ['playwright-core', '@playwright/test', 'playwright']) {
|
|
15
|
+
let entry;
|
|
16
|
+
try { entry = require.resolve(name); } catch (error) { if (error.code === 'MODULE_NOT_FOUND') continue; throw error; }
|
|
17
|
+
const playwright = require(name);
|
|
18
|
+
if (!playwright.chromium) continue;
|
|
19
|
+
let scope = createRequire(entry);
|
|
20
|
+
if (name === '@playwright/test') scope = createRequire(scope.resolve('playwright'));
|
|
21
|
+
const core = dirname(scope.resolve('playwright-core/package.json'));
|
|
22
|
+
const manifest = scope(join(core, 'package.json'));
|
|
23
|
+
// Playwright's bundled releases export the same registry through coreBundle;
|
|
24
|
+
// older checkout pins keep it in the server module tree.
|
|
25
|
+
const { registry } = manifest.exports?.['./lib/coreBundle']
|
|
26
|
+
? scope('playwright-core/lib/coreBundle').registry
|
|
27
|
+
: scope(join(core, 'lib/server/registry/index.js'));
|
|
28
|
+
return { name, playwright, registry, cli: join(core, 'cli.js') };
|
|
29
|
+
}
|
|
30
|
+
if (required) throw new RerError('browser_dependency_missing', `The checkout's Playwright is missing. Run ${browserRepair} to install its locked dependencies; verification requires playwright-core, @playwright/test or playwright.`, 3);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function browserDoctor(root) {
|
|
34
|
+
let resolved;
|
|
35
|
+
try { resolved = checkoutPlaywright(root); }
|
|
36
|
+
catch (error) { return { ok: false, issue: error instanceof RerError ? error.message : `The checkout's Playwright could not be inspected. Run ${browserRepair}.`, fix: browserRepair, executables: [] }; }
|
|
37
|
+
const executables = [];
|
|
38
|
+
for (const name of ['chromium', 'chromium-headless-shell']) {
|
|
39
|
+
// Releases before the separate headless shell use the Chromium executable.
|
|
40
|
+
const executable = resolved.registry.findExecutable(name);
|
|
41
|
+
if (!executable && name === 'chromium-headless-shell') continue;
|
|
42
|
+
const path = executable?.executablePath();
|
|
43
|
+
let ok = false;
|
|
44
|
+
if (path) try { await access(path, process.platform === 'win32' ? constants.F_OK : constants.X_OK); ok = true; } catch {}
|
|
45
|
+
executables.push({ name, ...(path ? { path } : {}), ok });
|
|
46
|
+
}
|
|
47
|
+
const missing = executables.filter(executable => !executable.ok).map(executable => executable.name);
|
|
48
|
+
return { ok: !missing.length, package: resolved.name, executables, ...(missing.length ? { issue: `Playwright browser executables are missing: ${missing.join(', ')}. Run ${browserRepair}.`, fix: browserRepair } : {}) };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function ensureChromium(root, store, signal, { required = true } = {}) {
|
|
52
|
+
// Installing a first-party adapter without browser dependencies remains valid.
|
|
53
|
+
// Verification requires Playwright; installation provisions it when declared.
|
|
54
|
+
const resolved = checkoutPlaywright(root, { required });
|
|
55
|
+
if (!resolved) return;
|
|
56
|
+
const before = await browserDoctor(root);
|
|
57
|
+
if (before.ok) return;
|
|
58
|
+
const { cli } = resolved;
|
|
59
|
+
const { dependencyEnvironment } = await shared('dependency-environment.mjs');
|
|
60
|
+
const env = dependencyEnvironment();
|
|
61
|
+
if (process.env.PLAYWRIGHT_BROWSERS_PATH !== undefined) env.PLAYWRIGHT_BROWSERS_PATH = process.env.PLAYWRIGHT_BROWSERS_PATH;
|
|
62
|
+
await store.run('Installing Chromium and its headless shell from the checkout’s Playwright', 'pnpm', ['exec', 'node', cli, 'install', 'chromium'], { cwd: root, signal, env });
|
|
63
|
+
const after = await browserDoctor(root);
|
|
64
|
+
if (!after.ok) throw new RerError('browser_install_incomplete', after.issue, 3);
|
|
65
|
+
}
|
package/cli/demo-host.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { cp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { randomBytes } from 'node:crypto';
|
|
2
3
|
import { createRequire } from 'node:module';
|
|
3
4
|
import { dirname, join } from 'node:path';
|
|
4
5
|
import { contained } from './project.mjs';
|
|
@@ -6,14 +7,18 @@ import { invalid, missing, refuse, RerError } from './errors.mjs';
|
|
|
6
7
|
import { imageFolder } from './container.mjs';
|
|
7
8
|
import { prepareDemoImage } from '../modules/demo-host/image.mjs';
|
|
8
9
|
import { DEMO_FILES, INSTANCE_TYPES, demoPlan } from '../modules/demo-host/plan.mjs';
|
|
10
|
+
import { awaitCertificates } from '../modules/demo-host/certificate.mjs';
|
|
11
|
+
import { MEASUREMENT_COOKIE, MEASUREMENT_HEADER, TESTING_SECRET } from '../modules/demo-host/measurement.mjs';
|
|
9
12
|
|
|
10
13
|
// `rer deploy --demo [--dry-run]`: the seed's hosted demo at demo.<domain>
|
|
11
14
|
// (modules/demo-host), from deploy-demo.json. It writes .rer/demo-host/: the
|
|
12
15
|
// front Worker, its wrangler.json and the container image folder (workerd
|
|
13
16
|
// engine). --dry-run stops there, so `wrangler dev` can serve that folder with
|
|
14
17
|
// Docker; a deploy runs `wrangler deploy` on it with the Turnstile secret and
|
|
15
|
-
// the demo's record as the version message
|
|
16
|
-
//
|
|
18
|
+
// the demo's record as the version message, then waits for every demo host's
|
|
19
|
+
// certificate. On Turnstile's testing secret (a test host) it also sets the
|
|
20
|
+
// measurement token starts must carry, and says where it is. `--remove --yes` removes
|
|
21
|
+
// what that record proves is the demo's (modules/demo-host/remove.mjs).
|
|
17
22
|
export async function demoHostCommand(project, options, store, signal, out, operation) {
|
|
18
23
|
const read = async path => { try { return JSON.parse(await readFile(await contained(project.root, path), 'utf8')); } catch (error) { if (error instanceof RerError) throw error; throw invalid(`Missing or malformed ${path}.`); } };
|
|
19
24
|
const app = await read(project.adapter.deploy?.declaration ?? 'deploy.json'), declaration = await read('deploy-demo.json');
|
|
@@ -23,11 +28,13 @@ export async function demoHostCommand(project, options, store, signal, out, oper
|
|
|
23
28
|
catch (error) { throw invalid(`The demo deploy declaration is invalid (${error.message}). deploy-demo.json holds {"version": 1, "domain": "<run site apex>", "name": "<product name>"}, optionally "maxInstances", "instanceType" (${INSTANCE_TYPES.join(', ')}; default basic), "ownerEmail" (the demo owner's address; default owner@demo.invalid) and plain "settings".`); }
|
|
24
29
|
if (options.remove) return removeDemo(plan, store, signal);
|
|
25
30
|
if (process.env.RER_DEMO_OPERATOR_TOKEN && (process.env.RER_DEMO_OPERATOR_TOKEN.length < 32 || process.env.RER_DEMO_OPERATOR_TOKEN.length > 512)) throw invalid('RER_DEMO_OPERATOR_TOKEN must contain 32 to 512 characters.');
|
|
31
|
+
const supplied = process.env.RER_DEMO_MEASUREMENT_TOKEN?.trim();
|
|
32
|
+
if (supplied && (supplied.length < 32 || supplied.length > 512 || /[\s;,]/.test(supplied))) throw invalid('RER_DEMO_MEASUREMENT_TOKEN must contain 32 to 512 characters, with no spaces, semicolons or commas.');
|
|
26
33
|
const folder = join(project.root, '.rer', 'demo-host');
|
|
27
34
|
await rm(folder, { recursive: true, force: true });
|
|
28
35
|
await mkdir(folder, { recursive: true, mode: 0o700 });
|
|
29
36
|
await store.step('Building the demo container image (workerd engine)');
|
|
30
|
-
await imageFolder(project, operation, { ...app, secrets: [...(app.secrets ?? []), { binding: 'RER_DEMO_OPERATOR_TOKEN' }, { binding: 'TURNSTILE_SECRET_KEY' }] }, { output: join(folder, 'image'), engine: 'workerd' });
|
|
37
|
+
await imageFolder(project, operation, { ...app, secrets: [...(app.secrets ?? []), { binding: 'RER_DEMO_OPERATOR_TOKEN' }, { binding: 'RER_DEMO_MEASUREMENT_TOKEN' }, { binding: 'TURNSTILE_SECRET_KEY' }] }, { output: join(folder, 'image'), engine: 'workerd' });
|
|
31
38
|
await prepareDemoImage(join(folder, 'image'));
|
|
32
39
|
for (const file of DEMO_FILES) await cp(new URL(`../modules/demo-host/${file}`, import.meta.url), join(folder, file));
|
|
33
40
|
await writeFile(join(folder, 'wrangler.json'), JSON.stringify(plan.wrangler, null, 2) + '\n');
|
|
@@ -43,15 +50,34 @@ export async function demoHostCommand(project, options, store, signal, out, oper
|
|
|
43
50
|
const names = ['CLOUDFLARE_ACCOUNT_ID', 'CLOUDFLARE_API_TOKEN', 'TURNSTILE_SITE_KEY', 'TURNSTILE_SECRET_KEY'];
|
|
44
51
|
if (names.some(name => !process.env[name]?.trim())) throw missing(`${names.join(', ')} are required; see DEMO.md "Hosting the demo".`);
|
|
45
52
|
if (!options.json) for (const line of human) out.human(line);
|
|
53
|
+
// Production hosts keep the real human check and never take a measurement token.
|
|
54
|
+
const measurement = TESTING_SECRET.test(process.env.TURNSTILE_SECRET_KEY.trim()) ? supplied || randomBytes(32).toString('base64url') : null;
|
|
46
55
|
const secrets = join(folder, '.secrets.json');
|
|
47
|
-
await writeFile(secrets, JSON.stringify({ TURNSTILE_SECRET_KEY: process.env.TURNSTILE_SECRET_KEY.trim(), ...(process.env.RER_DEMO_OPERATOR_TOKEN ? { RER_DEMO_OPERATOR_TOKEN: process.env.RER_DEMO_OPERATOR_TOKEN } : {})
|
|
56
|
+
await writeFile(secrets, JSON.stringify({ TURNSTILE_SECRET_KEY: process.env.TURNSTILE_SECRET_KEY.trim(), ...(process.env.RER_DEMO_OPERATOR_TOKEN ? { RER_DEMO_OPERATOR_TOKEN: process.env.RER_DEMO_OPERATOR_TOKEN } : {}),
|
|
57
|
+
...(measurement ? { RER_DEMO_MEASUREMENT_TOKEN: measurement } : {}) }), { mode: 0o600 });
|
|
48
58
|
try {
|
|
49
59
|
const require = createRequire(join(project.root, 'package.json'));
|
|
50
60
|
const manifest = require.resolve('wrangler/package.json');
|
|
51
61
|
const wrangler = join(dirname(manifest), JSON.parse(await readFile(manifest, 'utf8')).bin.wrangler);
|
|
52
62
|
await store.run('Deploying the demo Worker and its container image', process.execPath, [wrangler, 'deploy', '--config', 'wrangler.json', '--secrets-file', '.secrets.json', '--message', plan.record], { cwd: folder, signal });
|
|
53
63
|
} finally { await rm(secrets, { force: true }); }
|
|
54
|
-
|
|
64
|
+
await store.step(`Waiting for the certificate on ${plan.hostnames.join(', ')}`);
|
|
65
|
+
try { await awaitCertificates({ hostnames: plan.hostnames, report: line => store.report(line) }); }
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error.message !== 'demo-certificate-timeout') throw error;
|
|
68
|
+
throw new RerError('deploy_refused', `The demo is deployed, but its certificate is not active 10 minutes later (${error.hosts.join('; ')}). Run the deploy again to wait again; nothing needs removing.`, 1);
|
|
69
|
+
}
|
|
70
|
+
let measured;
|
|
71
|
+
if (measurement) {
|
|
72
|
+
// Output redaction masks credentials, so a token rer made goes to a private file.
|
|
73
|
+
const file = '.rer/demo-host/measurement-token';
|
|
74
|
+
if (!supplied) await writeFile(join(project.root, file), measurement + '\n', { mode: 0o600 });
|
|
75
|
+
measured = { cookie: MEASUREMENT_COOKIE, header: MEASUREMENT_HEADER, token: supplied ? 'RER_DEMO_MEASUREMENT_TOKEN' : file };
|
|
76
|
+
const how = `send it as the cookie ${MEASUREMENT_COOKIE}=<token> on ${plan.hostname} or the header ${MEASUREMENT_HEADER}: <token>`;
|
|
77
|
+
if (options.json) out.event('demo-measurement', measured);
|
|
78
|
+
else out.human(`Test host: it starts demos only with the measurement token in ${supplied ? 'RER_DEMO_MEASUREMENT_TOKEN' : file}; ${how}.`);
|
|
79
|
+
}
|
|
80
|
+
return { dryRun: false, deployed: true, origin: plan.origin, demo: summary, ...(measured ? { measurement: measured } : {}) };
|
|
55
81
|
}
|
|
56
82
|
|
|
57
83
|
async function removeDemo(plan, store, signal) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { observedReadiness } from '../modules/deploy-kit/readiness-window.mjs';
|
|
2
2
|
// Retry only the bootstrap HTTP exchange, never the hook's other effects. The
|
|
3
|
-
// current invocation must prove it uploaded this token to a
|
|
3
|
+
// current invocation must prove it uploaded this token to a fresh Worker version.
|
|
4
|
+
// The route can still answer 404 after /health first reaches another edge.
|
|
4
5
|
export async function ownerClaimRequest(fetch, input, init, { deployed, tokenKey = 'SETUP_TOKEN', signal } = {}) {
|
|
5
6
|
const url = new URL(input instanceof Request ? input.url : input);
|
|
6
7
|
if (deployed?.origin && url.origin !== deployed.origin) throw new Error('owner-claim-origin-mismatch');
|
|
@@ -21,11 +22,11 @@ export async function ownerClaimRequest(fetch, input, init, { deployed, tokenKey
|
|
|
21
22
|
const destination = response.headers.get('location');
|
|
22
23
|
if (destination && new URL(destination, url).origin !== url.origin) throw new Error('owner-claim-origin-mismatch');
|
|
23
24
|
}
|
|
24
|
-
let
|
|
25
|
+
let pending = fresh && !response.redirected && response.status === 404;
|
|
25
26
|
if (fresh && response.status === 403) {
|
|
26
|
-
try {
|
|
27
|
+
try { pending = (await response.clone().json())?.error === 'invalid_setup_token'; } catch {}
|
|
27
28
|
}
|
|
28
|
-
if (!
|
|
29
|
+
if (!pending || window.remaining() <= 0) return response;
|
|
29
30
|
await response.body?.cancel();
|
|
30
31
|
await window.pause();
|
|
31
32
|
}
|
package/cli/deploy-command.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import { rememberHookState, hookState } from './deploy-hook-record.mjs';
|
|
|
15
15
|
import { main as owner } from '../modules/deploy-kit/owner-cli.mjs';
|
|
16
16
|
import { localOnlyBinding, ownerWorkerName } from '../modules/deploy-kit/owner.mjs';
|
|
17
17
|
import { refuseLocalModels } from '../modules/deploy-kit/local-only.mjs';
|
|
18
|
-
import { providerFailure } from '../modules/deploy-kit/diagnostics.mjs';
|
|
18
|
+
import { migrationFailure, providerFailure, assetFailure } from '../modules/deploy-kit/diagnostics.mjs';
|
|
19
19
|
import { shared } from './shared.mjs';
|
|
20
20
|
|
|
21
21
|
export function validateDeployOptions(options) {
|
|
@@ -136,9 +136,9 @@ export async function deployCommand(context) {
|
|
|
136
136
|
if (setup) throw commandFailure(redact(setup));
|
|
137
137
|
const readiness = mutationReadinessFailure(error, { again, redact });
|
|
138
138
|
if (readiness) throw commandFailure(readiness);
|
|
139
|
-
const refused = providerFailure(error,redact);
|
|
139
|
+
const refused = [providerFailure(error,redact), assetFailure(error)].filter(Boolean).join('; '), migration = migrationFailure(error, again);
|
|
140
140
|
const exchange = error.ownerExchange ?? (error.message === 'owner-claim-failed' ? observedClaims.lastExchange ?? observedClaims.at(-1) : undefined);
|
|
141
141
|
const ownerCause = ownerExchangeFailure(exchange);
|
|
142
|
-
throw commandFailure(redact(`${state} Failed at ${step}: ${error.message}${refused ? ` (${refused})` : ''}${ownerCause ? ` (${ownerCause})` : ''}${error.cause ? ` (${error.cause})` : ''}
|
|
142
|
+
throw commandFailure(redact(`${state} Failed at ${step}: ${error.message}${refused ? ` (${refused})` : ''}${ownerCause ? ` (${ownerCause})` : ''}${error.cause ? ` (${error.cause})` : ''}.${migration ? ` ${migration}` : ''} Fix the cause and run ${again} again using the same environment credentials. ${outcome && recorded ? `To retire the token without rebuilding: ${again} --unset-secret ${setupManifest?.steps?.find(item => item.type === 'owner-claim')?.tokenField ?? 'SETUP_TOKEN'}.` : ''}`));
|
|
143
143
|
}
|
|
144
144
|
}
|
package/cli/deploy-inputs.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { relative } from 'node:path';
|
|
2
3
|
import { shared } from './shared.mjs';
|
|
3
4
|
import { invalid } from './errors.mjs';
|
|
4
5
|
import { readDeployEnvFile } from '../modules/deploy-kit/env-file.mjs';
|
|
@@ -54,5 +55,5 @@ export async function withDeployEnvironment(root, options, run) {
|
|
|
54
55
|
|
|
55
56
|
export function deployAgain(options) {
|
|
56
57
|
const quote = value => /^[a-zA-Z0-9_./-]+$/.test(value) ? value : `'${String(value).replaceAll("'", "'\"'\"'")}'`;
|
|
57
|
-
return `rer deploy --environment ${quote(options.environment ?? 'production')}${options.envFile ? ` --env-file ${quote(options.envFile)}` : ''}${options.cwd ? ` --cwd ${quote(options.cwd)}` : ''}`;
|
|
58
|
+
return `rer deploy --environment ${quote(options.environment ?? 'production')}${options.envFile ? ` --env-file ${quote(options.envFile)}` : ''}${options.cwd ? ` --cwd ${quote(relative(process.cwd(), options.cwd) || '.')}` : ''}`;
|
|
58
59
|
}
|
package/cli/deploy.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { requireProductionAuth } from './production-auth.mjs';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import { deployDiagnostic, providerFailure } from '../modules/deploy-kit/diagnostics.mjs';
|
|
3
|
+
import { deployDiagnostic, migrationFailure, providerFailure, assetFailure } from '../modules/deploy-kit/diagnostics.mjs';
|
|
4
4
|
import { shared } from './shared.mjs';
|
|
5
5
|
import { contained } from './project.mjs';
|
|
6
6
|
import { missing, invalid, refuse, RerError } from './errors.mjs';
|
|
@@ -110,6 +110,15 @@ export function ownerDeploy(declarationPath, lifecycle) {
|
|
|
110
110
|
|
|
111
111
|
// The failing step, its redacted cause, what this run created and the command that continues.
|
|
112
112
|
function failureText({ error, step, created, again, retry, secretChange, deployed, redact }) {
|
|
113
|
+
if (step === 'remove') {
|
|
114
|
+
const remaining = error.remaining;
|
|
115
|
+
if (error.message === 'nothing-to-remove') return `There are no recorded resources to remove; nothing was removed.`;
|
|
116
|
+
const cause = deployDiagnostic(error, redact)?.code ?? error.message;
|
|
117
|
+
const count = Array.isArray(remaining) ? `${remaining.length} resources remain (${remaining.join(', ') || 'none'})` : 'the remaining resource count could not be read';
|
|
118
|
+
const detail = providerFailure(error, redact);
|
|
119
|
+
const failed = error.failed?.map(item => `${item.resource}: ${providerFailure(item.error, redact) ?? item.code}`).join('; ');
|
|
120
|
+
return redact(`Removal failed: ${count}; run ${retry} again. Cause: ${cause}${detail ? ` (${detail})` : ''}${failed ? `; ${failed}` : ''}.`);
|
|
121
|
+
}
|
|
113
122
|
const setup = hostedSetupFailure(error, { origin: deployed?.origin, again });
|
|
114
123
|
if (setup) return redact(setup);
|
|
115
124
|
const readiness = mutationReadinessFailure(error, { again, redact });
|
|
@@ -119,18 +128,21 @@ function failureText({ error, step, created, again, retry, secretChange, deploye
|
|
|
119
128
|
const at = step === 'deploy' ? diagnostic?.step ?? 'prepare deploy' : step;
|
|
120
129
|
const input = /^missing-secret-([A-Z][A-Z0-9_]*)$/.exec(code)?.[1];
|
|
121
130
|
if (input) return `Deploy needs ${input}, which the deploy declaration lists as a secret and the Worker does not hold it. Set ${input} in the environment or in an --env-file file (an owned 0600 file of KEY=VALUE lines), then run the same command again. Nothing was uploaded.${created.length ? ` Resources created this attempt: ${created.join(', ')}.` : ''}`;
|
|
122
|
-
if (code === 'remove-incomplete') return `Removal stopped with ${error.remaining.join(', ')} still present${error.failed.length ? ` (${error.failed.map(item => `${item.resource}: ${providerFailure(item.error, redact) ?? item.code}`).join('; ')})` : ''}. Removed: ${error.removed.join(', ') || 'nothing'}. Confirmed owned R2 buckets are emptied automatically; unproved buckets are never purged. Run ${again} --remove --yes again to finish.`;
|
|
123
131
|
if (code === 'nothing-to-remove') return `The deployment record selected by ${again} has no resources that rer owns, so --remove deletes nothing.`;
|
|
124
132
|
if (code === 'owner-token-retirement-failed') return `The application is deployed at ${deployed?.origin}; owner ${error.owner}; setup token retirement failed (${redact(String(error.cause))}${providerFailure(error,redact) ? `; ${providerFailure(error,redact)}` : ''}). Run ${again} --unset-secret ${error.tokenKey ?? 'SETUP_TOKEN'} using the same environment credentials, or run ${again} again to finish.`;
|
|
125
133
|
if (code === 'owner-claim-failed') return `The application is deployed at ${deployed?.origin}, but claiming its owner failed: ${redact(String(error.cause))}. Owner claim and setup token retirement are not confirmed; run ${again} again using the same environment credentials to finish.`;
|
|
126
134
|
const resource = diagnostic?.resource ?? (error.resource ? redact(String(error.resource)) : undefined);
|
|
127
135
|
if (code === 'resource-not-listed') return `Deploy stopped at ${at}: ${resource} was created, but Cloudflare's account listing still does not show it after two minutes. Nothing was uploaded.\nResources created this attempt: ${created.join(', ') || 'none'}.\nRun ${again} again once the listing catches up: it reuses ${resource}. To delete what this environment created instead: ${again} --remove --yes.`;
|
|
128
136
|
const lines = [`Deploy failed at ${at}: ${code}${resource ? ` (${resource})` : ''}${diagnostic?.providerCodes?.length ? ` (provider ${diagnostic.providerCodes.join(', ')})` : ''}.`];
|
|
137
|
+
const asset = assetFailure(error, redact);
|
|
138
|
+
if (asset) lines.push(`${asset}.`);
|
|
129
139
|
const transport = providerFailure(error, redact);
|
|
130
140
|
if (transport) lines.push(`${transport}.`);
|
|
131
141
|
if (diagnostic?.output && diagnostic.output !== '(no provider output)') lines.push(`First redacted output lines:\n${diagnostic.output}`);
|
|
132
142
|
lines.push(`Resources created this attempt: ${created.join(', ') || 'none'}.`);
|
|
133
|
-
|
|
143
|
+
const migration = migrationFailure(error, again);
|
|
144
|
+
if (migration) lines.push(redact(migration));
|
|
145
|
+
if (code !== 'uncertain-migration-claim') lines.push(recovery({ code, at, resource, again, retry, secretChange }));
|
|
134
146
|
return lines.join('\n');
|
|
135
147
|
}
|
|
136
148
|
|
|
@@ -145,7 +157,7 @@ function recovery({ code, at, resource, again, retry, secretChange }) {
|
|
|
145
157
|
}
|
|
146
158
|
if (code === 'uncertain-resource-not-empty') return `Possibly created: ${resource}, but it holds data, so it may not be the one rer's interrupted run made and rer will not delete it. Inspect it in the Cloudflare dashboard; delete it yourself only if its data is disposable, then run ${retry} again.`;
|
|
147
159
|
if (code === 'uncertain-resource-unverifiable') return `Possibly created: ${resource}. rer cannot read whether a queue holds messages, so it will not delete it. Inspect it in the Cloudflare dashboard: if it is the empty one from the interrupted run, delete it, then run ${retry} again.`;
|
|
148
|
-
if (code === 'changed-or-uncertain-migration-history') return `${resource ?? 'A D1 database'} holds
|
|
160
|
+
if (code === 'changed-or-uncertain-migration-history') return `${resource ?? 'A D1 database'} holds migration history this build does not match: a migration changed or missing since it was applied, or an unconfirmed one that is not this build's next migration; rer never guesses migration history. Inspect it in the Cloudflare dashboard: if it is the empty one from this interrupted first deploy, delete it with ${remove} (that deletes everything this environment created), then run ${again} again. If it holds data, resolve the interrupted migration by hand first (deploy-kit README, Migration safety).`;
|
|
149
161
|
if (removing) return `Fix the cause, then run ${retry} again.`;
|
|
150
162
|
if (secretChange) return `Fix the cause, then run ${retry} again; a plain ${again} does not make this change.`;
|
|
151
163
|
return `Fix the cause, then run ${again} again: it continues with what was created. To delete what this environment created instead: ${remove}.`;
|
package/cli/export.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { cliVersion } from './version.mjs';
|
|
|
6
6
|
|
|
7
7
|
// Copy whole maintained source/tooling directories. Python publication scans
|
|
8
8
|
// load sibling modules and data dynamically; they belong in the inventory too.
|
|
9
|
-
export const sourceRoots = ['bin/rer.mjs', 'cli', 'modules/delivery-producer/declarations.mjs', 'modules/delivery-producer/bindings.mjs', 'modules/delivery-producer/migrations.mjs', 'modules/job-queue', 'modules/release', 'modules/deploy-kit', 'modules/container', 'modules/demo-host', 'modules/demo', 'modules/integrations/core', 'modules/mail', 'modules/ai', 'modules/portability', 'modules/d1-transport', 'modules/erasure', 'modules/dependencies', 'modules/operator-auth', 'modules/owner-claim', 'operations', 'scripts/publish-check', 'scripts/publish-check.mjs', 'composition/git-source.mjs', 'edition-authoring/manifest.mjs', 'edition-authoring/files.mjs'];
|
|
9
|
+
export const sourceRoots = ['bin/rer.mjs', 'cli', 'modules/delivery-producer/declarations.mjs', 'modules/delivery-producer/bindings.mjs', 'modules/delivery-producer/migrations.mjs', 'modules/delivery-producer/mail.mjs', 'modules/job-queue', 'modules/release', 'modules/deploy-kit', 'modules/container', 'modules/demo-host', 'modules/demo', 'modules/integrations/core', 'modules/mail', 'modules/ai', 'modules/portability', 'modules/d1-transport', 'modules/erasure', 'modules/dependencies', 'modules/operator-auth', 'modules/owner-claim', 'operations', 'scripts/publish-check', 'scripts/publish-check.mjs', 'composition/git-source.mjs', 'edition-authoring/manifest.mjs', 'edition-authoring/files.mjs'];
|
|
10
10
|
export async function inventory(base, roots = sourceRoots) {
|
|
11
11
|
const files = [];
|
|
12
12
|
async function walk(path) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { deliveryDeclarationSources } from './delivery-declarations.mjs';
|
|
3
|
+
import { sourcePath } from '../modules/delivery-producer/migrations.mjs';
|
|
4
|
+
import { usesManagedMail } from '../modules/delivery-producer/mail.mjs';
|
|
5
|
+
|
|
6
|
+
// Managed-capable seeds can retain direct-provider adapters. Only declared
|
|
7
|
+
// mail credentials receive stand-ins; other application secrets still need
|
|
8
|
+
// their own deploy declaration, even when packaging lists them.
|
|
9
|
+
const credentials = new Set(['MAIL_API_KEY', 'MAIL_PROVIDER_API_KEY', 'RESEND_API_KEY', 'SENDGRID_API_KEY']);
|
|
10
|
+
|
|
11
|
+
export async function hostedMailCredentials(root) {
|
|
12
|
+
const names = new Set();
|
|
13
|
+
for (const [candidate, select] of deliveryDeclarationSources) {
|
|
14
|
+
const path = await sourcePath(root, candidate, { optional: true });
|
|
15
|
+
if (!path) continue;
|
|
16
|
+
const spec = select(JSON.parse(await readFile(path, 'utf8')));
|
|
17
|
+
if (!spec || !usesManagedMail(spec.mail)) continue;
|
|
18
|
+
for (const name of [...(spec.secretNames ?? []), ...(spec.optionalSecretNames ?? [])]) {
|
|
19
|
+
if (credentials.has(name)) names.add(name);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return [...names];
|
|
23
|
+
}
|
package/cli/hosted-output.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { publicAssetPaths } from '../modules/deploy-kit/artifact.mjs';
|
|
|
8
8
|
import { migrate } from '../modules/container/migrations.mjs';
|
|
9
9
|
import { readMigrationRewrites, withRewrites } from '../modules/deploy-kit/migrations.mjs';
|
|
10
10
|
import { RerError } from './errors.mjs';
|
|
11
|
+
import { hostedMailCredentials } from './hosted-mail.mjs';
|
|
11
12
|
|
|
12
13
|
// Serve the production build the way rer deploy hosts it (assets behind the
|
|
13
14
|
// Worker, deploy identity bound, a public https origin) on loopback, with no
|
|
@@ -40,8 +41,8 @@ async function miniflareFor(root) {
|
|
|
40
41
|
const standIn = (item, field) => typeof item.verifyStandIn === 'string' && item.verifyStandIn ? item.verifyStandIn : field?.kind === 'email' ? 'owner@example.com' : typeof field?.default === 'string' && field.default ? field.default : randomBytes(24).toString('hex');
|
|
41
42
|
const links = html => [...html.matchAll(/(?:src|href)=["'](\/[^"'#?\s]+)/g)].map(match => match[1].slice(1)).filter(path => !path.startsWith('/') && /\.[A-Za-z0-9]+$/.test(path));
|
|
42
43
|
|
|
43
|
-
/** The build served as rer deploy hosts it, with
|
|
44
|
-
* deploy
|
|
44
|
+
/** The build served as rer deploy hosts it, with declared vars, origin and
|
|
45
|
+
* stand-in deploy/Managed mail secrets. `fetch(path, init)` uses the deployed origin. */
|
|
45
46
|
export async function serveHosted(root, { declaration: declarationPath = 'deploy.json' } = {}) {
|
|
46
47
|
const build = join(root, 'dist/server'), client = join(root, 'dist/client');
|
|
47
48
|
let config;
|
|
@@ -56,6 +57,9 @@ export async function serveHosted(root, { declaration: declarationPath = 'deploy
|
|
|
56
57
|
const modules = [entry, ...(await files(build)).map(path => join(build, path)).filter(path => path !== entry && moduleTypes[extname(path)])].map(path => ({ type: moduleTypes[extname(path)], path }));
|
|
57
58
|
const identity = { sourceSha: createHash('sha1').update(randomBytes(16)).digest('hex'), fingerprint: createHash('sha256').update(randomBytes(16)).digest('hex'), versionId: crypto.randomUUID() };
|
|
58
59
|
const secrets = Object.fromEntries((declaration.secrets ?? []).map(item => [item.binding, standIn(item, manifest.fields?.find(field => field.name === item.binding))]));
|
|
60
|
+
for (const binding of await hostedMailCredentials(root)) {
|
|
61
|
+
if (!Object.hasOwn(secrets, binding)) secrets[binding] = standIn({}, manifest.fields?.find(field => field.name === binding));
|
|
62
|
+
}
|
|
59
63
|
const mf = new Miniflare(convertV4MiniflareOptions({ host: '127.0.0.1', port: 0, cf: false, workers: [{ name: 'ingress', modules: true, script: ingress, serviceBindings: { APP: 'app' } }, {
|
|
60
64
|
name: 'app', modules, modulesRoot: build, compatibilityDate: config.compatibility_date, compatibilityFlags: config.compatibility_flags,
|
|
61
65
|
bindings: { ...config.vars, ...declaration.vars, ...secrets, ...(declaration.originVar ? { [declaration.originVar]: ORIGIN } : {}),
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
// Chromium from the seed's own Playwright, the two ways of serving pages to it
|
|
2
2
|
// (the production build as rer deploy hosts it, or a running origin), and one
|
|
3
3
|
// load: scripts held until the probe releases them, every external request aborted.
|
|
4
|
-
import {
|
|
5
|
-
import { join } from 'node:path';
|
|
4
|
+
import { checkoutPlaywright, browserRepair } from '../browser-runtime.mjs';
|
|
6
5
|
import { RerError } from '../errors.mjs';
|
|
7
6
|
import { serveHosted } from '../hosted-output.mjs';
|
|
8
7
|
import { probe } from './probe.mjs';
|
|
9
8
|
import { cloudflareRewrite } from './cases.mjs';
|
|
10
9
|
|
|
11
|
-
const INSTALL = 'pnpm exec playwright install chromium';
|
|
12
|
-
|
|
13
10
|
export async function launchChromium(root) {
|
|
14
|
-
const
|
|
15
|
-
let playwright, name;
|
|
16
|
-
for (const candidate of ['playwright-core', '@playwright/test', 'playwright']) { try { playwright = require(candidate); name = candidate; break; } catch {} }
|
|
17
|
-
if (!playwright?.chromium) throw new RerError('hydration_browser_missing', `The hydration check runs Chromium through the seed's own Playwright, and none of playwright-core, @playwright/test or playwright resolves from ${join(root, 'package.json')}. Add @playwright/test to devDependencies, install, then run ${INSTALL}.`, 1);
|
|
11
|
+
const { playwright, name } = checkoutPlaywright(root);
|
|
18
12
|
// Pages fulfilled by the check would otherwise count as public, and Chromium would
|
|
19
13
|
// refuse a dev server's loopback HMR socket from them.
|
|
20
14
|
try { return await playwright.chromium.launch({ args: ['--disable-features=LocalNetworkAccessChecks'] }); }
|
|
21
|
-
catch (error) { throw new RerError('hydration_browser_missing', `The hydration check could not start Chromium from the seed's ${name}: ${String(error.message).split('\n').find(line => line.trim()) ?? error}. Install the browser it pins with ${
|
|
15
|
+
catch (error) { throw new RerError('hydration_browser_missing', `The hydration check could not start Chromium from the seed's ${name}: ${String(error.message).split('\n').find(line => line.trim()) ?? error}. Install the browser it pins with ${browserRepair}.`, 1); }
|
|
22
16
|
}
|
|
23
17
|
|
|
24
18
|
const strip = new Set(['content-encoding', 'content-length', 'transfer-encoding', 'connection']);
|
package/cli/inspect.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { browserDoctor } from './browser-runtime.mjs';
|
|
1
2
|
import { dependencyDoctor } from './dependency-doctor.mjs';
|
|
2
3
|
import { inventory } from './export.mjs';
|
|
3
4
|
import { lstat, readFile } from 'node:fs/promises';
|
|
@@ -185,12 +186,13 @@ export async function doctor(project, store, signal) {
|
|
|
185
186
|
if (directory) { usePnpm(directory); try { pnpm = await probePnpm(project.root, store, signal); pnpmIssues.length = 0; } catch (error) { if (signal?.aborted) throw error; pnpmIssues.push(store.redact(error.message)); } }
|
|
186
187
|
}
|
|
187
188
|
}
|
|
189
|
+
const browser = project.profile === 'first-party' ? await browserDoctor(project.root) : undefined;
|
|
188
190
|
const aiIssues = await localAiDiagnostics(project,process.env);
|
|
189
191
|
const dependencies=project.profile==='first-party'?await dependencyDoctor(project.root):[];
|
|
190
192
|
const expectedNode = await projectNodePin(project.root);
|
|
191
193
|
const inputs = project.profile === 'first-party' ? requiredLocalSettings(project, values) : [];
|
|
192
194
|
const warnings = project.profile === 'first-party' ? await cacheWarnings(project.root) : [];
|
|
193
|
-
return { dependencies, warnings, operations: diagnostic, ok: !aiIssues.length && dependencies.every(d=>d.ok) && diagnostic.ok && stateValid && !inputs.length && (project.profile !== 'first-party' || (Boolean(expectedPnpm) && process.versions.node === expectedNode && pnpm === expectedPnpm)),
|
|
195
|
+
return { dependencies, warnings, browser, operations: diagnostic, ok: browser?.ok !== false && !aiIssues.length && dependencies.every(d=>d.ok) && diagnostic.ok && stateValid && !inputs.length && (project.profile !== 'first-party' || (Boolean(expectedPnpm) && process.versions.node === expectedNode && pnpm === expectedPnpm)),
|
|
194
196
|
node: { actual: process.versions.node, expected: expectedNode },
|
|
195
197
|
pnpm: project.profile === 'first-party' ? { actual: pnpm, expected: expectedPnpm ?? null, ...(pnpmIssues.length ? { issue: [...new Set(pnpmIssues)].join('\n') } : {}) } : undefined,
|
|
196
198
|
ai: { issues: aiIssues },
|
package/cli/lifecycle.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ensureChromium } from './browser-runtime.mjs';
|
|
1
2
|
import { dependencyInputs } from './dependency-input.mjs';
|
|
2
3
|
import { linkDependencies } from './dependencies.mjs';
|
|
3
4
|
import { savedSetupAnswers } from './setup-answers.mjs';
|
|
@@ -86,11 +87,13 @@ async function runLifecycle(project, options, out, deployRedaction) {
|
|
|
86
87
|
if (options.verb === 'deploy' && options.demo) return await (await import('./demo-host.mjs')).demoHostCommand(project, options, store, signal, out, operation);
|
|
87
88
|
if (options.verb === 'install') {
|
|
88
89
|
const { dependencyEnvironment } = await shared('dependency-environment.mjs');
|
|
89
|
-
await store.run('Installing frozen dependencies', 'pnpm', ['install', '--frozen-lockfile'], { cwd: project.root, signal, env: { ...dependencyEnvironment(), CI: 'true' } });
|
|
90
|
+
await store.run('Installing frozen dependencies', 'pnpm', ['install', '--frozen-lockfile'], { cwd: project.root, signal, env: { ...dependencyEnvironment(), CI: 'true' } });
|
|
91
|
+
await ensureChromium(project.root, store, signal, { required: false }); return {};
|
|
90
92
|
}
|
|
91
93
|
if (options.verb === 'verify') {
|
|
92
94
|
const target = adapter.verify;
|
|
93
95
|
if (!Array.isArray(target)) throw refuse('A complete internal verification target is missing.');
|
|
96
|
+
await ensureChromium(project.root, store, signal);
|
|
94
97
|
await store.run('Verifying application', target[0], target[1], { cwd: project.root, signal, env: { ...process.env, RER_LOCAL_OPERATION: operation.token } });
|
|
95
98
|
await store.step('Serving the production build as rer deploy hosts it');
|
|
96
99
|
const declaration = adapter.deployDeclaration ?? adapter.deploy?.declaration;
|
package/global/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.26
|
|
4
|
+
|
|
5
|
+
- The `rer` mail adapter carries `List-Id`, `List-Archive`, `List-Help`, `In-Reply-To` and `References` to the Managed relay as its `listId`, `listArchive`, `listHelp`, `inReplyTo` and `references` fields, and refuses invalid values before sending. Other raw headers stay refused.
|
|
6
|
+
- Hosted output takes Managed-mail credential stand-ins from the seed's mail spec when `mail.providers` includes `rer`, so a Managed seed no longer has to list them in `deploy.json`. `export/SEED-COMMAND-CONTRACT.md` documents the own-host and Managed contract.
|
|
7
|
+
- In a hosted demo, the app's fetches to its own demo hosts (primary and declared secondary) are served by its own container as the same visitor, with no network egress. Every other destination still goes through the demo egress.
|
|
8
|
+
- `rer deploy --demo` waits up to 10 minutes for each demo hostname to present a verified TLS certificate, and fails naming what each host last answered.
|
|
9
|
+
- Demo hosts on Turnstile testing keys start demos only when the start carries the deploy's measurement token, as the cookie `rer_demo_measure` or the header `x-rer-demo-measurement`. `rer deploy --demo` uses `RER_DEMO_MEASUREMENT_TOKEN` when it is set; otherwise it writes a token per deploy to `.rer/demo-host/measurement-token` (0600) and prints that path, not the token.
|
|
10
|
+
- Demo image builds accept `MAIL_RELAY_URL` as public Managed-mail configuration, alongside `MAIL_PROVIDER` and `MAIL_FROM`.
|
|
11
|
+
|
|
12
|
+
### Upgrade notes
|
|
13
|
+
|
|
14
|
+
- Update the exact rer package pin, or refresh vendored operating commands, to receive these changes.
|
|
15
|
+
- A demo deployed to a test host (Turnstile testing keys) needs its measurement token to start demos: set the repository secret `RER_DEMO_MEASUREMENT_TOKEN`, which `run-demo.yml` passes to `rer deploy --demo`, and send it with each measurement start.
|
|
16
|
+
- Remove `MAIL_RELAY_URL` from `deploy.json` secrets and keep it as a public spec or Wrangler variable.
|
|
17
|
+
|
|
18
|
+
## 0.2.25
|
|
19
|
+
|
|
20
|
+
- Invitations stay valid for seven days (`invitationSeconds`), separately from sign-in and step-up links, which keep their short lifetime.
|
|
21
|
+
- Demo and Dev title suffixes are added once, including for missing, empty and suffix-only titles.
|
|
22
|
+
- The shell installer acquires checksum-verified Node 22 in rer's private prefix when needed, leaving system tools alone. The launcher keeps using it without Node on PATH. `rer install` and `rer verify` acquire the checkout's Playwright Chromium and headless shell; `rer doctor` reports missing browser files with `rer install` as the fix, including through the global command for older checkout pins.
|
|
23
|
+
- Portability imports stage their writes in batches within D1's transport budget, with a durable cursor, so populated archives no longer hit `D1_RPC_TRANSPORT_LIMIT`. A same-hash retry resumes an interrupted part, and conflicting content is refused.
|
|
24
|
+
- On a fresh hosted deployment, the owner claim waits through a new route that still answers 404, within the upload propagation window. Asset uploads and checks replay a transient asset failure once; a final asset failure names the asset and its HTTP status.
|
|
25
|
+
- Environment removal retries transient provider 5xx responses within its deadline. A failed removal names the resources still present or not confirmed absent, and gives the same command to finish.
|
|
26
|
+
- Demo image builds accept `MAIL_PROVIDER` and `MAIL_FROM` as public configuration when the managed-mail spec declares them public. Credentials as image variables are still refused.
|
|
27
|
+
- A migration whose D1 import failed is retried by the next deploy of the same bytes, once rer proves none of it applied. Otherwise it stays refused as `uncertain-migration-claim`, and `rer deploy` names the migration, what is present and the exact recovery step.
|
|
28
|
+
- A failed D1 import keeps Cloudflare's codes and messages (credentials and URLs removed, 300 characters each) and names the migration it was running.
|
|
29
|
+
- The deployment spec emits the optional `surfaces.app.signIn` and `nativeExport` declarations from packaging `artifact.specInputs`, using platform's field rules.
|
|
30
|
+
- The owner-claim recovery command prints a relative cwd.
|
|
31
|
+
- The import-kit security test's fixture token now starts with `synthetic-` (`modules/import-kit/tests/readers/security.test.ts`), so credential scans no longer match it.
|
|
32
|
+
|
|
33
|
+
### Upgrade notes
|
|
34
|
+
|
|
35
|
+
- Update the exact rer package pin, or refresh vendored operating commands, to receive these changes.
|
|
36
|
+
- A deployment stuck at `changed-or-uncertain-migration-history` because its last migration stayed `applying` after a failed import recovers with a plain `rer deploy` of the same build, when that migration's effects are absent.
|
|
37
|
+
- Remove `MAIL_PROVIDER` and `MAIL_FROM` from `deploy.json` secrets and keep them as public spec or Wrangler variables.
|
|
38
|
+
|
|
3
39
|
## 0.2.24
|
|
4
40
|
|
|
5
41
|
- Hosted demos stay up through redeploys. The demo's Container application keeps a live demo's instance for an hour (`rollout_active_grace_period`), so a deploy that changes the image, instance type or limit no longer ends idle visitors' demos ("This demo has ended" within two minutes before).
|
package/global/README.md
CHANGED
|
@@ -22,13 +22,19 @@ refuses archives with absolute paths, `..` entries, links or devices, then runs
|
|
|
22
22
|
the package's own `rer cli install`. A failed or refused download leaves the
|
|
23
23
|
version you had selected.
|
|
24
24
|
|
|
25
|
+
With no Node 22 or later on PATH, the script installs Node 22.20.0 from
|
|
26
|
+
`nodejs.org` into `~/.local/share/rer/runtimes` (under `XDG_DATA_HOME` when set),
|
|
27
|
+
verifies the tarball against that release's published `SHASUMS256.txt`, and
|
|
28
|
+
prints its location. The launcher uses this private runtime on later runs.
|
|
29
|
+
System Node and other PATH directories are left alone.
|
|
30
|
+
|
|
25
31
|
No installer edits shell profiles. The canonical launcher is `~/.local/bin/rer`.
|
|
26
32
|
Installation creates that directory if needed and never writes into another
|
|
27
33
|
PATH directory. It names any existing `rer` elsewhere on PATH and leaves it
|
|
28
34
|
unchanged. If `~/.local/bin` is absent from PATH or another command shadows it,
|
|
29
35
|
it prints one activation line to run in the current shell:
|
|
30
|
-
`export PATH="$HOME/.local/bin:$PATH"` (with fish syntax for fish).
|
|
31
|
-
|
|
36
|
+
`export PATH="$HOME/.local/bin:$PATH"` (with fish syntax for fish). Without a
|
|
37
|
+
private runtime, the launcher uses `node` from PATH. A re-run with the same build changes
|
|
32
38
|
nothing; a different build is installed beside the current one, the previous one
|
|
33
39
|
is kept and older ones are removed. It refuses to replace a `~/.local/bin/rer`
|
|
34
40
|
that it did not write.
|
|
@@ -47,11 +53,14 @@ install in place.
|
|
|
47
53
|
### Requirements
|
|
48
54
|
|
|
49
55
|
- macOS or Linux, on x64 or arm64. WSL2 counts as Linux.
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
- For
|
|
53
|
-
-
|
|
54
|
-
|
|
56
|
+
- For `install.sh`: `curl`, `tar`, and `shasum` or `sha256sum` when it installs
|
|
57
|
+
Node. macOS includes these tools.
|
|
58
|
+
- For the npm/npx install alternatives: Node 22 or later on PATH.
|
|
59
|
+
- Checkout commands acquire the checkout's pinned Node and pnpm when needed.
|
|
60
|
+
`rer install` also downloads the checkout's Playwright Chromium and headless
|
|
61
|
+
shell for verification; `rer verify` installs missing browser files on first
|
|
62
|
+
need. Downloads print progress. `rer doctor` reports a missing browser and
|
|
63
|
+
directs you to `rer install`, without downloading anything itself.
|
|
55
64
|
|
|
56
65
|
Not supported: native Windows (`install.sh` and `rer` say to use WSL2), and
|
|
57
66
|
`OPERATIONS.json` version 1 projects.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// An older checkout pin still runs its own verbs. The installed launcher
|
|
2
|
+
// supplies the browser prerequisite those pins did not yet provision.
|
|
3
|
+
import { mkdtemp, rm } from 'node:fs/promises';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { browserDoctor, ensureChromium } from '../cli/browser-runtime.mjs';
|
|
7
|
+
import { output } from '../cli/output.mjs';
|
|
8
|
+
import { RerError } from '../cli/errors.mjs';
|
|
9
|
+
import { shared } from '../cli/shared.mjs';
|
|
10
|
+
|
|
11
|
+
export async function browserPreflight(root, argv) {
|
|
12
|
+
const verb = argv[0], out = output({ verb, json: argv.includes('--json') });
|
|
13
|
+
if (verb === 'doctor') {
|
|
14
|
+
const browser = await browserDoctor(root);
|
|
15
|
+
if (browser.ok) return;
|
|
16
|
+
const diagnostics = { browser, ok: false, scope: 'browser-prerequisite' };
|
|
17
|
+
if (!argv.includes('--json')) out.human(JSON.stringify(diagnostics, null, 2));
|
|
18
|
+
out.result(false, 3, { diagnostics });
|
|
19
|
+
return 3;
|
|
20
|
+
}
|
|
21
|
+
const cancellation = new AbortController();
|
|
22
|
+
let directory, store, termination;
|
|
23
|
+
const handlers = new Map(['SIGINT', 'SIGTERM'].map(name => [name, () => { termination ??= name; cancellation.abort(name); }]));
|
|
24
|
+
for (const [name, handler] of handlers) process.on(name, handler);
|
|
25
|
+
try {
|
|
26
|
+
directory = await mkdtemp(join(tmpdir(), 'rer-browser-'));
|
|
27
|
+
const { createCommands } = await shared('commands.mjs');
|
|
28
|
+
store = await createCommands(directory, { logs: [] }, { terminal: text => out.progress(text) });
|
|
29
|
+
store.setCommandSignal(cancellation.signal);
|
|
30
|
+
// A fresh vendored pin installs its own dependencies; verify will acquire
|
|
31
|
+
// their browser on first need. Package pins have already been bootstrapped.
|
|
32
|
+
await ensureChromium(root, store, cancellation.signal, { required: verb === 'verify' });
|
|
33
|
+
} catch (error) {
|
|
34
|
+
const failure = error instanceof RerError ? error : new RerError('browser_install_failed', `The checkout's Chromium installation failed. Run rer install to retry; inspect the browser download progress for the cause.`, 1);
|
|
35
|
+
if (termination) { failure.exitCode = termination === 'SIGINT' ? 130 : 143; failure.message = `Stopped by ${termination} after owned children were stopped.`; }
|
|
36
|
+
out.error(failure); out.result(false, failure.exitCode);
|
|
37
|
+
return failure.exitCode;
|
|
38
|
+
} finally {
|
|
39
|
+
try { await store?.closeCommands(); }
|
|
40
|
+
finally {
|
|
41
|
+
if (directory) await rm(directory, { recursive: true, force: true });
|
|
42
|
+
for (const [name, handler] of handlers) process.removeListener(name, handler);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|