npm-pkgbuild 7.21.4 → 7.22.3
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 +2 -2
- package/src/extract-from-package.mjs +3 -3
- package/src/npm-pkgbuild-cli.mjs +10 -10
- package/src/output/packager.mjs +3 -4
- package/src/publish.mjs +13 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.22.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"content-entry-transform": "^1.3.4",
|
|
47
47
|
"execa": "^6.0.0",
|
|
48
48
|
"expression-expander": "^7.0.9",
|
|
49
|
-
"globby": "^
|
|
49
|
+
"globby": "^13.0.0",
|
|
50
50
|
"iterable-string-interceptor": "^1.0.8",
|
|
51
51
|
"key-value-transformer": "^2.0.0",
|
|
52
52
|
"node-fetch": "^3.2.0",
|
|
@@ -62,7 +62,7 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
62
62
|
let output = {};
|
|
63
63
|
let arch = new Set();
|
|
64
64
|
|
|
65
|
-
const processPkg = (pkg, dir) => {
|
|
65
|
+
const processPkg = (pkg, dir, modulePath) => {
|
|
66
66
|
if (pkg.cpu) {
|
|
67
67
|
for (const a of asArray(pkg.cpu)) {
|
|
68
68
|
arch.add(npmArchMapping[a]);
|
|
@@ -84,7 +84,7 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
84
84
|
.filter(([k, v]) => typeof v === "string")
|
|
85
85
|
.forEach(([k, v]) => (properties[k] = v));
|
|
86
86
|
|
|
87
|
-
if (pkgbuild.content) {
|
|
87
|
+
if (pkgbuild.content && !modulePath) {
|
|
88
88
|
Object.entries(pkgbuild.content).forEach(
|
|
89
89
|
([destination, definitions]) => {
|
|
90
90
|
for (const definition of asArray(definitions)) {
|
|
@@ -116,7 +116,7 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
116
116
|
|
|
117
117
|
await packageWalker(async (pkg, base, modulePath) => {
|
|
118
118
|
if (modulePath.length > 0) {
|
|
119
|
-
processPkg(pkg, base);
|
|
119
|
+
processPkg(pkg, base, modulePath);
|
|
120
120
|
}
|
|
121
121
|
return true;
|
|
122
122
|
}, dir);
|
package/src/npm-pkgbuild-cli.mjs
CHANGED
|
@@ -47,18 +47,17 @@ program
|
|
|
47
47
|
)
|
|
48
48
|
.option("-m --meta <dir>", "meta directory", (c, a) => a.concat([c]), [])
|
|
49
49
|
.addOption(
|
|
50
|
-
new program.Option("--publish <url>", "publishing url of the package")
|
|
51
|
-
"PACMAN_PUBLISH"
|
|
52
|
-
|
|
53
|
-
let
|
|
54
|
-
if(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return url;
|
|
50
|
+
new program.Option("--publish <url>", "publishing url of the package")
|
|
51
|
+
.env("PACMAN_PUBLISH")
|
|
52
|
+
.argParser(value => {
|
|
53
|
+
let values = value.split(/,/);
|
|
54
|
+
if (values.length > 1) {
|
|
55
|
+
values = values.map(v => process.env[v] || v);
|
|
56
|
+
return { url: value[0], user: value[1], password: value[2] };
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
return value;
|
|
61
|
-
|
|
59
|
+
return { url: value };
|
|
60
|
+
})
|
|
62
61
|
)
|
|
63
62
|
.action(async options => {
|
|
64
63
|
try {
|
|
@@ -120,6 +119,7 @@ program
|
|
|
120
119
|
".json",
|
|
121
120
|
".html",
|
|
122
121
|
".txt",
|
|
122
|
+
".webmanifest",
|
|
123
123
|
".service",
|
|
124
124
|
".socket"
|
|
125
125
|
]),
|
package/src/output/packager.mjs
CHANGED
|
@@ -58,7 +58,6 @@ export class Packager {
|
|
|
58
58
|
return properties;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
62
61
|
async prepareExecute(options) {
|
|
63
62
|
const tmpdir = await this.tmpdir;
|
|
64
63
|
|
|
@@ -80,13 +79,13 @@ export class Packager {
|
|
|
80
79
|
mkdir(join(tmpdir, d), mdo)
|
|
81
80
|
])) {
|
|
82
81
|
await nd[2];
|
|
83
|
-
out[nd[0]] = nd[1];
|
|
82
|
+
out[nd[0]] = nd[1];
|
|
84
83
|
}
|
|
85
84
|
|
|
86
85
|
if (options.publish) {
|
|
87
|
-
const
|
|
86
|
+
const publish = analysePublish(options.publish, out.properties);
|
|
88
87
|
|
|
89
|
-
out.destination = scheme ===
|
|
88
|
+
out.destination = publish.scheme === "file:" ? publish.url : tmpdir;
|
|
90
89
|
|
|
91
90
|
await mkdir(dirname(out.destination), { recursive: true });
|
|
92
91
|
}
|
package/src/publish.mjs
CHANGED
|
@@ -3,15 +3,16 @@ import { createReadStream } from "fs";
|
|
|
3
3
|
import fetch from "node-fetch";
|
|
4
4
|
|
|
5
5
|
export function analysePublish(publish, properties) {
|
|
6
|
-
publish = publish.replace(
|
|
6
|
+
publish.url = publish.url.replace(
|
|
7
7
|
/\{\{(\w+)\}\}/m,
|
|
8
|
-
(match, key, offset, string) => properties[key]
|
|
8
|
+
(match, key, offset, string) => properties[key] || '{{' + key + '}}'
|
|
9
9
|
);
|
|
10
10
|
|
|
11
|
-
const m = publish.match(/^([\w_\+]+:)\/\/(.*)/);
|
|
12
|
-
const scheme = m ? m[0] : "file:";
|
|
11
|
+
const m = publish.url.match(/^([\w_\+]+:)\/\/(.*)/);
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
publish.scheme = m ? m[1] : "file:";
|
|
14
|
+
|
|
15
|
+
return publish;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export async function publish(fileName, destination, properties) {
|
|
@@ -19,24 +20,24 @@ export async function publish(fileName, destination, properties) {
|
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
const publish = analysePublish(destination, properties);
|
|
23
24
|
|
|
24
|
-
publish = publish + "/" + basename(fileName);
|
|
25
|
+
publish.url = publish.url + "/" + basename(fileName);
|
|
25
26
|
|
|
26
|
-
console.log(publish);
|
|
27
|
+
console.log(publish.url);
|
|
27
28
|
|
|
28
|
-
if (scheme === "http:" || scheme === "https:") {
|
|
29
|
+
if (publish.scheme === "http:" || publish.scheme === "https:") {
|
|
29
30
|
const headers = {};
|
|
30
31
|
|
|
31
|
-
if (
|
|
32
|
+
if (publish.username) {
|
|
32
33
|
headers.authorization =
|
|
33
34
|
"Basic " +
|
|
34
|
-
Buffer.from(
|
|
35
|
+
Buffer.from(publish.username + ":" + publish.password).toString(
|
|
35
36
|
"base64"
|
|
36
37
|
);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
const response = await fetch(publish, {
|
|
40
|
+
const response = await fetch(publish.url, {
|
|
40
41
|
method: "PUT",
|
|
41
42
|
headers,
|
|
42
43
|
body: createReadStream(fileName)
|