npm-pkgbuild 21.0.3 → 22.0.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 +6 -6
- package/src/content/content-provider.mjs +32 -31
- package/src/content/file-content-provider.mjs +21 -18
- package/src/content/nft-content-provider.mjs +4 -6
- package/src/content/node-modules-content-provider.mjs +6 -11
- package/src/content/npm-pack-content-provider.mjs +4 -12
- package/src/extract-from-package.mjs +3 -14
- package/src/npm-pkgbuild-cli.mjs +1 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "22.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": false
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"commander": "^15.0.0",
|
|
54
54
|
"compare-versions": "^6.1.1",
|
|
55
55
|
"content-entry": "^15.0.2",
|
|
56
|
-
"content-entry-filesystem": "^9.1.
|
|
57
|
-
"content-entry-transform": "^1.7.
|
|
56
|
+
"content-entry-filesystem": "^9.1.2",
|
|
57
|
+
"content-entry-transform": "^1.7.4",
|
|
58
58
|
"execa": "^10.0.1",
|
|
59
59
|
"ini": "^7.0.0",
|
|
60
60
|
"iterable-string-interceptor": "^3.0.8",
|
|
@@ -65,11 +65,11 @@
|
|
|
65
65
|
"package-directory": "^8.2.0",
|
|
66
66
|
"pacote": "^22.0.0",
|
|
67
67
|
"picomatch": "^4.0.7",
|
|
68
|
-
"tar-stream": "^3.1
|
|
68
|
+
"tar-stream": "^3.2.1",
|
|
69
69
|
"uti": "^8.11.3"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@types/node": "^26.
|
|
72
|
+
"@types/node": "^26.4.0",
|
|
73
73
|
"ava": "^8.0.1",
|
|
74
74
|
"c8": "^12.0.0",
|
|
75
75
|
"documentation": "^14.0.3",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"stream-buffers": "^3.0.3"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|
|
80
|
-
"node": ">=24.
|
|
80
|
+
"node": ">=24.20.0"
|
|
81
81
|
},
|
|
82
82
|
"repository": {
|
|
83
83
|
"type": "git",
|
|
@@ -6,38 +6,40 @@ import { ContentEntry, CollectionEntry } from "content-entry";
|
|
|
6
6
|
* @property {string} dir
|
|
7
7
|
*/
|
|
8
8
|
export class ContentProvider {
|
|
9
|
-
entryProperties;
|
|
10
|
-
directoryProperties;
|
|
11
9
|
dir;
|
|
12
|
-
properties;
|
|
13
10
|
|
|
14
11
|
/**
|
|
15
12
|
*
|
|
16
13
|
* @param {Object} definitions
|
|
17
14
|
* @param {string} [definitions.dir]
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {Object} [
|
|
20
|
-
* @param {string} [entryProperties.destination]
|
|
21
|
-
* @param {Object} [directoryProperties]
|
|
15
|
+
* @param {string} [definitions.destination]
|
|
16
|
+
* @param {Object} [definitions.permissions]
|
|
22
17
|
*/
|
|
23
|
-
constructor(definitions
|
|
18
|
+
constructor(definitions) {
|
|
24
19
|
this.dir = definitions.dir;
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
20
|
+
this.defaultProperties = { destination: definitions.destination };
|
|
21
|
+
|
|
22
|
+
if (definitions.permissions) {
|
|
23
|
+
if (
|
|
24
|
+
Object.values(definitions.permissions).find(v => typeof v !== "object")
|
|
25
|
+
) {
|
|
26
|
+
Object.assign(this.defaultProperties, definitions.permissions);
|
|
27
|
+
} else {
|
|
28
|
+
this.permissions = new Map(
|
|
29
|
+
Object.entries(definitions.permissions).map(
|
|
30
|
+
([pattern, properties]) => [picomatch(pattern), properties]
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
33
34
|
}
|
|
35
|
+
}
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
get destination() {
|
|
38
|
+
return this.defaultProperties.destination;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
toString() {
|
|
42
|
+
return `${this.constructor.name}: ${this.dir} -> ${this.destination}`;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
/**
|
|
@@ -47,18 +49,17 @@ export class ContentProvider {
|
|
|
47
49
|
* @returns {Object|undefined}
|
|
48
50
|
*/
|
|
49
51
|
propertiesFor(name, isCollection) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
if (this.permissions) {
|
|
53
|
+
for (const [matcher, properties] of this.permissions) {
|
|
54
|
+
if (matcher(name)) {
|
|
55
|
+
return isCollection && properties.collection
|
|
56
|
+
? { ...properties.collection, destination: this.destination }
|
|
57
|
+
: { ...properties, destination: this.destination };
|
|
58
|
+
}
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
return this.directoryProperties;
|
|
60
|
-
}
|
|
61
|
-
return this.entryProperties;
|
|
62
|
+
return this.defaultProperties;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
/**
|
|
@@ -23,34 +23,37 @@ export class FileContentProvider extends ContentProvider {
|
|
|
23
23
|
return "use plain files source";
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
pattern = DEFAULT_PATTERN;
|
|
27
|
-
|
|
28
26
|
/**
|
|
29
27
|
* Content provided form the file system.
|
|
30
28
|
* @param {Object|string} definitions
|
|
31
29
|
* @param {string} [definitions.dir] base directory where to find the files
|
|
32
30
|
* @param {string|string[]} [definitions.pattern]
|
|
31
|
+
* @param {string} [definitions.destination]
|
|
33
32
|
*/
|
|
34
|
-
constructor(definitions
|
|
35
|
-
|
|
33
|
+
constructor(definitions) {
|
|
34
|
+
let dir;
|
|
36
35
|
|
|
37
36
|
if (typeof definitions === "string") {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.pattern = DEFAULT_PATTERN;
|
|
41
|
-
} else {
|
|
42
|
-
const dir = dirname(definitions);
|
|
43
|
-
this.dir = dir;
|
|
44
|
-
this.pattern = [definitions.substring(dir.length + 1)];
|
|
45
|
-
}
|
|
37
|
+
dir = definitions;
|
|
38
|
+
definitions = {};
|
|
46
39
|
} else {
|
|
47
|
-
|
|
48
|
-
if (definitions.pattern) {
|
|
49
|
-
this.pattern = asArray(definitions.pattern);
|
|
50
|
-
}
|
|
40
|
+
dir = definitions.dir;
|
|
51
41
|
}
|
|
52
42
|
|
|
53
|
-
|
|
43
|
+
if (dir.endsWith("/")) {
|
|
44
|
+
definitions.dir = dir.substring(0, dir.length - 1);
|
|
45
|
+
} else if (!definitions.pattern) {
|
|
46
|
+
definitions.dir = dirname(dir);
|
|
47
|
+
definitions.pattern = [dir.substring(definitions.dir.length + 1)];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
definitions.dir = resolve(cwd(), definitions.dir);
|
|
51
|
+
|
|
52
|
+
super(definitions);
|
|
53
|
+
|
|
54
|
+
this.pattern = definitions.pattern
|
|
55
|
+
? asArray(definitions.pattern)
|
|
56
|
+
: DEFAULT_PATTERN;
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
get isPatternMatch() {
|
|
@@ -58,7 +61,7 @@ export class FileContentProvider extends ContentProvider {
|
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
toString() {
|
|
61
|
-
return `${this.constructor.name}: ${this.dir}, ${this.pattern} -> ${this.
|
|
64
|
+
return `${this.constructor.name}: ${this.dir}, ${this.pattern} -> ${this.destination}`;
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
/**
|
|
@@ -24,12 +24,10 @@ export class NFTContentProvider extends ContentProvider {
|
|
|
24
24
|
* @param {Object|string} definitions
|
|
25
25
|
* @param {string} definitions.start base directory where to find the files
|
|
26
26
|
* @param {string} [definitions.dir]
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {string} [entryProperties.destination]
|
|
29
|
-
* @param {Object} [directoryProperties]
|
|
27
|
+
* @param {string} [definitions.destination]
|
|
30
28
|
*/
|
|
31
|
-
constructor(definitions
|
|
32
|
-
super(definitions
|
|
29
|
+
constructor(definitions) {
|
|
30
|
+
super(definitions);
|
|
33
31
|
|
|
34
32
|
if (typeof definitions === "string") {
|
|
35
33
|
this.start = [definitions];
|
|
@@ -39,7 +37,7 @@ export class NFTContentProvider extends ContentProvider {
|
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
toString() {
|
|
42
|
-
return `${this.constructor.name}: ${this.start} -> ${this.
|
|
40
|
+
return `${this.constructor.name}: ${this.start} -> ${this.destination}`;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
/**
|
|
@@ -33,19 +33,14 @@ export class NodeModulesContentProvider extends ContentProvider {
|
|
|
33
33
|
|
|
34
34
|
withoutDevelpmentDependencies = true;
|
|
35
35
|
|
|
36
|
-
constructor(definitions
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
!entryProperties.destination.endsWith("/")
|
|
40
|
-
) {
|
|
41
|
-
entryProperties.destination += "/";
|
|
36
|
+
constructor(definitions) {
|
|
37
|
+
if (definitions?.destination && !definitions.destination.endsWith("/")) {
|
|
38
|
+
definitions.destination += "/";
|
|
42
39
|
}
|
|
43
|
-
super(definitions
|
|
44
|
-
Object.assign(this, definitions);
|
|
45
|
-
}
|
|
40
|
+
super(definitions);
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
this.withoutDevelpmentDependencies =
|
|
43
|
+
definitions.withoutDevelpmentDependencies;
|
|
49
44
|
}
|
|
50
45
|
|
|
51
46
|
/**
|
|
@@ -25,19 +25,11 @@ export class NPMPackContentProvider extends ContentProvider {
|
|
|
25
25
|
return "use npm pack as source";
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
constructor(definitions
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
!entryProperties.destination.endsWith("/")
|
|
32
|
-
) {
|
|
33
|
-
entryProperties.destination += "/";
|
|
28
|
+
constructor(definitions) {
|
|
29
|
+
if (definitions?.destination && !definitions.destination.endsWith("/")) {
|
|
30
|
+
definitions.destination += "/";
|
|
34
31
|
}
|
|
35
|
-
super(definitions
|
|
36
|
-
Object.assign(this, definitions);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
toString() {
|
|
40
|
-
return `${this.constructor.name}: ${this.dir} -> ${this.entryProperties.destination}`;
|
|
32
|
+
super(definitions);
|
|
41
33
|
}
|
|
42
34
|
|
|
43
35
|
async *[Symbol.asyncIterator]() {
|
|
@@ -67,23 +67,12 @@ function mergeArchs(a, b) {
|
|
|
67
67
|
*/
|
|
68
68
|
function* content2Sources(content, dir) {
|
|
69
69
|
for (const [destination, definitions] of Object.entries(content)) {
|
|
70
|
-
const allEntryProperties = {};
|
|
71
|
-
|
|
72
|
-
for (const a of entryAttributeNames) {
|
|
73
|
-
if (definitions[a] !== undefined) {
|
|
74
|
-
allEntryProperties[a] = definitions[a];
|
|
75
|
-
delete definitions[a];
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
70
|
for (let definition of asArray(definitions)) {
|
|
80
|
-
const entryProperties = { ...allEntryProperties, destination };
|
|
81
|
-
|
|
82
71
|
if (definition.type) {
|
|
83
72
|
const type = allInputs.find(i => i.name === definition.type);
|
|
84
73
|
if (type) {
|
|
85
74
|
delete definition.type;
|
|
86
|
-
yield new type({ ...definition, dir }
|
|
75
|
+
yield new type({ ...definition, dir, destination });
|
|
87
76
|
} else {
|
|
88
77
|
throw new Error(`Unknown content provider '${type}'`);
|
|
89
78
|
}
|
|
@@ -93,12 +82,12 @@ function* content2Sources(content, dir) {
|
|
|
93
82
|
definition.dir = definition.dir ? join(dir, definition.dir) : dir;
|
|
94
83
|
break;
|
|
95
84
|
case "string":
|
|
96
|
-
definition = join(dir, definition);
|
|
85
|
+
definition = { dir: join(dir, definition) };
|
|
97
86
|
break;
|
|
98
87
|
default:
|
|
99
88
|
throw new Error(`Unsupported content value '${definition}'`);
|
|
100
89
|
}
|
|
101
|
-
yield new FileContentProvider(definition,
|
|
90
|
+
yield new FileContentProvider({ ...definition, destination });
|
|
102
91
|
}
|
|
103
92
|
}
|
|
104
93
|
}
|