@orkestrel/scaffold 0.0.10 → 0.0.12

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.
@@ -141,7 +141,8 @@ export declare const DEFAULT_SYNC_TIMEOUT = 10000;
141
141
  * `app/<environment>/`; a target with no environment on either axis is also a coded
142
142
  * `TARGET` failure. The `bin`, `integration`, and `service` facts probe physical
143
143
  * directories at `src/bin`, `tests/integration`, and `tests/service`, respectively,
144
- * never the workspace name. `dependencies` /
144
+ * while `global` probes the physical exact-case `tests/setupGlobal.ts` file; none is
145
+ * inferred from the workspace name. `dependencies` /
145
146
  * `peers` are the `@orkestrel/`-prefixed entries of `manifest.dependencies` /
146
147
  * `manifest.peerDependencies` (a peer flagged `peerDependenciesMeta[name]
147
148
  * .optional === true` carries `optional: true`). `extras` is EVERY entry of
@@ -141,7 +141,8 @@ export declare const DEFAULT_SYNC_TIMEOUT = 10000;
141
141
  * `app/<environment>/`; a target with no environment on either axis is also a coded
142
142
  * `TARGET` failure. The `bin`, `integration`, and `service` facts probe physical
143
143
  * directories at `src/bin`, `tests/integration`, and `tests/service`, respectively,
144
- * never the workspace name. `dependencies` /
144
+ * while `global` probes the physical exact-case `tests/setupGlobal.ts` file; none is
145
+ * inferred from the workspace name. `dependencies` /
145
146
  * `peers` are the `@orkestrel/`-prefixed entries of `manifest.dependencies` /
146
147
  * `manifest.peerDependencies` (a peer flagged `peerDependenciesMeta[name]
147
148
  * .optional === true` carries `optional: true`). `extras` is EVERY entry of
@@ -1,7 +1,7 @@
1
- import { CONTROL_CHARACTER_PATTERN, DEFAULT_ENGINES, DEFAULT_VERSION, DEPENDENCY_NAME_PATTERN, ENVIRONMENTS, HEX_PATTERN, HOST_PATHS, INVALID_PATH_CHARACTER_PATTERN, MAX_ARTIFACT_BYTES, MAX_ARTIFACT_HEX_LENGTH, MAX_COLLECTION_ITEMS, MAX_MANIFEST_BYTES, MAX_PATH_LENGTH, MAX_TOTAL_ARTIFACT_BYTES, SERVICE_SCRIPT_PATH, SYNC_BASELINE_PATTERN, ScaffoldError, VERSION_PATTERN, blueprint, bytesToHex, contentByteLength, devDependenciesFor, diffPlan, findFileConflict, findPathConflict, hasOnlyDataProperties, hasValidAuditBytes, hasValidSnapshotBytes, isDenseDataArray, isDependency, isEmitterErrorHandler, isPlan, isSyncReport, isWorkspaceName, manifestToDependencies, manifestToName, ownDataValue, parsePlan, parseSyncReport, rangeToFreshness, snapshotPlan, validateDependencyArray, validatePlan } from "../core/index.js";
1
+ import { CONTROL_CHARACTER_PATTERN, DEFAULT_ENGINES, DEFAULT_VERSION, DEPENDENCY_NAME_PATTERN, ENVIRONMENTS, GLOBAL_SETUP_PATH, HEX_PATTERN, HOST_PATHS, INVALID_PATH_CHARACTER_PATTERN, MAX_ARTIFACT_BYTES, MAX_ARTIFACT_HEX_LENGTH, MAX_COLLECTION_ITEMS, MAX_MANIFEST_BYTES, MAX_PATH_LENGTH, MAX_TOTAL_ARTIFACT_BYTES, SERVICE_SCRIPT_PATH, SYNC_BASELINE_PATTERN, ScaffoldError, VERSION_PATTERN, blueprint, bytesToHex, contentByteLength, devDependenciesFor, diffPlan, findFileConflict, findPathConflict, hasOnlyDataProperties, hasValidAuditBytes, hasValidSnapshotBytes, isDenseDataArray, isDependency, isEmitterErrorHandler, isPlan, isSyncReport, isWorkspaceName, manifestToDependencies, manifestToName, ownDataValue, parsePlan, parseSyncReport, rangeToFreshness, snapshotPlan, validateDependencyArray, validatePlan } from "../core/index.js";
2
2
  import { attempt, booleanShape, createContract, integerShape, isError, isFunction, isRecord, isString, objectShape, optionalShape, parseJSON, parseJSONAs, stringShape } from "@orkestrel/contract";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
