@orkestrel/scaffold 0.0.136 → 0.0.138

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.
@@ -1210,7 +1210,7 @@ export declare const CANON_PATHS: readonly string[];
1210
1210
  * ```ts
1211
1211
  * import { CAPTURE_DEV_DEPENDENCIES } from '@orkestrel/scaffold'
1212
1212
  *
1213
- * CAPTURE_DEV_DEPENDENCIES['@orkestrel/capture'] // '^0.0.5'
1213
+ * CAPTURE_DEV_DEPENDENCIES['@orkestrel/capture'] // '^0.0.10'
1214
1214
  * ```
1215
1215
  */
1216
1216
  export declare const CAPTURE_DEV_DEPENDENCIES: Readonly<Record<string, string>>;
@@ -1210,7 +1210,7 @@ export declare const CANON_PATHS: readonly string[];
1210
1210
  * ```ts
1211
1211
  * import { CAPTURE_DEV_DEPENDENCIES } from '@orkestrel/scaffold'
1212
1212
  *
1213
- * CAPTURE_DEV_DEPENDENCIES['@orkestrel/capture'] // '^0.0.5'
1213
+ * CAPTURE_DEV_DEPENDENCIES['@orkestrel/capture'] // '^0.0.10'
1214
1214
  * ```
1215
1215
  */
1216
1216
  export declare const CAPTURE_DEV_DEPENDENCIES: Readonly<Record<string, string>>;
@@ -3,7 +3,7 @@ import { fillTemplate } from "@orkestrel/template";
3
3
  import { Emitter } from "@orkestrel/emitter";
