npm-pkgbuild 10.19.0 → 10.19.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/package.json +1 -1
- package/src/extract-from-package.mjs +47 -50
package/package.json
CHANGED
|
@@ -114,9 +114,26 @@ export async function* extractFromPackage(options = {}, env = {}) {
|
|
|
114
114
|
: packageContent.pkgbuild
|
|
115
115
|
? [packageContent.pkgbuild]
|
|
116
116
|
: []) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
const requires = pkgbuild.requires;
|
|
118
|
+
if (requires) {
|
|
119
|
+
if (requires.properties) {
|
|
120
|
+
let fullfilled = true;
|
|
121
|
+
for (const [k, v] of Object.entries(requires.properties)) {
|
|
122
|
+
if (root.properties[k] !== v) {
|
|
123
|
+
fullfilled = false;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (!fullfilled) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
delete pkgbuild.requires;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (requires.environment) {
|
|
134
|
+
if (env[requires.environment.has] === undefined) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
120
137
|
}
|
|
121
138
|
}
|
|
122
139
|
|
|
@@ -132,18 +149,22 @@ export async function* extractFromPackage(options = {}, env = {}) {
|
|
|
132
149
|
fragment.arch.add(npmArchMapping[a]);
|
|
133
150
|
}
|
|
134
151
|
}
|
|
152
|
+
|
|
135
153
|
if (pkgbuild.arch) {
|
|
136
154
|
for (const a of asArray(pkgbuild.arch)) {
|
|
137
|
-
fragment.arch.add(a);
|
|
138
155
|
if (modulePath.length === 0) {
|
|
156
|
+
fragment.arch.add(a);
|
|
157
|
+
} else {
|
|
139
158
|
fragment.restrictArch.add(a);
|
|
140
159
|
}
|
|
141
160
|
}
|
|
142
161
|
delete pkgbuild.arch;
|
|
143
162
|
}
|
|
144
163
|
|
|
145
|
-
|
|
146
|
-
|
|
164
|
+
for (const k of ["hooks"]) {
|
|
165
|
+
if (pkgbuild[k]) {
|
|
166
|
+
pkgbuild[k] = resolve(base, pkgbuild[k]);
|
|
167
|
+
}
|
|
147
168
|
}
|
|
148
169
|
|
|
149
170
|
for (const k of ["output", "content", "depends"]) {
|
|
@@ -159,12 +180,12 @@ export async function* extractFromPackage(options = {}, env = {}) {
|
|
|
159
180
|
},
|
|
160
181
|
packageContent.config,
|
|
161
182
|
modulePath.length === 0 &&
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
pkgbuild
|
|
183
|
+
Object.fromEntries(
|
|
184
|
+
["name", "version", "description", "homepage", "license"]
|
|
185
|
+
.map(key => [key, packageContent[key]])
|
|
186
|
+
.filter(([k, v]) => v !== undefined)
|
|
187
|
+
),
|
|
188
|
+
pkgbuild
|
|
168
189
|
);
|
|
169
190
|
|
|
170
191
|
if (modulePath.length >= 1) {
|
|
@@ -217,10 +238,8 @@ export async function* extractFromPackage(options = {}, env = {}) {
|
|
|
217
238
|
variants.default = root;
|
|
218
239
|
}
|
|
219
240
|
|
|
220
|
-
//console.log(variants);
|
|
221
|
-
|
|
222
241
|
for (const [name, variant] of Object.entries(variants)) {
|
|
223
|
-
|
|
242
|
+
let arch = [...variant.arch];
|
|
224
243
|
const properties = {};
|
|
225
244
|
const depends = {};
|
|
226
245
|
const output = {};
|
|
@@ -236,12 +255,15 @@ export async function* extractFromPackage(options = {}, env = {}) {
|
|
|
236
255
|
Object.assign(properties, fragment.properties);
|
|
237
256
|
Object.assign(depends, fragment.depends);
|
|
238
257
|
Object.assign(output, fragment.output);
|
|
258
|
+
arch = new Set([...arch, ...fragment.arch]);
|
|
239
259
|
|
|
240
260
|
sources.push(
|
|
241
261
|
...content2Sources(context.expand(fragment.content), fragment.dir)
|
|
242
262
|
);
|
|
243
263
|
}
|
|
244
264
|
|
|
265
|
+
arch = [...arch].sort();
|
|
266
|
+
|
|
245
267
|
properties.variant = name;
|
|
246
268
|
|
|
247
269
|
const context = createContext({ properties });
|
|
@@ -253,45 +275,20 @@ export async function* extractFromPackage(options = {}, env = {}) {
|
|
|
253
275
|
output,
|
|
254
276
|
dependencies: depends,
|
|
255
277
|
properties: context.expand(properties)
|
|
256
|
-
|
|
278
|
+
};
|
|
257
279
|
|
|
258
|
-
if(arch.length === 0) {
|
|
280
|
+
if (arch.length === 0) {
|
|
259
281
|
yield result;
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
282
|
+
} else {
|
|
262
283
|
for (const a of arch) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
/*
|
|
271
|
-
let numberOfArchs = 0;
|
|
272
|
-
|
|
273
|
-
for (const a of arch) {
|
|
274
|
-
if (!restrictArch.size || restrictArch.has(a)) {
|
|
275
|
-
if (!options.prepare || npmArchMapping[process.arch] === a) {
|
|
276
|
-
numberOfArchs++;
|
|
277
|
-
properties.arch = [a];
|
|
278
|
-
yield {
|
|
279
|
-
properties: context.expand(properties),
|
|
280
|
-
sources,
|
|
281
|
-
dependencies,
|
|
282
|
-
output,
|
|
283
|
-
variant: { name: variant, arch, type: Object.keys(output) },
|
|
284
|
-
context
|
|
285
|
-
};
|
|
284
|
+
if (variant.restrictArch.size && !variant.restrictArch.has(a)) {
|
|
285
|
+
console.log("RESTRICT", a);
|
|
286
|
+
} else {
|
|
287
|
+
result.variant.arch = a;
|
|
288
|
+
result.properties.arch = [a];
|
|
289
|
+
yield result;
|
|
286
290
|
}
|
|
287
291
|
}
|
|
288
292
|
}
|
|
289
|
-
|
|
290
|
-
console.warn(
|
|
291
|
-
`No arch remaining, ${[...arch]} : ${[...restrictArch]} : ${
|
|
292
|
-
process.arch
|
|
293
|
-
}`
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
*/
|
|
293
|
+
}
|
|
297
294
|
}
|