@runeditrun/rer 0.2.121 → 0.2.122
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/cli/README.md +124 -5
- package/cli/archive.mjs +1 -1
- package/cli/authoring.mjs +1 -1
- package/cli/browser-runtime.mjs +2 -2
- package/cli/business/agent-help.mjs +11 -11
- package/cli/business/agent-verbs.mjs +9 -8
- package/cli/business/api.mjs +11 -7
- package/cli/business/carry.mjs +4 -3
- package/cli/business/choices.mjs +1 -1
- package/cli/business/command.mjs +33 -11
- package/cli/business/connect.mjs +4 -4
- package/cli/business/credential-file.mjs +102 -0
- package/cli/business/errors.mjs +5 -2
- package/cli/business/invocation.mjs +7 -4
- package/cli/business/keychain.mjs +6 -2
- package/cli/business/local-commands.mjs +9 -3
- package/cli/business/mcp-bridge.mjs +2 -1
- package/cli/business/questions.mjs +1 -1
- package/cli/business/run-child.mjs +5 -5
- package/cli/business/run-grant.mjs +27 -8
- package/cli/business/run-mask.mjs +8 -1
- package/cli/business/scan-command.mjs +1 -1
- package/cli/business/service.mjs +4 -2
- package/cli/business/state.mjs +2 -2
- package/cli/checkout-folders.mjs +1 -1
- package/cli/checkout-preparation.mjs +4 -4
- package/cli/command-guidance.mjs +9 -0
- package/cli/companion/command.mjs +4 -3
- package/cli/companion/providers/sandbox.mjs +1 -1
- package/cli/companion/setup.mjs +4 -4
- package/cli/contract.mjs +8 -8
- package/cli/demo.mjs +1 -1
- package/cli/deploy-command.mjs +10 -5
- package/cli/deploy-hook.mjs +3 -2
- package/cli/deploy-inputs.mjs +7 -3
- package/cli/deploy-owner-input.mjs +2 -2
- package/cli/deploy-source.mjs +1 -1
- package/cli/deploy.mjs +4 -2
- package/cli/deployment-record.mjs +1 -1
- package/cli/dev-identity.mjs +4 -4
- package/cli/door-clauses.mjs +2 -2
- package/cli/door-mode.mjs +7 -7
- package/cli/door.mjs +7 -7
- package/cli/errors.mjs +15 -1
- package/cli/export-summary.mjs +1 -1
- package/cli/export.mjs +1 -1
- package/cli/hosted-export.mjs +1 -1
- package/cli/hosted-output.mjs +2 -2
- package/cli/human-error.mjs +8 -2
- package/cli/hydration/browser.mjs +1 -1
- package/cli/hydration/check.mjs +1 -1
- package/cli/import-summary.mjs +2 -2
- package/cli/inspect.mjs +3 -3
- package/cli/lifecycle.mjs +9 -9
- package/cli/listen.mjs +1 -1
- package/cli/listing.mjs +1 -1
- package/cli/local-env.mjs +1 -1
- package/cli/local.mjs +4 -4
- package/cli/managed-server.mjs +36 -13
- package/cli/output.mjs +2 -1
- package/cli/owner-entry-ready.mjs +92 -0
- package/cli/parse.mjs +8 -8
- package/cli/port.mjs +3 -3
- package/cli/portability-runtime.mjs +16 -0
- package/cli/portability.mjs +4 -4
- package/cli/production-auth.mjs +4 -2
- package/cli/production-mail.mjs +1 -1
- package/cli/project.mjs +2 -0
- package/cli/rehearse/options.mjs +3 -3
- package/cli/release-candidate.mjs +2 -2
- package/cli/release.mjs +5 -5
- package/cli/server-registry.mjs +3 -3
- package/cli/server-resources.mjs +1 -1
- package/cli/setup-input.mjs +6 -6
- package/cli/signin.mjs +11 -10
- package/cli/site-render.mjs +1 -1
- package/cli/size/schema.mjs +1 -1
- package/cli/size/verify-step.mjs +1 -1
- package/cli/transfers.mjs +4 -4
- package/edition-authoring/api-source.mjs +121 -0
- package/edition-authoring/archive-source.mjs +1 -86
- package/edition-authoring/base-copies.mjs +5 -3
- package/global/CHANGELOG.md +31 -0
- package/global/cli/command.mjs +6 -5
- package/global/cli/install.mjs +6 -3
- package/global/cli/path-link.mjs +11 -22
- package/global/cli/repo-command.mjs +4 -3
- package/global/cli/repository-contract.mjs +3 -3
- package/global/door/command.mjs +39 -38
- package/global/door/control.mjs +3 -3
- package/global/door/pages.mjs +6 -5
- package/global/door/server.mjs +8 -5
- package/global/door/sites.mjs +14 -13
- package/global/launch/capacity.mjs +2 -2
- package/global/launch/dev.mjs +6 -6
- package/global/launch/door.mjs +1 -1
- package/global/launch/facts.mjs +2 -2
- package/global/launch/failure.mjs +1 -1
- package/global/launch/prepare.mjs +3 -3
- package/global/launch/render.mjs +3 -2
- package/global/launch/worker.mjs +1 -1
- package/global/list.mjs +4 -4
- package/global/main.mjs +32 -31
- package/global/registry.mjs +1 -1
- package/global/run.mjs +4 -4
- package/global/update/command.mjs +5 -5
- package/global/update/notice.mjs +1 -1
- package/global/version.mjs +1 -1
- package/install.sh +17 -4
- package/modules/deploy-kit/README.md +10 -3
- package/modules/deploy-kit/asset-health.mjs +6 -4
- package/modules/deploy-kit/cancellation.mjs +26 -0
- package/modules/deploy-kit/d1-import-diagnostics.mjs +3 -2
- package/modules/deploy-kit/deploy.mjs +8 -3
- package/modules/deploy-kit/diagnostics.mjs +11 -4
- package/modules/deploy-kit/health-request.mjs +16 -9
- package/modules/deploy-kit/health.mjs +14 -11
- package/modules/deploy-kit/owner-cli.mjs +49 -21
- package/modules/deploy-kit/owner-remove.mjs +7 -6
- package/modules/deploy-kit/owner-secret.mjs +7 -4
- package/modules/deploy-kit/owner.mjs +46 -28
- package/modules/deploy-kit/provider-transport.mjs +2 -0
- package/modules/deploy-kit/provider.mjs +10 -9
- package/modules/deploy-kit/readiness-window.mjs +5 -3
- package/modules/deploy-kit/site.mjs +1 -1
- package/modules/deploy-kit/teardown.mjs +5 -4
- package/modules/operator-auth/dev/index.mjs +4 -3
- package/modules/operator-auth/dev/sign-in-as.mjs +2 -1
- package/modules/operator-auth/dev-gate.mjs +3 -2
- package/modules/operator-auth/routes.mjs +2 -1
- package/modules/operator-auth/terminal-guidance.mjs +3 -0
- package/onboarding/adapter-settings.mjs +1 -0
- package/onboarding/adapter.mjs +3 -3
- package/onboarding/agent-handoff.mjs +1 -1
- package/onboarding/busy.mjs +1 -1
- package/onboarding/launcher.mjs +1 -1
- package/onboarding/local/environment.mjs +1 -1
- package/onboarding/local/operation.mjs +12 -4
- package/onboarding/local/owner.mjs +2 -2
- package/onboarding/operator-installer.mjs +4 -3
- package/onboarding/operator-migrations.mjs +1 -1
- package/onboarding/operator-prerequisites.mjs +26 -14
- package/onboarding/operator-settings.mjs +28 -0
- package/onboarding/process-diagnostics.mjs +2 -2
- package/onboarding/project-vite.mjs +1 -1
- package/package.json +1 -1
package/cli/inspect.mjs
CHANGED
|
@@ -169,7 +169,7 @@ async function packageClauses(root, pkg) {
|
|
|
169
169
|
}
|
|
170
170
|
// Delivery operations, the scripts they run and CI workflows call the package too.
|
|
171
171
|
const calls = await vendoredCalls(root);
|
|
172
|
-
clauses.push(['SC-13.package.calls', !calls.length, `Run pnpm exec rer VERB instead of the removed vendored copy (pnpm install --frozen-lockfile first where nothing has installed yet) in ${calls.length} place${calls.length === 1 ? '' : 's'}:\n${calls.slice(0, 20).join('\n')}${calls.length > 20 ? `\n...and ${calls.length - 20} more` : ''}`]);
|
|
172
|
+
clauses.push(['SC-13.package.calls', !calls.length, `Run pnpm exec ~/.local/bin/rer VERB instead of the removed vendored copy (pnpm install --frozen-lockfile first where nothing has installed yet) in ${calls.length} place${calls.length === 1 ? '' : 's'}:\n${calls.slice(0, 20).join('\n')}${calls.length > 20 ? `\n...and ${calls.length - 20} more` : ''}`]);
|
|
173
173
|
return clauses;
|
|
174
174
|
}
|
|
175
175
|
|
|
@@ -287,7 +287,7 @@ export function doctorSummary(result) {
|
|
|
287
287
|
if (result.missingInputs.length) {
|
|
288
288
|
lines.push('Missing local inputs:');
|
|
289
289
|
for (const name of result.missingInputs) lines.push(` ${name}${result.sources[name] ? `: ${result.sources[name]}` : ''}`);
|
|
290
|
-
if (result.setupNeeded) lines.push('Run rer setup to configure this checkout.');
|
|
290
|
+
if (result.setupNeeded) lines.push('Run ~/.local/bin/rer setup to configure this checkout.');
|
|
291
291
|
}
|
|
292
292
|
const unavailable = result.operations.commands.filter(command => !command.available);
|
|
293
293
|
if (unavailable.length) lines.push('Unavailable command inputs:', ...unavailable.map(command => ` ${command.name}: restore its declared input files.`));
|
|
@@ -316,6 +316,6 @@ async function devIdentityClauses(root, adapter) {
|
|
|
316
316
|
const configs = (await Promise.all(['vite.config.ts', 'vite.config.mts', 'vite.config.js', 'vite.config.mjs', 'wrangler.local.jsonc', 'wrangler.local.json', 'wrangler.local.toml'].map(text))).filter(Boolean);
|
|
317
317
|
return [
|
|
318
318
|
['SC-05.dev-identity.entry', entry && await text(entry) !== null && entry !== main && configs.some(config => config.includes(entry)), 'Declare devIdentity.entry as an existing local-only Worker entry that the local Vite or wrangler configuration loads and that is not the deployed main.'],
|
|
319
|
-
['SC-05.dev-identity.exclusion', production !== null && !/operator-auth\/dev\//.test(production) && !production.includes(entry.replace(/\.[a-z]+$/, '')) && Array.isArray(declaration.output) && declaration.output.length > 0, 'Keep the deployed main free of the dev layer and its local entry, and declare devIdentity.output so rer build refuses output containing the dev layer.'],
|
|
319
|
+
['SC-05.dev-identity.exclusion', production !== null && !/operator-auth\/dev\//.test(production) && !production.includes(entry.replace(/\.[a-z]+$/, '')) && Array.isArray(declaration.output) && declaration.output.length > 0, 'Keep the deployed main free of the dev layer and its local entry, and declare devIdentity.output so ~/.local/bin/rer build refuses output containing the dev layer.'],
|
|
320
320
|
];
|
|
321
321
|
}
|
package/cli/lifecycle.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { join } from 'node:path';
|
|
|
9
9
|
import { shared } from './shared.mjs';
|
|
10
10
|
import { tools, doctor } from './inspect.mjs';
|
|
11
11
|
import { availablePort, selectedOrigin, setupInput, stateSafety, refuseLegacyProcess } from './local.mjs';
|
|
12
|
-
import { missing, refuse, RerError, lifecycleError } from './errors.mjs';
|
|
12
|
+
import { missing, refuse, RerError, lifecycleError, retainTransferFailure } from './errors.mjs';
|
|
13
13
|
import { executeDeclared } from './independent.mjs';
|
|
14
14
|
import { transfer } from './transfers.mjs';
|
|
15
15
|
import { runtimeFrontDoor } from './runtime-front-door.mjs';
|
|
@@ -37,7 +37,7 @@ export async function runCommand(project, options, out) {
|
|
|
37
37
|
|
|
38
38
|
async function runLifecycle(project, options, out, deployRedaction) {
|
|
39
39
|
if (project.profile === 'first-party' && ['build','deploy'].includes(options.verb) && !options.demo && !options.site && process.env.RER_DEMO) throw refuse('Production build and deploy refuse the local-only RER_DEMO environment binding. Unset it before retrying.');
|
|
40
|
-
if(project.profile==='first-party'&&options.verb==='outbox')throw refuse('Captured mail has been retired. Run rer dev and open its RER_OPEN link.');
|
|
40
|
+
if(project.profile==='first-party'&&options.verb==='outbox')throw refuse('Captured mail has been retired. Run ~/.local/bin/rer dev and open its RER_OPEN link.');
|
|
41
41
|
if(project.profile==='first-party'&&['dev','preview'].includes(options.verb))return (await import('./managed-server.mjs')).managedServer(project,options,out);
|
|
42
42
|
const cancellation = new AbortController(), signal = cancellation.signal;
|
|
43
43
|
let termination, operation, store, temporary, proxy, failed = false, installingFrozen = false;
|
|
@@ -55,7 +55,7 @@ async function runLifecycle(project, options, out, deployRedaction) {
|
|
|
55
55
|
}
|
|
56
56
|
if (project.profile === 'first-party' && options.verb !== 'doctor') {
|
|
57
57
|
if (!project.adapter?.run) throw refuse('The first-party command adapter is unavailable. Restore the shared lifecycle adapter.');
|
|
58
|
-
if (options.forwarded.length) throw refuse('First-party commands do not accept arbitrary forwarded arguments. Run rer VERB --help.');
|
|
58
|
+
if (options.forwarded.length) throw refuse('First-party commands do not accept arbitrary forwarded arguments. Run ~/.local/bin/rer VERB --help.');
|
|
59
59
|
await stateSafety(project);
|
|
60
60
|
const { localOperation } = await shared('local/operation.mjs');
|
|
61
61
|
// The run site reads no local state: it builds beside a running rer dev.
|
|
@@ -106,7 +106,7 @@ async function runLifecycle(project, options, out, deployRedaction) {
|
|
|
106
106
|
installingFrozen = false;
|
|
107
107
|
// The test browser downloads on first need (verify), not here. Package
|
|
108
108
|
// scripts run with the pinned pnpm through rer run, which keeps pnpm off PATH.
|
|
109
|
-
if (!options.json) store.report('Run this project\'s package scripts with rer run SCRIPT (it uses the pnpm this project pins).');
|
|
109
|
+
if (!options.json) store.report('Run this project\'s package scripts with ~/.local/bin/rer run SCRIPT (it uses the pnpm this project pins).');
|
|
110
110
|
return {};
|
|
111
111
|
} catch (error) { if (signal.aborted) throw error; throw await installStepError(error, store, project.root); } finally { installingFrozen = false; }
|
|
112
112
|
}
|
|
@@ -115,7 +115,7 @@ async function runLifecycle(project, options, out, deployRedaction) {
|
|
|
115
115
|
if (!Array.isArray(target)) throw refuse('A complete internal verification target is missing.');
|
|
116
116
|
await ensureChromium(project.root, store, signal, project.adapter?.browser);
|
|
117
117
|
await store.run('Verifying application', target[0], target[1], { cwd: project.root, signal, env: { ...process.env, RER_LOCAL_OPERATION: operation.token } });
|
|
118
|
-
await store.step('Serving the production build as rer deploy hosts it');
|
|
118
|
+
await store.step('Serving the production build as ~/.local/bin/rer deploy hosts it');
|
|
119
119
|
const declaration = adapter.deployDeclaration ?? adapter.deploy?.declaration;
|
|
120
120
|
const hosted = await (await import('./hosted-output.mjs')).checkHostedOutput(project.root, { declaration });
|
|
121
121
|
await store.step('Checking that page sections hydrate as separate units');
|
|
@@ -165,15 +165,15 @@ async function runLifecycle(project, options, out, deployRedaction) {
|
|
|
165
165
|
else {
|
|
166
166
|
const { checkoutPath } = await shared('step-failure.mjs');
|
|
167
167
|
out.human(`Setup complete: ${state.migrationsApplied ? `${state.migrationsApplied} migration${state.migrationsApplied === 1 ? '' : 's'} applied` : 'database already up to date'}, owner set up. Full output: ${store.redact(checkoutPath(project.root, store.logPath))}`);
|
|
168
|
-
out.human(`RER_SETUP_READY ${url}`); out.human(`Next: rer dev opens ${url} signed in as the owner; first-run setup finishes at ${url}/setup. rer preview prints a one-time native owner link on loopback; rer demo also prints a separate native owner entry.`);
|
|
169
|
-
if (deployNeeds.length) out.human(['To host it on your own Cloudflare account later, rer deploy needs:', ...deployNeeds.map(item => ` - ${item}`), 'Set them in your environment or a private (mode 0600) file passed with --env-file, then check with rer deploy --dry-run.'].join('\n'));
|
|
168
|
+
out.human(`RER_SETUP_READY ${url}`); out.human(`Next: ~/.local/bin/rer dev opens ${url} signed in as the owner; first-run setup finishes at ${url}/setup. ~/.local/bin/rer preview prints a one-time native owner link on loopback; ~/.local/bin/rer demo also prints a separate native owner entry.`);
|
|
169
|
+
if (deployNeeds.length) out.human(['To host it on your own Cloudflare account later, ~/.local/bin/rer deploy needs:', ...deployNeeds.map(item => ` - ${item}`), 'Set them in your environment or a private (mode 0600) file passed with --env-file, then check with ~/.local/bin/rer deploy --dry-run.'].join('\n'));
|
|
170
170
|
}
|
|
171
171
|
} else if (options.verb !== 'build') throw refuse('The requested first-party capability is unavailable.');
|
|
172
172
|
return {};
|
|
173
173
|
} catch (error) {
|
|
174
174
|
failed = true;
|
|
175
|
-
|
|
176
|
-
throw
|
|
175
|
+
const failure=await lifecycleError(error,store);
|
|
176
|
+
throw ['export','import'].includes(options.verb) ? retainTransferFailure(failure,store,project.root) : failure;
|
|
177
177
|
} finally {
|
|
178
178
|
// Every closer runs: one that fails must not leave the job-queue policy socket
|
|
179
179
|
// listening (the process would never exit) or the local operation held, and
|
package/cli/listen.mjs
CHANGED
|
@@ -17,7 +17,7 @@ export async function listen(server, host, port) {
|
|
|
17
17
|
});
|
|
18
18
|
return;
|
|
19
19
|
} catch (error) {
|
|
20
|
-
if (error.code !== 'EADDRINUSE') throw refuse(`Could not listen on ${host} port ${port}: ${error.code === 'EACCES' ? 'permission denied' : error.code ?? 'socket error'}. Check the address and permissions, then run rer dev again or use rer setup --port PORT with a free port.`);
|
|
20
|
+
if (error.code !== 'EADDRINUSE') throw refuse(`Could not listen on ${host} port ${port}: ${error.code === 'EACCES' ? 'permission denied' : error.code ?? 'socket error'}. Check the address and permissions, then run ~/.local/bin/rer dev again or use ~/.local/bin/rer setup --port PORT with a free port.`);
|
|
21
21
|
const unavailable = async listener => refuse(await busyPortMessage({ port, host, root: process.cwd(), context, listener: listener ?? null }));
|
|
22
22
|
if (context && performance.now() >= context.deadline) throw await unavailable();
|
|
23
23
|
const { inspectionContext } = await shared('process-diagnostics.mjs');
|
package/cli/listing.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { previousListing } from '../modules/release/previous-listing.mjs';
|
|
|
3
3
|
|
|
4
4
|
export async function dispatchListing(args) {
|
|
5
5
|
if (args.length === 1 && args[0] === '--help') {
|
|
6
|
-
console.log('Usage: rer listing --repo DIR --ref COMMIT --output NEW_DIR\n\nRead committed listing facts and assets without gates, signing or tags.\nWrites listing.json and its relative asset paths. --ref defaults to HEAD.');
|
|
6
|
+
console.log('Usage: ~/.local/bin/rer listing --repo DIR --ref COMMIT --output NEW_DIR\n\nRead committed listing facts and assets without gates, signing or tags.\nWrites listing.json and its relative asset paths. --ref defaults to HEAD.');
|
|
7
7
|
return 0;
|
|
8
8
|
}
|
|
9
9
|
try {
|
package/cli/local-env.mjs
CHANGED
|
@@ -27,7 +27,7 @@ export async function refuseLocalEnvOutput(root, outputs, { uploaded = false } =
|
|
|
27
27
|
try { await refuseLocalEnvFiles(root, outputs ?? ['dist']); }
|
|
28
28
|
catch (error) {
|
|
29
29
|
if (!error.resource) throw error;
|
|
30
|
-
if (uploaded) throw refuse(`The deploy hook's build output holds the local settings file ${error.resource}, and the hook has already uploaded its build, so it may be on the live Worker. Remove what copies it into the build output, rotate every credential in that file, then run rer deploy again.`);
|
|
30
|
+
if (uploaded) throw refuse(`The deploy hook's build output holds the local settings file ${error.resource}, and the hook has already uploaded its build, so it may be on the live Worker. Remove what copies it into the build output, rotate every credential in that file, then run ~/.local/bin/rer deploy again.`);
|
|
31
31
|
throw refuse(`The build output holds the local settings file ${error.resource}; a deployment never carries one. Remove what puts it there (a file in public/, or a build step that copies it), then run the command again. Nothing was uploaded.`);
|
|
32
32
|
}
|
|
33
33
|
}
|
package/cli/local.mjs
CHANGED
|
@@ -36,7 +36,7 @@ export async function selectedOrigin(project, options, { setup = false } = {}) {
|
|
|
36
36
|
// Setup on a saved checkout moves it to another port; the host stays.
|
|
37
37
|
let moved;
|
|
38
38
|
if (setup && previous && previous.origin !== url) {
|
|
39
|
-
if (previous.hostname.replace(/^\[|\]$/g, '') !== host) throw refuse('Setup origin conflicts with the saved installation. Reuse its origin or back up data and run rer reset --yes.');
|
|
39
|
+
if (previous.hostname.replace(/^\[|\]$/g, '') !== host) throw refuse('Setup origin conflicts with the saved installation. Reuse its origin or back up data and run ~/.local/bin/rer reset --yes.');
|
|
40
40
|
moved = { from: savedPort, to: port };
|
|
41
41
|
}
|
|
42
42
|
return { url, host, port, vars, savedOrigin: previous?.origin, moved, explicitPort: options.port !== undefined, ...(taken ? { skipped: defaultPort } : {}) };
|
|
@@ -48,7 +48,7 @@ export async function availablePort(host, port, { root, saved = false, verb = 'd
|
|
|
48
48
|
const context = inspectionContext({port,verb});
|
|
49
49
|
const result = await probePort(host, port, { context });
|
|
50
50
|
if (result.available) return;
|
|
51
|
-
if (result.code && result.code !== 'EADDRINUSE') throw refuse(`Port ${port} cannot be used on ${host}: ${result.code}. Check the address or use rer setup --port PORT with a free port, then run rer dev again.`);
|
|
51
|
+
if (result.code && result.code !== 'EADDRINUSE') throw refuse(`Port ${port} cannot be used on ${host}: ${result.code}. Check the address or use ~/.local/bin/rer setup --port PORT with a free port, then run ~/.local/bin/rer dev again.`);
|
|
52
52
|
throw refuse(await busyPortMessage({ port, host, root, saved, context, listener: result.listener ?? null }));
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -80,7 +80,7 @@ export async function reset(project, options, out) {
|
|
|
80
80
|
async function resetHeld(project,options,out,operation) {
|
|
81
81
|
await refuseLegacyProcess(project,{reset:true,verb:'reset',operation});
|
|
82
82
|
const { strandedOriginals } = await shared('local/recovery.mjs');
|
|
83
|
-
if ((await strandedOriginals(project.root)).length) throw refuse('An interrupted build holds private settings. Run rer build to recover them before reviewing reset.');
|
|
83
|
+
if ((await strandedOriginals(project.root)).length) throw refuse('An interrupted build holds private settings. Run ~/.local/bin/rer build to recover them before reviewing reset.');
|
|
84
84
|
// The seed's own safety check (legacy data it still has to recover, for
|
|
85
85
|
// example) runs before the inventory and confirmation; --yes cannot skip it.
|
|
86
86
|
const preflight = project.adapter.resetPreflight;
|
|
@@ -124,7 +124,7 @@ export async function refuseLegacyProcess(project,{reset=false,verb='dev',operat
|
|
|
124
124
|
if(!isolated){
|
|
125
125
|
const {sqliteCustody}=await shared('local/sqlite-custody.mjs');
|
|
126
126
|
const database=await sqliteCustody(project.root);
|
|
127
|
-
if(database)throw refuse(`Another process holds an active SQLite lock on ${database}. Process inspection did not identify its PID. Stop unmanaged local servers (including Wrangler), then retry. Use rer dev --stop or rer preview --stop for a registered server.`);
|
|
127
|
+
if(database)throw refuse(`Another process holds an active SQLite lock on ${database}. Process inspection did not identify its PID. Stop unmanaged local servers (including Wrangler), then retry. Use ~/.local/bin/rer dev --stop or ~/.local/bin/rer preview --stop for a registered server.`);
|
|
128
128
|
}
|
|
129
129
|
return {lockProof:true};
|
|
130
130
|
}
|
package/cli/managed-server.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { launchSummary } from './run-transfers.mjs';
|
|
2
2
|
import { readySummary } from './ready-summary.mjs';
|
|
3
|
+
import { ownerEntryReady } from './owner-entry-ready.mjs';
|
|
3
4
|
import { nativeOwnerEntry } from './native-owner-entry.mjs';
|
|
4
5
|
import { prepareLiveModels } from './ai-local.mjs';
|
|
5
6
|
import {fileURLToPath} from 'node:url';
|
|
@@ -32,19 +33,19 @@ export async function ready(out,url,dev,json=false,siteUrl,demo,root,ownerOpenUr
|
|
|
32
33
|
out.human(`RER_READY ${url}`);
|
|
33
34
|
if(dev){
|
|
34
35
|
if(dev.signedInAs)out.human(`RER_SIGNED_IN ${dev.signedInAs}`);
|
|
35
|
-
else if(dev.ownerLeft)out.human('No active owner remains in this app. Use rer dev --as PERSONA with an active operator, or rer reset --yes and rer setup for a new owner.');
|
|
36
|
+
else if(dev.ownerLeft)out.human('No active owner remains in this app. Use ~/.local/bin/rer dev --as PERSONA with an active operator, or ~/.local/bin/rer reset --yes and ~/.local/bin/rer setup for a new owner.');
|
|
36
37
|
out.human(`RER_OPEN ${dev.openUrl}`);
|
|
37
38
|
if (!root && !dev.native) out.human("Open that link on this computer. Its fragment holds this checkout's dev key, which the page keeps only as a cookie; never share the link.");
|
|
38
39
|
}
|
|
39
40
|
if(ownerOpenUrl){out.human(`RER_OWNER_OPEN ${ownerOpenUrl}`);out.human('Native owner entry: open on this computer once within 15 minutes. The link is not saved.');}
|
|
40
41
|
if(siteUrl){if(!root)out.human(`Site: ${siteUrl}`);out.human(`RER_SITE ${siteUrl}`);}
|
|
41
|
-
if(demo){out.human(`RER_DEMO_ENDS_ON_STOP ${demo.state}`);out.human(`This demo runs on its own data in that folder, which is deleted when it stops: rer demo --stop, Ctrl-C, or at its end (${demo.ends.slice(11,16)}). Public reads and checks run for real. This checkout's own data is untouched.`);}
|
|
42
|
+
if(demo){out.human(`RER_DEMO_ENDS_ON_STOP ${demo.state}`);out.human(`This demo runs on its own data in that folder, which is deleted when it stops: ~/.local/bin/rer demo --stop, Ctrl-C, or at its end (${demo.ends.slice(11,16)}). Public reads and checks run for real. This checkout's own data is untouched.`);}
|
|
42
43
|
}
|
|
43
44
|
export async function managedServer(project,options,out,{clock={}}={}){
|
|
44
45
|
const registry=await serverRegistry(project.root),controller=new AbortController();
|
|
45
46
|
// A demo registers as its own mode: `rer dev --stop` never stops it by accident.
|
|
46
47
|
const mode=options.demo?'demo':options.verb;
|
|
47
|
-
let store,operation,proxy,activity,app,termination,reason,cleanupPromise,finished,selected,cleaned,site,demo,demoEnd,ownerEntry;
|
|
48
|
+
let store,operation,proxy,activity,app,termination,reason,cleanupPromise,finished,selected,cleaned,site,demo,demoEnd,ownerEntry,forwarding=false;
|
|
48
49
|
const scheduling=new AbortController();
|
|
49
50
|
let activityWrites=Promise.resolve(),pendingActivity,activityWriting=false,infrastructureFailure;
|
|
50
51
|
function recordActivity(fields){
|
|
@@ -85,11 +86,12 @@ export async function managedServer(project,options,out,{clock={}}={}){
|
|
|
85
86
|
if(devIdentity)devKey=await requireDevKey(project.root);
|
|
86
87
|
// A key is sent (or printed) for a door origin only once the door proves it is ours.
|
|
87
88
|
if(devIdentity)await verifyDoorFor(running.url);
|
|
88
|
-
const
|
|
89
|
-
await
|
|
89
|
+
const ownerOpenUrl=await checkedNativeEntry(project.root,()=>registry.ownerEntry(running).then(value=>value.ownerOpenUrl),controller.signal);
|
|
90
|
+
const dev=devIdentity&&options.verb==='dev'&&await devReady(project.root,running.url,devKey,options,controller.signal);
|
|
91
|
+
await emitReady(out,options,project.root,running.url,dev,running.siteUrl,running.demo,ownerOpenUrl);return {reused:true};
|
|
90
92
|
}
|
|
91
93
|
await registry.serve(async action=>{
|
|
92
|
-
if(action==='status')return {...activity?.snapshot(),url:selected?.url,probe:proxy?.probe,siteUrl:site?.url,demo};
|
|
94
|
+
if(action==='status')return {...activity?.snapshot(),forwarding,url:selected?.url,probe:proxy?.probe,siteUrl:site?.url,demo};
|
|
93
95
|
if(action==='owner-entry')return ownerEntry?{ownerOpenUrl:ownerEntry.issue()}:{};
|
|
94
96
|
if(action==='stop')return stop('explicit stop');
|
|
95
97
|
throw Error('Unknown management operation');
|
|
@@ -105,12 +107,17 @@ export async function managedServer(project,options,out,{clock={}}={}){
|
|
|
105
107
|
const keys=localSettingKeys(project);
|
|
106
108
|
selected=await selectedOrigin(project,options);
|
|
107
109
|
if(!selected.door)await availablePort(selected.host,selected.port,{root:project.root,saved:!selected.explicitPort&&selected.savedOrigin!==undefined,verb:options.verb});
|
|
108
|
-
if(!selected.vars[keys.email])throw missing(
|
|
110
|
+
if(!selected.vars[keys.email])throw missing(`Local prerequisite ${keys.email}: found unset; expected set; run ~/.local/bin/rer setup.`);
|
|
109
111
|
if(devIdentity&&!devKey)devKey=await requireDevKey(project.root);
|
|
110
112
|
if(devIdentity&&['dev','preview'].includes(options.verb))refuseManagedInstallation(selected.vars,process.env);
|
|
111
113
|
if(options.demo)demo=await demoPreflight(project,selected.vars,options.idleTimeout);
|
|
112
114
|
const prerequisites=async()=>{
|
|
113
|
-
if(
|
|
115
|
+
if(demo||!project.adapter.localPrerequisites)return;
|
|
116
|
+
const result=await project.adapter.localPrerequisites({root:project.root,vars:selected.vars,email:selected.vars[keys.email],demo:false});
|
|
117
|
+
if(result===true)return;
|
|
118
|
+
// Older adapters can still return false; named failures carry only safe values.
|
|
119
|
+
const {field,found,expected}=result||{field:'localPrerequisites',found:'false',expected:'true'};
|
|
120
|
+
throw missing(`Local prerequisite ${field}: found ${found}; expected ${expected}; run ~/.local/bin/rer setup.`);
|
|
114
121
|
};
|
|
115
122
|
if(options.verb!=='dev')await prerequisites();
|
|
116
123
|
await registry.update({url:selected.url,host:selected.host,port:selected.port,models:options.models??'fake'});
|
|
@@ -140,10 +147,16 @@ export async function managedServer(project,options,out,{clock={}}={}){
|
|
|
140
147
|
if(!identity)throw Error('Runtime exited before custody registration.');
|
|
141
148
|
await registry.update({runtimeProcess:{pid:identity.pid,start:identity.start}});
|
|
142
149
|
},controller.signal,{...adapterOptions,verb:options.verb,dev:project.adapter.dev,preview:project.adapter.preview});
|
|
150
|
+
// The runtime can receive public requests now. Keep announcement/registry
|
|
151
|
+
// readiness false until the browser has verified that same public door.
|
|
152
|
+
forwarding=true;
|
|
143
153
|
// A key is sent (or printed) for a door origin only once the door proves it is ours.
|
|
144
154
|
if(devKey)await verifyDoorFor(selected.url);
|
|
145
155
|
if(demo)await demoGuarded(selected.url,demo.state,controller.signal);
|
|
146
|
-
|
|
156
|
+
// Demo's dev-key exchange is authorized only after a native entry exists.
|
|
157
|
+
// Verify that entry first, then leave a fresh single-use link for the owner.
|
|
158
|
+
const ownerOpenUrl=await checkedNativeEntry(project.root,()=>ownerEntry?.issue(),controller.signal,store);
|
|
159
|
+
const dev=devIdentity&&options.verb==='dev'&&await devReady(project.root,selected.url,devKey,options,controller.signal,store);
|
|
147
160
|
if(options.verb==='dev'&&project.adapter.site){
|
|
148
161
|
const {devSite}=await import('./site.mjs');
|
|
149
162
|
try {
|
|
@@ -151,11 +164,11 @@ export async function managedServer(project,options,out,{clock={}}={}){
|
|
|
151
164
|
await registry.update({siteUrl:site.url});
|
|
152
165
|
} catch(error) {
|
|
153
166
|
if(error.code!=='site_private_data')throw error;
|
|
154
|
-
const message=`Run site preview refused: ${error.message} The app is running; fix the site and run rer build --site before publishing it.`;
|
|
167
|
+
const message=`Run site preview refused: ${error.message} The app is running; fix the site and run ~/.local/bin/rer build --site before publishing it.`;
|
|
155
168
|
if(options.json)out.event('warning',{code:error.code,message});else out.progress(`Warning: ${message}\n`);
|
|
156
169
|
}
|
|
157
170
|
}
|
|
158
|
-
activity.ready();await emitReady(out,options,project.root,selected.url,dev,site?.url,demo,
|
|
171
|
+
activity.ready();await emitReady(out,options,project.root,selected.url,dev,site?.url,demo,ownerOpenUrl);
|
|
159
172
|
if(crons.length){
|
|
160
173
|
out.progress(`Running ${crons.length===1?'the scheduled trigger':'the scheduled triggers'} locally: ${crons.join(' | ')}\n`);
|
|
161
174
|
void runScheduled({crons,url:`http://127.0.0.1:${proxy.runtimePort}`,path:options.verb==='preview'?'/cdn-cgi/local/scheduled':undefined,signal:scheduling.signal,report:run=>reportScheduled(out,options,run)});
|
|
@@ -182,9 +195,19 @@ async function emitReady(out,options,root,url,dev,siteUrl,demo,ownerOpenUrl){
|
|
|
182
195
|
}
|
|
183
196
|
await ready(out,url,dev||(ownerOpenUrl?{openUrl:ownerOpenUrl,native:true}:undefined),options.json,siteUrl,demo,options.verb === 'dev' && !options.demo ? root : undefined,ownerOpenUrl);
|
|
184
197
|
}
|
|
185
|
-
async function devReady(url,key,options,signal){
|
|
198
|
+
async function devReady(root,url,key,options,signal,store){
|
|
186
199
|
const as=options.as??'owner',persona=await resolvePersona(url,key,as,signal);
|
|
187
200
|
// The owner persona names the owner the session will actually have (the
|
|
188
201
|
// remaining owner once the setup owner has left), or none when none is left.
|
|
189
|
-
|
|
202
|
+
const link=openUrl(url,key,{path:'/__dev/key',as:persona.as});
|
|
203
|
+
await ownerEntryReady(root,link,signal,store);
|
|
204
|
+
return {identity:true,signedInAs:persona.email??null,ownerLeft:as==='owner'&&!persona.email,openUrl:link};
|
|
205
|
+
}
|
|
206
|
+
async function checkedNativeEntry(root,issue,signal,store){
|
|
207
|
+
const link=await issue();
|
|
208
|
+
if(!link)return;
|
|
209
|
+
await ownerEntryReady(root,link,signal,store);
|
|
210
|
+
// The probe redeemed its single-use grant. Announce a fresh grant through
|
|
211
|
+
// that same checked public entry, leaving its redemption to the owner.
|
|
212
|
+
return issue();
|
|
190
213
|
}
|
package/cli/output.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withCommandHelp } from './command-guidance.mjs';
|
|
1
2
|
import { humanError } from './human-error.mjs';
|
|
2
3
|
import { handleBrokenPipes } from './stdio.mjs';
|
|
3
4
|
import { exportSummary } from './export-summary.mjs';
|
|
@@ -14,7 +15,7 @@ export function output(options) {
|
|
|
14
15
|
const write = (fd, text) => { const stream = fd === 1 ? process.stdout : process.stderr; if (!stream.destroyed) stream.write(text); };
|
|
15
16
|
return {
|
|
16
17
|
event(event, details = {}) { write(1, JSON.stringify({ version: 1, verb: options.verb ?? 'unknown', event, ...details }) + '\n'); },
|
|
17
|
-
human(text) { write(1, text + '\n'); },
|
|
18
|
+
human(text) { write(1, (options.json || structuredResult || options.verb === 'describe' ? text : withCommandHelp(text)) + '\n'); },
|
|
18
19
|
progress(text) { write(2, text); },
|
|
19
20
|
result(ok, exitCode, details = {}) {
|
|
20
21
|
if (finished) throw Error('Duplicate CLI result'); finished = true;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { setTimeout as pause } from 'node:timers/promises';
|
|
2
|
+
import { checkoutPlaywright, ensureChromium, browsersPresent } from './browser-runtime.mjs';
|
|
3
|
+
import { invalid, missing, RerError } from './errors.mjs';
|
|
4
|
+
|
|
5
|
+
// Use the browser protocol itself: fragment exchange, cookies, server and
|
|
6
|
+
// client redirects, and rendered content. No application destination is fixed.
|
|
7
|
+
export async function ownerEntryReady(root, link, signal, store) {
|
|
8
|
+
const timeout = Number(process.env.RER_OWNER_READY_TIMEOUT_MS ?? 60000);
|
|
9
|
+
if (!Number.isSafeInteger(timeout) || timeout <= 0 || timeout > 2147483647) throw invalid('RER_OWNER_READY_TIMEOUT_MS must be positive integer milliseconds, at most 2147483647.');
|
|
10
|
+
const entry = new URL(link), deadline = performance.now() + timeout;
|
|
11
|
+
const bounded = AbortSignal.any([signal, AbortSignal.timeout(timeout)].filter(Boolean));
|
|
12
|
+
let browser, page, lastState, destination = entry, last = 'browser did not open the entry', documents = 0, status, exchanged = !entry.hash, lastReload = 0;
|
|
13
|
+
const remaining = () => Math.max(1, Math.ceil(deadline - performance.now()));
|
|
14
|
+
const name = url => url.origin + url.pathname; // Fragments and query values may be credentials.
|
|
15
|
+
const close = () => { void browser?.close().catch(() => {}); };
|
|
16
|
+
bounded.addEventListener('abort', close, { once: true });
|
|
17
|
+
try {
|
|
18
|
+
last = 'headless browser prerequisites did not become ready';
|
|
19
|
+
if (store) await ensureChromium(root, store, bounded);
|
|
20
|
+
else if (!await browsersPresent(root)) throw missing('Owner entry verification needs the checkout’s headless browser. Run ~/.local/bin/rer verify to provision it, then run the command again.');
|
|
21
|
+
const { playwright } = checkoutPlaywright(root);
|
|
22
|
+
bounded.throwIfAborted();
|
|
23
|
+
last = 'browser did not open the entry';
|
|
24
|
+
browser = await playwright.chromium.launch({ headless: true, timeout: remaining(), args: ['--use-mock-keychain', '--password-store=basic'] });
|
|
25
|
+
bounded.throwIfAborted();
|
|
26
|
+
const context = await browser.newContext();
|
|
27
|
+
page = await context.newPage();
|
|
28
|
+
// An owner credential and its cookies must never travel to another origin.
|
|
29
|
+
await context.route('**/*', route => {
|
|
30
|
+
const url = new URL(route.request().url());
|
|
31
|
+
return url.origin === entry.origin || !['http:', 'https:'].includes(url.protocol) ? route.continue() : route.abort();
|
|
32
|
+
});
|
|
33
|
+
page.on('response', response => {
|
|
34
|
+
const request = response.request();
|
|
35
|
+
if (request.method() === 'POST' && new URL(response.url()).pathname === entry.pathname && response.ok()) exchanged = true;
|
|
36
|
+
if (request.isNavigationRequest() && request.frame() === page.mainFrame()) {
|
|
37
|
+
documents++; status = response.status(); destination = new URL(response.url());
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
try { await page.goto(link, { waitUntil: 'domcontentloaded', timeout: Math.min(5000, remaining()) }); } catch { last = 'entry document did not finish loading'; }
|
|
41
|
+
while (!bounded.aborted) {
|
|
42
|
+
destination = new URL(page.url() === 'about:blank' ? entry.href : page.url());
|
|
43
|
+
const state = await page.evaluate(() => {
|
|
44
|
+
const visible = element => !!(element.getClientRects().length && getComputedStyle(element).visibility !== 'hidden');
|
|
45
|
+
const area = document.querySelector('main') ?? document.body, text = area?.innerText.trim() ?? '';
|
|
46
|
+
const retry = /the workspace is busy|trying again in a few seconds/i.test(text);
|
|
47
|
+
const busy = retry || [...document.querySelectorAll('[aria-busy="true"], [role="progressbar"]')].some(visible) || /^loading[.\s…]*$/i.test(text);
|
|
48
|
+
// An owner destination may be a read-only status page. Its controls may
|
|
49
|
+
// also live outside the light DOM; visible rendered content is enough,
|
|
50
|
+
// provided all exchange, navigation and interstitial checks below pass.
|
|
51
|
+
const usable = !!text && !!area && visible(area);
|
|
52
|
+
return { busy, retry, usable, refresh: !!document.querySelector('meta[http-equiv="refresh" i]') };
|
|
53
|
+
}).catch(() => null); // A navigation can replace the execution context.
|
|
54
|
+
if (state) lastState = { ...state, status };
|
|
55
|
+
// Retain observations for diagnostics only. Readiness still requires a
|
|
56
|
+
// successful read of the current document, never a cached usable page.
|
|
57
|
+
const observed = lastState;
|
|
58
|
+
const conditions = [
|
|
59
|
+
observed && !observed.usable && 'no rendered owner content',
|
|
60
|
+
observed?.busy && 'busy/retry interstitial',
|
|
61
|
+
observed?.refresh && 'refresh interstitial',
|
|
62
|
+
].filter(Boolean);
|
|
63
|
+
const failed = [
|
|
64
|
+
!exchanged && 'entry exchange not observed',
|
|
65
|
+
entry.hash && documents <= 1 && 'destination document not observed after entry',
|
|
66
|
+
!(status >= 200 && status < 300) && 'destination status is not 2xx',
|
|
67
|
+
!state && (observed ? 'destination DOM could not be read again' : 'destination DOM unavailable'),
|
|
68
|
+
...conditions,
|
|
69
|
+
destination.hash && 'destination still has a fragment',
|
|
70
|
+
destination.origin !== entry.origin && 'destination is cross-origin',
|
|
71
|
+
].filter(Boolean);
|
|
72
|
+
last = `HTTP ${status ?? 'unknown'} (${failed.join('; ')}). Readiness: exchanged=${exchanged}, documents=${documents}, usable=${observed?.usable ?? 'unknown'}, busy=${observed?.busy ?? 'unknown'}, refresh=${observed?.refresh ?? 'unknown'}, fragment=${!!destination.hash}, sameOrigin=${destination.origin === entry.origin}`;
|
|
73
|
+
if (observed) last += `. Last seen: HTTP ${observed.status ?? 'unknown'} (${conditions.join('; ') || 'rendered owner content'})`;
|
|
74
|
+
if (!failed.length) return;
|
|
75
|
+
// A server interstitial needs another GET. Client navigation/loading gets
|
|
76
|
+
// time to finish on its own rather than being restarted on every poll.
|
|
77
|
+
if (status && (status >= 400 || state?.retry || state?.refresh) && performance.now() - lastReload > 1000) {
|
|
78
|
+
lastReload = performance.now();
|
|
79
|
+
try { await page.reload({ waitUntil: 'domcontentloaded', timeout: Math.min(5000, remaining()) }); } catch { last += '; the next destination document did not finish loading'; }
|
|
80
|
+
}
|
|
81
|
+
await pause(Math.min(100, remaining()), undefined, { signal: bounded }).catch(() => {});
|
|
82
|
+
}
|
|
83
|
+
} catch (error) {
|
|
84
|
+
signal?.throwIfAborted();
|
|
85
|
+
if (error instanceof RerError && !bounded.aborted) throw error;
|
|
86
|
+
} finally {
|
|
87
|
+
bounded.removeEventListener('abort', close);
|
|
88
|
+
await browser?.close();
|
|
89
|
+
}
|
|
90
|
+
signal?.throwIfAborted();
|
|
91
|
+
throw new RerError('owner_entry_not_ready', `Owner entry ${name(entry)} did not become ready within ${timeout} ms. Destination ${name(destination)}: ${last}. No ready link was announced. Check the application startup log, then run the command again.`, 1);
|
|
92
|
+
}
|
package/cli/parse.mjs
CHANGED
|
@@ -26,7 +26,7 @@ export function parse(argv, cwd = process.cwd(), { independent = false, deferTai
|
|
|
26
26
|
if (verb === 'demo' && !independent) return parse(['dev', '--demo', ...args], cwd, { independent, deferTail });
|
|
27
27
|
// Independent projects own verb names; only the common wrapper flags apply
|
|
28
28
|
// to unknown names. Profile resolution rejects undeclared commands later.
|
|
29
|
-
if (!/^[a-z][a-z0-9-]*$/.test(verb)) throw invalid('Unknown rer command. Run rer --help.');
|
|
29
|
+
if (!/^[a-z][a-z0-9-]*$/.test(verb)) throw invalid('Unknown rer command. Run ~/.local/bin/rer --help.');
|
|
30
30
|
const allowed = new Set(independent ? [...commonFlags,...(['install','setup','build','verify','deploy','release','export','import','dev','preview'].includes(verb)?['--no-queue']:[])] : (verbs[verb] ?? authoringVerbs[verb] ?? (verb === 'signin' ? signinVerb : verb === 'size' ? sizeVerb : undefined))?.flags ?? commonFlags), options = { verb, cwd: resolve(cwd), forwarded: [], supplied: new Set() };
|
|
31
31
|
let separator = false;
|
|
32
32
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -38,11 +38,11 @@ export function parse(argv, cwd = process.cwd(), { independent = false, deferTai
|
|
|
38
38
|
if (!allowed.has(flag)) {
|
|
39
39
|
if(flag==='--strictPort')throw invalid('Unsupported --strictPort. Use --port PORT; strict port binding is automatic.');
|
|
40
40
|
const suggestion=[...allowed].sort((a,b)=>distance(flag,a)-distance(flag,b))[0];
|
|
41
|
-
throw invalid(`Unsupported flag ${/^--[a-zA-Z-]{1,40}$/.test(flag)?flag:'(invalid)'} for ${verb}.${suggestion?` Did you mean ${suggestion}?`:''} Run rer ${verb} --help.`);
|
|
41
|
+
throw invalid(`Unsupported flag ${/^--[a-zA-Z-]{1,40}$/.test(flag)?flag:'(invalid)'} for ${verb}.${suggestion?` Did you mean ${suggestion}?`:''} Run ~/.local/bin/rer ${verb} --help.`);
|
|
42
42
|
}
|
|
43
43
|
// Several secrets change in one deploy: --set-secret A --set-secret B is --set-secret A,B.
|
|
44
44
|
const listed = ['--set-secret', '--unset-secret', '--edition-migration'].includes(flag);
|
|
45
|
-
if (options.supplied.has(flag) && !listed) throw invalid(`Repeated flag ${flag} for ${verb}. Run rer ${verb} --help.`);
|
|
45
|
+
if (options.supplied.has(flag) && !listed) throw invalid(`Repeated flag ${flag} for ${verb}. Run ~/.local/bin/rer ${verb} --help.`);
|
|
46
46
|
options.supplied.add(flag);
|
|
47
47
|
const key = flag.slice(2).replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
48
48
|
if (booleans.has(flag)) options[key] = true;
|
|
@@ -54,7 +54,7 @@ export function parse(argv, cwd = process.cwd(), { independent = false, deferTai
|
|
|
54
54
|
}
|
|
55
55
|
if (options.help) return options;
|
|
56
56
|
if (deferTail) { options.cwd=resolve(cwd,options.cwd);return options; }
|
|
57
|
-
if (verb === 'refresh-base' && !independent && !options.ref) throw invalid('Provide --ref with the full immutable Base commit. Run rer refresh-base --help.');
|
|
57
|
+
if (verb === 'refresh-base' && !independent && !options.ref) throw invalid('Provide --ref with the full immutable Base commit. Run ~/.local/bin/rer refresh-base --help.');
|
|
58
58
|
if (options.detach && options.foreground) throw invalid('Choose one of --detach and --foreground.');
|
|
59
59
|
if(options.stop && ['--port','--host','--idle-timeout','--detach','--foreground','--no-queue','--as','--login','--models','--models-service','--door','--direct'].some(flag=>options.supplied.has(flag)))throw invalid('--stop cannot be combined with start-only flags.');
|
|
60
60
|
// --port and --host always mean direct mode; --door and --direct pick a mode.
|
|
@@ -77,7 +77,7 @@ export function parse(argv, cwd = process.cwd(), { independent = false, deferTai
|
|
|
77
77
|
options.idleTimeout=Number(value);
|
|
78
78
|
}
|
|
79
79
|
if (options.port !== undefined) {
|
|
80
|
-
if (!/^\d+$/.test(options.port) || Number(options.port) < 1 || Number(options.port) > 65535) throw Object.assign(invalid('Port must be a decimal integer from 1 to 65535.'), { humanMessage: `Port ${JSON.stringify(options.port)} is invalid. Use a port from 1 to 65535, for example: rer ${verb} --port 4800` });
|
|
80
|
+
if (!/^\d+$/.test(options.port) || Number(options.port) < 1 || Number(options.port) > 65535) throw Object.assign(invalid('Port must be a decimal integer from 1 to 65535.'), { humanMessage: `Port ${JSON.stringify(options.port)} is invalid. Use a port from 1 to 65535, for example: ~/.local/bin/rer ${verb} --port 4800` });
|
|
81
81
|
options.port = Number(options.port);
|
|
82
82
|
}
|
|
83
83
|
for(const key of ['httpPort','httpsPort'])if(options[key]!==undefined){if(!/^[0-9]+$/.test(options[key])||Number(options[key])<1||Number(options[key])>65535)throw invalid('Ingress port must be an integer from 1 to 65535.');options[key]=Number(options[key]);}
|
|
@@ -119,10 +119,10 @@ export function parse(argv, cwd = process.cwd(), { independent = false, deferTai
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
export function help(verb) {
|
|
122
|
-
if (!verb) return `Usage: rer VERB [FLAGS]\nCommands: ${Object.keys({...verbs, ...authoringVerbs}).join(', ')}, signin, size, release, listing, rehearse\nRun rer VERB --help for flags.\n${appSignInHelp}\n`;
|
|
122
|
+
if (!verb) return `Usage: ~/.local/bin/rer VERB [FLAGS]\nCommands: ${Object.keys({...verbs, ...authoringVerbs}).join(', ')}, signin, size, release, listing, rehearse\nRun ~/.local/bin/rer VERB --help for flags.\n${appSignInHelp}\n`;
|
|
123
123
|
const known = verbs[verb] ?? authoringVerbs[verb] ?? (verb === 'signin' ? signinVerb : verb === 'size' ? sizeVerb : undefined);
|
|
124
|
-
const door = ['export', 'import'].includes(verb) ? 'To move records, start the app and open its signed-in owner import door:\n\n rer dev\n\nOpen its Move in page (/app/import in the Base reference; the project\'s own docs name its path), then export or upload and review supported records there.\n\nTo back up or restore this installation:\n' : '';
|
|
125
|
-
return `${door}Usage: rer ${verb}${verb === 'refresh-base' ? ' --ref FULL_COMMIT' : ''} [FLAGS]\nFlags: ${(known?.flags ?? commonFlags).join(', ')}\n${known?.effects ?? 'Execute the declared OPERATIONS v2 argv with explicit arguments after --.'}\n`;
|
|
124
|
+
const door = ['export', 'import'].includes(verb) ? 'To move records, start the app and open its signed-in owner import door:\n\n ~/.local/bin/rer dev\n\nOpen its Move in page (/app/import in the Base reference; the project\'s own docs name its path), then export or upload and review supported records there.\n\nTo back up or restore this installation:\n' : '';
|
|
125
|
+
return `${door}Usage: ~/.local/bin/rer ${verb}${verb === 'refresh-base' ? ' --ref FULL_COMMIT' : ''} [FLAGS]\nFlags: ${(known?.flags ?? commonFlags).join(', ')}\n${known?.effects ?? 'Execute the declared OPERATIONS v2 argv with explicit arguments after --.'}\n`;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
function distance(a,b){let row=Array.from({length:b.length+1},(_,i)=>i);for(let i=1;i<=a.length;i++){const next=[i];for(let j=1;j<=b.length;j++)next[j]=Math.min(next[j-1]+1,row[j]+1,row[j-1]+(a[i-1]===b[j-1]?0:1));row=next;}return row[b.length];}
|
package/cli/port.mjs
CHANGED
|
@@ -17,7 +17,7 @@ export async function firstFreePort(host, from = defaultPort) {
|
|
|
17
17
|
const { searchPort } = await shared('port-probe.mjs');
|
|
18
18
|
const found = await searchPort({ host, from, verb: 'setup' });
|
|
19
19
|
if (found.port !== undefined) return found.port;
|
|
20
|
-
throw refuse(`No free port from ${found.range[0]} to ${found.range[1]}: all ${found.tried} ports tried were in use. Stop something that holds one, or run rer setup --port PORT with a free port.`);
|
|
20
|
+
throw refuse(`No free port from ${found.range[0]} to ${found.range[1]}: all ${found.tried} ports tried were in use. Stop something that holds one, or run ~/.local/bin/rer setup --port PORT with a free port.`);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// Who holds a port: a server another checkout registered (its path and the
|
|
@@ -45,10 +45,10 @@ export async function busyPortMessage({ port, host, root, saved, env = process.e
|
|
|
45
45
|
await new Promise((resolve, reject) => { socket.once('error', reject); socket.listen({ host, port: 0, exclusive: true }, resolve); });
|
|
46
46
|
next = socket.address().port;
|
|
47
47
|
} finally { if (socket.listening) await new Promise(resolve => socket.close(resolve)); }
|
|
48
|
-
const move = `\nTo move this checkout to a free port and keep its data, run this in its folder:\n rer setup --port ${next}`;
|
|
48
|
+
const move = `\nTo move this checkout to a free port and keep its data, run this in its folder:\n ~/.local/bin/rer setup --port ${next}`;
|
|
49
49
|
|
|
50
50
|
const kind = saved ? `Port ${port} is saved for this checkout but is` : `Port ${port} is`;
|
|
51
|
-
if (!holder) return `${kind} still unavailable for binding on ${host} after retrying; no listener was identified. Run rer dev or rer setup again.${move}`;
|
|
51
|
+
if (!holder) return `${kind} still unavailable for binding on ${host} after retrying; no listener was identified. Run ~/.local/bin/rer dev or ~/.local/bin/rer setup again.${move}`;
|
|
52
52
|
if (holder.own) return `${kind} held by this checkout's own ${holder.server.mode} server for ${holder.checkout} (PID ${holder.pid}). Stop it with: ${stopInstruction(holder.server)}${move}`;
|
|
53
53
|
const who = holder.server
|
|
54
54
|
? `the ${holder.server.mode} server for ${holder.checkout} (PID ${holder.pid})`
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { register } from 'node:module';
|
|
2
|
+
|
|
3
|
+
let active=false;
|
|
4
|
+
export function activatePortabilityRuntime() {
|
|
5
|
+
if(active)return;
|
|
6
|
+
// The selected dispatcher owns installation archives. A seed supplies the
|
|
7
|
+
// bindings and policy, even when its node_modules holds another rer version.
|
|
8
|
+
register(import.meta.url,import.meta.url);
|
|
9
|
+
active=true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function resolve(specifier,context,nextResolve) {
|
|
13
|
+
if(specifier==='@runeditrun/rer/portability')
|
|
14
|
+
return {url:new URL('./portability.mjs',import.meta.url).href,shortCircuit:true};
|
|
15
|
+
return nextResolve(specifier,context);
|
|
16
|
+
}
|
package/cli/portability.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { ledgerRefusal } from './ledger-refusal.mjs';
|
|
|
13
13
|
|
|
14
14
|
export { withManagedDataImport };
|
|
15
15
|
|
|
16
|
-
const reExport = 'Re-export from the original installation with rer export --output exports/recovered.rer (add --target remote for a hosted installation), then retry rer import --input exports/recovered.rer --yes. Keep the original archive until recovery succeeds.';
|
|
16
|
+
const reExport = 'Re-export from the original installation with ~/.local/bin/rer export --output exports/recovered.rer (add --target remote for a hosted installation), then retry ~/.local/bin/rer import --input exports/recovered.rer --yes. Keep the original archive until recovery succeeds.';
|
|
17
17
|
|
|
18
18
|
// Seeds declare their real bindings and data policy. The shared module owns the
|
|
19
19
|
// archive format and atomic restore; the shared runner owns its native children.
|
|
@@ -37,7 +37,7 @@ export function localPortability({ database, binding = 'DB', buckets = {}, polic
|
|
|
37
37
|
if (error.message === 'archive_json') throw new RerError('invalid_archive', `Restore refused: the archive is damaged or incomplete. ${reExport}`, 2);
|
|
38
38
|
if (!(error instanceof PortabilityError)) throw error;
|
|
39
39
|
const message = error.code === 'legacy_archive_unverifiable'
|
|
40
|
-
? 'Restore refused (legacy_archive_unverifiable): version 1 metadata cannot be authenticated. Upgrade the original installation and re-export, or use rer import --legacy-v1 --input FILE --yes --acknowledge-unverified-metadata --output exports/recovered-v2.rer in an empty installation. See modules/portability/README.md#backup-only-v1-recovery.'
|
|
40
|
+
? 'Restore refused (legacy_archive_unverifiable): version 1 metadata cannot be authenticated. Upgrade the original installation and re-export, or use ~/.local/bin/rer import --legacy-v1 --input FILE --yes --acknowledge-unverified-metadata --output exports/recovered-v2.rer in an empty installation. See modules/portability/README.md#backup-only-v1-recovery.'
|
|
41
41
|
: `Restore refused (${error.code}): archive verification failed. ${reExport}`;
|
|
42
42
|
const refused = error.status === 409;
|
|
43
43
|
throw new RerError(refused ? 'restore_refused' : 'transfer_failed', message, refused ? 4 : 1);
|
|
@@ -102,7 +102,7 @@ async function nativeWorker(store,direction,input,signal) {
|
|
|
102
102
|
const status = await closed;
|
|
103
103
|
if (!receipt || typeof receipt !== 'object') throw new RerError('transfer_failed', `Local portability ended before it finished (${status.signal ? `signal ${status.signal}` : `exit code ${status.code}`}). Run the same command again; it starts over${direction === 'import' ? ' and first cleans up anything this attempt staged' : ''}.`, 1);
|
|
104
104
|
if (status.code !== 0 || !receipt.ok) throw new RerError(receipt.code ?? 'transfer_failed', receipt.reason==='legacy_restored_export_failed'
|
|
105
|
-
? 'Legacy data was restored and audited, but its v2 export failed. Preserve this installation, resolve the output problem, then run rer export --output FILE. Do not reset it to retry recovery.'
|
|
105
|
+
? 'Legacy data was restored and audited, but its v2 export failed. Preserve this installation, resolve the output problem, then run ~/.local/bin/rer export --output FILE. Do not reset it to retry recovery.'
|
|
106
106
|
: receipt.reason === 'archive_json' ? `Restore refused: the archive is damaged or incomplete. ${reExport}`
|
|
107
107
|
: receipt.reExport ? `Restore refused (schema_mismatch): the schema definitions cannot be safely verified by this version. ${reExport}`
|
|
108
108
|
: receipt.identityTable ? `Transfer refused (identity_table_undeclared:${receipt.identityTable}): declare this table in includeTables to transfer its rows or excludeTables to omit them.`
|
|
@@ -116,5 +116,5 @@ async function nativeWorker(store,direction,input,signal) {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
function occupiedRefusal(input,reason) {
|
|
119
|
-
return `Restore refused (${reason}): this installation already contains ${reason === 'bucket_not_empty' ? 'files' : 'people or data'}. Import restores into an empty installation. Use a fresh installation, or to replace this installation's data, keep a copy with rer export --output exports/before-restore.rer, then run rer reset --yes and rer import --input ${relative(input.root, input.path)} --yes again.`;
|
|
119
|
+
return `Restore refused (${reason}): this installation already contains ${reason === 'bucket_not_empty' ? 'files' : 'people or data'}. Import restores into an empty installation. Use a fresh installation, or to replace this installation's data, keep a copy with ~/.local/bin/rer export --output exports/before-restore.rer, then run ~/.local/bin/rer reset --yes and ~/.local/bin/rer import --input ${relative(input.root, input.path)} --yes again.`;
|
|
120
120
|
}
|
package/cli/production-auth.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withCommandHelp } from './command-guidance.mjs';
|
|
1
2
|
import { refuse } from './errors.mjs';
|
|
2
3
|
import { main as owner } from '../modules/deploy-kit/owner-cli.mjs';
|
|
3
4
|
import { hookState } from './deploy-hook-record.mjs';
|
|
@@ -9,12 +10,13 @@ import { productionMail, mailOffSignInCommand } from './production-mail.mjs';
|
|
|
9
10
|
// true: with the Worker's bound secret names in `live`, a bound mail secret is named instead, and
|
|
10
11
|
// without them (a dry run reads no secrets) the line says the bound secrets were not read.
|
|
11
12
|
export function mailOffNotice({ signIn, credentialNames = [] }, environment = 'production', live) {
|
|
13
|
+
signIn = signIn.replace(/^rer(?=\s|$)/, '~/.local/bin/rer');
|
|
12
14
|
if (credentialNames.length && Array.isArray(live)) {
|
|
13
15
|
const bound = credentialNames.filter(name => live.includes(name));
|
|
14
|
-
if (bound.length) return `Outbound email is configured by the secrets bound on this environment's Worker: ${bound.join(', ')} (names only; values are never printed). This deploy's MAIL_PROVIDER=none setting does not remove them; turn mail off with rer deploy --environment ${environment} --unset-secret and these names. Sign in without mail with \`${signIn}\` for the ${environment} environment, from this checkout with the Cloudflare credentials that deployed it
|
|
16
|
+
if (bound.length) return withCommandHelp(`Outbound email is configured by the secrets bound on this environment's Worker: ${bound.join(', ')} (names only; values are never printed). This deploy's MAIL_PROVIDER=none setting does not remove them; turn mail off with ~/.local/bin/rer deploy --environment ${environment} --unset-secret and these names. Sign in without mail with \`${signIn}\` for the ${environment} environment, from this checkout with the Cloudflare credentials that deployed it.`);
|
|
15
17
|
}
|
|
16
18
|
const unread = credentialNames.length && !Array.isArray(live) ? ` The bound secrets were not read: if one of ${credentialNames.join(', ')} is bound on the Worker, outbound email is configured by it.` : '';
|
|
17
|
-
return `Outbound email is off (MAIL_PROVIDER=none): no mail credential is bound and this installation sends nothing. Sign in without mail with \`${signIn}\` for the ${environment} environment, from this checkout with the Cloudflare credentials that deployed it. Turn mail on later with rer deploy --environment ${environment} --set-secret and the provider inputs.${unread}
|
|
19
|
+
return withCommandHelp(`Outbound email is off (MAIL_PROVIDER=none): no mail credential is bound and this installation sends nothing. Sign in without mail with \`${signIn}\` for the ${environment} environment, from this checkout with the Cloudflare credentials that deployed it. Turn mail on later with ~/.local/bin/rer deploy --environment ${environment} --set-secret and the provider inputs.${unread}`);
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
// Validate the shared email/identity contract using the bindings that will reach
|
package/cli/production-mail.mjs
CHANGED
|
@@ -101,7 +101,7 @@ export async function productionMail(root, declaration, env, declarationPath = '
|
|
|
101
101
|
catch (error) { throw refuse(`${error.message} Nothing was built or uploaded.`); }
|
|
102
102
|
let senderIssue;
|
|
103
103
|
if (present(bindings.MAIL_FROM) && (!sender(bindings.MAIL_FROM) || placeholderSender(bindings.MAIL_FROM))) {
|
|
104
|
-
senderIssue = `MAIL_FROM is invalid or a placeholder sender. Replace it with a real sender address on your mail provider's verified domain (a bare address or Display Name <address>). ${senderFix}, then run rer deploy --dry-run again.`;
|
|
104
|
+
senderIssue = `MAIL_FROM is invalid or a placeholder sender. Replace it with a real sender address on your mail provider's verified domain (a bare address or Display Name <address>). ${senderFix}, then run ~/.local/bin/rer deploy --dry-run again.`;
|
|
105
105
|
}
|
|
106
106
|
const provider = bindings.MAIL_PROVIDER;
|
|
107
107
|
const deferred = !provider || provider === 'later';
|
package/cli/project.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
4
4
|
import { containedInput } from '../modules/demo/input-path.mjs';
|
|
5
5
|
import { readOperations } from '../operations/operations.mjs';
|
|
6
6
|
import { invalid, missing, refuse } from './errors.mjs';
|
|
7
|
+
import { activatePortabilityRuntime } from './portability-runtime.mjs';
|
|
7
8
|
|
|
8
9
|
export function contained(root, path, options = {}) {
|
|
9
10
|
return containedInput(root, path, { ...options, refuse, missing });
|
|
@@ -20,6 +21,7 @@ export async function resolveProject(root) {
|
|
|
20
21
|
let adapter;
|
|
21
22
|
if (marker) {
|
|
22
23
|
await contained(root, marker.adapter);
|
|
24
|
+
activatePortabilityRuntime();
|
|
23
25
|
try { adapter = (await import(pathToFileURL(resolve(root, marker.adapter)))).commandAdapter; }
|
|
24
26
|
catch { throw invalid('The declared adapter could not be loaded. Restore its portable sources.'); }
|
|
25
27
|
}
|