@runeditrun/rer 0.2.79 → 0.2.81
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/deploy-needs.mjs +4 -2
- package/cli/dev-identity.mjs +2 -2
- package/cli/export.mjs +1 -1
- package/cli/inspect.mjs +38 -2
- package/cli/ledger-refusal.mjs +18 -0
- package/cli/main.mjs +8 -2
- package/cli/managed-server.mjs +1 -1
- package/cli/parse.mjs +7 -6
- package/cli/portability-migrations.mjs +30 -11
- package/cli/portability-worker.mjs +4 -1
- package/cli/portability.mjs +8 -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 +6 -5
- package/cli/site-hosting.mjs +90 -0
- package/cli/site-preview.mjs +4 -1
- package/cli/site-render.mjs +3 -2
- package/cli/site.mjs +8 -4
- package/edition-authoring/adopt.mjs +39 -0
- package/edition-authoring/base-acknowledgements.mjs +24 -0
- package/edition-authoring/base-copies.mjs +427 -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/runtime-dependencies.mjs +108 -0
- package/edition-authoring/sources.mjs +114 -0
- package/edition-authoring/updates.mjs +105 -0
- package/global/CHANGELOG.md +24 -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 +16 -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 +148 -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/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/dependencies/auth.mjs +2 -2
- package/modules/deploy-kit/README.md +19 -15
- package/modules/deploy-kit/owner-cli.mjs +1 -1
- package/modules/deploy-kit/owner.mjs +8 -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-effects.ts +33 -0
- package/modules/import-kit/src/d1/apply.ts +46 -14
- 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/import-kit/src/types.ts +3 -1
- 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/README.md +92 -3
- package/modules/operator-auth/accounts/admin.mjs +52 -20
- package/modules/operator-auth/accounts/audit.mjs +24 -0
- package/modules/operator-auth/accounts/business-team.mjs +91 -0
- package/modules/operator-auth/accounts/domain-audit.mjs +24 -0
- package/modules/operator-auth/accounts/native.mjs +6 -2
- 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 +26 -4
- package/modules/operator-auth/accounts/status.mjs +7 -2
- package/modules/operator-auth/accounts/store.mjs +32 -6
- package/modules/operator-auth/business-settings.mjs +40 -0
- 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/identity/email-link/index.mjs +1 -1
- package/modules/operator-auth/identity/oidc/admin-audit.mjs +31 -0
- package/modules/operator-auth/identity/oidc/index.mjs +12 -5
- package/modules/operator-auth/identity/oidc/store.mjs +2 -0
- package/modules/operator-auth/index.d.mts +41 -2
- package/modules/operator-auth/page.mjs +14 -0
- package/modules/operator-auth/representation.mjs +83 -0
- package/modules/operator-auth/routes.mjs +31 -3
- package/modules/operator-auth/service.mjs +8 -3
- package/modules/operator-auth/signin/index.mjs +1 -1
- package/modules/portability/README.md +173 -15
- 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 +10 -14
- package/modules/portability/format.mjs +12 -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 +13 -2
- package/modules/portability/index.mjs +3 -2
- package/modules/portability/ledgers.mjs +27 -4
- 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 +94 -11
- package/modules/release/github-verify.mjs +30 -9
- package/modules/release/sign.mjs +4 -2
- package/modules/release/signature.mjs +14 -7
- package/modules/release/signing-cli.mjs +2 -1
- package/modules/release/statement.mjs +2 -2
- package/modules/release/vectors/generate.mjs +1 -0
- package/modules/release/vectors/publisher-projects.mjs +133 -0
- package/modules/release/vectors/release-signature-vectors.json +5195 -0
- package/modules/release/verify.mjs +5 -1
- 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 +68 -1
- package/onboarding/schema/business-field-inputs.mjs +36 -0
- package/onboarding/schema/json-schema.mjs +6 -2
- package/onboarding/schema/setup-validation.mjs +23 -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,108 @@
|
|
|
1
|
+
// Keep partial and single-file runtime copies closed over their relative imports.
|
|
2
|
+
// Both maintained exporters already ship the whole foundation/runtime directory;
|
|
3
|
+
// refresh must also recover siblings omitted by an older seed's copy selection.
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
const runtime = 'foundation/runtime/';
|
|
7
|
+
const code = /\.(?:[cm]?[jt]s|[jt]sx)$/;
|
|
8
|
+
const inside = (name, prefix) => name === prefix || name.startsWith(prefix + '/');
|
|
9
|
+
const mapped = (name, from, to) => to + name.slice(from.length);
|
|
10
|
+
|
|
11
|
+
// Tokenize enough module syntax to ignore comments and quoted page/CSS content.
|
|
12
|
+
// Static imports (including type imports), re-exports and literal import() /
|
|
13
|
+
// require() calls share the same relative resolution below. Templates are page
|
|
14
|
+
// content, never static module declarations.
|
|
15
|
+
function specifiers(source) {
|
|
16
|
+
const tokens = [...source.matchAll(/\/\/[^\n]*|\/\*[\s\S]*?\*\/|`(?:\\[\s\S]|[^`\\])*`|'(?:\\[\s\S]|[^'\\])*'|"(?:\\[\s\S]|[^"\\])*"|[\w$]+|[^\s]/g)]
|
|
17
|
+
.map(match => match[0]).filter(token => !token.startsWith('//') && !token.startsWith('/*') && !token.startsWith('`'));
|
|
18
|
+
const result = [];
|
|
19
|
+
const literal = token => /^['"]\.{1,2}\//.test(token || '') ? token.slice(1, -1) : null;
|
|
20
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
21
|
+
if (!['import', 'export', 'require'].includes(tokens[i])) continue;
|
|
22
|
+
if (tokens[i - 1] === '.' || (tokens[i] === 'require' && tokens[i + 1] !== '(')) continue;
|
|
23
|
+
if (tokens[i] === 'export' && !['{', '*', 'type'].includes(tokens[i + 1])) continue;
|
|
24
|
+
let value = literal(tokens[i + 1]);
|
|
25
|
+
if (tokens[i + 1] === '(') value = literal(tokens[i + 2]);
|
|
26
|
+
else if (!value) {
|
|
27
|
+
for (let j = i + 1; j < tokens.length && ![';', 'import', 'export'].includes(tokens[j]); j++) {
|
|
28
|
+
if (tokens[j] === 'from') { value = literal(tokens[j + 1]); break; }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (value) result.push(value);
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function resolve(tree, source, specifier) {
|
|
37
|
+
const name = path.posix.normalize(path.posix.join(path.posix.dirname(source), specifier));
|
|
38
|
+
const candidates = [name];
|
|
39
|
+
// TypeScript source commonly uses its emitted JS extension in imports.
|
|
40
|
+
const replacement = {'.js': ['.ts', '.tsx', '.d.ts'], '.mjs': ['.mts', '.d.mts'], '.cjs': ['.cts', '.d.cts']}[path.posix.extname(name)];
|
|
41
|
+
if (replacement) candidates.push(...replacement.map(extension => name.slice(0, -path.posix.extname(name).length) + extension));
|
|
42
|
+
if (!path.posix.extname(name)) {
|
|
43
|
+
for (const suffix of ['.ts', '.tsx', '.mts', '.mjs', '.js', '.jsx', '.cts', '.cjs', '.json']) candidates.push(name + suffix, name + '/index' + suffix);
|
|
44
|
+
}
|
|
45
|
+
const found = candidates.find(candidate => tree.has(candidate));
|
|
46
|
+
if (!found || !found.startsWith(runtime)) throw Error(`Cannot ship runtime dependency ${specifier} from ${source}; keep its source inside foundation/runtime`);
|
|
47
|
+
return found;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function completeRuntimeCopies(plans, {tree, read, local, upstream, revision, checkTarget}) {
|
|
51
|
+
const queue = plans.flatMap(plan => plan.sources.filter(([source]) => source.startsWith(runtime) && code.test(source))
|
|
52
|
+
.map(([source]) => ({source, target: mapped(source, plan.copy.originPath, plan.copy.path), baseline: plan.copy.revision})));
|
|
53
|
+
const seen = new Set();
|
|
54
|
+
const blobs = new Map();
|
|
55
|
+
function bytes(source) {
|
|
56
|
+
const object = tree.get(source).object;
|
|
57
|
+
if (!blobs.has(object)) blobs.set(object, read.blobs([object]).get(object));
|
|
58
|
+
return blobs.get(object).toString('utf8');
|
|
59
|
+
}
|
|
60
|
+
function include(source, target, baseline) {
|
|
61
|
+
checkTarget(target);
|
|
62
|
+
let plan = plans.find(plan => inside(target, plan.copy.path));
|
|
63
|
+
if (plan && mapped(target, plan.copy.path, plan.copy.originPath) !== source) throw Error(`Runtime dependency ${target} conflicts with its Base copy mapping`);
|
|
64
|
+
// A missing recorded file is a removal, not an omitted sibling. Restoring
|
|
65
|
+
// it here would bypass refresh's retirement/removal plan and could leave
|
|
66
|
+
// the recreated source outside its record. Refuse before any writes.
|
|
67
|
+
if (plan?.removed.includes(target)) throw Error(`Runtime dependency ${target} was removed locally but is still imported; no files were refreshed. Restore it or adapt the importing module before refreshing.`);
|
|
68
|
+
if (plan?.copy.adapted?.[target]) {
|
|
69
|
+
queue.push({source, target, baseline});
|
|
70
|
+
return; // Keep seed bytes while supplying the shipped module's dependencies.
|
|
71
|
+
}
|
|
72
|
+
if (!plan?.sources.some(([name]) => name === source)) {
|
|
73
|
+
const actual = local(target);
|
|
74
|
+
const previous = actual && read.tree(baseline).get(source);
|
|
75
|
+
const previousDigest = previous && read.digests([previous.object]).get(previous.object);
|
|
76
|
+
if (actual && actual !== upstream.get(tree.get(source).object) && actual !== previousDigest) {
|
|
77
|
+
// Existing unrecorded siblings belong to the seed, just as in the
|
|
78
|
+
// ordinary copy selection. They already satisfy this import's presence;
|
|
79
|
+
// only an absent sibling needs to be supplied by Base. Keep traversing
|
|
80
|
+
// the shipped graph so a later adoption cannot omit its dependencies.
|
|
81
|
+
// Recorded edits and acknowledgements were checked before planning.
|
|
82
|
+
queue.push({source, target, baseline});
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!plan) {
|
|
86
|
+
if (plans.some(plan => inside(plan.copy.path, target))) throw Error(`Runtime dependency ${target} overlaps an existing Base copy`);
|
|
87
|
+
plan = {copy: {path: target, originPath: source, revision, files: {}, modes: {}}, sources: [], removed: []};
|
|
88
|
+
plans.push(plan);
|
|
89
|
+
}
|
|
90
|
+
plan.sources.push([source, tree.get(source)]);
|
|
91
|
+
plan.removed = plan.removed.filter(name => name !== target);
|
|
92
|
+
}
|
|
93
|
+
queue.push({source, target, baseline});
|
|
94
|
+
}
|
|
95
|
+
for (let i = 0; i < queue.length; i++) {
|
|
96
|
+
const {source, target, baseline} = queue[i];
|
|
97
|
+
const key = source + '\0' + target;
|
|
98
|
+
if (seen.has(key)) continue;
|
|
99
|
+
seen.add(key);
|
|
100
|
+
if (code.test(source)) for (const specifier of specifiers(bytes(source))) {
|
|
101
|
+
const dependency = resolve(tree, source, specifier);
|
|
102
|
+
include(dependency, path.posix.join(path.posix.dirname(target), path.posix.relative(path.posix.dirname(source), dependency)), baseline);
|
|
103
|
+
}
|
|
104
|
+
// JS type imports also need the declaration file used by edition typechecks.
|
|
105
|
+
const declaration = source.replace(/\.mjs$/, '.d.mts').replace(/\.cjs$/, '.d.cts');
|
|
106
|
+
if (declaration !== source && tree.has(declaration)) include(declaration, target.replace(/\.mjs$/, '.d.mts').replace(/\.cjs$/, '.d.cts'), baseline);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -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,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.81
|
|
4
|
+
|
|
5
|
+
- Import RER Platform archives into native installations by migration hash, recording `rer_migrations` as the source ledger without restoring it as product data; expose `mapMigrationLedger` for custom archive adapters and name unapplied files in preflight refusals.
|
|
6
|
+
- Project declared import intake fields before storing chunks, keeping excluded values such as Auth0 password hashes and Okta credentials and factors out of custody.
|
|
7
|
+
- Validate preserving import adapters before every apply batch, including resumed work; retain earlier admitted batches for Undo when later preparation is refused.
|
|
8
|
+
- Deliver the shared three-way Run chooser and hosting guide through Base refresh, with byte-exact Copy, listing-aware Assisted and Managed links, and commands that wrap under adopted seed themes.
|
|
9
|
+
- Keep demo Run exits within available header space and reveal the full accessible link on keyboard focus without moving host controls.
|
|
10
|
+
- Add transactional audit hooks for native operator administration and direct installation exports; audit provider unlink only for a new pin generation.
|
|
11
|
+
- Apply signed runtime Business settings, same-origin logos, app accents, local overrides and owner-scoped team reconciliation; allow owners to stop settings with fresh sign-in proof.
|
|
12
|
+
- Authorize explicit publisher project lists with version 2 signing anchors and an optional signing publisher, while retaining version 1 verification.
|
|
13
|
+
- Simplify the shared Run invocation, show the public Roadmap without repository citations, and preserve retained runtime dependencies during Base copy refresh.
|
|
14
|
+
|
|
15
|
+
## 0.2.80
|
|
16
|
+
|
|
17
|
+
- Healthy doctor now exits 0 when local settings are present.
|
|
18
|
+
- Restore installation archives using SQL-aware schema identity and an object inventory; ignore SQL comments while preserving behavioral schema checks and staged file validation.
|
|
19
|
+
- Expose edition adoption and `refresh-base` in the packaged CLI, preserve adaptation acknowledgements and offline provenance, and retire absent singleton Base copies.
|
|
20
|
+
- 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.
|
|
21
|
+
- Keep harness ingress listeners bound across Worker generations and let test runtimes own ephemeral ports.
|
|
22
|
+
- Link demo exits to the seed's canonical Run chooser, bootstrap pinned demo commands, and improve shared header, link and minimum text sizes.
|
|
23
|
+
- Limit Business profile hints to declared public input names and reject credential-shaped hints and duplicate field claims.
|
|
24
|
+
- Update compatible dependencies while retaining Node 22.20.0 and pnpm 10.12.4; pnpm 10.34.7 is not adopted.
|
|
25
|
+
- Give Chromium apt attempts separate deadlines and clean up timed-out attempts and cache payloads.
|
|
26
|
+
|
|
3
27
|
## 0.2.79
|
|
4
28
|
|
|
5
29
|
- Reuse bounded keep-alive connections in the local dev proxy and retry stale connections for bodyless reads.
|