dsh-plugin-toolkit 0.20.46 → 0.20.48
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 +36 -0
- package/README.md +2 -2
- package/lib/verify.mjs +73 -56
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
## 0.20.48
|
|
2
|
+
|
|
3
|
+
- **`verify` packs exactly once, so `prepack` cannot change the archive after
|
|
4
|
+
the check read a different one.** The separate `npm pack --dry-run` was a
|
|
5
|
+
second invocation of the same hook: a non-idempotent `prepack` could write
|
|
6
|
+
`client.js` for the dry run and remove it for the real pack, and `verify` ran
|
|
7
|
+
user build code twice on every check. The dry run is gone. `verify` now runs a
|
|
8
|
+
single `npm pack`, judges that tarball's own file list, and — after installing
|
|
9
|
+
it — asks `doctor` again against the unpacked copy, so the installed patch,
|
|
10
|
+
client bundle and root are confirmed rather than assumed. A committed
|
|
11
|
+
`client.js` that `prepack` removes is caught at `pack` with the panel named.
|
|
12
|
+
`test/verify-prepack.test.mjs` pins one invocation per run on the
|
|
13
|
+
non-idempotent fixture across two runs at the library and, on the shipped CLI,
|
|
14
|
+
runs `verify` and `verify --no-mount` twice each on fresh copies: the first
|
|
15
|
+
run exits `0` after exactly one `prepack` and leaves the generated panel, and
|
|
16
|
+
the second exits `1` at `pack` naming `client.js`. It also spawns the shipped
|
|
17
|
+
CLI three times each for `verify .` and `verify --no-mount .` on the flip
|
|
18
|
+
fixture, requiring exit `1` every time; the generated-panel and
|
|
19
|
+
unmodified-scaffold controls still exit `0` with `ok packed`.
|
|
20
|
+
|
|
21
|
+
## 0.20.47
|
|
22
|
+
|
|
23
|
+
- **`verify` judges the tarball it installs, not the separate dry run.** A
|
|
24
|
+
non-idempotent `prepack` could write `client.js` during `npm pack --dry-run`
|
|
25
|
+
and remove it during the real `npm pack`, so `verify --no-mount` checked a
|
|
26
|
+
file list that did not describe the archive it installed and printed
|
|
27
|
+
`ok packed` for a tarball with no panel. The file-list check now reads npm's
|
|
28
|
+
file list for the exact tarball the install step receives, so a missing
|
|
29
|
+
`client.js` stops at `pack` and exits 1. A `prepack` that generates the panel
|
|
30
|
+
still passes, and the unchanged `init` scaffold still exits 0 with `ok
|
|
31
|
+
packed`. `test/verify-prepack.test.mjs` pins the non-idempotent fixture at the
|
|
32
|
+
library and the shipped CLI beside the generated, missing, and scaffold
|
|
33
|
+
controls. It also packs the fixture twice to prove the regression premise:
|
|
34
|
+
the dry run lists `client.js` and the real tarball omits it, so the fixture
|
|
35
|
+
cannot silently stop reproducing the bug.
|
|
36
|
+
|
|
1
37
|
## 0.20.46
|
|
2
38
|
|
|
3
39
|
- **`index` rejects two plugin entries that share a name before auditing
|
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 — exactly once — means the check reads the file list from the tarball `verify` installs, not from the folder you have. A separate dry run would execute `prepack` a second time, and that second execution can see a tree the first one changed, so the archive could differ from the list that was checked. 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
|
|
|
@@ -1055,7 +1055,7 @@ ok packed 5 file(s), installed the tarball, mounted the panel
|
|
|
1055
1055
|
My panel This panel came from dsh-plugin init. Clicks: 0
|
|
1056
1056
|
```
|
|
1057
1057
|
|
|
1058
|
-
It packs,
|
|
1058
|
+
It packs exactly once, 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, and `prepack` is never asked to run a second time against a tree the first run changed. A hook that removes the panel while building the tarball — on its first run or a later one — is caught here, and the installed copy is checked again after unpacking. 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:
|
|
1059
1059
|
|
|
1060
1060
|
```sh
|
|
1061
1061
|
$ npx dsh-plugin-toolkit verify .
|
package/lib/verify.mjs
CHANGED
|
@@ -16,16 +16,16 @@ import { resolveEntry } from './dev.mjs';
|
|
|
16
16
|
import { resolvePath } from './paths.mjs';
|
|
17
17
|
import { run } from './exec.mjs';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Pack exactly once, and report the files npm put in *that* tarball.
|
|
21
|
+
*
|
|
22
|
+
* `prepack` is arbitrary user code. Running a dry run first would execute it
|
|
23
|
+
* twice, and the second invocation can see a tree the first one changed: a hook
|
|
24
|
+
* that deletes `client.js` when it already exists would pass the dry run with a
|
|
25
|
+
* panel and then build the tarball without one. The archive described here is
|
|
26
|
+
* the one the install step below receives, so its file list is the only one
|
|
27
|
+
* `verify` may judge.
|
|
28
|
+
*/
|
|
29
29
|
function packTarball(dir, destination) {
|
|
30
30
|
const output = run('npm', ['pack', '--pack-destination', destination, '--json'], {
|
|
31
31
|
cwd: dir,
|
|
@@ -33,7 +33,11 @@ function packTarball(dir, destination) {
|
|
|
33
33
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
34
34
|
});
|
|
35
35
|
const [document] = JSON.parse(output);
|
|
36
|
-
return
|
|
36
|
+
return {
|
|
37
|
+
tarball: path.join(destination, document.filename),
|
|
38
|
+
files: (document.files ?? []).map((entry) => entry.path),
|
|
39
|
+
size: document.size,
|
|
40
|
+
};
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
/**
|
|
@@ -183,56 +187,59 @@ export async function verify({ dir, mount = true }) {
|
|
|
183
187
|
}
|
|
184
188
|
const failures = [];
|
|
185
189
|
|
|
186
|
-
|
|
190
|
+
const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'dsh-plugin-verify-'));
|
|
187
191
|
try {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
192
|
+
// One pack. The dry run that used to precede it was a second `prepack`
|
|
193
|
+
// invocation, and the tarball was built from a tree that hook had already
|
|
194
|
+
// changed. This archive is the exact one handed to `npm install` below.
|
|
195
|
+
let packed;
|
|
196
|
+
try {
|
|
197
|
+
packed = packTarball(root, scratch);
|
|
198
|
+
} catch (error) {
|
|
199
|
+
return {
|
|
200
|
+
ok: false,
|
|
201
|
+
stage: 'pack',
|
|
202
|
+
failures: [{ check: 'pack', message: `npm pack failed: ${String(error.stderr ?? error.message).trim().split('\n').slice(-1)[0]}` }],
|
|
203
|
+
files: [],
|
|
204
|
+
};
|
|
205
|
+
}
|
|
197
206
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
+
// Everything package.json points at has to be inside the tarball, or the
|
|
208
|
+
// installed plugin is missing its own code.
|
|
209
|
+
const shipped = new Set(packed.files);
|
|
210
|
+
for (const target of declaredPaths(report.manifest)) {
|
|
211
|
+
if (shipsPath(shipped, target) === false) {
|
|
212
|
+
failures.push({
|
|
213
|
+
check: 'pack',
|
|
214
|
+
message: `the tarball does not contain ${target}, so the installed plugin would be missing it`,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
207
217
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
218
|
+
// The client bundle is usually found by convention (`client.js`), so it is
|
|
219
|
+
// not in `declaredPaths` — but it still has to be in the tarball.
|
|
220
|
+
const repoEntry = resolveEntry(root, report.manifest);
|
|
221
|
+
if (repoEntry !== null) {
|
|
222
|
+
const relative = path.relative(root, repoEntry).split(path.sep).join('/');
|
|
223
|
+
if (shipsPath(shipped, relative) === false) {
|
|
224
|
+
failures.push({
|
|
225
|
+
check: 'pack',
|
|
226
|
+
message: `the tarball does not contain ${relative}, so the installed plugin has no panel`,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
219
229
|
}
|
|
220
|
-
}
|
|
221
230
|
|
|
222
|
-
|
|
231
|
+
if (failures.length > 0) return { ok: false, stage: 'pack', failures, files: packed.files };
|
|
223
232
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
+
// `prepack` has now run, so whatever it generates is on disk. Ask every
|
|
234
|
+
// source check again, even when the first pass was clean: `prepack` can also
|
|
235
|
+
// make a previously passing package worse, for example by writing a
|
|
236
|
+
// `client.js` that no `dsh.client` declaration serves. Reading the folder
|
|
237
|
+
// after the pack is the only way to judge what was actually shipped.
|
|
238
|
+
const checked = doctor(root);
|
|
239
|
+
if (checked.failures.length > 0) {
|
|
240
|
+
return { ok: false, stage: 'doctor', failures: checked.failures, files: packed.files };
|
|
241
|
+
}
|
|
233
242
|
|
|
234
|
-
const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'dsh-plugin-verify-'));
|
|
235
|
-
try {
|
|
236
243
|
return await inspectScratch({ dir: root, mount, report: checked, packed, scratch });
|
|
237
244
|
} finally {
|
|
238
245
|
// Verify runs repeatedly in CI; leaving a full install tree behind each
|
|
@@ -266,8 +273,7 @@ async function importInstalledRoot(name, scratch) {
|
|
|
266
273
|
async function inspectScratch({ dir, mount, report, packed, scratch }) {
|
|
267
274
|
let installed;
|
|
268
275
|
try {
|
|
269
|
-
|
|
270
|
-
run('npm', ['install', tarball, '--prefix', path.join(scratch, 'install'), '--no-save', '--ignore-scripts', '--no-audit', '--no-fund'], {
|
|
276
|
+
run('npm', ['install', packed.tarball, '--prefix', path.join(scratch, 'install'), '--no-save', '--ignore-scripts', '--no-audit', '--no-fund'], {
|
|
271
277
|
cwd: scratch,
|
|
272
278
|
encoding: 'utf8',
|
|
273
279
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
@@ -291,6 +297,17 @@ async function inspectScratch({ dir, mount, report, packed, scratch }) {
|
|
|
291
297
|
};
|
|
292
298
|
}
|
|
293
299
|
|
|
300
|
+
// The tarball's own file list caught an omission before install, but the copy
|
|
301
|
+
// npm unpacked is what the loader will actually read. Judge that copy too: a
|
|
302
|
+
// prepack hook (or an ignore file) can still leave the installed package
|
|
303
|
+
// without the patch, the client bundle or the root it declared. `installed`
|
|
304
|
+
// mode skips the `files` allowlist, because by now only the unpacked files
|
|
305
|
+
// matter.
|
|
306
|
+
const unpacked = doctor(installed, { installed: true });
|
|
307
|
+
if (unpacked.failures.length > 0) {
|
|
308
|
+
return { ok: false, stage: 'install', failures: unpacked.failures, files: packed.files, installed };
|
|
309
|
+
}
|
|
310
|
+
|
|
294
311
|
// The loader starts the host half by importing the bare package name. Doing
|
|
295
312
|
// the same import here is the only way to know the row will have an apply —
|
|
296
313
|
// 0.8.0 shipped a package whose root export was the CLI, installed cleanly,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-toolkit",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.48",
|
|
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": {
|