4
4
  var package_default = {
5
5
  name: "@orkestrel/scaffold",
6
- version: "0.0.136",
6
+ version: "0.0.138",
7
7
  description: "Scaffold workspaces with commands: new, audit, surface, repair, catalog, and overwrite.",
8
8
  keywords: [
9
9
  "audit",
@@ -95,20 +95,20 @@ var package_default = {
95
95
  "prepublishOnly": "npm run format:check && npm run lint:check && npm run check && npm run build && npm test && npm run test:templates && npm run test:distribution -- --mode release"
96
96
  },
97
97
  dependencies: {
98
- "@orkestrel/console": "^0.0.20",
98
+ "@orkestrel/console": "^0.0.21",
99
99
  "@orkestrel/contract": "^0.0.24",
100
- "@orkestrel/emitter": "^0.0.16",
101
- "@orkestrel/markdown": "^0.0.21",
102
- "@orkestrel/process": "^0.0.19",
103
- "@orkestrel/template": "^0.0.14"
100
+ "@orkestrel/emitter": "^0.0.17",
101
+ "@orkestrel/markdown": "^0.0.22",
102
+ "@orkestrel/process": "^0.0.21",
103
+ "@orkestrel/template": "^0.0.15"
104
104
  },
105
105
  devDependencies: {
106
106
  "@microsoft/api-extractor": "^7.60.1",
107
- "@orkestrel/browser": "^0.0.33",
108
- "@orkestrel/guide": "^0.0.31",
109
- "@orkestrel/html": "^0.0.16",
110
- "@orkestrel/probe": "^0.0.30",
111
- "@orkestrel/test": "^0.0.39",
107
+ "@orkestrel/browser": "^0.0.34",
108
+ "@orkestrel/guide": "^0.0.32",
109
+ "@orkestrel/html": "^0.0.17",
110
+ "@orkestrel/probe": "^0.0.31",
111
+ "@orkestrel/test": "^0.0.42",
112
112
  "@types/node": "^24.19.2",
113
113
  "@vitest/browser-playwright": "^5.1.0",
114
114
  "oxfmt": "^0.78.0",
@@ -795,10 +795,10 @@ var BROWSE_DEV_DEPENDENCIES = Object.freeze({ "@orkestrel/browser": package_defa
795
795
  * ```ts
796
796
  * import { CAPTURE_DEV_DEPENDENCIES } from '@orkestrel/scaffold'
797
797
  *
798
- * CAPTURE_DEV_DEPENDENCIES['@orkestrel/capture'] // '^0.0.5'
798
+ * CAPTURE_DEV_DEPENDENCIES['@orkestrel/capture'] // '^0.0.10'
799
799
  * ```
800
800
  */
801
- var CAPTURE_DEV_DEPENDENCIES = Object.freeze({ "@orkestrel/capture": "^0.0.5" });
801
+ var CAPTURE_DEV_DEPENDENCIES = Object.freeze({ "@orkestrel/capture": "^0.0.10" });
802
802
  /**
803
803
  * Lists the Orkestrel packages that publish a `/browser` entry, frozen.
804
804
  *
@@ -847,6 +847,7 @@ var CAPTURE_UPSTREAM = Object.freeze([
847
847
  "@orkestrel/contract",
848
848
  "@orkestrel/emitter",
849
849
  "@orkestrel/process",
850
+ "@orkestrel/test",
850
851
  "@orkestrel/timeout"
851
852
  ]);
852
853
  /**
@@ -1408,7 +1409,6 @@ export function srcBin(override?: UserConfig): UserConfig {
1408
1409
  // and retain the exclusion of the journey suite.
1409
1410
  export function appJourney(
1410
1411
  variant: JourneyVariant,
1411
- variants: readonly JourneyVariant[],
1412
1412
  mode?: string,
1413
1413
  override?: UserConfig,
1414
1414
  ): UserConfig {
@@ -1421,7 +1421,6 @@ export function appJourney(
1421
1421
  name: { label: \`journey:\${variant.name}\`, color: 'green' },
1422
1422
  include: [\`tests/app/\${application}/integration.test.ts\`],
1423
1423
  exclude: [],
1424
- provide: { variant: variant.name, variants, capture },
1425
1424
  browser: {
1426
1425
  ...browser.test?.browser,
1427
1426
  enabled: true,
@@ -2221,6 +2220,7 @@ import { appShowcase } from '../../vite.config.ts'
2221
2220
  export default defineConfig(({ mode }) => appShowcase(mode))
2222
2221
  `,
2223
2222
  journey: `import type { JourneyVariant } from '@orkestrel/test'
2223
+ import { buildCaptureWrapper } from '@orkestrel/capture/server'
2224
2224
  import { defineConfig } from 'vitest/config'
2225
2225
  import { appJourney } from '../../vite.config.ts'
2226
2226
 
@@ -2230,11 +2230,24 @@ const VARIANTS: readonly JourneyVariant[] = Object.freeze([
2230
2230
  { name: 'compact', width: 390, height: 844 },
2231
2231
  ])
2232
2232
 
2233
- export default defineConfig(({ mode }) => ({
2234
- test: {
2235
- projects: VARIANTS.map((variant) => () => appJourney(variant, VARIANTS, mode)),
2236
- },
2237
- }))
2233
+ // Declare every owner path a journey case carries; the seeded arrival journey owns pages:arrival.
2234
+ export default defineConfig(({ mode }) =>
2235
+ buildCaptureWrapper({
2236
+ url: import.meta.url,
2237
+ variants: VARIANTS,
2238
+ owners: ['pages:arrival'],
2239
+ first: 'desktop',
2240
+ final: 'closes the run',
2241
+ directory: 'tmp/captures/states',
2242
+ inputs: ['app/**', 'src/**', 'configs/**', 'tests/**', 'vite.config.ts', 'package-lock.json'],
2243
+ sources: {
2244
+ shared: ['configs/**', 'tests/setup*.ts', 'vite.config.ts', 'package-lock.json'],
2245
+ tests: ['tests/app/**'],
2246
+ },
2247
+ portfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],
2248
+ project: (variant, override) => appJourney(variant, mode, override),
2249
+ }),
2250
+ )
2238
2251
  `
2239
2252
  })
2240
2253
  }),
@@ -2643,7 +2656,16 @@ createApp(App).mount(document.body.appendChild(document.createElement('main')))
2643
2656
  `
2644
2657
  }),
2645
2658
  tests: Object.freeze({
2646
- journey: `import {
2659
+ journey: `import type { CaptureRules } from '@orkestrel/capture'
2660
+ import {
2661
+ buildCaptureDestinations,
2662
+ buildCaptureRun,
2663
+ buildCaptureTags,
2664
+ buildCaptureTest,
2665
+ collectCaptureCases,
2666
+ renderCaptureArtifact,
2667
+ } from '@orkestrel/capture'
2668
+ import {
2647
2669
  ACCESSIBLE_ROLES,
2648
2670
  createPortfolio,
2649
2671
  expandCaptures,
@@ -2651,26 +2673,42 @@ createApp(App).mount(document.body.appendChild(document.createElement('main')))
2651
2673
  readRefusal,
2652
2674
  readStyle,
2653
2675
  } from '@orkestrel/test/browser'
2654
- {{imports}}import { page } from 'vitest/browser'
2676
+ {{imports}}import { page, server } from 'vitest/browser'
2655
2677
  import { describe, expect, inject, it } from 'vitest'
2656
2678
 
2657
2679
  const VARIANT = inject('variant')
2658
2680
  const VARIANTS = inject('variants')
2659
2681
  const CAPTURE = inject('capture')
2682
+ const REQUEST = inject('request')
2683
+ const RECORD = inject('record')
2684
+ const STATES = ['{{application}}-arrival']
2685
+ const RULES: CaptureRules = {
2686
+ owners: ['pages:arrival'],
2687
+ part: (state) => {
2688
+ if (!STATES.includes(state)) throw new Error(\`Undeclared capture state: \${state}\`)
2689
+ return 'pages:arrival'
2690
+ },
2691
+ sources: () => ({ own: ['app/{{application}}/**'], ...inject('sources') }),
2692
+ }
2693
+ const ARRIVAL = buildCaptureTest(
2694
+ { owner: 'pages:arrival', states: STATES, variant: VARIANT },
2695
+ RULES,
2696
+ )
2697
+ const FINAL = { tags: [...buildCaptureTags(RULES.owners)] }
2698
+ const PORTFOLIO = createPortfolio({
2699
+ states: STATES,
2700
+ variants: VARIANTS,
2701
+ variant: VARIANT,
2702
+ directory: '../../../tmp/captures/states',
2703
+ scope: () => 'pages',
2704
+ enabled: CAPTURE,
2705
+ ...(REQUEST?.state === undefined ? {} : { state: REQUEST.state }),
2706
+ })
2660
2707
 
2661
2708
  describe('{{application}} arrival journey', () => {
2662
- it('proves the declared arrival families', async () => {
2709
+ it('proves the declared arrival families', ARRIVAL, async () => {
2663
2710
  const families = ['Journey', 'Refusal', 'Matrix', ...(CAPTURE ? ['Capture'] : [])]
2664
2711
  const proven: string[] = []
2665
- const states = ['{{application}}-arrival']
2666
- const placed: string[] = []
2667
- const portfolio = createPortfolio({
2668
- states,
2669
- variants: VARIANTS,
2670
- variant: VARIANT,
2671
- directory: '../../../tmp/captures/states',
2672
- enabled: CAPTURE,
2673
- })
2674
2712
  {{mount}} try {
2675
2713
  {{arrival}} const heading = page
2676
2714
  .getByRole('heading', {
@@ -2681,8 +2719,7 @@ describe('{{application}} arrival journey', () => {
2681
2719
  .element()
2682
2720
  expect(isRendered(heading)).toBe(true)
2683
2721
  proven.push('Journey')
2684
- await portfolio.place('{{application}}-arrival')
2685
- placed.push('{{application}}-arrival')
2722
+ await PORTFOLIO.place('{{application}}-arrival')
2686
2723
 
2687
2724
  for (const role of ACCESSIBLE_ROLES) expect(page.getByRole(role).elements()).toEqual([])
2688
2725
  expect(readRefusal('Continue')).toBe(
@@ -2700,19 +2737,22 @@ describe('{{application}} arrival journey', () => {
2700
2737
  expect(measured).toEqual(VARIANTS.map(({ name }) => name))
2701
2738
  proven.push('Matrix')
2702
2739
 
2703
- const files = expandCaptures(states, VARIANTS)
2704
- expect(portfolio.files).toEqual(files)
2705
- expect(new Set(files).size).toBe(states.length * VARIANTS.length)
2706
- expect(placed).toEqual(states)
2740
+ const files = expandCaptures(STATES, VARIANTS, () => 'pages')
2741
+ expect(PORTFOLIO.files).toEqual(files)
2742
+ expect(new Set(files).size).toBe(STATES.length * VARIANTS.length)
2743
+ expect(PORTFOLIO.observed).toEqual(STATES)
2707
2744
  const expected = CAPTURE
2708
2745
  ? expandCaptures(
2709
- states,
2746
+ STATES,
2710
2747
  VARIANTS.filter(({ name }) => name === VARIANT),
2748
+ () => 'pages',
2711
2749
  )
2712
2750
  : []
2713
- expect(portfolio.paths.map((path) => path.replaceAll('\\\\', '/').split('/').at(-1))).toEqual(
2714
- expected,
2715
- )
2751
+ expect(
2752
+ (await server.commands.readCaptureFrames()).filter((file) =>
2753
+ file.endsWith(\`--\${VARIANT}.png\`),
2754
+ ),
2755
+ ).toEqual(expected)
2716
2756
  if (CAPTURE) proven.push('Capture')
2717
2757
  expect(proven).toEqual(families)
2718
2758
  } finally {
@@ -2721,14 +2761,53 @@ describe('{{application}} arrival journey', () => {
2721
2761
  }
2722
2762
  })
2723
2763
  })
2764
+
2765
+ it('closes the run', FINAL, async (context) => {
2766
+ const cases = collectCaptureCases(context.task.file)
2767
+ const run = buildCaptureRun({
2768
+ cases,
2769
+ registry: buildCaptureDestinations(cases, RULES, {
2770
+ project: \`journey:\${VARIANT}\`,
2771
+ portfolios: inject('portfolios').map((root) => ({
2772
+ ...root,
2773
+ variant: VARIANT,
2774
+ states: STATES,
2775
+ })),
2776
+ }),
2777
+ observed: PORTFOLIO.observed,
2778
+ emitted: [...PORTFOLIO.placements.entries()].flatMap(([index, state]) => {
2779
+ const path = PORTFOLIO.paths[index]
2780
+ return path === undefined ? [] : [[state, path] as const]
2781
+ }),
2782
+ variant: VARIANT,
2783
+ time: new Date().toISOString(),
2784
+ ...(REQUEST === undefined ? {} : { request: REQUEST }),
2785
+ })
2786
+ const stem = RECORD.slice('tmp/captures/states/'.length).replace(/\\.json$/u, '')
2787
+ const artifact = \`tmp/journey/\${stem}.txt\`
2788
+ const text = [...renderCaptureArtifact(RECORD, run), ''].join('\\n')
2789
+ const digest = Array.from(
2790
+ new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text))),
2791
+ (byte) => byte.toString(16).padStart(2, '0'),
2792
+ ).join('')
2793
+ await server.commands.writeFile(artifact, text)
2794
+ await server.commands.writeFile(
2795
+ RECORD,
2796
+ JSON.stringify({ ...run, artifact: { file: artifact, digest } }),
2797
+ )
2798
+ expect(run.passed).not.toEqual([])
2799
+ })
2724
2800
  `,
2725
- browser: `import type { JourneyVariant } from '@orkestrel/test'
2801
+ browser: `import type { CaptureMeta, CaptureProvided } from '@orkestrel/capture'
2726
2802
 
2727
2803
  declare module 'vitest' {
2728
- export interface ProvidedContext {
2729
- readonly variant: string
2730
- readonly variants: readonly JourneyVariant[]
2731
- readonly capture: boolean
2804
+ export interface ProvidedContext extends CaptureProvided {}
2805
+ export interface TaskMeta extends CaptureMeta {}
2806
+ }
2807
+
2808
+ declare module 'vitest/browser' {
2809
+ export interface BrowserCommands {
2810
+ readonly readCaptureFrames: () => Promise<readonly string[]>
2732
2811
  }
2733
2812
  }
2734
2813
  `,
@@ -8259,7 +8338,7 @@ ${projects.map((project) => `\t\t\t${project},`).join("\n")}
8259
8338
  vitest: benches.length === 0 ? "" : "defaultExclude, ",
8260
8339
  helpers: helpers.length === 0 ? "" : matchesPrintWidth(helperImport.trimEnd()) ? helperImport : `import {\n${helpers.map((helper) => `\t${helper},`).join("\n")}\n} from './configs/helpers.js'\n`,
8261
8340
  browsers: machinery.browser ? "import { resolveBrowser, resolvePinnedBrowser } from './configs/browsers.js'\nimport { commands } from './configs/commands.js'\n" : "",
8262
- options: (machinery.browser ? "const browserOptions = resolveBrowser(resolvePinnedBrowser(), process.platform, process.env)\n// Vitest writes a page.screenshot() capture beside its test file unless a directory is named.\nconst screenshots = resolveWorkspacePath('tmp/captures/screenshots')\n\n" + blueprintToOptimizedDependencies(blueprint) : "") + (journeyed ? "const capture = process.env.CAPTURE === '1'\n\n" : "") + ((blueprint.journey || blueprint.showcase) && (base || applicationFaces.length > 0) ? `const applications = {\n${base ? " browser: appBrowser,\n" : ""}${applicationFaces.map((extension) => `\t${extension.name}: app${extension.name[0]?.toUpperCase()}${extension.name.slice(1)},\n`).join("")}}\n\n` : ""),
8341
+ options: (machinery.browser ? "const browserOptions = resolveBrowser(resolvePinnedBrowser(), process.platform, process.env)\n// Vitest writes a page.screenshot() capture beside its test file unless a directory is named.\nconst screenshots = resolveWorkspacePath('tmp/captures/screenshots')\n\n" + blueprintToOptimizedDependencies(blueprint) : "") + ((blueprint.journey || blueprint.showcase) && (base || applicationFaces.length > 0) ? `const applications = {\n${base ? " browser: appBrowser,\n" : ""}${applicationFaces.map((extension) => `\t${extension.name}: app${extension.name[0]?.toUpperCase()}${extension.name.slice(1)},\n`).join("")}}\n\n` : ""),
8263
8342
  factories: body,
8264
8343
  projects: projectRows
8265
8344
  });
@@ -8664,13 +8743,29 @@ function blueprintToTestArtifacts(blueprint) {
8664
8743
  })
8665
8744
  };
8666
8745
  });
8746
+ const base = blueprint.base && blueprint.app.includes("browser");
8747
+ const journeys = blueprint.journey && (base || blueprintToFaces(blueprint).some((extension) => extension.surface === "browser" && extension.axes.includes("app"))) ? [...base ? ["browser"] : [], ...blueprintToFaces(blueprint).flatMap((extension) => extension.surface === "browser" && extension.axes.includes("app") ? [extension.name] : [])].map((application) => ({
8748
+ path: `tests/app/${application}/integration.test.ts`,
8749
+ group: "tests",
8750
+ ownership: "birth",
8751
+ origin: "template",
8752
+ environment: "browser",
8753
+ content: fillTemplate(ARTIFACT_TEMPLATES.tests.journey, {
8754
+ application,
8755
+ heading: serializeTypeScriptString(blueprint.name),
8756
+ imports: application === "vue" ? "import { createApp } from 'vue'\nimport App from '../../../app/vue/App.vue'\n" : "",
8757
+ mount: application === "vue" ? " const container = document.body.appendChild(document.createElement('main'))\n const app = createApp(App)\n" : "",
8758
+ arrival: application === "vue" ? " app.mount(container)\n" : " await import('../../../app/browser/main.js')\n",
8759
+ cleanup: application === "vue" ? " app.unmount()\n container.remove()\n" : " for (const main of page.getByRole('main').elements()) main.remove()\n"
8760
+ })
8761
+ })) : [];
8667
8762
  const browsers = blueprintToMachinery(blueprint).browser ? [{
8668
8763
  path: "tests/setupBrowser.ts",
8669
8764
  group: "tests",
8670
8765
  ownership: "birth",
8671
8766
  origin: "template",
8672
8767
  environment: "browser",
8673
- content: blueprint.journey ? ARTIFACT_TEMPLATES.tests.browser : ARTIFACT_TEMPLATES.tests.setup
8768
+ content: journeys.length > 0 ? ARTIFACT_TEMPLATES.tests.browser : ARTIFACT_TEMPLATES.tests.setup
8674
8769
  }] : [];
8675
8770
  const servers = blueprint.src.includes("server") || blueprint.app.includes("server") || blueprint.bin.length > 0 || blueprint.conformance || blueprint.tree ? [{
8676
8771
  path: "tests/setupServer.ts",
@@ -8700,22 +8795,6 @@ function blueprintToTestArtifacts(blueprint) {
8700
8795
  origin: "template",
8701
8796
  content: ARTIFACT_TEMPLATES.tests.global.proof
8702
8797
  }] : [];
8703
- const base = blueprint.base && blueprint.app.includes("browser");
8704
- const journeys = blueprint.journey && (base || blueprintToFaces(blueprint).some((extension) => extension.surface === "browser" && extension.axes.includes("app"))) ? [...base ? ["browser"] : [], ...blueprintToFaces(blueprint).flatMap((extension) => extension.surface === "browser" && extension.axes.includes("app") ? [extension.name] : [])].map((application) => ({
8705
- path: `tests/app/${application}/integration.test.ts`,
8706
- group: "tests",
8707
- ownership: "birth",
8708
- origin: "template",
8709
- environment: "browser",
8710
- content: fillTemplate(ARTIFACT_TEMPLATES.tests.journey, {
8711
- application,
8712
- heading: serializeTypeScriptString(blueprint.name),
8713
- imports: application === "vue" ? "import { createApp } from 'vue'\nimport App from '../../../app/vue/App.vue'\n" : "",
8714
- mount: application === "vue" ? " const container = document.body.appendChild(document.createElement('main'))\n const app = createApp(App)\n" : "",
8715
- arrival: application === "vue" ? " app.mount(container)\n" : " await import('../../../app/browser/main.js')\n",
8716
- cleanup: application === "vue" ? " app.unmount()\n container.remove()\n" : " for (const main of page.getByRole('main').elements()) main.remove()\n"
8717
- })
8718
- })) : [];
8719
8798
  const sources = Iterator.from(blueprint.src).map((environment) => ({
8720
8799
  path: `tests/src/${environment}/index.test.ts`,
8721
8800
  group: "tests",