@orkestrel/scaffold 0.0.49 → 0.0.50

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.
@@ -292,6 +292,29 @@ var isDependencyNames = (0, _orkestrel_contract.andOf)(_src_core.isCollection, (
292
292
  var isPaths = (0, _orkestrel_contract.andOf)(_src_core.isCollection, (0, _orkestrel_contract.arrayOf)(_src_core.isPath));
293
293
  /** Narrow a value to a bounded list of declared runtime dependencies. */
294
294
  var isDependencies = (0, _orkestrel_contract.andOf)(_src_core.isCollection, (0, _orkestrel_contract.arrayOf)(_src_core.isDependency));
295
+ /**
296
+ * Narrow a value to one {@link ManifestRegionSet}.
297
+ *
298
+ * @remarks
299
+ * The whole closed record a manifest-writing method accepts, so a caller
300
+ * naming a region the writer does not carry is refused before any byte moves.
301
+ * Each region is bounded by the same collection law its own list guard applies.
302
+ *
303
+ * @example
304
+ * ```ts
305
+ * import { isManifestRegionSet } from '@orkestrel/scaffold/server'
306
+ *
307
+ * isManifestRegionSet({ pins: { runtime: [], development: [] }, scripts: [] }) // true
308
+ * isManifestRegionSet({ pins: { runtime: [], development: [] } }) // false
309
+ * ```
310
+ */
311
+ var isManifestRegionSet = (0, _orkestrel_contract.recordOf)({
312
+ pins: (0, _orkestrel_contract.recordOf)({
313
+ runtime: isDependencies,
314
+ development: isDependencies
315
+ }),
316
+ scripts: (0, _orkestrel_contract.andOf)(_src_core.isCollection, (0, _orkestrel_contract.arrayOf)(_src_core.isManifestScript))
317
+ });
295
318
  /** Narrow a value to a bounded list of fetched guide mirrors. */
296
319
  var isMirrors = (0, _orkestrel_contract.andOf)(_src_core.isCollection, (0, _orkestrel_contract.arrayOf)(_src_core.isMirror));
297
320
  /** Narrow a value to a bounded list of fleet catalog rows. */
@@ -2786,26 +2809,32 @@ var Materializer = class Materializer {
2786
2809
  return this.#rewrite(directory, _src_core.CATALOG_AGENT_PATH, _src_core.MAX_ARTIFACT_BYTES, this.#recatalog(accepted));
2787
2810
  }
2788
2811
  /**
2789
- * Rewrite the declared dependency ranges the caller names in the target's manifest.
2812
+ * Rewrite the manifest regions the caller names in the target's manifest.
2790
2813
  *
2791
- * @param dependencies - The names and ranges the manifest must declare.
2814
+ * @param regions - The dependency ranges and script values the manifest must declare.
2792
2815
  * @param target - The directory to write into.
2793
- * @returns The manifest path, written when a declared range moved and skipped otherwise.
2816
+ * @returns The manifest path, written when a named region moved and skipped otherwise.
2794
2817
  * @throws {@link ScaffoldError} coded `INVALID` when an argument is not the
2795
2818
  * exact shape or names a package the manifest does not declare, `TARGET` when
2796
2819
  * the manifest is unreadable, `WRITE` when the write cannot be staged or
2797
2820
  * committed, and `DESTROYED` after teardown.
2798
2821
  *
2799
2822
  * @remarks
2800
- * No other part of the manifest is read back out or rewritten, so a consumer's
2801
- * own description, keywords, scripts, and formatting survive the call. Only a
2802
- * range already declared is rewritten: inserting a package would mean
2803
- * re-serializing the whole manifest, which is exactly the edit this verb
2804
- * promises not to make, so an undeclared name is refused by name instead.
2823
+ * No other part of the manifest is read back out or rewritten. The method
2824
+ * never reads or writes `peerDependencies` or `peerDependenciesMeta`. Only a
2825
+ * range already declared in its named writable section is rewritten, so an
2826
+ * undeclared name is refused instead of inserted.
2827
+ *
2828
+ * The regions refuse differently because their targets differ. A range
2829
+ * the manifest does not declare is the caller's mistake and throws. A script
2830
+ * holding a value the region does not accept is the workspace author's own
2831
+ * chain, so the script region is skipped without a byte moving and the range
2832
+ * region is still written. The advisory channel reports what the maintainer
2833
+ * must paste.
2805
2834
  */
2806
- declare(dependencies, target) {
2835
+ declare(regions, target) {
2807
2836
  this.#assertAlive();
2808
- const accepted = this.#accept(dependencies, isDependencies, "dependencies");
2837
+ const accepted = this.#accept(regions, isManifestRegionSet, "regions");
2809
2838
  const directory = this.#accept(target, isFilesystemPath, "target");
2810
2839
  return this.#rewrite(directory, "package.json", _src_core.MAX_MANIFEST_BYTES, this.#redeclare(accepted));
2811
2840
  }
@@ -3342,12 +3371,14 @@ var Materializer = class Materializer {
3342
3371
  #cell(note) {
3343
3372
  return note.replaceAll("|", "\\|").replaceAll(/\s+/gu, " ").trim();
3344
3373
  }
3345
- #redeclare(dependencies) {
3374
+ #redeclare(regions) {
3346
3375
  return (text) => {
3347
- const manifest = (0, _src_core.replaceManifestRanges)(text, dependencies);
3348
- if (manifest !== void 0) return manifest;
3349
- const missing = dependencies.find((dependency) => !text.includes(JSON.stringify(dependency.name)));
3350
- throw this.#error("INVALID", `The manifest does not declare ${missing?.name ?? "a requested package"}, so its range cannot be rewritten.`, missing === void 0 ? void 0 : { name: missing.name });
3376
+ const manifest = (0, _src_core.replaceManifestRanges)(text, regions.pins);
3377
+ if (manifest === void 0) {
3378
+ const missing = [...regions.pins.runtime, ...regions.pins.development].find((dependency) => !text.includes(JSON.stringify(dependency.name)));
3379
+ throw this.#error("INVALID", `The manifest does not declare ${missing?.name ?? "a requested package"}, so its range cannot be rewritten.`, missing === void 0 ? void 0 : { name: missing.name });
3380
+ }
3381
+ return (0, _src_core.replaceManifestScripts)(manifest, regions.scripts) ?? manifest;
3351
3382
  };
3352
3383
  }
3353
3384
  #finish(result) {
@@ -4140,6 +4171,7 @@ exports.isHost = isHost;
4140
4171
  exports.isHostManifest = isHostManifest;
4141
4172
  exports.isInventory = isInventory;
4142
4173
  exports.isManifestEntry = isManifestEntry;
4174
+ exports.isManifestRegionSet = isManifestRegionSet;
4143
4175
  exports.isMaterializerHooks = isMaterializerHooks;
4144
4176
  exports.isMaterializerOptions = isMaterializerOptions;
4145
4177
  exports.isMirrors = isMirrors;