dsh-plugin-toolkit 0.20.28 → 0.20.29

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,30 @@
1
+ ## 0.20.29
2
+
3
+ - **The tarball gate covers `examples/*.mjs` as well as `scripts/*.mjs`.** The
4
+ gate reads every `node <path>` command from `README.md` and `README.zh.md`,
5
+ compares the paths with `npm pack --dry-run --json` and with the published
6
+ `files` list, and names every missing path. Replaying the 0.20.12 file list
7
+ fails with the four example paths and `scripts/preview.mjs`; the current list
8
+ passes, so a future `files` edit that drops either kind of documented command
9
+ is caught before publication.
10
+
11
+ - **A fresh install ships the four `node examples/*.mjs` commands its README
12
+ cites.** `files` listed only `examples/compatibility-sample/`, so the four
13
+ testkit examples worked in a checkout and were absent after `npm pack` +
14
+ `npm install`. The published file list now names `mount-a-bundle.mjs`,
15
+ `route-stubs.mjs`, `baseline.mjs` and `aria.mjs`. A regression test reads the
16
+ commands from the shipped READMEs, packs and installs the tarball into a temp
17
+ prefix, and requires each installed example to exist and match the repository
18
+ byte for byte.
19
+
20
+ - **The BOM acceptance cases run through the real CLI.** Three checked-in
21
+ fixtures (`readme-plain`, `readme-bom`, `readme-bom-no-heading`) turn the
22
+ documented behavior into commands: the first two exit `0` with `ok`, and the
23
+ third exits `1` with the `readme` failure. The test asserts each fixture
24
+ README really does (or does not) start with U+FEFF before spawning
25
+ `bin/dsh-plugin.mjs doctor`, so a fixture that lost its BOM cannot make the
26
+ test pass for the wrong reason.
27
+
1
28
  ## 0.20.28
2
29
 
3
30
  - **`doctor` reads a README saved with a UTF-8 BOM instead of calling its
