npm-pkgbuild 10.11.3 → 10.12.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  [![npm](https://img.shields.io/npm/v/npm-pkgbuild.svg)](https://www.npmjs.com/package/npm-pkgbuild)
2
2
  [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
3
- [![minified size](https://badgen.net/bundlephobia/min/npm-pkgbuild)](https://bundlephobia.com/result?p=npm-pkgbuild)
3
+ [![Open Bundle](https://bundlejs.com/badge-light.svg)](https://bundlejs.com/?q=npm-pkgbuild)
4
4
  [![downloads](http://img.shields.io/npm/dm/npm-pkgbuild.svg?style=flat-square)](https://npmjs.org/package/npm-pkgbuild)
5
5
  [![GitHub Issues](https://img.shields.io/github/issues/arlac77/npm-pkgbuild.svg?style=flat-square)](https://github.com/arlac77/npm-pkgbuild/issues)
6
6
  [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Farlac77%2Fnpm-pkgbuild%2Fbadge\&style=flat)](https://actions-badge.atrox.dev/arlac77/npm-pkgbuild/goto)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-pkgbuild",
3
- "version": "10.11.3",
3
+ "version": "10.12.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -41,19 +41,19 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@npmcli/arborist": "^5.3.0",
44
- "@vercel/nft": "^0.20.1",
44
+ "@vercel/nft": "^0.21.0",
45
45
  "aggregate-async-iterator": "^1.1.14",
46
- "commander": "^9.3.0",
47
- "content-entry": "^5.0.7",
46
+ "commander": "^9.4.0",
47
+ "content-entry": "^5.0.8",
48
48
  "content-entry-filesystem": "^5.0.8",
49
- "content-entry-transform": "^1.4.9",
49
+ "content-entry-transform": "^1.4.10",
50
50
  "execa": "^6.1.0",
51
51
  "expression-expander": "^7.0.19",
52
52
  "globby": "^13.1.2",
53
53
  "ini": "^3.0.0",
54
54
  "iterable-string-interceptor": "^2.0.4",
55
55
  "key-value-transformer": "^3.0.3",
56
- "node-fetch": "^3.2.8",
56
+ "node-fetch": "^3.2.9",
57
57
  "npm-package-walker": "^6.0.3",
58
58
  "npm-packlist": "^5.1.1",
59
59
  "pacote": "^13.6.1",
@@ -62,7 +62,7 @@
62
62
  },
63
63
  "devDependencies": {
64
64
  "ava": "^4.3.1",
65
- "c8": "^7.11.3",
65
+ "c8": "^7.12.0",
66
66
  "documentation": "^13.2.5",
67
67
  "semantic-release": "^19.0.3",
68
68
  "stream-buffers": "^3.0.2"
@@ -41,8 +41,8 @@ export const npmArchMapping = {
41
41
 
42
42
  /**
43
43
  * Deliver basic properties from the root package
44
- * @param {Object} json content of root package.json
45
- * @returns {Object} key value pairs extracted from json
44
+ * @param {Object} content of root package.json
45
+ * @returns {Object} key value pairs extracted from package
46
46
  */
47
47
  function extractFromRootPackage(json) {
48
48
  const properties = Object.fromEntries(
@@ -140,13 +140,13 @@ function* content2Sources(content, dir) {
140
140
  /**
141
141
  * Extract package definition from package.json.
142
142
  * - for each architecture deliver a new result
143
- * - if not architecture is given one result set is provided nethertheless
143
+ * - if no architecture is given one result set is provided nethertheless
144
144
  * - architectures are taken from cpu (node arch ids) and from pkgbuild.arch (raw arch ids)
145
- * - architecture given in a abstract definition are used to reduce the set of avaliable architectures
145
+ * - architecture given in a abstract definition are used to restrict the set of avaliable architectures
146
146
  * @param {Object} options
147
147
  * @param {Object} options.json package.json content
148
148
  * @param {string} options.dir where to look for package.json
149
- * @returns {AsyncIter<PackageDefinition>}
149
+ * @returns {AsyncIterator<PackageDefinition>}
150
150
  */
151
151
  export async function* extractFromPackage(options = {}) {
152
152
  let variant = "default";
@@ -7,13 +7,14 @@ import {
7
7
  createExpressionTransformer,
8
8
  nameExtensionMatcher
9
9
  } from "content-entry-transform";
10
- import { utf8StreamOptions, decodePassword } from "./util.mjs";
10
+ import { utf8StreamOptions } from "./util.mjs";
11
11
  import {
12
12
  FileContentProvider,
13
13
  allInputs,
14
14
  allOutputs,
15
15
  extractFromPackage,
16
- publish
16
+ publish,
17
+ preparePublish
17
18
  } from "npm-pkgbuild";
18
19
 
19
20
  const { version, description } = JSON.parse(
@@ -51,7 +52,7 @@ program
51
52
  )
52
53
  .action(async options => {
53
54
  try {
54
- options.publish = preparePublish(options.publish);
55
+ options.publish = preparePublish(options.publish, process.env);
55
56
 
56
57
  for await (const {
57
58
  properties,
@@ -136,8 +137,8 @@ program
136
137
  context.expand
137
138
  );
138
139
 
139
- for(const p of options.publish) {
140
- await publish(fileName, p, output.properties );
140
+ for (const p of options.publish) {
141
+ await publish(fileName, p, output.properties);
141
142
  }
142
143
  } catch (e) {
143
144
  handleError(e, options);
@@ -156,24 +157,3 @@ function handleError(e, options) {
156
157
  process.exit(-1);
157
158
  }
158
159
  }
159
-
160
- function preparePublish(publish=[]) {
161
- const e = process.env["PKGBUILD_PUBLISH"]
162
- if(e) {
163
- publish.push(e);
164
- }
165
-
166
- return publish.map(value => {
167
- let values = value.split(/,/);
168
- if (values.length > 1) {
169
- values = values.map(v => process.env[v] || v);
170
- return {
171
- url: values[0],
172
- user: values[1],
173
- password: decodePassword(values[2])
174
- };
175
- }
176
-
177
- return { url: value };
178
- });
179
- }
package/src/publish.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { basename } from "node:path";
2
2
  import { createReadStream } from "node:fs";
3
3
  import fetch from "node-fetch";
4
+ import { decodePassword } from "./util.mjs";
4
5
 
5
6
  export function analysePublish(publish, properties) {
6
7
  publish = Object.assign({}, publish);
@@ -33,10 +34,12 @@ export async function publish(fileName, destination, properties) {
33
34
  "user-agent": properties["user-agent"] || "npm-pkgbuild"
34
35
  };
35
36
 
36
- if (publish.user) {
37
+ if (publish.username) {
37
38
  headers.authorization =
38
39
  "Basic " +
39
- Buffer.from(publish.user + ":" + publish.password).toString("base64");
40
+ Buffer.from(publish.username + ":" + publish.password).toString(
41
+ "base64"
42
+ );
40
43
  }
41
44
 
42
45
  const response = await fetch(url, {
@@ -56,3 +59,41 @@ export async function publish(fileName, destination, properties) {
56
59
  console.log(`#<CI>publish ${fileName}`);
57
60
  */
58
61
  }
62
+
63
+ export function preparePublish(publish = [], env = {}) {
64
+ function vm(k) {
65
+ return env[k] || k;
66
+ }
67
+
68
+ const e = env["PKGBUILD_PUBLISH"];
69
+ if (e) {
70
+ publish.push(e);
71
+ }
72
+
73
+ return publish.map(value => {
74
+ let values = value.split(/,/);
75
+ if (values.length > 1) {
76
+ values = values.map(v => vm(v));
77
+ return {
78
+ url: values[0],
79
+ user: values[1],
80
+ password: decodePassword(values[2])
81
+ };
82
+ }
83
+
84
+ try {
85
+ const url = new URL(value);
86
+ let password = vm(url.password);
87
+ let username = vm(url.username);
88
+ url.username = "";
89
+ url.password = "";
90
+
91
+ return {
92
+ url: url.href.replace(/%7B/g,'{').replace(/%7D/g,'}'),
93
+ ...(username.length ? { username, password } : {})
94
+ };
95
+ } catch {
96
+ return { url: value };
97
+ }
98
+ });
99
+ }