npm-pkgbuild 10.19.4 → 10.19.7
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 +1 -1
- package/src/extract-from-package.mjs +38 -42
package/package.json
CHANGED
|
@@ -51,31 +51,29 @@ const entryAttributeNames = ["owner", "group", "mode"];
|
|
|
51
51
|
* @returns {Iterator<ContentProvider>}
|
|
52
52
|
*/
|
|
53
53
|
function* content2Sources(content, dir) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
delete definitions[a];
|
|
62
|
-
}
|
|
54
|
+
for (const [destination, definitions] of Object.entries(content)) {
|
|
55
|
+
const allEntryProperties = {};
|
|
56
|
+
|
|
57
|
+
for (const a of entryAttributeNames) {
|
|
58
|
+
if (definitions[a] !== undefined) {
|
|
59
|
+
allEntryProperties[a] = definitions[a];
|
|
60
|
+
delete definitions[a];
|
|
63
61
|
}
|
|
62
|
+
}
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
for (const definition of asArray(definitions)) {
|
|
65
|
+
const entryProperties = { ...allEntryProperties, destination };
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} else {
|
|
74
|
-
console.error(`Unknown type '${type}'`);
|
|
75
|
-
}
|
|
67
|
+
if (definition.type) {
|
|
68
|
+
const type = allInputs.find(i => i.name === definition.type);
|
|
69
|
+
if (type) {
|
|
70
|
+
delete definition.type;
|
|
71
|
+
yield new type({ ...definition, dir }, entryProperties);
|
|
76
72
|
} else {
|
|
77
|
-
|
|
73
|
+
console.error(`Unknown type '${type}'`);
|
|
78
74
|
}
|
|
75
|
+
} else {
|
|
76
|
+
yield new FileContentProvider(definition, entryProperties);
|
|
79
77
|
}
|
|
80
78
|
}
|
|
81
79
|
}
|
|
@@ -167,10 +165,12 @@ export async function* extractFromPackage(options = {}, env = {}) {
|
|
|
167
165
|
}
|
|
168
166
|
}
|
|
169
167
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
168
|
+
if (modulePath.length === 0 || pkgbuild.variant) {
|
|
169
|
+
for (const k of ["output", "content", "depends"]) {
|
|
170
|
+
if (pkgbuild[k]) {
|
|
171
|
+
fragment[k] = pkgbuild[k];
|
|
172
|
+
delete pkgbuild[k];
|
|
173
|
+
}
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
@@ -191,12 +191,6 @@ export async function* extractFromPackage(options = {}, env = {}) {
|
|
|
191
191
|
if (modulePath.length >= 1) {
|
|
192
192
|
fragment.parent =
|
|
193
193
|
modulePath.length === 1 ? parent : modulePath[modulePath.length - 2];
|
|
194
|
-
/*console.log(
|
|
195
|
-
"FRAGMENT",
|
|
196
|
-
fragment.name,
|
|
197
|
-
fragment.parent,
|
|
198
|
-
fragments[fragment.parent] ? "exists" : "missing"
|
|
199
|
-
);*/
|
|
200
194
|
} else {
|
|
201
195
|
if (properties.name) {
|
|
202
196
|
properties.name = properties.name.replace(/^\@[^\/]+\//, "");
|
|
@@ -243,39 +237,41 @@ export async function* extractFromPackage(options = {}, env = {}) {
|
|
|
243
237
|
if (root && Object.keys(variants).length === 0) {
|
|
244
238
|
variants.default = root;
|
|
245
239
|
}
|
|
246
|
-
|
|
247
|
-
console.log("FRAGMENTS", Object.keys(fragments));
|
|
248
|
-
console.log("VARIANTS", variants);
|
|
249
|
-
*/
|
|
240
|
+
|
|
241
|
+
//console.log("FRAGMENTS", Object.keys(fragments));
|
|
242
|
+
//console.log("VARIANTS", variants);
|
|
250
243
|
|
|
251
244
|
for (const [name, variant] of Object.entries(variants)) {
|
|
252
245
|
let arch = variant.arch;
|
|
253
246
|
const properties = {};
|
|
254
247
|
const depends = {};
|
|
255
248
|
const output = {};
|
|
256
|
-
const
|
|
249
|
+
const content = [];
|
|
257
250
|
|
|
258
251
|
for (
|
|
259
252
|
let fragment = variant;
|
|
260
253
|
fragment;
|
|
261
254
|
fragment = fragments[fragment.parent]
|
|
262
255
|
) {
|
|
263
|
-
|
|
264
|
-
|
|
256
|
+
arch = new Set([...arch, ...fragment.arch]);
|
|
265
257
|
Object.assign(properties, fragment.properties);
|
|
266
258
|
Object.assign(depends, fragment.depends);
|
|
267
259
|
Object.assign(output, fragment.output);
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
...content2Sources(context.expand(fragment.content), fragment.dir)
|
|
272
|
-
);
|
|
260
|
+
if (fragment.content) {
|
|
261
|
+
content.push(fragment.content);
|
|
262
|
+
}
|
|
273
263
|
}
|
|
274
264
|
|
|
275
265
|
properties.variant = name;
|
|
276
266
|
|
|
277
267
|
const context = createContext({ properties });
|
|
278
268
|
|
|
269
|
+
const sources = [];
|
|
270
|
+
|
|
271
|
+
for (const s of context.expand(content)) {
|
|
272
|
+
sources.push(...content2Sources(s, root.dir));
|
|
273
|
+
}
|
|
274
|
+
|
|
279
275
|
const result = {
|
|
280
276
|
context,
|
|
281
277
|
variant: { name },
|