@runeditrun/rer 0.2.120 → 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 +173 -5
- package/cli/archive.mjs +1 -1
- package/cli/authoring.mjs +1 -1
- package/cli/browser-runtime.mjs +33 -18
- 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 +20 -3
- package/cli/deploy-owner-input.mjs +2 -2
- package/cli/deploy-settings.mjs +14 -0
- package/cli/deploy-source.mjs +1 -1
- package/cli/deploy-variables.mjs +7 -1
- package/cli/deploy.mjs +6 -4
- 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 +9 -4
- package/cli/lifecycle.mjs +10 -10
- 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 +19 -9
- 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 +47 -0
- package/global/browser-runtime.mjs +9 -5
- 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 +5 -5
- 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 +11 -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 +55 -25
- package/modules/deploy-kit/owner-remove.mjs +7 -6
- package/modules/deploy-kit/owner-secret-copy.mjs +2 -1
- package/modules/deploy-kit/owner-secret.mjs +8 -5
- package/modules/deploy-kit/owner.mjs +49 -30
- 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/deploy-kit/validation.mjs +1 -0
- package/modules/deploy-kit/worker.mjs +1 -0
- 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
|
@@ -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]);}
|
|
@@ -91,7 +91,17 @@ export function parse(argv, cwd = process.cwd(), { independent = false, deferTai
|
|
|
91
91
|
if (options.profile !== undefined && options.profile !== 'first-party') throw invalid('The supported explicit profile is first-party.');
|
|
92
92
|
if (options.environment !== undefined && !/^[a-z][a-z0-9-]{0,39}$/.test(options.environment)) throw invalid('Provide a valid deployment environment name.');
|
|
93
93
|
for (const key of ['setSecret', 'unsetSecret']) if (options[key] !== undefined) {
|
|
94
|
-
const
|
|
94
|
+
const entries = options[key].split(',');
|
|
95
|
+
const assignments = key === 'setSecret' ? entries.filter(entry => entry.includes('=')) : [];
|
|
96
|
+
if (assignments.length) {
|
|
97
|
+
options.setSecretValues = {};
|
|
98
|
+
for (const entry of assignments) {
|
|
99
|
+
const at = entry.indexOf('='), name = entry.slice(0, at), value = entry.slice(at + 1);
|
|
100
|
+
if (!value.trim() || value.length > 1024 || /[\u0000-\u001f\u007f]/.test(value) || Object.hasOwn(options.setSecretValues, name)) throw invalid('--set-secret NAME=VALUE requires one nonempty public setting value per binding.');
|
|
101
|
+
options.setSecretValues[name] = value;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const names = [...new Set(entries.map(entry => key === 'setSecret' ? entry.split('=', 1)[0] : entry))];
|
|
95
105
|
if (names.length > 16 || !names.every(name => /^[A-Z][A-Z0-9_]{0,63}$/.test(name))) throw invalid(`--${key === 'setSecret' ? '' : 'un'}set-secret names declared secret bindings, repeated or separated by commas, such as SESSION_SECRET or MAIL_API_KEY,MAIL_FROM.`);
|
|
96
106
|
options[key] = names.join(',');
|
|
97
107
|
}
|
|
@@ -109,10 +119,10 @@ export function parse(argv, cwd = process.cwd(), { independent = false, deferTai
|
|
|
109
119
|
}
|
|
110
120
|
|
|
111
121
|
export function help(verb) {
|
|
112
|
-
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`;
|
|
113
123
|
const known = verbs[verb] ?? authoringVerbs[verb] ?? (verb === 'signin' ? signinVerb : verb === 'size' ? sizeVerb : undefined);
|
|
114
|
-
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' : '';
|
|
115
|
-
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`;
|
|
116
126
|
}
|
|
117
127
|
|
|
118
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
|
}
|
package/cli/rehearse/options.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {resolve} from 'node:path';
|
|
2
2
|
import {invalid} from '../errors.mjs';
|
|
3
3
|
|
|
4
|
-
export const rehearseHelp = `Usage: rer rehearse [--cwd DIR] [--ref REF] [--json] [FLAGS]
|
|
4
|
+
export const rehearseHelp = `Usage: ~/.local/bin/rer rehearse [--cwd DIR] [--ref REF] [--json] [FLAGS]
|
|
5
5
|
|
|
6
6
|
Rehearse the first managed build in a fresh two-commit copy, outside this checkout.
|
|
7
7
|
Runs every declared setup, build, verify and artifact operation, in that order,
|
|
@@ -27,7 +27,7 @@ Operations are trusted seed code and can install packages and contact the networ
|
|
|
27
27
|
This is a local build rehearsal; it does not attest, upload or deploy an artifact.
|
|
28
28
|
|
|
29
29
|
Heavy work: signers and seed lanes must run through .tools/heavy-slot.py:
|
|
30
|
-
python3 -I /path/to/.tools/heavy-slot.py --remote auto -- rer rehearse --cwd SEED
|
|
30
|
+
python3 -I /path/to/.tools/heavy-slot.py --remote auto -- ~/.local/bin/rer rehearse --cwd SEED
|
|
31
31
|
Use a clean committed worktree when routing remotely; the selected source must be local
|
|
32
32
|
on that runner. Only declared operations may acquire dependencies over the network.
|
|
33
33
|
`;
|
|
@@ -46,7 +46,7 @@ export function rehearseOptions(args) {
|
|
|
46
46
|
if (!/^[1-9][0-9]*$/.test(value) || !Number.isSafeInteger(Number(value)) || Number(value)>86400) throw invalid(`${flag} takes integer seconds from 1 to 86400.`);
|
|
47
47
|
options[key]=Number(value);
|
|
48
48
|
} else options[key]=value;
|
|
49
|
-
} else throw invalid(`Unsupported rehearsal flag ${flag}. Run rer rehearse --help.`);
|
|
49
|
+
} else throw invalid(`Unsupported rehearsal flag ${flag}. Run ~/.local/bin/rer rehearse --help.`);
|
|
50
50
|
}
|
|
51
51
|
options.cwd=resolve(options.cwd);
|
|
52
52
|
if (options.ref.startsWith('-')) throw invalid('--ref must name a Git commit or reference.');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {resolve} from 'node:path';
|
|
2
2
|
import {prepareCandidate} from '../modules/release/candidate.mjs';
|
|
3
3
|
|
|
4
|
-
export const candidateHelp = `Usage: rer release candidate --tag vVERSION-PRERELEASE [--cwd DIR] [--json]
|
|
4
|
+
export const candidateHelp = `Usage: ~/.local/bin/rer release candidate --tag vVERSION-PRERELEASE [--cwd DIR] [--json]
|
|
5
5
|
|
|
6
6
|
Prepare stage-only version metadata in one local commit on the caller's checkout.
|
|
7
7
|
Updates only version in seed.json, package.json and RELEASE.json; requires a clean
|
|
@@ -24,7 +24,7 @@ export async function candidateCommand(args) {
|
|
|
24
24
|
if (seen.has(flag)) throw Error(`Repeated candidate flag ${flag}.`); seen.add(flag);
|
|
25
25
|
if (flag==='--help') {console.log(candidateHelp);return 0;}
|
|
26
26
|
if (flag==='--json' || flag==='--non-interactive') continue;
|
|
27
|
-
if (!['--cwd','--tag'].includes(flag) || !args[index+1]?.trim() || args[index+1].startsWith('--')) throw Error('Use rer release candidate --tag vVERSION-PRERELEASE [--cwd DIR] [--json].');
|
|
27
|
+
if (!['--cwd','--tag'].includes(flag) || !args[index+1]?.trim() || args[index+1].startsWith('--')) throw Error('Use ~/.local/bin/rer release candidate --tag vVERSION-PRERELEASE [--cwd DIR] [--json].');
|
|
28
28
|
const value=args[++index]; if(flag==='--cwd')cwd=resolve(value);else tag=value;
|
|
29
29
|
}
|
|
30
30
|
console.log(JSON.stringify(prepareCandidate(cwd, tag), null, 2));return 0;
|
package/cli/release.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { releaseVerb } from './contract.mjs';
|
|
|
2
2
|
import { parseTimeoutSeconds, timeoutBounds } from '../scripts/publish-check/timeout.mjs';
|
|
3
3
|
|
|
4
4
|
// Preserve release's accepted parser, producer, receipt and validation exits.
|
|
5
|
-
const releaseHelp = `Usage: rer release --repo DIR --project OWNER/NAME --repository GITHUB_URL --output NEW_DIR [FLAGS]
|
|
5
|
+
const releaseHelp = `Usage: ~/.local/bin/rer release --repo DIR --project OWNER/NAME --repository GITHUB_URL --output NEW_DIR [FLAGS]
|
|
6
6
|
|
|
7
7
|
Produce local artifacts using the exact source commit's green GitHub Verify,
|
|
8
8
|
frozen installation, local build and publication checks.
|
|
@@ -39,12 +39,12 @@ Without --tag, write a preview. This command never pushes, uploads or deploys.
|
|
|
39
39
|
--help Print this help without performing release work.
|
|
40
40
|
|
|
41
41
|
Stage-only metadata preparation:
|
|
42
|
-
rer release candidate --tag vVERSION-PRERELEASE [--cwd DIR] [--json]
|
|
42
|
+
~/.local/bin/rer release candidate --tag vVERSION-PRERELEASE [--cwd DIR] [--json]
|
|
43
43
|
|
|
44
44
|
Signing and receipt commands:
|
|
45
|
-
rer release sign --artifact DIR (--key-file FILE | --key-stdin) [--scope test|rer] [--publisher NAMESPACE]
|
|
46
|
-
rer release receipt --artifact DIR --anchors FILE [--environment test] [--after VERSION:SHA256]
|
|
47
|
-
rer release keygen --scope test|rer --publisher NAMESPACE --github-owner LOGIN --github-owner-id ID --anchor-out FILE
|
|
45
|
+
~/.local/bin/rer release sign --artifact DIR (--key-file FILE | --key-stdin) [--scope test|rer] [--publisher NAMESPACE]
|
|
46
|
+
~/.local/bin/rer release receipt --artifact DIR --anchors FILE [--environment test] [--after VERSION:SHA256]
|
|
47
|
+
~/.local/bin/rer release keygen --scope test|rer --publisher NAMESPACE --github-owner LOGIN --github-owner-id ID --anchor-out FILE
|
|
48
48
|
[--not-before YYYY-MM-DDTHH:MM:SSZ] [--not-after YYYY-MM-DDTHH:MM:SSZ]
|
|
49
49
|
[--unsigned-through PROJECT:VERSION ...]
|
|
50
50
|
|
package/cli/server-registry.mjs
CHANGED
|
@@ -17,7 +17,7 @@ export function positive(value, name, fallback) {
|
|
|
17
17
|
if(!/^[1-9][0-9]*$/.test(String(value)) || !Number.isSafeInteger(Number(value)))throw invalid(`${name} must be positive integer seconds/count.`);
|
|
18
18
|
return Number(value);
|
|
19
19
|
}
|
|
20
|
-
export const stopInstruction = record =>
|
|
20
|
+
export const stopInstruction = record => `~/.local/bin/rer ${record.mode} --cwd ${JSON.stringify(record.checkout)} --stop`;
|
|
21
21
|
// Plain-words listing of one running server for the limit refusal.
|
|
22
22
|
const listing = record => ` ${record.mode} on port ${record.port ?? '(starting)'} in ${record.checkout}\n stop it with: ${stopInstruction(record)}`;
|
|
23
23
|
export const description = record => `${record.mode} ${record.url ?? '(starting)'} for ${record.checkout}; stop it with: ${stopInstruction(record)}`;
|
|
@@ -56,7 +56,7 @@ function memoryMessage(counted,available,floor,mode) {
|
|
|
56
56
|
const gib=bytes=>(bytes/1024**3).toFixed(1);
|
|
57
57
|
const head=`Not started: this computer is short of memory. ${gib(available)} GiB is available and a new server starts only at ${gib(floor)} GiB or more.`;
|
|
58
58
|
const list=counted.length?`Running now:\n${counted.map(listing).join('\n')}\nA dev server holds about 0.5-1.3 GiB and a preview 0.4-0.8 GiB; stopping one with its command above frees that.`:'No dev or preview server is running, so something else is using the memory.';
|
|
59
|
-
return `${head}\n${list}\nTo start anyway, lower the floor, for example RER_SERVERS_MIN_MEMORY_BYTES=${Math.floor(floor/2)} rer ${mode} (0 turns it off).`;
|
|
59
|
+
return `${head}\n${list}\nTo start anyway, lower the floor, for example RER_SERVERS_MIN_MEMORY_BYTES=${Math.floor(floor/2)} ~/.local/bin/rer ${mode} (0 turns it off).`;
|
|
60
60
|
}
|
|
61
61
|
function limitMessage(counted,cap,explicit,mode,file) {
|
|
62
62
|
const holders=explicit?[]:counted.filter(item=>item.explicit&&item.limit===cap);
|
|
@@ -67,7 +67,7 @@ function limitMessage(counted,cap,explicit,mode,file) {
|
|
|
67
67
|
:holders.length
|
|
68
68
|
?`The limit is ${cap} because ${holders.length===1?'a server was':'servers were'} started with RER_SERVER_LIMIT=${cap} (${holders.map(item=>item.checkout).join(', ')}). Stop ${holders.length===1?'it':'them'} and start again, or start everything with a higher RER_SERVER_LIMIT=N.`
|
|
69
69
|
:explicit?`This start set RER_SERVER_LIMIT=${cap}; to allow more, start it with a higher RER_SERVER_LIMIT=N.`
|
|
70
|
-
:`To allow more, start this one with a higher limit, for example RER_SERVER_LIMIT=${cap*2} rer ${mode}. Servers started without RER_SERVER_LIMIT allow ${defaultServerLimit}.`;
|
|
70
|
+
:`To allow more, start this one with a higher limit, for example RER_SERVER_LIMIT=${cap*2} ~/.local/bin/rer ${mode}. Servers started without RER_SERVER_LIMIT allow ${defaultServerLimit}.`;
|
|
71
71
|
return `${head}\n${list}\nTo make room, stop one with its command above. ${raise}`;
|
|
72
72
|
}
|
|
73
73
|
// A server is only ever stopped by the checkout that owns it, through its own
|
package/cli/server-resources.mjs
CHANGED
|
@@ -51,7 +51,7 @@ export async function serverResources(root,{load=()=>loadavg()[0],disk=statfs,en
|
|
|
51
51
|
// Validate explicit values before doing any measurements.
|
|
52
52
|
let floor=serversDiskFloor(env);
|
|
53
53
|
const measured=threshold===Infinity?0:await load();
|
|
54
|
-
if(!Number.isFinite(measured)||measured>threshold)throw refuse(`Not started: this computer is busy. Its 1-minute load is ${Number.isFinite(measured)?measured.toFixed(1):'unknown'} and a server starts only at ${threshold} or below.\nTry again in a few minutes, or start it anyway with a higher threshold, for example RER_SERVERS_LOAD_THRESHOLD=${Math.ceil(Math.max(threshold,Number.isFinite(measured)?measured:0)*2)} rer dev.`);
|
|
54
|
+
if(!Number.isFinite(measured)||measured>threshold)throw refuse(`Not started: this computer is busy. Its 1-minute load is ${Number.isFinite(measured)?measured.toFixed(1):'unknown'} and a server starts only at ${threshold} or below.\nTry again in a few minutes, or start it anyway with a higher threshold, for example RER_SERVERS_LOAD_THRESHOLD=${Math.ceil(Math.max(threshold,Number.isFinite(measured)?measured:0)*2)} ~/.local/bin/rer dev.`);
|
|
55
55
|
if(env.RER_SERVERS_DISK_FLOOR_GIB===undefined)floor=serversDiskFloor(env,await seedDiskBytes(root));
|
|
56
56
|
const temporary=resolve(env.TMPDIR||env.TMP||env.TEMP||tmpdir());
|
|
57
57
|
for(const path of new Set([resolve(root),temporary,serversDirectory(env)])){
|
package/cli/setup-input.mjs
CHANGED
|
@@ -81,7 +81,7 @@ export async function setupInput(project, options, vars, signal, { origin } = {}
|
|
|
81
81
|
shape[key]=privateValue?'<private value>':choices?.[0]??'<value>';
|
|
82
82
|
return `${key} (${type}${choices?`; choices: ${choices.map(value=>JSON.stringify(value)).join(' | ')}`:''})`;
|
|
83
83
|
});
|
|
84
|
-
throw missing(`Missing or invalid active setup fields: ${details.join(', ')}. Create an owner-only JSON file (chmod 600 answers.json) shaped ${JSON.stringify(shape)}, then run rer setup --answers answers.json --non-interactive. --owner-email EMAIL and --owner-name NAME are also accepted when declared; use manifest field names inside the JSON, never an environment-file wrapper.`);
|
|
84
|
+
throw missing(`Missing or invalid active setup fields: ${details.join(', ')}. Create an owner-only JSON file (chmod 600 answers.json) shaped ${JSON.stringify(shape)}, then run ~/.local/bin/rer setup --answers answers.json --non-interactive. --owner-email EMAIL and --owner-name NAME are also accepted when declared; use manifest field names inside the JSON, never an environment-file wrapper.`);
|
|
85
85
|
}
|
|
86
86
|
if(!mailbox(answers[names.email]))throw invalid('Provide a valid plain owner mailbox.');
|
|
87
87
|
answers[names.email]=answers[names.email].toLowerCase();
|
|
@@ -89,13 +89,13 @@ export async function setupInput(project, options, vars, signal, { origin } = {}
|
|
|
89
89
|
const {owners,placeholder}=await assertLocalOwner(project.root,answers[names.email],message=>refuse(message),project.adapter.hooks?.localOwner,`${names.email} in ${project.adapter.hooks?.secrets?.file??'.dev.vars'}`);
|
|
90
90
|
// The zero-setup owner gives way to the real one; lifecycle renames it in place.
|
|
91
91
|
if(placeholder&&placeholder.toLowerCase()!==answers[names.email])project.ownerReplacement={from:placeholder,to:answers[names.email]};
|
|
92
|
-
if(savedEmail&&!mailbox(savedEmail))throw refuse('Saved owner is malformed. Restore private settings or run rer reset --yes.');
|
|
92
|
+
if(savedEmail&&!mailbox(savedEmail))throw refuse('Saved owner is malformed. Restore private settings or run ~/.local/bin/rer reset --yes.');
|
|
93
93
|
if(savedEmail&&savedEmail.toLowerCase()!==answers[names.email]&&(owners.length?!placeholder:savedEmail.toLowerCase()!==zeroSetupOwner(await realpath(project.root)))){
|
|
94
|
-
if(owners.length)throw refuse(`Private setting ${names.email} differs from the retained database owner. Restore ${names.email} in ${project.adapter.hooks?.secrets?.file??'.dev.vars'} to ${answers[names.email]}, then run rer setup --owner-email ${answers[names.email]}; or back up data and run rer reset --yes. Private bytes were kept.`);
|
|
95
|
-
throw refuse(`Owner conflicts with the saved installation (${savedEmail}). Run rer setup --owner-email ${savedEmail}, or back up data, run rer dev --stop, then rer reset --yes followed by rer setup --owner-email ${answers[names.email]}. Reset deletes local data.`);
|
|
94
|
+
if(owners.length)throw refuse(`Private setting ${names.email} differs from the retained database owner. Restore ${names.email} in ${project.adapter.hooks?.secrets?.file??'.dev.vars'} to ${answers[names.email]}, then run ~/.local/bin/rer setup --owner-email ${answers[names.email]}; or back up data and run ~/.local/bin/rer reset --yes. Private bytes were kept.`);
|
|
95
|
+
throw refuse(`Owner conflicts with the saved installation (${savedEmail}). Run ~/.local/bin/rer setup --owner-email ${savedEmail}, or back up data, run ~/.local/bin/rer dev --stop, then ~/.local/bin/rer reset --yes followed by ~/.local/bin/rer setup --owner-email ${answers[names.email]}. Reset deletes local data.`);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
try{return seed.model.validateInput(answers,known);}catch{throw missing('Installer answers are incomplete. Supply the active manifest fields using rer setup --answers answers.json --non-interactive.');}
|
|
98
|
+
try{return seed.model.validateInput(answers,known);}catch{throw missing('Installer answers are incomplete. Supply the active manifest fields using ~/.local/bin/rer setup --answers answers.json --non-interactive.');}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
async function question(label,privateValue,signal){
|
|
@@ -103,7 +103,7 @@ async function question(label,privateValue,signal){
|
|
|
103
103
|
const output=new Writable({write(chunk,_encoding,done){if(!muted)process.stderr.write(chunk);done();}});
|
|
104
104
|
const prompt=createInterface({input:process.stdin,output,terminal:true});
|
|
105
105
|
prompt.on('SIGINT',()=>process.kill(process.pid,'SIGINT'));
|
|
106
|
-
const closed=new Promise((_,reject)=>prompt.once('close',()=>reject(missing('Terminal input closed before setup answers were complete. Use rer setup --answers answers.json --non-interactive.'))));
|
|
106
|
+
const closed=new Promise((_,reject)=>prompt.once('close',()=>reject(missing('Terminal input closed before setup answers were complete. Use ~/.local/bin/rer setup --answers answers.json --non-interactive.'))));
|
|
107
107
|
try{const pending=prompt.question(label+'\n',{signal});muted=privateValue;return await Promise.race([pending,closed]);}finally{prompt.close();muted=false;output.end();if(privateValue)process.stderr.write('\n');}
|
|
108
108
|
}
|
|
109
109
|
|
package/cli/signin.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { invalid, missing, refuse, RerError } from './errors.mjs';
|
|
|
5
5
|
import { shared } from './shared.mjs';
|
|
6
6
|
import { settingKinds } from './deploy-settings.mjs';
|
|
7
7
|
import { main as owner } from '../modules/deploy-kit/owner-cli.mjs';
|
|
8
|
-
import { deployDiagnostic, providerRefusal } from '../modules/deploy-kit/diagnostics.mjs';
|
|
8
|
+
import { deployDiagnostic, providerRefusal, ownerTargetFailure } from '../modules/deploy-kit/diagnostics.mjs';
|
|
9
9
|
|
|
10
10
|
// rer signin: the owner's way into a hosted install without mail. With the same
|
|
11
11
|
// Cloudflare credentials that deployed it, rer writes a one-time grant (only its
|
|
@@ -13,12 +13,12 @@ import { deployDiagnostic, providerRefusal } from '../modules/deploy-kit/diagnos
|
|
|
13
13
|
// It never reaches a log, receipt or the deploy record; the Worker admits it only
|
|
14
14
|
// for the recorded owner, once, within 15 minutes, and logs its use.
|
|
15
15
|
export async function signinCommand(project, options, out, { fetch } = {}) {
|
|
16
|
-
if (project.profile !== 'first-party' || typeof project.adapter?.deploy !== 'function') throw refuse('rer signin needs a seed with an owner-account deploy declaration.');
|
|
17
|
-
const root = project.root, environment = options.environment ?? 'production', again = deployAgain(options).replace(
|
|
16
|
+
if (project.profile !== 'first-party' || typeof project.adapter?.deploy !== 'function') throw refuse('~/.local/bin/rer signin needs a seed with an owner-account deploy declaration.');
|
|
17
|
+
const root = project.root, environment = options.environment ?? 'production', again = deployAgain(options).replace('~/.local/bin/rer deploy', '~/.local/bin/rer signin');
|
|
18
18
|
const { path, value: declaration } = await declarationFor(root, project.adapter);
|
|
19
19
|
const state = await deploymentRecord(root, { ...options, verb: 'signin' });
|
|
20
20
|
const { env } = await deployEnvironment({ root, options, declaration, localOnlyKeys: project.adapter.localOnlyKeys ?? [] });
|
|
21
|
-
if (['CLOUDFLARE_ACCOUNT_ID', 'CLOUDFLARE_API_TOKEN'].some(name => !env[name]?.trim())) throw missing('rer signin uses the Cloudflare credentials that deployed this environment: set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in the environment or an --env-file, then run it again.');
|
|
21
|
+
if (['CLOUDFLARE_ACCOUNT_ID', 'CLOUDFLARE_API_TOKEN'].some(name => !env[name]?.trim())) throw missing('~/.local/bin/rer signin uses the Cloudflare credentials that deployed this environment: set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in the environment or an --env-file, then run it again.');
|
|
22
22
|
const { createRedaction } = await shared('redaction.mjs');
|
|
23
23
|
const redaction = createRedaction();
|
|
24
24
|
redaction.addSecrets([...(await settingKinds({ declaration, setupManifest: project.setupManifest })).privateValues(env), env.CLOUDFLARE_ACCOUNT_ID]);
|
|
@@ -31,17 +31,18 @@ export async function signinCommand(project, options, out, { fetch } = {}) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function failure(error, { environment, again, adapter, redact }) {
|
|
34
|
+
if (ownerTargetFailure(error)) return refuse(redact(ownerTargetFailure(error)));
|
|
34
35
|
const code = deployDiagnostic(error, redact)?.code ?? error.message;
|
|
35
|
-
if (code === 'missing-owner-receipt') return refuse(`This checkout has no completed rer deployment of the ${environment} environment. Run rer signin from the checkout that deployed it (rer deploy --environment ${environment}).`);
|
|
36
|
-
if (code === 'owned-resource-replaced') return refuse(`The ${environment} Worker is no longer the one this checkout deployed, so rer will not sign anyone in to it. Run rer deploy --environment ${environment} first.`);
|
|
36
|
+
if (code === 'missing-owner-receipt') return refuse(`This checkout has no completed rer deployment of the ${environment} environment. Run ~/.local/bin/rer signin from the checkout that deployed it (~/.local/bin/rer deploy --environment ${environment}).`);
|
|
37
|
+
if (code === 'owned-resource-replaced') return refuse(`The ${environment} Worker is no longer the one this checkout deployed, so rer will not sign anyone in to it. Run ~/.local/bin/rer deploy --environment ${environment} first.`);
|
|
37
38
|
if (code === 'owner-signin-unsupported') {
|
|
38
39
|
const path = adapter.signInPath;
|
|
39
|
-
if (path !== undefined && (typeof path !== 'string' || path.length > 2048 || !path.startsWith('/') || path.startsWith('//') || /[\\\s\u0000-\u001f\u007f-\u009f]/u.test(path))) return invalid('The adapter signInPath must be a same-origin browser path such as /login. Correct the seed declaration, then run rer signin again.');
|
|
40
|
+
if (path !== undefined && (typeof path !== 'string' || path.length > 2048 || !path.startsWith('/') || path.startsWith('//') || /[\\\s\u0000-\u001f\u007f-\u009f]/u.test(path))) return invalid('The adapter signInPath must be a same-origin browser path such as /login. Correct the seed declaration, then run ~/.local/bin/rer signin again.');
|
|
40
41
|
const destination = new URL(path ?? '/setup', error.origin).href;
|
|
41
|
-
return refuse(redact(`The ${environment} deployment signs owners in through the seed's own sign-in flow. ${path ? `Open ${destination} to sign in.` : `Open ${destination} for the seed's owner recovery.`} rer signin cannot issue a link for this seed.`));
|
|
42
|
+
return refuse(redact(`The ${environment} deployment signs owners in through the seed's own sign-in flow. ${path ? `Open ${destination} to sign in.` : `Open ${destination} for the seed's owner recovery.`} ~/.local/bin/rer signin cannot issue a link for this seed.`));
|
|
42
43
|
}
|
|
43
44
|
if (code === 'owner-signin-ambiguous') return refuse(`More than one D1 database of the ${environment} deployment holds an owner sign-in table, so rer cannot tell which one signs in the owner. Nothing was written.`);
|
|
44
|
-
if (code === 'owner-not-claimed') return refuse(`No owner has claimed the ${environment} deployment yet. Run rer deploy --environment ${environment}: it claims the owner. Nothing was written.`);
|
|
45
|
+
if (code === 'owner-not-claimed') return refuse(`No owner has claimed the ${environment} deployment yet. Run ~/.local/bin/rer deploy --environment ${environment}: it claims the owner. Nothing was written.`);
|
|
45
46
|
const refusal = providerRefusal(error, redact);
|
|
46
|
-
return new RerError('command_failed',
|
|
47
|
+
return new RerError('command_failed', `~/.local/bin/rer signin failed: ${/^[a-zA-Z0-9_-]{1,120}$/.test(code) ? redact(code) : 'signin-failed'}${refusal ? ` (${refusal})` : ''}. No sign-in link was issued; run ${again} again.`, 1);
|
|
47
48
|
}
|
package/cli/site-render.mjs
CHANGED
|
@@ -35,7 +35,7 @@ const ASSETS = 'site-assets';
|
|
|
35
35
|
|
|
36
36
|
let vite;
|
|
37
37
|
try { vite = await import(pathToFileURL(createRequire(join(root, 'package.json')).resolve('vite')).href); }
|
|
38
|
-
catch { fail('The run site renders with the checkout\'s own Vite. Run rer install first.'); }
|
|
38
|
+
catch { fail('The run site renders with the checkout\'s own Vite. Run ~/.local/bin/rer install first.'); }
|
|
39
39
|
process.env.NODE_ENV ??= 'production';
|
|
40
40
|
|
|
41
41
|
let contract;
|
package/cli/size/schema.mjs
CHANGED
|
@@ -42,7 +42,7 @@ export async function schemasFromBuild(root, { wrangler = defaultBuild.wrangler
|
|
|
42
42
|
const file = join(root, wrangler), build = dirname(file);
|
|
43
43
|
let config;
|
|
44
44
|
try { config = JSON.parse(await readFile(file, 'utf8')); }
|
|
45
|
-
catch { throw missing(`No production build at ${wrangler}. Run rer build, or point --migrations at a directory of D1 migrations.`); }
|
|
45
|
+
catch { throw missing(`No production build at ${wrangler}. Run ~/.local/bin/rer build, or point --migrations at a directory of D1 migrations.`); }
|
|
46
46
|
const schemas = [];
|
|
47
47
|
for (const item of config.d1_databases ?? []) {
|
|
48
48
|
const directory = resolve(build, item.migrations_dir ?? 'migrations');
|
package/cli/size/verify-step.mjs
CHANGED
|
@@ -14,7 +14,7 @@ function failureText({ statements, size = {}, flows = [] }) {
|
|
|
14
14
|
for (const name of ['small', 'large']) if (size[name]?.error) parts.push(`the ${name} size did not build: ${size[name].error}`);
|
|
15
15
|
const failing = flows.filter(flow => !flow.ok);
|
|
16
16
|
if (failing.length) parts.push(`${failing.length} of ${flows.length} declared flows fail: ${join(failing.map(flow => `${flow.name} (${[...new Set(flow.failures.map(failure => failure.rule))].join(', ')})`))}`);
|
|
17
|
-
return `Size check failed: ${parts.join('; ')}. Run rer size for the full report.`;
|
|
17
|
+
return `Size check failed: ${parts.join('; ')}. Run ~/.local/bin/rer size for the full report.`;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
package/cli/transfers.mjs
CHANGED
|
@@ -24,7 +24,7 @@ export async function transfer(project, options, signal, custody) {
|
|
|
24
24
|
if (error.code === 'safety_refusal' && error.message === 'Path must be a contained checkout path without traversal.') {
|
|
25
25
|
const quote = value => "'" + value.replaceAll("'", "'\\''") + "'";
|
|
26
26
|
const staged = value => `.rer/recovery/${basename(value.replaceAll('\\', '/'))}`;
|
|
27
|
-
const args = ['rer import', '--input', quote(flag === '--input' ? staged(options.input) : options.input), ...(options.journal ? ['--journal', quote(staged(options.journal))] : []), '--yes', '--cwd', quote(project.root)];
|
|
27
|
+
const args = ['~/.local/bin/rer import', '--input', quote(flag === '--input' ? staged(options.input) : options.input), ...(options.journal ? ['--journal', quote(staged(options.journal))] : []), '--yes', '--cwd', quote(project.root)];
|
|
28
28
|
error.humanMessage = `${flag} ${JSON.stringify(options[flag.slice(2)])} must stay inside this checkout, without .. or an absolute path, for example .rer/recovery/<name>.rer. Stage the archives there as owned private files (0600), then run: ${args.join(' ')}`;
|
|
29
29
|
}
|
|
30
30
|
throw error;
|
|
@@ -47,8 +47,8 @@ export async function transfer(project, options, signal, custody) {
|
|
|
47
47
|
// The archive's size, for the line a finished export ends with.
|
|
48
48
|
if(direction==='export')return {...result,target,...(target==='remote'&&options.origin?{origin:new URL(options.origin).origin}:{}),output:result.output??relative(project.root,path),bytes:(await stat(path)).size,captureLog:relative(project.root,custody.store.logPath)};
|
|
49
49
|
if(direction==='import' && target==='local' && (await localDependencyLinks(project.root)).some(link=>link.needs_relink)) {
|
|
50
|
-
custody.store.report('Imported provider links need fresh approval. Run rer setup with RER_LINK_TOKEN_FILE to re-link this installation.');
|
|
51
|
-
return {...result,needsRelink:true,nextCommand:'rer setup'};
|
|
50
|
+
custody.store.report('Imported provider links need fresh approval. Run ~/.local/bin/rer setup with RER_LINK_TOKEN_FILE to re-link this installation.');
|
|
51
|
+
return {...result,needsRelink:true,nextCommand:'~/.local/bin/rer setup'};
|
|
52
52
|
}
|
|
53
|
-
return direction === 'import' ? { ...result, captureLog: relative(project.root, custody.store.logPath), nextCommand: 'rer setup' } : result;
|
|
53
|
+
return direction === 'import' ? { ...result, captureLog: relative(project.root, custody.store.logPath), nextCommand: '~/.local/bin/rer setup' } : result;
|
|
54
54
|
}
|