dsh-plugin-toolkit 0.20.9 → 0.20.10

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 CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.20.10
2
+
3
+ - **`expectSnapshot()` writes the baseline when `UPDATE_SNAPSHOTS=1`.** The
4
+ documented rerun now writes the normalised HTML and returns
5
+ `{ status: "written" }` instead of failing with the same missing-baseline
6
+ error. Without the variable, a missing or changed baseline still fails, so a
7
+ snapshot is never written as a side effect of an ordinary test run.
8
+ `panel.snapshot()` shares the same contract and names the same flag when the
9
+ baseline is missing.
10
+
1
11
  ## 0.20.9
2
12
 
3
13
  - **`dsh-plugin doctor` and `verify --no-mount` resolve a root export written as
package/README.md CHANGED
@@ -192,7 +192,7 @@ expectSnapshot(panel.html(), '__snapshots__', 'panel'); // throws with the ele
192
192
  await panel.unmount();
193
193
  ```
194
194
 
195
- First run writes nothing: it tells you to re-run with `UPDATE_SNAPSHOTS=1`, so a baseline is always a decision, never a side effect.
195
+ First run writes nothing: it tells you to re-run with `UPDATE_SNAPSHOTS=1`, so a baseline is always a decision, never a side effect. That rerun writes the normalised HTML and returns `{ status: 'written' }`; later runs return `same` or fail with the element that moved.
196
196
 
197
197
  ### Check what assistive tech sees
198
198
 
@@ -984,7 +984,11 @@ Honest list, so nobody plans around a feature that does not exist:
984
984
  ## Changelog
985
985
 
986
986
  [`CHANGELOG.md`](CHANGELOG.md) lists what changed in each release, including
987
- the `0.20.9` fix: `explain --log` expands the Windows spelling
987
+ the `0.20.10` fix: `expectSnapshot()` and `panel.snapshot()` honor the
988
+ documented `UPDATE_SNAPSHOTS=1` rerun by writing the normalised HTML and
989
+ returning `{ status: "written" }`, while an ordinary run still fails a missing
990
+ or changed baseline rather than writing one as a side effect. The `0.20.9` fix
991
+ is recorded too: `explain --log` expands the Windows spelling
988
992
  `~\.dsh\logs\install.log` exactly like `~/.dsh/logs/install.log`, so the
989
993
  documented command works in PowerShell and `cmd`, and a log that cannot be read
990
994
  exits `2` naming the resolved absolute path it tried instead of a directory
@@ -7,7 +7,7 @@
7
7
  import { createDom, installGlobals, requireFrom } from './env.mjs';
8
8
  import { createHost } from './host.mjs';
9
9
  import { loadBundle } from './load.mjs';
10
- import { compare, write } from './snapshot.mjs';
10
+ import { expectSnapshot, write } from './snapshot.mjs';
11
11
 
12
12
  function moduleShim(modules) {
13
13
  return (name) => {
@@ -213,16 +213,9 @@ export async function mountClient(options) {
213
213
  }
214
214
  return actual;
215
215
  },
216
- snapshot: (dir, name) => {
217
- const result = compare(dir, name, root.innerHTML);
218
- if (result.status === 'changed') {
219
- throw new Error(`${name} changed at <${result.actual.split(/(?=<)/)[result.firstDifference]}>`);
220
- }
221
- if (result.status === 'missing') {
222
- throw new Error(`${name} has no baseline at ${result.file}; run with --update to create it`);
223
- }
224
- return result;
225
- },
216
+ // Same contract as expectSnapshot: compare by default, write only when
217
+ // UPDATE_SNAPSHOTS=1 asks for it.
218
+ snapshot: (dir, name) => expectSnapshot(root.innerHTML, dir, name),
226
219
  writeSnapshot: (dir, name) => write(dir, name, root.innerHTML),
227
220
  unmount: async () => {
228
221
  await act(async () => {
@@ -53,6 +53,11 @@ export function write(dir, name, html) {
53
53
  export function expectSnapshot(html, dir, name) {
54
54
  const result = compare(dir, name, html);
55
55
  if (result.status === 'same') return result;
56
+ // Writing is opt-in: an ordinary run must never turn a missing or changed
57
+ // baseline into a pass. `UPDATE_SNAPSHOTS=1` is the documented decision.
58
+ if (process.env.UPDATE_SNAPSHOTS === '1') {
59
+ return { file: write(dir, name, html), status: 'written', actual: result.actual };
60
+ }
56
61
  if (result.status === 'missing') {
57
62
  throw new Error(`no baseline at ${result.file}; run with UPDATE_SNAPSHOTS=1 to create it`);
58
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-toolkit",
3
- "version": "0.20.9",
3
+ "version": "0.20.10",
4
4
  "description": "Preflight, release and test DeepSeek Harness plugins: check a folder or any GitHub repository, wait for npm to actually serve the version, and keep the market index honest.",
5
5
  "type": "module",
6
6
  "bin": {