@orkestrel/scaffold 0.0.12 → 0.0.14

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.
@@ -2276,7 +2276,7 @@ export declare function coreViteConfig(browser?: boolean): string;
2276
2276
  export declare function rootViteConfig(src: readonly Environment[], facts?: ViteFacts): string;
2277
2277
 
2278
2278
  /** The devDependency range generated packages pin `@orkestrel/scaffold` at. */
2279
- export declare const SCAFFOLD_RANGE = "^0.0.12";
2279
+ export declare const SCAFFOLD_RANGE = "^0.0.14";
2280
2280
 
2281
2281
  /**
2282
2282
  * Carries a `ScaffoldErrorCode` + optional `context` (AGENTS §12).
@@ -2276,7 +2276,7 @@ export declare function coreViteConfig(browser?: boolean): string;
2276
2276
  export declare function rootViteConfig(src: readonly Environment[], facts?: ViteFacts): string;
2277
2277
 
2278
2278
  /** The devDependency range generated packages pin `@orkestrel/scaffold` at. */
2279
- export declare const SCAFFOLD_RANGE = "^0.0.12";
2279
+ export declare const SCAFFOLD_RANGE = "^0.0.14";
2280
2280
 
2281
2281
  /**
2282
2282
  * Carries a `ScaffoldErrorCode` + optional `context` (AGENTS §12).
@@ -226,7 +226,7 @@ var DEFAULT_VERSION = "0.0.1";
226
226
  /** The `engines.node` range the `blueprint` builder fills. */
227
227
  var DEFAULT_ENGINES = `>=${MINIMUM_NODE_VERSION}`;
228
228
  /** The devDependency range generated packages pin `@orkestrel/scaffold` at. */
229
- var SCAFFOLD_RANGE = "^0.0.12";
229
+ var SCAFFOLD_RANGE = "^0.0.14";
230
230
  /** Tooling versions shared by scaffold and every generated workspace. */
