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