dsh-plugin-toolkit 0.20.45 → 0.20.47
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 +32 -0
- package/README.md +7 -4
- package/lib/index-file.mjs +25 -0
- package/lib/verify.mjs +65 -38
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
## 0.20.47
|
|
2
|
+
|
|
3
|
+
- **`verify` judges the tarball it installs, not the separate dry run.** A
|
|
4
|
+
non-idempotent `prepack` could write `client.js` during `npm pack --dry-run`
|
|
5
|
+
and remove it during the real `npm pack`, so `verify --no-mount` checked a
|
|
6
|
+
file list that did not describe the archive it installed and printed
|
|
7
|
+
`ok packed` for a tarball with no panel. The file-list check now reads npm's
|
|
8
|
+
file list for the exact tarball the install step receives, so a missing
|
|
9
|
+
`client.js` stops at `pack` and exits 1. A `prepack` that generates the panel
|
|
10
|
+
still passes, and the unchanged `init` scaffold still exits 0 with `ok
|
|
11
|
+
packed`. `test/verify-prepack.test.mjs` pins the non-idempotent fixture at the
|
|
12
|
+
library and the shipped CLI beside the generated, missing, and scaffold
|
|
13
|
+
controls. It also packs the fixture twice to prove the regression premise:
|
|
14
|
+
the dry run lists `client.js` and the real tarball omits it, so the fixture
|
|
15
|
+
cannot silently stop reproducing the bug.
|
|
16
|
+
|
|
17
|
+
## 0.20.46
|
|
18
|
+
|
|
19
|
+
- **`index` rejects two plugin entries that share a name before auditing
|
|
20
|
+
either.** The audit resolves a plugin by name, so a second `dup-plugin` entry
|
|
21
|
+
re-read the first entry's versions and printed `ok` for both, even when the
|
|
22
|
+
duplicate was the broken one. The shape pass now groups plugin names by
|
|
23
|
+
position and emits one finding naming every duplicate position
|
|
24
|
+
(`plugins[0], plugins[1]`), so the command exits `1` before the `ok` loop can
|
|
25
|
+
start. Distinct names still audit and print `ok` for each entry. A unique
|
|
26
|
+
plugin may list several versions, and when its second version (`1.0.1`) omits
|
|
27
|
+
`engines.dsh` the command still exits `1` with `1.0.1 no engines.dsh` instead
|
|
28
|
+
of inheriting the clean first version.
|
|
29
|
+
`test/index-duplicate.test.mjs` pins the duplicate finding at the library and
|
|
30
|
+
the shipped CLI, the absence of either `ok` line, and both control paths,
|
|
31
|
+
including the finding for a second version that is missing its range.
|
|
32
|
+
|
|
1
33
|
## 0.20.45
|
|
2
34
|
|
|
3
35
|
- **The reproducible compatibility sample answers for the DSH version the
|
package/README.md
CHANGED
|
@@ -80,7 +80,7 @@ npx dsh-plugin-toolkit@latest release . --pr --merge
|
|
|
80
80
|
|
|
81
81
|

