dsh-plugin-toolkit 0.20.23 → 0.20.24
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 +44 -0
- package/README.md +9 -2
- package/lib/doctor.mjs +65 -24
- package/lib/exec.mjs +34 -0
- package/lib/pr.mjs +2 -2
- package/lib/release.mjs +51 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
+
## 0.20.24
|
|
2
|
+
|
|
3
|
+
- **A check run with a conclusion is settled even if GitHub leaves its status
|
|
4
|
+
at `in_progress`.** On 2026-11-11 GitHub wrote `conclusion: success` and
|
|
5
|
+
`completed_at` for `the tool on a real plugin` but kept `status:
|
|
6
|
+
in_progress`; the gate read only the status, called the commit still checked,
|
|
7
|
+
and refused `plugin-v0.20.24` twice while every real check had passed. A
|
|
8
|
+
conclusion now counts as the verdict in both required and best-effort checks,
|
|
9
|
+
and a failure conclusion still refuses. A check with no conclusion is still
|
|
10
|
+
pending, so this does not turn a queued job green. A regression test feeds the
|
|
11
|
+
exact `in_progress`/`success` pair and requires the commit to publish.
|
|
12
|
+
|
|
13
|
+
- **`doctor` applies negated `files` entries instead of passing a package npm
|
|
14
|
+
will publish without its client.** `files: ["lib", "!lib/secret.js"]` ships
|
|
15
|
+
the folder but drops `lib/secret.js`; the check saw `lib` cover the exported
|
|
16
|
+
client and exited `0`, so the installed plugin was missing code its own
|
|
17
|
+
`exports["./client"]` named. A leading `!` now removes what the positive
|
|
18
|
+
entries shipped — a file, a folder and its subtree, or a basename pattern at
|
|
19
|
+
any depth — and a later positive entry can re-include a path. The same
|
|
20
|
+
manifest without the `!` entry still passes. A committed fixture feeds one
|
|
21
|
+
`files` list to both `npm pack` and `doctor`: the suite requires the packer to
|
|
22
|
+
leave `lib/secret.js` out of the tarball and `doctor` to report it on three
|
|
23
|
+
consecutive runs, so the check cannot drift from the packer.
|
|
24
|
+
|
|
25
|
+
- **A failed `market/<version>` push is named, not a raw exec error.** With
|
|
26
|
+
`--pr`, a rejected or denied branch push used to surface only as
|
|
27
|
+
`Command failed: git push -u origin market/<version>` from the exec wrapper.
|
|
28
|
+
The `push` step now quotes git's own `stderr` (or `stdout` when that is where a
|
|
29
|
+
wrapper wrote the reason), names the branch, and drops the wrapper's
|
|
30
|
+
`Command failed:` line. The tag push uses the same helper, so a remote that
|
|
31
|
+
writes its rejection on stdout is named too.
|
|
32
|
+
|
|
33
|
+
- **A failed push is checked against origin before the retry is blamed.** A
|
|
34
|
+
push can exit non-zero after receive-pack already updated the ref (a
|
|
35
|
+
post-receive hook, or a connection that drops after the reply). The retry
|
|
36
|
+
path now reads `refs/tags/<tag>` from `origin` when `git push` fails: the same
|
|
37
|
+
tag object means the tag landed and the release continues; a different object
|
|
38
|
+
means origin owns that name at another commit, so the error names both object
|
|
39
|
+
ids and says neither tag was moved instead of claiming "the tag is still
|
|
40
|
+
local" and telling the user to re-run a push that cannot succeed. A test
|
|
41
|
+
makes the push throw while the bare origin already carries the tag and
|
|
42
|
+
requires exit `0`; a conflicting-tag test requires both ids in the `git`
|
|
43
|
+
stage error and leaves origin's tag untouched.
|
|
44
|
+
|
|
1
45
|
## 0.20.23
|
|
2
46
|
|
|
3
47
|
- **A failed `git push` is reported as the `git` stage, not a raw exec error.**
|
package/README.md
CHANGED
|
@@ -697,7 +697,7 @@ the diff in the terminal.
|
|
|
697
697
|
| `dsh field` | `dsh.bundle.patch` must exist for the host to load the plugin |
|
|
698
698
|
| `patch file` | The path declared above must be a real file |
|
|
699
699
|
| `client entry` | If `dsh.client` is declared, the bundle has to be there |
|
|
700
|
-
| `files list` | Every path `package.json` points at (`exports`, patch, client) must be covered by `files
|
|
700
|
+
| `files list` | Every path `package.json` points at (`exports`, patch, client) must be covered by `files`; a leading `!` excludes what the positive entries would ship |
|
|
701
701
|
| `root export` | The loader imports the bare package name; if that module is missing, is a directory, is the CLI, exports no `apply`, or the `exports` map has no `.` entry, the row mounts nothing while the install reports success |
|
|
702
702
|
|
|
703
703
|
The `root export` check is a source check, not an install. `doctor` resolves the module the loader imports — `exports["."]` when it is a string or a conditions object (`default`, `import`, `require`, `node`, `module-sync`), otherwise `main` — then checks that the path is a readable regular file, removes comments and the contents of string, template and regex literals, and looks for a real export. A missing file, a directory and an unreadable file are reported as `root export` failures naming the target instead of being skipped or raising a raw `EISDIR`; on a directory the install would have failed at import too. It accepts `export function apply`, `export async function apply`, `export const apply = ...` (also `let` and `var`), `export { apply }` (including `export { helper as apply }`), `exports.apply = ...`, and an `apply` property in `module.exports = { ... }`. A comment such as `// TODO: export function apply() {}` is not an export, and `doctor` never imports or runs the plugin to decide.
|
|
@@ -1021,7 +1021,14 @@ dsh-plugin release stopped at git
|
|
|
1021
1021
|
|
|
1022
1022
|
Fix the remote (for example `git remote set-url origin <url>`) and run the same
|
|
1023
1023
|
command again. The local tag already points at HEAD, so the re-run resumes and
|
|
1024
|
-
pushes it instead of creating it again.
|
|
1024
|
+
pushes it instead of creating it again. A push that exits non-zero is checked
|
|
1025
|
+
against origin before it is reported: if the remote already has the same tag
|
|
1026
|
+
object, the release continues (the ref landed despite the error); if origin has
|
|
1027
|
+
that tag at a different commit, the error names both objects and says neither
|
|
1028
|
+
tag was moved, because re-running cannot resolve a published-tag conflict. With
|
|
1029
|
+
`--pr`, a rejected push of the `market/<version>` branch is reported the same
|
|
1030
|
+
way: the branch is named and git's own reason is quoted instead of the exec
|
|
1031
|
+
wrapper's `Command failed:` line.
|
|
1025
1032
|
|
|
1026
1033
|
### When nothing publishes for you
|
|
1027
1034
|
|
package/lib/doctor.mjs
CHANGED
|
@@ -411,36 +411,77 @@ function globMatches(value, pattern) {
|
|
|
411
411
|
}
|
|
412
412
|
|
|
413
413
|
/**
|
|
414
|
-
* A `files` entry covers a path when it is equal, a parent folder, or
|
|
415
|
-
* that npm's own packer would expand to that path. `*` does not cross a
|
|
414
|
+
* A positive `files` entry covers a path when it is equal, a parent folder, or
|
|
415
|
+
* a glob that npm's own packer would expand to that path. `*` does not cross a
|
|
416
416
|
* directory separator: `"files": ["*.js"]` ships root-level JavaScript only,
|
|
417
417
|
* while `lib/*.js` covers direct children of `lib` and `lib/**` (or npm's
|
|
418
418
|
* `lib/*` shorthand) covers the subtree.
|
|
419
419
|
*/
|
|
420
|
+
function shippedByEntry(wanted, entry) {
|
|
421
|
+
let clean = packagePath(entry);
|
|
422
|
+
if (clean === '' || clean === '.') return false;
|
|
423
|
+
if (GLOB_MAGIC.test(clean) === false) {
|
|
424
|
+
// npm treats a folder entry as "everything below it", with or without a
|
|
425
|
+
// trailing slash: `"files": ["lib"]` ships lib/index.js.
|
|
426
|
+
clean = clean.replace(/\/+$/u, '');
|
|
427
|
+
if (clean === '') return false;
|
|
428
|
+
return wanted === clean || wanted.startsWith(`${clean}/`);
|
|
429
|
+
}
|
|
430
|
+
// npm appends `*` to a `dir/*` entry, making it a subtree pattern.
|
|
431
|
+
if (clean.endsWith('/*') === true) clean += '*';
|
|
432
|
+
if (globMatches(wanted, clean) === true) return true;
|
|
433
|
+
// minimatch's matchBase: a pattern with no slash can match a basename, but
|
|
434
|
+
// ignore-walk still has to have traversed every parent directory first.
|
|
435
|
+
if (clean.includes('/') === false) {
|
|
436
|
+
const segments = wanted.split('/');
|
|
437
|
+
return segments.length > 1 && segments.every((segment) => globMatches(segment, clean));
|
|
438
|
+
}
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* npm reads a leading `!` in `files` as an exclusion. An ignore rule is looser
|
|
444
|
+
* than a whitelist entry: a pattern with no slash matches a basename at any
|
|
445
|
+
* depth (`!*.test.js`), and a pattern that names a parent folder removes the
|
|
446
|
+
* whole subtree (`!lib/secret.js` and `!lib/private`).
|
|
447
|
+
*/
|
|
448
|
+
function excludedByEntry(wanted, entry) {
|
|
449
|
+
let clean = packagePath(entry);
|
|
450
|
+
if (clean === '' || clean === '.') return false;
|
|
451
|
+
if (GLOB_MAGIC.test(clean) === false) {
|
|
452
|
+
clean = clean.replace(/\/+$/u, '');
|
|
453
|
+
if (clean === '') return false;
|
|
454
|
+
if (clean.includes('/') === true) return wanted === clean || wanted.startsWith(`${clean}/`);
|
|
455
|
+
return wanted.split('/').includes(clean);
|
|
456
|
+
}
|
|
457
|
+
// npm appends `*` to a `dir/*` entry here too, so `!lib/*` drops the folder.
|
|
458
|
+
if (clean.endsWith('/*') === true) clean += '*';
|
|
459
|
+
// Walk from the root: a pattern that matches a parent folder removes the
|
|
460
|
+
// files below it, and a pattern with no slash may match any basename.
|
|
461
|
+
let prefix = '';
|
|
462
|
+
for (const segment of wanted.split('/')) {
|
|
463
|
+
prefix = prefix === '' ? segment : `${prefix}/${segment}`;
|
|
464
|
+
if (globMatches(prefix, clean) === true) return true;
|
|
465
|
+
if (clean.includes('/') === false && globMatches(segment, clean) === true) return true;
|
|
466
|
+
}
|
|
467
|
+
return false;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Whether a `files` list ships `target`. Entries are applied in order, so a
|
|
472
|
+
* later positive entry can re-include a path an earlier `!` entry excluded.
|
|
473
|
+
*/
|
|
420
474
|
export function isShipped(target, files) {
|
|
421
475
|
const wanted = packagePath(target);
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
return wanted === clean || wanted.startsWith(`${clean}/`);
|
|
432
|
-
}
|
|
433
|
-
// npm appends `*` to a `dir/*` entry, making it a subtree pattern.
|
|
434
|
-
if (clean.endsWith('/*') === true) clean += '*';
|
|
435
|
-
if (globMatches(wanted, clean) === true) return true;
|
|
436
|
-
// minimatch's matchBase: a pattern with no slash can match a basename, but
|
|
437
|
-
// ignore-walk still has to have traversed every parent directory first.
|
|
438
|
-
if (clean.includes('/') === false) {
|
|
439
|
-
const segments = wanted.split('/');
|
|
440
|
-
return segments.length > 1 && segments.every((segment) => globMatches(segment, clean));
|
|
441
|
-
}
|
|
442
|
-
return false;
|
|
443
|
-
});
|
|
476
|
+
let shipped = false;
|
|
477
|
+
for (const entry of files) {
|
|
478
|
+
if (typeof entry !== 'string') continue;
|
|
479
|
+
const negated = entry.startsWith('!');
|
|
480
|
+
const pattern = negated ? entry.slice(1) : entry;
|
|
481
|
+
const matches = negated ? excludedByEntry(wanted, pattern) : shippedByEntry(wanted, pattern);
|
|
482
|
+
if (matches === true) shipped = !negated;
|
|
483
|
+
}
|
|
484
|
+
return shipped;
|
|
444
485
|
}
|
|
445
486
|
|
|
446
487
|
/**
|
package/lib/exec.mjs
CHANGED
|
@@ -28,3 +28,37 @@ export function run(name, args, options = {}) {
|
|
|
28
28
|
}
|
|
29
29
|
return execFileSync(name, args, options);
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The command's own answer, without the thrown command line, stack, or the
|
|
34
|
+
* `Command failed:` prefix execFileSync puts in front of it.
|
|
35
|
+
*
|
|
36
|
+
* A failed step in a release is not a crash: the caller has to be able to name
|
|
37
|
+
* the stage and quote the remote's reason. Prefer stderr (where git writes
|
|
38
|
+
* `fatal:` / `remote:`), then stdout (where some wrappers put it), and only
|
|
39
|
+
* fall back to the exception message. Keeping the first six non-empty lines
|
|
40
|
+
* preserves the useful lines and drops blank lines and trailing advice.
|
|
41
|
+
*/
|
|
42
|
+
export function commandFailureDetail(error, maxLines = 6) {
|
|
43
|
+
let text = '';
|
|
44
|
+
for (const candidate of [error?.stderr, error?.stdout, error?.message]) {
|
|
45
|
+
const value = String(candidate ?? '').trim();
|
|
46
|
+
if (value !== '') {
|
|
47
|
+
text = value;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (text === '') return 'the command exited with an error.';
|
|
52
|
+
|
|
53
|
+
const lines = text
|
|
54
|
+
.split('\n')
|
|
55
|
+
.map((line) => line.trim())
|
|
56
|
+
.filter((line) => line !== '');
|
|
57
|
+
// execFileSync's `.message` starts with the command it ran. Once there is a
|
|
58
|
+
// following line, that first line is noise, not the command's reason.
|
|
59
|
+
if (lines.length > 1 && /^Command failed:/u.test(lines[0]) === true) lines.shift();
|
|
60
|
+
const detail = lines.slice(0, maxLines).join('; ');
|
|
61
|
+
// Callers append their own sentence after this, so give every detail a
|
|
62
|
+
// sentence ending instead of producing "rejected The tag ...".
|
|
63
|
+
return /[.!?]$/u.test(detail) === true ? detail : `${detail}.`;
|
|
64
|
+
}
|
package/lib/pr.mjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Every side effect goes through an injected runner, so the sequence can be
|
|
6
6
|
* asserted without a network, a repository, or a `gh` login.
|
|
7
7
|
*/
|
|
8
|
-
import { run } from './exec.mjs';
|
|
8
|
+
import { commandFailureDetail, run } from './exec.mjs';
|
|
9
9
|
|
|
10
10
|
// stderr is piped, not inherited: git's "fatal: ambiguous argument" for a tag
|
|
11
11
|
// that does not exist yet and gh's "no checks reported" both arrive there, and
|
|
@@ -69,7 +69,7 @@ export async function openIndexPr(options) {
|
|
|
69
69
|
step('push');
|
|
70
70
|
git(['push', '-u', 'origin', branch]);
|
|
71
71
|
} catch (error) {
|
|
72
|
-
return { ok: false, stage: 'push', reason: error
|
|
72
|
+
return { ok: false, stage: 'push', reason: `could not push ${branch} to origin: ${commandFailureDetail(error)}` };
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
try {
|
package/lib/release.mjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* registry, then touch the index — the index entry carries the publish time the
|
|
6
6
|
* registry reported, so writing it earlier would mean guessing.
|
|
7
7
|
*/
|
|
8
|
-
import { run as runCommand } from './exec.mjs';
|
|
8
|
+
import { commandFailureDetail, run as runCommand } from './exec.mjs';
|
|
9
9
|
import fs from 'node:fs';
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
|
|
@@ -26,23 +26,33 @@ function git(dir, args) {
|
|
|
26
26
|
return runCommand('git', args, { cwd: dir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/** The object this checkout's tag names, or null when it cannot be read. */
|
|
30
|
+
function localTagObject(run, tag) {
|
|
31
|
+
try {
|
|
32
|
+
return run(['rev-parse', `refs/tags/${tag}`]);
|
|
33
|
+
} catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
29
38
|
/**
|
|
30
|
-
* The
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* lines keeps git's useful `fatal:` / `remote:` lines and drops the blank lines
|
|
35
|
-
* and trailing advice.
|
|
39
|
+
* The object `origin` advertises for this tag, or null when origin has no such
|
|
40
|
+
* tag (or cannot be read). `ls-remote` asks the remote directly without
|
|
41
|
+
* fetching, which is what lets a failed push be checked against the state it
|
|
42
|
+
* may already have written.
|
|
36
43
|
*/
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.split('\n')
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
function remoteTagObject(run, tag) {
|
|
45
|
+
try {
|
|
46
|
+
const output = String(run(['ls-remote', '--tags', 'origin', `refs/tags/${tag}`]) ?? '');
|
|
47
|
+
const ref = `refs/tags/${tag}`;
|
|
48
|
+
for (const line of output.split('\n')) {
|
|
49
|
+
const [object, name] = line.trim().split('\t');
|
|
50
|
+
if (name === ref && object !== undefined && object !== '') return object;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
} catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
46
56
|
}
|
|
47
57
|
|
|
48
58
|
export function tagName(version, prefix = 'plugin-v') {
|
|
@@ -230,6 +240,29 @@ export async function release(options) {
|
|
|
230
240
|
gitRun(['push', 'origin', tag]);
|
|
231
241
|
return null;
|
|
232
242
|
} catch (error) {
|
|
243
|
+
const detail = commandFailureDetail(error);
|
|
244
|
+
// A push can exit non-zero after the remote already updated the ref (a
|
|
245
|
+
// post-receive hook, a dropped connection after receive-pack replied).
|
|
246
|
+
// The release's goal is the tag on origin, so ask origin what it has
|
|
247
|
+
// instead of treating every non-zero exit as "not pushed".
|
|
248
|
+
const localObject = localTagObject(gitRun, tag);
|
|
249
|
+
const remoteObject = remoteTagObject(gitRun, tag);
|
|
250
|
+
if (localObject !== null && remoteObject !== null && localObject === remoteObject) {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
if (localObject !== null && remoteObject !== null) {
|
|
254
|
+
// The name is taken by a different object. Re-running cannot fix this,
|
|
255
|
+
// so name both tags and leave the decision to the user: moving a
|
|
256
|
+
// published tag silently would rewrite what the earlier release said.
|
|
257
|
+
return {
|
|
258
|
+
ok: false,
|
|
259
|
+
stage: 'git',
|
|
260
|
+
failures: [{
|
|
261
|
+
check: 'git',
|
|
262
|
+
message: `could not run \`git push origin ${tag}\`: ${detail}. origin already has ${tag} at ${remoteObject}, but this checkout's tag is at ${localObject}; neither tag was moved. Delete the tag you do not want and re-run release.`,
|
|
263
|
+
}],
|
|
264
|
+
};
|
|
265
|
+
}
|
|
233
266
|
// Keep the failure in the release's own vocabulary. Letting the raw
|
|
234
267
|
// execFileSync error escape hides both the stage and the fact that the
|
|
235
268
|
// tag now exists only locally, which is exactly what the retry needs.
|
|
@@ -238,7 +271,7 @@ export async function release(options) {
|
|
|
238
271
|
stage: 'git',
|
|
239
272
|
failures: [{
|
|
240
273
|
check: 'git',
|
|
241
|
-
message: `could not run \`git push origin ${tag}\`: ${
|
|
274
|
+
message: `could not run \`git push origin ${tag}\`: ${detail} The tag is still local; fix the remote and re-run release to push it.`,
|
|
242
275
|
}],
|
|
243
276
|
};
|
|
244
277
|
}
|
|
@@ -266,7 +299,7 @@ export async function release(options) {
|
|
|
266
299
|
stage: 'git',
|
|
267
300
|
failures: [{
|
|
268
301
|
check: 'git',
|
|
269
|
-
message: `could not run \`git tag ${tag}\`: ${
|
|
302
|
+
message: `could not run \`git tag ${tag}\`: ${commandFailureDetail(error)}`,
|
|
270
303
|
}],
|
|
271
304
|
};
|
|
272
305
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-toolkit",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.24",
|
|
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": {
|