npm-packlist 11.1.0 → 11.3.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.
Files changed (2) hide show
  1. package/lib/index.js +29 -0
  2. package/package.json +3 -3
package/lib/index.js CHANGED
@@ -305,6 +305,7 @@ class PackWalker extends IgnoreWalker {
305
305
  browser,
306
306
  files,
307
307
  main,
308
+ patchedDependencies,
308
309
  } = this.tree.package
309
310
 
310
311
  // rules in these arrays are inverted since they are patterns we want to _not_ ignore
@@ -325,6 +326,8 @@ class PackWalker extends IgnoreWalker {
325
326
  '/pnpm-lock.yaml',
326
327
  '/bun.lockb',
327
328
  '/bun.lock',
329
+ '/.npm-extension.mjs',
330
+ '/.npm-extension.cjs',
328
331
  ]
329
332
 
330
333
  // if we have a files array in our package, we need to pull rules from it
@@ -394,6 +397,32 @@ class PackWalker extends IgnoreWalker {
394
397
  }
395
398
  }
396
399
 
400
+ // patch files declared in patchedDependencies are project-local fixes and must never ship.
401
+ // patchedDependencies is root-only state, so this applies only to the package being packed.
402
+ // each declared patch file is force-excluded even when it was added via "files".
403
+ // only the exact files are excluded, never their directory, so a shared dir keeps its other contents.
404
+ if (this.tree.isProjectRoot && patchedDependencies && typeof patchedDependencies === 'object') {
405
+ for (const patchPath of Object.values(patchedDependencies)) {
406
+ if (typeof patchPath !== 'string') {
407
+ continue
408
+ }
409
+ const rel = normalizePath(patchPath).replace(/^\.?\//, '').replace(/\/+$/, '')
410
+ // skip absolute paths or paths that escape the package root, which are never packed anyway
411
+ if (!rel || rel.startsWith('/') || rel === '..' || rel.startsWith('../') || rel.includes('/../')) {
412
+ continue
413
+ }
414
+ // warn when a "files" entry pulled the patch file in, either directly or via its directory
415
+ const parentGlob = `!/${normalizePath(dirname(rel))}/**`
416
+ if (files && (ignores.includes(`!/${rel}`) || ignores.includes(parentGlob))) {
417
+ log.warn(
418
+ 'patched-dependencies',
419
+ `excluding "${rel}" from the package tarball: patch files in patchedDependencies must not be published`
420
+ )
421
+ }
422
+ strict.push(`/${rel}`)
423
+ }
424
+ }
425
+
397
426
  // and now we add all of the strict rules to our synthetic file
398
427
  this.injectRules(strictRules, strict, callback)
399
428
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-packlist",
3
- "version": "11.1.0",
3
+ "version": "11.3.0",
4
4
  "description": "Get a list of the files to add from a folder into an npm package",
5
5
  "directories": {
6
6
  "test": "test"
@@ -20,7 +20,7 @@
20
20
  "devDependencies": {
21
21
  "@npmcli/arborist": "^9.0.0",
22
22
  "@npmcli/eslint-config": "^7.0.0",
23
- "@npmcli/template-oss": "5.1.0",
23
+ "@npmcli/template-oss": "5.1.1",
24
24
  "mutate-fs": "^2.1.1",
25
25
  "tap": "^16.0.1"
26
26
  },
@@ -57,7 +57,7 @@
57
57
  },
58
58
  "templateOSS": {
59
59
  "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
60
- "version": "5.1.0",
60
+ "version": "5.1.1",
61
61
  "publish": true,
62
62
  "updateNpm": false
63
63
  }