@orkestrel/scaffold 0.0.27 → 0.0.29

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.
@@ -200,6 +200,12 @@ var GLOBAL_SETUP_PATH = "tests/setupGlobal.ts";
200
200
  var GUIDES_TEST_PATH = "tests/guides.test.ts";
201
201
  /** The installed-package proof whose presence makes a workspace `integration`. */
202
202
  var INTEGRATION_TEST_PATH = "tests/integration.test.ts";
203
+ /** The official-tooling drift proof whose presence makes a workspace `conformance`. */
204
+ var CONFORMANCE_TEST_PATH = "tests/conformance.test.ts";
205
+ /** The live-service readiness module whose presence makes a workspace `service`. */
206
+ var SERVICE_SETUP_PATH = "tests/setupService.ts";
207
+ /** The include the live-service project covers, which is a directory rather than one proof. */
208
+ var SERVICE_TEST_INCLUDE = "tests/service/**/*.test.ts";
203
209
  /** The Vite wrapper whose presence makes a workspace `showcase`. */
204
210
  var SHOWCASE_CONFIG_PATH = "configs/app/vite.showcase.config.ts";
205
211
  /** The bare workspace name syntax: lowercase alphanumeric with hyphens, letter first. */
@@ -283,7 +289,7 @@ var DEFAULT_ENGINES = `>=${MINIMUM_NODE_VERSION}`;
283
289
  var BASE_DEV_DEPENDENCIES = Object.freeze({
284
290
  "@microsoft/api-extractor": "^7.58.12",
285
291
  "@orkestrel/guide": "^0.0.10",
286
- "@orkestrel/scaffold": "^0.0.27",
292
+ "@orkestrel/scaffold": "^0.0.29",
287
293
  "@types/node": "^26.2.0",
288
294
  oxfmt: "^0.62.0",
289
295
  oxlint: "^1.77.0",
@@ -379,11 +385,11 @@ var CONFIG_TEMPLATES = Object.freeze({
379
385
  vite: `import type { {{viteTypes}} } from 'vite'
380
386
  {{imports}}import { defineConfig, mergeConfig } from 'vitest/config'
381
387
  import tsconfig from './tsconfig.json' with { type: 'json' }
382
- {{helpers}}import { lstatSync, readdirSync, realpathSync } from 'node:fs'
388
+ {{helpers}}{{browsers}}import { lstatSync, readdirSync, realpathSync } from 'node:fs'
383
389
  import { basename, join, parse, relative, resolve as resolvePath, sep } from 'node:path'
384
390
  import { fileURLToPath, URL } from 'node:url'
385
391
 
386
- export function resolveWorkspacePath(relativePath: string): string {
392
+ {{options}}export function resolveWorkspacePath(relativePath: string): string {
387
393
  return fileURLToPath(new URL(relativePath, import.meta.url))
388
394
  }
389
395
 
@@ -477,7 +483,7 @@ const resolve = {
477
483
  {{exclude}} setupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],
478
484
  browser: {
479
485
  enabled: true,
480
- provider: playwright(),
486
+ provider: playwright(browserOptions),
481
487
  instances: [{ browser: 'chromium', headless: true }],
482
488
  },
483
489
  fileParallelism: false,
@@ -588,7 +594,7 @@ const resolve = {
588
594
  setupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],
589
595
  browser: {
590
596
  enabled: true,
591
- provider: playwright(),
597
+ provider: playwright(browserOptions),
592
598
  instances: [{ browser: 'chromium', headless: true }],
593
599
  },
594
600
  fileParallelism: false,
@@ -675,6 +681,44 @@ export function appBrowser(...options: never[]): UserConfig {
675
681
  },
676
682
  options ?? {},
677
683
  )
684
+ `,
685
+ conformance: `// Where this package drifts from the official tooling it stays compatible with.
686
+ // The subject is this package, so the proof is hermetic and stays in \`npm test\`.
687
+ export const conformance = (options?: UserConfig): UserConfig =>
688
+ mergeConfig(
689
+ {
690
+ resolve,
691
+ test: {
692
+ name: { label: 'conformance', color: 'magenta' },
693
+ include: ['${CONFORMANCE_TEST_PATH}'],
694
+ setupFiles: ['./tests/setup.ts'],
695
+ environment: 'node',
696
+ browser: { enabled: false },
697
+ },
698
+ },
699
+ options ?? {},
700
+ )
701
+ `,
702
+ service: `// The live external services this package drives. It starts nothing itself:
703
+ // \`scripts/service.sh\` provisions, \`tests/setupService.ts\` proves readiness, and
704
+ // the project stays out of \`npm test\` because a real service answers it.
705
+ export const service = (options?: UserConfig): UserConfig =>
706
+ mergeConfig(
707
+ {
708
+ resolve,
709
+ test: {
710
+ name: { label: 'service', color: 'red' },
711
+ include: ['${SERVICE_TEST_INCLUDE}'],
712
+ setupFiles: ['./tests/setup.ts', './tests/setupService.ts'],
713
+ environment: 'node',
714
+ browser: { enabled: false },
715
+ testTimeout: 120_000,
716
+ hookTimeout: 120_000,
717
+ fileParallelism: false,
718
+ },
719
+ },
720
+ options ?? {},
721
+ )
678
722
  `,
679
723
  probe: `// A workbench, not a proof. No gate selects this project.
680
724
  export const probe = (options?: UserConfig): UserConfig =>
@@ -875,12 +919,22 @@ export default defineConfig(
875
919
  import dts from 'vite-plugin-dts'
876
920
  import { srcBrowser, resolveWorkspacePath } from '../../vite.config.ts'
877
921
 
922
+ // vite-plugin-dts rolls this face into one declaration, and the roll-up reaches
923
+ // src/core through a relative source path the tarball does not carry. The path
924
+ // keeps each source module's own depth, so a module in a browser subfolder emits
925
+ // one that leaves dist/src entirely. The rewrite below externalizes core through
926
+ // the package's own published root export, on the final roll-up only.
878
927
  export default defineConfig(
879
928
  srcBrowser({
880
929
  plugins: [
881
930
  dts({
882
931
  tsconfigPath: resolveWorkspacePath('configs/src/tsconfig.browser.json'),
883
932
  bundleTypes: true,
933
+ beforeWriteFile: (path, content) => ({
934
+ content: /[\\\\/]dist[\\\\/]src[\\\\/]browser[\\\\/]index\\.d\\.ts$/.test(path)
935
+ {{replacement}}
936
+ : content,
937
+ }),
884
938
  }),
885
939
  ],
886
940
  }),
@@ -949,7 +1003,319 @@ import { appShowcase } from '../../vite.config.ts'
949
1003
  export default defineConfig(appShowcase())
950
1004
  `
951
1005
  })
952
- })
1006
+ }),
1007
+ browsers: `// A generated browser workspace resolves its own Chromium here rather than in
1008
+ // \`configs/helpers.ts\`, because that leaf is vendored byte-identical to every
1009
+ // workspace and most of them declare no \`playwright\` to import.
1010
+
1011
+ import type { PlaywrightProviderOptions } from '@vitest/browser-playwright'
1012
+ import { chromium } from 'playwright'
1013
+ import { accessSync, constants as FS_CONSTANTS, globSync, readdirSync, statSync } from 'node:fs'
1014
+ import { basename, dirname, join, resolve as resolvePath } from 'node:path'
1015
+
1016
+ /**
1017
+ * Chromium executable layouts inside a \`chromium-<revision>\` browsers-directory entry, per
1018
+ * platform.
1019
+ *
1020
+ * @remarks
1021
+ * The current Playwright build ships Chrome for Testing on macOS. The trailing \`Chromium.app\`
1022
+ * layouts are what earlier builds shipped, so the list spans Playwright versions instead of
1023
+ * pinning to the installed one.
1024
+ */
1025
+ export const CHROMIUM_LAYOUTS = Object.freeze([
1026
+ 'chrome-linux/chrome',
1027
+ 'chrome-linux64/chrome',
1028
+ 'chrome-win/chrome.exe',
1029
+ 'chrome-win64/chrome.exe',
1030
+ 'chrome-mac-x64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing',
1031
+ 'chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing',
1032
+ 'chrome-mac/Chromium.app/Contents/MacOS/Chromium',
1033
+ 'chrome-mac-arm64/Chromium.app/Contents/MacOS/Chromium',
1034
+ ])
1035
+
1036
+ /** The \`chromium-<revision>\` entry name Playwright installs one managed build into. */
1037
+ export const CHROMIUM_ENTRY_PATTERN = /^chromium-\\d+$/
1038
+
1039
+ /** The revision number carried by any path containing a \`chromium-<revision>\` segment. */
1040
+ export const CHROMIUM_REVISION_PATTERN = /chromium-(\\d+)/
1041
+
1042
+ /** The directory a managed Linux container installs its bundled Playwright browsers into. */
1043
+ export const BUNDLED_BROWSERS_ROOT = '/opt/pw-browsers'
1044
+
1045
+ /**
1046
+ * Bundled Chromium layouts under the managed-container browsers root, as glob patterns.
1047
+ *
1048
+ * @remarks
1049
+ * The revision directory and its inner layout both drift across Playwright builds, and the
1050
+ * container also carries a top-level \`chromium\` alias, so every known shape is globbed.
1051
+ */
1052
+ export const BUNDLED_CHROMIUM_LAYOUTS = Object.freeze([
1053
+ 'chromium',
1054
+ 'chromium-*/chrome-linux64/chrome',
1055
+ 'chromium-*/chrome-linux/chrome',
1056
+ ])
1057
+
1058
+ /** Stable Playwright Chromium channels and their standard executable layouts. */
1059
+ export const SYSTEM_BROWSER_CHANNELS = Object.freeze([
1060
+ Object.freeze({
1061
+ channel: 'chrome',
1062
+ layouts: Object.freeze({
1063
+ linux: '/opt/google/chrome/chrome',
1064
+ darwin: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
1065
+ win32: Object.freeze(['Google', 'Chrome', 'Application', 'chrome.exe']),
1066
+ }),
1067
+ }),
1068
+ Object.freeze({
1069
+ channel: 'msedge',
1070
+ layouts: Object.freeze({
1071
+ linux: '/opt/microsoft/msedge/msedge',
1072
+ darwin: '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
1073
+ win32: Object.freeze(['Microsoft', 'Edge', 'Application', 'msedge.exe']),
1074
+ }),
1075
+ }),
1076
+ ])
1077
+
1078
+ /**
1079
+ * Determine whether a path identifies an executable regular file.
1080
+ *
1081
+ * @param path - The filesystem path to inspect.
1082
+ * @returns Whether the path is a regular file with execute access.
1083
+ *
1084
+ * @example
1085
+ * \`\`\`ts
1086
+ * isBrowserExecutable('/opt/google/chrome/chrome')
1087
+ * \`\`\`
1088
+ */
1089
+ export function isBrowserExecutable(path: string): boolean {
1090
+ try {
1091
+ if (!statSync(path).isFile()) return false
1092
+ accessSync(path, FS_CONSTANTS.X_OK)
1093
+ return true
1094
+ } catch {
1095
+ return false
1096
+ }
1097
+ }
1098
+
1099
+ /**
1100
+ * Order two Chromium paths so the highest revision sorts first.
1101
+ *
1102
+ * @param left - The first path or directory entry to compare.
1103
+ * @param right - The second path or directory entry to compare.
1104
+ * @returns A negative number when \`left\` sorts first, positive when \`right\` does.
1105
+ *
1106
+ * @remarks
1107
+ * Revisions are numbers, so \`chromium-1200\` outranks \`chromium-999\` despite sorting below it
1108
+ * lexically. A path carrying no revision falls back to descending name order.
1109
+ *
1110
+ * @example
1111
+ * \`\`\`ts
1112
+ * ['chromium-999', 'chromium-1200'].sort(compareRevisions)
1113
+ * \`\`\`
1114
+ */
1115
+ export function compareRevisions(left: string, right: string): number {
1116
+ const leftRevision = CHROMIUM_REVISION_PATTERN.exec(left)?.[1]
1117
+ const rightRevision = CHROMIUM_REVISION_PATTERN.exec(right)?.[1]
1118
+ if (leftRevision === undefined || rightRevision === undefined) return right.localeCompare(left)
1119
+ return Number(rightRevision) - Number(leftRevision)
1120
+ }
1121
+
1122
+ /**
1123
+ * Read the executable path of Playwright's pinned Chromium revision.
1124
+ *
1125
+ * @returns The pinned executable path, or \`undefined\` when this platform has none.
1126
+ *
1127
+ * @remarks
1128
+ * Playwright throws rather than returning a path when the current platform carries no initialized
1129
+ * executable, and an unguarded call would fail configuration evaluation for every project.
1130
+ *
1131
+ * @example
1132
+ * \`\`\`ts
1133
+ * resolvePinnedBrowser()
1134
+ * \`\`\`
1135
+ */
1136
+ export function resolvePinnedBrowser(): string | undefined {
1137
+ try {
1138
+ const pinned = chromium.executablePath()
1139
+ return pinned.length === 0 ? undefined : pinned
1140
+ } catch {
1141
+ return undefined
1142
+ }
1143
+ }
1144
+
1145
+ /**
1146
+ * Resolve a launchable Playwright-managed Chromium executable: the pinned revision when installed,
1147
+ * otherwise a \`chromium\` / \`chromium.exe\` alias or any other \`chromium-*\` revision under the same
1148
+ * Playwright browsers directory. A pinned-revision miss is not Chromium absence — managed
1149
+ * containers ship one usable build, often behind a revision-agnostic alias, for many Playwright
1150
+ * versions.
1151
+ *
1152
+ * @param pinned - The executable path for Playwright's pinned Chromium revision.
1153
+ * @returns The managed executable path, or \`undefined\` when none is executable.
1154
+ *
1155
+ * @example
1156
+ * \`\`\`ts
1157
+ * resolveManagedBrowser('/root/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome')
1158
+ * \`\`\`
1159
+ */
1160
+ export function resolveManagedBrowser(pinned: string): string | undefined {
1161
+ if (isBrowserExecutable(pinned)) return pinned
1162
+ let revisionRoot = dirname(pinned)
1163
+ for (;;) {
1164
+ if (CHROMIUM_ENTRY_PATTERN.test(basename(revisionRoot))) break
1165
+ const parent = dirname(revisionRoot)
1166
+ if (parent === revisionRoot) return undefined
1167
+ revisionRoot = parent
1168
+ }
1169
+ const browsersRoot = dirname(revisionRoot)
1170
+ for (const alias of ['chromium', 'chromium.exe']) {
1171
+ const candidate = resolvePath(browsersRoot, alias)
1172
+ if (isBrowserExecutable(candidate)) return candidate
1173
+ }
1174
+ let entries: readonly string[]
1175
+ try {
1176
+ entries = readdirSync(browsersRoot)
1177
+ } catch {
1178
+ return undefined
1179
+ }
1180
+ const revisions = entries
1181
+ .filter((entry) => CHROMIUM_ENTRY_PATTERN.test(entry))
1182
+ .sort(compareRevisions)
1183
+ for (const revision of revisions) {
1184
+ for (const layout of CHROMIUM_LAYOUTS) {
1185
+ const candidate = resolvePath(browsersRoot, revision, layout)
1186
+ if (isBrowserExecutable(candidate)) return candidate
1187
+ }
1188
+ }
1189
+ return undefined
1190
+ }
1191
+
1192
+ /**
1193
+ * Resolve the Chromium a managed Linux container bundles outside the Playwright cache.
1194
+ *
1195
+ * @param platform - The Node platform the container runs on.
1196
+ * @param root - The bundled browsers directory to search.
1197
+ * @returns The highest matching executable path, or \`undefined\` when none is executable.
1198
+ *
1199
+ * @example
1200
+ * \`\`\`ts
1201
+ * resolveBundledBrowser('linux', BUNDLED_BROWSERS_ROOT)
1202
+ * \`\`\`
1203
+ */
1204
+ export function resolveBundledBrowser(platform: NodeJS.Platform, root: string): string | undefined {
1205
+ if (platform !== 'linux') return undefined
1206
+ for (const layout of BUNDLED_CHROMIUM_LAYOUTS) {
1207
+ let matches: readonly string[]
1208
+ try {
1209
+ matches = globSync(layout, { cwd: root })
1210
+ } catch {
1211
+ return undefined
1212
+ }
1213
+ for (const match of [...matches].sort(compareRevisions)) {
1214
+ const candidate = resolvePath(root, match)
1215
+ if (isBrowserExecutable(candidate)) return candidate
1216
+ }
1217
+ }
1218
+ return undefined
1219
+ }
1220
+
1221
+ /**
1222
+ * Resolve the first installed stable system Chromium channel.
1223
+ *
1224
+ * @param platform - The Node platform whose standard layouts should be probed.
1225
+ * @param environment - The process environment supplying Windows installation roots.
1226
+ * @returns \`chrome\`, then \`msedge\`, or \`undefined\` when neither is executable.
1227
+ *
1228
+ * @example
1229
+ * \`\`\`ts
1230
+ * resolveSystemBrowser(process.platform, process.env)
1231
+ * \`\`\`
1232
+ */
1233
+ export function resolveSystemBrowser(
1234
+ platform: NodeJS.Platform,
1235
+ environment: NodeJS.ProcessEnv,
1236
+ ): string | undefined {
1237
+ if (platform !== 'linux' && platform !== 'darwin' && platform !== 'win32') return undefined
1238
+ const roots = new Set<string>()
1239
+ if (platform === 'win32') {
1240
+ for (const root of [
1241
+ environment.LOCALAPPDATA,
1242
+ environment.PROGRAMFILES,
1243
+ environment['PROGRAMFILES(X86)'],
1244
+ ]) {
1245
+ if (root !== undefined && root.length > 0) roots.add(root)
1246
+ }
1247
+ const homeDrive = environment.HOMEDRIVE
1248
+ if (homeDrive !== undefined && homeDrive.length > 0) {
1249
+ roots.add(join(homeDrive, 'Program Files'))
1250
+ roots.add(join(homeDrive, 'Program Files (x86)'))
1251
+ }
1252
+ }
1253
+ for (const browser of SYSTEM_BROWSER_CHANNELS) {
1254
+ if (platform === 'win32') {
1255
+ for (const root of roots) {
1256
+ if (isBrowserExecutable(join(root, ...browser.layouts.win32))) return browser.channel
1257
+ }
1258
+ continue
1259
+ }
1260
+ if (isBrowserExecutable(browser.layouts[platform])) return browser.channel
1261
+ }
1262
+ return undefined
1263
+ }
1264
+
1265
+ /**
1266
+ * Resolve Playwright provider options for whatever browser this host can actually launch.
1267
+ *
1268
+ * @param pinned - The executable path for Playwright's pinned Chromium revision, when it has one.
1269
+ * @param platform - The Node platform whose standard layouts should be probed.
1270
+ * @param environment - The process environment supplying operator overrides and Windows roots.
1271
+ * @param root - The managed-container bundled browsers directory to search.
1272
+ * @returns Provider options naming an executable, a WebSocket endpoint, or a channel.
1273
+ *
1274
+ * @remarks
1275
+ * Precedence, most important first: \`PLAYWRIGHT_EXECUTABLE_PATH\`, \`PLAYWRIGHT_WS_ENDPOINT\`,
1276
+ * \`PLAYWRIGHT_CHANNEL\`, the managed Playwright Chromium, the container's bundled Chromium, a
1277
+ * verified system channel, then the platform default channel. An operator override outranks
1278
+ * discovery and is returned exactly as given: none of those three environment values is checked
1279
+ * against the filesystem, because verifying an override would defeat the override. The pinned
1280
+ * managed revision outranks anything found on the host because it is deterministic. The installed
1281
+ * pinned revision returns empty options so Playwright keeps its own default launch semantics. Only
1282
+ * a discovered system channel is verified before it is named. The platform default is unverified
1283
+ * as well and exists only as a last resort: Windows takes \`msedge\`, which ships with the OS and
1284
+ * never collides with a foreground Chrome.
1285
+ *
1286
+ * @example
1287
+ * \`\`\`ts
1288
+ * resolveBrowser(resolvePinnedBrowser(), process.platform, process.env)
1289
+ * \`\`\`
1290
+ */
1291
+ export function resolveBrowser(
1292
+ pinned: string | undefined,
1293
+ platform: NodeJS.Platform,
1294
+ environment: NodeJS.ProcessEnv,
1295
+ root: string = BUNDLED_BROWSERS_ROOT,
1296
+ ): PlaywrightProviderOptions {
1297
+ const executable = environment.PLAYWRIGHT_EXECUTABLE_PATH
1298
+ if (executable !== undefined && executable.length > 0) {
1299
+ return { launchOptions: { executablePath: executable } }
1300
+ }
1301
+ const endpoint = environment.PLAYWRIGHT_WS_ENDPOINT
1302
+ if (endpoint !== undefined && endpoint.length > 0) {
1303
+ return { connectOptions: { wsEndpoint: endpoint } }
1304
+ }
1305
+ const requested = environment.PLAYWRIGHT_CHANNEL
1306
+ if (requested !== undefined && requested.length > 0) {
1307
+ return { launchOptions: { channel: requested } }
1308
+ }
1309
+ const managed = pinned === undefined ? undefined : resolveManagedBrowser(pinned)
1310
+ if (managed !== undefined) {
1311
+ return managed === pinned ? {} : { launchOptions: { executablePath: managed } }
1312
+ }
1313
+ const bundled = resolveBundledBrowser(platform, root)
1314
+ if (bundled !== undefined) return { launchOptions: { executablePath: bundled } }
1315
+ const fallback = platform === 'win32' ? 'msedge' : 'chrome'
1316
+ return { launchOptions: { channel: resolveSystemBrowser(platform, environment) ?? fallback } }
1317
+ }
1318
+ `
953
1319
  });
