npm-pkgbuild 13.0.21 → 13.1.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-pkgbuild",
3
- "version": "13.0.21",
3
+ "version": "13.1.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -39,7 +39,7 @@
39
39
  "npm-pkgbuild": "src/npm-pkgbuild-cli.mjs"
40
40
  },
41
41
  "scripts": {
42
- "prepare": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs --rootDir src",
42
+ "prepare": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types -t esnext -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
43
43
  "test": "npm run test:ava",
44
44
  "test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
45
45
  "cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp",
@@ -11,8 +11,8 @@ import { utf8StreamOptions } from "../util.mjs";
11
11
  import { shrinkNPM } from "../npm-shrink.mjs";
12
12
 
13
13
  /**
14
- * Content from node_modules
15
- *
14
+ * Content from node_modules.
15
+ * Requires .npmrc or NPM_TOKEN environment
16
16
  * @property {boolean} withoutDevelpmentDependencies
17
17
  */
18
18
  export class NodeModulesContentProvider extends ContentProvider {
@@ -71,7 +71,7 @@ export class NodeModulesContentProvider extends ContentProvider {
71
71
  if (process.env.NPM_TOKEN) {
72
72
  npmrc["_authToken"] = process.env.NPM_TOKEN;
73
73
  } else {
74
- throw new Error(`.npmrc not found in ${searchDirs}`);
74
+ throw new Error(`.npmrc not found in ${searchDirs} (neither NPM_TOKEN in envinronment)`);
75
75
  }
76
76
  }
77
77
 
@@ -350,14 +350,29 @@ export async function* extractFromPackage(options = {}, env = {}) {
350
350
  arch
351
351
  );*/
352
352
 
353
+ function* forEachOutput(result) {
354
+ if (Object.entries(result.output).length === 0) {
355
+ yield result;
356
+ }
357
+
358
+ for (const [name, output] of Object.entries(result.output)) {
359
+ yield {
360
+ ...result,
361
+ variant: { ...result.variant, output: name },
362
+ output: { [name]: output },
363
+ properties: { ...result.properties, ...output.properties }
364
+ };
365
+ }
366
+ }
367
+
353
368
  if (arch.size === 0) {
354
- yield result;
369
+ yield* forEachOutput(result);
355
370
  } else {
356
371
  for (const a of [...arch].sort()) {
357
372
  if (variant.restrictArch.size === 0 || variant.restrictArch.has(a)) {
358
373
  result.variant.arch = a;
359
374
  result.properties.arch = [a];
360
- yield result;
375
+ yield* forEachOutput(result);
361
376
  }
362
377
  }
363
378
  }
@@ -88,7 +88,7 @@ program
88
88
  try {
89
89
  Object.assign(
90
90
  properties,
91
- output[outputFactory.name],
91
+ output?.[outputFactory.name]?.properties,
92
92
  {
93
93
  type: outputFactory.name,
94
94
  "user-agent": `npm-pkgbuild-${version}`
@@ -130,7 +130,7 @@ program
130
130
  console.log(" " + sources.join("\n "));
131
131
  console.log("dependencies:");
132
132
  console.log(kv(dependencies, " "));
133
- console.log(kv(output.properties));
133
+ console.log(kv(output));
134
134
  }
135
135
 
136
136
  const fileName = await o.execute(
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Content from node_modules
3
- *
2
+ * Content from node_modules.
3
+ * Requires .npmrc or NPM_TOKEN environment
4
4
  * @property {boolean} withoutDevelpmentDependencies
5
5
  */
6
6
  export class NodeModulesContentProvider extends ContentProvider {