npm-pkgbuild 20.8.18 → 20.9.1
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/README.md +37 -26
- package/package.json +2 -2
- package/src/content/content-provider.mjs +38 -2
- package/src/content/file-content-provider.mjs +3 -4
- package/src/content/nft-content-provider.mjs +2 -2
- package/src/content/node-modules-content-provider.mjs +3 -3
- package/src/content/npm-pack-content-provider.mjs +3 -2
- package/src/extract-from-package.mjs +2 -2
- package/src/util.mjs +1 -23
package/README.md
CHANGED
|
@@ -117,84 +117,86 @@ See [mf-hosting](https://www.npmjs.com/package/mf-hosting) or [mf-hosting-fronte
|
|
|
117
117
|
* [ContentProvider](#contentprovider)
|
|
118
118
|
* [Parameters](#parameters-6)
|
|
119
119
|
* [Properties](#properties-3)
|
|
120
|
+
* [propertiesFor](#propertiesfor)
|
|
121
|
+
* [Parameters](#parameters-7)
|
|
120
122
|
* [asyncIterator](#asynciterator-3)
|
|
121
123
|
* [DEBIAN](#debian)
|
|
122
124
|
* [hookMapping](#hookmapping)
|
|
123
125
|
* [attributes](#attributes)
|
|
124
126
|
* [prepare](#prepare)
|
|
125
|
-
* [Parameters](#parameters-
|
|
127
|
+
* [Parameters](#parameters-8)
|
|
126
128
|
* [pkgKeyValuePairOptions](#pkgkeyvaluepairoptions)
|
|
127
129
|
* [attributes](#attributes-1)
|
|
128
130
|
* [quoteFile](#quotefile)
|
|
129
|
-
* [Parameters](#parameters-
|
|
131
|
+
* [Parameters](#parameters-9)
|
|
130
132
|
* [RPM](#rpm)
|
|
131
133
|
* [hookMapping](#hookmapping-1)
|
|
132
134
|
* [attributes](#attributes-2)
|
|
133
135
|
* [prepare](#prepare-1)
|
|
134
|
-
* [Parameters](#parameters-
|
|
136
|
+
* [Parameters](#parameters-10)
|
|
135
137
|
* [OCI](#oci)
|
|
136
138
|
* [DOCKER](#docker)
|
|
137
139
|
* [attributes](#attributes-3)
|
|
138
140
|
* [prepare](#prepare-2)
|
|
139
|
-
* [Parameters](#parameters-
|
|
141
|
+
* [Parameters](#parameters-11)
|
|
140
142
|
* [BUILDAH](#buildah)
|
|
141
143
|
* [Packager](#packager)
|
|
142
|
-
* [Parameters](#parameters-
|
|
144
|
+
* [Parameters](#parameters-12)
|
|
143
145
|
* [packageName](#packagename)
|
|
144
|
-
* [Parameters](#parameters-
|
|
146
|
+
* [Parameters](#parameters-13)
|
|
145
147
|
* [hookContent](#hookcontent)
|
|
146
148
|
* [dependencyExpression](#dependencyexpression)
|
|
147
|
-
* [Parameters](#parameters-
|
|
149
|
+
* [Parameters](#parameters-14)
|
|
148
150
|
* [tmpdir](#tmpdir)
|
|
149
151
|
* [prepare](#prepare-3)
|
|
150
|
-
* [Parameters](#parameters-14)
|
|
151
|
-
* [create](#create)
|
|
152
152
|
* [Parameters](#parameters-15)
|
|
153
|
+
* [create](#create)
|
|
154
|
+
* [Parameters](#parameters-16)
|
|
153
155
|
* [workspaceLayout](#workspacelayout)
|
|
154
156
|
* [prepare](#prepare-4)
|
|
155
|
-
* [Parameters](#parameters-
|
|
157
|
+
* [Parameters](#parameters-17)
|
|
156
158
|
* [Packager](#packager-1)
|
|
157
|
-
* [Parameters](#parameters-
|
|
159
|
+
* [Parameters](#parameters-18)
|
|
158
160
|
* [packageName](#packagename-1)
|
|
159
|
-
* [Parameters](#parameters-
|
|
161
|
+
* [Parameters](#parameters-19)
|
|
160
162
|
* [hookContent](#hookcontent-1)
|
|
161
163
|
* [dependencyExpression](#dependencyexpression-1)
|
|
162
|
-
* [Parameters](#parameters-
|
|
164
|
+
* [Parameters](#parameters-20)
|
|
163
165
|
* [tmpdir](#tmpdir-1)
|
|
164
166
|
* [prepare](#prepare-5)
|
|
165
|
-
* [Parameters](#parameters-20)
|
|
166
|
-
* [create](#create-1)
|
|
167
167
|
* [Parameters](#parameters-21)
|
|
168
|
+
* [create](#create-1)
|
|
169
|
+
* [Parameters](#parameters-22)
|
|
168
170
|
* [workspaceLayout](#workspacelayout-1)
|
|
169
171
|
* [prepare](#prepare-6)
|
|
170
|
-
* [Parameters](#parameters-
|
|
172
|
+
* [Parameters](#parameters-23)
|
|
171
173
|
* [Field](#field)
|
|
172
174
|
* [Properties](#properties-4)
|
|
173
175
|
* [deleteKey](#deletekey)
|
|
174
|
-
* [Parameters](#parameters-23)
|
|
175
|
-
* [copyNodeModules](#copynodemodules)
|
|
176
176
|
* [Parameters](#parameters-24)
|
|
177
|
+
* [copyNodeModules](#copynodemodules)
|
|
178
|
+
* [Parameters](#parameters-25)
|
|
177
179
|
* [PublishingDetail](#publishingdetail)
|
|
178
180
|
* [Properties](#properties-5)
|
|
179
181
|
* [createPublishingDetails](#createpublishingdetails)
|
|
180
|
-
* [Parameters](#parameters-25)
|
|
181
|
-
* [publish](#publish)
|
|
182
182
|
* [Parameters](#parameters-26)
|
|
183
|
+
* [publish](#publish)
|
|
184
|
+
* [Parameters](#parameters-27)
|
|
183
185
|
* [utf8StreamOptions](#utf8streamoptions)
|
|
184
186
|
* [decodePassword](#decodepassword)
|
|
185
|
-
* [Parameters](#parameters-
|
|
187
|
+
* [Parameters](#parameters-28)
|
|
186
188
|
* [FunctionDecl](#functiondecl)
|
|
187
189
|
* [Properties](#properties-6)
|
|
188
190
|
* [extractFunctions](#extractfunctions)
|
|
189
|
-
* [Parameters](#parameters-28)
|
|
190
|
-
* [asArray](#asarray)
|
|
191
191
|
* [Parameters](#parameters-29)
|
|
192
|
-
* [
|
|
192
|
+
* [asArray](#asarray)
|
|
193
193
|
* [Parameters](#parameters-30)
|
|
194
|
-
* [
|
|
194
|
+
* [fieldProvider](#fieldprovider)
|
|
195
195
|
* [Parameters](#parameters-31)
|
|
196
|
-
* [
|
|
196
|
+
* [Expander](#expander)
|
|
197
197
|
* [Parameters](#parameters-32)
|
|
198
|
+
* [copyEntries](#copyentries)
|
|
199
|
+
* [Parameters](#parameters-33)
|
|
198
200
|
|
|
199
201
|
## allInputs
|
|
200
202
|
|
|
@@ -358,6 +360,15 @@ Source of package content.
|
|
|
358
360
|
|
|
359
361
|
* `dir` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
|
|
360
362
|
|
|
363
|
+
### propertiesFor
|
|
364
|
+
|
|
365
|
+
#### Parameters
|
|
366
|
+
|
|
367
|
+
* `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
|
|
368
|
+
* `isCollection` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
|
|
369
|
+
|
|
370
|
+
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
|
|
371
|
+
|
|
361
372
|
### asyncIterator
|
|
362
373
|
|
|
363
374
|
List all entries.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.9.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": false
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"key-value-transformer": "^3.3.2",
|
|
61
61
|
"npm-package-walker": "^8.0.11",
|
|
62
62
|
"npm-packlist": "^11.3.0",
|
|
63
|
-
"pacc": "^11.
|
|
63
|
+
"pacc": "^11.3.0",
|
|
64
64
|
"package-directory": "^8.2.0",
|
|
65
65
|
"pacote": "^22.0.0",
|
|
66
66
|
"tar-stream": "^3.1.7",
|
|
@@ -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
|
|
@@ -3,7 +3,7 @@ import { cwd } from "node:process";
|
|
|
3
3
|
import { glob } from "node:fs/promises";
|
|
4
4
|
import { ContentEntry, CollectionEntry } from "content-entry";
|
|
5
5
|
import { FileSystemEntry } from "content-entry-filesystem";
|
|
6
|
-
import { asArray } from "
|
|
6
|
+
import { asArray } from "pacc";
|
|
7
7
|
import { ContentProvider } from "./content-provider.mjs";
|
|
8
8
|
|
|
9
9
|
const DEFAULT_PATTERN = ["**/*", "!.*"];
|
|
@@ -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
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { nodeFileTrace } from "@vercel/nft";
|
|
2
2
|
import { ContentEntry } from "content-entry";
|
|
3
3
|
import { FileSystemEntry } from "content-entry-filesystem";
|
|
4
|
-
import { asArray } from "
|
|
4
|
+
import { asArray } from "pacc";
|
|
5
5
|
import { ContentProvider } from "./content-provider.mjs";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -52,7 +52,7 @@ export class NFTContentProvider extends ContentProvider {
|
|
|
52
52
|
for (const name of fileList) {
|
|
53
53
|
yield new FileSystemEntry(
|
|
54
54
|
name,
|
|
55
|
-
{ ...this.
|
|
55
|
+
{ ...this.propertiesFor(name), baseDir }
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -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
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { join, resolve } from "node:path";
|
|
2
2
|
import { packageDirectory } from "package-directory";
|
|
3
3
|
import { packageWalker } from "npm-package-walker";
|
|
4
|
-
import { expand } from "pacc";
|
|
4
|
+
import { expand, asArray } from "pacc";
|
|
5
5
|
import { satisfies } from "compare-versions";
|
|
6
|
-
import {
|
|
6
|
+
import { mergeDependencies } from "./util.mjs";
|
|
7
7
|
import { NPMPackContentProvider } from "./content/npm-pack-content-provider.mjs";
|
|
8
8
|
import { NodeModulesContentProvider } from "./content/node-modules-content-provider.mjs";
|
|
9
9
|
import { FileContentProvider } from "./content/file-content-provider.mjs";
|
package/src/util.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { mkdir } from "node:fs/promises";
|
|
|
3
3
|
import { pipeline } from "node:stream/promises";
|
|
4
4
|
import { Readable } from "node:stream";
|
|
5
5
|
import { createWriteStream } from "node:fs";
|
|
6
|
-
import { toExternal } from "pacc";
|
|
6
|
+
import { toExternal, asArray } from "pacc";
|
|
7
7
|
import { ContentEntry } from "content-entry";
|
|
8
8
|
import { aggregateFifo } from "aggregate-async-iterator";
|
|
9
9
|
|
|
@@ -138,28 +138,6 @@ export function quote(v, qc = "'") {
|
|
|
138
138
|
return v.match(/^\w+$/) ? v : qc + v + qc;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
/**
|
|
142
|
-
* Convert scalar or iterable into Array.
|
|
143
|
-
* @param {any} value
|
|
144
|
-
* @returns {Array<any>}
|
|
145
|
-
*/
|
|
146
|
-
export function asArray(value) {
|
|
147
|
-
switch (typeof value) {
|
|
148
|
-
case "undefined":
|
|
149
|
-
return [];
|
|
150
|
-
case "object":
|
|
151
|
-
if (Array.isArray(value)) {
|
|
152
|
-
return value;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (value instanceof Iterator || value[Symbol.iterator]) {
|
|
156
|
-
return [...value];
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return [value];
|
|
161
|
-
}
|
|
162
|
-
|
|
163
141
|
/**
|
|
164
142
|
*
|
|
165
143
|
* @param {Object} properties
|