@@ -0,0 +1,18 @@
1
+ /**
2
+ * What assistive tech sees, asserted the same way the rest of the panel is.
3
+ *
4
+ * Run: node examples/aria.mjs
5
+ */
6
+ import { mountClient } from 'dsh-plugin-toolkit/testkit';
7
+
8
+ const panel = await mountClient({ file: 'fixtures/client-bundle/client.js', copy: { demo: { title: 'Demo' } } });
9
+
10
+ // expectAria names the attribute that differs, so a failure reads like a bug
11
+ // report instead of "expected true to equal false".
12
+ const live = panel.expectAria('[aria-live="polite"]', { live: 'polite', text: '0' });
13
+ console.log(`live region: ${live.live} -> "${live.text}"`);
14
+
15
+ const button = panel.expectAria('[aria-label]', { label: 'increment' });
16
+ console.log(`labelled control: ${button.label}`);
17
+
18
+ await panel.unmount();
@@ -0,0 +1,14 @@
1
+ /**
2
+ * A DOM baseline: normalised markup in a file, compared on every run.
3
+ *
4
+ * Run: node examples/baseline.mjs
5
+ * First run writes nothing; re-run with UPDATE_SNAPSHOTS=1 to create the file.
6
+ */
7
+ import { expectSnapshot, mountClient } from 'dsh-plugin-toolkit/testkit';
8
+
9
+ const panel = await mountClient({ file: 'fixtures/client-bundle/client.js', copy: { demo: { title: 'Demo' } } });
10
+
11
+ const result = expectSnapshot(panel.html(), 'fixtures/client-bundle/__snapshots__', 'panel');
12
+ console.log(`baseline: ${result.status}`);
13
+
14
+ await panel.unmount();
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The shortest useful thing testkit does: mount a real client bundle and read
3
+ * what a user would see.
4
+ *
5
+ * Run: node examples/mount-a-bundle.mjs
6
+ */
7
+ import { mountClient } from 'dsh-plugin-toolkit/testkit';
8
+
9
+ const panel = await mountClient({ file: 'fixtures/client-bundle/client.js', copy: { demo: { title: 'Demo' } } });
10
+
11
+ console.log(panel.text());
12
+
13
+ await panel.click('[data-testid="inc"]');
14
+ console.log(panel.text());
15
+
16
+ await panel.unmount();
@@ -0,0 +1,19 @@
1
+ /**
2
+ * A panel that talks to its host: answer the routes it asks for, then assert on
3
+ * what it did — including the requests themselves.
4
+ *
5
+ * Run: node examples/route-stubs.mjs
6
+ */
7
+ import { createFetch, mountClient } from 'dsh-plugin-toolkit/testkit';
8
+
9
+ const stub = createFetch({
10
+ '/demo/report': { body: { score: 71 } },
11
+ '/demo/apply': () => ({ status: 201, body: { score: 92 } }),
12
+ });
13
+
14
+ const panel = await mountClient({ file: 'fixtures/fetching-bundle/client.js', fetch: stub });
15
+
16
+ console.log(panel.text());
17
+ console.log(`asked for: ${stub.calls('/demo/report').length} route(s), undeclared route answers ${(await stub('/demo/nothing')).status}`);
18
+
19
+ await panel.unmount();
@@ -0,0 +1,43 @@
1
+ /**
2
+ * A `node <path>` command printed in a shipped README is a promise about the
3
+ * installed package. The READMEs are in `files`, but the paths they name are
4
+ * not automatically packed: `scripts/preview.mjs` and the four
5
+ * `examples/*.mjs` commands were documented while `files` left them out.
6
+ *
7
+ * The tarball gate reads the promise from the shipped READMEs instead of a
8
+ * copy in the test, so a command added to a README and a path dropped from
9
+ * `files` cannot drift apart between releases.
10
+ */
11
+ import fs from 'node:fs';
12
+ import path from 'node:path';
13
+
14
+ // Both READMEs are in the published file list. A command documented only in
15
+ // the Chinese README is still a command an installed reader can try to run.
16
+ export const SHIPPED_READMES = ['README.md', 'README.zh.md'];
17
+
18
+ // Examples may live below a folder (examples/compatibility-sample/...); keep
19
+ // the capture broad enough for a nested path but restricted to the two
20
+ // directories the toolkit actually documents as runnable commands.
21
+ export const RUN_COMMAND = /\bnode\s+((?:scripts|examples)\/[A-Za-z0-9._/-]+\.mjs)\b/gu;
22
+
23
+ /** Every distinct runnable path the shipped READMEs tell a reader to pass to node. */
24
+ export function documentedRunCommands(root, readmes = SHIPPED_READMES) {
25
+ const found = new Map();
26
+ for (const readme of readmes) {
27
+ const file = path.join(root, readme);
28
+ if (fs.existsSync(file) === false) continue;
29
+ // A Windows checkout writes README.md with CRLF; the command is text, so
30
+ // normalize before matching the line a reader copies.
31
+ const text = fs.readFileSync(file, 'utf8').replace(/\r\n/gu, '\n');
32
+ for (const match of text.matchAll(RUN_COMMAND)) {
33
+ if (found.has(match[1]) === false) found.set(match[1], readme);
34
+ }
35
+ }
36
+ return found;
37
+ }
38
+
39
+ /** Documented paths that the given shipped-file list does not contain. */
40
+ export function missingRunCommands(documented, shipped) {
41
+ const files = new Set(shipped);
42
+ return [...documented.keys()].filter((command) => files.has(command) === false).sort();
43
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-toolkit",
3
- "version": "0.20.28",
3
+ "version": "0.20.29",
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": {
@@ -26,10 +26,14 @@
26
26
  "docs/badge.svg",
27
27
  "docs/card.png",
28
28
  "docs/ecosystem-audit-2026-11-03.txt",
29
+ "examples/aria.mjs",
30
+ "examples/baseline.mjs",
31
+ "examples/compatibility-sample/",
32
+ "examples/mount-a-bundle.mjs",
33
+ "examples/route-stubs.mjs",
29
34
  "scripts/benchmark-audit.mjs",
30
35
  "scripts/compatibility-sample.mjs",
31
- "scripts/preview.mjs",
32
- "examples/compatibility-sample/"
36
+ "scripts/preview.mjs"
33
37
  ],
34
38
  "engines": {
35
39
  "node": ">=18",