@orkestrel/scaffold 0.0.26 → 0.0.28

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.
@@ -1,5 +1,5 @@
1
1
  import { andOf, arrayOf, attempt, boundsOf, holds, isArray, isBoolean, isError, isFunction, isInteger, isRecord, isString, parseJSON, parseJSONAs, parseStringField, recordOf, stringOf } from "@orkestrel/contract";
2
- import { CATALOG_AGENT_PATH, CONTROL_CHARACTER_PATTERN, EXECUTABLE_PATHS, HOST_PATHS, MAX_ARTIFACT_BYTES, MAX_COLLECTION_ITEMS, MAX_MANIFEST_BYTES, MAX_PATH_LENGTH, MAX_RANGE_LENGTH, MAX_TOTAL_ARTIFACT_BYTES, ScaffoldError, bytesToHex, cloneValue, computeBytes, contentToHex, inferGroup, isAudit, isCatalogEntry, isCollection, isDependency, isDependencyName, isMirror, isPath, isPlan, isSnapshot, matchesDriftReachability, nameToGuide, planToFindings } from "../core/index.js";
2
+ import { CATALOG_AGENT_PATH, CONTROL_CHARACTER_PATTERN, EXECUTABLE_PATHS, HOST_PATHS, MAX_ARTIFACT_BYTES, MAX_COLLECTION_ITEMS, MAX_DEPENDENCY_NAME_LENGTH, MAX_MANIFEST_BYTES, MAX_PATH_LENGTH, MAX_RANGE_LENGTH, MAX_TOTAL_ARTIFACT_BYTES, ScaffoldError, bytesToHex, catalogToLayers, cloneValue, computeBytes, contentToHex, inferGroup, isAudit, isCatalogEntry, isCollection, isDependency, isDependencyName, isMirror, isPath, isPlan, isSnapshot, matchesDriftReachability, nameToGuide, planToFindings } from "../core/index.js";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import { chmodSync, closeSync, constants, copyFileSync, fstatSync, linkSync, lstatSync, mkdirSync, openSync, opendirSync, readSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, rmdirSync, writeFileSync } from "node:fs";
5
5
  import { basename, dirname, join, parse, relative, resolve, sep } from "node:path";
@@ -2835,10 +2835,18 @@ var Materializer = class Materializer {
2835
2835
  transaction.copy(artifact.path, source, entry?.executable === true);
2836
2836
  }
2837
2837
  #recatalog(entries) {
2838
+ const layers = catalogToLayers(entries);
2839
+ const placed = /* @__PURE__ */ new Map();
2840
+ for (const [index, layer] of layers.entries()) for (const name of layer) placed.set(name, index);
2838
2841
  const table = [
2839
- "| Package | Version |",
2840
- "| --- | --- |",
2841
- ...entries.map((entry) => `| \`${entry.name}\` | ${entry.lookup === "found" ? `\`${entry.version}\`` : this.#cell(entry.note)} |`)
2842
+ "| Package | Version | Layer | Runtime dependencies |",
2843
+ "| --- | --- | --- | --- |",
2844
+ ...entries.map((entry) => {
2845
+ if (entry.lookup !== "found") return `| \`${entry.name}\` | ${this.#cell(entry.note)} | | |`;
2846
+ const layer = placed.get(entry.name);
2847
+ const edges = entry.dependencies.map((dependency) => `\`${dependency.name}\` \`${dependency.range}\``).join(", ");
2848
+ return `| \`${entry.name}\` | \`${entry.version}\` | ${layer === void 0 ? "" : `L${String(layer)}`} | ${edges} |`;
2849
+ })
2842
2850
  ].join("\n");
2843
2851
  return (text) => {
2844
2852
  const opening = text.indexOf(Materializer.#opening);
@@ -3193,7 +3201,8 @@ var Upstream = class Upstream {
3193
3201
  if (version !== void 0) return {
3194
3202
  name,
3195
3203
  lookup: "found",
3196
- version
3204
+ version,
3205
+ dependencies: this.#edges(outcome.content, version)
3197
3206
  };
3198
3207
  return {
3199
3208
  name,
@@ -3201,6 +3210,28 @@ var Upstream = class Upstream {
3201
3210
  note: outcome.lookup === "found" ? Upstream.#unreadable : outcome.note
3202
3211
  };
3203
3212
  }
3213
+ #edges(content, version) {
3214
+ const parsed = parseJSON(content);
3215
+ if (!isRecord(parsed)) return [];
3216
+ const versions = parsed.versions;
3217
+ if (!isRecord(versions)) return [];
3218
+ const manifest = versions[version];
3219
+ if (!isRecord(manifest)) return [];
3220
+ const declared = manifest.dependencies;
3221
+ if (!isRecord(declared)) return [];
3222
+ const edges = [];
3223
+ for (const [name, range] of Object.entries(declared)) {
3224
+ if (edges.length >= MAX_COLLECTION_ITEMS) break;
3225
+ if (typeof range !== "string" || range.length === 0 || range.length > MAX_RANGE_LENGTH) continue;
3226
+ if (CONTROL_CHARACTER_PATTERN.test(name) || CONTROL_CHARACTER_PATTERN.test(range)) continue;
3227
+ if (name.length === 0 || name.length > MAX_DEPENDENCY_NAME_LENGTH) continue;
3228
+ edges.push({
3229
+ name,
3230
+ range
3231
+ });
3232
+ }
3233
+ return edges;
3234
+ }
3204
3235
  async #packages(allowance) {
3205
3236
  const url = `${this.#registryBase}/-/org/${Upstream.#scope}/package`;
3206
3237
  const outcome = await this.#read(url, this.#registryTimeout, allowance);