dsh-plugin-toolkit 0.20.22 → 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 +68 -0
- package/README.md +24 -4
- package/lib/doctor.mjs +65 -24
- package/lib/exec.mjs +34 -0
- package/lib/pr.mjs +2 -2
- package/lib/release.mjs +107 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
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
|
+
|
|
45
|
+
## 0.20.23
|
|
46
|
+
|
|
47
|
+
- **A failed `git push` is reported as the `git` stage, not a raw exec error.**
|
|
48
|
+
When `origin` was unreachable, `release` created the local tag and then let
|
|
49
|
+
the `execFileSync` error escape, so the user saw a command line and stack
|
|
50
|
+
instead of the stage and the tag that still needed pushing. Tag creation and
|
|
51
|
+
the tag push now catch git's failure, return `stage: 'git'`, and print
|
|
52
|
+
`release stopped at git` with the tag, git's own reason, and the fact that
|
|
53
|
+
the tag exists only locally. With `origin` pointed at a missing path the CLI
|
|
54
|
+
exits `1` and leaves `plugin-v<version>` at HEAD; after `git remote set-url
|
|
55
|
+
origin` points at the bare repository, the same working tree re-runs, resumes
|
|
56
|
+
from that tag, pushes it, and exits `0`. A process-level test covers the
|
|
57
|
+
failed push and the corrected retry.
|
|
58
|
+
|
|
59
|
+
- **A retry pushes a tag that exists only locally.** When `release` created
|
|
60
|
+
`plugin-v<version>` and then failed at `git push`, the next run saw the local
|
|
61
|
+
tag at HEAD, took the resume path, skipped both the tag and the push, and
|
|
62
|
+
could report success while the remote still had no tag. The resume path now
|
|
63
|
+
pushes the existing tag before the registry wait. Pushing a tag the remote
|
|
64
|
+
already has at the same commit is a no-op, so repeated retries leave exactly
|
|
65
|
+
one tag on origin. A test reproduces the failed-push state, retries, and
|
|
66
|
+
requires the bare origin to list the tag exactly once; a CLI test starts from
|
|
67
|
+
a local-only tag and requires exit `0` with the tag on origin.
|
|
68
|
+
|
|
1
69
|
## 0.20.22
|
|
2
70
|
|
|
3
71
|
- **A missing `audit --home` value is refused before the scan, and a later
|
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.
|
|
@@ -978,8 +978,8 @@ The install reports success and nothing shows up. In this order:
|
|
|
978
978
|
`release` runs the sequence in the order that fails cheapest first:
|
|
979
979
|
|
|
980
980
|
1. Preflight (`doctor`) — stop before tagging anything.
|
|
981
|
-
2. Refuse to run on a dirty tree. If the tag already exists and points at the current commit, reuse it and resume; if it points somewhere else, stop with the tag's commit and HEAD, and print the `git tag -d` / `git push --delete` recovery.
|
|
982
|
-
3. Create and push the tag, which starts the plugin's release workflow.
|
|
981
|
+
2. Refuse to run on a dirty tree. If the tag already exists and points at the current commit, reuse it, push it again, and resume; if it points somewhere else, stop with the tag's commit and HEAD, and print the `git tag -d` / `git push --delete` recovery.
|
|
982
|
+
3. Create and push the tag, which starts the plugin's release workflow. A retry pushes an existing local tag too, so a tag left behind by a failed `git push` still reaches origin.
|
|
983
983
|
4. Poll the registry until it actually serves that version, reporting each wait.
|
|
984
984
|
5. Write the index entry with the publish time **the registry reports**, not the local clock. It waits for `time[version]` specifically: the abbreviated registry document has no `time` field, and an entry with a null timestamp is rejected by the market checker.
|
|
985
985
|
6. With `--pr`: commit that entry on `market/<version>`, push it, and open the pull request. With `--merge` as well: wait for `gh pr checks` to settle, then squash-merge. When the committed index already carries this version with the same publish time there is nothing to commit, so the branch and PR steps are skipped instead of failing at `git commit`. An entry written by an earlier run without `--pr` is still uncommitted, so a later `--pr` run commits it and opens the PR.
|
|
@@ -996,7 +996,7 @@ checks settled after 1s (1 look(s))
|
|
|
996
996
|
merged
|
|
997
997
|
```
|
|
998
998
|
|
|
999
|
-
Without `--pr` it prints the `git add` / `gh pr create` commands instead of running them; `--dry-run` prints the whole sequence before anything happens. A re-run after a failure is safe: when the tag already points at HEAD it is reused rather than recreated, the release continues with the registry wait, and the same version with the same publish time is a no-op once the index entry is committed. A no-op release prints `<index> already carried <version>; nothing to commit`, exits `0`, leaves `git log -1` unchanged, and creates no `market/<version>` branch, even when `--pr` or `--merge` is passed. A different publish time is not a no-op: the release stops at `index`, names the indexed and registry timestamps in the error, exits `1`, and creates no `market/<version>` branch.
|
|
999
|
+
Without `--pr` it prints the `git add` / `gh pr create` commands instead of running them; `--dry-run` prints the whole sequence before anything happens. A re-run after a failure is safe: when the tag already points at HEAD it is reused rather than recreated, it is pushed again so a local-only tag left by a failed push reaches origin, the release continues with the registry wait, and the same version with the same publish time is a no-op once the index entry is committed. A no-op release prints `<index> already carried <version>; nothing to commit`, exits `0`, leaves `git log -1` unchanged, and creates no `market/<version>` branch, even when `--pr` or `--merge` is passed. A different publish time is not a no-op: the release stops at `index`, names the indexed and registry timestamps in the error, exits `1`, and creates no `market/<version>` branch.
|
|
1000
1000
|
|
|
1001
1001
|
If that tag points at another commit, the release does not move it. It exits `1`
|
|
1002
1002
|
and names the tag, the commit it points at, HEAD, and the recovery:
|
|
@@ -1010,6 +1010,26 @@ Run those two commands when the old tag really was a mistake, then release
|
|
|
1010
1010
|
again. A tag at HEAD needs no separate `--resume`: it takes the resume path
|
|
1011
1011
|
automatically.
|
|
1012
1012
|
|
|
1013
|
+
A tag that cannot be pushed is also its own stage, not a raw `git` crash. The
|
|
1014
|
+
release names the tag and git's reason, exits `1`, and leaves the local tag in
|
|
1015
|
+
place:
|
|
1016
|
+
|
|
1017
|
+
```
|
|
1018
|
+
dsh-plugin release stopped at git
|
|
1019
|
+
✗ git: could not run `git push origin plugin-v0.4.0`: fatal: '/tmp/missing.git' does not appear to be a git repository; fatal: Could not read from remote repository. The tag is still local; fix the remote and re-run release to push it.
|
|
1020
|
+
```
|
|
1021
|
+
|
|
1022
|
+
Fix the remote (for example `git remote set-url origin <url>`) and run the same
|
|
1023
|
+
command again. The local tag already points at HEAD, so the re-run resumes and
|
|
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.
|
|
1032
|
+
|
|
1013
1033
|
### When nothing publishes for you
|
|
1014
1034
|
|
|
1015
1035
|
`release` assumes a tag starts a workflow that publishes. Repositories without
|
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,6 +26,35 @@ 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
|
+
|
|
38
|
+
/**
|
|
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.
|
|
43
|
+
*/
|
|
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
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
29
58
|
export function tagName(version, prefix = 'plugin-v') {
|
|
30
59
|
return `${prefix}${version}`;
|
|
31
60
|
}
|
|
@@ -100,6 +129,16 @@ function indexHasChanges(dir, indexFile, run) {
|
|
|
100
129
|
}
|
|
101
130
|
}
|
|
102
131
|
|
|
132
|
+
/** True when the repository has a remote with this name. */
|
|
133
|
+
function hasRemote(dir, name, run) {
|
|
134
|
+
try {
|
|
135
|
+
(run ?? ((args) => git(dir, args)))(['remote', 'get-url', name]);
|
|
136
|
+
return true;
|
|
137
|
+
} catch {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
103
142
|
/** The paths git would carry into the tag, so the message can name them. */
|
|
104
143
|
export function dirtyPaths(dir, limit = 3, run) {
|
|
105
144
|
const status = (run ?? ((args) => git(dir, args)))(['status', '--porcelain']);
|
|
@@ -188,6 +227,56 @@ export async function release(options) {
|
|
|
188
227
|
}],
|
|
189
228
|
};
|
|
190
229
|
}
|
|
230
|
+
|
|
231
|
+
// Push the tag even when reusing an existing one. The local tag may be the
|
|
232
|
+
// only copy: the previous attempt can have failed at `git push` after
|
|
233
|
+
// creating it. A push of a tag that is already on the remote at the same
|
|
234
|
+
// commit is a no-op, so this is safe to repeat and is what lets a retry
|
|
235
|
+
// finish the release instead of reporting success while origin still has no
|
|
236
|
+
// tag. A checkout with no origin has nowhere to push, so it keeps the old
|
|
237
|
+
// local resume behavior.
|
|
238
|
+
const pushTag = () => {
|
|
239
|
+
try {
|
|
240
|
+
gitRun(['push', 'origin', tag]);
|
|
241
|
+
return null;
|
|
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
|
+
}
|
|
266
|
+
// Keep the failure in the release's own vocabulary. Letting the raw
|
|
267
|
+
// execFileSync error escape hides both the stage and the fact that the
|
|
268
|
+
// tag now exists only locally, which is exactly what the retry needs.
|
|
269
|
+
return {
|
|
270
|
+
ok: false,
|
|
271
|
+
stage: 'git',
|
|
272
|
+
failures: [{
|
|
273
|
+
check: 'git',
|
|
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.`,
|
|
275
|
+
}],
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
|
|
191
280
|
if (resuming === false) {
|
|
192
281
|
// A resume does not create a tag, so the clean-tree rule that protects the
|
|
193
282
|
// tag does not apply: the index write from a previous attempt is allowed to
|
|
@@ -202,8 +291,23 @@ export async function release(options) {
|
|
|
202
291
|
};
|
|
203
292
|
}
|
|
204
293
|
|
|
205
|
-
|
|
206
|
-
|
|
294
|
+
try {
|
|
295
|
+
gitRun(['tag', tag]);
|
|
296
|
+
} catch (error) {
|
|
297
|
+
return {
|
|
298
|
+
ok: false,
|
|
299
|
+
stage: 'git',
|
|
300
|
+
failures: [{
|
|
301
|
+
check: 'git',
|
|
302
|
+
message: `could not run \`git tag ${tag}\`: ${commandFailureDetail(error)}`,
|
|
303
|
+
}],
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
const failedPush = pushTag();
|
|
307
|
+
if (failedPush !== null) return failedPush;
|
|
308
|
+
} else if (hasRemote(root, 'origin', gitRun) === true) {
|
|
309
|
+
const failedPush = pushTag();
|
|
310
|
+
if (failedPush !== null) return failedPush;
|
|
207
311
|
}
|
|
208
312
|
|
|
209
313
|
// Not every plugin publishes from CI. `--publish` runs the publish here, so
|
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": {
|