954
1320
  /**
955
1321
  * Formatter-stable template text for source, test, document, guide, and service artifacts.
@@ -1149,7 +1515,7 @@ npm test
1149
1515
  set -eu
1150
1516
 
1151
1517
  printf '%s\\n' \\
1152
- {{services}}
1518
+ {{vendors}}
1153
1519
  ` })
1154
1520
  });
1155
1521
  //#endregion
@@ -1436,7 +1802,9 @@ var isBlueprint = recordOf({
1436
1802
  overrides: andOf(isCollection, arrayOf(isOverride)),
1437
1803
  bin: isBoolean,
1438
1804
  integration: isBoolean,
1439
- services: andOf(isCollection, arrayOf(isString)),
1805
+ conformance: isBoolean,
1806
+ service: isBoolean,
1807
+ vendors: andOf(isCollection, arrayOf(isString)),
1440
1808
  global: isBoolean,
1441
1809
  showcase: isBoolean
1442
1810
  }, ["description"]);
@@ -2028,6 +2396,46 @@ function nameToGuide(name) {
2028
2396
  return `guides/${name.slice(name.lastIndexOf("/") + 1)}.md`;
2029
2397
  }
2030
2398
  /**
2399
+ * Derive the declaration rewrite a published face's `beforeWriteFile` applies.
2400
+ *
2401
+ * @param name - The workspace's own bare package name.
2402
+ * @returns The ternary consequent an emitted `vite.{browser,server}.config.ts`
2403
+ * fills its `{{replacement}}` span with, indented for that span.
2404
+ *
2405
+ * @remarks
2406
+ * `vite-plugin-dts` rolls a face into one declaration and keeps each source
2407
+ * module's own relative depth, so a nested module emits a path that escapes
2408
+ * `dist/src` and a flat one resolves only by luck. Both faces rewrite the same
2409
+ * relative core path to the package's published root export, so the branch is
2410
+ * derived once here. The extension alternation is what the two permitted import
2411
+ * spellings produce: an `@src/core` alias resolves to the core source module and
2412
+ * prints `.ts`, while a relative import prints the `.js` specifier it was
2413
+ * written with. The formatter keeps the call on one line only while the line it
2414
+ * prints measures inside the vendored width, and the workspace name is what
2415
+ * varies, so the shape is chosen by measuring the candidate: a tab prints as the
2416
+ * vendored two columns, and the gate admits a name long enough to push the
2417
+ * joined call past 100.
2418
+ *
2419
+ * @example
2420
+ * ```ts
2421
+ * import { nameToRewrite } from '@orkestrel/scaffold'
2422
+ *
2423
+ * nameToRewrite('router').includes("'@orkestrel/router'") // true
2424
+ * ```
2425
+ */
2426
+ function nameToRewrite(name) {
2427
+ const specifier = serializeTypeScriptString(`@orkestrel/${name}`);
2428
+ const pattern = "/(?:\\.\\.\\/)+core\\/index\\.[jt]s/g";
2429
+ const joined = `\t\t\t\t\t\t? content.replaceAll(${pattern}, ${specifier})`;
2430
+ if (joined.replaceAll(" ", " ").length <= 100) return joined;
2431
+ return [
2432
+ " ? content.replaceAll(",
2433
+ `\t\t\t\t\t\t\t\t${pattern},`,
2434
+ `\t\t\t\t\t\t\t\t${specifier},`,
2435
+ " )"
2436
+ ].join("\n");
2437
+ }
2438
+ /**
2031
2439
  * Select the host paths a named workspace vendors.
2032
2440
  *
2033
2441
  * @param paths - The candidate host paths, in their declared order.
@@ -2672,8 +3080,14 @@ function blueprintToDevDependencies(blueprint) {
2672
3080
  * to the axes the blueprint declares: a check and a test script per declared
2673
3081
  * environment, an aggregate over each axis, the policy and configuration
2674
3082
  * proofs every workspace can pass before it has a public API, and one build per
2675
- * target that actually builds. The isolated installed-package integration
2676
- * proof stays out of `test` and runs from `prepublishOnly` instead.
3083
+ * target that actually builds.
3084
+ *
3085
+ * A proof leaves `test` when a real service or a real install answers it. The
3086
+ * installed-package integration proof and the live-service proof therefore run
3087
+ * from `prepublishOnly` instead. The conformance proof stays in `test`, because
3088
+ * it measures this package against official tooling and drives nothing external:
3089
+ * a conformance run may start a server, but it starts its own and reaches it
3090
+ * over loopback, so the run stays hermetic.
2677
3091
  *
2678
3092
  * The configuration paths interpolated here are the same ones `SRC_MATRIX` and
2679
3093
  * `APP_MATRIX` list as each environment's configuration files, so a rename in
@@ -2720,7 +3134,8 @@ function blueprintToScripts(blueprint) {
2720
3134
  ...compiles ? ["npm run test:src"] : [],
2721
3135
  ...blueprint.app.length > 0 ? ["npm run test:app"] : [],
2722
3136
  "npm run test:policy",
2723
- "npm run test:config"
3137
+ "npm run test:config",
3138
+ ...blueprint.conformance ? ["npm run test:conformance"] : []
2724
3139
  ].join(" && ");
2725
3140
  if (compiles) {
2726
3141
  scripts["test:src"] = [
@@ -2737,8 +3152,10 @@ function blueprintToScripts(blueprint) {
2737
3152
  }
2738
3153
  scripts["test:policy"] = `${vitest} --project policy`;
2739
3154
  scripts["test:config"] = `${vitest} --project config`;
3155
+ if (blueprint.conformance) scripts["test:conformance"] = `${vitest} --project conformance`;
2740
3156
  scripts["test:probe"] = "vitest run --config vite.config.ts --no-cache --reporter=verbose --project probe";
2741
3157
  if (integrates) scripts["test:integration"] = `${vitest} --project integration`;
3158
+ if (blueprint.service) scripts["test:service"] = `${vitest} --project service`;
2742
3159
  scripts.build = [
2743
3160
  "npm run clean",
2744
3161
  ...compiles ? ["npm run build:src"] : [],
@@ -2768,7 +3185,11 @@ function blueprintToScripts(blueprint) {
2768
3185
  scripts.serve = "node dist/app/server/main.cjs";
2769
3186
  scripts["serve:build"] = "npm run build:app:server && npm run serve";
2770
3187
  }
2771
- scripts.prepublishOnly = ["npm run format:check && npm run lint:check && npm run check && npm run build && npm test", ...integrates ? ["npm run test:integration"] : []].join(" && ");
3188
+ scripts.prepublishOnly = [
3189
+ "npm run format:check && npm run lint:check && npm run check && npm run build && npm test",
3190
+ ...integrates ? ["npm run test:integration"] : [],
3191
+ ...blueprint.service ? ["npm run test:service"] : []
3192
+ ].join(" && ");
2772
3193
  return scripts;
2773
3194
  }
2774
3195
  /**
@@ -3050,6 +3471,14 @@ export function appShowcase(...options: never[]): UserConfig {
3050
3471
  projects.push("config");
3051
3472
  factories.push(CONFIG_TEMPLATES.factories.guides);
3052
3473
  projects.push(`...(isExactCaseFile(resolveWorkspacePath('${GUIDES_TEST_PATH}')) ? [guides] : [])`);
3474
+ if (blueprint.conformance) {
3475
+ factories.push(CONFIG_TEMPLATES.factories.conformance);
3476
+ projects.push("conformance");
3477
+ }
3478
+ if (blueprint.service) {
3479
+ factories.push(CONFIG_TEMPLATES.factories.service);
3480
+ projects.push("service");
3481
+ }
3053
3482
  if (blueprint.src.length > 0 && blueprint.integration) {
3054
3483
  factories.push(fillTemplate(CONFIG_TEMPLATES.factories.integration, { global: blueprint.global ? " globalSetup: ['./tests/setupGlobal.ts'],\n" : "" }));
3055
3484
  projects.push("integration");
@@ -3065,6 +3494,8 @@ ${projects.map((project) => `\t\t\t${project},`).join("\n")}
3065
3494
  viteTypes: machinery.showcase ? "PluginOption, UserConfig" : "UserConfig",
3066
3495
  imports: imports.length === 0 ? "" : `${imports.join("\n")}\n`,
3067
3496
  helpers: boundaries.length === 0 ? "" : `import { ${boundaries.join(", ")} } from './configs/helpers.js'\n`,
3497
+ browsers: machinery.browser ? "import { resolveBrowser, resolvePinnedBrowser } from './configs/browsers.js'\n" : "",
3498
+ options: machinery.browser ? "const browserOptions = resolveBrowser(resolvePinnedBrowser(), process.platform, process.env)\n\n" : "",
3068
3499
  factories: body,
3069
3500
  projects: projectRows
3070
3501
  });
@@ -3098,22 +3529,20 @@ function blueprintToConfigArtifacts(blueprint) {
3098
3529
  origin: "template",
3099
3530
  content: blueprintToRootVite(blueprint)
3100
3531
  }];
3532
+ if (blueprintToMachinery(blueprint).browser) artifacts.push({
3533
+ path: "configs/browsers.ts",
3534
+ group: "configs",
3535
+ ownership: "content",
3536
+ origin: "template",
3537
+ content: CONFIG_TEMPLATES.browsers
3538
+ });
3101
3539
  for (const environment of blueprint.src) for (const path of SRC_MATRIX[environment].configs) {
3102
3540
  let content = CONFIG_TEMPLATES.vites.src.core;
3103
3541
  if (path === "configs/src/tsconfig.core.json") content = CONFIG_TEMPLATES.tsconfigs.src.core;
3104
- else if (path === "configs/src/vite.browser.config.ts") content = CONFIG_TEMPLATES.vites.src.browser;
3542
+ else if (path === "configs/src/vite.browser.config.ts") content = fillTemplate(CONFIG_TEMPLATES.vites.src.browser, { replacement: nameToRewrite(blueprint.name) });
3105
3543
  else if (path === "configs/src/tsconfig.browser.json") content = CONFIG_TEMPLATES.tsconfigs.src.browser;
3106
- else if (path === "configs/src/vite.server.config.ts") {
3107
- const packageName = serializeTypeScriptString(`@orkestrel/${blueprint.name}`);
3108
- const joined = `\t\t\t\t\t\t? content.replaceAll(/(?:\\.\\.\\/)+core\\/index\\.ts/g, ${packageName})`;
3109
- const replacement = joined.replaceAll(" ", " ").length <= 100 ? joined : [
3110
- " ? content.replaceAll(",
3111
- " /(?:\\.\\.\\/)+core\\/index\\.ts/g,",
3112
- `\t\t\t\t\t\t\t\t${packageName},`,
3113
- " )"
3114
- ].join("\n");
3115
- content = fillTemplate(CONFIG_TEMPLATES.vites.src.server, { replacement });
3116
- } else if (path === "configs/src/tsconfig.server.json") content = CONFIG_TEMPLATES.tsconfigs.src.server;
3544
+ else if (path === "configs/src/vite.server.config.ts") content = fillTemplate(CONFIG_TEMPLATES.vites.src.server, { replacement: nameToRewrite(blueprint.name) });
3545
+ else if (path === "configs/src/tsconfig.server.json") content = CONFIG_TEMPLATES.tsconfigs.src.server;
3117
3546
  artifacts.push({
3118
3547
  path,
3119
3548
  group: "configs",
@@ -3270,6 +3699,12 @@ function blueprintToSourceArtifacts(blueprint) {
3270
3699
  * workspace and therefore follows the `src` axis as well as its structural
3271
3700
  * flag.
3272
3701
  *
3702
+ * The conformance proof is not emitted either, for the reason the guide proof
3703
+ * is not: it names an official artifact only the package knows, so a generated
3704
+ * placeholder would read as a proof while measuring nothing. `service` emits its
3705
+ * readiness setup alone, because the root configuration names that module by
3706
+ * path.
3707
+ *
3273
3708
  * @example
3274
3709
  * ```ts
3275
3710
  * import { blueprintToTestArtifacts, createBlueprint } from '@orkestrel/scaffold'
@@ -3303,6 +3738,13 @@ function blueprintToTestArtifacts(blueprint) {
3303
3738
  environment: "server",
3304
3739
  content: ARTIFACT_TEMPLATES.tests.setup
3305
3740
  });
3741
+ if (blueprint.service) artifacts.push({
3742
+ path: SERVICE_SETUP_PATH,
3743
+ group: "tests",
3744
+ ownership: "birth",
3745
+ origin: "template",
3746
+ content: ARTIFACT_TEMPLATES.tests.setup
3747
+ });
3306
3748
  if (blueprint.global) artifacts.push({
3307
3749
  path: GLOBAL_SETUP_PATH,
3308
3750
  group: "tests",
@@ -3416,22 +3858,22 @@ function blueprintToDocumentArtifacts(blueprint) {
3416
3858
  * Compile the blueprint-dependent orchestration artifacts.
3417
3859
  *
3418
3860
  * @param blueprint - The workspace specification.
3419
- * @returns A service inventory script when services are declared, otherwise none.
3861
+ * @returns A vendor inventory script when vendors are declared, otherwise none.
3420
3862
  *
3421
3863
  * @remarks
3422
- * A service name does not describe startup, readiness, or cleanup. The script
3864
+ * A vendor name does not describe startup, readiness, or cleanup. The script
3423
3865
  * therefore records only the declared inventory and does not invent a service
3424
3866
  * runner or test project.
3425
3867
  */
