dsh-plugin-toolkit 0.20.31 → 0.20.32

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,17 @@
1
+ ## 0.20.32
2
+
3
+ - **Every value-taking flag rejects a missing value instead of falling back to
4
+ a default or swallowing the next option.** `--range`, `--log`, `--tag-prefix`,
5
+ `--base`, `--market`, `--timeout`, `--debounce`, `--slot`, `--surface`,
6
+ `--dest`, `--entry`, `--build`, `--title` and `--name` share the guard
7
+ `--index`, `--host` and `--home` already had. Before this, `fix --engines
8
+ --range --write` stored `--write` as the range and failed later with a semver
9
+ error, while `release --dry-run --tag-prefix` silently planned the default
10
+ `plugin-v` prefix. Each now exits `2`, names the flag, and stops before
11
+ reading a file or planning a release. A valid value still reaches the
12
+ command, and `test/value-flag-contract.test.mjs` pins the whole family at the
13
+ process boundary.
14
+
1
15
  ## 0.20.31
2
16
 
3
17
  - **`index --index` with no path is a usage error, not a silent default.** A
package/README.md CHANGED
@@ -1077,6 +1077,14 @@ merged
1077
1077
  | 1 | A check failed, an installed plugin was not loaded by the running app, or the release stopped (the failing stage is named) |
1078
1078
  | 2 | Unknown command, invalid usage, or a remote request that could not be completed |
1079
1079
 
1080
+ A flag that takes a value must be given one. When `--range`, `--log`,
1081
+ `--tag-prefix`, `--base`, `--market`, `--timeout`, `--debounce`, `--slot`,
1082
+ `--surface`, `--dest`, `--entry`, `--build`, `--title`, `--name`, `--index`,
1083
+ `--host`, `--home`, `--budget`, `--patch`, `--from`, `--jobs` or `--patch-dir`
1084
+ is the last token, or is followed by another flag, the command exits `2` and
1085
+ names the flag instead of falling back to a default or consuming the next
1086
+ option as the value.
1087
+
1080
1088
  `fix <owner>/<repo> --remote` exits `0` both when it prints a diff for a missing
1081
1089
  `engines.dsh` and when the manifest already declares a range that clears the
1082
1090
  check; the second case prints `ok ... nothing to apply` and writes no diff.
package/lib/cli.mjs CHANGED
@@ -116,22 +116,58 @@ Flags
116
116
  --force with init: write into a directory that is not empty; with fix --remote --patch or audit --patch-dir: overwrite an existing patch file