|
|
82
82
|
|
|
83
|
-
The order matters. Packing first means the check reads the file list
|
|
83
|
+
The order matters. Packing first means the check reads the file list from the tarball `verify` installs, not the folder you have and not a separate dry run whose `prepack` output can differ. Installing the tarball means the root is imported by its bare specifier — the package name the loader uses — not by a file path taken from `main` or `exports["."]`. Node ignores `main` once `exports` exists, so a package whose `exports` map has no `"."` entry fails with `ERR_PACKAGE_PATH_NOT_EXPORTED` at that step even though the file is present. Mounting means the client bundle is actually executed, in jsdom, with a host that records what it registered. Packing first also means a panel built by a `prepack` hook exists when the source checks run: the hook has written it into the folder before `doctor`'s file checks are asked again.
|
|
84
84
|
|
|
85
85
|
Each step exists because a plugin once got past the step before it and still installed into nothing.
|
|
86
86
|
|
|
@@ -416,8 +416,11 @@ forgets `client.js` passes it and fails only after `npm i`.
|
|
|
416
416
|
`engines.dsh` is missing or is not a semver range (a malformed value such as
|
|
417
417
|
`>=banana`, or a single pinned version such as `0.2.0`, both fail). It also
|
|
418
418
|
rejects an index it cannot audit: a missing `plugins` or `versions` array, a
|
|
419
|
-
plugin entry without a name,
|
|
420
|
-
non-SemVer `version`. Each failure names the file and
|
|
419
|
+
plugin entry without a name, two entries sharing one name, a version entry
|
|
420
|
+
without `version`, and a non-SemVer `version`. Each failure names the file and
|
|
421
|
+
the plugin, entry, or both duplicate positions. A duplicate is rejected before
|
|
422
|
+
any audit, so the second entry cannot inherit the first entry's clean result or
|
|
423
|
+
produce an `ok` line.
|
|
421
424
|
Pin `version:` if you would rather not track the latest release.
|
|
422
425
|
|
|
423
426
|
## Check a plugin you have not cloned
|
|
@@ -1052,7 +1055,7 @@ ok packed 5 file(s), installed the tarball, mounted the panel
|
|
|
1052
1055
|
My panel This panel came from dsh-plugin init. Clicks: 0
|
|
1053
1056
|
```
|
|
1054
1057
|
|
|
1055
|
-
It packs,
|
|
1058
|
+
It packs, reads that tarball's file list, installs the same tarball into a throwaway directory, then mounts the bundle **from the installed copy**. The file list therefore describes the archive users would get, so a `client.js` that a non-idempotent `prepack` writes only during the dry run no longer passes. The host half is imported by the package's bare name, exactly as the loader imports it, so an `exports` map with no `.` entry fails with `ERR_PACKAGE_PATH_NOT_EXPORTED` even when `main` names a working file; `verify --no-mount` reports that as a `root export` failure naming the missing `.` export. The host half is also called and awaited, so an `async apply()` that rejects is reported as a `host apply` failure instead of printing the success line and then crashing with an unhandled rejection; the client half's boot probe is awaited the same way, so an async `apply()` that rejects on the bare context is a `boot` failure. A package that declares neither `exports` nor `main` has no root module at all; there is nothing to import, and the success line says it skipped the host import instead of claiming one ran. When the `files` list drops the panel:
|
|
1056
1059
|
|
|
1057
1060
|
```sh
|
|
1058
1061
|
$ npx dsh-plugin-toolkit verify .
|
package/lib/index-file.mjs
CHANGED
|
@@ -37,6 +37,11 @@ function nonEmptyString(value) {
|
|
|
37
37
|
* list) or crashed on `plugin.name` and printed a raw TypeError. Every finding
|
|
38
38
|
* names the plugin and, where one exists, the entry position or version, so a
|
|
39
39
|
* CI log points at the JSON line to edit instead of at the command.
|
|
40
|
+
*
|
|
41
|
+
* Names have to be unique too. `auditVersions()` resolves a plugin by name, so
|
|
42
|
+
* a second entry with the same name made the audit re-read the first entry and
|
|
43
|
+
* report the duplicate clean. Duplicate names are reported by position, before
|
|
44
|
+
* any `engines.dsh` check can print `ok` for either entry.
|
|
40
45
|
*/
|
|
41
46
|
export function validateIndex(index) {
|
|
42
47
|
if (isRecord(index) === false) {
|
|
@@ -55,6 +60,7 @@ export function validateIndex(index) {
|
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
const findings = [];
|
|
63
|
+
const names = new Map();
|
|
58
64
|
index.plugins.forEach((plugin, pluginPosition) => {
|
|
59
65
|
if (isRecord(plugin) === false) {
|
|
60
66
|
findings.push({ entry: `plugins[${pluginPosition}]`, problem: 'the plugin entry is not an object' });
|
|
@@ -62,6 +68,14 @@ export function validateIndex(index) {
|
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
const name = nonEmptyString(plugin.name) ? plugin.name : `plugins[${pluginPosition}]`;
|
|
71
|
+
if (nonEmptyString(plugin.name)) {
|
|
72
|
+
// Keep every position so the finding names the entry to delete, not just
|
|
73
|
+
// the one the audit happens to read. A blank or missing name already has
|
|
74
|
+
// its own finding and is not a duplicate.
|
|
75
|
+
const positions = names.get(plugin.name) ?? [];
|
|
76
|
+
positions.push(pluginPosition);
|
|
77
|
+
names.set(plugin.name, positions);
|
|
78
|
+
}
|
|
65
79
|
if (nonEmptyString(plugin.name) === false) {
|
|
66
80
|
findings.push({
|
|
67
81
|
entry: name,
|
|
@@ -111,6 +125,17 @@ export function validateIndex(index) {
|
|
|
111
125
|
}
|
|
112
126
|
});
|
|
113
127
|
});
|
|
128
|
+
|
|
129
|
+
// One finding per repeated name, naming every duplicate position. Auditing a
|
|
130
|
+
// duplicate by name would silently reuse the first entry, so this has to
|
|
131
|
+
// stop the command before the `ok` loop starts.
|
|
132
|
+
for (const [name, positions] of names) {
|
|
133
|
+
if (positions.length < 2) continue;
|
|
134
|
+
findings.push({
|
|
135
|
+
entry: positions.map((position) => `plugins[${position}]`).join(', '),
|
|
136
|
+
problem: `all are named "${name}"; every plugin name must be unique`,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
114
139
|
return findings;
|
|
115
140
|
}
|
|
116
141
|
|
package/lib/verify.mjs
CHANGED
|
@@ -26,6 +26,15 @@ function packJson(dir) {
|
|
|
26
26
|
return { files: (document.files ?? []).map((entry) => entry.path), filename: document.filename, size: document.size };
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Pack once, and report the files npm put in *that* tarball.
|
|
31
|
+
*
|
|
32
|
+
* The returned list is the one `verify` has to judge: it describes the archive
|
|
33
|
+
* npm install is about to receive. A dry-run list is not enough, because npm
|
|
34
|
+
* runs `prepack` for the dry run too. A non-idempotent hook can produce a
|
|
35
|
+
* different file set the second time, so a tarball that omits the declared
|
|
36
|
+
* `client.js` would still pass a check made against the dry run.
|
|
37
|
+
*/
|
|
29
38
|
function packTarball(dir, destination) {
|
|
30
39
|
const output = run('npm', ['pack', '--pack-destination', destination, '--json'], {
|
|
31
40
|
cwd: dir,
|
|
@@ -33,7 +42,11 @@ function packTarball(dir, destination) {
|
|
|
33
42
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
34
43
|
});
|
|
35
44
|
const [document] = JSON.parse(output);
|
|
36
|
-
return
|
|
45
|
+
return {
|
|
46
|
+
tarball: path.join(destination, document.filename),
|
|
47
|
+
files: (document.files ?? []).map((entry) => entry.path),
|
|
48
|
+
size: document.size,
|
|
49
|
+
};
|
|
37
50
|
}
|
|
38
51
|
|
|
39
52
|
/**
|
|
@@ -183,9 +196,12 @@ export async function verify({ dir, mount = true }) {
|
|
|
183
196
|
}
|
|
184
197
|
const failures = [];
|
|
185
198
|
|
|
186
|
-
|
|
199
|
+
// Keep the dry run as a cheap preflight, but do not trust its file list: a
|
|
200
|
+
// non-idempotent `prepack` may put `client.js` in the dry-run list and omit it
|
|
201
|
+
// from the tarball npm builds next. That second invocation is the archive
|
|
202
|
+
// `verify` installs, so its own file list is the one checked below.
|
|
187
203
|
try {
|
|
188
|
-
|
|
204
|
+
packJson(root);
|
|
189
205
|
} catch (error) {
|
|
190
206
|
return {
|
|
191
207
|
ok: false,
|
|
@@ -195,44 +211,56 @@ export async function verify({ dir, mount = true }) {
|
|
|
195
211
|
};
|
|
196
212
|
}
|
|
197
213
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
214
|
+
const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'dsh-plugin-verify-'));
|
|
215
|
+
try {
|
|
216
|
+
let packed;
|
|
217
|
+
try {
|
|
218
|
+
packed = packTarball(root, scratch);
|
|
219
|
+
} catch (error) {
|
|
220
|
+
return {
|
|
221
|
+
ok: false,
|
|
222
|
+
stage: 'pack',
|
|
223
|
+
failures: [{ check: 'pack', message: `npm pack failed: ${String(error.stderr ?? error.message).trim().split('\n').slice(-1)[0]}` }],
|
|
224
|
+
files: [],
|
|
225
|
+
};
|
|
207
226
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
227
|
+
|
|
228
|
+
// Everything package.json points at has to be inside the tarball, or the
|
|
229
|
+
// installed plugin is missing its own code.
|
|
230
|
+
const shipped = new Set(packed.files);
|
|
231
|
+
for (const target of declaredPaths(report.manifest)) {
|
|
232
|
+
if (shipsPath(shipped, target) === false) {
|
|
233
|
+
failures.push({
|
|
234
|
+
check: 'pack',
|
|
235
|
+
message: `the tarball does not contain ${target}, so the installed plugin would be missing it`,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
// The client bundle is usually found by convention (`client.js`), so it is
|
|
240
|
+
// not in `declaredPaths` — but it still has to be in the tarball.
|
|
241
|
+
const repoEntry = resolveEntry(root, report.manifest);
|
|
242
|
+
if (repoEntry !== null) {
|
|
243
|
+
const relative = path.relative(root, repoEntry).split(path.sep).join('/');
|
|
244
|
+
if (shipsPath(shipped, relative) === false) {
|
|
245
|
+
failures.push({
|
|
246
|
+
check: 'pack',
|
|
247
|
+
message: `the tarball does not contain ${relative}, so the installed plugin has no panel`,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
219
250
|
}
|
|
220
|
-
}
|
|
221
251
|
|
|
222
|
-
|
|
252
|
+
if (failures.length > 0) return { ok: false, stage: 'pack', failures, files: packed.files };
|
|
223
253
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
254
|
+
// `prepack` has now run, so whatever it generates is on disk. Ask every
|
|
255
|
+
// source check again, even when the first pass was clean: `prepack` can also
|
|
256
|
+
// make a previously passing package worse, for example by writing a
|
|
257
|
+
// `client.js` that no `dsh.client` declaration serves. Reading the folder
|
|
258
|
+
// after the pack is the only way to judge what was actually shipped.
|
|
259
|
+
const checked = doctor(root);
|
|
260
|
+
if (checked.failures.length > 0) {
|
|
261
|
+
return { ok: false, stage: 'doctor', failures: checked.failures, files: packed.files };
|
|
262
|
+
}
|
|
233
263
|
|
|
234
|
-
const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'dsh-plugin-verify-'));
|
|
235
|
-
try {
|
|
236
264
|
return await inspectScratch({ dir: root, mount, report: checked, packed, scratch });
|
|
237
265
|
} finally {
|
|
238
266
|
// Verify runs repeatedly in CI; leaving a full install tree behind each
|
|
@@ -266,8 +294,7 @@ async function importInstalledRoot(name, scratch) {
|
|
|
266
294
|
async function inspectScratch({ dir, mount, report, packed, scratch }) {
|
|
267
295
|
let installed;
|
|
268
296
|
try {
|
|
269
|
-
|
|
270
|
-
run('npm', ['install', tarball, '--prefix', path.join(scratch, 'install'), '--no-save', '--ignore-scripts', '--no-audit', '--no-fund'], {
|
|
297
|
+
run('npm', ['install', packed.tarball, '--prefix', path.join(scratch, 'install'), '--no-save', '--ignore-scripts', '--no-audit', '--no-fund'], {
|
|
271
298
|
cwd: scratch,
|
|
272
299
|
encoding: 'utf8',
|
|
273
300
|
stdio: ['ignore', 'pipe', 'pipe'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-toolkit",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.47",
|
|
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": {
|