@runeditrun/rer 0.2.78 → 0.2.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -3
- package/cli/README.md +25 -13
- package/cli/authoring.mjs +14 -0
- package/cli/contract.mjs +25 -5
- package/cli/demo-host.mjs +4 -2
- package/cli/dev-identity.mjs +2 -2
- package/cli/export.mjs +1 -1
- package/cli/inspect.mjs +38 -2
- package/cli/main.mjs +8 -2
- package/cli/managed-server.mjs +1 -1
- package/cli/parse.mjs +7 -6
- package/cli/portability-worker.mjs +2 -1
- package/cli/portability.mjs +6 -2
- package/cli/production-auth.mjs +2 -1
- package/cli/production-mail.mjs +36 -9
- package/cli/project.mjs +5 -14
- package/cli/release.mjs +2 -1
- package/cli/server-proxy.mjs +30 -8
- package/cli/site-preview.mjs +4 -1
- package/cli/site.mjs +3 -2
- package/cli/upstream-agent.mjs +14 -0
- package/edition-authoring/adopt.mjs +39 -0
- package/edition-authoring/base-acknowledgements.mjs +24 -0
- package/edition-authoring/base-copies.mjs +418 -0
- package/edition-authoring/cli.mjs +85 -0
- package/edition-authoring/copy-checkout.mjs +69 -0
- package/edition-authoring/files.mjs +15 -2
- package/edition-authoring/lock.mjs +48 -0
- package/edition-authoring/offline-git.mjs +28 -0
- package/edition-authoring/parent-comparison.mjs +77 -0
- package/edition-authoring/projection-lock.mjs +38 -0
- package/edition-authoring/release.mjs +48 -0
- package/edition-authoring/sources.mjs +114 -0
- package/edition-authoring/updates.mjs +105 -0
- package/global/CHANGELOG.md +17 -0
- package/global/README.md +17 -3
- package/global/cli/install.mjs +3 -1
- package/global/main.mjs +9 -12
- package/modules/container/build.mjs +1 -1
- package/modules/d1-transport/index.mjs +68 -21
- package/modules/demo/README.md +8 -2
- package/modules/demo/declaration.mjs +21 -0
- package/modules/demo/input-path.mjs +18 -0
- package/modules/demo/label.d.mts +1 -1
- package/modules/demo/label.mjs +10 -5
- package/modules/demo/navigation.mjs +32 -0
- package/modules/demo/run-url.mjs +9 -0
- package/modules/demo/vite.d.mts +7 -2
- package/modules/demo/vite.mjs +17 -2
- package/modules/demo-host/README.md +5 -3
- package/modules/demo-host/native/visitor.mjs +1 -1
- package/modules/demo-host/page-style.mjs +2 -2
- package/modules/demo-host/pages.mjs +3 -3
- package/modules/demo-host/plan.mjs +6 -4
- package/modules/demo-host/theme.mjs +5 -2
- package/modules/deploy-kit/README.md +19 -15
- package/modules/deploy-kit/owner-cli.mjs +1 -1
- package/modules/deploy-kit/readiness-window.mjs +3 -3
- package/modules/erasure/README.md +10 -5
- package/modules/import-kit/src/d1/README.md +15 -9
- package/modules/import-kit/src/d1/apply.ts +10 -6
- package/modules/import-kit/src/d1/atomic-prefix.ts +64 -0
- package/modules/import-kit/src/d1/budget.ts +48 -26
- package/modules/import-kit/src/d1/compressed-plan.ts +9 -2
- package/modules/import-kit/src/d1/database.ts +2 -1
- package/modules/import-kit/src/d1/jobs.ts +2 -1
- package/modules/import-kit/src/d1/plans.ts +4 -2
- package/modules/import-kit/src/d1/verified-plan.ts +63 -0
- package/modules/integrations/core/README.md +2 -2
- package/modules/mail/README.md +4 -3
- package/modules/mail/pnpm-lock.yaml +16 -0
- package/modules/operator-auth/accounts/native.mjs +3 -1
- package/modules/operator-auth/accounts/provider-control.mjs +7 -4
- package/modules/operator-auth/accounts/provider-setup.mjs +34 -0
- package/modules/operator-auth/accounts/settings-page.mjs +13 -4
- package/modules/operator-auth/conformance/README.md +1 -1
- package/modules/operator-auth/dev/index.mjs +22 -4
- package/modules/operator-auth/dev/refusal.mjs +19 -0
- package/modules/operator-auth/docs/README.md +6 -5
- package/modules/operator-auth/docs/tanstack-start.md +1 -1
- package/modules/operator-auth/docs/vite-spa.md +5 -6
- package/modules/operator-auth/index.d.mts +1 -1
- package/modules/operator-auth/page.mjs +14 -0
- package/modules/operator-auth/representation.mjs +83 -0
- package/modules/operator-auth/routes.mjs +25 -2
- package/modules/portability/README.md +91 -14
- package/modules/portability/bookkeeping.mjs +3 -3
- package/modules/portability/bridge.mjs +5 -4
- package/modules/portability/catalogue.mjs +12 -8
- package/modules/portability/cli.mjs +5 -1
- package/modules/portability/export.mjs +5 -11
- package/modules/portability/format.mjs +7 -1
- package/modules/portability/http-errors.mjs +51 -0
- package/modules/portability/http.mjs +4 -1
- package/modules/portability/import-lease.mjs +13 -2
- package/modules/portability/import.mjs +10 -0
- package/modules/portability/index.d.mts +3 -0
- package/modules/portability/references.mjs +20 -0
- package/modules/portability/schema-identity.mjs +13 -0
- package/modules/portability/schema-legacy.mjs +21 -0
- package/modules/portability/sqlite-tokens.mjs +121 -0
- package/modules/release/README.md +20 -9
- package/modules/release/github-verify.mjs +30 -9
- package/modules/site/docs-search/search.css +1 -1
- package/onboarding/README.md +16 -4
- package/onboarding/adapter.mjs +5 -1
- package/onboarding/schema/SETUP.schema.json +26 -1
- package/onboarding/schema/business-field-inputs.mjs +37 -0
- package/onboarding/schema/json-schema.mjs +6 -2
- package/onboarding/schema/setup-validation.mjs +20 -3
- package/onboarding/server.mjs +1 -1
- package/onboarding/setup-manifest.mjs +2 -0
- package/onboarding/start-origin-diagnostic.mjs +24 -0
- package/onboarding/ui/style.css +9 -9
- package/package.json +1 -1
- package/scripts/publish-check/README.md +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {fileURLToPath} from 'node:url';
|
|
4
|
+
import {manifest, VERSION} from './manifest.mjs';
|
|
5
|
+
import {snapshot, merge} from './sources.mjs';
|
|
6
|
+
import {hash, json, tracked} from './files.mjs';
|
|
7
|
+
|
|
8
|
+
function toolsIdentity() {
|
|
9
|
+
const dir = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const names = fs.readdirSync(dir).filter(p => p.endsWith('.mjs') && !p.endsWith('.test.mjs')).sort();
|
|
11
|
+
const bytes = names.map(p => p + '\0' + fs.readFileSync(path.join(dir, p), 'utf8')).join('\0');
|
|
12
|
+
return {id: 'runeditrun/edition-authoring', version: VERSION, sha256: hash(bytes)};
|
|
13
|
+
}
|
|
14
|
+
function includes(files, selected) {
|
|
15
|
+
return Object.keys(files).some(p => p === selected || p.startsWith(selected + '/'));
|
|
16
|
+
}
|
|
17
|
+
export function resolveSources(root, retain = false, diagnostics = false, additionalFiles = {}) {
|
|
18
|
+
const recipe = manifest(root);
|
|
19
|
+
const files = Object.assign(tracked(root, diagnostics), additionalFiles);
|
|
20
|
+
// The recipe is input even before initial adoption has staged it.
|
|
21
|
+
files['edition.json'] ??= {data: fs.readFileSync(path.join(root, 'edition.json')).toString('base64'), executable: false};
|
|
22
|
+
const components = [];
|
|
23
|
+
for (const component of recipe.components) {
|
|
24
|
+
const selected = component.source;
|
|
25
|
+
if (selected.workspace) throw Error('Retain workspace edits by promotion or commit and exact revision selection before locking/release');
|
|
26
|
+
const reference = selected.kind === 'git' ? selected : selected.origin;
|
|
27
|
+
const baseline = reference ? snapshot(root, reference, retain) : null;
|
|
28
|
+
if (selected.kind === 'git') merge(files, selected.destination, baseline.files);
|
|
29
|
+
else for (const name of selected.paths) {
|
|
30
|
+
if (!diagnostics && !includes(files, name)) throw Error(`Local source missing or untracked: ${name}`);
|
|
31
|
+
}
|
|
32
|
+
for (const mapping of selected.mappings || []) {
|
|
33
|
+
if ((!diagnostics && !includes(files, mapping.path)) || !baseline || !includes(baseline.files, mapping.originPath)) {
|
|
34
|
+
throw Error('Mapping names missing local or retained origin source');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
components.push({id: component.id, source: selected, baseline: baseline ? {key: baseline.key, digest: baseline.digest, sha256: hash(json(baseline))} : null});
|
|
38
|
+
}
|
|
39
|
+
const parent = recipe.parent ? snapshot(root, {...recipe.parent, excludeSnapshots: true}, retain) : null;
|
|
40
|
+
const identities = Object.entries(files).sort(([a], [b]) => a.localeCompare(b)).map(([name, value]) => [name, {
|
|
41
|
+
sha256: hash(Buffer.from(value.data, 'base64')), executable: value.executable,
|
|
42
|
+
}]);
|
|
43
|
+
return {
|
|
44
|
+
schemaVersion: 1, parent: parent ? {key: parent.key, digest: parent.digest, sha256: hash(json(parent))} : null,
|
|
45
|
+
edition: recipe.id, manifest: hash(json(recipe)), toolchain: toolsIdentity(),
|
|
46
|
+
components, files: Object.fromEntries(identities),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {execFileSync} from 'node:child_process';
|
|
5
|
+
|
|
6
|
+
// Older Git ignores GIT_NO_LAZY_FETCH. Read the real object store through a
|
|
7
|
+
// repository with no remotes instead: even missing promisor objects cannot
|
|
8
|
+
// launch a fetch. Never load the source's config into this repository.
|
|
9
|
+
export function offlineRepository(root) {
|
|
10
|
+
const env = Object.fromEntries(Object.entries(process.env).filter(([name]) =>
|
|
11
|
+
!/^GIT_(?:CONFIG|DIR$|COMMON_DIR$|WORK_TREE$|INDEX_FILE$|OBJECT_DIRECTORY$|ALTERNATE_OBJECT_DIRECTORIES$|SHALLOW_FILE$|NAMESPACE$|QUARANTINE_PATH$|REPLACE_REF_BASE$)/.test(name)));
|
|
12
|
+
Object.assign(env, {GIT_CONFIG_NOSYSTEM: '1', GIT_CONFIG_GLOBAL: os.devNull, GIT_NO_REPLACE_OBJECTS: '1', GIT_NO_LAZY_FETCH: '1', GIT_OPTIONAL_LOCKS: '0'});
|
|
13
|
+
const metadata = (...args) => execFileSync('git', ['-C', root, 'rev-parse', ...args], {env, encoding: 'utf8', stdio: 'pipe'}).trim();
|
|
14
|
+
let temporary;
|
|
15
|
+
try {
|
|
16
|
+
// These queries read repository metadata and refs, never object contents.
|
|
17
|
+
const objects = metadata('--path-format=absolute', '--git-path', 'objects');
|
|
18
|
+
const format = metadata('--show-object-format');
|
|
19
|
+
const head = metadata('--verify', 'HEAD');
|
|
20
|
+
temporary = fs.mkdtempSync(path.join(os.tmpdir(), 'base-offline-'));
|
|
21
|
+
execFileSync('git', ['init', '--bare', '--quiet', '--template=', `--object-format=${format}`, temporary], {env, stdio: 'pipe'});
|
|
22
|
+
fs.writeFileSync(path.join(temporary, 'HEAD'), head + '\n');
|
|
23
|
+
return {root: temporary, env: {...env, GIT_OBJECT_DIRECTORY: objects}, close: () => fs.rmSync(temporary, {recursive: true, force: true})};
|
|
24
|
+
} catch {
|
|
25
|
+
if (temporary) fs.rmSync(temporary, {recursive: true, force: true});
|
|
26
|
+
throw Error('Cannot prepare the local Base object reader. Ensure Git is installed, the Base checkout and its HEAD are readable, and temporary storage is writable, then retry offline. No copy record was changed.');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {hash, json, git, safe, noLinks} from './files.mjs';
|
|
4
|
+
|
|
5
|
+
// A retained parent baseline may be a reviewed public projection of a private
|
|
6
|
+
// original. Its plan and receipt sit at this conventional location and are bound
|
|
7
|
+
// by the edition's source lock.
|
|
8
|
+
export const PROJECTION_PLAN = 'scripts/public-projections/plan.json';
|
|
9
|
+
export const PROJECTION_RECEIPT = 'scripts/public-projections/receipt.json';
|
|
10
|
+
|
|
11
|
+
// Match the whole-parent snapshot's archive-only exclusion. In particular, keep
|
|
12
|
+
// source locks and other .edition files visible, and observe tracked deletions.
|
|
13
|
+
export function parentFiles(root) {
|
|
14
|
+
if (fs.realpathSync(git(root, 'rev-parse', '--show-toplevel')) !== fs.realpathSync(root)) throw Error('Current source must be a Git repository root');
|
|
15
|
+
const files = {};
|
|
16
|
+
for (const name of git(root, 'ls-files', '-z').split('\0').filter(Boolean)) {
|
|
17
|
+
safe(name);
|
|
18
|
+
if (name.startsWith('.edition/sources/')) continue;
|
|
19
|
+
noLinks(root, name);
|
|
20
|
+
let stat;
|
|
21
|
+
try { stat = fs.lstatSync(path.join(root, name)); }
|
|
22
|
+
catch (error) { if (error.code === 'ENOENT') continue; throw error; }
|
|
23
|
+
if (!stat.isFile()) throw Error('Unsupported current parent source');
|
|
24
|
+
files[name] = {data: fs.readFileSync(path.join(root, name)).toString('base64'), executable: !!(stat.mode & 0o111)};
|
|
25
|
+
}
|
|
26
|
+
return files;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Members whose exact original bytes the projection plan replaces or omits.
|
|
30
|
+
function projectedMembers(root, saved) {
|
|
31
|
+
if (!fs.existsSync(path.join(root, PROJECTION_RECEIPT))) {
|
|
32
|
+
if (saved.origin.projection) throw Error('Missing parent projection receipt');
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
const receiptBytes = fs.readFileSync(path.join(root, PROJECTION_RECEIPT));
|
|
36
|
+
const receipt = JSON.parse(receiptBytes);
|
|
37
|
+
const selected = receipt.archives.find(item => item.selector === 'parent' &&
|
|
38
|
+
(item.key === saved.key || item.originalKey === saved.key));
|
|
39
|
+
if (!selected) {
|
|
40
|
+
if (saved.origin.projection) throw Error('Unaccounted parent projection');
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
const planBytes = fs.readFileSync(path.join(root, PROJECTION_PLAN));
|
|
44
|
+
const lock = JSON.parse(fs.readFileSync(path.join(root, 'sources.lock.json')));
|
|
45
|
+
if (lock.files[PROJECTION_RECEIPT]?.sha256 !== hash(receiptBytes) || lock.files[PROJECTION_PLAN]?.sha256 !== hash(planBytes) || receipt.recipeSha256 !== hash(planBytes)) throw Error('Parent comparison policy differs from source lock');
|
|
46
|
+
const planned = JSON.parse(planBytes).archives.find(item => item.originalKey === selected.originalKey);
|
|
47
|
+
const isOriginal = selected.originalKey === saved.key;
|
|
48
|
+
if (!planned || planned.originalSha256 !== selected.originalSha256 || hash(json(saved)) !== (isOriginal ? selected.originalSha256 : selected.sha256)) throw Error('Parent comparison identity mismatch');
|
|
49
|
+
if (!isOriginal && (saved.origin.projection.originalSha256 !== selected.originalSha256 || saved.origin.projection.recipeSha256 !== receipt.recipeSha256)) throw Error('Parent comparison derivation mismatch');
|
|
50
|
+
const result = [];
|
|
51
|
+
for (const [name, rule] of Object.entries(planned.members)) {
|
|
52
|
+
const member = selected.members.find(item => item.path === name);
|
|
53
|
+
if (!member || rule.originalSha256 !== member.originalSha256 || (member.projectedSha256 === null) !== !!rule.omit) throw Error('Parent member policy mismatch');
|
|
54
|
+
// Every omission is planned member by member, with the reason it is safe.
|
|
55
|
+
if (rule.omit && (typeof rule.reason !== 'string' || !rule.reason.trim())) throw Error('Only planned omissions with a recorded reason may be omitted');
|
|
56
|
+
const value = saved.files[name], expected = isOriginal ? member.originalSha256 : member.projectedSha256;
|
|
57
|
+
if (expected === null ? value !== undefined : !value || hash(Buffer.from(value.data, 'base64')) !== expected || value.executable !== member.executable) throw Error('Parent member identity mismatch');
|
|
58
|
+
result.push(member);
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Normalize only exact planned original bytes to their projected identity; every
|
|
64
|
+
// other byte, mode, addition and removal stays visible.
|
|
65
|
+
export function parentIdentities(root, saved) {
|
|
66
|
+
const members = new Map(projectedMembers(root, saved).map(member => [member.path, member]));
|
|
67
|
+
return files => Object.fromEntries(Object.entries(files).flatMap(([name, file]) => {
|
|
68
|
+
const identity = {sha256: hash(Buffer.from(file.data, 'base64')), executable: file.executable};
|
|
69
|
+
const member = members.get(name);
|
|
70
|
+
if (member && identity.sha256 === member.originalSha256) {
|
|
71
|
+
if (member.projectedSha256 === null) {
|
|
72
|
+
if (identity.executable === member.executable) return [];
|
|
73
|
+
} else identity.sha256 = member.projectedSha256;
|
|
74
|
+
}
|
|
75
|
+
return [[name, identity]];
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {manifest} from './manifest.mjs';
|
|
4
|
+
import {hash, json, noLinks} from './files.mjs';
|
|
5
|
+
|
|
6
|
+
export function snapshotOrigin(ref) {
|
|
7
|
+
return {repository: ref.repository, ...(ref.projection ? {projection: ref.projection} : {revision: ref.revision}), path: ref.path || '.', paths: ref.paths || null, excludeSnapshots: !!ref.excludeSnapshots};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function verifyProjectionLock(root, origin, saved, bytes) {
|
|
11
|
+
noLinks(root, 'edition.json');
|
|
12
|
+
noLinks(root, 'sources.lock.json');
|
|
13
|
+
if (!fs.existsSync(path.join(root, 'sources.lock.json'))) throw Error('Public projection requires a selected source-lock binding');
|
|
14
|
+
for (const name of ['edition.json', 'sources.lock.json']) {
|
|
15
|
+
if (!fs.lstatSync(path.join(root, name)).isFile()) throw Error('Public projection selection and lock must be regular files');
|
|
16
|
+
}
|
|
17
|
+
const recipe = manifest(root);
|
|
18
|
+
const lock = JSON.parse(fs.readFileSync(path.join(root, 'sources.lock.json')));
|
|
19
|
+
if (lock.schemaVersion !== 1 || lock.edition !== recipe.id) throw Error('Public projection source lock identifies a different edition');
|
|
20
|
+
const pins = [];
|
|
21
|
+
const matches = ref => ref?.projection && json(snapshotOrigin(ref)) === json(origin);
|
|
22
|
+
if (recipe.parent && matches({...recipe.parent, excludeSnapshots: true})) pins.push(lock.parent);
|
|
23
|
+
for (const component of recipe.components) {
|
|
24
|
+
const ref = component.source.kind === 'git' ? component.source : component.source.origin;
|
|
25
|
+
if (!matches(ref)) continue;
|
|
26
|
+
const locked = lock.components?.find(entry => entry.id === component.id);
|
|
27
|
+
const lockedRef = locked?.source?.kind === 'git' ? locked.source : locked?.source?.origin;
|
|
28
|
+
if (!matches(lockedRef)) throw Error('Public projection selection differs from source lock');
|
|
29
|
+
pins.push(locked.baseline);
|
|
30
|
+
}
|
|
31
|
+
if (!pins.length) throw Error('Public projection is not selected by this edition');
|
|
32
|
+
const rawSha256 = hash(bytes);
|
|
33
|
+
for (const expected of pins) {
|
|
34
|
+
if (!expected || expected.key !== saved.key || expected.digest !== saved.digest || expected.sha256 !== rawSha256) {
|
|
35
|
+
throw Error('Public projection artifact differs from source lock');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {execFileSync} from 'node:child_process';
|
|
4
|
+
import {fresh, git, hash, json} from './files.mjs';
|
|
5
|
+
|
|
6
|
+
export function release(root, destination, check) {
|
|
7
|
+
const output = fresh(destination, root);
|
|
8
|
+
const receiptPath = fresh(output + '.release.json', root);
|
|
9
|
+
if (git(root, 'status', '--porcelain', '--untracked-files=all')) throw Error('Release requires a clean committed edition');
|
|
10
|
+
const lock = check();
|
|
11
|
+
const comparisons = [...lock.components, ...(lock.parent ? [{baseline: lock.parent}] : [])];
|
|
12
|
+
const pending = comparisons.filter(c => c.baseline).map(c => c.baseline);
|
|
13
|
+
const checked = new Set();
|
|
14
|
+
while (pending.length) {
|
|
15
|
+
const baseline = pending.pop();
|
|
16
|
+
if (checked.has(baseline.key)) continue;
|
|
17
|
+
checked.add(baseline.key);
|
|
18
|
+
const filename = '.edition/sources/' + baseline.key + '.json';
|
|
19
|
+
if (!git(root, 'ls-files', '--', filename)) throw Error('Comparison source snapshot must be tracked');
|
|
20
|
+
const archive = JSON.parse(fs.readFileSync(path.join(root, filename)));
|
|
21
|
+
pending.push(...(archive.dependencies || []));
|
|
22
|
+
}
|
|
23
|
+
const commit = git(root, 'rev-parse', 'HEAD');
|
|
24
|
+
const tree = git(root, 'rev-parse', 'HEAD^{tree}');
|
|
25
|
+
execFileSync('git', ['clone', '--no-hardlinks', '--', root, output], {stdio: 'pipe'});
|
|
26
|
+
git(output, 'remote', 'remove', 'origin');
|
|
27
|
+
const receipt = {
|
|
28
|
+
schemaVersion: 1, edition: lock.edition, source: {commit, tree},
|
|
29
|
+
lockSha256: hash(fs.readFileSync(path.join(root, 'sources.lock.json'))), toolchain: lock.toolchain,
|
|
30
|
+
verification: 'source integrity only; no product build or deployment asserted',
|
|
31
|
+
};
|
|
32
|
+
// Outside the author tree: publication preserves the exact authoritative commit.
|
|
33
|
+
fs.writeFileSync(receiptPath, json(receipt), {flag: 'wx'});
|
|
34
|
+
return {output, receiptPath, ...receipt};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function verifyReceipt(root, filename, check) {
|
|
38
|
+
const receipt = JSON.parse(fs.readFileSync(filename, 'utf8'));
|
|
39
|
+
const lock = check();
|
|
40
|
+
if (receipt.schemaVersion !== 1 || receipt.edition !== lock.edition ||
|
|
41
|
+
receipt.source?.commit !== git(root, 'rev-parse', 'HEAD') ||
|
|
42
|
+
receipt.source?.tree !== git(root, 'rev-parse', 'HEAD^{tree}') ||
|
|
43
|
+
receipt.lockSha256 !== hash(fs.readFileSync(path.join(root, 'sources.lock.json'))) ||
|
|
44
|
+
json(receipt.toolchain) !== json(lock.toolchain) || git(root, 'status', '--porcelain', '--untracked-files=all')) {
|
|
45
|
+
throw Error('Receipt does not identify this clean source checkout');
|
|
46
|
+
}
|
|
47
|
+
return {ok: true, ...receipt, verification: 'source integrity only; receipt is not publisher authentication or product acceptance'};
|
|
48
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {execFileSync} from 'node:child_process';
|
|
5
|
+
import {hash, json, git, raw, safe, digest, noLinks} from './files.mjs';
|
|
6
|
+
import {snapshotOrigin, verifyProjectionLock} from './projection-lock.mjs';
|
|
7
|
+
|
|
8
|
+
const environment = {...process.env, GIT_NO_REPLACE_OBJECTS: '1'};
|
|
9
|
+
function selected(name, ref) {
|
|
10
|
+
const prefix = ref.path && ref.path !== '.' ? ref.path : '';
|
|
11
|
+
if (prefix && name !== prefix && !name.startsWith(prefix + '/')) return false;
|
|
12
|
+
const relative = prefix ? (name === prefix ? path.basename(name) : name.slice(prefix.length + 1)) : name;
|
|
13
|
+
if (ref.excludeSnapshots && relative.startsWith('.edition/sources/')) return false;
|
|
14
|
+
if (ref.paths && !ref.paths.some(p => relative === p || relative.startsWith(p + '/'))) return false;
|
|
15
|
+
return relative;
|
|
16
|
+
}
|
|
17
|
+
function committed(root, ref, archives) {
|
|
18
|
+
const files = Object.create(null);
|
|
19
|
+
const entries = raw(root, 'ls-tree', '-rz', '--full-tree', ref.revision).toString('utf8').split('\0').filter(Boolean);
|
|
20
|
+
for (const entry of entries) {
|
|
21
|
+
const tab = entry.indexOf('\t');
|
|
22
|
+
const [mode, type, object] = entry.slice(0, tab).split(' ');
|
|
23
|
+
const name = entry.slice(tab + 1);
|
|
24
|
+
if (ref.excludeSnapshots && name.startsWith('.edition/sources/') && /^\.edition\/sources\/[a-f0-9]{64}\.json$/.test(name)) {
|
|
25
|
+
if (type !== 'blob' || mode !== '100644') throw Error('Unsupported comparison archive');
|
|
26
|
+
const archived = JSON.parse(raw(root, 'cat-file', 'blob', object));
|
|
27
|
+
if (archived.key !== path.basename(name, '.json') || archived.key !== hash(json(archived.origin)) || archived.digest !== digest(archived.files)) throw Error('Corrupt ancestor comparison archive');
|
|
28
|
+
archives[archived.key] = archived;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const relative = selected(name, ref);
|
|
32
|
+
if (relative === false) continue;
|
|
33
|
+
safe(relative);
|
|
34
|
+
if (type !== 'blob' || !['100644', '100755'].includes(mode)) throw Error(`Unsupported committed source: ${name}`);
|
|
35
|
+
files[relative] = {data: raw(root, 'cat-file', 'blob', object).toString('base64'), executable: mode === '100755'};
|
|
36
|
+
}
|
|
37
|
+
return files;
|
|
38
|
+
}
|
|
39
|
+
export function snapshot(root, ref, retain = false) {
|
|
40
|
+
if (ref.projection && ref.workspace) throw Error('Public projections cannot select workspace source');
|
|
41
|
+
const origin = snapshotOrigin(ref);
|
|
42
|
+
const key = hash(json(origin));
|
|
43
|
+
noLinks(root, '.edition/sources/' + key + '.json');
|
|
44
|
+
const filename = path.join(root, '.edition/sources', key + '.json');
|
|
45
|
+
if (fs.existsSync(filename)) {
|
|
46
|
+
if (!fs.lstatSync(filename).isFile()) throw Error('Retained source snapshot must be a regular file');
|
|
47
|
+
const bytes = fs.readFileSync(filename);
|
|
48
|
+
const saved = JSON.parse(bytes);
|
|
49
|
+
if (saved.key !== key || json(saved.origin) !== json(origin) || saved.digest !== digest(saved.files)) throw Error('Corrupt retained source snapshot');
|
|
50
|
+
if (ref.projection) verifyProjectionLock(root, origin, saved, bytes);
|
|
51
|
+
for (const dependency of saved.dependencies || []) {
|
|
52
|
+
noLinks(root, '.edition/sources/' + dependency.key + '.json');
|
|
53
|
+
const ancestor = JSON.parse(fs.readFileSync(path.join(root, '.edition/sources', dependency.key + '.json')));
|
|
54
|
+
if (ancestor.digest !== dependency.digest || digest(ancestor.files) !== dependency.digest || hash(json(ancestor)) !== dependency.sha256) {
|
|
55
|
+
throw Error('Missing or corrupt ancestor comparison archive');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return saved;
|
|
59
|
+
}
|
|
60
|
+
// A projection has no fetchable revision; it exists only as a reviewed retained archive.
|
|
61
|
+
if (ref.projection) throw Error('Missing retained public projection; regenerate from the pinned private original outside the public tree');
|
|
62
|
+
const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'edition-source-'));
|
|
63
|
+
try {
|
|
64
|
+
execFileSync('git', ['clone', '--no-checkout', '--', ref.repository, temp], {env: environment, stdio: 'pipe'});
|
|
65
|
+
if (git(temp, 'rev-parse', `${ref.revision}^{commit}`) !== ref.revision) throw Error('Source revision is not exact commit');
|
|
66
|
+
const archives = Object.create(null);
|
|
67
|
+
const files = committed(temp, ref, archives);
|
|
68
|
+
if (!Object.keys(files).length) throw Error('Empty source export');
|
|
69
|
+
const dependencies = Object.values(archives).map(a => ({key: a.key, digest: a.digest, sha256: hash(json(a))}));
|
|
70
|
+
const saved = {key, origin, digest: digest(files), files, dependencies};
|
|
71
|
+
if (retain) {
|
|
72
|
+
fs.mkdirSync(path.dirname(filename), {recursive: true});
|
|
73
|
+
for (const archive of Object.values(archives)) {
|
|
74
|
+
noLinks(root, '.edition/sources/' + archive.key + '.json');
|
|
75
|
+
fs.writeFileSync(path.join(root, '.edition/sources', archive.key + '.json'), json(archive));
|
|
76
|
+
}
|
|
77
|
+
fs.writeFileSync(filename, json(saved));
|
|
78
|
+
}
|
|
79
|
+
return saved;
|
|
80
|
+
} finally {
|
|
81
|
+
fs.rmSync(temp, {recursive: true, force: true});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export function source(root, ref, dev = false, retain = false) {
|
|
85
|
+
if (ref.projection && ref.workspace) throw Error('Public projections cannot select workspace source');
|
|
86
|
+
if (!dev || !ref.workspace) return snapshot(root, ref, retain).files;
|
|
87
|
+
if (fs.realpathSync(git(ref.workspace, 'rev-parse', '--show-toplevel')) !== fs.realpathSync(ref.workspace)) throw Error('Workspace must name the repository root');
|
|
88
|
+
const files = Object.create(null);
|
|
89
|
+
const index = raw(ref.workspace, 'ls-files', '--stage', '-z').toString('utf8').split('\0').filter(Boolean);
|
|
90
|
+
for (const entry of index) {
|
|
91
|
+
const [header, name] = entry.split('\t');
|
|
92
|
+
if (selected(name, ref) !== false && header.startsWith('160000 ')) throw Error('Submodules are not source files');
|
|
93
|
+
}
|
|
94
|
+
const names = raw(ref.workspace, 'ls-files', '--cached', '--others', '--exclude-standard', '-z').toString('utf8').split('\0').filter(Boolean);
|
|
95
|
+
for (const name of [...new Set(names)].sort()) {
|
|
96
|
+
const relative = selected(name, ref);
|
|
97
|
+
if (relative === false) continue;
|
|
98
|
+
safe(name); safe(relative); noLinks(ref.workspace, name);
|
|
99
|
+
const absolute = path.join(ref.workspace, name);
|
|
100
|
+
if (!fs.existsSync(absolute)) continue; // A tracked deletion is a real workspace edit.
|
|
101
|
+
const stat = fs.lstatSync(absolute);
|
|
102
|
+
if (!stat.isFile()) throw Error(`Unsupported workspace source: ${name}`);
|
|
103
|
+
files[relative] = {data: fs.readFileSync(absolute).toString('base64'), executable: !!(stat.mode & 0o111)};
|
|
104
|
+
}
|
|
105
|
+
if (!Object.keys(files).length) throw Error('Empty workspace source export');
|
|
106
|
+
return files;
|
|
107
|
+
}
|
|
108
|
+
export function merge(files, destination, ingredient) {
|
|
109
|
+
for (const [name, value] of Object.entries(ingredient)) {
|
|
110
|
+
const target = destination + '/' + safe(name);
|
|
111
|
+
if (Object.keys(files).some(p => p === target || p.startsWith(target + '/') || target.startsWith(p + '/'))) throw Error(`Source collision: ${target}`);
|
|
112
|
+
files[target] = value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {manifest} from './manifest.mjs';
|
|
4
|
+
import {snapshot} from './sources.mjs';
|
|
5
|
+
import {parentFiles, parentIdentities} from './parent-comparison.mjs';
|
|
6
|
+
import {hash, json, git, tracked, fresh, writeTree} from './files.mjs';
|
|
7
|
+
|
|
8
|
+
function diff(before, after) {
|
|
9
|
+
return [...new Set([...Object.keys(before), ...Object.keys(after)])].sort()
|
|
10
|
+
.filter(name => json(before[name]) !== json(after[name]))
|
|
11
|
+
.map(name => ({path: name, change: !(name in before) ? 'added' : !(name in after) ? 'removed' : 'modified', before: before[name] ?? null, after: after[name] ?? null}));
|
|
12
|
+
}
|
|
13
|
+
export function changes(before, after) {
|
|
14
|
+
return {
|
|
15
|
+
files: diff(before.files, after.files),
|
|
16
|
+
metadata: diff(Object.fromEntries(Object.entries(before).filter(([k]) => k !== 'files')),
|
|
17
|
+
Object.fromEntries(Object.entries(after).filter(([k]) => k !== 'files'))),
|
|
18
|
+
meaning: 'Origins are comparison baselines; changing an origin does not assert adoption or local byte equality.',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function baseline(root, id) {
|
|
22
|
+
const recipe = manifest(root);
|
|
23
|
+
const component = recipe.components.find(c => c.id === id);
|
|
24
|
+
const ref = id === 'parent' ? recipe.parent && {...recipe.parent, excludeSnapshots: true}
|
|
25
|
+
: component?.source.kind === 'git' ? component.source : component?.source.origin;
|
|
26
|
+
if (!ref) throw Error('Selected component has no comparison baseline');
|
|
27
|
+
const saved = snapshot(root, ref);
|
|
28
|
+
const lock = JSON.parse(fs.readFileSync(path.join(root, 'sources.lock.json')));
|
|
29
|
+
const expected = id === 'parent' ? lock.parent : lock.components.find(c => c.id === id)?.baseline;
|
|
30
|
+
if (!expected || saved.key !== expected.key || saved.digest !== expected.digest || hash(json(saved)) !== expected.sha256) {
|
|
31
|
+
throw Error('Baseline differs from lock; inspect selection before extracting or comparing');
|
|
32
|
+
}
|
|
33
|
+
return {component, ref, saved};
|
|
34
|
+
}
|
|
35
|
+
export function extract(root, id, destination) {
|
|
36
|
+
const output = fresh(destination, root);
|
|
37
|
+
const {saved} = baseline(root, id);
|
|
38
|
+
writeTree(output, saved.files);
|
|
39
|
+
return {output, origin: saved.origin, digest: saved.digest, files: Object.keys(saved.files).length};
|
|
40
|
+
}
|
|
41
|
+
function identities(files) {
|
|
42
|
+
return Object.fromEntries(Object.entries(files).map(([name, file]) => [name,
|
|
43
|
+
{sha256: hash(Buffer.from(file.data, 'base64')), executable: file.executable}]));
|
|
44
|
+
}
|
|
45
|
+
// The most specific mapping owns a local file; one origin file may have several
|
|
46
|
+
// local copies, and each copy is compared with that origin file on its own.
|
|
47
|
+
function owner(mappings, name) {
|
|
48
|
+
let found = null;
|
|
49
|
+
for (const mapping of mappings) {
|
|
50
|
+
if (name !== mapping.path && !name.startsWith(mapping.path + '/')) continue;
|
|
51
|
+
if (found?.path === mapping.path && found.originPath !== mapping.originPath) throw Error(`Ambiguous comparison mappings for ${mapping.path}`);
|
|
52
|
+
if (!found || mapping.path.length > found.path.length) found = mapping;
|
|
53
|
+
}
|
|
54
|
+
return found;
|
|
55
|
+
}
|
|
56
|
+
function mappedChanges(mappings, before, editionFiles) {
|
|
57
|
+
const result = [];
|
|
58
|
+
for (const [name, file] of Object.entries(editionFiles)) {
|
|
59
|
+
const mapping = owner(mappings, name);
|
|
60
|
+
if (!mapping) continue;
|
|
61
|
+
const target = mapping.originPath + name.slice(mapping.path.length);
|
|
62
|
+
const after = identities({[name]: file})[name];
|
|
63
|
+
if (json(before[target]) !== json(after)) result.push({path: target, localPath: name, change: before[target] ? 'modified' : 'added', before: before[target] ?? null, after});
|
|
64
|
+
}
|
|
65
|
+
for (const mapping of mappings) for (const [target, identity] of Object.entries(before)) {
|
|
66
|
+
if (target !== mapping.originPath && !target.startsWith(mapping.originPath + '/')) continue;
|
|
67
|
+
const name = mapping.path + target.slice(mapping.originPath.length);
|
|
68
|
+
if (!(name in editionFiles) && owner(mappings, name) === mapping) result.push({path: target, localPath: name, change: 'removed', before: identity, after: null});
|
|
69
|
+
}
|
|
70
|
+
return result.sort((a, b) => a.path.localeCompare(b.path) || a.localPath.localeCompare(b.localPath));
|
|
71
|
+
}
|
|
72
|
+
export function compare(root, id, candidate, currentRoot = root) {
|
|
73
|
+
const {component, ref, saved} = baseline(root, id);
|
|
74
|
+
const repository = fs.realpathSync(candidate);
|
|
75
|
+
if (fs.realpathSync(git(repository, 'rev-parse', '--show-toplevel')) !== repository) throw Error('Candidate must be a Git repository root');
|
|
76
|
+
if (git(repository, 'status', '--porcelain', '--untracked-files=all')) throw Error('Candidate must be clean and committed');
|
|
77
|
+
// Incoming source is the candidate's own Git source; it never inherits a projection identity.
|
|
78
|
+
const incoming = snapshot(root, {...ref, projection: undefined, repository, revision: git(repository, 'rev-parse', 'HEAD')});
|
|
79
|
+
if (!component) {
|
|
80
|
+
const normalize = parentIdentities(root, saved);
|
|
81
|
+
const before = normalize(saved.files), current = normalize(parentFiles(currentRoot));
|
|
82
|
+
return {component: 'parent', baseline: {origin: saved.origin, digest: saved.digest},
|
|
83
|
+
incoming: {origin: incoming.origin, digest: incoming.digest},
|
|
84
|
+
upstreamChanges: diff(before, normalize(incoming.files)),
|
|
85
|
+
localChanges: diff(before, current), currentFiles: current, mappings: null,
|
|
86
|
+
meaning: 'Whole-parent comparison reads independent incoming Git source and current tracked source. Only exact planned projection identities and planned omissions are normalized; all other bytes, modes, additions and removals remain visible. This does not judge compatibility, owner intent, or adoption.',
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if (currentRoot !== root) throw Error('An independent current checkout is supported only for parent comparison');
|
|
90
|
+
const selected = component.source;
|
|
91
|
+
if (selected.workspace) throw Error('Promote or commit workspace source before comparing immutable selections');
|
|
92
|
+
const editionFiles = tracked(root);
|
|
93
|
+
const mappings = selected.kind === 'git' ? [] : selected.mappings || [];
|
|
94
|
+
const owned = selected.kind === 'local' ? Object.fromEntries(Object.entries(editionFiles)
|
|
95
|
+
.filter(([name]) => selected.paths.some(p => name === p || name.startsWith(p + '/')))) : saved.files;
|
|
96
|
+
const before = identities(saved.files);
|
|
97
|
+
return {component: id, baseline: {origin: saved.origin, digest: saved.digest},
|
|
98
|
+
incoming: {origin: incoming.origin, digest: incoming.digest},
|
|
99
|
+
upstreamChanges: diff(before, identities(incoming.files)),
|
|
100
|
+
// Never guess correspondence for dispersed or deeply rewritten local source.
|
|
101
|
+
localChanges: selected.kind === 'git' ? [] : mappings.length ? mappedChanges(mappings, before, editionFiles) : null,
|
|
102
|
+
currentFiles: identities(owned), mappings,
|
|
103
|
+
meaning: 'Current source may intentionally differ. Local comparison uses explicit mappings only; each local copy is compared with its own origin file. This does not judge compatibility, owner intent, or adoption.',
|
|
104
|
+
};
|
|
105
|
+
}
|
package/global/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.80
|
|
4
|
+
|
|
5
|
+
- Healthy doctor now exits 0 when local settings are present.
|
|
6
|
+
- Restore installation archives using SQL-aware schema identity and an object inventory; ignore SQL comments while preserving behavioral schema checks and staged file validation.
|
|
7
|
+
- Expose edition adoption and `refresh-base` in the packaged CLI, preserve adaptation acknowledgements and offline provenance, and retire absent singleton Base copies.
|
|
8
|
+
- Accept a successful exact-SHA branch push or dispatch Verify for releases, including when a duplicate main run failed; reuse qualified branch verification in seed workflows.
|
|
9
|
+
- Keep harness ingress listeners bound across Worker generations and let test runtimes own ephemeral ports.
|
|
10
|
+
- Link demo exits to the seed's canonical Run chooser, bootstrap pinned demo commands, and improve shared header, link and minimum text sizes.
|
|
11
|
+
- Limit Business profile hints to declared public input names and reject credential-shaped hints and duplicate field claims.
|
|
12
|
+
- Update compatible dependencies while retaining Node 22.20.0 and pnpm 10.12.4; pnpm 10.34.7 is not adopted.
|
|
13
|
+
- Give Chromium apt attempts separate deadlines and clean up timed-out attempts and cache payloads.
|
|
14
|
+
|
|
15
|
+
## 0.2.79
|
|
16
|
+
|
|
17
|
+
- Reuse bounded keep-alive connections in the local dev proxy and retry stale connections for bodyless reads.
|
|
18
|
+
- Give each native demo visitor a separate 64-hex installation key so dependency signing works.
|
|
19
|
+
|
|
3
20
|
## 0.2.78
|
|
4
21
|
|
|
5
22
|
- Add signed seed test delivery to the optional mail relay, with public Worker routing, bounded target checks and invocation logs.
|
package/global/README.md
CHANGED
|
@@ -4,6 +4,17 @@
|
|
|
4
4
|
Run Edit Run checkout: every verb runs that checkout's own pinned copy, so a
|
|
5
5
|
checkout always gets the behaviour it was built and tested with.
|
|
6
6
|
|
|
7
|
+
For source authors, `rer adopt-edition` adds a recipe and lock to existing tracked
|
|
8
|
+
seed source while preserving copy/composition provenance. `rer refresh-base
|
|
9
|
+
--ref FULL_COMMIT` refreshes recorded Base copies with the seed's pinned package;
|
|
10
|
+
no vendored authoring CLI is needed. Base source comes from a temporary clone of
|
|
11
|
+
`https://github.com/runeditrun/base.git` unless the seed declares another source
|
|
12
|
+
or you pass `--base CHECKOUT`. Offline refresh requires `--offline --base CHECKOUT`.
|
|
13
|
+
Both verbs have effect-free `--help` and newline-delimited `--json` events.
|
|
14
|
+
Review source changes and run edition tests before committing. See the
|
|
15
|
+
[edition authoring guide](https://github.com/runeditrun/base/blob/main/export/EDITION-AUTHORING.md)
|
|
16
|
+
for adoption, refusal behavior, JSON fields and the original Base-checkout form.
|
|
17
|
+
|
|
7
18
|
## Install
|
|
8
19
|
|
|
9
20
|
Start a seed from an empty folder, with or without Node:
|
|
@@ -244,8 +255,11 @@ which inside `pnpm run` is the pinned copy in `node_modules/.bin`, so
|
|
|
244
255
|
`pnpm install --frozen-lockfile && pnpm run build` needs no global `rer`. A global
|
|
245
256
|
`rer` hands every verb to the pinned package, launching included. Until
|
|
246
257
|
`node_modules` holds the pinned version (a fresh clone, or a pulled pin change),
|
|
247
|
-
|
|
248
|
-
started at once share that one install.
|
|
258
|
+
commands that run project code install it first (the frozen `pnpm install`),
|
|
259
|
+
then run it; commands started at once share that one install. Help, version,
|
|
260
|
+
read-only `doctor`, and `release sign`, `release receipt` and `release keygen`
|
|
261
|
+
do not install dependencies. The release producer still bootstraps before it
|
|
262
|
+
runs project build or verification scripts.
|
|
249
263
|
Every dependency install, `rer release`'s included, receives an allowlisted
|
|
250
264
|
environment: the shell, locale, terminal and temporary-folder variables, `CI`,
|
|
251
265
|
`TZ`, `SSH_AUTH_SOCK`, `NODE_OPTIONS`, `NODE_EXTRA_CA_CERTS`, `XDG_*`, proxy
|
|
@@ -514,7 +528,7 @@ The current MCP `next_question` filters out owner items. When an owner summary
|
|
|
514
528
|
is supplied, the CLI displays its browser link and refuses to answer it.
|
|
515
529
|
|
|
516
530
|
The four deterministic adapter implementations and their native output formats
|
|
517
|
-
are described in [the adapter guide](cli/business/vendors/README.md). Their
|
|
531
|
+
are described in [the adapter guide](https://github.com/runeditrun/base/blob/main/cli/business/vendors/README.md). Their
|
|
518
532
|
presence does not enable export until the seed import authority and remaining
|
|
519
533
|
transport contracts are connected.
|
|
520
534
|
|
package/global/cli/install.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { ownManifest, ownRoot, packageDigest, packageFileList } from '../package
|
|
|
8
8
|
import { installRecord, launcherOwner, launcherScript, layout } from './layout.mjs';
|
|
9
9
|
import { pathAdvice } from './path-link.mjs';
|
|
10
10
|
import { runningDoor } from '../../cli/door.mjs';
|
|
11
|
+
import { channelOf } from './status.mjs';
|
|
11
12
|
|
|
12
13
|
async function readLink(path) { try { return await readlink(path); } catch (error) { if (['ENOENT', 'EINVAL'].includes(error.code)) return undefined; throw error; } }
|
|
13
14
|
|
|
@@ -49,7 +50,8 @@ async function closing(paths) {
|
|
|
49
50
|
|
|
50
51
|
export async function install({ quiet = false } = {}) {
|
|
51
52
|
const paths = layout(), manifest = ownManifest(), digest = await packageDigest(ownRoot);
|
|
52
|
-
const name = `${manifest.version}-${digest.slice(0, 8)}
|
|
53
|
+
const name = `${manifest.version}-${digest.slice(0, 8)}`;
|
|
54
|
+
const channel = (process.env.RER_INSTALL_CHANNEL ?? (await channelOf(paths)).channel) === 'script' ? 'script' : 'npx';
|
|
53
55
|
const launcher = await launcherOwner(paths.launcher);
|
|
54
56
|
if (launcher.state === 'foreign') {
|
|
55
57
|
process.stderr.write(`rer cli install: ${paths.launcher} already exists and was not written by rer cli install (it may be the unrelated npm package "rer"). Nothing was changed. Remove or rename it, then run the install again.\n`);
|
package/global/main.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { checkoutBootstrap, checkoutVerbs } from '../cli/contract.mjs';
|
|
2
2
|
import { dispatcher, locate, pinnedPackage, unsupportedMessage } from './checkout.mjs';
|
|
3
3
|
import { delegate } from './delegate.mjs';
|
|
4
4
|
import { localDefaults } from './launch/local-defaults.mjs';
|
|
@@ -15,7 +15,8 @@ ${repositoryHelp}
|
|
|
15
15
|
|
|
16
16
|
Inside a project (the nearest OPERATIONS.json at or above this folder, or --cwd DIR),
|
|
17
17
|
every verb runs that checkout's own pinned rer: the @runeditrun/rer version its package.json
|
|
18
|
-
pins (installed first
|
|
18
|
+
pins (installed first for commands that run project code when node_modules holds another),
|
|
19
|
+
else its vendored scripts/rer.mjs.
|
|
19
20
|
|
|
20
21
|
rer dev Launch a first-party checkout with no setup steps: installs dependencies,
|
|
21
22
|
sets up a local owner and a free port when needed, starts the app and prints
|
|
@@ -44,17 +45,13 @@ pins (installed first by any verb when node_modules holds another), else its ven
|
|
|
44
45
|
Run COMMAND once this computer's job queue admits it (heavy package scripts
|
|
45
46
|
of a checkout that pins the rer package use it).
|
|
46
47
|
|
|
47
|
-
Checkout verbs:
|
|
48
|
-
import, doctor, describe, check, release, listing. Run rer VERB --help in a checkout for its flags.
|
|
48
|
+
Checkout verbs: ${Object.keys(checkoutVerbs).join(', ')}, listing. Run rer VERB --help in a checkout for its flags.
|
|
49
49
|
`;
|
|
50
50
|
|
|
51
|
-
// The checkout verbs that install the pinned package before they run when
|
|
52
|
-
// node_modules holds another version or none (dev installs it in its launch).
|
|
53
|
-
const installsFirst = new Set([...Object.keys(verbs), 'signin', 'release'].filter(verb => !['dev', 'doctor'].includes(verb)));
|
|
54
|
-
|
|
55
51
|
export async function main(argv) {
|
|
56
52
|
handleBrokenPipes();
|
|
57
53
|
const [verb] = argv;
|
|
54
|
+
const installsFirst = checkoutBootstrap(argv) === 'before';
|
|
58
55
|
if (verb === '--version' || verb === '-v') return (await import('./version.mjs')).versionCommand(argv);
|
|
59
56
|
if (verb === 'queue' && argv.length === 2 && argv[1] === '--help') {
|
|
60
57
|
process.stdout.write('Usage: rer queue NAME -- COMMAND [ARGS]\nRun COMMAND once this computer\'s job queue admits it.\n');
|
|
@@ -102,7 +99,7 @@ export async function main(argv) {
|
|
|
102
99
|
const code = await (await import('./browser-runtime.mjs')).browserPreflight(target.root, target.args);
|
|
103
100
|
if (code !== undefined) return code;
|
|
104
101
|
}
|
|
105
|
-
const bootstrap = pinnedPackage(target.root)?.ready === false && installsFirst
|
|
102
|
+
const bootstrap = pinnedPackage(target.root)?.ready === false && installsFirst;
|
|
106
103
|
if ((bootstrap || ['install', 'setup', 'dev', 'preview', 'build', 'verify'].includes(verb)) && !argv.includes('--help') && !argv.includes('--stop')) {
|
|
107
104
|
const { parse } = await import('../cli/parse.mjs');
|
|
108
105
|
// The door's launch marker belongs to launchDev, which consumes it before
|
|
@@ -125,13 +122,13 @@ export async function main(argv) {
|
|
|
125
122
|
}
|
|
126
123
|
// A checkout that pins its own rer package runs all of it, launching included.
|
|
127
124
|
// Until node_modules holds the pinned version (a fresh clone, or a pulled pin
|
|
128
|
-
// change),
|
|
125
|
+
// change), a command that runs project code installs it with the frozen lockfile and then
|
|
129
126
|
// runs the pinned verb, so a fresh clone checks and a changed pin deploys with
|
|
130
127
|
// the pinned bytes; the zero-setup launch installs it first.
|
|
131
128
|
// Verbs started at once share one install, and one whose pin already looks
|
|
132
129
|
// installed waits for an install still running.
|
|
133
130
|
const pinned = first && mode !== 'package' ? pinnedPackage(target.root) : undefined;
|
|
134
|
-
if (pinned && !pinned.ready && !argv.includes('--help') && installsFirst
|
|
131
|
+
if (pinned && !pinned.ready && !argv.includes('--help') && installsFirst) {
|
|
135
132
|
const { installPinned } = await import('./launch/install-pinned.mjs'), { LaunchFailure } = await import('./launch/failure.mjs');
|
|
136
133
|
try { await installPinned(target.root); }
|
|
137
134
|
catch (failure) {
|
|
@@ -142,7 +139,7 @@ export async function main(argv) {
|
|
|
142
139
|
return failure.exitCode;
|
|
143
140
|
}
|
|
144
141
|
}
|
|
145
|
-
if (mode === 'package' && installsFirst
|
|
142
|
+
if (mode === 'package' && installsFirst) await (await import('./launch/install-pinned.mjs')).settledPin(target.root);
|
|
146
143
|
if (verb === 'describe' && !argv.includes('--help')) return (await import('./cli/describe.mjs')).describeCommand(target);
|
|
147
144
|
if (first && dispatcher(target.root).mode !== 'bundled' && verb === 'verify' && !argv.includes('--help') && !argv.includes('--site')) {
|
|
148
145
|
const code = await (await import('./browser-runtime.mjs')).browserPreflight(target.root, target.args);
|
|
@@ -91,7 +91,7 @@ async function buildImage(root, { output = join(root,'.rer/container/image'), en
|
|
|
91
91
|
}
|
|
92
92
|
const base = resolve(import.meta.dirname,'../..');
|
|
93
93
|
for (const path of ['modules/container','modules/portability','modules/d1-transport','modules/deploy-kit','cli/scheduled.mjs','cli/jsonc.mjs','modules/integrations/core/public-address.ts']) { await mkdir(join(output,'runtime',path,'..'),{recursive:true}); await cp(join(base,path),join(output,'runtime',path),{recursive:true,filter:path => !path.includes('/tests/')}); }
|
|
94
|
-
const dependencies = { ws:'8.
|
|
94
|
+
const dependencies = { ws:'8.22.0', ...(engine === 'workerd' ? { miniflare:'5.20260907.0-alpha' } : {}) };
|
|
95
95
|
await writeFile(join(output,'runtime/package.json'),JSON.stringify({private:true,type:'module',dependencies}));
|
|
96
96
|
await writeFile(join(output,'Dockerfile'),`FROM node:26.8.1-bookworm-slim\nRUN apt-get update && apt-get install -y --no-install-recommends util-linux ca-certificates && apt-get clean\nRUN mkdir -p /private /archive\nWORKDIR /runtime\nCOPY runtime/package.json ./package.json\nRUN npm install --omit=dev --no-audit --no-fund\nCOPY runtime/ /runtime/\nCOPY app/ /app/\nENV NODE_ENV=production PORT=8080 WRANGLER_SEND_METRICS=false\nEXPOSE 8080\nVOLUME /data\nENTRYPOINT ["sh", "/runtime/modules/container/entrypoint.sh"]\n`);
|
|
97
97
|
return { output,manifest };
|