117
117
  `;
118
118
 
119
+ const MISSING_VALUE_MESSAGES = {
120
+ '--range': '--range needs a semver range, for example --range ">=0.3.0 <1.0.0"',
121
+ '--log': '--log needs a log file path, for example --log ~/.dsh/logs/install.log',
122
+ '--tag-prefix': '--tag-prefix needs a prefix, for example --tag-prefix plugin-v',
123
+ '--base': '--base needs a branch name, for example --base main',
124
+ '--market': '--market needs a checkout path, for example --market ../market-repo',
125
+ '--timeout': '--timeout needs a number of milliseconds',
126
+ '--debounce': '--debounce needs a number of milliseconds',
127
+ '--slot': '--slot needs a slot name, for example --slot sidebar.right.pane.tab',
128
+ '--surface': '--surface needs a surface name, for example --surface sidebar',
129
+ '--dest': '--dest needs a directory path',
130
+ '--entry': '--entry needs a file path',
131
+ '--build': '--build needs a command, for example --build "npm run build"',
132
+ '--title': '--title needs a panel title, for example --title "My panel"',
133
+ };
134
+
119
135
  function flags(argv) {
120
- const parsed = { positional: [] };
136
+ const parsed = { positional: [], missingValues: [] };
121
137
  for (let index = 0; index < argv.length; index += 1) {
122
138
  const token = argv[index];
139
+ // A value-taking flag must be followed by its value, not by another flag or
140
+ // the end of the line. The old branches read `argv[++index]` unconditionally,
141
+ // so `--range --write` made `--write` the range and `--tag-prefix` silently
142
+ // fell back to the default. Remember the missing flag so `run()` can stop at
143
+ // usage validation before reading a file or planning a release.
144
+ const take = (flag) => {
145
+ const next = argv[index + 1];
146
+ if (next === undefined || next.startsWith('--') === true) {
147
+ parsed.missingValues.push(flag);
148
+ return null;
149
+ }
150
+ index += 1;
151
+ return next;
152
+ };
123
153
  if (token === '--dry-run') parsed.dryRun = true;
124
154
  else if (token === '--engines') parsed.engines = true;
125
155
  else if (token === '--fix') parsed.fix = true;
126
156
  else if (token === '--write') parsed.write = true;
127
- else if (token === '--range') parsed.range = argv[++index];
157
+ else if (token === '--range') {
158
+ const value = take('--range');
159
+ if (value !== null) parsed.range = value;
160
+ }
128
161
  else if (token === '--patch') {
129
162
  // Leave the value blank when the next token is another flag; the fix
130
163
  // branch reports the missing path instead of swallowing that flag.
131
164
  const next = argv[index + 1];
132
165
  parsed.patch = next === undefined || next.startsWith('--') === true ? '' : argv[++index];
133
166
  }
134
- else if (token === '--log') parsed.log = argv[++index];
167
+ else if (token === '--log') {
168
+ const value = take('--log');
169
+ if (value !== null) parsed.log = value;
170
+ }
135
171
  else if (token === '--index') {
136
172
  // A bare `--index` is a missing path, not a request for the default. The
137
173
  // `index` command used to fall back to ./market/index.json and exit 0,
@@ -145,7 +181,10 @@ function flags(argv) {
145
181
  parsed.index = argv[++index];
146
182
  }
147
183
  }
148
- else if (token === '--tag-prefix') parsed.tagPrefix = argv[++index];
184
+ else if (token === '--tag-prefix') {
185
+ const value = take('--tag-prefix');
186
+ if (value !== null) parsed.tagPrefix = value;
187
+ }
149
188
  else if (token === '--budget') {
150
189
  // A budget of `8m`, `0`, or `-1` is not a wait, and by the time the
151
190
  // registry loop notices, the tag is already pushed. Validate the flag
@@ -158,16 +197,40 @@ function flags(argv) {
158
197
  parsed.budget = seconds;
159
198
  }
160
199
  }
161
- else if (token === '--slot') parsed.slot = argv[++index];
162
- else if (token === '--surface') parsed.surface = argv[++index];
200
+ else if (token === '--slot') {
201
+ const value = take('--slot');
202
+ if (value !== null) parsed.slot = value;
203
+ }
204
+ else if (token === '--surface') {
205
+ const value = take('--surface');
206
+ if (value !== null) parsed.surface = value;
207
+ }
163
208
  else if (token === '--html') parsed.html = true;
164
- else if (token === '--name') parsed.name = argv[++index];
165
- else if (token === '--title') parsed.title = argv[++index];
209
+ else if (token === '--name') {
210
+ // The init branch already has a precise "required" message; remember a
211
+ // missing value so a following flag is not consumed as the package name.
212
+ const next = argv[index + 1];
213
+ if (next === undefined || next.startsWith('--') === true) parsed.nameMissing = true;
214
+ else parsed.name = argv[++index];
215
+ }
216
+ else if (token === '--title') {
217
+ const value = take('--title');
218
+ if (value !== null) parsed.title = value;
219
+ }
166
220
  else if (token === '--force') parsed.force = true;
167
221
  else if (token === '--no-mount') parsed.noMount = true;
168
- else if (token === '--dest') parsed.dest = argv[++index];
169
- else if (token === '--entry') parsed.entry = argv[++index];
170
- else if (token === '--build') parsed.build = argv[++index];
222
+ else if (token === '--dest') {
223
+ const value = take('--dest');
224
+ if (value !== null) parsed.dest = value;
225
+ }
226
+ else if (token === '--entry') {
227
+ const value = take('--entry');
228
+ if (value !== null) parsed.entry = value;
229
+ }
230
+ else if (token === '--build') {
231
+ const value = take('--build');
232
+ if (value !== null) parsed.build = value;
233
+ }
171
234
  else if (token === '--host') {
172
235
  // A bare `--host` is a missing value, not permission to swallow the next
173
236
  // flag. `audit --remote --host --json` used to compare every repository
@@ -209,8 +272,14 @@ function flags(argv) {
209
272
  else if (value !== true) parsed.remote = parsed.remote === true ? value : `${parsed.remote},${value}`;
210
273
  } else if (token === '--json') parsed.json = true;
211
274
  else if (token === '--once') parsed.once = true;
212
- else if (token === '--debounce') parsed.debounce = Number(argv[++index]);
213
- else if (token === '--timeout') parsed.timeout = Number(argv[++index]);
275
+ else if (token === '--debounce') {
276
+ const value = take('--debounce');
277
+ if (value !== null) parsed.debounce = Number(value);
278
+ }
279
+ else if (token === '--timeout') {
280
+ const value = take('--timeout');
281
+ if (value !== null) parsed.timeout = Number(value);
282
+ }
214
283
  else if (token === '--pr') parsed.pr = true;
215
284
  else if (token === '--merge') parsed.merge = true;
216
285
  else if (token === '--publish') parsed.publish = true;
@@ -228,8 +297,14 @@ function flags(argv) {
228
297
  parsed.home = argv[++index];
229
298
  }
230
299
  }
231
- else if (token === '--base') parsed.base = argv[++index];
232
- else if (token === '--market') parsed.market = argv[++index];
300
+ else if (token === '--base') {
301
+ const value = take('--base');
302
+ if (value !== null) parsed.base = value;
303
+ }
304
+ else if (token === '--market') {
305
+ const value = take('--market');
306
+ if (value !== null) parsed.market = value;
307
+ }
233
308
  else if (token.startsWith('--') === true) throw new Error(`unknown flag ${token}`);
234
309
  else parsed.positional.push(token);
235
310
  }
@@ -267,6 +342,23 @@ export async function run(argv, io = console, deps = {}) {
267
342
  return 0;
268
343
  }
269
344
 
345
+ // `--name` has its own required-argument wording, but a following option is
346
+ // still a missing value rather than the package name.
347
+ if (options.nameMissing === true) {
348
+ io.error('dsh-plugin init: --name <package-name> is required');
349
+ return 2;
350
+ }
351
+
352
+ // Every value-taking flag is validated here, before a command can read a
353
+ // file, plan a release, or consume the next option as its value. A missing
354
+ // value is invalid usage, not a request for the flag's default.
355
+ if (options.missingValues.length > 0) {
356
+ const flag = options.missingValues[0];
357
+ const message = MISSING_VALUE_MESSAGES[flag] ?? `${flag} needs a value`;
358
+ io.error(`dsh-plugin ${command}: ${message}`);
359
+ return 2;
360
+ }
361
+
270
362
  // `--index` names the file to audit or update. Without a value the `index`
271
363
  // command used to read ./market/index.json and exit 0, which let a CI step
272
364
  // pass against an index the caller never named. Reject the usage error here,
@@ -562,7 +654,7 @@ export async function run(argv, io = console, deps = {}) {
562
654
  }
563
655
 
564
656
  if (command === 'init') {
565
- if (options.name === undefined) {
657
+ if (options.name === undefined || options.nameMissing === true) {
566
658
  io.error('dsh-plugin init: --name <package-name> is required');
567
659
  return 2;
568
660
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-toolkit",
3
- "version": "0.20.31",
3
+ "version": "0.20.32",
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": {