@variance-authority/storybook-collector 0.1.0 → 0.1.1
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.
- package/CHANGELOG.md +22 -0
- package/dist/execution.js +24 -7
- package/dist/execution.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @variance-authority/storybook-collector
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- db08866: Keep the run when the execution journal cannot be recorded.
|
|
8
|
+
|
|
9
|
+
`close()` already held the position that a journal is not the artefact under
|
|
10
|
+
review: a recorder that declines to record is written to stderr and the run
|
|
11
|
+
continues, because failing the run over it would cost every subject in it the
|
|
12
|
+
baselines it just captured. Only the declining half was handled. A throw out of
|
|
13
|
+
the same call — `duplicate test coverage observation` was the one reached in
|
|
14
|
+
practice — went straight up through `close()` and took the run down with it.
|
|
15
|
+
Both outcomes now end the same way, in a sentence on stderr and a run that keeps
|
|
16
|
+
its images.
|
|
17
|
+
- Updated dependencies [fe578c8]
|
|
18
|
+
- @variance-authority/sense@0.1.1
|
|
19
|
+
- @variance-authority/core@0.1.1
|
|
20
|
+
- @variance-authority/dom@0.1.1
|
|
21
|
+
- @variance-authority/playwright@0.1.1
|
|
22
|
+
- @variance-authority/react@0.1.1
|
|
23
|
+
- @variance-authority/storybook@0.1.1
|
|
24
|
+
|
|
3
25
|
## 0.1.0
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/execution.js
CHANGED
|
@@ -49,13 +49,30 @@ export async function createStoryRecorder(index, options) {
|
|
|
49
49
|
// a visual run: losing it costs the *next* selection its narrowing, which
|
|
50
50
|
// is a full suite — the safe direction — while failing the run over it
|
|
51
51
|
// would cost this one its baselines, which is not.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
//
|
|
53
|
+
// That holds for a throw as much as for a refusal. The recorder reports
|
|
54
|
+
// what it declined in `because`, but it is a file format, a lock and a
|
|
55
|
+
// filesystem underneath, and any of them can raise something it has no
|
|
56
|
+
// sentence for. Letting that escape ends the run *after* every subject
|
|
57
|
+
// has been rendered and compared — the most expensive possible moment to
|
|
58
|
+
// lose a set of baselines, and over the half of the work that was only
|
|
59
|
+
// ever an addition.
|
|
60
|
+
let record;
|
|
61
|
+
try {
|
|
62
|
+
record = await recordExecution({
|
|
63
|
+
root,
|
|
64
|
+
subjects: observed,
|
|
65
|
+
...(options.label === undefined ? {} : { label: options.label }),
|
|
66
|
+
...(options.modulesFile === undefined ? {} : { modulesFile: options.modulesFile }),
|
|
67
|
+
...(options.coverageFile === undefined ? {} : { coverageFile: options.coverageFile }),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
process.stderr.write('variance-authority: recorded no story execution — the recorder failed with ' +
|
|
72
|
+
`${error instanceof Error ? error.message : String(error)}; this run is ` +
|
|
73
|
+
'unaffected and the next `--since` will run everything\n');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
59
76
|
if (!record.recorded) {
|
|
60
77
|
process.stderr.write(`variance-authority: recorded no story execution — ${record.because}\n`);
|
|
61
78
|
}
|
package/dist/execution.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../src/execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,cAAc,EACd,eAAe,GAGhB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4BpC,MAAM,CAAC,KAAK,UAAU,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CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB;oBACzE,yDAAyD,CAC5D,CAAC;gBACF,OAAO;YACT,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,qDAAqD,MAAM,CAAC,OAAO,IAAI,CACxE,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,cAAc,CAAC,KAAa;IACzC,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACjF,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["/**\n * What each story executed, recorded for the next run's selection.\n *\n * The instrument is the one `@variance-authority/sense` already uses; only the\n * transport differs, which is the rule\n * [spec 0028](../../../docs/specs/0028-the-instrument.md) states. The preview is\n * built with `testSelectionProbes()`, the page counts block crossings, and this\n * closes one window per story and joins them at the end of the run.\n *\n * A story is its own owner. Storybook is an execution surface this tool drives\n * one subject at a time, so — unlike a test runner, where the file is the\n * smallest thing a runner can be asked to execute — the crossings of one story\n * belong to that story and to nothing else.\n */\n\nimport { readFile } from 'node:fs/promises';\nimport {\n drainExecution,\n preconditionOf,\n recordExecution,\n type EvaluatingPage,\n type ObservedSubject,\n} from '@variance-authority/sense/journal';\nimport { parseStoryIndex } from '@variance-authority/storybook';\nimport { resolve } from 'node:path';\n\n/** Where a story run's execution evidence is joined, read and kept. */\nexport interface StoryExecutionOptions {\n /** Repository root the recorded paths are relative to. Defaults to the cwd. */\n readonly root?: string;\n /** Matches the `label` the build's `testSelectionProbes()` used. Defaults to `build`. */\n readonly label?: string;\n /** Block inventory the build wrote. Defaults to the label's repository-keyed cache. */\n readonly modulesFile?: string;\n /** Coverage index. Defaults to the repository-keyed cache the runner seams share. */\n readonly coverageFile?: string;\n}\n\n/** One run's accumulation: a window per story, written once at the end. */\nexport interface StoryRecorder {\n /**\n * Close one story's window.\n *\n * `complete` is false for a story this run refused. A refused story still\n * executed code, so its crossings are kept — what it may never do is justify\n * excluding itself from a later run.\n */\n readonly note: (page: EvaluatingPage, subjectId: string, complete: boolean) => Promise<void>;\n /** Merge the run into the index, or say on stderr why it could not. */\n readonly close: () => Promise<void>;\n}\n\nexport async function createStoryRecorder(\n index: string,\n options: StoryExecutionOptions,\n): Promise<StoryRecorder> {\n const root = resolve(options.root ?? process.cwd());\n const storyFiles = await storyFilesFrom(index);\n const observed: ObservedSubject[] = [];\n let seen = false;\n\n return {\n note: async (page, subjectId, complete) => {\n const journal = await drainExecution(page);\n if (journal === undefined) return;\n seen = true;\n const storyId = subjectId.replace(/^story:/, '');\n const file = storyFiles.get(storyId);\n const precondition = file === undefined ? undefined : await preconditionOf(root, file);\n observed.push({\n owner: subjectId,\n journal,\n complete,\n ...(precondition === undefined ? {} : { preconditions: [precondition] }),\n });\n },\n\n close: async () => {\n if (!seen) {\n process.stderr.write(\n 'variance-authority: `tests` is on and the Storybook preview has no execution ' +\n 'collector in it — build it with `testSelectionProbes()` from ' +\n '`@variance-authority/sense/journal`, or the next `--since` will run ' +\n 'everything\\n',\n );\n return;\n }\n // A refusal is written and the run continues. Recording is an addition to\n // a visual run: losing it costs the *next* selection its narrowing, which\n // is a full suite — the safe direction — while failing the run over it\n // would cost this one its baselines, which is not.\n //\n // That holds for a throw as much as for a refusal. The recorder reports\n // what it declined in `because`, but it is a file format, a lock and a\n // filesystem underneath, and any of them can raise something it has no\n // sentence for. Letting that escape ends the run *after* every subject\n // has been rendered and compared — the most expensive possible moment to\n // lose a set of baselines, and over the half of the work that was only\n // ever an addition.\n let record: Awaited<ReturnType<typeof recordExecution>>;\n try {\n record = await recordExecution({\n root,\n subjects: observed,\n ...(options.label === undefined ? {} : { label: options.label }),\n ...(options.modulesFile === undefined ? {} : { modulesFile: options.modulesFile }),\n ...(options.coverageFile === undefined ? {} : { coverageFile: options.coverageFile }),\n });\n } catch (error) {\n process.stderr.write(\n 'variance-authority: recorded no story execution — the recorder failed with ' +\n `${error instanceof Error ? error.message : String(error)}; this run is ` +\n 'unaffected and the next `--since` will run everything\\n',\n );\n return;\n }\n if (!record.recorded) {\n process.stderr.write(\n `variance-authority: recorded no story execution — ${record.because}\\n`,\n );\n }\n },\n };\n}\n\n/**\n * Story id to the file that declares it, from the index the run is driving.\n *\n * The one route from a subject back to a file, and the reason a story's own\n * `.stories` file can select it: nothing *enters* a story file the way execution\n * enters a module, so without this a commit that edits one selects nothing.\n */\nasync function storyFilesFrom(index: string): Promise<Map<string, string>> {\n const parsed = parseStoryIndex(JSON.parse(await readFile(index, 'utf8')), index);\n return new Map(parsed.stories.map((story) => [story.id, story.importPath]));\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@variance-authority/storybook-collector",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Turn a built or already-served Storybook into Variance Authority subjects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"variance-authority",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"build": "tsc --build"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@variance-authority/core": "^0.1.
|
|
44
|
-
"@variance-authority/dom": "^0.1.
|
|
45
|
-
"@variance-authority/playwright": "^0.1.
|
|
46
|
-
"@variance-authority/react": "^0.1.
|
|
47
|
-
"@variance-authority/sense": "^0.1.
|
|
48
|
-
"@variance-authority/storybook": "^0.1.
|
|
43
|
+
"@variance-authority/core": "^0.1.1",
|
|
44
|
+
"@variance-authority/dom": "^0.1.1",
|
|
45
|
+
"@variance-authority/playwright": "^0.1.1",
|
|
46
|
+
"@variance-authority/react": "^0.1.1",
|
|
47
|
+
"@variance-authority/sense": "^0.1.1",
|
|
48
|
+
"@variance-authority/storybook": "^0.1.1"
|
|
49
49
|
}
|
|
50
50
|
}
|