npm-pkgbuild 20.8.18 → 20.9.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/package.json
CHANGED
|
@@ -8,17 +8,20 @@ export class ContentProvider {
|
|
|
8
8
|
entryProperties;
|
|
9
9
|
directoryProperties;
|
|
10
10
|
dir;
|
|
11
|
+
properties;
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param {Object} definitions
|
|
14
|
+
*
|
|
15
|
+
* @param {Object} definitions
|
|
15
16
|
* @param {string} [definitions.dir]
|
|
17
|
+
* @param {Object} [definitions.properties]
|
|
16
18
|
* @param {Object} [entryProperties]
|
|
17
19
|
* @param {string} [entryProperties.destination]
|
|
18
20
|
* @param {Object} [directoryProperties]
|
|
19
21
|
*/
|
|
20
22
|
constructor(definitions, entryProperties, directoryProperties) {
|
|
21
23
|
this.dir = definitions.dir;
|
|
24
|
+
this.properties = definitions.properties ?? {};
|
|
22
25
|
this.entryProperties = entryProperties;
|
|
23
26
|
this.directoryProperties = directoryProperties;
|
|
24
27
|
if (this.entryProperties?.destination) {
|
|
@@ -29,6 +32,39 @@ export class ContentProvider {
|
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param {string} name
|
|
38
|
+
* @param {boolean} isCollection
|
|
39
|
+
* @returns {Object}
|
|
40
|
+
*/
|
|
41
|
+
propertiesFor(name, isCollection) {
|
|
42
|
+
for (const [pattern, properties] of Object.entries(this.properties)) {
|
|
43
|
+
if (pattern === name) {
|
|
44
|
+
return properties;
|
|
45
|
+
}
|
|
46
|
+
if (pattern.endsWith("**/*")) {
|
|
47
|
+
const prefix = pattern.substring(0, pattern.length - 4);
|
|
48
|
+
if (name.startsWith(prefix)) {
|
|
49
|
+
return properties;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (pattern.endsWith("*")) {
|
|
53
|
+
const prefix = pattern.substring(0, pattern.length - 1);
|
|
54
|
+
if (name.startsWith(prefix)) {
|
|
55
|
+
if (name.substring(prefix.length).indexOf("/") < 0) {
|
|
56
|
+
return properties;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (isCollection) {
|
|
63
|
+
return this.directoryProperties;
|
|
64
|
+
}
|
|
65
|
+
return this.entryProperties;
|
|
66
|
+
}
|
|
67
|
+
|
|
32
68
|
/**
|
|
33
69
|
* List all entries.
|
|
34
70
|
* @return {AsyncIterable<ContentEntry|CollectionEntry>} all entries
|
|
@@ -74,15 +74,14 @@ export class FileContentProvider extends ContentProvider {
|
|
|
74
74
|
withFileTypes: true
|
|
75
75
|
})) {
|
|
76
76
|
const name = join(entry.parentPath, entry.name).substring(startPos);
|
|
77
|
-
|
|
78
77
|
if (entry.isFile()) {
|
|
79
78
|
yield new FileSystemEntry(name, {
|
|
80
|
-
...this.
|
|
79
|
+
...this.propertiesFor(name),
|
|
81
80
|
baseDir
|
|
82
81
|
});
|
|
83
82
|
count++;
|
|
84
83
|
} else if (entry.isDirectory()) {
|
|
85
|
-
yield new CollectionEntry(name, this.
|
|
84
|
+
yield new CollectionEntry(name, this.propertiesFor(name, true));
|
|
86
85
|
count++;
|
|
87
86
|
}
|
|
88
87
|
}
|
|
@@ -143,7 +143,7 @@ export class NodeModulesContentProvider extends ContentProvider {
|
|
|
143
143
|
if (json) {
|
|
144
144
|
yield new StringContentEntry(
|
|
145
145
|
name,
|
|
146
|
-
this.
|
|
146
|
+
this.propertiesFor(name),
|
|
147
147
|
JSON.stringify(json)
|
|
148
148
|
);
|
|
149
149
|
}
|
|
@@ -154,11 +154,11 @@ export class NodeModulesContentProvider extends ContentProvider {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
yield new FileSystemEntry(name, {
|
|
157
|
-
...this.
|
|
157
|
+
...this.propertiesFor(name),
|
|
158
158
|
baseDir: nodeModulesDir
|
|
159
159
|
});
|
|
160
160
|
} else if (entry.isDirectory()) {
|
|
161
|
-
yield new CollectionEntry(name, this.
|
|
161
|
+
yield new CollectionEntry(name, this.propertiesFor(name, true));
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
} catch (e) {
|
|
@@ -56,11 +56,12 @@ export class NPMPackContentProvider extends ContentProvider {
|
|
|
56
56
|
chunks.push(chunk);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
const name = header.name.substring(8);
|
|
59
60
|
entries.push(
|
|
60
61
|
new BufferContentEntry(
|
|
61
|
-
|
|
62
|
+
name,
|
|
62
63
|
{
|
|
63
|
-
...this.
|
|
64
|
+
...this.propertiesFor(name),
|
|
64
65
|
mtime: header.mtime,
|
|
65
66
|
mode: header.mode
|
|
66
67
|
},
|