@orkestrel/scaffold 0.0.85 → 0.0.86

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.
@@ -2145,7 +2145,8 @@ var isDependencies = (0, _orkestrel_contract.andOf)(_src_core.isCollection, (0,
2145
2145
  * @remarks
2146
2146
  * The whole closed record a manifest-writing method accepts, so a caller
2147
2147
  * naming a region the writer does not carry is refused before any byte moves.
2148
- * Each region is bounded by the same collection law its own list guard applies.
2148
+ * Each region is bounded by the same collection law its own list guard applies,
2149
+ * and `additions` is the one region a caller may omit.
2149
2150
  *
2150
2151
  * @example
2151
2152
  * ```ts
@@ -2153,6 +2154,11 @@ var isDependencies = (0, _orkestrel_contract.andOf)(_src_core.isCollection, (0,
2153
2154
  *
2154
2155
  * isManifestRegionSet({ pins: { runtime: [], development: [] }, scripts: [] }) // true
2155
2156
  * isManifestRegionSet({ pins: { runtime: [], development: [] } }) // false
2157
+ * isManifestRegionSet({
2158
+ * pins: { runtime: [], development: [] },
2159
+ * scripts: [],
2160
+ * additions: { runtime: [], development: [{ name: 'typescript', range: '^6.0.3' }] },
2161
+ * }) // true
2156
2162
  * ```
2157
2163
  */
2158
2164
  var isManifestRegionSet = (0, _orkestrel_contract.recordOf)({
@@ -2160,8 +2166,12 @@ var isManifestRegionSet = (0, _orkestrel_contract.recordOf)({
2160
2166
  runtime: isDependencies,
2161
2167
  development: isDependencies
2162
2168
  }),
2163
- scripts: (0, _orkestrel_contract.andOf)(_src_core.isCollection, (0, _orkestrel_contract.arrayOf)(_src_core.isManifestScript))
2164
- });
2169
+ scripts: (0, _orkestrel_contract.andOf)(_src_core.isCollection, (0, _orkestrel_contract.arrayOf)(_src_core.isManifestScript)),
2170
+ additions: (0, _orkestrel_contract.recordOf)({
2171
+ runtime: isDependencies,
2172
+ development: isDependencies
2173
+ })
2174
+ }, ["additions"]);
2165
2175
  /** Narrows a value to a bounded list of fetched guide mirrors. */
2166
2176
  var isMirrors = (0, _orkestrel_contract.andOf)(_src_core.isCollection, (0, _orkestrel_contract.arrayOf)(_src_core.isMirror));
2167
2177
  /** Narrows a value to a bounded list of fleet catalog rows. */
@@ -3153,11 +3163,13 @@ var Materializer = class {
3153
3163
  /**
3154
3164
  * Rewrites the manifest regions the caller names in the target's manifest.
3155
3165
  *
3156
- * @param regions - The dependency ranges and script values the manifest must declare.
3166
+ * @param regions - The dependency ranges, script values, and additions the manifest must declare.
3157
3167
  * @param target - The directory to write into.
3158
3168
  * @returns The manifest path, written when a named region moved and skipped otherwise.
3159
3169
  * @throws {@link ScaffoldError} coded `INVALID` when an argument is not the
3160
- * exact shape or names a package the manifest does not declare, `TARGET` when
3170
+ * exact shape, names a range the manifest does not declare, or names an
3171
+ * addition the manifest already declares or whose section is not an object
3172
+ * of version strings, `TARGET` when
3161
3173
  * the manifest is unreadable, `WRITE` when the write cannot be staged or
3162
3174
  * committed, and `DESTROYED` after teardown.
3163
3175
  *
@@ -3165,7 +3177,10 @@ var Materializer = class {
3165
3177
  * No other part of the manifest is read back out or rewritten. The method
3166
3178
  * never reads or writes `peerDependencies` or `peerDependenciesMeta`. Only a
3167
3179
  * range already declared in its named writable section is rewritten, so an
3168
- * undeclared name is refused instead of inserted.
3180
+ * undeclared pin is refused instead of inserted. An undeclared package enters
3181
+ * the manifest only through `additions`, which inserts it into the section its
3182
+ * list names in key order, creating that section when the manifest lacks it,
3183
+ * before the ranges are rewritten.
3169
3184
  *
3170
3185
  * The regions refuse differently because their targets differ. A range
3171
3186
  * the manifest does not declare is the caller's mistake and throws. A script
@@ -3769,7 +3784,16 @@ var Materializer = class {
3769
3784
  }
3770
3785
  #redeclare(regions) {
3771
3786
  return (text) => {
3772
- const manifest = (0, _src_core.replaceManifestRanges)(text, regions.pins);
3787
+ const additions = regions.additions ?? {
3788
+ runtime: [],
3789
+ development: []
3790
+ };
3791
+ const declared = (0, _src_core.insertManifestDependencies)(text, additions);
3792
+ if (declared === void 0) {
3793
+ const names = [...additions.runtime, ...additions.development].map(({ name }) => name);
3794
+ throw this.#error("INVALID", `The manifest cannot declare ${names.join(", ")}: it already declares one of them, or the section that receives them is not an object of version strings.`, { names: names.length });
3795
+ }
3796
+ const manifest = (0, _src_core.replaceManifestRanges)(declared, regions.pins);
3773
3797
  if (manifest === void 0) {
3774
3798
  const missing = [...regions.pins.runtime, ...regions.pins.development].find((dependency) => !text.includes(JSON.stringify(dependency.name)));
3775
3799
  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 });