dsh-plugin-toolkit 0.20.39 → 0.20.40
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 +12 -0
- package/lib/doctor.mjs +91 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 0.20.40
|
|
2
|
+
|
|
3
|
+
- **`doctor`'s subdirectory ignore matcher understands npm extglob patterns.**
|
|
4
|
+
A `lib/.npmignore` of `@(client|other).js` makes `npm pack` drop
|
|
5
|
+
`lib/client.js`, but the files-list check escaped the parentheses and read
|
|
6
|
+
the line as one literal filename, so it called the package clean. The glob
|
|
7
|
+
compiler now expands npm's extglob operators (`@()`, `+()`, `?()`, `*()` and
|
|
8
|
+
`!()`), including alternatives with their own wildcards, so the ignore rule
|
|
9
|
+
removes the same paths the packer does. `test/doctor-files-npmignore.test.mjs`
|
|
10
|
+
runs the extglob fixture and a literal `client.js` control against
|
|
11
|
+
`npm pack --dry-run --json` and three consecutive `doctor` runs.
|
|
12
|
+
|
|
1
13
|
## 0.20.39
|
|
2
14
|
|
|
3
15
|
- **`doctor`'s files-list check honors a `.npmignore` in a subdirectory.** npm
|
package/lib/doctor.mjs
CHANGED
|
@@ -322,7 +322,7 @@ export function declaredPaths(manifest) {
|
|
|
322
322
|
return [...paths];
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
const GLOB_MAGIC = /[*?{}[\]]/u;
|
|
325
|
+
const GLOB_MAGIC = /[*?{}[\]]|[!+@]\(/u;
|
|
326
326
|
|
|
327
327
|
/** npm compares tarball paths with forward slashes and no leading `./` or `/`. */
|
|
328
328
|
function packagePath(value) {
|
|
@@ -374,11 +374,101 @@ function expandBraces(pattern) {
|
|
|
374
374
|
return parts.flatMap((part) => expandBraces(`${prefix}${part}${suffix}`));
|
|
375
375
|
}
|
|
376
376
|
|
|
377
|
+
/**
|
|
378
|
+
* Index of the `)` that closes the extglob opened at `open`, or -1 when the
|
|
379
|
+
* pattern has no closing paren. Parentheses inside a bracket class, a nested
|
|
380
|
+
* extglob or an escape do not count.
|
|
381
|
+
*/
|
|
382
|
+
function extglobEnd(pattern, open) {
|
|
383
|
+
let depth = 0;
|
|
384
|
+
let inClass = false;
|
|
385
|
+
for (let index = open; index < pattern.length; index += 1) {
|
|
386
|
+
const char = pattern[index];
|
|
387
|
+
if (char === '\\') {
|
|
388
|
+
index += 1;
|
|
389
|
+
} else if (inClass === true) {
|
|
390
|
+
if (char === ']') inClass = false;
|
|
391
|
+
} else if (char === '[') {
|
|
392
|
+
inClass = true;
|
|
393
|
+
} else if (char === '(') {
|
|
394
|
+
depth += 1;
|
|
395
|
+
} else if (char === ')') {
|
|
396
|
+
depth -= 1;
|
|
397
|
+
if (depth === 0) return index;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return -1;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/** Split an extglob body on `|`, ignoring separators inside a nested group or class. */
|
|
404
|
+
function splitExtglobAlternatives(body) {
|
|
405
|
+
const parts = [];
|
|
406
|
+
let current = '';
|
|
407
|
+
let depth = 0;
|
|
408
|
+
let inClass = false;
|
|
409
|
+
for (let index = 0; index < body.length; index += 1) {
|
|
410
|
+
const char = body[index];
|
|
411
|
+
if (char === '\\') {
|
|
412
|
+
current += char;
|
|
413
|
+
if (index + 1 < body.length) current += body[(index += 1)];
|
|
414
|
+
} else if (inClass === true) {
|
|
415
|
+
current += char;
|
|
416
|
+
if (char === ']') inClass = false;
|
|
417
|
+
} else if (char === '[') {
|
|
418
|
+
inClass = true;
|
|
419
|
+
current += char;
|
|
420
|
+
} else if (char === '(') {
|
|
421
|
+
depth += 1;
|
|
422
|
+
current += char;
|
|
423
|
+
} else if (char === ')') {
|
|
424
|
+
depth -= 1;
|
|
425
|
+
current += char;
|
|
426
|
+
} else if (char === '|' && depth === 0) {
|
|
427
|
+
parts.push(current);
|
|
428
|
+
current = '';
|
|
429
|
+
} else {
|
|
430
|
+
current += char;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
parts.push(current);
|
|
434
|
+
return parts;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/** The regex source for one extglob operator and its `|`-separated body. */
|
|
438
|
+
function extglobSource(operator, body) {
|
|
439
|
+
const alternatives = splitExtglobAlternatives(body).map(globSource);
|
|
440
|
+
const inner = alternatives.length === 1 ? alternatives[0] : `(?:${alternatives.join('|')})`;
|
|
441
|
+
switch (operator) {
|
|
442
|
+
case '@':
|
|
443
|
+
return `(?:${inner})`;
|
|
444
|
+
case '+':
|
|
445
|
+
return `(?:${inner})+`;
|
|
446
|
+
case '?':
|
|
447
|
+
return `(?:${inner})?`;
|
|
448
|
+
case '*':
|
|
449
|
+
return `(?:${inner})*`;
|
|
450
|
+
default:
|
|
451
|
+
// `!(...)` is minimatch's negative extglob: at this position no
|
|
452
|
+
// alternative may match, and the lazy segment lets the rest of the
|
|
453
|
+
// pattern decide where the group ends (`!(foo).js` still matches
|
|
454
|
+
// `bar.js`, not `foo.js`).
|
|
455
|
+
return `(?:(?!(?:${inner}))[^/]*?)`;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
377
459
|
/** One glob alternative, with `*` kept inside a path segment and `**` crossing them. */
|
|
378
460
|
function globSource(pattern) {
|
|
379
461
|
let source = '';
|
|
380
462
|
for (let index = 0; index < pattern.length; index += 1) {
|
|
381
463
|
const char = pattern[index];
|
|
464
|
+
if ('@+?!*'.includes(char) === true && pattern[index + 1] === '(') {
|
|
465
|
+
const close = extglobEnd(pattern, index + 1);
|
|
466
|
+
if (close !== -1) {
|
|
467
|
+
source += extglobSource(char, pattern.slice(index + 2, close));
|
|
468
|
+
index = close;
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
382
472
|
if (char === '*') {
|
|
383
473
|
if (pattern[index + 1] === '*') {
|
|
384
474
|
while (pattern[index + 1] === '*') index += 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-toolkit",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.40",
|
|
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": {
|