231
231
  var BASE_DEV_DEPENDENCIES = Object.freeze({
232
232
  "@microsoft/api-extractor": "^7.58.12",
@@ -5875,7 +5875,7 @@ ${renderedProjects}
5875
5875
  ${fitsPrintWidth(inlineRegistrations) ? inlineRegistrations : ` [
5876
5876
  ${renderedRegistrations.map((registration) => ` ${registration},`).join("\n")}
5877
5877
  ],`}
5878
- hasChromium,
5878
+ chromiumPath !== undefined,
5879
5879
  process.argv,
5880
5880
  ),`;
5881
5881
  }
@@ -7252,11 +7252,66 @@ import {
7252
7252
  fstatSync,
7253
7253
  lstatSync,
7254
7254
  openSync,
7255
- readSync,
7255
+ ${needsBrowser ? " readdirSync,\n" : ""} readSync,
7256
7256
  realpathSync,
7257
- } from 'node:fs'
7258
- import { dirname, isAbsolute, relative, resolve as resolvePath, sep } from 'node:path'
7259
- ${playwrightImports}${vueImports}${needsBrowser ? `\n${CONST_KEYWORD} hasChromium = existsSync(chromium.executablePath())\n` : ""}
7257
+ ${needsBrowser ? " statSync,\n" : ""}} from 'node:fs'
7258
+ import { ${needsBrowser ? "basename, " : ""}dirname, isAbsolute, relative, resolve as resolvePath, sep } from 'node:path'
7259
+ ${playwrightImports}${vueImports}${needsBrowser ? `\n/** Chromium executable layouts inside a \`chromium-<revision>\` browsers-directory entry, per platform. */
7260
+ ${EXPORT_KEYWORD} ${CONST_KEYWORD} CHROMIUM_LAYOUTS = Object.freeze([
7261
+ 'chrome-linux/chrome',
7262
+ 'chrome-linux64/chrome',
7263
+ 'chrome-win/chrome.exe',
7264
+ 'chrome-win64/chrome.exe',
7265
+ 'chrome-mac/Chromium.app/Contents/MacOS/Chromium',
7266
+ 'chrome-mac-arm64/Chromium.app/Contents/MacOS/Chromium',
7267
+ ])
7268
+
7269
+ /**
7270
+ * Resolve a launchable Chromium executable: the pinned revision when installed,
7271
+ * otherwise a \`chromium\` / \`chromium.exe\` alias or any other \`chromium-*\`
7272
+ * revision under the same Playwright browsers directory. A pinned-revision miss
7273
+ * is not Chromium absence — managed containers ship one usable build (often
7274
+ * behind a revision-agnostic alias) for many Playwright versions.
7275
+ */
7276
+ ${EXPORT_KEYWORD} function resolveChromium(pinned: string): string | undefined {
7277
+ if (existsSync(pinned)) return pinned
7278
+ let revisionRoot = dirname(pinned)
7279
+ for (;;) {
7280
+ if (/^chromium-\\d+$/.test(basename(revisionRoot))) break
7281
+ const parent = dirname(revisionRoot)
7282
+ if (parent === revisionRoot) return undefined
7283
+ revisionRoot = parent
7284
+ }
7285
+ const browsersRoot = dirname(revisionRoot)
7286
+ for (const alias of ['chromium', 'chromium.exe']) {
7287
+ const candidate = resolvePath(browsersRoot, alias)
7288
+ if (existsSync(candidate) && statSync(candidate).isFile()) return candidate
7289
+ }
7290
+ let entries: readonly string[]
7291
+ try {
7292
+ entries = readdirSync(browsersRoot)
7293
+ } catch {
7294
+ return undefined
7295
+ }
7296
+ const revisions = entries
7297
+ .filter((entry) => /^chromium-\\d+$/.test(entry))
7298
+ .sort((a, b) => Number(b.slice('chromium-'.length)) - Number(a.slice('chromium-'.length)))
7299
+ for (const revision of revisions) {
7300
+ for (const layout of CHROMIUM_LAYOUTS) {
7301
+ const candidate = resolvePath(browsersRoot, revision, layout)
7302
+ if (existsSync(candidate)) return candidate
7303
+ }
7304
+ }
7305
+ return undefined
7306
+ }
7307
+
7308
+ ${CONST_KEYWORD} chromiumPinned = chromium.executablePath()
7309
+ ${CONST_KEYWORD} chromiumPath = resolveChromium(chromiumPinned)
7310
+ ${CONST_KEYWORD} chromiumOptions =
7311
+ chromiumPath === undefined || chromiumPath === chromiumPinned
7312
+ ? {}
7313
+ : { launchOptions: { executablePath: chromiumPath } }
7314
+ ` : ""}
7260
7315
  ${EXPORT_KEYWORD} function resolveWorkspacePath(relativePath: string): string {
7261
7316
  return fileURLToPath(new URL(relativePath, import.meta.url))
7262
7317
  }
@@ -7596,7 +7651,7 @@ ${EXPORT_KEYWORD} const srcBrowser = (config?: UserConfig): UserConfig =>
7596
7651
  }),
7597
7652
  browser: {
7598
7653
  enabled: true,
7599
- provider: playwright(),
7654
+ provider: playwright(chromiumOptions),
7600
7655
  instances: [{ browser: 'chromium', headless: true }],
7601
7656
  },
7602
7657
  fileParallelism: false,
@@ -7729,7 +7784,7 @@ ${EXPORT_KEYWORD} const srcBrowser = (config?: UserConfig): UserConfig =>
7729
7784
  }),
7730
7785
  browser: {
7731
7786
  enabled: true,
7732
- provider: playwright(),
7787
+ provider: playwright(chromiumOptions),
7733
7788
  instances: [{ browser: 'chromium', headless: true }],
7734
7789
  },
7735
7790
  fileParallelism: false,
@@ -7895,7 +7950,7 @@ ${EXPORT_KEYWORD} const srcBrowser = (config?: UserConfig): UserConfig =>
7895
7950
  }),
7896
7951
  browser: {
7897
7952
  enabled: true,
7898
- provider: playwright(),
7953
+ provider: playwright(chromiumOptions),
7899
7954
  instances: [{ browser: 'chromium', headless: true }],
7900
7955
  },
7901
7956
  fileParallelism: false,
@@ -8024,7 +8079,7 @@ ${EXPORT_KEYWORD} function appBrowser(...config: readonly never[]): UserConfig {
8024
8079
  },
8025
8080
  browser: {
8026
8081
  enabled: true,
8027
- provider: playwright(),
8082
+ provider: playwright(chromiumOptions),
8028
8083
  instances: [{ browser: 'chromium', headless: true }],
8029
8084
  },
8030
8085
  fileParallelism: false,
@@ -8597,8 +8652,8 @@ ${EXPORT_KEYWORD} ${FUNCTION_KEYWORD} exportsFor(specifier: string): readonly st
8597
8652
  function testArtifacts(spec, pascal) {
8598
8653
  const hasBrowser = spec.src.includes("browser") || spec.app.includes("browser");
8599
8654
  const hasVue = spec.app.includes("browser");
8600
- const browserPolicySpecifier = hasBrowser ? ", existsSync" : "";
8601
- const browserPolicyImport = hasBrowser ? "import { chromium } from 'playwright'" : "";
8655
+ const browserPolicySpecifier = hasBrowser ? ", accessSync, constants as FS_CONSTANTS, statSync" : "";
8656
+ const browserPolicyImport = hasBrowser ? "import { chromium } from 'playwright'\nimport { resolveChromium } from '../vite.config.js'" : "";
8602
8657
  const vuePolicyImport = hasVue ? "import { parse as parseVue } from 'vue/compiler-sfc'" : "";
8603
8658
  const workspacePolicyAssertion = hasVue ? `expect(
8604
8659
  inspectCodingWorkspace(process.cwd(), (path, content) => {
@@ -8610,12 +8665,13 @@ function testArtifacts(spec, pascal) {
8610
8665
  }),
8611
8666
  ).toEqual([])` : "expect(inspectCodingWorkspace(process.cwd())).toEqual([])";
8612
8667
  const browserPolicyTest = hasBrowser ? `
8613
- it.skipIf(!existsSync(chromium.executablePath()))(
8614
- 'runs browser suites only when the real Chromium executable is installed',
8615
- () => {
8616
- expect(existsSync(chromium.executablePath())).toBe(true)
8617
- },
8618
- )` : "";
8668
+ it('resolves Chromium only to a real executable file', () => {
8669
+ const chromiumPath = resolveChromium(chromium.executablePath())
8670
+ if (chromiumPath === undefined) return
8671
+
8672
+ expect(statSync(chromiumPath).isFile()).toBe(true)
8673
+ expect(() => accessSync(chromiumPath, FS_CONSTANTS.X_OK)).not.toThrow()
8674
+ })` : "";
8619
8675
  const artifacts = [fillArtifact("tests/setup.ts", "tests", "setup", {}), fillArtifact("tests/policy.test.ts", "tests", "policyTest", {
8620
8676
  browserPolicySpecifier,
8621
8677
  browserPolicyImport,