dsh-plugin-toolkit 0.20.22 → 0.20.23

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,27 @@
1
+ ## 0.20.23
2
+
3
+ - **A failed `git push` is reported as the `git` stage, not a raw exec error.**
4
+ When `origin` was unreachable, `release` created the local tag and then let
5
+ the `execFileSync` error escape, so the user saw a command line and stack
6
+ instead of the stage and the tag that still needed pushing. Tag creation and
7
+ the tag push now catch git's failure, return `stage: 'git'`, and print
8
+ `release stopped at git` with the tag, git's own reason, and the fact that
9
+ the tag exists only locally. With `origin` pointed at a missing path the CLI
10
+ exits `1` and leaves `plugin-v<version>` at HEAD; after `git remote set-url
11
+ origin` points at the bare repository, the same working tree re-runs, resumes
12
+ from that tag, pushes it, and exits `0`. A process-level test covers the
13
+ failed push and the corrected retry.
14
+
15
+ - **A retry pushes a tag that exists only locally.** When `release` created
16
+ `plugin-v<version>` and then failed at `git push`, the next run saw the local
17
+ tag at HEAD, took the resume path, skipped both the tag and the push, and
18
+ could report success while the remote still had no tag. The resume path now
19
+ pushes the existing tag before the registry wait. Pushing a tag the remote
20
+ already has at the same commit is a no-op, so repeated retries leave exactly
21
+ one tag on origin. A test reproduces the failed-push state, retries, and
22
+ requires the bare origin to list the tag exactly once; a CLI test starts from
23
+ a local-only tag and requires exit `0` with the tag on origin.
24
+
1
25
  ## 0.20.22
2
26
 
3
27
  - **A missing `audit --home` value is refused before the scan, and a later
package/README.md CHANGED
@@ -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,19 @@ 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.
1025
+
1013
1026
  ### When nothing publishes for you
1014
1027
 
1015
1028
  `release` assumes a tag starts a workflow that publishes. Repositories without
package/lib/release.mjs CHANGED
@@ -26,6 +26,25 @@ function git(dir, args) {
26
26
  return runCommand('git', args, { cwd: dir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
27
27
  }
28
28
 
29
+ /**
30
+ * The reason a git command failed, without the thrown command line and stack.
31
+ *
32
+ * A failed push is a step in the release, not a crash: the caller has to name
33
+ * the tag and the remote's answer so the user can fix `origin` and re-run. Six
34
+ * lines keeps git's useful `fatal:` / `remote:` lines and drops the blank lines
35
+ * and trailing advice.
36
+ */
37
+ function gitFailureDetail(error) {
38
+ const text = String(error?.stderr ?? error?.message ?? error ?? '').trim();
39
+ if (text === '') return 'git exited with an error';
40
+ return text
41
+ .split('\n')
42
+ .map((line) => line.trim())
43
+ .filter((line) => line !== '')
44
+ .slice(0, 6)
45
+ .join('; ');
46
+ }
47
+
29
48
  export function tagName(version, prefix = 'plugin-v') {
30
49
  return `${prefix}${version}`;
31
50
  }
@@ -100,6 +119,16 @@ function indexHasChanges(dir, indexFile, run) {
100
119
  }
101
120
  }
102
121
 
122
+ /** True when the repository has a remote with this name. */
123
+ function hasRemote(dir, name, run) {
124
+ try {
125
+ (run ?? ((args) => git(dir, args)))(['remote', 'get-url', name]);
126
+ return true;
127
+ } catch {
128
+ return false;
129
+ }
130
+ }
131
+
103
132
  /** The paths git would carry into the tag, so the message can name them. */
104
133
  export function dirtyPaths(dir, limit = 3, run) {
105
134
  const status = (run ?? ((args) => git(dir, args)))(['status', '--porcelain']);
@@ -188,6 +217,33 @@ export async function release(options) {
188
217
  }],
189
218
  };
190
219
  }
220
+
221
+ // Push the tag even when reusing an existing one. The local tag may be the
222
+ // only copy: the previous attempt can have failed at `git push` after
223
+ // creating it. A push of a tag that is already on the remote at the same
224
+ // commit is a no-op, so this is safe to repeat and is what lets a retry
225
+ // finish the release instead of reporting success while origin still has no
226
+ // tag. A checkout with no origin has nowhere to push, so it keeps the old
227
+ // local resume behavior.
228
+ const pushTag = () => {
229
+ try {
230
+ gitRun(['push', 'origin', tag]);
231
+ return null;
232
+ } catch (error) {
233
+ // Keep the failure in the release's own vocabulary. Letting the raw
234
+ // execFileSync error escape hides both the stage and the fact that the
235
+ // tag now exists only locally, which is exactly what the retry needs.
236
+ return {
237
+ ok: false,
238
+ stage: 'git',
239
+ failures: [{
240
+ check: 'git',
241
+ message: `could not run \`git push origin ${tag}\`: ${gitFailureDetail(error)}. The tag is still local; fix the remote and re-run release to push it.`,
242
+ }],
243
+ };
244
+ }
245
+ };
246
+
191
247
  if (resuming === false) {
192
248
  // A resume does not create a tag, so the clean-tree rule that protects the
193
249
  // tag does not apply: the index write from a previous attempt is allowed to
@@ -202,8 +258,23 @@ export async function release(options) {
202
258
  };
203
259
  }
204
260
 
205
- gitRun(['tag', tag]);
206
- gitRun(['push', 'origin', tag]);
261
+ try {
262
+ gitRun(['tag', tag]);
263
+ } catch (error) {
264
+ return {
265
+ ok: false,
266
+ stage: 'git',
267
+ failures: [{
268
+ check: 'git',
269
+ message: `could not run \`git tag ${tag}\`: ${gitFailureDetail(error)}`,
270
+ }],
271
+ };
272
+ }
273
+ const failedPush = pushTag();
274
+ if (failedPush !== null) return failedPush;
275
+ } else if (hasRemote(root, 'origin', gitRun) === true) {
276
+ const failedPush = pushTag();
277
+ if (failedPush !== null) return failedPush;
207
278
  }
208
279
 
209
280
  // 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.22",
3
+ "version": "0.20.23",
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": {