npm-pkgbuild 7.3.7 → 7.3.11
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 +3 -3
- package/src/output/deb.mjs +11 -46
- package/src/util.mjs +31 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.11",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"aggregate-async-iterator": "^1.1.7",
|
|
42
42
|
"commander": "^8.3.0",
|
|
43
|
-
"content-entry": "^2.
|
|
44
|
-
"content-entry-filesystem": "^3.1.
|
|
43
|
+
"content-entry": "^2.10.0",
|
|
44
|
+
"content-entry-filesystem": "^3.1.11",
|
|
45
45
|
"execa": "^6.0.0",
|
|
46
46
|
"expression-expander": "^7.0.9",
|
|
47
47
|
"globby": "^12.0.2",
|
package/src/output/deb.mjs
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { join, dirname } from "path";
|
|
2
2
|
import { tmpdir } from "os";
|
|
3
|
-
import {
|
|
4
|
-
import { mkdtemp, mkdir, chmod } from "fs/promises";
|
|
5
|
-
import { pipeline } from "stream/promises";
|
|
3
|
+
import { mkdtemp } from "fs/promises";
|
|
6
4
|
import { execa } from "execa";
|
|
7
|
-
import { EmptyContentEntry } from "content-entry";
|
|
5
|
+
import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
|
|
8
6
|
import { keyValueTransformer } from "key-value-transformer";
|
|
9
7
|
import { Packager } from "./packager.mjs";
|
|
8
|
+
import { copyEntries, transform } from "../util.mjs";
|
|
10
9
|
|
|
11
|
-
const executableAttributes = {
|
|
10
|
+
const executableAttributes = { mode: 0o775 };
|
|
12
11
|
|
|
13
12
|
const permissions = {
|
|
14
13
|
"DEBIAN/preinst": executableAttributes,
|
|
@@ -58,49 +57,15 @@ export class DEB extends Packager {
|
|
|
58
57
|
{
|
|
59
58
|
match: entry => entry.name === debianControlName,
|
|
60
59
|
transform: async entry =>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
let debianControlEntry;
|
|
67
|
-
|
|
68
|
-
for await (const entry of this.source) {
|
|
69
|
-
const destName = join(staging, entry.name);
|
|
70
|
-
|
|
71
|
-
await mkdir(dirname(destName), { recursive: true });
|
|
72
|
-
|
|
73
|
-
if (entry.name === debianControlName) {
|
|
74
|
-
debianControlEntry = entry;
|
|
75
|
-
} else {
|
|
76
|
-
console.log("ENTRY", entry.name, entry.basename);
|
|
77
|
-
await pipeline(await entry.readStream, createWriteStream(destName));
|
|
78
|
-
|
|
79
|
-
await Promise.all(
|
|
80
|
-
Object.entries(permissions).map(async ([pattern, option]) => {
|
|
81
|
-
if (destName.endsWith(pattern)) {
|
|
82
|
-
return chmod(destName, option.chmod);
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
);
|
|
60
|
+
new ReadableStreamContentEntry(
|
|
61
|
+
entry.name,
|
|
62
|
+
keyValueTransformer(await entry.readStream, controlProperties)
|
|
63
|
+
),
|
|
64
|
+
createEntryWhenMissing: () => new EmptyContentEntry(debianControlName)
|
|
86
65
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (!debianControlEntry) {
|
|
90
|
-
debianControlEntry = new EmptyContentEntry(debianControlName);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
let destName = join(staging, debianControlEntry.name);
|
|
94
|
-
|
|
95
|
-
await mkdir(dirname(destName), { recursive: true });
|
|
66
|
+
];
|
|
96
67
|
|
|
97
|
-
await
|
|
98
|
-
keyValueTransformer(
|
|
99
|
-
await debianControlEntry.readStream,
|
|
100
|
-
controlProperties
|
|
101
|
-
),
|
|
102
|
-
createWriteStream(destName)
|
|
103
|
-
);
|
|
68
|
+
await copyEntries(transform(this.source, transformers), staging);
|
|
104
69
|
|
|
105
70
|
await execa("dpkg", ["-b", staging, options.destination]);
|
|
106
71
|
|
package/src/util.mjs
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { join, dirname } from "path";
|
|
2
|
+
import { mkdir } from "fs/promises";
|
|
3
|
+
import { pipeline } from "stream/promises";
|
|
4
|
+
import { createWriteStream } from "fs";
|
|
5
|
+
|
|
1
6
|
import { FileContentProvider } from "npm-pkgbuild";
|
|
2
7
|
|
|
3
8
|
export const utf8StreamOptions = { encoding: "utf8" };
|
|
@@ -62,25 +67,40 @@ export function extractFromPackage(pkg) {
|
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
/**
|
|
65
|
-
*
|
|
70
|
+
* Apply transformers
|
|
66
71
|
* @param {AsyncIterator<ContentEntry>} source
|
|
67
|
-
* @param {string} destinationDirectory
|
|
68
72
|
* @param {Transformer[]} transformers
|
|
69
73
|
*/
|
|
70
|
-
export async function
|
|
71
|
-
|
|
72
|
-
const destName = join(destinationDirectory, entry.name);
|
|
73
|
-
|
|
74
|
-
await mkdir(dirname(destName), { recursive: true });
|
|
74
|
+
export async function* transform(source, transformers) {
|
|
75
|
+
const usedTransformers = new Set();
|
|
75
76
|
|
|
77
|
+
for await (let entry of source) {
|
|
76
78
|
for (const t of transformers) {
|
|
77
79
|
if (t.match(entry)) {
|
|
78
|
-
t.transform(entry);
|
|
79
|
-
|
|
80
|
-
break;
|
|
80
|
+
entry = await t.transform(entry);
|
|
81
|
+
usedTransformers.add(t);
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
|
|
85
|
+
yield entry;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
for (const t of transformers) {
|
|
89
|
+
if (!usedTransformers.has(t) && t.createEntryWhenMissing !== undefined) {
|
|
90
|
+
yield t.transform(await t.createEntryWhenMissing());
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Copy content from source into destinationDirectory
|
|
97
|
+
* @param {AsyncIterator<ContentEntry>} source
|
|
98
|
+
* @param {string} destinationDirectory
|
|
99
|
+
*/
|
|
100
|
+
export async function copyEntries(source, destinationDirectory) {
|
|
101
|
+
for await (let entry of source) {
|
|
102
|
+
const destName = join(destinationDirectory, entry.name);
|
|
103
|
+
await mkdir(dirname(destName), { recursive: true });
|
|
104
|
+
await pipeline(await entry.readStream, createWriteStream(destName, { mode: entry.mode }));
|
|
85
105
|
}
|
|
86
106
|
}
|