@sublang/spex 4.2.0 → 5.0.0
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 +433 -89
- package/dist/cli.js +80 -42
- package/dist/commands/add.d.ts +12 -0
- package/dist/commands/add.js +138 -0
- package/dist/commands/auth-target.d.ts +11 -0
- package/dist/commands/auth-target.js +50 -0
- package/dist/commands/environment.d.ts +123 -0
- package/dist/commands/environment.js +411 -0
- package/dist/commands/export.d.ts +21 -0
- package/dist/commands/export.js +663 -0
- package/dist/commands/home.d.ts +56 -0
- package/dist/commands/home.js +215 -0
- package/dist/commands/install.d.ts +2 -0
- package/dist/commands/install.js +48 -0
- package/dist/commands/list.d.ts +2 -0
- package/dist/commands/list.js +87 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.js +211 -0
- package/dist/commands/logout.d.ts +2 -0
- package/dist/commands/logout.js +74 -0
- package/dist/commands/publish.d.ts +2 -0
- package/dist/commands/publish.js +120 -0
- package/dist/commands/remove.d.ts +2 -0
- package/dist/commands/remove.js +34 -0
- package/dist/commands/run.d.ts +50 -0
- package/dist/commands/run.js +309 -0
- package/dist/commands/search.d.ts +2 -0
- package/dist/commands/search.js +34 -0
- package/dist/commands/settle.d.ts +124 -0
- package/dist/commands/settle.js +475 -0
- package/dist/commands/update.d.ts +2 -0
- package/dist/commands/update.js +37 -0
- package/dist/commands/whoami.d.ts +2 -0
- package/dist/commands/whoami.js +75 -0
- package/dist/lib/environment/agent-folders.d.ts +14 -0
- package/dist/lib/environment/agent-folders.js +11 -0
- package/dist/lib/environment/archive.d.ts +26 -0
- package/dist/lib/environment/archive.js +91 -0
- package/dist/lib/environment/builtins.d.ts +112 -0
- package/dist/lib/environment/builtins.js +539 -0
- package/dist/lib/environment/citations.d.ts +75 -0
- package/dist/lib/environment/citations.js +267 -0
- package/dist/lib/environment/exports.d.ts +190 -0
- package/dist/lib/environment/exports.js +1029 -0
- package/dist/lib/environment/format.d.ts +133 -0
- package/dist/lib/environment/format.js +651 -0
- package/dist/lib/environment/git-source.d.ts +41 -0
- package/dist/lib/environment/git-source.js +159 -0
- package/dist/lib/environment/index.d.ts +20 -0
- package/dist/lib/environment/index.js +27 -0
- package/dist/lib/environment/install.d.ts +140 -0
- package/dist/lib/environment/install.js +694 -0
- package/dist/lib/environment/layout.d.ts +15 -0
- package/dist/lib/environment/layout.js +50 -0
- package/dist/lib/environment/lock.d.ts +87 -0
- package/dist/lib/environment/lock.js +305 -0
- package/dist/lib/environment/marker.d.ts +15 -0
- package/dist/lib/environment/marker.js +31 -0
- package/dist/lib/environment/own-paths.d.ts +59 -0
- package/dist/lib/environment/own-paths.js +174 -0
- package/dist/lib/environment/placed-record.d.ts +32 -0
- package/dist/lib/environment/placed-record.js +72 -0
- package/dist/lib/environment/registries.d.ts +25 -0
- package/dist/lib/environment/registries.js +75 -0
- package/dist/lib/environment/registry.d.ts +173 -0
- package/dist/lib/environment/registry.js +390 -0
- package/dist/lib/environment/requests.d.ts +108 -0
- package/dist/lib/environment/requests.js +403 -0
- package/dist/lib/environment/resolve.d.ts +70 -0
- package/dist/lib/environment/resolve.js +451 -0
- package/dist/lib/environment/semver.d.ts +30 -0
- package/dist/lib/environment/semver.js +130 -0
- package/dist/lib/environment/store.d.ts +23 -0
- package/dist/lib/environment/store.js +123 -0
- package/dist/lib/environment/tar.d.ts +27 -0
- package/dist/lib/environment/tar.js +219 -0
- package/dist/lib/files.d.ts +66 -0
- package/dist/lib/files.js +233 -0
- package/dist/lib/git-host.d.ts +579 -0
- package/dist/lib/git-host.js +1363 -0
- package/dist/lib/home-file.d.ts +124 -0
- package/dist/lib/home-file.js +288 -0
- package/dist/lib/instance.d.ts +63 -0
- package/dist/lib/instance.js +130 -0
- package/dist/lib/words.d.ts +32 -0
- package/dist/lib/words.js +27 -0
- package/dist/lint.js +8 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +7 -0
- package/dist/testing/standin-registry.d.ts +94 -0
- package/dist/testing/standin-registry.js +449 -0
- package/package.json +37 -3
- package/dist/attached-cli.d.ts +0 -13
- package/dist/attached-cli.js +0 -249
- package/dist/attached-client.d.ts +0 -53
- package/dist/attached-client.js +0 -237
- package/dist/generated-protocol.d.ts +0 -2
- package/dist/generated-protocol.js +0 -6
- package/dist/package-init.d.ts +0 -21
- package/dist/package-init.js +0 -442
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface GitCredential {
|
|
2
|
+
username: string;
|
|
3
|
+
secret: string;
|
|
4
|
+
/** A brokered credential's permitted HTTP(S) origin, retained for its helper. */
|
|
5
|
+
origin?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface GitSource {
|
|
8
|
+
/** Fetch a repository at a branch, tag or commit; returns the commit
|
|
9
|
+
* and a folder holding its tree. */
|
|
10
|
+
fetch(repo: string, rev: string, credential?: GitCredential): Promise<{
|
|
11
|
+
commit: string;
|
|
12
|
+
dir: string;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
export interface GitRun {
|
|
16
|
+
code: number | null;
|
|
17
|
+
stdout: Buffer;
|
|
18
|
+
stderr: string;
|
|
19
|
+
}
|
|
20
|
+
export type RunGit = (args: string[], options?: {
|
|
21
|
+
env?: NodeJS.ProcessEnv;
|
|
22
|
+
}) => Promise<GitRun>;
|
|
23
|
+
/** How a credential reaches Git: extra `-c` arguments and variables,
|
|
24
|
+
* and what removes them after (as `withGitCredential` does). */
|
|
25
|
+
export type CredentialArgs = (credential: GitCredential) => Promise<{
|
|
26
|
+
env: Record<string, string>;
|
|
27
|
+
configArgs: string[];
|
|
28
|
+
dispose: () => Promise<void> | void;
|
|
29
|
+
}>;
|
|
30
|
+
export declare class GitSourceError extends Error {
|
|
31
|
+
readonly repo: string;
|
|
32
|
+
readonly run?: GitRun | undefined;
|
|
33
|
+
constructor(repo: string, message: string, run?: GitRun | undefined);
|
|
34
|
+
}
|
|
35
|
+
export declare const defaultRunGit: RunGit;
|
|
36
|
+
export interface GitSourceOptions {
|
|
37
|
+
runGit?: RunGit;
|
|
38
|
+
credentialArgs?: CredentialArgs;
|
|
39
|
+
}
|
|
40
|
+
/** A Git source caching under `<cacheDir>/git/` and `<cacheDir>/git-trees/`. */
|
|
41
|
+
export declare function gitSource(cacheDir: string, options?: GitSourceOptions): GitSource;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
// The Git source (environments-13): a repository fetched at a branch,
|
|
4
|
+
// tag or commit into a bare mirror under `cache/git/`, and the commit's
|
|
5
|
+
// tree exported once under `cache/git-trees/<commit>`. Resolution reads
|
|
6
|
+
// the manifest there and digests every file; installing reads the same
|
|
7
|
+
// tree at the locked commit. The tree is the repository's own: Git converts
|
|
8
|
+
// line endings only as the repository's attributes direct, never as this
|
|
9
|
+
// device is set, so the lock's digests match on every device
|
|
10
|
+
// (environments-45). A credential, where one is given, reaches Git only
|
|
11
|
+
// through the caller's credential arguments.
|
|
12
|
+
import { spawn } from "node:child_process";
|
|
13
|
+
import { randomUUID } from "node:crypto";
|
|
14
|
+
import { existsSync, mkdirSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
15
|
+
import { dirname, join } from "node:path";
|
|
16
|
+
import { sha256Hex } from "./format.js";
|
|
17
|
+
import { readTar } from "./tar.js";
|
|
18
|
+
export class GitSourceError extends Error {
|
|
19
|
+
repo;
|
|
20
|
+
run;
|
|
21
|
+
constructor(repo, message, run) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.repo = repo;
|
|
24
|
+
this.run = run;
|
|
25
|
+
this.name = "GitSourceError";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export const defaultRunGit = (args, options = {}) => new Promise((resolve, reject) => {
|
|
29
|
+
// Git for Windows otherwise rejects pack/ref files below long cache roots.
|
|
30
|
+
// Keep this on the command, never in the user's or mirror's configuration.
|
|
31
|
+
const commandArgs = process.platform === "win32" ? ["-c", "core.longpaths=true", ...args] : args;
|
|
32
|
+
const child = spawn("git", commandArgs, {
|
|
33
|
+
env: {
|
|
34
|
+
...process.env,
|
|
35
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
36
|
+
GIT_ASKPASS: "",
|
|
37
|
+
SSH_ASKPASS: "",
|
|
38
|
+
LC_ALL: "C",
|
|
39
|
+
LANG: "C",
|
|
40
|
+
...(process.env.GIT_SSH_COMMAND ? {} : { GIT_SSH_COMMAND: "ssh -oBatchMode=yes" }),
|
|
41
|
+
...(options.env ?? {}),
|
|
42
|
+
},
|
|
43
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
44
|
+
});
|
|
45
|
+
const stdout = [];
|
|
46
|
+
const stderr = [];
|
|
47
|
+
child.stdout.on("data", (chunk) => stdout.push(chunk));
|
|
48
|
+
child.stderr.on("data", (chunk) => stderr.push(chunk));
|
|
49
|
+
child.on("error", reject);
|
|
50
|
+
child.on("close", (code) => resolve({ code, stdout: Buffer.concat(stdout), stderr: Buffer.concat(stderr).toString("utf8") }));
|
|
51
|
+
});
|
|
52
|
+
const COMMIT_RE = /^[0-9a-f]{40}(?:[0-9a-f]{24})?$/;
|
|
53
|
+
/** A Git source caching under `<cacheDir>/git/` and `<cacheDir>/git-trees/`. */
|
|
54
|
+
export function gitSource(cacheDir, options = {}) {
|
|
55
|
+
const runGit = options.runGit ?? defaultRunGit;
|
|
56
|
+
const mirrors = join(cacheDir, "git");
|
|
57
|
+
const trees = join(cacheDir, "git-trees");
|
|
58
|
+
async function withCredential(credential, body) {
|
|
59
|
+
if (!credential || !options.credentialArgs)
|
|
60
|
+
return body([], {});
|
|
61
|
+
const prepared = await options.credentialArgs(credential);
|
|
62
|
+
try {
|
|
63
|
+
return await body(prepared.configArgs, prepared.env);
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
await prepared.dispose();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function git(repo, args, env = {}) {
|
|
70
|
+
const run = await runGit(args, { env });
|
|
71
|
+
if (run.code !== 0)
|
|
72
|
+
throw new GitSourceError(repo, `git ${args.find((arg) => !arg.startsWith("-") && !arg.includes("=")) ?? ""} failed for ${repo}: ${run.stderr.trim() || `exit ${run.code}`}`, run);
|
|
73
|
+
return run.stdout;
|
|
74
|
+
}
|
|
75
|
+
async function revParse(mirror, rev) {
|
|
76
|
+
const candidates = rev.startsWith("refs/") ? [rev] : [`refs/heads/${rev}`, `refs/tags/${rev}`, rev];
|
|
77
|
+
for (const candidate of candidates) {
|
|
78
|
+
const run = await runGit(["-C", mirror, "rev-parse", "--verify", "--quiet", `${candidate}^{commit}`]);
|
|
79
|
+
if (run.code === 0)
|
|
80
|
+
return run.stdout.toString("utf8").trim();
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
async function exportTree(repo, mirror, commit) {
|
|
85
|
+
const dir = join(trees, commit);
|
|
86
|
+
if (existsSync(dir))
|
|
87
|
+
return dir;
|
|
88
|
+
// `git archive` applies this device's core.autocrlf and core.eol even
|
|
89
|
+
// from a bare mirror; the digests are of the repository's own bytes, so
|
|
90
|
+
// neither applies, and only the repository's own attributes do.
|
|
91
|
+
const tar = await git(repo, ["-c", "core.autocrlf=false", "-c", "core.eol=lf", "-C", mirror, "archive", "--format=tar", commit]);
|
|
92
|
+
const staging = join(trees, `.${commit}.${randomUUID()}`);
|
|
93
|
+
mkdirSync(staging, { recursive: true });
|
|
94
|
+
try {
|
|
95
|
+
for (const entry of readTar(new Uint8Array(tar))) {
|
|
96
|
+
const target = join(staging, ...entry.path.split("/"));
|
|
97
|
+
if (entry.type === "directory") {
|
|
98
|
+
mkdirSync(target, { recursive: true });
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
102
|
+
if (entry.type === "symlink")
|
|
103
|
+
symlinkSync(entry.linkname ?? "", target);
|
|
104
|
+
else if (entry.type === "file")
|
|
105
|
+
writeFileSync(target, entry.data, { mode: entry.mode & 0o100 ? 0o755 : 0o644 });
|
|
106
|
+
}
|
|
107
|
+
if (existsSync(dir))
|
|
108
|
+
rmSync(staging, { recursive: true, force: true });
|
|
109
|
+
else
|
|
110
|
+
renameSync(staging, dir);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
rmSync(staging, { recursive: true, force: true });
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
return dir;
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
async fetch(repo, rev, credential) {
|
|
120
|
+
if (rev.startsWith("-"))
|
|
121
|
+
throw new GitSourceError(repo, `"${rev}" is not a branch, tag or commit`);
|
|
122
|
+
const mirror = join(mirrors, sha256Hex(repo));
|
|
123
|
+
return withCredential(credential, async (config, env) => {
|
|
124
|
+
if (!existsSync(join(mirror, "HEAD"))) {
|
|
125
|
+
mkdirSync(mirrors, { recursive: true });
|
|
126
|
+
const staging = `${mirror}.${randomUUID()}`;
|
|
127
|
+
try {
|
|
128
|
+
await git(repo, [...config, "clone", "--mirror", "--quiet", "--", repo, staging], env);
|
|
129
|
+
if (existsSync(join(mirror, "HEAD")))
|
|
130
|
+
rmSync(staging, { recursive: true, force: true });
|
|
131
|
+
else {
|
|
132
|
+
rmSync(mirror, { recursive: true, force: true });
|
|
133
|
+
renameSync(staging, mirror);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
rmSync(staging, { recursive: true, force: true });
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else if (!(COMMIT_RE.test(rev) && (await revParse(mirror, rev)))) {
|
|
142
|
+
// A branch or tag moves; a commit already held does not.
|
|
143
|
+
await git(repo, [...config, "-C", mirror, "fetch", "--prune", "--quiet", "origin"], env);
|
|
144
|
+
}
|
|
145
|
+
let commit = await revParse(mirror, rev);
|
|
146
|
+
if (!commit && /^[0-9a-f]{7,64}$/.test(rev)) {
|
|
147
|
+
// A commit no ref names: ask for it by id.
|
|
148
|
+
const run = await runGit([...config, "-C", mirror, "fetch", "--quiet", "origin", rev], { env });
|
|
149
|
+
if (run.code === 0)
|
|
150
|
+
commit = await revParse(mirror, rev);
|
|
151
|
+
}
|
|
152
|
+
if (!commit)
|
|
153
|
+
throw new GitSourceError(repo, `${repo} has no branch, tag or commit "${rev}"`);
|
|
154
|
+
return { commit, dir: await exportTree(repo, mirror, commit) };
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=git-source.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from "./format.js";
|
|
2
|
+
export * from "./semver.js";
|
|
3
|
+
export * from "./requests.js";
|
|
4
|
+
export * from "./lock.js";
|
|
5
|
+
export * from "./registry.js";
|
|
6
|
+
export * from "./registries.js";
|
|
7
|
+
export * from "./git-source.js";
|
|
8
|
+
export * from "./resolve.js";
|
|
9
|
+
export * from "./store.js";
|
|
10
|
+
export * from "./layout.js";
|
|
11
|
+
export * from "./install.js";
|
|
12
|
+
export * from "./placed-record.js";
|
|
13
|
+
export * from "./marker.js";
|
|
14
|
+
export * from "./exports.js";
|
|
15
|
+
export * from "./own-paths.js";
|
|
16
|
+
export * from "./agent-folders.js";
|
|
17
|
+
export * from "./archive.js";
|
|
18
|
+
export * from "./tar.js";
|
|
19
|
+
export * from "./citations.js";
|
|
20
|
+
export { builtinLock, stagedBuiltinPackage, prepareBuiltinEnvironment, prepareProjectEnvironment, rehomeBuiltinLock, builtinRegistrySource, compositeRegistry, ensureBuiltinRequest, seedBuiltinPackage, type BuiltinPackage, type BuiltinRelease, type BuiltinSourceOptions, } from "./builtins.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
// Spec packages and environments (DR-104): the format, requests and
|
|
4
|
+
// lock, the registry and Git sources, resolution, the store and
|
|
5
|
+
// installs, exports, the placed specs' record and marker, citations across a
|
|
6
|
+
// release's boundary (DR-174) and the built-in spec package.
|
|
7
|
+
export * from "./format.js";
|
|
8
|
+
export * from "./semver.js";
|
|
9
|
+
export * from "./requests.js";
|
|
10
|
+
export * from "./lock.js";
|
|
11
|
+
export * from "./registry.js";
|
|
12
|
+
export * from "./registries.js";
|
|
13
|
+
export * from "./git-source.js";
|
|
14
|
+
export * from "./resolve.js";
|
|
15
|
+
export * from "./store.js";
|
|
16
|
+
export * from "./layout.js";
|
|
17
|
+
export * from "./install.js";
|
|
18
|
+
export * from "./placed-record.js";
|
|
19
|
+
export * from "./marker.js";
|
|
20
|
+
export * from "./exports.js";
|
|
21
|
+
export * from "./own-paths.js";
|
|
22
|
+
export * from "./agent-folders.js";
|
|
23
|
+
export * from "./archive.js";
|
|
24
|
+
export * from "./tar.js";
|
|
25
|
+
export * from "./citations.js";
|
|
26
|
+
export { builtinLock, stagedBuiltinPackage, prepareBuiltinEnvironment, prepareProjectEnvironment, rehomeBuiltinLock, builtinRegistrySource, compositeRegistry, ensureBuiltinRequest, seedBuiltinPackage, } from "./builtins.js";
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { type FileVersion } from "../files.js";
|
|
2
|
+
import type { GitCredential, GitSource } from "./git-source.js";
|
|
3
|
+
import { type Lock, type RegistrySourceLock } from "./lock.js";
|
|
4
|
+
import { type OwnPathIssue } from "./own-paths.js";
|
|
5
|
+
import { type RegistrySource } from "./registry.js";
|
|
6
|
+
import { type ContentStore } from "./store.js";
|
|
7
|
+
/** Where a working folder's Git is told to ignore every playbook
|
|
8
|
+
* artifact folder's engine links (playbook-library-12): a release-layout
|
|
9
|
+
* `playbooks/<language>/<id>/` folder anywhere in it. */
|
|
10
|
+
export declare const ENGINE_LINKS_EXCLUDE = "**/playbooks/*/*/node_modules/";
|
|
11
|
+
/** A host's engine (DR-165): how an installed playbook artifact's folder
|
|
12
|
+
* is prepared to run on it. */
|
|
13
|
+
export interface InstallEngine {
|
|
14
|
+
/** Prepare an installed playbook artifact's folder, its id given:
|
|
15
|
+
* why a module was kept as it is, or null. */
|
|
16
|
+
prepare(folder: string, id: string): Promise<string | null>;
|
|
17
|
+
/** Give a path source's playbook folder the engine links, its files
|
|
18
|
+
* left as they are. */
|
|
19
|
+
link(folder: string): void;
|
|
20
|
+
}
|
|
21
|
+
export interface InstallOptions {
|
|
22
|
+
/** The environment's root (environments-26): its `.spex/` holds the
|
|
23
|
+
* installed files. */
|
|
24
|
+
root: string;
|
|
25
|
+
lock: Lock;
|
|
26
|
+
/** The version of `spex.lock` this lock was read as or written as —
|
|
27
|
+
* null where none stands: a lock on disk at any other version by the
|
|
28
|
+
* swap refuses it (DR-111). */
|
|
29
|
+
lockVersion: FileVersion;
|
|
30
|
+
store: ContentStore;
|
|
31
|
+
/** The home's `cache/` folder. */
|
|
32
|
+
cache: string;
|
|
33
|
+
registry: RegistrySource;
|
|
34
|
+
/** The registries asked for a registry source's files, in order
|
|
35
|
+
* (environments-7): the first serving its release at the locked
|
|
36
|
+
* version and checksum serves them. `[registry]` where omitted. */
|
|
37
|
+
registries?: (source: RegistrySourceLock) => readonly RegistrySource[];
|
|
38
|
+
/** This device's seed of the built-in spec package (environments-11),
|
|
39
|
+
* asked first for its locked release: it serves where it holds the
|
|
40
|
+
* locked version with each locked file at the lock's digest, whatever
|
|
41
|
+
* archive checksum the lock records (environments-7). */
|
|
42
|
+
seed?: RegistrySource;
|
|
43
|
+
/** Where no seed and no registry serves the built-in spec package's
|
|
44
|
+
* locked release (environments-7): `fail`, the default, fails the
|
|
45
|
+
* install naming it; `leave` leaves it out as not installed, for the
|
|
46
|
+
* app's next use to install from its seed, and installs the rest. */
|
|
47
|
+
builtinUnserved?: "fail" | "leave";
|
|
48
|
+
git: GitSource;
|
|
49
|
+
gitCredential?: (repo: string) => Promise<GitCredential | undefined>;
|
|
50
|
+
/** The folder a path source's path is relative to (environments-2):
|
|
51
|
+
* the paired working folder's root, or your own group's clone's; null
|
|
52
|
+
* where this device has none. */
|
|
53
|
+
pathRoot: string | null;
|
|
54
|
+
/** Whether `pathRoot` is your own group's clone, whose path sources
|
|
55
|
+
* hold only what its sync carries (environments-32). */
|
|
56
|
+
confined?: boolean;
|
|
57
|
+
/** `spex.yaml`'s text; read from the root when omitted. */
|
|
58
|
+
requestsText?: string | null;
|
|
59
|
+
/** The host's engine; with none, nothing is prepared or linked. */
|
|
60
|
+
engine?: InstallEngine;
|
|
61
|
+
/** Test seam: runs after every file is fetched and staged, before
|
|
62
|
+
* the new tree replaces the old. */
|
|
63
|
+
beforeReplace?: () => void | Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
export interface InstallReport {
|
|
66
|
+
/** The spec packages whose files this install placed. */
|
|
67
|
+
installed: string[];
|
|
68
|
+
/** Path sources this device lacks where their paths resolve. */
|
|
69
|
+
missingPaths: string[];
|
|
70
|
+
/** Why the lock is stale, where it is: nothing new was installed. */
|
|
71
|
+
stale?: string[];
|
|
72
|
+
/** True when the installed files already matched the lock. */
|
|
73
|
+
unchanged: boolean;
|
|
74
|
+
/** Registry modules left carrying the engine they were bundled with,
|
|
75
|
+
* each with why (playbook-library-46). */
|
|
76
|
+
engineKept: {
|
|
77
|
+
module: string;
|
|
78
|
+
reason: string;
|
|
79
|
+
}[];
|
|
80
|
+
/** The built-in spec package, where this install left it out as not
|
|
81
|
+
* installed, no seed and no registry serving it (environments-7);
|
|
82
|
+
* absent where nothing was left out. */
|
|
83
|
+
left?: string[];
|
|
84
|
+
}
|
|
85
|
+
export declare class InstallError extends Error {
|
|
86
|
+
readonly packageName: string | undefined;
|
|
87
|
+
readonly cause?: unknown;
|
|
88
|
+
/** The folder your own group's clone refuses, with its reason, for a
|
|
89
|
+
* host to phrase (environments-32). */
|
|
90
|
+
readonly confined?: {
|
|
91
|
+
path: string;
|
|
92
|
+
issue: OwnPathIssue;
|
|
93
|
+
} | undefined;
|
|
94
|
+
constructor(packageName: string | undefined, message: string, cause?: unknown,
|
|
95
|
+
/** The folder your own group's clone refuses, with its reason, for a
|
|
96
|
+
* host to phrase (environments-32). */
|
|
97
|
+
confined?: {
|
|
98
|
+
path: string;
|
|
99
|
+
issue: OwnPathIssue;
|
|
100
|
+
} | undefined);
|
|
101
|
+
}
|
|
102
|
+
/** The installed tree's record of what it holds, beside the packages. */
|
|
103
|
+
export declare const INSTALL_RECORD = ".spex-install.json";
|
|
104
|
+
/** The path sources of a lock this device lacks where their paths
|
|
105
|
+
* resolve (environments-7). */
|
|
106
|
+
export declare function missingPathSources(lock: Lock, pathRoot: string | null): string[];
|
|
107
|
+
/** The registry and Git packages the install record holds as the lock
|
|
108
|
+
* locks them, whether or not every file still stands: one recorded here
|
|
109
|
+
* that `installedPackages` lacks has files missing (environments-14). */
|
|
110
|
+
export declare function recordedPackages(root: string, lock: Lock): Set<string>;
|
|
111
|
+
/** The registry and Git sources of a lock whose files stand installed
|
|
112
|
+
* under the root's `.spex/` as the lock locks them: recorded by the
|
|
113
|
+
* install that placed them, the same source, files and artifacts, every
|
|
114
|
+
* file there. */
|
|
115
|
+
export declare function installedPackages(root: string, lock: Lock): Set<string>;
|
|
116
|
+
/** Install a lock's selected files (environments-7). */
|
|
117
|
+
export declare function install(options: InstallOptions): Promise<InstallReport>;
|
|
118
|
+
/** Remove every installed file of an environment (one emptied). */
|
|
119
|
+
export declare function removeInstalled(root: string): void;
|
|
120
|
+
export interface PrepareOptions {
|
|
121
|
+
root: string;
|
|
122
|
+
lock: Lock;
|
|
123
|
+
/** The folder a path source's path is relative to (environments-2). */
|
|
124
|
+
pathRoot: string | null;
|
|
125
|
+
/** Whether `pathRoot` is your own group's clone (environments-32). */
|
|
126
|
+
confined?: boolean;
|
|
127
|
+
engine: InstallEngine;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Prepare an environment's playbook artifact folders to run on the
|
|
131
|
+
* host's engine at a use that hands the launcher module locations
|
|
132
|
+
* (environments-7, environments-9, playbook-library-46): each installed
|
|
133
|
+
* as the lock locks it, and each path source's where its path resolves,
|
|
134
|
+
* so a playbook another host installed — the command line prepares
|
|
135
|
+
* none — runs. Nothing here fails the use: a folder that cannot be
|
|
136
|
+
* prepared is logged and left; a path source's links are made only once
|
|
137
|
+
* its Git lists them, your own group's clone otherwise taking none.
|
|
138
|
+
* Returns the registry modules kept carrying their own engine.
|
|
139
|
+
*/
|
|
140
|
+
export declare function prepareEnvironment(options: PrepareOptions): Promise<InstallReport["engineKept"]>;
|