npm-packlist 8.0.0 → 8.0.2
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/lib/index.js +10 -39
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -42,20 +42,6 @@ const strictDefaults = [
|
|
|
42
42
|
'/.git',
|
|
43
43
|
]
|
|
44
44
|
|
|
45
|
-
const allLevels = [
|
|
46
|
-
// these are included by default but can be excluded by package.json files array
|
|
47
|
-
'!/readme{,.*[^~$]}',
|
|
48
|
-
'!/copying{,.*[^~$]}',
|
|
49
|
-
'!/license{,.*[^~$]}',
|
|
50
|
-
'!/licence{,.*[^~$]}',
|
|
51
|
-
]
|
|
52
|
-
|
|
53
|
-
const rootOnly = [
|
|
54
|
-
/^!.*readme/i,
|
|
55
|
-
/^!.*copying/i,
|
|
56
|
-
/^!.*licen[sc]e/i,
|
|
57
|
-
]
|
|
58
|
-
|
|
59
45
|
const normalizePath = (path) => path.split('\\').join('/')
|
|
60
46
|
|
|
61
47
|
const readOutOfTreeIgnoreFiles = (root, rel, result = []) => {
|
|
@@ -141,7 +127,6 @@ class PackWalker extends IgnoreWalker {
|
|
|
141
127
|
// known required files for this directory
|
|
142
128
|
this.injectRules(strictRules, [
|
|
143
129
|
...strictDefaults,
|
|
144
|
-
...allLevels,
|
|
145
130
|
...this.requiredFiles.map((file) => `!${file}`),
|
|
146
131
|
])
|
|
147
132
|
}
|
|
@@ -294,10 +279,14 @@ class PackWalker extends IgnoreWalker {
|
|
|
294
279
|
const ignores = []
|
|
295
280
|
const strict = [
|
|
296
281
|
...strictDefaults,
|
|
297
|
-
...allLevels,
|
|
298
282
|
'!/package.json',
|
|
283
|
+
'!/readme{,.*[^~$]}',
|
|
284
|
+
'!/copying{,.*[^~$]}',
|
|
285
|
+
'!/license{,.*[^~$]}',
|
|
286
|
+
'!/licence{,.*[^~$]}',
|
|
299
287
|
'/.git',
|
|
300
288
|
'/node_modules',
|
|
289
|
+
'.npmrc',
|
|
301
290
|
'/package-lock.json',
|
|
302
291
|
'/yarn.lock',
|
|
303
292
|
'/pnpm-lock.yaml',
|
|
@@ -307,17 +296,13 @@ class PackWalker extends IgnoreWalker {
|
|
|
307
296
|
if (files) {
|
|
308
297
|
for (let file of files) {
|
|
309
298
|
// invert the rule because these are things we want to include
|
|
310
|
-
if (file.startsWith('
|
|
299
|
+
if (file.startsWith('./')) {
|
|
311
300
|
file = file.slice(1)
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
file = file.slice(0, -2)
|
|
301
|
+
}
|
|
302
|
+
if (file.endsWith('/*')) {
|
|
303
|
+
file += '*'
|
|
316
304
|
}
|
|
317
305
|
const inverse = `!${file}`
|
|
318
|
-
|
|
319
|
-
this.excludeNonRoot(file)
|
|
320
|
-
|
|
321
306
|
try {
|
|
322
307
|
// if an entry in the files array is a specific file, then we need to include it as a
|
|
323
308
|
// strict requirement for this package. if it's a directory or a pattern, it's a default
|
|
@@ -326,7 +311,7 @@ class PackWalker extends IgnoreWalker {
|
|
|
326
311
|
// if we have a file and we know that, it's strictly required
|
|
327
312
|
if (stat.isFile()) {
|
|
328
313
|
strict.unshift(inverse)
|
|
329
|
-
this.requiredFiles.push(file)
|
|
314
|
+
this.requiredFiles.push(file.startsWith('/') ? file.slice(1) : file)
|
|
330
315
|
} else if (stat.isDirectory()) {
|
|
331
316
|
// otherwise, it's a default ignore, and since we got here we know it's not a pattern
|
|
332
317
|
// so we include the directory contents
|
|
@@ -366,20 +351,6 @@ class PackWalker extends IgnoreWalker {
|
|
|
366
351
|
this.injectRules(strictRules, strict, callback)
|
|
367
352
|
}
|
|
368
353
|
|
|
369
|
-
// excludes non root files by checking if elements from the files array in
|
|
370
|
-
// package.json contain an ! and readme/license/licence/copying, and then
|
|
371
|
-
// removing readme/license/licence/copying accordingly from strict defaults
|
|
372
|
-
excludeNonRoot (file) {
|
|
373
|
-
// Find the pattern
|
|
374
|
-
const matchingPattern = rootOnly.find(regex => regex.test(file))
|
|
375
|
-
|
|
376
|
-
if (matchingPattern) {
|
|
377
|
-
// Find which index matches the pattern and remove it from allLevels
|
|
378
|
-
const indexToRemove = allLevels.findIndex(element => matchingPattern.test(element))
|
|
379
|
-
allLevels.splice(indexToRemove, 1)
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
354
|
// custom method: after we've finished gathering the files for the root package, we call this
|
|
384
355
|
// before emitting the 'done' event in order to gather all of the files for bundled deps
|
|
385
356
|
async gatherBundles () {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-packlist",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.2",
|
|
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"
|
|
7
7
|
},
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"ignore-walk": "^6.0.
|
|
10
|
+
"ignore-walk": "^6.0.4"
|
|
11
11
|
},
|
|
12
12
|
"author": "GitHub Inc.",
|
|
13
13
|
"license": "ISC",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@npmcli/arborist": "^6.0.0 || ^6.0.0-pre.0",
|
|
20
20
|
"@npmcli/eslint-config": "^4.0.0",
|
|
21
|
-
"@npmcli/template-oss": "4.
|
|
21
|
+
"@npmcli/template-oss": "4.21.2",
|
|
22
22
|
"mutate-fs": "^2.1.1",
|
|
23
23
|
"tap": "^16.0.1"
|
|
24
24
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"snap": "tap",
|
|
29
29
|
"postsnap": "npm run lintfix --",
|
|
30
30
|
"eslint": "eslint",
|
|
31
|
-
"lint": "eslint \"**/*.js\"",
|
|
31
|
+
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
|
|
32
32
|
"lintfix": "npm run lint -- --fix",
|
|
33
33
|
"npmclilint": "npmcli-lint",
|
|
34
34
|
"postlint": "template-oss-check",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"templateOSS": {
|
|
57
57
|
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
|
58
|
-
"version": "4.
|
|
58
|
+
"version": "4.21.2",
|
|
59
59
|
"publish": true
|
|
60
60
|
}
|
|
61
61
|
}
|