npm-pkgbuild 7.14.15 → 7.15.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": "7.14.15",
3
+ "version": "7.15.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -42,6 +42,7 @@
42
42
  "commander": "^8.3.0",
43
43
  "content-entry": "^4.0.0",
44
44
  "content-entry-filesystem": "^4.0.0",
45
+ "content-entry-transform": "^1.2.0",
45
46
  "execa": "^6.0.0",
46
47
  "expression-expander": "^7.0.9",
47
48
  "globby": "^12.0.2",
@@ -3,6 +3,7 @@ import { createReadStream, createWriteStream } from "fs";
3
3
  import { pipeline } from "stream/promises";
4
4
  import { execa } from "execa";
5
5
  import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
6
+ import { transform } from "content-entry-transform";
6
7
  import { iterableStringInterceptor } from "iterable-string-interceptor";
7
8
  import {
8
9
  keyValueTransformer,
@@ -11,7 +12,6 @@ import {
11
12
  import { Packager } from "./packager.mjs";
12
13
  import {
13
14
  copyEntries,
14
- transform,
15
15
  fieldProvider,
16
16
  createPropertiesInterceptor,
17
17
  quote,
@@ -1,17 +1,20 @@
1
1
  import { join } from "path";
2
2
  import { execa } from "execa";
3
3
  import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
4
+ import {
5
+ transform,
6
+ createPropertiesTransformer
7
+ } from "content-entry-transform";
4
8
  import { keyValueTransformer } from "key-value-transformer";
5
9
  import { Packager } from "./packager.mjs";
6
- import { copyEntries, transform, fieldProvider, createModeTransformer } from "../util.mjs";
10
+ import { copyEntries, fieldProvider } from "../util.mjs";
7
11
 
8
12
  export class DEB extends Packager {
9
13
  static get name() {
10
14
  return "deb";
11
15
  }
12
16
 
13
- static get description()
14
- {
17
+ static get description() {
15
18
  return "generate Debian package";
16
19
  }
17
20
 
@@ -32,35 +35,40 @@ export class DEB extends Packager {
32
35
  const properties = this.properties;
33
36
  const staging = await this.tmpdir;
34
37
 
35
- transformer.push(createModeTransformer(0o775, entry => entry.name.match(/DEBIAN\/.*(inst|rm)/) ? true: false));
38
+ transformer.push(
39
+ createPropertiesTransformer(
40
+ entry => (entry.name.match(/DEBIAN\/.*(inst|rm)/) ? true : false),
41
+ { mode: { value: 0o775 } },
42
+ "mode"
43
+ )
44
+ );
36
45
 
37
46
  const fp = fieldProvider(properties, fields);
38
47
  const debianControlName = "DEBIAN/control";
39
-
40
- transformer.push(
41
- {
42
- match: entry => entry.name === debianControlName,
43
- transform: async entry =>
44
- new ReadableStreamContentEntry(
45
- entry.name,
46
- keyValueTransformer(await entry.readStream, fp)
47
- ),
48
- createEntryWhenMissing: () => new EmptyContentEntry(debianControlName)
49
- });
50
-
51
- for await (const file of copyEntries(
52
- transform(sources, transformer),
53
- staging,
54
- expander
55
- )) {
56
- if (options.verbose) {
57
- console.log(file.destination);
58
- }
48
+
49
+ transformer.push({
50
+ match: entry => entry.name === debianControlName,
51
+ transform: async entry =>
52
+ new ReadableStreamContentEntry(
53
+ entry.name,
54
+ keyValueTransformer(await entry.readStream, fp)
55
+ ),
56
+ createEntryWhenMissing: () => new EmptyContentEntry(debianControlName)
57
+ });
58
+
59
+ for await (const file of copyEntries(
60
+ transform(sources, transformer),
61
+ staging,
62
+ expander
63
+ )) {
64
+ if (options.verbose) {
65
+ console.log(file.destination);
59
66
  }
60
-
67
+ }
68
+
61
69
  const dpkg = await execa("dpkg", ["-b", staging, options.destination]);
62
70
 
63
- if(options.verbose) {
71
+ if (options.verbose) {
64
72
  console.log(dpkg.stdout);
65
73
  }
66
74
 
@@ -2,12 +2,13 @@ import { join } from "path";
2
2
  import { mkdir, cp } from "fs/promises";
3
3
  import { execa } from "execa";
4
4
  import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
5
+ import { transform } from "content-entry-transform";
5
6
  import {
6
7
  keyValueTransformer,
7
8
  colonSeparatedKeyValuePairOptions
8
9
  } from "key-value-transformer";
9
10
  import { Packager } from "./packager.mjs";
10
- import { copyEntries, transform, fieldProvider } from "../util.mjs";
11
+ import { copyEntries, fieldProvider } from "../util.mjs";
11
12
 
12
13
  export class RPM extends Packager {
13
14
  static get name() {
package/src/util.mjs CHANGED
@@ -58,14 +58,6 @@ export function fieldProvider(properties, fields) {
58
58
  };
59
59
  }
60
60
 
61
- export function createModeTransformer(mode, match) {
62
- return {
63
- name: "mode",
64
- match,
65
- transform: async entry => Object.create(entry, { mode: { value: mode } })
66
- };
67
- }
68
-
69
61
  export function createPropertiesInterceptor(properties) {
70
62
  return async function* transformer(expression, remainder, source, cb) {
71
63
  const value = properties[expression];
@@ -97,38 +89,6 @@ export function createExpressionTransformer(
97
89
  };
98
90
  }
99
91
 
100
- /**
101
- * Apply transformers.
102
- * @param {AsyncIterator<ContentEntry>} source
103
- * @param {Transformer[]} transformers
104
- * @param {Boolean]} onlyMatching filter out all none matching entries
105
- */
106
- export async function* transform(source, transformers = [], onlyMatching) {
107
- const usedTransformers = new Set();
108
-
109
- for await (let entry of source) {
110
- let didMatch = false;
111
- for (const t of transformers) {
112
- //console.log(t.name,entry.name,t.match(entry));
113
- if (t.match(entry)) {
114
- didMatch = true;
115
- entry = await t.transform(entry);
116
- usedTransformers.add(t);
117
- }
118
- }
119
-
120
- if ((onlyMatching && didMatch) || !onlyMatching) {
121
- yield entry;
122
- }
123
- }
124
-
125
- for (const t of transformers) {
126
- if (!usedTransformers.has(t) && t.createEntryWhenMissing !== undefined) {
127
- yield t.transform(await t.createEntryWhenMissing());
128
- }
129
- }
130
- }
131
-
132
92
  /**
133
93
  * @typedef {Function} Expander
134
94
  * @param {string} path