- import { chmodSync, closeSync, constants, copyFileSync, existsSync, fstatSync, linkSync, lstatSync, mkdirSync, openSync, opendirSync, readSync, realpathSync, renameSync, rmSync, rmdirSync, writeFileSync } from "node:fs";
4
+ import { chmodSync, closeSync, constants, copyFileSync, existsSync, fstatSync, linkSync, lstatSync, mkdirSync, openSync, opendirSync, readSync, readdirSync, realpathSync, renameSync, rmSync, rmdirSync, writeFileSync } from "node:fs";
5
5
  import { basename, dirname, join, relative, resolve, sep } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  import { flattenText, isBlockquoteNode, isParagraphNode, parseDocument, walkNodes } from "@orkestrel/markdown";
@@ -1745,7 +1745,8 @@ function selectOrkestrelEntries(value) {
1745
1745
  * `app/<environment>/`; a target with no environment on either axis is also a coded
1746
1746
  * `TARGET` failure. The `bin`, `integration`, and `service` facts probe physical
1747
1747
  * directories at `src/bin`, `tests/integration`, and `tests/service`, respectively,
1748
- * never the workspace name. `dependencies` /
1748
+ * while `global` probes the physical exact-case `tests/setupGlobal.ts` file; none is
1749
+ * inferred from the workspace name. `dependencies` /
1749
1750
  * `peers` are the `@orkestrel/`-prefixed entries of `manifest.dependencies` /
1750
1751
  * `manifest.peerDependencies` (a peer flagged `peerDependenciesMeta[name]
1751
1752
  * .optional === true` carries `optional: true`). `extras` is EVERY entry of
@@ -1774,7 +1775,8 @@ function selectOrkestrelEntries(value) {
1774
1775
  * ```
1775
1776
  */
1776
1777
  function deriveBlueprint(target) {
1777
- const parsed = parseJSON(readManifest(target));
1778
+ const text = readManifest(target);
1779
+ const parsed = parseJSON(text);
1778
1780
  if (!isRecord(parsed)) throw new ScaffoldError("TARGET", `Manifest at ${target} is not a valid JSON object`, { target });
1779
1781
  const src = ENVIRONMENTS.filter((environment) => isRealDirectory(join(target, "src", environment)));
1780
1782
  const app = ENVIRONMENTS.filter((environment) => isRealDirectory(join(target, "app", environment)));
@@ -1798,11 +1800,15 @@ function deriveBlueprint(target) {
1798
1800
  const keywords = Array.isArray(rawKeywords) && rawKeywords.every((word) => typeof word === "string") ? rawKeywords : [];
1799
1801
  const rawVersion = ownDataValue(parsed, "version");
1800
1802
  const version = typeof rawVersion === "string" ? rawVersion : DEFAULT_VERSION;
1801
- const rawNode = ownDataValue(ownDataValue(parsed, "engines"), "node");
1803
+ const rawEngines = ownDataValue(parsed, "engines");
1804
+ const rawNode = ownDataValue(rawEngines, "node");
1802
1805
  const engines = typeof rawNode === "string" ? rawNode : DEFAULT_ENGINES;
1803
1806
  const bin = isRealDirectory(join(target, "src", "bin"));
1804
1807
  const integration = isRealDirectory(join(target, "tests", "integration"));
1805
1808
  const service = isRealDirectory(join(target, "tests", "service"));
1809
+ const tests = join(target, dirname(GLOBAL_SETUP_PATH));
1810
+ const entries = attempt(() => readdirSync(tests));
1811
+ const global = entries.success && entries.value.includes(basename(GLOBAL_SETUP_PATH)) && isRealFile(join(target, GLOBAL_SETUP_PATH));
1806
1812
  if (service) {
1807
1813
  const missing = [];
1808
1814
  if (!isRealFile(join(target, "tests", "setupService.ts"))) missing.push("tests/setupService.ts");
@@ -1840,7 +1846,8 @@ function deriveBlueprint(target) {
1840
1846
  extras: [],
1841
1847
  bin,
1842
1848
  integration,
1843
- service
1849
+ service,
1850
+ global
1844
1851
  }))));
1845
1852
  const rawDevDependencies = ownDataValue(parsed, "devDependencies");
1846
1853
  const devDependencies = isRecord(rawDevDependencies) ? rawDevDependencies : {};
@@ -1861,7 +1868,8 @@ function deriveBlueprint(target) {
1861
1868
  overrides: [],
1862
1869
  bin,
1863
1870
  integration,
1864
- service
1871
+ service,
1872
+ global
1865
1873
  });
1866
1874
  }
1867
1875
  /**
@@ -2516,7 +2524,8 @@ function stageHost(root, out, paths = HOST_PATHS) {
2516
2524
  root,
2517
2525
  destination: entry.destination
2518
2526
  });
2519
- mkdirSync(dirname(resolvePhysicalPath(staging, entry.storage, "WRITE", "staging")), { recursive: true });
2527
+ const destination = resolvePhysicalPath(staging, entry.storage, "WRITE", "staging");
2528
+ mkdirSync(dirname(destination), { recursive: true });
2520
2529
  validateWriteAnchor(stagingAnchor, "host staging root");
2521
2530
  const containedDestination = resolvePhysicalPath(staging, entry.storage, "WRITE", "staging");
2522
2531
  copyFileSync(source, containedDestination, constants.COPYFILE_EXCL);
@@ -3228,7 +3237,8 @@ var Materializer = class {
3228
3237
  const sourceDigest = digestFile(source);
3229
3238
  const expectedHex = preview.value[file.path];
3230
3239
  if (expectedHex === void 0 || sourceDigest !== digestHex(expectedHex)) throw new ScaffoldError("WRITE", `Prune target changed at ${file.path}`, { path: file.path });
3231
- mkdirSync(dirname(resolvePhysicalPath(transaction.backup, file.path, "WRITE", "quarantine")), { recursive: true });
3240
+ const destination = resolvePhysicalPath(transaction.backup, file.path, "WRITE", "quarantine");
3241
+ mkdirSync(dirname(destination), { recursive: true });
3232
3242
  validateWriteTarget(transaction, void 0);
3233
3243
  const containedDestination = resolvePhysicalPath(transaction.backup, file.path, "WRITE", "quarantine");
3234
3244
  renameSync(source, containedDestination);
@@ -3344,7 +3354,8 @@ var Materializer = class {
3344
3354
  return;
3345
3355
  }
3346
3356
  if (manifest === void 0 && artifact.hex === void 0) {
3347
- const status = lstatSync(resolvePhysicalPath(this.#host, source, "TARGET", "host"));
3357
+ const directory = resolvePhysicalPath(this.#host, source, "TARGET", "host");
3358
+ const status = lstatSync(directory);
3348
3359
  if (!status.isDirectory() || status.isSymbolicLink()) throw new ScaffoldError("TARGET", `Host artifact is not a physical directory at ${source}`, { source });
3349
3360
  const destination = resolvePhysicalPath(transaction.stage, artifact.path, "WRITE", "staging");
3350
3361
  mkdirSync(destination, { recursive: true });
@@ -3687,7 +3698,8 @@ var Sync = class Sync {
3687
3698
  limit: MAX_ARTIFACT_BYTES
3688
3699
  });
3689
3700
  validateWriteDirectories(transaction);
3690
- mkdirSync(dirname(resolvePhysicalPath(transaction.stage, guide.path, "WRITE", "staging")), { recursive: true });
3701
+ const candidate = resolvePhysicalPath(transaction.stage, guide.path, "WRITE", "staging");
3702
+ mkdirSync(dirname(candidate), { recursive: true });
3691
3703
  validateWriteDirectories(transaction);
3692
3704
  const destination = resolvePhysicalPath(transaction.stage, guide.path, "WRITE", "staging");
3693
3705
  writeFileSync(destination, guide.content, {