dsh-plugin-toolkit 0.0.0-stage → 0.1.0
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 +10 -0
- package/LICENSE +201 -0
- package/README.md +74 -2
- package/bin/dsh-plugin.mjs +10 -0
- package/lib/cli.mjs +134 -0
- package/lib/doctor.mjs +159 -0
- package/lib/index-file.mjs +61 -0
- package/lib/registry.mjs +64 -0
- package/lib/release.mjs +137 -0
- package/package.json +41 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
First cut: `doctor`, `index`, `release`.
|
|
6
|
+
|
|
7
|
+
- `doctor` checks the manifest, the README's stated host range, the bundle patch, the client entry, and whether `files` ships everything `package.json` points at.
|
|
8
|
+
- `index` audits `market/index.json` and names every version that cannot state a host range.
|
|
9
|
+
- `release` runs preflight → tag → registry wait → index entry, prints every GitHub step, and refuses to run on a dirty tree or an existing tag.
|
|
10
|
+
- Registry checks read the registry's own document (and `time`), because `npm view` answers from a cache.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 WJDdidi-1
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,75 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-plugin-toolkit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A preflight and release tool for [DeepSeek Harness](https://github.com/deepseek-ai/dsh) plugins, plus the pieces of the publishing ritual that kept going wrong by hand.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npx dsh-plugin doctor . # can this plugin be loaded and installed?
|
|
7
|
+
npx dsh-plugin index # does every market-index version state a host range?
|
|
8
|
+
npx dsh-plugin release --dry-run # what would shipping this version do?
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- Node.js 18 or newer (`node --fetch` is used to read the registry; no dependencies)
|
|
14
|
+
- Git and `gh` on `PATH` for the steps that touch GitHub
|
|
15
|
+
- DeepSeek Harness `>=0.2.0` — the version whose market index carries `engines.dsh`, which is what makes the range check meaningful
|
|
16
|
+
|
|
17
|
+
## Why this exists
|
|
18
|
+
|
|
19
|
+
Releasing one plugin fifteen times taught me three things the ecosystem's tooling does not cover:
|
|
20
|
+
|
|
21
|
+
1. **A version is not shipped when npm accepts it.** Registry propagation took two to eight minutes every time. `npm view` answered from a stale local cache, so I repeatedly believed a release had failed when it had not — and once believed it had succeeded when the market still could not see it.
|
|
22
|
+
2. **The market index is a second release, done by hand.** Each version needs an entry carrying `publishTimestamp` from the registry and `engines.dsh` from the manifest. Forget the range and the index validator rejects the PR with `Engines mismatch` — after the tag is already public.
|
|
23
|
+
3. **Reading a manifest is not the same as checking it.** A plugin can have a valid `package.json` and still be uninstallable: `files` that omit the entry the manifest points at, a bundle patch that does not exist, a README that never states the host range it declares.
|
|
24
|
+
|
|
25
|
+
## What `doctor` checks
|
|
26
|
+
|
|
27
|
+
| Check | Why it matters |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| `version` | The tag is built from it; a malformed version produces a tag nobody can install |
|
|
30
|
+
| `engines.dsh` | The market index copies this into every version entry. Missing it fails the index PR |
|
|
31
|
+
| `readme` | A `Requirements` section that states the declared range, so an install failure is predictable |
|
|
32
|
+
| `dsh field` | `dsh.bundle.patch` must exist for the host to load the plugin |
|
|
33
|
+
| `patch file` | The path declared above must be a real file |
|
|
34
|
+
| `client entry` | If `dsh.client` is declared, the bundle has to be there |
|
|
35
|
+
| `files list` | Every path `package.json` points at (`exports`, patch, client) must be covered by `files` |
|
|
36
|
+
|
|
37
|
+
Exit code is `0` when the plugin can be installed and `1` when it cannot, so it drops into CI unchanged.
|
|
38
|
+
|
|
39
|
+
## What `release` does
|
|
40
|
+
|
|
41
|
+
`release` runs the sequence in the order that fails cheapest first:
|
|
42
|
+
|
|
43
|
+
1. Preflight (`doctor`) — stop before tagging anything.
|
|
44
|
+
2. Refuse to run on a dirty tree, or if the tag already exists.
|
|
45
|
+
3. Create and push the tag, which starts the plugin's release workflow.
|
|
46
|
+
4. Poll the registry until it actually serves that version, reporting each wait.
|
|
47
|
+
5. Write the index entry with the publish time **the registry reports**, not the local clock.
|
|
48
|
+
6. Print the exact `git add` / `gh pr create` commands for the index change.
|
|
49
|
+
|
|
50
|
+
Steps that touch your repository are printed, never guessed at. `--dry-run` prints the whole sequence with the commands it would run.
|
|
51
|
+
|
|
52
|
+
## Exit codes
|
|
53
|
+
|
|
54
|
+
| Code | Meaning |
|
|
55
|
+
| --- | --- |
|
|
56
|
+
| 0 | Done, or nothing to complain about |
|
|
57
|
+
| 1 | A check failed, or the release stopped (the failing stage is named) |
|
|
58
|
+
| 2 | Unknown command |
|
|
59
|
+
|
|
60
|
+
## Looking at it without a Harness
|
|
61
|
+
|
|
62
|
+
The fixtures under `test/fixtures/` are three tiny plugins — one good, one missing its host range, one whose README contradicts its manifest — and the tests run every check against them:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
npm test
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Roadmap
|
|
69
|
+
|
|
70
|
+
- `testkit`: load a single-file client bundle in a DOM with a fake host ctx, so panel behaviour can be asserted in CI instead of by hand.
|
|
71
|
+
- `dev`: watch a client bundle and push it to a running app, instead of restarting the app for every change.
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { run } from '../lib/cli.mjs';
|
|
3
|
+
|
|
4
|
+
run(process.argv.slice(2)).then((code) => {
|
|
5
|
+
process.exitCode = typeof code === 'number' ? code : 0;
|
|
6
|
+
}).catch((error) => {
|
|
7
|
+
console.error(`dsh-plugin: ${error.message}`);
|
|
8
|
+
if (process.env.DSH_PLUGIN_DEBUG === '1') console.error(error.stack);
|
|
9
|
+
process.exitCode = 1;
|
|
10
|
+
});
|
package/lib/cli.mjs
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `dsh-plugin <command>` — small enough to read in one sitting, which is the
|
|
4
|
+
* point: a release tool that hides what it does is worse than a checklist.
|
|
5
|
+
*/
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
|
|
8
|
+
import { doctor } from './doctor.mjs';
|
|
9
|
+
import { plan, release } from './release.mjs';
|
|
10
|
+
import { auditVersions, readIndex } from './index-file.mjs';
|
|
11
|
+
|
|
12
|
+
export const HELP = `dsh-plugin — preflight and release DeepSeek Harness plugins
|
|
13
|
+
|
|
14
|
+
dsh-plugin doctor [dir] check the manifest, README and bundle
|
|
15
|
+
dsh-plugin release [dir] [flags] tag, wait for npm, update the market index
|
|
16
|
+
dsh-plugin index [dir] audit every version in market/index.json
|
|
17
|
+
|
|
18
|
+
Flags
|
|
19
|
+
--dry-run show the steps without touching anything
|
|
20
|
+
--index <path> index file, default market/index.json
|
|
21
|
+
--tag-prefix <prefix> default plugin-v
|
|
22
|
+
--budget <seconds> how long to wait for npm, default 480
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
function flags(argv) {
|
|
26
|
+
const parsed = { positional: [] };
|
|
27
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
28
|
+
const token = argv[index];
|
|
29
|
+
if (token === '--dry-run') parsed.dryRun = true;
|
|
30
|
+
else if (token === '--index') parsed.index = argv[++index];
|
|
31
|
+
else if (token === '--tag-prefix') parsed.tagPrefix = argv[++index];
|
|
32
|
+
else if (token === '--budget') parsed.budget = Number(argv[++index]);
|
|
33
|
+
else if (token.startsWith('--') === true) throw new Error(`unknown flag ${token}`);
|
|
34
|
+
else parsed.positional.push(token);
|
|
35
|
+
}
|
|
36
|
+
return parsed;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function printFailures(failures, io = console) {
|
|
40
|
+
for (const failure of failures) {
|
|
41
|
+
io.error(` ✗ ${failure.check}: ${failure.message}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function run(argv, io = console) {
|
|
46
|
+
const [command, ...rest] = argv;
|
|
47
|
+
const options = flags(rest);
|
|
48
|
+
const dir = path.resolve(options.positional[0] ?? '.');
|
|
49
|
+
|
|
50
|
+
if (command === undefined || command === 'help' || command === '--help') {
|
|
51
|
+
io.log(HELP);
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (command === 'doctor') {
|
|
56
|
+
const report = doctor(dir);
|
|
57
|
+
if (report.failures.length === 0) {
|
|
58
|
+
io.log(`ok ${report.manifest.name}@${report.notes.version} (host ${report.notes.hostRange})`);
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
io.error(`dsh-plugin doctor: ${report.failures.length} problem(s) in ${dir}`);
|
|
62
|
+
printFailures(report.failures, io);
|
|
63
|
+
return 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (command === 'index') {
|
|
67
|
+
const target = options.index ?? (dir.endsWith('.json') === true ? dir : path.join(dir, 'market/index.json'));
|
|
68
|
+
const index = readIndex(target);
|
|
69
|
+
let problems = 0;
|
|
70
|
+
for (const plugin of index.plugins ?? []) {
|
|
71
|
+
const audit = auditVersions(index, plugin.name);
|
|
72
|
+
if (audit.length === 0) {
|
|
73
|
+
io.log(`ok ${plugin.name}: ${plugin.versions.length} version(s) all carry engines.dsh`);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
problems += audit.length;
|
|
77
|
+
io.error(`dsh-plugin index: ${plugin.name}`);
|
|
78
|
+
for (const finding of audit) {
|
|
79
|
+
io.error(` ✗ ${finding.version ?? ''} ${finding.problem}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return problems === 0 ? 0 : 1;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (command === 'release') {
|
|
86
|
+
const report = doctor(dir);
|
|
87
|
+
const name = report.manifest?.name ?? '(no name)';
|
|
88
|
+
const version = report.notes?.version ?? '(no version)';
|
|
89
|
+
|
|
90
|
+
if (options.dryRun === true) {
|
|
91
|
+
io.log(`dry run: ${name}@${version}`);
|
|
92
|
+
const planned = plan({ dir, version, name, tagPrefix: options.tagPrefix, indexFile: options.index });
|
|
93
|
+
for (const step of planned.steps) {
|
|
94
|
+
io.log(` ${step.runs === false ? '·' : '→'} ${step.title}`);
|
|
95
|
+
io.log(` ${step.command}`);
|
|
96
|
+
}
|
|
97
|
+
if (report.failures.length > 0) {
|
|
98
|
+
io.error(' the real run would stop at preflight:');
|
|
99
|
+
printFailures(report.failures, io);
|
|
100
|
+
return 1;
|
|
101
|
+
}
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const result = await release({
|
|
106
|
+
dir,
|
|
107
|
+
indexFile: options.index,
|
|
108
|
+
tagPrefix: options.tagPrefix,
|
|
109
|
+
budgetMs: options.budget === undefined ? undefined : options.budget * 1000,
|
|
110
|
+
onWait: ({ attempts, waitedMs }) => {
|
|
111
|
+
io.log(` … ${name}@${version} not on the registry yet (${attempts} checks, ${Math.round(waitedMs / 1000)}s)`);
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
if (result.ok === false) {
|
|
116
|
+
io.error(`dsh-plugin release stopped at ${result.stage}`);
|
|
117
|
+
printFailures(result.failures, io);
|
|
118
|
+
return 1;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
io.log(`tagged ${result.tag}, npm served ${name}@${version} after ${Math.round(result.waitedMs / 1000)}s`);
|
|
122
|
+
if (result.indexUpdate !== null) {
|
|
123
|
+
io.log(`updated ${result.indexUpdate.file} — commit it and open the PR:`);
|
|
124
|
+
io.log(` git add ${result.indexUpdate.file} && git commit -m "market: ${version}" && gh pr create --fill`);
|
|
125
|
+
} else {
|
|
126
|
+
io.log('no market/index.json here, so only the tag and the publish happened');
|
|
127
|
+
}
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
io.error(`unknown command "${command}"\n`);
|
|
132
|
+
io.error(HELP);
|
|
133
|
+
return 2;
|
|
134
|
+
}
|
package/lib/doctor.mjs
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The checks a plugin has to pass before a release is worth starting.
|
|
3
|
+
*
|
|
4
|
+
* Every check answers a question that has actually gone wrong somewhere:
|
|
5
|
+
* a tag that did not match package.json, a market entry missing `engines`, a
|
|
6
|
+
* README that promised a host version the manifest did not require. Each one
|
|
7
|
+
* returns either null (fine) or a line a human can act on.
|
|
8
|
+
*/
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
|
|
12
|
+
const SEMVER = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
13
|
+
const RANGE = /^\s*[><=^~*]|\s*\|\||\s*-\s/;
|
|
14
|
+
|
|
15
|
+
export function readManifest(dir) {
|
|
16
|
+
const manifestPath = path.join(dir, 'package.json');
|
|
17
|
+
if (fs.existsSync(manifestPath) === false) {
|
|
18
|
+
throw new Error(`no package.json in ${dir}`);
|
|
19
|
+
}
|
|
20
|
+
return { manifest: JSON.parse(fs.readFileSync(manifestPath, 'utf8')), manifestPath };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function version(manifest) {
|
|
24
|
+
return typeof manifest.version === 'string' ? manifest.version : null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The host range a version declares is the one the market index must repeat. */
|
|
28
|
+
export function hostRange(manifest) {
|
|
29
|
+
const engines = manifest.engines;
|
|
30
|
+
if (engines === undefined || engines === null) return null;
|
|
31
|
+
const dsh = engines.dsh;
|
|
32
|
+
return typeof dsh === 'string' && dsh.trim() !== '' ? dsh.trim() : null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function checkVersion(manifest) {
|
|
36
|
+
const value = version(manifest);
|
|
37
|
+
if (value === null) return 'package.json has no version';
|
|
38
|
+
if (SEMVER.test(value) === false) return `version "${value}" is not semver`;
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function checkDshField(manifest) {
|
|
43
|
+
if (manifest.dsh === undefined || manifest.dsh === null) {
|
|
44
|
+
return 'package.json has no "dsh" field, so the host will not load it as a plugin';
|
|
45
|
+
}
|
|
46
|
+
const bundle = manifest.dsh.bundle;
|
|
47
|
+
if (bundle === undefined || bundle === null) {
|
|
48
|
+
return 'dsh.bundle is missing; the host needs the patch file it points at';
|
|
49
|
+
}
|
|
50
|
+
if (typeof bundle.patch === 'string' && bundle.patch !== '') {
|
|
51
|
+
return { patch: bundle.patch };
|
|
52
|
+
}
|
|
53
|
+
return 'dsh.bundle.patch is missing';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function checkHostRange(manifest) {
|
|
57
|
+
const range = hostRange(manifest);
|
|
58
|
+
if (range === null) return 'engines.dsh is missing, so the market index cannot state the host requirement';
|
|
59
|
+
if (RANGE.test(range) === false) return `engines.dsh "${range}" is not a semver range`;
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function checkReadme(dir) {
|
|
64
|
+
const readmePath = path.join(dir, 'README.md');
|
|
65
|
+
if (fs.existsSync(readmePath) === false) return 'README.md is missing';
|
|
66
|
+
const text = fs.readFileSync(readmePath, 'utf8');
|
|
67
|
+
if (/^#{1,3}\s*Requirements/im.test(text) === false) {
|
|
68
|
+
return 'README.md has no Requirements section, so users cannot tell which host it needs';
|
|
69
|
+
}
|
|
70
|
+
const range = hostRange(JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8')));
|
|
71
|
+
// ">= 0.2.0" and ">=0.2.0" are the same range; authors write both.
|
|
72
|
+
const squeeze = (value) => value.replace(/\s+/g, '');
|
|
73
|
+
if (range !== null && squeeze(text).includes(squeeze(range)) === false) {
|
|
74
|
+
return `README.md does not mention the host range "${range}" it declares`;
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function checkPatchFile(dir, manifest) {
|
|
80
|
+
const bundle = manifest.dsh?.bundle;
|
|
81
|
+
if (bundle === undefined || typeof bundle.patch !== 'string') return null;
|
|
82
|
+
const patchPath = path.join(dir, bundle.patch);
|
|
83
|
+
if (fs.existsSync(patchPath) === true) return null;
|
|
84
|
+
return `dsh.bundle.patch points at ${bundle.patch}, which does not exist`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function checkClientEntry(dir, manifest) {
|
|
88
|
+
const client = manifest.dsh?.client;
|
|
89
|
+
if (client === undefined || client === null) return null;
|
|
90
|
+
const entries = ['client.js', 'lib/client.js', 'dist/client.js'];
|
|
91
|
+
const found = entries.some((entry) => fs.existsSync(path.join(dir, entry)));
|
|
92
|
+
return found ? null : `dsh.client is declared but none of ${entries.join(', ')} exists`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Every path the manifest points at: exports, the bundle patch, the client entry. */
|
|
96
|
+
export function declaredPaths(manifest) {
|
|
97
|
+
const paths = new Set();
|
|
98
|
+
const add = (value) => {
|
|
99
|
+
if (typeof value !== 'string') return;
|
|
100
|
+
if (value.startsWith('./')) paths.add(value.slice(2));
|
|
101
|
+
else if (value.startsWith('.')) paths.add(value.slice(1));
|
|
102
|
+
};
|
|
103
|
+
const walk = (value) => {
|
|
104
|
+
if (typeof value === 'string') add(value);
|
|
105
|
+
else if (value !== null && typeof value === 'object') Object.values(value).forEach(walk);
|
|
106
|
+
};
|
|
107
|
+
walk(manifest.exports);
|
|
108
|
+
walk(manifest.dsh?.bundle?.patch);
|
|
109
|
+
walk(manifest.dsh?.client?.entry);
|
|
110
|
+
walk(manifest.main);
|
|
111
|
+
walk(manifest.types);
|
|
112
|
+
return [...paths];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** A `files` entry covers a path when it is equal, a parent folder, or a glob prefix. */
|
|
116
|
+
export function isShipped(target, files) {
|
|
117
|
+
return files.some((entry) => {
|
|
118
|
+
const clean = entry.replace(/^\//, '');
|
|
119
|
+
if (clean.includes('*') === true) {
|
|
120
|
+
const [head] = clean.split('*');
|
|
121
|
+
return head === '' || target.startsWith(head);
|
|
122
|
+
}
|
|
123
|
+
if (clean.endsWith('/') === true) return target.startsWith(clean);
|
|
124
|
+
return target === clean;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function checkFilesList(manifest) {
|
|
129
|
+
const files = manifest.files;
|
|
130
|
+
if (Array.isArray(files) === false) {
|
|
131
|
+
return 'package.json has no "files" list, so the tarball ships whatever happens to be in the folder';
|
|
132
|
+
}
|
|
133
|
+
const declared = declaredPaths(manifest);
|
|
134
|
+
const missing = declared.filter((entry) => isShipped(entry, files) === false);
|
|
135
|
+
if (missing.length > 0) {
|
|
136
|
+
return `files does not ship ${missing.join(', ')}, which package.json points at, so the installed plugin would be missing its own code`;
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Runs every check and returns `{ failures, notes }`. */
|
|
142
|
+
export function doctor(dir) {
|
|
143
|
+
const { manifest } = readManifest(dir);
|
|
144
|
+
const checks = [
|
|
145
|
+
['version', checkVersion(manifest)],
|
|
146
|
+
['engines.dsh', checkHostRange(manifest)],
|
|
147
|
+
['readme', checkReadme(dir)],
|
|
148
|
+
['dsh field', checkDshField(manifest)],
|
|
149
|
+
['patch file', checkPatchFile(dir, manifest)],
|
|
150
|
+
['client entry', checkClientEntry(dir, manifest)],
|
|
151
|
+
['files list', checkFilesList(manifest)],
|
|
152
|
+
];
|
|
153
|
+
const failures = checks.filter(([, result]) => result !== null && typeof result === 'string');
|
|
154
|
+
return {
|
|
155
|
+
manifest,
|
|
156
|
+
failures: failures.map(([name, message]) => ({ check: name, message })),
|
|
157
|
+
notes: { hostRange: hostRange(manifest), version: version(manifest) },
|
|
158
|
+
};
|
|
159
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The market index is a list of versions with a host range per version.
|
|
3
|
+
* Adding an entry is small; getting it right is what broke a release before —
|
|
4
|
+
* a version object without `engines` makes the entry uninstallable, and the
|
|
5
|
+
* validator only tells you after you have already opened the PR.
|
|
6
|
+
*/
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
|
|
9
|
+
export function readIndex(file) {
|
|
10
|
+
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function findPlugin(index, name) {
|
|
14
|
+
const plugins = Array.isArray(index.plugins) ? index.plugins : [];
|
|
15
|
+
return plugins.find((entry) => entry.name === name) ?? null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The version objects the validator understands, newest first. */
|
|
19
|
+
export function buildEntry({ version, publishTimestamp, hostRange }) {
|
|
20
|
+
const entry = {
|
|
21
|
+
version,
|
|
22
|
+
publishTimestamp,
|
|
23
|
+
source: { type: 'npm' },
|
|
24
|
+
};
|
|
25
|
+
if (hostRange !== null && hostRange !== undefined) {
|
|
26
|
+
entry.engines = { dsh: hostRange };
|
|
27
|
+
}
|
|
28
|
+
return entry;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function addVersion(index, name, entry) {
|
|
32
|
+
const plugin = findPlugin(index, name);
|
|
33
|
+
if (plugin === null) {
|
|
34
|
+
throw new Error(`the index has no plugin called "${name}"`);
|
|
35
|
+
}
|
|
36
|
+
const versions = Array.isArray(plugin.versions) ? plugin.versions : [];
|
|
37
|
+
if (versions.some((existing) => existing.version === entry.version)) {
|
|
38
|
+
throw new Error(`${name}@${entry.version} is already in the index`);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
...index,
|
|
42
|
+
plugins: index.plugins.map((candidate) => {
|
|
43
|
+
if (candidate.name !== name) return candidate;
|
|
44
|
+
return { ...candidate, versions: [entry, ...versions] };
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Every version must carry the host range, not just the newest one. */
|
|
50
|
+
export function auditVersions(index, name) {
|
|
51
|
+
const plugin = findPlugin(index, name);
|
|
52
|
+
if (plugin === null) return [{ problem: `no plugin called "${name}"` }];
|
|
53
|
+
const versions = Array.isArray(plugin.versions) ? plugin.versions : [];
|
|
54
|
+
return versions
|
|
55
|
+
.filter((entry) => typeof entry.engines?.dsh !== 'string' || entry.engines.dsh.trim() === '')
|
|
56
|
+
.map((entry) => ({ version: entry.version, problem: 'no engines.dsh' }));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function writeIndex(file, index) {
|
|
60
|
+
fs.writeFileSync(file, `${JSON.stringify(index, null, 2)}\n`);
|
|
61
|
+
}
|
package/lib/registry.mjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Talking to npm without lying to yourself.
|
|
3
|
+
*
|
|
4
|
+
* `npm view` hits a local cache and can answer with a version that the registry
|
|
5
|
+
* is still not serving; the only honest question is "does the registry's own
|
|
6
|
+
* document list this version". That is what `versionsOf` asks, and the release
|
|
7
|
+
* command waits on it instead of on a sleep.
|
|
8
|
+
*/
|
|
9
|
+
export const REGISTRY = 'https://registry.npmjs.org';
|
|
10
|
+
|
|
11
|
+
export async function packument(name, options = {}) {
|
|
12
|
+
const base = options.registry ?? REGISTRY;
|
|
13
|
+
const request = options.fetch ?? fetch;
|
|
14
|
+
const response = await request(`${base}/${name.replace('/', '%2F')}`, {
|
|
15
|
+
headers: { accept: 'application/vnd.npm.install-v1+json' },
|
|
16
|
+
});
|
|
17
|
+
if (response.status === 404) return null;
|
|
18
|
+
if (response.ok === false) {
|
|
19
|
+
throw new Error(`registry answered ${response.status} for ${name}`);
|
|
20
|
+
}
|
|
21
|
+
return response.json();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The publish time the index should carry, straight from the registry. */
|
|
25
|
+
export function publishedAt(document, version) {
|
|
26
|
+
const time = document?.time?.[version];
|
|
27
|
+
if (typeof time !== 'string') return null;
|
|
28
|
+
const seconds = Math.floor(Date.parse(time) / 1000);
|
|
29
|
+
return Number.isFinite(seconds) ? seconds : null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function hasVersion(document, version) {
|
|
33
|
+
// `versions` is what an install sees; `time` is what a publish writes first.
|
|
34
|
+
// Either one means the registry is serving this version.
|
|
35
|
+
return Boolean(document?.versions?.[version]) || typeof document?.time?.[version] === 'string';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Polls until the version is visible or the budget runs out.
|
|
40
|
+
* `onWait` is called after each miss so the CLI can report progress.
|
|
41
|
+
*/
|
|
42
|
+
export async function waitForVersion(name, version, options = {}) {
|
|
43
|
+
const budgetMs = options.budgetMs ?? 8 * 60 * 1000;
|
|
44
|
+
const intervalMs = options.intervalMs ?? 10 * 1000;
|
|
45
|
+
const now = options.now ?? Date.now;
|
|
46
|
+
const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
47
|
+
const started = now();
|
|
48
|
+
let attempts = 0;
|
|
49
|
+
|
|
50
|
+
for (;;) {
|
|
51
|
+
attempts += 1;
|
|
52
|
+
const document = await packument(name, options);
|
|
53
|
+
if (hasVersion(document, version) === true) {
|
|
54
|
+
return { document, attempts, waitedMs: now() - started };
|
|
55
|
+
}
|
|
56
|
+
if (now() - started >= budgetMs) {
|
|
57
|
+
return { document, attempts, waitedMs: now() - started, timedOut: true };
|
|
58
|
+
}
|
|
59
|
+
if (typeof options.onWait === 'function') {
|
|
60
|
+
options.onWait({ attempts, waitedMs: now() - started, version });
|
|
61
|
+
}
|
|
62
|
+
await sleep(intervalMs);
|
|
63
|
+
}
|
|
64
|
+
}
|
package/lib/release.mjs
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The release sequence, as a function instead of a checklist in my head.
|
|
3
|
+
*
|
|
4
|
+
* Order matters: verify the manifest first (cheap), then tag, then wait for the
|
|
5
|
+
* registry, then touch the index — the index entry carries the publish time the
|
|
6
|
+
* registry reported, so writing it earlier would mean guessing.
|
|
7
|
+
*/
|
|
8
|
+
import { execFileSync } from 'node:child_process';
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
|
|
12
|
+
import { doctor } from './doctor.mjs';
|
|
13
|
+
import { addVersion, buildEntry, readIndex, writeIndex } from './index-file.mjs';
|
|
14
|
+
import { publishedAt, waitForVersion } from './registry.mjs';
|
|
15
|
+
|
|
16
|
+
function git(dir, args) {
|
|
17
|
+
return execFileSync('git', args, { cwd: dir, encoding: 'utf8' }).trim();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function tagName(version, prefix = 'plugin-v') {
|
|
21
|
+
return `${prefix}${version}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function tagExists(dir, tag) {
|
|
25
|
+
try {
|
|
26
|
+
git(dir, ['rev-parse', `refs/tags/${tag}`]);
|
|
27
|
+
return true;
|
|
28
|
+
} catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function workingTreeIsClean(dir) {
|
|
34
|
+
return git(dir, ['status', '--porcelain']) === '';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Steps a human must do, and steps the tool can do. Returning this list before
|
|
39
|
+
* anything runs is what makes `--dry-run` useful: it shows the whole sequence
|
|
40
|
+
* and the exact commands.
|
|
41
|
+
*/
|
|
42
|
+
export function plan({ dir = process.cwd(), version, name, tagPrefix = 'plugin-v', indexFile = 'market/index.json' }) {
|
|
43
|
+
const report = doctor(dir);
|
|
44
|
+
const resolvedName = name ?? report.manifest.name ?? 'this-plugin';
|
|
45
|
+
const resolvedVersion = version ?? report.manifest.version ?? '0.0.0';
|
|
46
|
+
const tag = tagName(resolvedVersion, tagPrefix);
|
|
47
|
+
const steps = [
|
|
48
|
+
{ title: 'Read the manifest and check it can be loaded', command: 'dsh-plugin doctor', runs: true },
|
|
49
|
+
{ title: `Create the tag ${tag}`, command: `git tag ${tag}`, runs: true },
|
|
50
|
+
{ title: 'Push the tag, which starts the release workflow', command: `git push origin ${tag}`, runs: true },
|
|
51
|
+
{ title: `Wait until the registry serves ${resolvedName}@${resolvedVersion}`, command: `GET /${resolvedName}`, runs: true },
|
|
52
|
+
{ title: 'Write the version into the market index, with the publish time the registry reported', command: `patch ${indexFile}`, runs: true },
|
|
53
|
+
{ title: 'Open the index pull request', command: 'gh pr create', runs: false },
|
|
54
|
+
{ title: 'Re-read the live index and confirm the version is listed', command: 'GET market/index.json', runs: false },
|
|
55
|
+
];
|
|
56
|
+
return { tag, name: resolvedName, version: resolvedVersion, indexFile, steps };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function release(options) {
|
|
60
|
+
const {
|
|
61
|
+
dir = process.cwd(),
|
|
62
|
+
registry,
|
|
63
|
+
tagPrefix = 'plugin-v',
|
|
64
|
+
indexFile = 'market/index.json',
|
|
65
|
+
budgetMs,
|
|
66
|
+
intervalMs,
|
|
67
|
+
sleep,
|
|
68
|
+
now,
|
|
69
|
+
onChange,
|
|
70
|
+
} = options;
|
|
71
|
+
|
|
72
|
+
const report = doctor(dir);
|
|
73
|
+
if (report.failures.length > 0) {
|
|
74
|
+
return { ok: false, stage: 'preflight', failures: report.failures };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const name = report.manifest.name;
|
|
78
|
+
const version = report.manifest.version;
|
|
79
|
+
const tag = tagName(version, tagPrefix);
|
|
80
|
+
|
|
81
|
+
if (tagExists(dir, tag) === true) {
|
|
82
|
+
return { ok: false, stage: 'tag', failures: [{ check: 'tag', message: `${tag} already exists` }] };
|
|
83
|
+
}
|
|
84
|
+
if (workingTreeIsClean(dir) === false) {
|
|
85
|
+
return {
|
|
86
|
+
ok: false,
|
|
87
|
+
stage: 'git',
|
|
88
|
+
failures: [{ check: 'git', message: 'the working tree has uncommitted changes' }],
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
git(dir, ['tag', tag]);
|
|
93
|
+
git(dir, ['push', 'origin', tag]);
|
|
94
|
+
|
|
95
|
+
const waited = await waitForVersion(name, version, {
|
|
96
|
+
registry,
|
|
97
|
+
budgetMs,
|
|
98
|
+
intervalMs,
|
|
99
|
+
sleep,
|
|
100
|
+
now,
|
|
101
|
+
onWait: options.onWait,
|
|
102
|
+
});
|
|
103
|
+
if (waited.timedOut === true) {
|
|
104
|
+
return {
|
|
105
|
+
ok: false,
|
|
106
|
+
stage: 'registry',
|
|
107
|
+
failures: [
|
|
108
|
+
{
|
|
109
|
+
check: 'registry',
|
|
110
|
+
message: `${name}@${version} is not on the registry after ${Math.round(waited.waitedMs / 1000)}s (tag ${tag} is pushed; re-run when npm catches up)`,
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const timestamp = publishedAt(waited.document, version);
|
|
117
|
+
const entry = buildEntry({ version, publishTimestamp: timestamp, hostRange: report.notes.hostRange });
|
|
118
|
+
const indexPath = path.join(dir, indexFile);
|
|
119
|
+
let indexUpdate = null;
|
|
120
|
+
if (fs.existsSync(indexPath) === true) {
|
|
121
|
+
const before = readIndex(indexPath);
|
|
122
|
+
const after = addVersion(before, name, entry);
|
|
123
|
+
writeIndex(indexPath, after);
|
|
124
|
+
indexUpdate = { file: indexFile, version, entry };
|
|
125
|
+
if (typeof onChange === 'function') onChange(indexUpdate);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
ok: true,
|
|
130
|
+
stage: 'index',
|
|
131
|
+
tag,
|
|
132
|
+
version,
|
|
133
|
+
attempts: waited.attempts,
|
|
134
|
+
waitedMs: waited.waitedMs,
|
|
135
|
+
indexUpdate,
|
|
136
|
+
};
|
|
137
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-toolkit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Preflight, release and test DeepSeek Harness plugins: checks what the host needs, waits for npm to actually serve the version, and keeps the market index honest.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"dsh-plugin": "bin/dsh-plugin.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/",
|
|
11
|
+
"lib/",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"CHANGELOG.md"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"dsh-plugin",
|
|
21
|
+
"deepseek-harness",
|
|
22
|
+
"dsh",
|
|
23
|
+
"plugin-tooling",
|
|
24
|
+
"release",
|
|
25
|
+
"preflight"
|
|
26
|
+
],
|
|
27
|
+
"license": "Apache-2.0",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/WJDdidi-1/dsh-plugin-toolkit.git"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/WJDdidi-1/dsh-plugin-toolkit#readme",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/WJDdidi-1/dsh-plugin-toolkit/issues"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"test": "node --test",
|
|
41
|
+
"lint": "node --check bin/dsh-plugin.mjs"
|
|
42
|
+
}
|
|
43
|
+
}
|