npm-pkgbuild 7.26.2 → 7.28.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/README.md +16 -4
- package/package.json +3 -3
- package/src/npm-pkgbuild-cli.mjs +3 -15
- package/src/output/deb.mjs +39 -2
- package/src/output/rpm.mjs +1 -1
- package/src/util.mjs +20 -0
package/README.md
CHANGED
|
@@ -53,14 +53,16 @@ The resulting pkg will contain the package dist content and all production depen
|
|
|
53
53
|
* [execute](#execute)
|
|
54
54
|
* [Parameters](#parameters-4)
|
|
55
55
|
* [hookMapping](#hookmapping)
|
|
56
|
-
* [
|
|
56
|
+
* [decodePassword](#decodepassword)
|
|
57
57
|
* [Parameters](#parameters-5)
|
|
58
|
-
* [
|
|
58
|
+
* [extractFunctions](#extractfunctions)
|
|
59
59
|
* [Parameters](#parameters-6)
|
|
60
|
-
* [
|
|
60
|
+
* [fieldProvider](#fieldprovider)
|
|
61
61
|
* [Parameters](#parameters-7)
|
|
62
|
-
* [
|
|
62
|
+
* [Expander](#expander)
|
|
63
63
|
* [Parameters](#parameters-8)
|
|
64
|
+
* [copyEntries](#copyentries)
|
|
65
|
+
* [Parameters](#parameters-9)
|
|
64
66
|
|
|
65
67
|
## ContentProvider
|
|
66
68
|
|
|
@@ -175,6 +177,16 @@ Execute package generation
|
|
|
175
177
|
|
|
176
178
|
map install hook named from arch to rpm
|
|
177
179
|
|
|
180
|
+
## decodePassword
|
|
181
|
+
|
|
182
|
+
Decode a password
|
|
183
|
+
|
|
184
|
+
### Parameters
|
|
185
|
+
|
|
186
|
+
* `password` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
|
187
|
+
|
|
188
|
+
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** plaintext password
|
|
189
|
+
|
|
178
190
|
## extractFunctions
|
|
179
191
|
|
|
180
192
|
Extract shell functions from a given text
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.28.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"lint:docs": "documentation lint ./src/**/*.mjs"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@npmcli/arborist": "^5.0.
|
|
41
|
+
"@npmcli/arborist": "^5.0.2",
|
|
42
42
|
"aggregate-async-iterator": "^1.1.9",
|
|
43
43
|
"commander": "^9.0.0",
|
|
44
44
|
"content-entry": "^4.1.7",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"node-fetch": "^3.2.3",
|
|
53
53
|
"npm-package-walker": "^5.0.5",
|
|
54
54
|
"npm-packlist": "^4.0.0",
|
|
55
|
-
"pacote": "^13.0.
|
|
55
|
+
"pacote": "^13.0.4",
|
|
56
56
|
"pkg-dir": "^6.0.1",
|
|
57
57
|
"tar-stream": "^2.2.0"
|
|
58
58
|
},
|
package/src/npm-pkgbuild-cli.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
createExpressionTransformer,
|
|
12
12
|
nameExtensionMatcher
|
|
13
13
|
} from "content-entry-transform";
|
|
14
|
-
import { utf8StreamOptions } from "./util.mjs";
|
|
14
|
+
import { utf8StreamOptions, decodePassword } from "./util.mjs";
|
|
15
15
|
import {
|
|
16
16
|
FileContentProvider,
|
|
17
17
|
allInputs,
|
|
@@ -51,19 +51,7 @@ program
|
|
|
51
51
|
let values = value.split(/,/);
|
|
52
52
|
if (values.length > 1) {
|
|
53
53
|
values = values.map(v => process.env[v] || v);
|
|
54
|
-
|
|
55
|
-
const m = password.match(/\{([^\}]+)\}(.*)/);
|
|
56
|
-
if (m) {
|
|
57
|
-
switch (m[1]) {
|
|
58
|
-
case "BASE64":
|
|
59
|
-
password = Buffer.from(m[2], "base64").toString("utf8");
|
|
60
|
-
break;
|
|
61
|
-
default:
|
|
62
|
-
console.log(`Unknown algorithm ${m[1]}`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return { url: values[0], user: values[1], password };
|
|
54
|
+
return { url: values[0], user: values[1], password: decodePassword(values[2]) };
|
|
67
55
|
}
|
|
68
56
|
|
|
69
57
|
return { url: value };
|
|
@@ -98,7 +86,7 @@ program
|
|
|
98
86
|
continute;
|
|
99
87
|
}
|
|
100
88
|
|
|
101
|
-
Object.assign(properties, options.define);
|
|
89
|
+
Object.assign(properties, { type: outputFactory.name }, options.define);
|
|
102
90
|
|
|
103
91
|
for (const [k, v] of Object.entries(properties)) {
|
|
104
92
|
if (typeof v === "string") {
|
package/src/output/deb.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
2
|
import { execa } from "execa";
|
|
3
|
-
import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
|
|
3
|
+
import { EmptyContentEntry, ReadableStreamContentEntry, StringContentEntry } from "content-entry";
|
|
4
4
|
import {
|
|
5
5
|
transform,
|
|
6
6
|
createPropertiesTransformer
|
|
@@ -9,6 +9,14 @@ import { keyValueTransformer } from "key-value-transformer";
|
|
|
9
9
|
import { Packager } from "./packager.mjs";
|
|
10
10
|
import { copyEntries, fieldProvider } from "../util.mjs";
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* map install hook named from arch to deb
|
|
14
|
+
*/
|
|
15
|
+
const hookMapping = {
|
|
16
|
+
post_install: "DEBIAN/postinst",
|
|
17
|
+
post_remove: "DEBIAN/postrm"
|
|
18
|
+
};
|
|
19
|
+
|
|
12
20
|
export class DEB extends Packager {
|
|
13
21
|
static get name() {
|
|
14
22
|
return "deb";
|
|
@@ -41,7 +49,9 @@ export class DEB extends Packager {
|
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
async execute(sources, transformer, dependencies, options, expander) {
|
|
44
|
-
const { properties, staging, destination } = await this.prepareExecute(
|
|
52
|
+
const { properties, staging, destination } = await this.prepareExecute(
|
|
53
|
+
options
|
|
54
|
+
);
|
|
45
55
|
|
|
46
56
|
transformer.push(
|
|
47
57
|
createPropertiesTransformer(
|
|
@@ -51,6 +61,33 @@ export class DEB extends Packager {
|
|
|
51
61
|
)
|
|
52
62
|
);
|
|
53
63
|
|
|
64
|
+
if (properties.hooks) {
|
|
65
|
+
for await (const f of extractFunctions(
|
|
66
|
+
createReadStream(properties.hooks, utf8StreamOptions)
|
|
67
|
+
)) {
|
|
68
|
+
const name = hookMapping[f.name];
|
|
69
|
+
if (name) {
|
|
70
|
+
transformer.push({
|
|
71
|
+
match: entry => entry.name === name,
|
|
72
|
+
transform: async entry =>
|
|
73
|
+
new ReadableStreamContentEntry(
|
|
74
|
+
entry.name,
|
|
75
|
+
keyValueTransformer(await entry.readStream, fp)
|
|
76
|
+
),
|
|
77
|
+
createEntryWhenMissing: () =>
|
|
78
|
+
new StringContentEntry(
|
|
79
|
+
name,
|
|
80
|
+
f.body.replace(
|
|
81
|
+
/\{\{(\w+)\}\}/m,
|
|
82
|
+
(match, key, offset, string) =>
|
|
83
|
+
properties[key] || "{{" + key + "}}"
|
|
84
|
+
)
|
|
85
|
+
)
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
54
91
|
const fp = fieldProvider(properties, fields);
|
|
55
92
|
const debianControlName = "DEBIAN/control";
|
|
56
93
|
|
package/src/output/rpm.mjs
CHANGED
package/src/util.mjs
CHANGED
|
@@ -5,6 +5,26 @@ import { createWriteStream } from "fs";
|
|
|
5
5
|
|
|
6
6
|
export const utf8StreamOptions = { encoding: "utf8" };
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Decode a password
|
|
10
|
+
* @param {string} password
|
|
11
|
+
* @returns {string} plaintext password
|
|
12
|
+
*/
|
|
13
|
+
export function decodePassword(password)
|
|
14
|
+
{
|
|
15
|
+
const m = password.match(/\{([^\}]+)\}(.*)/);
|
|
16
|
+
if (m) {
|
|
17
|
+
switch (m[1]) {
|
|
18
|
+
case "BASE64":
|
|
19
|
+
return Buffer.from(m[2], "base64").toString("utf8");
|
|
20
|
+
break;
|
|
21
|
+
default:
|
|
22
|
+
throw new Error(`Unknown algorithm ${m[1]}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return password;
|
|
26
|
+
}
|
|
27
|
+
|
|
8
28
|
/**
|
|
9
29
|
* Extract shell functions from a given text
|
|
10
30
|
* @param {AsyncIterator<string>} source
|