@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
package/cli/project.mjs
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import { readFile,
|
|
2
|
-
import {
|
|
1
|
+
import { readFile, realpath } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
3
|
import { pathToFileURL } from 'node:url';
|
|
4
|
+
import { containedInput } from '../modules/demo/input-path.mjs';
|
|
4
5
|
import { readOperations } from '../operations/operations.mjs';
|
|
5
6
|
import { invalid, missing, refuse } from './errors.mjs';
|
|
6
7
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
const checkout = await realpath(root), destination = resolve(checkout, path), parts = relative(checkout, destination).split(sep);
|
|
10
|
-
let current = checkout;
|
|
11
|
-
for (let i = 0; i < parts.length; i++) {
|
|
12
|
-
current = resolve(current, parts[i]);
|
|
13
|
-
let status; try { status = await lstat(current); } catch (error) { if (error.code === 'ENOENT' && optional) return destination; if (error.code === 'ENOENT') throw missing(`Missing input file: ${path}. See the project operating documentation.`); throw error; }
|
|
14
|
-
if (status.isSymbolicLink()) throw refuse(`Symlink refused at ${path}; preserve it and resolve placement first.`);
|
|
15
|
-
if (i < parts.length - 1 && !status.isDirectory()) throw refuse(`Unsafe path ancestor for ${path}.`);
|
|
16
|
-
if (privateFile && i === parts.length - 1 && (!status.isFile() || status.nlink !== 1 || (status.mode & 0o077) !== 0 || (process.getuid && status.uid !== process.getuid()))) throw refuse(`Input must be an owned regular private file (0600): ${path}.`);
|
|
17
|
-
}
|
|
18
|
-
return destination;
|
|
8
|
+
export function contained(root, path, options = {}) {
|
|
9
|
+
return containedInput(root, path, { ...options, refuse, missing });
|
|
19
10
|
}
|
|
20
11
|
|
|
21
12
|
export async function resolveProject(root) {
|
package/cli/release.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { releaseVerb } from './contract.mjs';
|
|
1
2
|
import { parseTimeoutSeconds, timeoutBounds } from '../scripts/publish-check/timeout.mjs';
|
|
2
3
|
|
|
3
4
|
// Preserve release's accepted parser, producer, receipt and validation exits.
|
|
@@ -51,7 +52,7 @@ Key generation requires non-terminal stdout; --key-stdin requires non-terminal s
|
|
|
51
52
|
|
|
52
53
|
export async function dispatchRelease(args) {
|
|
53
54
|
if (args.length === 1 && args[0] === '--help') { console.log(releaseHelp); return 0; }
|
|
54
|
-
if (
|
|
55
|
+
if (Object.hasOwn(releaseVerb.subcommands, args[0])) return (await import('../modules/release/signing-cli.mjs')).dispatchSigning(args[0], args.slice(1));
|
|
55
56
|
try {
|
|
56
57
|
const options = {};
|
|
57
58
|
for (let index = 0; index < args.length; index++) {
|
package/cli/server-proxy.mjs
CHANGED
|
@@ -5,11 +5,12 @@ import { posix } from 'node:path';
|
|
|
5
5
|
import { listen } from './listen.mjs';
|
|
6
6
|
import { loopback } from './parse.mjs';
|
|
7
7
|
import { fontResponseHeaders } from './font-cache.mjs';
|
|
8
|
+
import { UpstreamAgent } from './upstream-agent.mjs';
|
|
8
9
|
|
|
9
10
|
// The public listener observes transport lifetime without buffering or replacing
|
|
10
11
|
// application responses. Preserve Host, Origin, cookies, status and streaming.
|
|
11
|
-
//
|
|
12
|
-
//
|
|
12
|
+
// Share bounded upstream connections. A runtime closing an idle socket races
|
|
13
|
+
// reuse; retry only a bodyless read, once, before any response bytes arrive.
|
|
13
14
|
// In door mode (`door`: {host, header, secret}) it answers only requests whose
|
|
14
15
|
// Host is its own `<name>.localhost:<port>` (or a subdomain) and that carry the
|
|
15
16
|
// per-start secret the front door adds; cookies are not scoped by port, so
|
|
@@ -24,17 +25,25 @@ import { fontResponseHeaders } from './font-cache.mjs';
|
|
|
24
25
|
// anyway, and an auth check that throws on it must not answer with a crash page.
|
|
25
26
|
export async function trafficProxy({host,port,target,activity,door,devKey,origin}) {
|
|
26
27
|
const probe=randomUUID(),sockets=new Set(),keyed=keyHolder(devKey),configured=origin?new URL(origin).host:null;
|
|
28
|
+
const agent=new UpstreamAgent();let closing=false;
|
|
27
29
|
const server=http.createServer((req,res)=>{
|
|
28
30
|
if(door&&!doorAdmits(req,door)){req.resume();res.writeHead(403,{'content-type':'text/plain; charset=utf-8'});res.end('This checkout answers only through its front door.');return;}
|
|
29
31
|
if(!hostAdmits(req,configured)){req.resume();res.writeHead(421,{'content-type':'text/plain; charset=utf-8'});res.end('This local server answers only its own host.');return;}
|
|
30
32
|
if(!publicPath(req.url)||fsPath(req.url)&&!keyed(req)){req.resume();notFound(res);return;}
|
|
31
33
|
const internal=req.headers['x-rer-probe']===probe;delete req.headers['x-rer-probe'];
|
|
32
|
-
const
|
|
34
|
+
const endActivity=internal?()=>{}:activity.begin();let finished=false;
|
|
35
|
+
const finish=()=>{if(!finished){finished=true;endActivity();}};
|
|
33
36
|
let requestEnded=req.complete,responseEnded=false;
|
|
34
37
|
const completed=()=>{if(requestEnded&&responseEnded)finish();};
|
|
35
38
|
req.once('end',()=>{requestEnded=true;completed();});req.once('aborted',finish);
|
|
36
39
|
res.once('close',()=>{responseEnded=true;if(req.destroyed)finish();else completed();});res.once('finish',()=>{responseEnded=true;completed();});
|
|
37
|
-
|
|
40
|
+
let upstream,bodyStarted=false;
|
|
41
|
+
req.on('data',()=>{bodyStarted=true;});
|
|
42
|
+
const bodyless=['GET','HEAD','OPTIONS'].includes(req.method)&&!req.headers['transfer-encoding']&&(!req.headers['content-length']||req.headers['content-length']==='0');
|
|
43
|
+
function send(retried=false){
|
|
44
|
+
let responseStarted=false,readAtStart;
|
|
45
|
+
const attempt=http.request({host:'127.0.0.1',port:target,path:req.url,method:req.method,headers:req.headers,agent:retried?false:agent},reply=>{
|
|
46
|
+
responseStarted=true;
|
|
38
47
|
// Vite answers a path outside its serving allow list with a 403 page that lists the
|
|
39
48
|
// allow list (checkout and home paths); a request without the dev key gets 404 instead.
|
|
40
49
|
// Any other 403 is the application's own and passes through.
|
|
@@ -51,8 +60,21 @@ export async function trafficProxy({host,port,target,activity,door,devKey,origin
|
|
|
51
60
|
}
|
|
52
61
|
res.writeHead(reply.statusCode,fontResponseHeaders(req.url,reply.statusCode,reply.rawHeaders,req.headers));reply.pipe(res);
|
|
53
62
|
});
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
upstream=attempt;
|
|
64
|
+
attempt.once('socket',socket=>{readAtStart=socket.bytesRead;});
|
|
65
|
+
attempt.on('error',error=>{
|
|
66
|
+
if(closing||req.aborted||res.destroyed)return;
|
|
67
|
+
const dropped=['ECONNRESET','EPIPE'].includes(error.code)||error.message==='socket hang up';
|
|
68
|
+
if(!retried&&dropped&&attempt.reusedSocket&&!responseStarted&&attempt.socket?.bytesRead===readAtStart&&bodyless&&!bodyStarted&&req.readableEnded){
|
|
69
|
+
req.unpipe(attempt);send(true);return;
|
|
70
|
+
}
|
|
71
|
+
if(!res.headersSent)notFound(res);else res.destroy();
|
|
72
|
+
});
|
|
73
|
+
if(retried)attempt.end();else req.pipe(attempt);
|
|
74
|
+
}
|
|
75
|
+
req.once('aborted',()=>upstream.destroy());
|
|
76
|
+
res.once('close',()=>{if(!res.writableFinished)upstream.destroy();});
|
|
77
|
+
send();
|
|
56
78
|
});
|
|
57
79
|
server.on('connection',socket=>{sockets.add(socket);socket.on('close',()=>sockets.delete(socket));});
|
|
58
80
|
server.on('upgrade',(req,socket,head)=>{
|
|
@@ -79,8 +101,8 @@ export async function trafficProxy({host,port,target,activity,door,devKey,origin
|
|
|
79
101
|
}
|
|
80
102
|
upstream.on('error',()=>socket.destroy());socket.on('error',()=>upstream.destroy());socket.on('close',()=>upstream.destroy());upstream.on('close',()=>socket.destroy());
|
|
81
103
|
});
|
|
82
|
-
await listen(server,host,port);
|
|
83
|
-
return {probe,port:server.address().port,async close(){for(const socket of sockets)socket.destroy();await new Promise(resolve=>server.close(resolve));}};
|
|
104
|
+
try{await listen(server,host,port);}catch(error){agent.destroy();throw error;}
|
|
105
|
+
return {probe,port:server.address().port,async close(){closing=true;agent.destroy();for(const socket of sockets)socket.destroy();await new Promise(resolve=>server.close(resolve));}};
|
|
84
106
|
}
|
|
85
107
|
function doorAdmits(req,door){
|
|
86
108
|
const host=String(req.headers.host??'').toLowerCase(),given=Buffer.from(String(req.headers[door.header]??'')),secret=Buffer.from(door.secret);
|
package/cli/site-preview.mjs
CHANGED
|
@@ -47,7 +47,10 @@ export async function sitePreview(folder, { host = '127.0.0.1', ports }) {
|
|
|
47
47
|
server.once('error', failed);
|
|
48
48
|
server.listen(port, host, () => { server.off('error', failed); resolve(true); });
|
|
49
49
|
});
|
|
50
|
-
if (bound)
|
|
50
|
+
if (bound) {
|
|
51
|
+
const port = server.address().port;
|
|
52
|
+
return { url: `http://${host === '::1' ? '[::1]' : host}:${port}`, port, close: () => new Promise(resolve => { server.closeAllConnections?.(); server.close(() => resolve()); }) };
|
|
53
|
+
}
|
|
51
54
|
}
|
|
52
55
|
throw new Error('No free port for the run site preview.');
|
|
53
56
|
}
|
package/cli/site.mjs
CHANGED
|
@@ -122,7 +122,8 @@ export async function siteCommand(project, options, store, signal, out) {
|
|
|
122
122
|
return { site: { folder: built.folder, path, pages: built.pages, files: built.files, references:built.references, ...(built.runtime ? {runtime:runtimeSummary(built.runtime)} : {}) } };
|
|
123
123
|
}
|
|
124
124
|
const plan = await siteDeployment(project, options, built.folder, built.runtime);
|
|
125
|
-
const
|
|
125
|
+
const assets = relative(project.root, plan.assets);
|
|
126
|
+
const human = [`Run site plan: site Worker ${plan.worker}, Base-generated, ${built.runtime ? 'docs-search runtime with ASSETS and AI' : 'its only binding the assets'} (the app's Worker ${plan.appWorker} is not touched)`, ` assets: ${assets} (${built.files} files; HTML ${plan.assetsConfig.html_handling}, not found ${plan.assetsConfig.not_found_handling}; the Worker runs first)`,
|
|
126
127
|
` custom domains: ${plan.hostnames.join(', ')}; workers.dev off`, ...plan.redirects.map(rule => ` redirect in the Worker: ${rule.from} -> ${rule.to} (${rule.status}, keeps ${rule.keeps.join(' and ')})`)];
|
|
127
128
|
const { collectFiles } = await import('../modules/deploy-kit/artifact.mjs');
|
|
128
129
|
const { siteFingerprint } = await import('../modules/deploy-kit/site.mjs');
|
|
@@ -131,7 +132,7 @@ export async function siteCommand(project, options, store, signal, out) {
|
|
|
131
132
|
if (runtime) human.push(` runtime: ${runtime.type}; module ${runtime.module}; endpoint ${runtime.endpoint}; bindings ${runtime.bindings.join(', ')}; model ${runtime.model}; pooling ${runtime.pooling}; corpus ${runtime.corpusHash}`);
|
|
132
133
|
const fingerprint = siteFingerprint(plan, files, {preparing:Boolean(runtime) && !prepare});
|
|
133
134
|
if (runtime) human.push(` fingerprint: ${fingerprint}${prepare ? '' : ' (vectors prepared only on a real deploy)'}`);
|
|
134
|
-
const summary = { ...(runtime ? {runtime, fingerprint, vectors:prepare ? 'prepared' : 'prepare-on-deploy'} : {}), worker: plan.worker, appWorker: plan.appWorker, module: plan.module, bindings: plan.bindings, assets
|
|
135
|
+
const summary = { ...(runtime ? {runtime, fingerprint, vectors:prepare ? 'prepared' : 'prepare-on-deploy'} : {}), worker: plan.worker, appWorker: plan.appWorker, module: plan.module, bindings: plan.bindings, assets, files: built.files, references:built.references, domain: plan.domain, hostnames: plan.hostnames, workersDev: false, runWorkerFirst: true, assetsConfig: plan.assetsConfig, redirects: plan.redirects.map(({ from, to, status }) => ({ from, to, status })) };
|
|
135
136
|
if (options.dryRun) {
|
|
136
137
|
if (options.json) out.event('site', summary); else for (const line of human) out.human(line);
|
|
137
138
|
store.report('deploy --site: dry run complete; no deployment occurred and no provider request was made.');
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
|
|
3
|
+
// Expire only idle connections, well before Vite's 5 s keep-alive timeout.
|
|
4
|
+
// Keep a browser's six HTTP/1 connections free between module bursts.
|
|
5
|
+
// Active streams have no deadline imposed by the pool.
|
|
6
|
+
export class UpstreamAgent extends http.Agent {
|
|
7
|
+
constructor(){super({keepAlive:true,maxSockets:16,maxFreeSockets:6});}
|
|
8
|
+
keepSocketAlive(socket){
|
|
9
|
+
if(!super.keepSocketAlive(socket))return false;
|
|
10
|
+
socket.setTimeout(1000);
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
reuseSocket(socket,request){socket.setTimeout(0);super.reuseSocket(socket,request);}
|
|
14
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {VERSION} from './manifest.mjs';
|
|
4
|
+
import {resolveSources} from './lock.mjs';
|
|
5
|
+
import {validate} from './base-copies.mjs';
|
|
6
|
+
import {git, json, noLinks, tracked, writeTree} from './files.mjs';
|
|
7
|
+
|
|
8
|
+
// Existing source and copy/composition provenance stay authoritative. Adoption
|
|
9
|
+
// adds a local-source recipe and lock; it does not regenerate the product or
|
|
10
|
+
// manufacture an upstream origin for source the seed already owns.
|
|
11
|
+
export function adoptEdition(root) {
|
|
12
|
+
if (fs.realpathSync(git(root, 'rev-parse', '--show-toplevel')) !== fs.realpathSync(root)) throw Error('Run adoption at the edition Git repository root.');
|
|
13
|
+
for (const name of ['edition.json', 'sources.lock.json', 'base-copies.json', 'rer-project.json', 'OPERATIONS.json']) noLinks(root, name);
|
|
14
|
+
if (fs.existsSync(path.join(root, 'edition.json')) || fs.existsSync(path.join(root, 'sources.lock.json'))) throw Error('Edition authoring inputs already exist. Preserve them; inspect and lock with the existing edition-authoring CLI instead of adopting again.');
|
|
15
|
+
const read = name => fs.existsSync(path.join(root, name)) ? JSON.parse(fs.readFileSync(path.join(root, name), 'utf8')) : {};
|
|
16
|
+
const id = read('rer-project.json').projectId ?? read('OPERATIONS.json').project;
|
|
17
|
+
if (typeof id !== 'string' || !/^[a-zA-Z0-9][a-zA-Z0-9._-]*\/[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(id)) throw Error('Declare a publisher-qualified projectId in rer-project.json before rer adopt-edition.');
|
|
18
|
+
const files = tracked(root);
|
|
19
|
+
const paths = Object.keys(files).filter(name => !['edition.json', 'sources.lock.json'].includes(name) && !name.startsWith('.edition'));
|
|
20
|
+
if (!paths.length) throw Error('Adoption needs tracked edition source. Add the intended source with git add, then repeat rer adopt-edition.');
|
|
21
|
+
const hasRecord = fs.existsSync(path.join(root, 'base-copies.json'));
|
|
22
|
+
if (hasRecord) validate(read('base-copies.json'));
|
|
23
|
+
const recipe = {schemaVersion: 1, id, toolchain: {id: 'runeditrun/edition-authoring', version: VERSION}, parent: null,
|
|
24
|
+
components: [{id, role: 'edition', source: {kind: 'local', paths}}]};
|
|
25
|
+
const created = [];
|
|
26
|
+
try {
|
|
27
|
+
const put = (name, value) => { writeTree(root, {[name]: {data: Buffer.from(json(value)).toString('base64'), executable: false}}); created.push(name); };
|
|
28
|
+
put('edition.json', recipe);
|
|
29
|
+
if (!hasRecord) put('base-copies.json', {schemaVersion: 1, copies: []});
|
|
30
|
+
const record = path.join(root, 'base-copies.json');
|
|
31
|
+
const additional = {'base-copies.json': {data: fs.readFileSync(record).toString('base64'), executable: !!(fs.statSync(record).mode & 0o111)}};
|
|
32
|
+
put('sources.lock.json', resolveSources(root, false, false, additional));
|
|
33
|
+
} catch (error) {
|
|
34
|
+
for (const name of created) fs.rmSync(path.join(root, name));
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
return {adopted: id, created, record: 'base-copies.json', preservedCopyRecord: hasRecord,
|
|
38
|
+
next: 'Review git diff and git status; stage edition.json, sources.lock.json and any untracked base-copies.json. Existing copy and composition provenance is preserved. An empty copy record claims no Base copies; record known copies before refreshing. Run the edition tests before committing.'};
|
|
39
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import {fileURLToPath} from 'node:url';
|
|
3
|
+
import {hash} from './files.mjs';
|
|
4
|
+
|
|
5
|
+
const cli = fileURLToPath(new URL('./cli.mjs', import.meta.url));
|
|
6
|
+
const quote = value => /^[a-zA-Z0-9_./:-]+$/.test(value) ? value : `'${value.replaceAll("'", "'\\''")}'`;
|
|
7
|
+
|
|
8
|
+
export const snapshot = file => ({sha256: hash(file.read()), mode: file.executable ? '100755' : '100644'});
|
|
9
|
+
|
|
10
|
+
// Keep the upstream baseline separate from the local bytes the owner accepted.
|
|
11
|
+
// Legacy declarations remain readable, but cannot silently acknowledge new bytes.
|
|
12
|
+
export function acknowledgementDrift(root, copy, name, file, recordPath) {
|
|
13
|
+
const relative = path.relative(root, cli);
|
|
14
|
+
const command = ['node', relative.startsWith('..') ? cli : relative, 'adapt-base', name,
|
|
15
|
+
...(recordPath === 'base-copies.json' ? [] : ['--record', recordPath])].map(quote).join(' ');
|
|
16
|
+
const detail = {path: name, copy: copy.path, acknowledge: command};
|
|
17
|
+
const expected = copy.acknowledged?.[name];
|
|
18
|
+
if (!expected) return [{kind: 'adaptation-unacknowledged', ...detail}];
|
|
19
|
+
const actual = snapshot(file);
|
|
20
|
+
const drift = [];
|
|
21
|
+
if (actual.sha256 !== expected.sha256) drift.push({kind: 'adaptation-modified', ...detail, expected: expected.sha256, actual: actual.sha256});
|
|
22
|
+
if (actual.mode !== expected.mode) drift.push({kind: 'adaptation-mode', ...detail, expected: expected.mode, actual: actual.mode});
|
|
23
|
+
return drift;
|
|
24
|
+
}
|