@cyaxis/ulvia 0.1.0-beta → 0.1.0-beta.1
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/INSTALLATION.md +160 -96
- package/README.md +39 -4
- package/dist/index.js +760 -293
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25006,6 +25006,80 @@ function freezeRecord(admission, publishedAt, deprecation, yank) {
|
|
|
25006
25006
|
...yank ? { yank } : {}
|
|
25007
25007
|
});
|
|
25008
25008
|
}
|
|
25009
|
+
// packages/features/cms-repository/src/contracts/core/catalogue/planPublications.ts
|
|
25010
|
+
var PLANNED_AT = "1970-01-01T00:00:00.000Z";
|
|
25011
|
+
async function planContractPublications(catalogue, admissions, limits = DEFAULT_RELEASE_LIMITS) {
|
|
25012
|
+
const snapshotLimits = Object.freeze({ ...limits });
|
|
25013
|
+
const verified = await Promise.all(admissions.map((admission) => verifyAdmission(admission, snapshotLimits)));
|
|
25014
|
+
const published = [...await catalogue.list()];
|
|
25015
|
+
const planned = [];
|
|
25016
|
+
const candidates = orderCandidatesByLineage(verified);
|
|
25017
|
+
for (const admission of candidates) {
|
|
25018
|
+
const { contractId, version, publisherId } = admission.release;
|
|
25019
|
+
const existing = [...published, ...planned].find((record) => record.admission.release.contractId === contractId && record.admission.release.version === version);
|
|
25020
|
+
if (existing) {
|
|
25021
|
+
if (existing.admission.digest !== admission.digest) {
|
|
25022
|
+
throw new ReleaseValidationError("invalid_contract", `${contractId}@${version} is already published`);
|
|
25023
|
+
}
|
|
25024
|
+
continue;
|
|
25025
|
+
}
|
|
25026
|
+
const digestOwner = [...published, ...planned].find((record) => record.admission.digest === admission.digest);
|
|
25027
|
+
if (digestOwner) {
|
|
25028
|
+
throw new ReleaseValidationError("invalid_contract", "release digest is already assigned", "$.digest");
|
|
25029
|
+
}
|
|
25030
|
+
const historical = [...published, ...planned].find((record) => record.admission.release.contractId === contractId);
|
|
25031
|
+
if (historical && historical.admission.release.publisherId !== publisherId) {
|
|
25032
|
+
throw new ReleaseValidationError("invalid_contract", "publisher ownership cannot change between releases", "$.publisherId");
|
|
25033
|
+
}
|
|
25034
|
+
verifyEvolution(admission.release, [...published, ...planned], snapshotLimits);
|
|
25035
|
+
verifySpecialization(admission.release, [...published, ...planned]);
|
|
25036
|
+
planned.push(Object.freeze({ admission, publishedAt: PLANNED_AT }));
|
|
25037
|
+
}
|
|
25038
|
+
const complete = [...published, ...planned];
|
|
25039
|
+
for (const record of planned) {
|
|
25040
|
+
verifyRequirements2(record.admission.release, complete);
|
|
25041
|
+
}
|
|
25042
|
+
return orderByRequirements(planned, published);
|
|
25043
|
+
}
|
|
25044
|
+
function orderCandidatesByLineage(admissions) {
|
|
25045
|
+
const pending = [...admissions];
|
|
25046
|
+
const ordered = [];
|
|
25047
|
+
while (pending.length > 0) {
|
|
25048
|
+
const pendingIds = new Set(pending.map(({ release }) => release.contractId));
|
|
25049
|
+
const ready = pending.filter(({ release }) => !release.extends || !pendingIds.has(release.extends.contractId)).sort((left, right) => compareSemVer(left.release.version, right.release.version));
|
|
25050
|
+
if (ready.length === 0) {
|
|
25051
|
+
throw new ReleaseValidationError("invalid_contract", "contract inheritance contains a cycle");
|
|
25052
|
+
}
|
|
25053
|
+
for (const admission of ready) {
|
|
25054
|
+
pending.splice(pending.indexOf(admission), 1);
|
|
25055
|
+
ordered.push(admission);
|
|
25056
|
+
}
|
|
25057
|
+
}
|
|
25058
|
+
return ordered;
|
|
25059
|
+
}
|
|
25060
|
+
function orderByRequirements(planned, published) {
|
|
25061
|
+
const pending = [...planned];
|
|
25062
|
+
const available = [...published];
|
|
25063
|
+
const ordered = [];
|
|
25064
|
+
while (pending.length > 0) {
|
|
25065
|
+
const index = pending.findIndex((record) => {
|
|
25066
|
+
try {
|
|
25067
|
+
verifyRequirements2(record.admission.release, available);
|
|
25068
|
+
return true;
|
|
25069
|
+
} catch {
|
|
25070
|
+
return false;
|
|
25071
|
+
}
|
|
25072
|
+
});
|
|
25073
|
+
if (index === -1) {
|
|
25074
|
+
verifyRequirements2(pending[0].admission.release, available);
|
|
25075
|
+
throw new ReleaseValidationError("invalid_contract", "cyclic staged contract requirements");
|
|
25076
|
+
}
|
|
25077
|
+
const [record] = pending.splice(index, 1);
|
|
25078
|
+
available.push(record);
|
|
25079
|
+
ordered.push(record.admission);
|
|
25080
|
+
}
|
|
25081
|
+
return Object.freeze(ordered);
|
|
25082
|
+
}
|
|
25009
25083
|
// packages/features/cms-repository/src/repository/filesystem/contracts.ts
|
|
25010
25084
|
class LocalContractReleases {
|
|
25011
25085
|
files;
|
|
@@ -25867,6 +25941,21 @@ function assertRepositoryNamespace(namespace) {
|
|
|
25867
25941
|
throw new RepositoryRequestError("REJECTED", "Invalid repository namespace");
|
|
25868
25942
|
}
|
|
25869
25943
|
}
|
|
25944
|
+
function namespacePublicKey(encoded) {
|
|
25945
|
+
if (!/^[A-Za-z0-9_-]{59}$/u.test(encoded)) {
|
|
25946
|
+
throw new RepositoryRequestError("REJECTED", "Invalid namespace public key");
|
|
25947
|
+
}
|
|
25948
|
+
let key;
|
|
25949
|
+
try {
|
|
25950
|
+
key = createPublicKey({ key: Buffer.from(encoded, "base64url"), format: "der", type: "spki" });
|
|
25951
|
+
} catch {
|
|
25952
|
+
throw new RepositoryRequestError("REJECTED", "Invalid namespace public key");
|
|
25953
|
+
}
|
|
25954
|
+
if (key.asymmetricKeyType !== "ed25519" || key.export({ format: "der", type: "spki" }).toString("base64url") !== encoded) {
|
|
25955
|
+
throw new RepositoryRequestError("REJECTED", "Namespace keys must use canonical Ed25519 SPKI");
|
|
25956
|
+
}
|
|
25957
|
+
return key;
|
|
25958
|
+
}
|
|
25870
25959
|
function repositoryDigest(value) {
|
|
25871
25960
|
return `sha256:${createHash6("sha256").update(canonicalIJsonBytes(value)).digest("hex")}`;
|
|
25872
25961
|
}
|
|
@@ -26862,8 +26951,8 @@ function localKernelEnvironment(instance, config, connection, services, image) {
|
|
|
26862
26951
|
}
|
|
26863
26952
|
|
|
26864
26953
|
// packages/runtimes/ulvia-cli/src/runtime/stack/version.ts
|
|
26865
|
-
var injectedCliVersion = "0.1.0-beta";
|
|
26866
|
-
var injectedStackVersion = "0.1.0-beta";
|
|
26954
|
+
var injectedCliVersion = "0.1.0-beta.1";
|
|
26955
|
+
var injectedStackVersion = "0.1.0-beta.1";
|
|
26867
26956
|
var CLI_VERSION = injectedCliVersion ?? "development";
|
|
26868
26957
|
var DEFAULT_STACK_VERSION = injectedStackVersion ?? "unbundled";
|
|
26869
26958
|
function defaultStackVersion() {
|
|
@@ -28170,8 +28259,11 @@ async function pruneCommand(args, repository, log) {
|
|
|
28170
28259
|
log("Local repository cleared");
|
|
28171
28260
|
}
|
|
28172
28261
|
|
|
28173
|
-
// packages/runtimes/ulvia-cli/src/commands/release.ts
|
|
28174
|
-
import {
|
|
28262
|
+
// packages/runtimes/ulvia-cli/src/commands/release/index.ts
|
|
28263
|
+
import { resolve as resolve6 } from "path";
|
|
28264
|
+
|
|
28265
|
+
// packages/runtimes/ulvia-cli/src/commands/release/resource.ts
|
|
28266
|
+
import { basename as basename6, join as join32 } from "path";
|
|
28175
28267
|
|
|
28176
28268
|
// packages/runtimes/ulvia-cli/src/release/authored/conformance.ts
|
|
28177
28269
|
import { readFile as readFile16 } from "fs/promises";
|
|
@@ -28185,42 +28277,11 @@ import { readdir as readdir10 } from "fs/promises";
|
|
|
28185
28277
|
import { join as join20 } from "path";
|
|
28186
28278
|
var MAX_TREE_DEPTH = 16;
|
|
28187
28279
|
var MAX_JSON_FILES = 2048;
|
|
28188
|
-
var MAX_SOURCE_FILES = 2048;
|
|
28189
|
-
async function scanFileSourceTree(root) {
|
|
28190
|
-
const files = [];
|
|
28191
|
-
await visitFileTree(root, root, 0, files).catch((error) => {
|
|
28192
|
-
if (error.code !== "ENOENT") {
|
|
28193
|
-
throw error;
|
|
28194
|
-
}
|
|
28195
|
-
});
|
|
28196
|
-
return files.sort((left, right) => left.relativePath.localeCompare(right.relativePath));
|
|
28197
|
-
}
|
|
28198
28280
|
async function scanJsonSourceTree(root, excludedRootFiles = new Set) {
|
|
28199
28281
|
const files = [];
|
|
28200
28282
|
await visitJsonTree(root, root, 0, excludedRootFiles, files);
|
|
28201
28283
|
return files.sort((left, right) => left.relativePath.localeCompare(right.relativePath));
|
|
28202
28284
|
}
|
|
28203
|
-
async function visitFileTree(root, directory, depth, files) {
|
|
28204
|
-
if (depth > MAX_TREE_DEPTH) {
|
|
28205
|
-
throw new Error(`Source tree must not exceed ${MAX_TREE_DEPTH} directory levels`);
|
|
28206
|
-
}
|
|
28207
|
-
for (const entry of await readSourceEntries(directory)) {
|
|
28208
|
-
const absolutePath = join20(directory, entry.name);
|
|
28209
|
-
const relativePath = absolutePath.slice(root.length + 1).replaceAll("\\", "/");
|
|
28210
|
-
if (entry.isDirectory()) {
|
|
28211
|
-
await visitFileTree(root, absolutePath, depth + 1, files);
|
|
28212
|
-
} else if (entry.isFile()) {
|
|
28213
|
-
if (entry.name !== ".gitkeep") {
|
|
28214
|
-
files.push({ absolutePath, relativePath });
|
|
28215
|
-
}
|
|
28216
|
-
} else {
|
|
28217
|
-
throw new Error(`Unsupported entry in source tree: ${relativePath}`);
|
|
28218
|
-
}
|
|
28219
|
-
if (files.length > MAX_SOURCE_FILES) {
|
|
28220
|
-
throw new Error(`Source tree must contain at most ${MAX_SOURCE_FILES} files`);
|
|
28221
|
-
}
|
|
28222
|
-
}
|
|
28223
|
-
}
|
|
28224
28285
|
async function readSourceEntries(directory) {
|
|
28225
28286
|
return (await readdir10(directory, { withFileTypes: true })).sort((left, right) => left.name.localeCompare(right.name));
|
|
28226
28287
|
}
|
|
@@ -28461,13 +28522,6 @@ async function collectMocks(directory, capabilities) {
|
|
|
28461
28522
|
return grouped;
|
|
28462
28523
|
}
|
|
28463
28524
|
|
|
28464
|
-
// packages/runtimes/ulvia-cli/src/release/source.ts
|
|
28465
|
-
import { basename as basename5, dirname as dirname7, join as join30, resolve as resolve5 } from "path";
|
|
28466
|
-
|
|
28467
|
-
// packages/runtimes/ulvia-cli/src/release/blocSources.ts
|
|
28468
|
-
import { stat as stat4 } from "fs/promises";
|
|
28469
|
-
import { join as join26 } from "path";
|
|
28470
|
-
|
|
28471
28525
|
// packages/features/cms-repository/src/collections/tooling/buildCollectionBloc.ts
|
|
28472
28526
|
import { mkdtemp, rm as rm10 } from "fs/promises";
|
|
28473
28527
|
import { tmpdir } from "os";
|
|
@@ -28693,9 +28747,86 @@ function executableSources(source) {
|
|
|
28693
28747
|
source: Buffer.from(contents, "base64").toString("utf8")
|
|
28694
28748
|
}));
|
|
28695
28749
|
}
|
|
28696
|
-
// packages/
|
|
28750
|
+
// packages/features/cms-repository/src/collections/tooling/authoring/source.ts
|
|
28751
|
+
import { basename as basename5, dirname as dirname7, join as join31, resolve as resolve5 } from "path";
|
|
28752
|
+
|
|
28753
|
+
// packages/features/cms-repository/src/collections/tooling/authoring/blocSources.ts
|
|
28754
|
+
import { stat as stat4 } from "fs/promises";
|
|
28755
|
+
import { join as join27 } from "path";
|
|
28756
|
+
|
|
28757
|
+
// packages/features/cms-repository/src/collections/tooling/authoring/blocDiscovery.ts
|
|
28697
28758
|
import { stat as stat3 } from "fs/promises";
|
|
28698
|
-
import { basename as basename2, join as
|
|
28759
|
+
import { basename as basename2, join as join26 } from "path";
|
|
28760
|
+
|
|
28761
|
+
// packages/features/cms-repository/src/collections/tooling/authoring/sourceTree.ts
|
|
28762
|
+
import { readdir as readdir11 } from "fs/promises";
|
|
28763
|
+
import { join as join25 } from "path";
|
|
28764
|
+
var MAX_TREE_DEPTH2 = 16;
|
|
28765
|
+
var MAX_JSON_FILES2 = 2048;
|
|
28766
|
+
var MAX_SOURCE_FILES = 2048;
|
|
28767
|
+
async function scanFileSourceTree(root) {
|
|
28768
|
+
const files = [];
|
|
28769
|
+
await visitFileTree(root, root, 0, files).catch((error) => {
|
|
28770
|
+
if (error.code !== "ENOENT") {
|
|
28771
|
+
throw error;
|
|
28772
|
+
}
|
|
28773
|
+
});
|
|
28774
|
+
return files.sort((left, right) => left.relativePath.localeCompare(right.relativePath));
|
|
28775
|
+
}
|
|
28776
|
+
async function scanJsonSourceTree2(root, excludedRootFiles = new Set) {
|
|
28777
|
+
const files = [];
|
|
28778
|
+
await visitJsonTree2(root, root, 0, excludedRootFiles, files);
|
|
28779
|
+
return files.sort((left, right) => left.relativePath.localeCompare(right.relativePath));
|
|
28780
|
+
}
|
|
28781
|
+
async function visitFileTree(root, directory, depth, files) {
|
|
28782
|
+
if (depth > MAX_TREE_DEPTH2) {
|
|
28783
|
+
throw new Error(`Source tree must not exceed ${MAX_TREE_DEPTH2} directory levels`);
|
|
28784
|
+
}
|
|
28785
|
+
for (const entry of await readSourceEntries2(directory)) {
|
|
28786
|
+
const absolutePath = join25(directory, entry.name);
|
|
28787
|
+
const relativePath = absolutePath.slice(root.length + 1).replaceAll("\\", "/");
|
|
28788
|
+
if (entry.isDirectory()) {
|
|
28789
|
+
await visitFileTree(root, absolutePath, depth + 1, files);
|
|
28790
|
+
} else if (entry.isFile()) {
|
|
28791
|
+
if (entry.name !== ".gitkeep") {
|
|
28792
|
+
files.push({ absolutePath, relativePath });
|
|
28793
|
+
}
|
|
28794
|
+
} else {
|
|
28795
|
+
throw new Error(`Unsupported entry in source tree: ${relativePath}`);
|
|
28796
|
+
}
|
|
28797
|
+
if (files.length > MAX_SOURCE_FILES) {
|
|
28798
|
+
throw new Error(`Source tree must contain at most ${MAX_SOURCE_FILES} files`);
|
|
28799
|
+
}
|
|
28800
|
+
}
|
|
28801
|
+
}
|
|
28802
|
+
async function readSourceEntries2(directory) {
|
|
28803
|
+
return (await readdir11(directory, { withFileTypes: true })).sort((left, right) => left.name.localeCompare(right.name));
|
|
28804
|
+
}
|
|
28805
|
+
async function visitJsonTree2(root, directory, depth, excludedRootFiles, files) {
|
|
28806
|
+
if (depth > MAX_TREE_DEPTH2) {
|
|
28807
|
+
throw new Error(`JSON source tree must not exceed ${MAX_TREE_DEPTH2} directory levels`);
|
|
28808
|
+
}
|
|
28809
|
+
for (const entry of await readSourceEntries2(directory)) {
|
|
28810
|
+
const absolutePath = join25(directory, entry.name);
|
|
28811
|
+
const relativePath = absolutePath.slice(root.length + 1).replaceAll("\\", "/");
|
|
28812
|
+
if (entry.isDirectory()) {
|
|
28813
|
+
await visitJsonTree2(root, absolutePath, depth + 1, excludedRootFiles, files);
|
|
28814
|
+
continue;
|
|
28815
|
+
}
|
|
28816
|
+
if (!entry.isFile() || !entry.name.endsWith(".json")) {
|
|
28817
|
+
throw new Error(`Unsupported entry in JSON source tree: ${relativePath}`);
|
|
28818
|
+
}
|
|
28819
|
+
if (depth === 0 && excludedRootFiles.has(entry.name)) {
|
|
28820
|
+
continue;
|
|
28821
|
+
}
|
|
28822
|
+
files.push({ absolutePath, relativePath });
|
|
28823
|
+
if (files.length > MAX_JSON_FILES2) {
|
|
28824
|
+
throw new Error(`JSON source tree must contain at most ${MAX_JSON_FILES2} files`);
|
|
28825
|
+
}
|
|
28826
|
+
}
|
|
28827
|
+
}
|
|
28828
|
+
|
|
28829
|
+
// packages/features/cms-repository/src/collections/tooling/authoring/blocDiscovery.ts
|
|
28699
28830
|
var MAX_BLOC_DEPTH = 16;
|
|
28700
28831
|
var BLOC_ENTRIES = new Set([
|
|
28701
28832
|
"bloc.ts",
|
|
@@ -28718,11 +28849,11 @@ async function visitBlocSources(base, directory, depth, sources) {
|
|
|
28718
28849
|
if (depth > MAX_BLOC_DEPTH) {
|
|
28719
28850
|
throw new Error(`Bloc source tree must not exceed ${MAX_BLOC_DEPTH} directory levels`);
|
|
28720
28851
|
}
|
|
28721
|
-
const entries = await
|
|
28852
|
+
const entries = await readSourceEntries2(directory);
|
|
28722
28853
|
const definition = entries.find((entry) => entry.name === "definition.json" && entry.isFile());
|
|
28723
28854
|
if (definition) {
|
|
28724
28855
|
const relativePath = directory.slice(base.length + 1).replaceAll("\\", "/");
|
|
28725
|
-
const value = await Bun.file(
|
|
28856
|
+
const value = await Bun.file(join26(directory, definition.name)).json();
|
|
28726
28857
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
28727
28858
|
throw new Error(`Bloc source ${relativePath} requires an object definition with a string id`);
|
|
28728
28859
|
}
|
|
@@ -28742,10 +28873,10 @@ async function visitBlocSources(base, directory, depth, sources) {
|
|
|
28742
28873
|
}
|
|
28743
28874
|
for (const entry of entries) {
|
|
28744
28875
|
if (!entry.isDirectory()) {
|
|
28745
|
-
const path =
|
|
28876
|
+
const path = join26(directory, entry.name).slice(base.length + 1).replaceAll("\\", "/");
|
|
28746
28877
|
throw new Error(`Bloc grouping directories may not contain files: ${path}`);
|
|
28747
28878
|
}
|
|
28748
|
-
await visitBlocSources(base,
|
|
28879
|
+
await visitBlocSources(base, join26(directory, entry.name), depth + 1, sources);
|
|
28749
28880
|
}
|
|
28750
28881
|
}
|
|
28751
28882
|
function validateBlocEntries(entries, relativePath) {
|
|
@@ -28769,7 +28900,7 @@ async function directoryExists(directory) {
|
|
|
28769
28900
|
}
|
|
28770
28901
|
}
|
|
28771
28902
|
|
|
28772
|
-
// packages/
|
|
28903
|
+
// packages/features/cms-repository/src/collections/tooling/authoring/blocSources.ts
|
|
28773
28904
|
async function loadCollectionBlocs(directory) {
|
|
28774
28905
|
const sources = await discoverCollectionBlocSources(directory);
|
|
28775
28906
|
const byId = new Map;
|
|
@@ -28791,17 +28922,17 @@ async function compileBlocSource(source) {
|
|
|
28791
28922
|
if (["markup", "style", "runtime", "defaultContent"].some((key) => Object.hasOwn(definition, key))) {
|
|
28792
28923
|
throw new Error(`Bloc ${id} must keep markup, CSS and JavaScript in separate files`);
|
|
28793
28924
|
}
|
|
28794
|
-
const markupFile = Bun.file(
|
|
28795
|
-
const style = Bun.file(
|
|
28796
|
-
const defaults = Bun.file(
|
|
28797
|
-
const script = Bun.file(
|
|
28798
|
-
const settingsRoot =
|
|
28799
|
-
const runtimeRoot =
|
|
28800
|
-
const settingsFile = Bun.file(
|
|
28925
|
+
const markupFile = Bun.file(join27(root, "markup.html"));
|
|
28926
|
+
const style = Bun.file(join27(root, "style.css"));
|
|
28927
|
+
const defaults = Bun.file(join27(root, "default.html"));
|
|
28928
|
+
const script = Bun.file(join27(root, "bloc.ts"));
|
|
28929
|
+
const settingsRoot = join27(root, "settings");
|
|
28930
|
+
const runtimeRoot = join27(root, "runtime");
|
|
28931
|
+
const settingsFile = Bun.file(join27(settingsRoot, "definition.json"));
|
|
28801
28932
|
const hasSettingsDirectory = await directoryExists2(settingsRoot);
|
|
28802
28933
|
const runtimeSources = await loadRuntimeSources(runtimeRoot, id);
|
|
28803
28934
|
if (hasSettingsDirectory) {
|
|
28804
|
-
const entries = await
|
|
28935
|
+
const entries = await readSourceEntries2(settingsRoot);
|
|
28805
28936
|
if (entries.length !== 1 || entries[0].name !== "definition.json" || !entries[0].isFile()) {
|
|
28806
28937
|
throw new Error(`Bloc ${id} settings must contain only definition.json`);
|
|
28807
28938
|
}
|
|
@@ -28865,8 +28996,8 @@ async function directoryExists2(directory) {
|
|
|
28865
28996
|
}
|
|
28866
28997
|
}
|
|
28867
28998
|
|
|
28868
|
-
// packages/
|
|
28869
|
-
import { basename as basename3, join as
|
|
28999
|
+
// packages/features/cms-repository/src/collections/tooling/authoring/metadataSources.ts
|
|
29000
|
+
import { basename as basename3, join as join28 } from "path";
|
|
28870
29001
|
function expandCollectionSourceExports(value, resources) {
|
|
28871
29002
|
if (value === undefined) {
|
|
28872
29003
|
return;
|
|
@@ -28890,12 +29021,12 @@ function isExportKind(value) {
|
|
|
28890
29021
|
}
|
|
28891
29022
|
async function loadCollectionTranslations(directory) {
|
|
28892
29023
|
const catalogues = [];
|
|
28893
|
-
for (const entry of await
|
|
29024
|
+
for (const entry of await readSourceEntries2(directory)) {
|
|
28894
29025
|
if (!entry.isDirectory()) {
|
|
28895
29026
|
throw new Error(`Translation entry ${entry.name} must be a locale directory`);
|
|
28896
29027
|
}
|
|
28897
|
-
const root =
|
|
28898
|
-
const files = await
|
|
29028
|
+
const root = join28(directory, entry.name);
|
|
29029
|
+
const files = await scanJsonSourceTree2(root);
|
|
28899
29030
|
if (files.length === 0) {
|
|
28900
29031
|
throw new Error(`Translation locale ${entry.name} must contain at least one JSON file`);
|
|
28901
29032
|
}
|
|
@@ -28918,7 +29049,7 @@ async function loadCollectionTranslations(directory) {
|
|
|
28918
29049
|
return Object.fromEntries(catalogues);
|
|
28919
29050
|
}
|
|
28920
29051
|
async function loadCollectionTheme(directory) {
|
|
28921
|
-
const definitionFile = Bun.file(
|
|
29052
|
+
const definitionFile = Bun.file(join28(directory, "definition.json"));
|
|
28922
29053
|
if (!await definitionFile.exists()) {
|
|
28923
29054
|
return;
|
|
28924
29055
|
}
|
|
@@ -28931,7 +29062,7 @@ async function loadCollectionTheme(directory) {
|
|
|
28931
29062
|
throw new Error("Theme category references must be unique lowercase identifiers");
|
|
28932
29063
|
}
|
|
28933
29064
|
const categories = new Map;
|
|
28934
|
-
for (const file of await
|
|
29065
|
+
for (const file of await scanJsonSourceTree2(directory, new Set(["definition.json"]))) {
|
|
28935
29066
|
const category = await Bun.file(file.absolutePath).json();
|
|
28936
29067
|
const id = category.id;
|
|
28937
29068
|
if (typeof id !== "string" || basename3(file.relativePath, ".json") !== id) {
|
|
@@ -28952,19 +29083,19 @@ async function loadCollectionTheme(directory) {
|
|
|
28952
29083
|
return { label: definition.label, categories: orderedIds.map((id) => categories.get(id).value) };
|
|
28953
29084
|
}
|
|
28954
29085
|
|
|
28955
|
-
// packages/
|
|
29086
|
+
// packages/features/cms-repository/src/collections/tooling/authoring/textSources.ts
|
|
28956
29087
|
import { stat as stat5 } from "fs/promises";
|
|
28957
|
-
import { join as
|
|
29088
|
+
import { join as join29 } from "path";
|
|
28958
29089
|
async function loadCollectionTexts(directory) {
|
|
28959
29090
|
if (!await directoryExists3(directory)) {
|
|
28960
29091
|
return [];
|
|
28961
29092
|
}
|
|
28962
|
-
const entries = await
|
|
29093
|
+
const entries = await readSourceEntries2(directory);
|
|
28963
29094
|
if (entries.length !== 2 || entries.some((entry) => !entry.isDirectory() || !["definitions", "locales"].includes(entry.name))) {
|
|
28964
29095
|
throw new Error("Texts source must contain only definitions/ and locales/");
|
|
28965
29096
|
}
|
|
28966
|
-
const definitions = await loadDefinitions(
|
|
28967
|
-
const locales = await loadLocaleValues(
|
|
29097
|
+
const definitions = await loadDefinitions(join29(directory, "definitions"));
|
|
29098
|
+
const locales = await loadLocaleValues(join29(directory, "locales"), definitions);
|
|
28968
29099
|
return [...definitions.entries()].sort(([left], [right]) => left.localeCompare(right)).map(([id, definition]) => ({
|
|
28969
29100
|
...definition.source,
|
|
28970
29101
|
values: Object.fromEntries([...locales.entries()].flatMap(([locale, values]) => {
|
|
@@ -28974,7 +29105,7 @@ async function loadCollectionTexts(directory) {
|
|
|
28974
29105
|
}));
|
|
28975
29106
|
}
|
|
28976
29107
|
async function loadDefinitions(directory) {
|
|
28977
|
-
const files = await
|
|
29108
|
+
const files = await scanJsonSourceTree2(directory);
|
|
28978
29109
|
if (files.length === 0) {
|
|
28979
29110
|
throw new Error("Texts definitions must contain at least one JSON file");
|
|
28980
29111
|
}
|
|
@@ -29003,11 +29134,11 @@ async function loadDefinitions(directory) {
|
|
|
29003
29134
|
}
|
|
29004
29135
|
async function loadLocaleValues(directory, definitions) {
|
|
29005
29136
|
const locales = new Map;
|
|
29006
|
-
for (const entry of await
|
|
29137
|
+
for (const entry of await readSourceEntries2(directory)) {
|
|
29007
29138
|
if (!entry.isDirectory()) {
|
|
29008
29139
|
throw new Error(`Text locale entry ${entry.name} must be a locale directory`);
|
|
29009
29140
|
}
|
|
29010
|
-
const files = await
|
|
29141
|
+
const files = await scanJsonSourceTree2(join29(directory, entry.name));
|
|
29011
29142
|
if (files.length === 0) {
|
|
29012
29143
|
throw new Error(`Text locale ${entry.name} must contain at least one JSON file`);
|
|
29013
29144
|
}
|
|
@@ -29048,11 +29179,11 @@ async function directoryExists3(directory) {
|
|
|
29048
29179
|
}
|
|
29049
29180
|
}
|
|
29050
29181
|
|
|
29051
|
-
// packages/
|
|
29182
|
+
// packages/features/cms-repository/src/collections/tooling/authoring/migrationSources.ts
|
|
29052
29183
|
import { basename as basename4 } from "path";
|
|
29053
29184
|
async function loadCollectionMigrations(directory) {
|
|
29054
29185
|
const migrations = [];
|
|
29055
|
-
const files = await
|
|
29186
|
+
const files = await scanJsonSourceTree2(directory).catch((error) => {
|
|
29056
29187
|
if (error.code === "ENOENT") {
|
|
29057
29188
|
return [];
|
|
29058
29189
|
}
|
|
@@ -29072,9 +29203,9 @@ async function loadCollectionMigrations(directory) {
|
|
|
29072
29203
|
return migrations;
|
|
29073
29204
|
}
|
|
29074
29205
|
|
|
29075
|
-
// packages/
|
|
29206
|
+
// packages/features/cms-repository/src/collections/tooling/authoring/assetSources.ts
|
|
29076
29207
|
import { readFile as readFile18 } from "fs/promises";
|
|
29077
|
-
import { extname, join as
|
|
29208
|
+
import { extname, join as join30 } from "path";
|
|
29078
29209
|
var ASSET_DEFINITION = "definition.json";
|
|
29079
29210
|
var MEDIA_TYPES = new Map([
|
|
29080
29211
|
[".avif", "image/avif"],
|
|
@@ -29160,7 +29291,7 @@ function mediaTypeFor(id) {
|
|
|
29160
29291
|
return mediaType;
|
|
29161
29292
|
}
|
|
29162
29293
|
async function loadGenerations(directory) {
|
|
29163
|
-
const file = Bun.file(
|
|
29294
|
+
const file = Bun.file(join30(directory, ASSET_DEFINITION));
|
|
29164
29295
|
if (!await file.exists()) {
|
|
29165
29296
|
return new Map;
|
|
29166
29297
|
}
|
|
@@ -29183,24 +29314,24 @@ async function loadGenerations(directory) {
|
|
|
29183
29314
|
}));
|
|
29184
29315
|
}
|
|
29185
29316
|
|
|
29186
|
-
// packages/
|
|
29317
|
+
// packages/features/cms-repository/src/collections/tooling/authoring/source.ts
|
|
29187
29318
|
async function prepareCollectionRelease(directory, contracts) {
|
|
29188
29319
|
const collectionRoot = resolve5(directory);
|
|
29189
29320
|
const collectionId = basename5(collectionRoot);
|
|
29190
29321
|
if (!isCollectionNamespace(collectionId)) {
|
|
29191
29322
|
throw new Error("Invalid collection ID");
|
|
29192
29323
|
}
|
|
29193
|
-
const definition = await Bun.file(
|
|
29194
|
-
const translations = await loadCollectionTranslations(
|
|
29195
|
-
const blocs = await loadCollectionBlocs(
|
|
29196
|
-
const texts = await loadCollectionTexts(
|
|
29197
|
-
const pages = await loadPages(
|
|
29198
|
-
const theme = await loadCollectionTheme(
|
|
29199
|
-
const migrations = await loadCollectionMigrations(
|
|
29324
|
+
const definition = await Bun.file(join31(collectionRoot, "definition.json")).json();
|
|
29325
|
+
const translations = await loadCollectionTranslations(join31(collectionRoot, "translations"));
|
|
29326
|
+
const blocs = await loadCollectionBlocs(join31(collectionRoot, "blocs"));
|
|
29327
|
+
const texts = await loadCollectionTexts(join31(collectionRoot, "texts"));
|
|
29328
|
+
const pages = await loadPages(join31(collectionRoot, "pages"));
|
|
29329
|
+
const theme = await loadCollectionTheme(join31(collectionRoot, "theme"));
|
|
29330
|
+
const migrations = await loadCollectionMigrations(join31(collectionRoot, "migrations"));
|
|
29200
29331
|
if (Object.hasOwn(definition, "assets")) {
|
|
29201
29332
|
throw new Error("Collection source assets are discovered from assets/ and must not be declared in definition.json");
|
|
29202
29333
|
}
|
|
29203
|
-
const assets = await loadCollectionAssets(
|
|
29334
|
+
const assets = await loadCollectionAssets(join31(collectionRoot, "assets"));
|
|
29204
29335
|
const exports = expandCollectionSourceExports(definition.exports, {
|
|
29205
29336
|
blocs: ids(blocs, (bloc) => bloc.catalogue !== "hidden"),
|
|
29206
29337
|
themeTokens: themeTokenIds(theme),
|
|
@@ -29263,72 +29394,237 @@ async function loadPages(directory) {
|
|
|
29263
29394
|
};
|
|
29264
29395
|
}));
|
|
29265
29396
|
}
|
|
29266
|
-
|
|
29267
|
-
|
|
29268
|
-
|
|
29269
|
-
|
|
29270
|
-
|
|
29271
|
-
|
|
29272
|
-
|
|
29273
|
-
|
|
29274
|
-
|
|
29275
|
-
|
|
29276
|
-
|
|
29277
|
-
const definition = JSON.parse(bytes);
|
|
29278
|
-
const kind = definition.kind;
|
|
29279
|
-
const files = new LocalArtifactFiles(repositoryRoot);
|
|
29280
|
-
const yanks = new LocalRepositoryYanks(repositoryRoot);
|
|
29281
|
-
const contracts = new LocalContractReleases(files, yanks);
|
|
29282
|
-
if (kind === "collection") {
|
|
29283
|
-
const artifact = await prepareCollectionRelease(directory, await contracts.catalogue());
|
|
29284
|
-
const added = await new LocalCollectionRepository(repositoryRoot).store(artifact);
|
|
29285
|
-
const { publisherId, collectionId, version } = artifact.release;
|
|
29286
|
-
log(`${added ? "+" : "="} collection ${publisherId}/${collectionId}@${version} (${artifact.digest})`);
|
|
29287
|
-
return;
|
|
29397
|
+
// packages/runtimes/ulvia-cli/src/commands/release/resource.ts
|
|
29398
|
+
async function prepareContractResource(directory) {
|
|
29399
|
+
const { admission } = await prepareContractSource(directory);
|
|
29400
|
+
assertFolder(directory, admission.release.contractId);
|
|
29401
|
+
return { kind: "contract", admission };
|
|
29402
|
+
}
|
|
29403
|
+
async function validateConformance(directory, release, contracts) {
|
|
29404
|
+
const source = await compileConformanceSource(directory);
|
|
29405
|
+
if (source) {
|
|
29406
|
+
const dependencies = await resolveConformanceDependencies(source, async (id, version) => (await contracts.get(id, version))?.admission ?? null);
|
|
29407
|
+
await prepareConformanceSource(directory, release, dependencies, source);
|
|
29288
29408
|
}
|
|
29289
|
-
|
|
29290
|
-
|
|
29291
|
-
|
|
29292
|
-
|
|
29293
|
-
|
|
29294
|
-
|
|
29295
|
-
|
|
29296
|
-
|
|
29297
|
-
return dependency?.admission ?? null;
|
|
29298
|
-
});
|
|
29299
|
-
await prepareConformanceSource(directory, prepared.admission, dependencies, conformance);
|
|
29300
|
-
}
|
|
29301
|
-
const { added, admission } = await contracts.release(prepared.sourceJson, directory);
|
|
29302
|
-
const { publisherId, contractId, version } = admission.release;
|
|
29303
|
-
log(`${added ? "+" : "="} contract ${publisherId}/${contractId}@${version} (${admission.digest})`);
|
|
29304
|
-
return;
|
|
29409
|
+
}
|
|
29410
|
+
async function prepareResource(directory, contracts) {
|
|
29411
|
+
const source = await Bun.file(join32(directory, "definition.json")).text();
|
|
29412
|
+
const definition = JSON.parse(source);
|
|
29413
|
+
if (definition.kind === "contract") {
|
|
29414
|
+
const prepared = await prepareContractResource(directory);
|
|
29415
|
+
await validateConformance(directory, prepared.admission, contracts);
|
|
29416
|
+
return prepared;
|
|
29305
29417
|
}
|
|
29306
|
-
if (kind === "provider-manifest") {
|
|
29307
|
-
|
|
29308
|
-
|
|
29309
|
-
|
|
29310
|
-
|
|
29311
|
-
|
|
29418
|
+
if (definition.kind === "provider-manifest") {
|
|
29419
|
+
const admission = await admitProviderManifestJson(source, contracts);
|
|
29420
|
+
assertFolder(directory, admission.manifest.providerId);
|
|
29421
|
+
return { kind: "provider-manifest", admission };
|
|
29422
|
+
}
|
|
29423
|
+
if (definition.kind === "collection") {
|
|
29424
|
+
return { kind: "collection", admission: await prepareCollectionRelease(directory, contracts) };
|
|
29312
29425
|
}
|
|
29313
29426
|
throw new Error("definition.json must declare kind: collection, contract, or provider-manifest");
|
|
29314
29427
|
}
|
|
29428
|
+
async function storeResource(resource, root, log) {
|
|
29429
|
+
const files = new LocalArtifactFiles(root);
|
|
29430
|
+
const yanks = new LocalRepositoryYanks(root);
|
|
29431
|
+
const contracts = new LocalContractReleases(files, yanks);
|
|
29432
|
+
let added;
|
|
29433
|
+
if (resource.kind === "contract") {
|
|
29434
|
+
added = (await contracts.publish(resource.admission.canonicalJson, resource.admission.fixtureAssets)).added;
|
|
29435
|
+
} else if (resource.kind === "provider-manifest") {
|
|
29436
|
+
added = (await new LocalProviderReleases(files, contracts, yanks).release(resource.admission.canonicalJson)).added;
|
|
29437
|
+
} else {
|
|
29438
|
+
added = await new LocalCollectionRepository(root).store(resource.admission);
|
|
29439
|
+
}
|
|
29440
|
+
log(`${added ? "+" : "="} ${resourceCoordinate(resource)} (${resource.admission.digest})`);
|
|
29441
|
+
}
|
|
29442
|
+
function resourceCoordinate(resource) {
|
|
29443
|
+
if (resource.kind === "provider-manifest") {
|
|
29444
|
+
const { provenance, providerId, version } = resource.admission.manifest;
|
|
29445
|
+
return `provider ${provenance.publisherId}/${providerId}@${version}`;
|
|
29446
|
+
}
|
|
29447
|
+
if (resource.kind === "contract") {
|
|
29448
|
+
const { publisherId, contractId, version } = resource.admission.release;
|
|
29449
|
+
return `contract ${publisherId}/${contractId}@${version}`;
|
|
29450
|
+
}
|
|
29451
|
+
const { publisherId, collectionId, version } = resource.admission.release;
|
|
29452
|
+
return `collection ${publisherId}/${collectionId}@${version}`;
|
|
29453
|
+
}
|
|
29315
29454
|
function assertFolder(directory, id) {
|
|
29316
|
-
if (
|
|
29455
|
+
if (basename6(directory) !== id) {
|
|
29317
29456
|
throw new Error(`Resource folder ${basename6(directory)} does not match definition ID ${id}`);
|
|
29318
29457
|
}
|
|
29319
29458
|
}
|
|
29320
29459
|
|
|
29460
|
+
// packages/runtimes/ulvia-cli/src/commands/release/batch.ts
|
|
29461
|
+
var MAX_PREPARED_BYTES = 512 * 1024 * 1024;
|
|
29462
|
+
async function releaseBatch(sources, root, log) {
|
|
29463
|
+
const contracts = new LocalContractReleases(new LocalArtifactFiles(root), new LocalRepositoryYanks(root));
|
|
29464
|
+
const catalogue = await contracts.catalogue();
|
|
29465
|
+
const candidates = [];
|
|
29466
|
+
let bytes = 0;
|
|
29467
|
+
const coordinates = new Set;
|
|
29468
|
+
function include(resource) {
|
|
29469
|
+
const coordinate = resourceCoordinate(resource);
|
|
29470
|
+
if (coordinates.has(coordinate)) {
|
|
29471
|
+
throw new Error(`Duplicate authored release coordinate: ${coordinate}`);
|
|
29472
|
+
}
|
|
29473
|
+
coordinates.add(coordinate);
|
|
29474
|
+
bytes += Buffer.byteLength(resource.admission.canonicalJson);
|
|
29475
|
+
if (resource.kind === "contract") {
|
|
29476
|
+
bytes += (resource.admission.fixtureAssets ?? []).reduce((total, asset) => total + asset.bytes.size, 0);
|
|
29477
|
+
} else if (resource.kind === "collection") {
|
|
29478
|
+
bytes += resource.admission.assets.reduce((total, asset) => total + asset.bytes.size, 0);
|
|
29479
|
+
}
|
|
29480
|
+
if (bytes > MAX_PREPARED_BYTES) {
|
|
29481
|
+
throw new Error("Recursive release exceeds its 512 MiB prepared-byte limit");
|
|
29482
|
+
}
|
|
29483
|
+
}
|
|
29484
|
+
for (const source of sources.filter((source) => source.kind === "contract")) {
|
|
29485
|
+
const resource = await prepareContractResource(source.directory);
|
|
29486
|
+
include(resource);
|
|
29487
|
+
candidates.push({ directory: source.directory, resource });
|
|
29488
|
+
}
|
|
29489
|
+
const ordered = await planContractPublications(catalogue, candidates.map(({ resource }) => resource.admission));
|
|
29490
|
+
for (const admission of ordered) {
|
|
29491
|
+
await catalogue.publish(admission);
|
|
29492
|
+
}
|
|
29493
|
+
for (const { directory, resource } of candidates) {
|
|
29494
|
+
await validateConformance(directory, resource.admission, catalogue);
|
|
29495
|
+
}
|
|
29496
|
+
const byDigest = new Map(candidates.map(({ resource }) => [resource.admission.digest, resource]));
|
|
29497
|
+
const planned = new Set(ordered.map((admission) => admission.digest));
|
|
29498
|
+
const resources = [
|
|
29499
|
+
...ordered.map((admission) => byDigest.get(admission.digest)),
|
|
29500
|
+
...candidates.filter(({ resource }) => !planned.has(resource.admission.digest)).map(({ resource }) => resource)
|
|
29501
|
+
];
|
|
29502
|
+
const remaining = [];
|
|
29503
|
+
for (const source of sources.filter((source) => source.kind !== "contract")) {
|
|
29504
|
+
const resource = await prepareResource(source.directory, catalogue);
|
|
29505
|
+
include(resource);
|
|
29506
|
+
remaining.push(resource);
|
|
29507
|
+
}
|
|
29508
|
+
remaining.sort((left, right) => {
|
|
29509
|
+
if (left.kind !== right.kind) {
|
|
29510
|
+
return left.kind === "provider-manifest" ? -1 : 1;
|
|
29511
|
+
}
|
|
29512
|
+
const a = resourceCoordinate(left);
|
|
29513
|
+
const b = resourceCoordinate(right);
|
|
29514
|
+
const prefixA = a.slice(0, a.lastIndexOf("@"));
|
|
29515
|
+
const prefixB = b.slice(0, b.lastIndexOf("@"));
|
|
29516
|
+
return prefixA === prefixB ? compareSemVer(a.slice(a.lastIndexOf("@") + 1), b.slice(b.lastIndexOf("@") + 1)) : prefixA < prefixB ? -1 : 1;
|
|
29517
|
+
});
|
|
29518
|
+
for (const resource of [...resources, ...remaining]) {
|
|
29519
|
+
await storeResource(resource, root, log);
|
|
29520
|
+
}
|
|
29521
|
+
log(`Prepared ${coordinates.size} local releases.`);
|
|
29522
|
+
}
|
|
29523
|
+
|
|
29524
|
+
// packages/runtimes/ulvia-cli/src/commands/release/discovery.ts
|
|
29525
|
+
import { lstat as lstat5, readdir as readdir12 } from "fs/promises";
|
|
29526
|
+
import { join as join33 } from "path";
|
|
29527
|
+
var MAX_RESOURCES = 256;
|
|
29528
|
+
var MAX_DIRECTORIES = 4096;
|
|
29529
|
+
var MAX_DEPTH2 = 32;
|
|
29530
|
+
async function discoverResources(root) {
|
|
29531
|
+
const resources = [];
|
|
29532
|
+
let visited = 0;
|
|
29533
|
+
async function visit(directory, depth) {
|
|
29534
|
+
if (++visited > MAX_DIRECTORIES || depth > MAX_DEPTH2) {
|
|
29535
|
+
throw new Error("Recursive release source tree exceeds its directory or depth limit");
|
|
29536
|
+
}
|
|
29537
|
+
const metadata = await lstat5(directory);
|
|
29538
|
+
if (!metadata.isDirectory() || metadata.isSymbolicLink()) {
|
|
29539
|
+
throw new Error(`Release source must be a real directory: ${directory}`);
|
|
29540
|
+
}
|
|
29541
|
+
const definitionPath = join33(directory, "definition.json");
|
|
29542
|
+
const entry = await lstat5(definitionPath).catch((error) => {
|
|
29543
|
+
if (error.code === "ENOENT") {
|
|
29544
|
+
return null;
|
|
29545
|
+
}
|
|
29546
|
+
throw error;
|
|
29547
|
+
});
|
|
29548
|
+
if (entry && (!entry.isFile() || entry.isSymbolicLink())) {
|
|
29549
|
+
throw new Error(`Release definition must be a regular file: ${definitionPath}`);
|
|
29550
|
+
}
|
|
29551
|
+
const definition = await readOptionalJsonSourceRecord(definitionPath, directory);
|
|
29552
|
+
if (definition) {
|
|
29553
|
+
const kind = definition.value.kind;
|
|
29554
|
+
if (kind !== "contract" && kind !== "provider-manifest" && kind !== "collection") {
|
|
29555
|
+
throw new Error(`Unsupported release root kind at ${directory}`);
|
|
29556
|
+
}
|
|
29557
|
+
resources.push({ directory, kind });
|
|
29558
|
+
if (resources.length > MAX_RESOURCES) {
|
|
29559
|
+
throw new Error(`Recursive release must contain at most ${MAX_RESOURCES} resources`);
|
|
29560
|
+
}
|
|
29561
|
+
return;
|
|
29562
|
+
}
|
|
29563
|
+
const entries = (await readdir12(directory, { withFileTypes: true })).sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0);
|
|
29564
|
+
for (const entry of entries) {
|
|
29565
|
+
if (entry.name === "node_modules" || entry.name.startsWith(".")) {
|
|
29566
|
+
continue;
|
|
29567
|
+
}
|
|
29568
|
+
if (entry.isSymbolicLink()) {
|
|
29569
|
+
throw new Error(`Recursive release does not follow symbolic links: ${join33(directory, entry.name)}`);
|
|
29570
|
+
}
|
|
29571
|
+
if (entry.isDirectory()) {
|
|
29572
|
+
await visit(join33(directory, entry.name), depth + 1);
|
|
29573
|
+
}
|
|
29574
|
+
}
|
|
29575
|
+
}
|
|
29576
|
+
await visit(root, 0);
|
|
29577
|
+
if (!resources.length) {
|
|
29578
|
+
throw new Error(`No authored release resources found below ${root}`);
|
|
29579
|
+
}
|
|
29580
|
+
return resources;
|
|
29581
|
+
}
|
|
29582
|
+
|
|
29583
|
+
// packages/runtimes/ulvia-cli/src/commands/release/index.ts
|
|
29584
|
+
var HELP2 = `Usage: ulvia release <resource-directory> [--recursive]
|
|
29585
|
+
|
|
29586
|
+
Prepare immutable releases in the local cache. --recursive discovers authored
|
|
29587
|
+
resource roots and orders contracts before provider manifests and collections.
|
|
29588
|
+
Use push separately to publish an exact coordinate to a remote Repository.`;
|
|
29589
|
+
async function releaseCommand(args, cwd, repositoryRoot, log) {
|
|
29590
|
+
if (args.length === 1 && ["--help", "-h"].includes(args[0])) {
|
|
29591
|
+
log(HELP2);
|
|
29592
|
+
return;
|
|
29593
|
+
}
|
|
29594
|
+
const recursive = args.includes("--recursive");
|
|
29595
|
+
const directories = args.filter((argument) => argument !== "--recursive");
|
|
29596
|
+
if (directories.length !== 1 || directories[0].startsWith("-") || args.length !== (recursive ? 2 : 1)) {
|
|
29597
|
+
throw new Error(HELP2);
|
|
29598
|
+
}
|
|
29599
|
+
const directory = resolve6(cwd, directories[0]);
|
|
29600
|
+
const resources = recursive ? await discoverResources(directory) : undefined;
|
|
29601
|
+
await withRepositoryWriteLock(repositoryRoot, async () => {
|
|
29602
|
+
if (resources) {
|
|
29603
|
+
await releaseBatch(resources, repositoryRoot, log);
|
|
29604
|
+
return;
|
|
29605
|
+
}
|
|
29606
|
+
const files = new LocalArtifactFiles(repositoryRoot);
|
|
29607
|
+
const contracts = new LocalContractReleases(files, new LocalRepositoryYanks(repositoryRoot));
|
|
29608
|
+
await storeResource(await prepareResource(directory, await contracts.catalogue()), repositoryRoot, log);
|
|
29609
|
+
});
|
|
29610
|
+
}
|
|
29611
|
+
|
|
29321
29612
|
// packages/features/cms-repository/src/repository-http/getBytes.ts
|
|
29322
29613
|
var MAX_REPOSITORY_RESPONSE_BYTES = 8 * 1024 * 1024;
|
|
29323
29614
|
|
|
29324
|
-
// packages/features/cms-repository/src/repository/
|
|
29325
|
-
function
|
|
29326
|
-
const url = new URL(
|
|
29615
|
+
// packages/features/cms-repository/src/repository-http/baseUrl.ts
|
|
29616
|
+
function repositoryBaseUrl(baseUrl, kind, options = {}) {
|
|
29617
|
+
const url = new URL(baseUrl);
|
|
29327
29618
|
const loopback = ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
|
|
29328
|
-
if (url.protocol !== "https:" && !(url.protocol === "http:" && loopback) || url.username || url.password || url.search || url.hash) {
|
|
29329
|
-
throw new
|
|
29619
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && (loopback || options.allowInsecureHttp === true)) || url.username || url.password || url.search || url.hash) {
|
|
29620
|
+
throw new TypeError(`${kind} repository must use HTTPS or explicitly allowed HTTP without URL credentials`);
|
|
29330
29621
|
}
|
|
29331
|
-
return new URL(`${url.toString().replace(
|
|
29622
|
+
return new URL(`${url.toString().replace(/\/+$/, "")}/`);
|
|
29623
|
+
}
|
|
29624
|
+
|
|
29625
|
+
// packages/features/cms-repository/src/repository/publication/transport/index.ts
|
|
29626
|
+
function repositoryUrl(value, options = {}) {
|
|
29627
|
+
return repositoryBaseUrl(value, "Publication", options);
|
|
29332
29628
|
}
|
|
29333
29629
|
async function boundedResponseBytes(response, maximum) {
|
|
29334
29630
|
const declared = Number(response.headers.get("content-length"));
|
|
@@ -29587,8 +29883,8 @@ var FETCH_CONCURRENCY = 4;
|
|
|
29587
29883
|
class RemoteRepositoryClient {
|
|
29588
29884
|
base;
|
|
29589
29885
|
writer;
|
|
29590
|
-
constructor(baseUrl, credential) {
|
|
29591
|
-
this.base = repositoryUrl(baseUrl);
|
|
29886
|
+
constructor(baseUrl, credential, options = {}) {
|
|
29887
|
+
this.base = repositoryUrl(baseUrl, options);
|
|
29592
29888
|
this.writer = new RemoteRepositoryWriter(this.base, credential);
|
|
29593
29889
|
}
|
|
29594
29890
|
async pull(coordinate, assetSink) {
|
|
@@ -29714,34 +30010,49 @@ function releasePath(coordinate) {
|
|
|
29714
30010
|
var SIGNATURE_TTL_MS = 5 * 60 * 1000;
|
|
29715
30011
|
var UPLOAD_TTL_MS = 60 * 60 * 1000;
|
|
29716
30012
|
var MAX_CONFORMANCE_EVIDENCE_BYTES = 8 * 1024 * 1024;
|
|
29717
|
-
// packages/runtimes/ulvia-cli/src/commands/
|
|
30013
|
+
// packages/runtimes/ulvia-cli/src/commands/remote/arguments.ts
|
|
29718
30014
|
function parseRemoteArguments(action, args, environment) {
|
|
29719
30015
|
const positional = [];
|
|
29720
|
-
|
|
29721
|
-
let reason;
|
|
30016
|
+
const options = new Map;
|
|
29722
30017
|
for (let index = 0;index < args.length; index++) {
|
|
29723
30018
|
const argument = args[index];
|
|
29724
|
-
if (argument
|
|
29725
|
-
|
|
29726
|
-
|
|
29727
|
-
|
|
30019
|
+
if (argument.startsWith("--")) {
|
|
30020
|
+
const value = args[++index];
|
|
30021
|
+
if (!["--repository", "--reason"].includes(argument) || options.has(argument) || !value || value.startsWith("--")) {
|
|
30022
|
+
throw new Error(remoteUsage(action));
|
|
30023
|
+
}
|
|
30024
|
+
options.set(argument, value);
|
|
29728
30025
|
} else {
|
|
29729
30026
|
positional.push(argument);
|
|
29730
30027
|
}
|
|
29731
30028
|
}
|
|
29732
|
-
|
|
29733
|
-
|
|
30029
|
+
const reason = options.get("--reason");
|
|
30030
|
+
if (action === "yank" && !reason || action !== "yank" && reason) {
|
|
30031
|
+
throw new Error(remoteUsage(action));
|
|
30032
|
+
}
|
|
30033
|
+
let selection;
|
|
30034
|
+
if (action === "push" && positional.length === 1 && positional[0] === "all") {
|
|
30035
|
+
selection = { mode: "all" };
|
|
30036
|
+
} else if (action === "push" && positional.length === 1) {
|
|
30037
|
+
selection = { mode: "one", ...parseCoordinate(positional[0]) };
|
|
30038
|
+
} else if (positional.length === 2) {
|
|
30039
|
+
selection = { mode: "one", kind: normalizeKind(positional[0]), ...parseCoordinate(positional[1]) };
|
|
30040
|
+
} else {
|
|
30041
|
+
throw new Error(remoteUsage(action));
|
|
29734
30042
|
}
|
|
29735
|
-
|
|
29736
|
-
|
|
30043
|
+
const repositoryUrl = options.get("--repository") ?? environment.ULVIA_REPOSITORY_URL?.trim();
|
|
30044
|
+
if (!repositoryUrl) {
|
|
30045
|
+
throw new Error("No Repository selected. Run ulvia repository login <url> or use --repository <url>.");
|
|
29737
30046
|
}
|
|
29738
|
-
return {
|
|
30047
|
+
return { selection, repositoryUrl, reason };
|
|
29739
30048
|
}
|
|
29740
30049
|
function formatCoordinate(value) {
|
|
29741
30050
|
return `${value.kind} ${value.publisherId}/${value.id}@${value.version}`;
|
|
29742
30051
|
}
|
|
29743
|
-
function
|
|
29744
|
-
|
|
30052
|
+
function remoteUsage(action) {
|
|
30053
|
+
return action === "push" ? "Usage: ulvia push <publisher/id@version | all> [--repository <url>] (add a kind before the coordinate only to resolve ambiguity)" : `Usage: ulvia ${action} <collection|contract|provider> <publisher/id@version> [--repository <url>]${action === "yank" ? " --reason <text>" : ""}`;
|
|
30054
|
+
}
|
|
30055
|
+
function parseCoordinate(value) {
|
|
29745
30056
|
const separator = value.lastIndexOf("@");
|
|
29746
30057
|
const slash = value.indexOf("/");
|
|
29747
30058
|
const publisherId = value.slice(0, slash);
|
|
@@ -29750,7 +30061,7 @@ function parseCoordinate(kindValue, value) {
|
|
|
29750
30061
|
if (slash < 1 || separator <= slash + 1 || !IDENTIFIER2.test(publisherId) || !IDENTIFIER2.test(id) || !VERSION4.test(version)) {
|
|
29751
30062
|
throw new Error("Repository coordinate must use publisher/id@version");
|
|
29752
30063
|
}
|
|
29753
|
-
return {
|
|
30064
|
+
return { publisherId, id, version };
|
|
29754
30065
|
}
|
|
29755
30066
|
function normalizeKind(value) {
|
|
29756
30067
|
if (value === "provider") {
|
|
@@ -29761,23 +30072,17 @@ function normalizeKind(value) {
|
|
|
29761
30072
|
}
|
|
29762
30073
|
throw new Error("Repository kind must be collection, contract, or provider");
|
|
29763
30074
|
}
|
|
29764
|
-
function requiredOption(value, name) {
|
|
29765
|
-
if (!value || value.startsWith("--")) {
|
|
29766
|
-
throw new Error(`${name} requires a value`);
|
|
29767
|
-
}
|
|
29768
|
-
return value;
|
|
29769
|
-
}
|
|
29770
30075
|
var IDENTIFIER2 = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/u;
|
|
29771
30076
|
var VERSION4 = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;
|
|
29772
30077
|
|
|
29773
|
-
// packages/runtimes/ulvia-cli/src/commands/
|
|
30078
|
+
// packages/runtimes/ulvia-cli/src/commands/remote/assetSink.ts
|
|
29774
30079
|
import { mkdir as mkdir7, open as open6, rename as rename4, rm as rm11, stat as stat6 } from "fs/promises";
|
|
29775
|
-
import { join as
|
|
30080
|
+
import { join as join34 } from "path";
|
|
29776
30081
|
|
|
29777
30082
|
class RemoteAssetFileSink {
|
|
29778
30083
|
root;
|
|
29779
30084
|
constructor(repositoryRoot) {
|
|
29780
|
-
this.root =
|
|
30085
|
+
this.root = join34(repositoryRoot, ".remote-transfers");
|
|
29781
30086
|
}
|
|
29782
30087
|
async get(asset) {
|
|
29783
30088
|
const path = this.path(asset);
|
|
@@ -29813,7 +30118,7 @@ class RemoteAssetFileSink {
|
|
|
29813
30118
|
await rm11(this.root, { recursive: true, force: true });
|
|
29814
30119
|
}
|
|
29815
30120
|
path(asset) {
|
|
29816
|
-
return
|
|
30121
|
+
return join34(this.root, asset.digest.slice("sha256:".length));
|
|
29817
30122
|
}
|
|
29818
30123
|
}
|
|
29819
30124
|
async function writeAll(handle, bytes) {
|
|
@@ -29823,12 +30128,193 @@ async function writeAll(handle, bytes) {
|
|
|
29823
30128
|
offset += bytesWritten;
|
|
29824
30129
|
}
|
|
29825
30130
|
}
|
|
30131
|
+
|
|
30132
|
+
// packages/runtimes/ulvia-cli/src/commands/remote/storage.ts
|
|
30133
|
+
async function loadLocal(root, coordinate) {
|
|
30134
|
+
const yanks = new LocalRepositoryYanks(root);
|
|
30135
|
+
if (await yanks.get(coordinate.kind, coordinate.publisherId, coordinate.id, coordinate.version)) {
|
|
30136
|
+
throw new Error("A locally yanked release cannot be pushed");
|
|
30137
|
+
}
|
|
30138
|
+
if (coordinate.kind === "collection") {
|
|
30139
|
+
const artifact = await new LocalCollectionRepository(root).get(coordinate.publisherId, coordinate.id, coordinate.version);
|
|
30140
|
+
if (!artifact) {
|
|
30141
|
+
throw new Error("Local collection release not found");
|
|
30142
|
+
}
|
|
30143
|
+
return {
|
|
30144
|
+
digest: artifact.digest,
|
|
30145
|
+
envelope: {
|
|
30146
|
+
kind: coordinate.kind,
|
|
30147
|
+
canonicalJson: artifact.canonicalJson,
|
|
30148
|
+
assets: await collectionAssets(artifact.assets)
|
|
30149
|
+
}
|
|
30150
|
+
};
|
|
30151
|
+
}
|
|
30152
|
+
const files = new LocalArtifactFiles(root);
|
|
30153
|
+
const type = coordinate.kind === "contract" ? "contracts" : "providers";
|
|
30154
|
+
const bytes = await files.get(type, coordinate.publisherId, coordinate.id, coordinate.version);
|
|
30155
|
+
if (!bytes) {
|
|
30156
|
+
throw new Error(`Local ${coordinate.kind} release not found`);
|
|
30157
|
+
}
|
|
30158
|
+
const canonicalJson = bytes.toString("utf8");
|
|
30159
|
+
const contracts = new LocalContractReleases(files, yanks);
|
|
30160
|
+
if (coordinate.kind === "contract") {
|
|
30161
|
+
const assets = await contractAssets(files, canonicalJson);
|
|
30162
|
+
const admission = assets.length ? await admitContractBundleJson(canonicalJson, assets) : await admitContractReleaseJson(canonicalJson);
|
|
30163
|
+
const record = await (await contracts.catalogue()).get(coordinate.id, coordinate.version);
|
|
30164
|
+
assertDigest(admission.digest, record.admission.digest);
|
|
30165
|
+
return {
|
|
30166
|
+
digest: admission.digest,
|
|
30167
|
+
envelope: {
|
|
30168
|
+
kind: coordinate.kind,
|
|
30169
|
+
canonicalJson,
|
|
30170
|
+
assets
|
|
30171
|
+
}
|
|
30172
|
+
};
|
|
30173
|
+
}
|
|
30174
|
+
const record = await (await new LocalProviderReleases(files, contracts, yanks).catalogue()).get(coordinate.id, coordinate.version);
|
|
30175
|
+
return {
|
|
30176
|
+
digest: record.admission.digest,
|
|
30177
|
+
envelope: { kind: coordinate.kind, canonicalJson, assets: [] }
|
|
30178
|
+
};
|
|
30179
|
+
}
|
|
30180
|
+
async function storeLocal(root, remote) {
|
|
30181
|
+
const files = new LocalArtifactFiles(root);
|
|
30182
|
+
const yanks = new LocalRepositoryYanks(root);
|
|
30183
|
+
const contracts = new LocalContractReleases(files, yanks);
|
|
30184
|
+
if (remote.kind === "collection") {
|
|
30185
|
+
const admission = await admitCollectionReleaseJson(remote.canonicalJson, remote.assets, {
|
|
30186
|
+
contracts: await contracts.catalogue()
|
|
30187
|
+
});
|
|
30188
|
+
assertDigest(admission.digest, remote.expectedDigest);
|
|
30189
|
+
return new LocalCollectionRepository(root).store(admission);
|
|
30190
|
+
}
|
|
30191
|
+
if (remote.kind === "contract") {
|
|
30192
|
+
const admission = remote.assets.length ? await admitContractBundleJson(remote.canonicalJson, remote.assets) : await admitContractReleaseJson(remote.canonicalJson);
|
|
30193
|
+
assertDigest(admission.digest, remote.expectedDigest);
|
|
30194
|
+
return (await contracts.publish(remote.canonicalJson, remote.assets)).added;
|
|
30195
|
+
}
|
|
30196
|
+
const admission = await admitProviderManifestJson(remote.canonicalJson, await contracts.catalogue());
|
|
30197
|
+
assertDigest(admission.digest, remote.expectedDigest);
|
|
30198
|
+
return (await new LocalProviderReleases(files, contracts, yanks).release(remote.canonicalJson)).added;
|
|
30199
|
+
}
|
|
30200
|
+
async function collectionAssets(assets) {
|
|
30201
|
+
return assets.map((asset) => ({ id: asset.id, bytes: asset.bytes }));
|
|
30202
|
+
}
|
|
30203
|
+
async function contractAssets(files, canonicalJson) {
|
|
30204
|
+
return (parseContractReleaseJson(canonicalJson).fixtureAssets ?? []).map((asset) => ({
|
|
30205
|
+
id: asset.id,
|
|
30206
|
+
bytes: files.fixtureBlob(canonicalJson, asset.id)
|
|
30207
|
+
}));
|
|
30208
|
+
}
|
|
30209
|
+
function assertDigest(actual, expected) {
|
|
30210
|
+
if (actual !== expected) {
|
|
30211
|
+
throw new Error(`Repository digest mismatch: expected ${expected}, received ${actual}`);
|
|
30212
|
+
}
|
|
30213
|
+
}
|
|
30214
|
+
|
|
30215
|
+
// packages/runtimes/ulvia-cli/src/commands/remote/selection.ts
|
|
30216
|
+
async function inferLocalCoordinate(root, coordinate) {
|
|
30217
|
+
const files = new LocalArtifactFiles(root);
|
|
30218
|
+
const { publisherId, id, version } = coordinate;
|
|
30219
|
+
const [contract, provider, collection] = await Promise.all([
|
|
30220
|
+
files.get("contracts", publisherId, id, version),
|
|
30221
|
+
files.get("providers", publisherId, id, version),
|
|
30222
|
+
new LocalCollectionRepository(root).getMetadata(publisherId, id, version)
|
|
30223
|
+
]);
|
|
30224
|
+
const candidates = [];
|
|
30225
|
+
if (contract) {
|
|
30226
|
+
candidates.push({ publisherId, id, version, kind: "contract" });
|
|
30227
|
+
}
|
|
30228
|
+
if (provider) {
|
|
30229
|
+
candidates.push({ publisherId, id, version, kind: "provider-manifest" });
|
|
30230
|
+
}
|
|
30231
|
+
if (collection) {
|
|
30232
|
+
candidates.push({ publisherId, id, version, kind: "collection" });
|
|
30233
|
+
}
|
|
30234
|
+
if (candidates.length !== 1) {
|
|
30235
|
+
throw new Error(candidates.length ? "Ambiguous local release: add collection, contract or provider before the coordinate." : "Local release not found. Prepare it with ulvia release before pushing.");
|
|
30236
|
+
}
|
|
30237
|
+
return candidates[0];
|
|
30238
|
+
}
|
|
30239
|
+
|
|
30240
|
+
// packages/runtimes/ulvia-cli/src/commands/remote/ordering.ts
|
|
30241
|
+
async function orderContracts(records) {
|
|
30242
|
+
const catalogue = new InMemoryReleaseCatalogue;
|
|
30243
|
+
const pending = [...records];
|
|
30244
|
+
const ordered = [];
|
|
30245
|
+
while (pending.length) {
|
|
30246
|
+
let progress = false;
|
|
30247
|
+
let failure;
|
|
30248
|
+
for (let index = 0;index < pending.length; ) {
|
|
30249
|
+
const record = pending[index];
|
|
30250
|
+
try {
|
|
30251
|
+
await catalogue.restore(record.admission.canonicalJson, record.admission.digest, record.publishedAt);
|
|
30252
|
+
} catch (error) {
|
|
30253
|
+
failure ??= error;
|
|
30254
|
+
index++;
|
|
30255
|
+
continue;
|
|
30256
|
+
}
|
|
30257
|
+
ordered.push(record);
|
|
30258
|
+
pending.splice(index, 1);
|
|
30259
|
+
progress = true;
|
|
30260
|
+
}
|
|
30261
|
+
if (!progress) {
|
|
30262
|
+
throw failure;
|
|
30263
|
+
}
|
|
30264
|
+
}
|
|
30265
|
+
return ordered;
|
|
30266
|
+
}
|
|
30267
|
+
function orderCollections(records) {
|
|
30268
|
+
const pending = [...records].sort((left, right) => compareSemVer(left.release.version, right.release.version));
|
|
30269
|
+
const ordered = [];
|
|
30270
|
+
const matches = (release, dependency) => release.publisherId === dependency.publisherId && release.collectionId === dependency.collectionId && satisfiesVersionRange(release.version, dependency.versionRange);
|
|
30271
|
+
while (pending.length) {
|
|
30272
|
+
const index = pending.findIndex(({ release }) => !pending.some(({ release: other }) => other.publisherId === release.publisherId && other.collectionId === release.collectionId && compareSemVer(other.version, release.version) < 0) && (release.dependencies ?? []).every((dependency) => !records.some((record) => matches(record.release, dependency)) || ordered.some((record) => matches(record.release, dependency))));
|
|
30273
|
+
if (index === -1) {
|
|
30274
|
+
throw new Error("Cannot order local collection dependencies for push all");
|
|
30275
|
+
}
|
|
30276
|
+
ordered.push(pending.splice(index, 1)[0]);
|
|
30277
|
+
}
|
|
30278
|
+
return ordered;
|
|
30279
|
+
}
|
|
30280
|
+
|
|
30281
|
+
// packages/runtimes/ulvia-cli/src/commands/remote/plan.ts
|
|
30282
|
+
async function allLocalCoordinates(root) {
|
|
30283
|
+
const files = new LocalArtifactFiles(root);
|
|
30284
|
+
const yanks = new LocalRepositoryYanks(root);
|
|
30285
|
+
const contracts = new LocalContractReleases(files, yanks);
|
|
30286
|
+
const coordinates = [];
|
|
30287
|
+
for (const record of await orderContracts(await (await contracts.catalogue()).list())) {
|
|
30288
|
+
if (!record.yank) {
|
|
30289
|
+
const { publisherId, contractId: id, version } = record.admission.release;
|
|
30290
|
+
coordinates.push({ kind: "contract", publisherId, id, version });
|
|
30291
|
+
}
|
|
30292
|
+
}
|
|
30293
|
+
for (const record of await (await new LocalProviderReleases(files, contracts, yanks).catalogue()).list()) {
|
|
30294
|
+
if (!record.yank) {
|
|
30295
|
+
const { provenance, providerId: id, version } = record.admission.manifest;
|
|
30296
|
+
coordinates.push({ kind: "provider-manifest", publisherId: provenance.publisherId, id, version });
|
|
30297
|
+
}
|
|
30298
|
+
}
|
|
30299
|
+
for (const { release } of orderCollections(await new LocalCollectionRepository(root).listMetadata())) {
|
|
30300
|
+
const coordinate = {
|
|
30301
|
+
kind: "collection",
|
|
30302
|
+
publisherId: release.publisherId,
|
|
30303
|
+
id: release.collectionId,
|
|
30304
|
+
version: release.version
|
|
30305
|
+
};
|
|
30306
|
+
if (!await yanks.get(coordinate.kind, coordinate.publisherId, coordinate.id, coordinate.version)) {
|
|
30307
|
+
coordinates.push(coordinate);
|
|
30308
|
+
}
|
|
30309
|
+
}
|
|
30310
|
+
return coordinates;
|
|
30311
|
+
}
|
|
29826
30312
|
// packages/features/cms-repository/src/repository/namespaces/client.ts
|
|
29827
30313
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
29828
30314
|
class RepositoryNamespaceClient {
|
|
29829
30315
|
base;
|
|
29830
|
-
constructor(url) {
|
|
29831
|
-
this.base = repositoryUrl(url);
|
|
30316
|
+
constructor(url, options = {}) {
|
|
30317
|
+
this.base = repositoryUrl(url, options);
|
|
29832
30318
|
}
|
|
29833
30319
|
async identity() {
|
|
29834
30320
|
const value = await this.request("v1/repository");
|
|
@@ -29839,7 +30325,16 @@ class RepositoryNamespaceClient {
|
|
|
29839
30325
|
}
|
|
29840
30326
|
async get(namespace) {
|
|
29841
30327
|
assertRepositoryNamespace(namespace);
|
|
29842
|
-
|
|
30328
|
+
const value = await this.request(`v1/namespaces/${namespace}`, undefined, true);
|
|
30329
|
+
if (value === null) {
|
|
30330
|
+
return null;
|
|
30331
|
+
}
|
|
30332
|
+
const owner = value;
|
|
30333
|
+
if (!owner || owner.namespace !== namespace || !Number.isSafeInteger(owner.revision) || owner.revision < 1 || typeof owner.revoked !== "boolean" || typeof owner.publicKey !== "string" || !["claim", "rotate", "revoke"].includes(owner.action) || typeof owner.updatedAt !== "string" || !Number.isFinite(Date.parse(owner.updatedAt)) || owner.previousDigest !== null && !/^sha256:[a-f0-9]{64}$/u.test(owner.previousDigest)) {
|
|
30334
|
+
throw new Error("Repository returned an invalid namespace owner");
|
|
30335
|
+
}
|
|
30336
|
+
namespacePublicKey(owner.publicKey);
|
|
30337
|
+
return owner;
|
|
29843
30338
|
}
|
|
29844
30339
|
async claim(credential, publicKey) {
|
|
29845
30340
|
return await this.request(`v1/namespaces/${credential.namespace}`, {
|
|
@@ -29950,24 +30445,74 @@ async function remoteRepositoryCredential(url, namespace, environment) {
|
|
|
29950
30445
|
};
|
|
29951
30446
|
}
|
|
29952
30447
|
|
|
29953
|
-
// packages/runtimes/ulvia-cli/src/commands/remote.ts
|
|
30448
|
+
// packages/runtimes/ulvia-cli/src/commands/remote/push.ts
|
|
30449
|
+
async function pushCommand(selection, url, root, environment, log) {
|
|
30450
|
+
const coordinates = selection.mode === "all" ? await allLocalCoordinates(root) : [
|
|
30451
|
+
selection.kind ? {
|
|
30452
|
+
kind: selection.kind,
|
|
30453
|
+
publisherId: selection.publisherId,
|
|
30454
|
+
id: selection.id,
|
|
30455
|
+
version: selection.version
|
|
30456
|
+
} : await inferLocalCoordinate(root, selection)
|
|
30457
|
+
];
|
|
30458
|
+
if (!coordinates.length) {
|
|
30459
|
+
throw new Error("No non-yanked local releases to push. Prepare resources with ulvia release first.");
|
|
30460
|
+
}
|
|
30461
|
+
const prepared = [];
|
|
30462
|
+
for (const coordinate of coordinates) {
|
|
30463
|
+
prepared.push({ coordinate, local: await loadLocal(root, coordinate) });
|
|
30464
|
+
}
|
|
30465
|
+
const credentials = new Map;
|
|
30466
|
+
for (const namespace of new Set(coordinates.map((coordinate) => coordinate.publisherId))) {
|
|
30467
|
+
credentials.set(namespace, await remoteRepositoryCredential(url, namespace, environment));
|
|
30468
|
+
}
|
|
30469
|
+
if (selection.mode === "all") {
|
|
30470
|
+
log(`Publishing ${prepared.length} local releases to ${url}.`);
|
|
30471
|
+
}
|
|
30472
|
+
let completed = 0;
|
|
30473
|
+
for (const { coordinate, local } of prepared) {
|
|
30474
|
+
try {
|
|
30475
|
+
const result = await new RemoteRepositoryClient(url, credentials.get(coordinate.publisherId)).push(local.envelope);
|
|
30476
|
+
if (result.digest !== local.digest) {
|
|
30477
|
+
throw new Error("Remote repository returned a different publication digest");
|
|
30478
|
+
}
|
|
30479
|
+
completed++;
|
|
30480
|
+
log(`${result.added ? "+" : "="} ${formatCoordinate(coordinate)} (${result.digest})`);
|
|
30481
|
+
} catch (error) {
|
|
30482
|
+
throw new Error(`Push stopped at ${formatCoordinate(coordinate)} (${completed}/${prepared.length} completed): ${error instanceof Error ? error.message : "Publication failed"}`, { cause: error });
|
|
30483
|
+
}
|
|
30484
|
+
}
|
|
30485
|
+
if (selection.mode === "all") {
|
|
30486
|
+
log(`Published ${completed} local releases.`);
|
|
30487
|
+
}
|
|
30488
|
+
}
|
|
30489
|
+
|
|
30490
|
+
// packages/runtimes/ulvia-cli/src/commands/remote/index.ts
|
|
29954
30491
|
async function remoteCommand(action, args, repositoryRoot, environment, log) {
|
|
29955
|
-
|
|
30492
|
+
if (args.length === 1 && ["--help", "-h"].includes(args[0])) {
|
|
30493
|
+
log(remoteUsage(action));
|
|
30494
|
+
return;
|
|
30495
|
+
}
|
|
30496
|
+
const { selection, repositoryUrl, reason } = parseRemoteArguments(action, args, environment);
|
|
30497
|
+
if (action === "push") {
|
|
30498
|
+
await pushCommand(selection, repositoryUrl, repositoryRoot, environment, log);
|
|
30499
|
+
return;
|
|
30500
|
+
}
|
|
30501
|
+
if (selection.mode !== "one" || !selection.kind) {
|
|
30502
|
+
throw new Error(remoteUsage(action));
|
|
30503
|
+
}
|
|
30504
|
+
const coordinate = {
|
|
30505
|
+
kind: selection.kind,
|
|
30506
|
+
publisherId: selection.publisherId,
|
|
30507
|
+
id: selection.id,
|
|
30508
|
+
version: selection.version
|
|
30509
|
+
};
|
|
29956
30510
|
const client = new RemoteRepositoryClient(repositoryUrl, action === "pull" ? undefined : await remoteRepositoryCredential(repositoryUrl, coordinate.publisherId, environment));
|
|
29957
30511
|
if (action === "yank" || action === "restore") {
|
|
29958
30512
|
await client.yank(coordinate, action === "restore" ? null : reason);
|
|
29959
30513
|
log(`${action === "restore" ? "Restored" : "Yanked"} ${formatCoordinate(coordinate)}`);
|
|
29960
30514
|
return;
|
|
29961
30515
|
}
|
|
29962
|
-
if (action === "push") {
|
|
29963
|
-
const local = await loadLocal(repositoryRoot, coordinate);
|
|
29964
|
-
const result = await client.push(local.envelope);
|
|
29965
|
-
if (result.digest !== local.digest) {
|
|
29966
|
-
throw new Error("Remote repository returned a different publication digest");
|
|
29967
|
-
}
|
|
29968
|
-
log(`${result.added ? "+" : "="} ${formatCoordinate(coordinate)} (${result.digest})`);
|
|
29969
|
-
return;
|
|
29970
|
-
}
|
|
29971
30516
|
const sink = new RemoteAssetFileSink(repositoryRoot);
|
|
29972
30517
|
const remote = await client.pull(coordinate, sink);
|
|
29973
30518
|
let added;
|
|
@@ -29978,95 +30523,17 @@ async function remoteCommand(action, args, repositoryRoot, environment, log) {
|
|
|
29978
30523
|
}
|
|
29979
30524
|
log(`${added ? "+" : "="} ${formatCoordinate(coordinate)} (${remote.expectedDigest})`);
|
|
29980
30525
|
}
|
|
29981
|
-
async function loadLocal(root, coordinate) {
|
|
29982
|
-
const yanks = new LocalRepositoryYanks(root);
|
|
29983
|
-
if (await yanks.get(coordinate.kind, coordinate.publisherId, coordinate.id, coordinate.version)) {
|
|
29984
|
-
throw new Error("A locally yanked release cannot be pushed");
|
|
29985
|
-
}
|
|
29986
|
-
if (coordinate.kind === "collection") {
|
|
29987
|
-
const artifact = await new LocalCollectionRepository(root).get(coordinate.publisherId, coordinate.id, coordinate.version);
|
|
29988
|
-
if (!artifact) {
|
|
29989
|
-
throw new Error("Local collection release not found");
|
|
29990
|
-
}
|
|
29991
|
-
return {
|
|
29992
|
-
digest: artifact.digest,
|
|
29993
|
-
envelope: {
|
|
29994
|
-
kind: coordinate.kind,
|
|
29995
|
-
canonicalJson: artifact.canonicalJson,
|
|
29996
|
-
assets: await collectionAssets(artifact.assets)
|
|
29997
|
-
}
|
|
29998
|
-
};
|
|
29999
|
-
}
|
|
30000
|
-
const files = new LocalArtifactFiles(root);
|
|
30001
|
-
const type = coordinate.kind === "contract" ? "contracts" : "providers";
|
|
30002
|
-
const bytes = await files.get(type, coordinate.publisherId, coordinate.id, coordinate.version);
|
|
30003
|
-
if (!bytes) {
|
|
30004
|
-
throw new Error(`Local ${coordinate.kind} release not found`);
|
|
30005
|
-
}
|
|
30006
|
-
const canonicalJson = bytes.toString("utf8");
|
|
30007
|
-
const contracts = new LocalContractReleases(files, yanks);
|
|
30008
|
-
if (coordinate.kind === "contract") {
|
|
30009
|
-
const record = await (await contracts.catalogue()).get(coordinate.id, coordinate.version);
|
|
30010
|
-
return {
|
|
30011
|
-
digest: record.admission.digest,
|
|
30012
|
-
envelope: {
|
|
30013
|
-
kind: coordinate.kind,
|
|
30014
|
-
canonicalJson,
|
|
30015
|
-
assets: await contractAssets(files, canonicalJson)
|
|
30016
|
-
}
|
|
30017
|
-
};
|
|
30018
|
-
}
|
|
30019
|
-
const record = await (await new LocalProviderReleases(files, contracts, yanks).catalogue()).get(coordinate.id, coordinate.version);
|
|
30020
|
-
return {
|
|
30021
|
-
digest: record.admission.digest,
|
|
30022
|
-
envelope: { kind: coordinate.kind, canonicalJson, assets: [] }
|
|
30023
|
-
};
|
|
30024
|
-
}
|
|
30025
|
-
async function storeLocal(root, remote) {
|
|
30026
|
-
const files = new LocalArtifactFiles(root);
|
|
30027
|
-
const yanks = new LocalRepositoryYanks(root);
|
|
30028
|
-
const contracts = new LocalContractReleases(files, yanks);
|
|
30029
|
-
if (remote.kind === "collection") {
|
|
30030
|
-
const admission = await admitCollectionReleaseJson(remote.canonicalJson, remote.assets, {
|
|
30031
|
-
contracts: await contracts.catalogue()
|
|
30032
|
-
});
|
|
30033
|
-
assertDigest(admission.digest, remote.expectedDigest);
|
|
30034
|
-
return new LocalCollectionRepository(root).store(admission);
|
|
30035
|
-
}
|
|
30036
|
-
if (remote.kind === "contract") {
|
|
30037
|
-
const admission = remote.assets.length ? await admitContractBundleJson(remote.canonicalJson, remote.assets) : await admitContractReleaseJson(remote.canonicalJson);
|
|
30038
|
-
assertDigest(admission.digest, remote.expectedDigest);
|
|
30039
|
-
return (await contracts.publish(remote.canonicalJson, remote.assets)).added;
|
|
30040
|
-
}
|
|
30041
|
-
const admission = await admitProviderManifestJson(remote.canonicalJson, await contracts.catalogue());
|
|
30042
|
-
assertDigest(admission.digest, remote.expectedDigest);
|
|
30043
|
-
return (await new LocalProviderReleases(files, contracts, yanks).release(remote.canonicalJson)).added;
|
|
30044
|
-
}
|
|
30045
|
-
async function collectionAssets(assets) {
|
|
30046
|
-
return assets.map((asset) => ({ id: asset.id, bytes: asset.bytes }));
|
|
30047
|
-
}
|
|
30048
|
-
async function contractAssets(files, canonicalJson) {
|
|
30049
|
-
return (parseContractReleaseJson(canonicalJson).fixtureAssets ?? []).map((asset) => ({
|
|
30050
|
-
id: asset.id,
|
|
30051
|
-
bytes: files.fixtureBlob(canonicalJson, asset.id)
|
|
30052
|
-
}));
|
|
30053
|
-
}
|
|
30054
|
-
function assertDigest(actual, expected) {
|
|
30055
|
-
if (actual !== expected) {
|
|
30056
|
-
throw new Error(`Repository digest mismatch: expected ${expected}, received ${actual}`);
|
|
30057
|
-
}
|
|
30058
|
-
}
|
|
30059
30526
|
|
|
30060
30527
|
// packages/runtimes/ulvia-cli/src/runtime/stack/repository/project.ts
|
|
30061
30528
|
import { createHash as createHash11 } from "crypto";
|
|
30062
|
-
import { join as
|
|
30529
|
+
import { join as join35 } from "path";
|
|
30063
30530
|
async function repositoryProject(root, state) {
|
|
30064
|
-
await privateDirectory(
|
|
30531
|
+
await privateDirectory(join35(root, "data"));
|
|
30065
30532
|
const config = state.config;
|
|
30066
30533
|
const acme = config.tls.mode === "acme";
|
|
30067
30534
|
if (acme) {
|
|
30068
30535
|
for (const directory of ["certificates", "virtual-hosts", "challenge", "acme"]) {
|
|
30069
|
-
await privateDirectory(
|
|
30536
|
+
await privateDirectory(join35(root, "proxy", directory));
|
|
30070
30537
|
}
|
|
30071
30538
|
}
|
|
30072
30539
|
return {
|
|
@@ -30075,11 +30542,11 @@ async function repositoryProject(root, state) {
|
|
|
30075
30542
|
projectName: `ulvia-repository-${createHash11("sha256").update(root).digest("hex").slice(0, 12)}`,
|
|
30076
30543
|
environment: {
|
|
30077
30544
|
OFFICIAL_REPOSITORY_IMAGE: pinnedOfficialImageReference(state.image),
|
|
30078
|
-
ULVIA_REPOSITORY_DIR:
|
|
30545
|
+
ULVIA_REPOSITORY_DIR: join35(root, "data"),
|
|
30079
30546
|
ULVIA_REPOSITORY_PORT: String(state.config.port),
|
|
30080
30547
|
ULVIA_REPOSITORY_PUBLIC_URL: config.publicUrl,
|
|
30081
30548
|
ULVIA_REPOSITORY_DOMAIN: new URL(config.publicUrl).hostname,
|
|
30082
|
-
ULVIA_REPOSITORY_PROXY_DIR:
|
|
30549
|
+
ULVIA_REPOSITORY_PROXY_DIR: join35(root, "proxy"),
|
|
30083
30550
|
ULVIA_ACME_EMAIL: config.tls.mode === "acme" ? config.tls.email : "disabled@example.invalid",
|
|
30084
30551
|
ULVIA_UID: String(process.getuid?.() ?? 1000),
|
|
30085
30552
|
ULVIA_GID: String(process.getgid?.() ?? 1000)
|
|
@@ -30090,7 +30557,7 @@ async function repositoryProject(root, state) {
|
|
|
30090
30557
|
// packages/runtimes/ulvia-cli/src/runtime/stack/repository/config.ts
|
|
30091
30558
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
30092
30559
|
import { readFile as readFile19, rename as rename5, writeFile as writeFile9 } from "fs/promises";
|
|
30093
|
-
import { join as
|
|
30560
|
+
import { join as join36 } from "path";
|
|
30094
30561
|
function defaultRepositoryConfig(port = 5010) {
|
|
30095
30562
|
return {
|
|
30096
30563
|
schema: "ulvia.repository-deployment.v1",
|
|
@@ -30113,7 +30580,7 @@ function parseRepositoryConfig(value) {
|
|
|
30113
30580
|
return value;
|
|
30114
30581
|
}
|
|
30115
30582
|
async function readRepositoryConfig(root, fallback = defaultRepositoryConfig()) {
|
|
30116
|
-
const source = await readFile19(
|
|
30583
|
+
const source = await readFile19(join36(root, "config.json"), "utf8").catch((error) => {
|
|
30117
30584
|
if (error.code === "ENOENT") {
|
|
30118
30585
|
return null;
|
|
30119
30586
|
}
|
|
@@ -30127,21 +30594,21 @@ async function readRepositoryConfig(root, fallback = defaultRepositoryConfig())
|
|
|
30127
30594
|
async function saveRepositoryConfig(root, config) {
|
|
30128
30595
|
parseRepositoryConfig(config);
|
|
30129
30596
|
await privateDirectory(root);
|
|
30130
|
-
const temporary =
|
|
30597
|
+
const temporary = join36(root, `${randomUUID8()}.tmp`);
|
|
30131
30598
|
await writeFile9(temporary, `${JSON.stringify(config, null, 2)}
|
|
30132
30599
|
`, { flag: "wx", mode: 384 });
|
|
30133
|
-
await rename5(temporary,
|
|
30600
|
+
await rename5(temporary, join36(root, "config.json"));
|
|
30134
30601
|
}
|
|
30135
30602
|
|
|
30136
30603
|
// packages/runtimes/ulvia-cli/src/runtime/stack/repository/lifecycle.ts
|
|
30137
|
-
import { join as
|
|
30604
|
+
import { join as join38 } from "path";
|
|
30138
30605
|
|
|
30139
30606
|
// packages/runtimes/ulvia-cli/src/runtime/stack/repository/state.ts
|
|
30140
30607
|
import { readFile as readFile20, rename as rename6, writeFile as writeFile10 } from "fs/promises";
|
|
30141
30608
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
30142
|
-
import { join as
|
|
30609
|
+
import { join as join37 } from "path";
|
|
30143
30610
|
async function readRepositoryState(root) {
|
|
30144
|
-
const source = await readFile20(
|
|
30611
|
+
const source = await readFile20(join37(root, "service.json"), "utf8").catch((error) => {
|
|
30145
30612
|
if (error.code === "ENOENT") {
|
|
30146
30613
|
return null;
|
|
30147
30614
|
}
|
|
@@ -30158,15 +30625,15 @@ async function readRepositoryState(root) {
|
|
|
30158
30625
|
return value;
|
|
30159
30626
|
}
|
|
30160
30627
|
async function saveRepositoryState(root, state) {
|
|
30161
|
-
const temporary =
|
|
30628
|
+
const temporary = join37(root, `${randomUUID9()}.tmp`);
|
|
30162
30629
|
await writeFile10(temporary, `${JSON.stringify(state)}
|
|
30163
30630
|
`, { mode: 384, flag: "wx" });
|
|
30164
|
-
await rename6(temporary,
|
|
30631
|
+
await rename6(temporary, join37(root, "service.json"));
|
|
30165
30632
|
}
|
|
30166
30633
|
|
|
30167
30634
|
// packages/runtimes/ulvia-cli/src/runtime/stack/repository/lifecycle.ts
|
|
30168
30635
|
async function repositoryLifecycle(paths, action, options, log) {
|
|
30169
|
-
const root =
|
|
30636
|
+
const root = join38(paths.data, "repository-service");
|
|
30170
30637
|
await withRepositoryWriteLock(root, async () => {
|
|
30171
30638
|
const installed = await readRepositoryState(root);
|
|
30172
30639
|
if (action === "status" && !installed) {
|
|
@@ -30190,7 +30657,7 @@ async function repositoryLifecycle(paths, action, options, log) {
|
|
|
30190
30657
|
log(`Repository: ${service?.state ?? "stopped"}${service?.health ? ` / ${service.health}` : ""}`);
|
|
30191
30658
|
log(`Version: ${installed.image.version} (${installed.image.digest})`);
|
|
30192
30659
|
log(`Endpoint: ${installed.config.publicUrl}`);
|
|
30193
|
-
log(`Configuration: ${
|
|
30660
|
+
log(`Configuration: ${join38(root, "config.json")}`);
|
|
30194
30661
|
}
|
|
30195
30662
|
return;
|
|
30196
30663
|
}
|
|
@@ -30226,7 +30693,7 @@ async function repositoryLifecycle(paths, action, options, log) {
|
|
|
30226
30693
|
}
|
|
30227
30694
|
|
|
30228
30695
|
// packages/runtimes/ulvia-cli/src/commands/namespace/deployment.ts
|
|
30229
|
-
import { join as
|
|
30696
|
+
import { join as join39 } from "path";
|
|
30230
30697
|
function repositoryOptions(args, allowed) {
|
|
30231
30698
|
const values = new Map;
|
|
30232
30699
|
for (let index = 0;index < args.length; index += 2) {
|
|
@@ -30240,7 +30707,7 @@ function repositoryOptions(args, allowed) {
|
|
|
30240
30707
|
return values;
|
|
30241
30708
|
}
|
|
30242
30709
|
async function repositoryDeploymentCommand(args, paths, log) {
|
|
30243
|
-
const root =
|
|
30710
|
+
const root = join39(paths.data, "repository-service");
|
|
30244
30711
|
const values = repositoryOptions(args, ["--port", "--public-url", "--tls", "--acme-email"]);
|
|
30245
30712
|
await withRepositoryWriteLock(root, async () => {
|
|
30246
30713
|
const config = await readRepositoryConfig(root);
|
|
@@ -30261,11 +30728,11 @@ async function repositoryDeploymentCommand(args, paths, log) {
|
|
|
30261
30728
|
config.publicUrl = values.has("--public-url") ? normalizeRepositoryUrl(values.get("--public-url")) : mode === "local" ? `http://127.0.0.1:${config.port}` : config.publicUrl;
|
|
30262
30729
|
await saveRepositoryConfig(root, config);
|
|
30263
30730
|
});
|
|
30264
|
-
log(`Repository configuration saved: ${
|
|
30731
|
+
log(`Repository configuration saved: ${join39(root, "config.json")}. Run repository start to apply it.`);
|
|
30265
30732
|
}
|
|
30266
30733
|
|
|
30267
30734
|
// packages/runtimes/ulvia-cli/src/commands/local/repository.ts
|
|
30268
|
-
var
|
|
30735
|
+
var HELP3 = `Usage:
|
|
30269
30736
|
ulvia repository login <url> [--identity <name>]
|
|
30270
30737
|
ulvia repository logout
|
|
30271
30738
|
ulvia repository <start | stop | status>
|
|
@@ -30279,7 +30746,7 @@ TLS can use an external reverse proxy or a dedicated ACME proxy on ports 80/443.
|
|
|
30279
30746
|
No Provider, Kernel or database is started. Upgrades require a published version.`;
|
|
30280
30747
|
async function standaloneRepositoryCommand(args, paths, log, environment) {
|
|
30281
30748
|
if (!args.length || args.includes("--help") || args[0] === "help") {
|
|
30282
|
-
log(
|
|
30749
|
+
log(HELP3);
|
|
30283
30750
|
return;
|
|
30284
30751
|
}
|
|
30285
30752
|
const [action, ...rest] = args;
|
|
@@ -30287,7 +30754,7 @@ async function standaloneRepositoryCommand(args, paths, log, environment) {
|
|
|
30287
30754
|
if (action === "login") {
|
|
30288
30755
|
const values = repositoryOptions(rest.slice(1), ["--identity"]);
|
|
30289
30756
|
if (!rest[0]) {
|
|
30290
|
-
throw new Error(
|
|
30757
|
+
throw new Error(HELP3);
|
|
30291
30758
|
}
|
|
30292
30759
|
const id = await loginRepository(directory, rest[0], values.get("--identity"));
|
|
30293
30760
|
log(`Repository connection saved: ${(await readClientConfig(directory)).repository.url} (${id}). Writes use local owner keys.`);
|
|
@@ -30305,7 +30772,7 @@ async function standaloneRepositoryCommand(args, paths, log, environment) {
|
|
|
30305
30772
|
return;
|
|
30306
30773
|
}
|
|
30307
30774
|
if (!["start", "stop", "status", "upgrade"].includes(action)) {
|
|
30308
|
-
throw new Error(
|
|
30775
|
+
throw new Error(HELP3);
|
|
30309
30776
|
}
|
|
30310
30777
|
const values = repositoryOptions(rest, ["--version", "--port"]);
|
|
30311
30778
|
const version = values.get("--version");
|
|
@@ -30318,13 +30785,13 @@ async function standaloneRepositoryCommand(args, paths, log, environment) {
|
|
|
30318
30785
|
throw new Error("Repository port must be an integer between 1 and 65535");
|
|
30319
30786
|
}
|
|
30320
30787
|
if (action === "upgrade" && (!version || port !== undefined) || (action === "stop" || action === "status") && rest.length) {
|
|
30321
|
-
throw new Error(
|
|
30788
|
+
throw new Error(HELP3);
|
|
30322
30789
|
}
|
|
30323
30790
|
await repositoryLifecycle(paths, action, { version, port }, log);
|
|
30324
30791
|
}
|
|
30325
30792
|
|
|
30326
30793
|
// packages/runtimes/ulvia-cli/src/commands/namespace/command.ts
|
|
30327
|
-
var
|
|
30794
|
+
var HELP4 = `Usage:
|
|
30328
30795
|
ulvia namespace <claim | status | rotate | revoke> <namespace> [--repository <url>] [--identity <name>] [--replacement-identity <name>] [--yes]
|
|
30329
30796
|
|
|
30330
30797
|
Mutations use saved local identities; --identity selects a claim owner.
|
|
@@ -30334,27 +30801,27 @@ Revoke requires --yes and is permanent. There is no operator key recovery.`;
|
|
|
30334
30801
|
async function namespaceCommand(args, environment, log) {
|
|
30335
30802
|
const [action, namespace, ...rest] = args;
|
|
30336
30803
|
if (!action || action === "--help" || action === "help") {
|
|
30337
|
-
log(
|
|
30804
|
+
log(HELP4);
|
|
30338
30805
|
return;
|
|
30339
30806
|
}
|
|
30340
30807
|
if (!namespace || !["claim", "status", "rotate", "revoke"].includes(action)) {
|
|
30341
|
-
throw new Error(
|
|
30808
|
+
throw new Error(HELP4);
|
|
30342
30809
|
}
|
|
30343
30810
|
const values = new Map;
|
|
30344
30811
|
for (let index = 0;index < rest.length; index++) {
|
|
30345
30812
|
const key = rest[index];
|
|
30346
30813
|
if (values.has(key) || !["--repository", "--replacement-identity", "--identity", "--yes"].includes(key)) {
|
|
30347
|
-
throw new Error(
|
|
30814
|
+
throw new Error(HELP4);
|
|
30348
30815
|
}
|
|
30349
30816
|
const value = key === "--yes" ? "true" : rest[++index];
|
|
30350
30817
|
if (!value || value.startsWith("--")) {
|
|
30351
|
-
throw new Error(
|
|
30818
|
+
throw new Error(HELP4);
|
|
30352
30819
|
}
|
|
30353
30820
|
values.set(key, value);
|
|
30354
30821
|
}
|
|
30355
30822
|
const url = values.get("--repository") ?? environment.ULVIA_REPOSITORY_URL;
|
|
30356
30823
|
if (!url || action === "revoke" && !values.has("--yes") || values.has("--yes") && action !== "revoke" || values.has("--replacement-identity") && action !== "rotate") {
|
|
30357
|
-
throw new Error(
|
|
30824
|
+
throw new Error(HELP4);
|
|
30358
30825
|
}
|
|
30359
30826
|
const client = new RepositoryNamespaceClient(url);
|
|
30360
30827
|
const repositoryId = await client.identity();
|
|
@@ -30377,7 +30844,7 @@ async function namespaceCommand(args, environment, log) {
|
|
|
30377
30844
|
} else if (action === "rotate") {
|
|
30378
30845
|
const name = values.get("--replacement-identity");
|
|
30379
30846
|
if (!name) {
|
|
30380
|
-
throw new Error(
|
|
30847
|
+
throw new Error(HELP4);
|
|
30381
30848
|
}
|
|
30382
30849
|
const replacement = await selectIdentity(directory, name);
|
|
30383
30850
|
const key = await readNamespacePrivateKey(replacement.keyFile);
|
|
@@ -30389,7 +30856,7 @@ async function namespaceCommand(args, environment, log) {
|
|
|
30389
30856
|
}
|
|
30390
30857
|
|
|
30391
30858
|
// packages/runtimes/ulvia-cli/src/cli.ts
|
|
30392
|
-
var
|
|
30859
|
+
var HELP5 = `Ulvia CMS CLI
|
|
30393
30860
|
|
|
30394
30861
|
Usage:
|
|
30395
30862
|
ulvia start [--version <version>]
|
|
@@ -30406,8 +30873,8 @@ Usage:
|
|
|
30406
30873
|
ulvia instance delete <name> --yes
|
|
30407
30874
|
ulvia upgrade <kernel | provider | repository> --version <version>
|
|
30408
30875
|
ulvia reset --yes
|
|
30409
|
-
ulvia release <resource-directory>
|
|
30410
|
-
ulvia push <
|
|
30876
|
+
ulvia release <resource-directory> [--recursive]
|
|
30877
|
+
ulvia push <publisher/id@version | all> [--repository <url>]
|
|
30411
30878
|
ulvia pull <kind> <publisher/id@version> --repository <url>
|
|
30412
30879
|
ulvia yank <kind> <publisher/id@version> --repository <url> --reason <text>
|
|
30413
30880
|
ulvia restore <kind> <publisher/id@version> --repository <url>
|
|
@@ -30423,8 +30890,8 @@ Commands:
|
|
|
30423
30890
|
instance Create and manage independent Kernel instances
|
|
30424
30891
|
upgrade Pull and install one exact official Docker image version
|
|
30425
30892
|
reset Delete all instances, services data, and repository releases after --yes
|
|
30426
|
-
release Validate and store
|
|
30427
|
-
push Publish one
|
|
30893
|
+
release Validate and store one resource or a recursive resource batch
|
|
30894
|
+
push Publish one local release or all non-yanked local releases
|
|
30428
30895
|
pull Validate and store one exact remote release locally
|
|
30429
30896
|
yank Hide a remote release from new catalogue resolutions
|
|
30430
30897
|
restore Make a yanked remote release resolvable again
|
|
@@ -30445,7 +30912,7 @@ async function runCli(args, options = {}) {
|
|
|
30445
30912
|
const log = options.log ?? console.log;
|
|
30446
30913
|
const command = args[0];
|
|
30447
30914
|
if (!command || command === "help" || command === "--help" || command === "-h") {
|
|
30448
|
-
log(
|
|
30915
|
+
log(HELP5.trimEnd());
|
|
30449
30916
|
return;
|
|
30450
30917
|
}
|
|
30451
30918
|
if (command === "--version" || command === "-v") {
|