3426
3868
  function blueprintToOrchestrationArtifacts(blueprint) {
3427
- if (blueprint.services.length === 0) return [];
3428
- const services = blueprint.services.map((service, index) => `\t'${service}'${index === blueprint.services.length - 1 ? "" : " \\"}`).join("\n");
3869
+ if (blueprint.vendors.length === 0) return [];
3870
+ const vendors = blueprint.vendors.map((vendor, index) => `\t'${vendor}'${index === blueprint.vendors.length - 1 ? "" : " \\"}`).join("\n");
3429
3871
  return [{
3430
3872
  path: SERVICE_SCRIPT_PATH,
3431
3873
  group: "orchestration",
3432
3874
  ownership: "birth",
3433
3875
  origin: "template",
3434
- content: fillTemplate(ARTIFACT_TEMPLATES.orchestration.service, { services })
3876
+ content: fillTemplate(ARTIFACT_TEMPLATES.orchestration.service, { vendors })
3435
3877
  }];
3436
3878
  }
3437
3879
  /**
@@ -3787,19 +4229,19 @@ function blueprintToQuestions(blueprint) {
3787
4229
  message: "integration projects a published src, and this workspace declares none, so it emits nothing.",
3788
4230
  blocking: false
3789
4231
  });
3790
- const services = /* @__PURE__ */ new Set();
3791
- for (const service of blueprint.services) {
3792
- if (!NAME_PATTERN.test(service)) questions.push({
3793
- field: "services",
3794
- message: `${service} is not a lowercase alphanumeric service name starting with a letter.`,
4232
+ const vendors = /* @__PURE__ */ new Set();
4233
+ for (const vendor of blueprint.vendors) {
4234
+ if (!NAME_PATTERN.test(vendor)) questions.push({
4235
+ field: "vendors",
4236
+ message: `${vendor} is not a lowercase alphanumeric vendor name starting with a letter.`,
3795
4237
  blocking: true
3796
4238
  });
3797
- else if (services.has(service)) questions.push({
3798
- field: "services",
3799
- message: `${service} is declared more than once on services.`,
4239
+ else if (vendors.has(vendor)) questions.push({
4240
+ field: "vendors",
4241
+ message: `${vendor} is declared more than once on vendors.`,
3800
4242
  blocking: true
3801
4243
  });
3802
- services.add(service);
4244
+ vendors.add(vendor);
3803
4245
  }
3804
4246
  if (blueprint.showcase && !blueprint.app.includes("browser")) questions.push({
3805
4247
  field: "showcase",
@@ -4267,8 +4709,8 @@ var Compiler = class {
4267
4709
  * blueprint.
4268
4710
  *
4269
4711
  * @remarks
4270
- * A blueprint is a closed record of sixteen fields, and most of them have one
4271
- * sensible starting value: an empty list, a cleared flag, `DEFAULT_VERSION`, and
4712
+ * A blueprint is a closed record, and most of its fields have one sensible
4713
+ * starting value: an empty list, a cleared flag, `DEFAULT_VERSION`, and
4272
4714
  * `DEFAULT_ENGINES`. Filling them here is what lets a caller state only what its
4273
4715
  * workspace actually declares.
4274
4716
  *
@@ -4309,7 +4751,9 @@ function createBlueprint(name, input) {
4309
4751
  overrides: input?.overrides ?? [],
4310
4752
  bin: input?.bin ?? false,
4311
4753
  integration: input?.integration ?? false,
4312
- services: input?.services ?? [],
4754
+ conformance: input?.conformance ?? false,
4755
+ service: input?.service ?? false,
4756
+ vendors: input?.vendors ?? [],
4313
4757
  global: input?.global ?? false,
4314
4758
  showcase: input?.showcase ?? false
4315
4759
  }));
@@ -4336,6 +4780,6 @@ function createCompiler(options) {
4336
4780
  return new Compiler(options);
4337
4781
  }
4338
4782
  //#endregion
4339
- export { APP_BROWSER_DEV_DEPENDENCIES, APP_DEV_DEPENDENCIES, APP_MATRIX, APP_SERVER_DEV_DEPENDENCIES, ARTIFACT_TEMPLATES, BASE_DEV_DEPENDENCIES, BIN_CONFIGS, BIN_ENTRY_PATH, CATALOG_AGENT_PATH, CONFIG_TEMPLATES, CONTROL_CHARACTER_PATTERN, Compiler, DEFAULT_ENGINES, DEFAULT_VERSION, DEPENDENCY_NAME_PATTERN, ENGINES_PATTERN, ENVIRONMENTS, EXECUTABLE_PATHS, EXTRA_NAME_PATTERN, EXTRA_RANGE_PATTERN, GLOBAL_SETUP_PATH, GROUPS, GUIDES_TEST_PATH, HEX_PATTERN, HOST_PATHS, INTEGRATION_TEST_PATH, INVALID_PATH_CHARACTER_PATTERN, MAX_ARTIFACT_BYTES, MAX_ARTIFACT_HEX_LENGTH, MAX_AUDIT_FINDINGS, MAX_COLLECTION_ITEMS, MAX_DEPENDENCY_NAME_LENGTH, MAX_MANIFEST_BYTES, MAX_NAME_LENGTH, MAX_PATH_LENGTH, MAX_RANGE_LENGTH, MAX_TOTAL_ARTIFACT_BYTES, MINIMUM_NODE_VERSION, NAME_PATTERN, ORCHESTRATION_PATH_NAMES, ORCHESTRATION_PATH_PREFIXES, ORKESTREL_RANGE_PATTERN, SERVICE_SCRIPT_PATH, SHOWCASE_CONFIG_PATH, SHOWCASE_DEV_DEPENDENCIES, SOURCE_BROWSER_DEV_DEPENDENCIES, SRC_MATRIX, ScaffoldError, VERSION_PATTERN, applyOverrides, artifactToFinding, artifactToHex, artifactsToQuestions, blueprintToConfigArtifacts, blueprintToDevDependencies, blueprintToDocumentArtifacts, blueprintToGuideArtifacts, blueprintToMachinery, blueprintToManifest, blueprintToOrchestrationArtifacts, blueprintToQuestions, blueprintToRootTsconfig, blueprintToRootVite, blueprintToScripts, blueprintToSourceArtifacts, blueprintToTestArtifacts, bytesToHex, catalogToLayers, cloneValue, compareVersions, computeBytes, computeHash, contentToHex, createBlueprint, createCompiler, dependenciesToQuestions, extractVersion, inferDrift, inferGroup, isArtifact, isAudit, isBlueprint, isCatalogEntry, isCollection, isCompilerHooks, isCompilerOptions, isContent, isDependency, isDependencyName, isEnvironment, isFinding, isGroup, isGroups, isHex, isMirror, isOverride, isPath, isPlan, isQuestion, isScaffoldError, isSnapshot, manifestToDependencies, manifestToName, matchesDriftReachability, matchesEngines, matchesOrchestrationPath, matchesRange, nameToGuide, nameToHostArtifacts, overridesToQuestions, parseBlueprint, parseCompilerOptions, parseGroups, parseSnapshot, pathToCondition, planToFindings, planToHash, planToSummary, selectGroups, selectHostPaths, serializeTypeScriptString, srcToEntry, srcToExports, srcToRoot };
4783
+ export { APP_BROWSER_DEV_DEPENDENCIES, APP_DEV_DEPENDENCIES, APP_MATRIX, APP_SERVER_DEV_DEPENDENCIES, ARTIFACT_TEMPLATES, BASE_DEV_DEPENDENCIES, BIN_CONFIGS, BIN_ENTRY_PATH, CATALOG_AGENT_PATH, CONFIG_TEMPLATES, CONFORMANCE_TEST_PATH, CONTROL_CHARACTER_PATTERN, Compiler, DEFAULT_ENGINES, DEFAULT_VERSION, DEPENDENCY_NAME_PATTERN, ENGINES_PATTERN, ENVIRONMENTS, EXECUTABLE_PATHS, EXTRA_NAME_PATTERN, EXTRA_RANGE_PATTERN, GLOBAL_SETUP_PATH, GROUPS, GUIDES_TEST_PATH, HEX_PATTERN, HOST_PATHS, INTEGRATION_TEST_PATH, INVALID_PATH_CHARACTER_PATTERN, MAX_ARTIFACT_BYTES, MAX_ARTIFACT_HEX_LENGTH, MAX_AUDIT_FINDINGS, MAX_COLLECTION_ITEMS, MAX_DEPENDENCY_NAME_LENGTH, MAX_MANIFEST_BYTES, MAX_NAME_LENGTH, MAX_PATH_LENGTH, MAX_RANGE_LENGTH, MAX_TOTAL_ARTIFACT_BYTES, MINIMUM_NODE_VERSION, NAME_PATTERN, ORCHESTRATION_PATH_NAMES, ORCHESTRATION_PATH_PREFIXES, ORKESTREL_RANGE_PATTERN, SERVICE_SCRIPT_PATH, SERVICE_SETUP_PATH, SERVICE_TEST_INCLUDE, SHOWCASE_CONFIG_PATH, SHOWCASE_DEV_DEPENDENCIES, SOURCE_BROWSER_DEV_DEPENDENCIES, SRC_MATRIX, ScaffoldError, VERSION_PATTERN, applyOverrides, artifactToFinding, artifactToHex, artifactsToQuestions, blueprintToConfigArtifacts, blueprintToDevDependencies, blueprintToDocumentArtifacts, blueprintToGuideArtifacts, blueprintToMachinery, blueprintToManifest, blueprintToOrchestrationArtifacts, blueprintToQuestions, blueprintToRootTsconfig, blueprintToRootVite, blueprintToScripts, blueprintToSourceArtifacts, blueprintToTestArtifacts, bytesToHex, catalogToLayers, cloneValue, compareVersions, computeBytes, computeHash, contentToHex, createBlueprint, createCompiler, dependenciesToQuestions, extractVersion, inferDrift, inferGroup, isArtifact, isAudit, isBlueprint, isCatalogEntry, isCollection, isCompilerHooks, isCompilerOptions, isContent, isDependency, isDependencyName, isEnvironment, isFinding, isGroup, isGroups, isHex, isMirror, isOverride, isPath, isPlan, isQuestion, isScaffoldError, isSnapshot, manifestToDependencies, manifestToName, matchesDriftReachability, matchesEngines, matchesOrchestrationPath, matchesRange, nameToGuide, nameToHostArtifacts, nameToRewrite, overridesToQuestions, parseBlueprint, parseCompilerOptions, parseGroups, parseSnapshot, pathToCondition, planToFindings, planToHash, planToSummary, selectGroups, selectHostPaths, serializeTypeScriptString, srcToEntry, srcToExports, srcToRoot };
4340
4784
 
4341
4785
  //# sourceMappingURL=index.js.map