npm-pkgbuild 7.14.10 → 7.14.14

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.10",
3
+ "version": "7.14.14",
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": "^3.0.1",
44
- "content-entry-filesystem": "^3.1.14",
43
+ "content-entry": "^3.0.3",
44
+ "content-entry-filesystem": "^3.1.15",
45
45
  "execa": "^6.0.0",
46
46
  "expression-expander": "^7.0.9",
47
47
  "globby": "^12.0.2",
@@ -54,7 +54,7 @@
54
54
  "tar-stream": "^2.2.0"
55
55
  },
56
56
  "devDependencies": {
57
- "ava": "^4.0.0",
57
+ "ava": "^4.0.1",
58
58
  "c8": "^7.11.0",
59
59
  "documentation": "^13.2.5",
60
60
  "semantic-release": "^18.0.1",
@@ -10,6 +10,12 @@ import { RPM } from "./output/rpm.mjs";
10
10
  export const allInputs = [NPMPackContentProvider, NodeModulesContentProvider];
11
11
  export const allOutputs = [DEB, ARCH, RPM];
12
12
 
13
+ const npmArchMapping = {
14
+ "arm64" : "aarch64",
15
+ "armv7h": "armv7h",
16
+ "x86" : "a86_64"
17
+ };
18
+
13
19
  /**
14
20
  * Extract package definition from package.json.
15
21
  * @param {Object} pkg package.json content
@@ -54,11 +60,11 @@ export async function extractFromPackage(pkg, dir) {
54
60
 
55
61
  const processPkg = (pkg, dir) => {
56
62
 
57
- if(pkg.cpu) {
58
- for(const a of asArray(pkg.cpu)) {
59
- arch.add(a);
60
- }
61
- }
63
+ if(pkg.cpu) {
64
+ for(const a of asArray(pkg.cpu)) {
65
+ arch.add(npmArchMapping[a]);
66
+ }
67
+ }
62
68
 
63
69
  if (pkg.pkg) {
64
70
  const pkgbuild = pkg.pkg;
@@ -9,8 +9,14 @@ import {
9
9
  equalSeparatedKeyValuePairOptions
10
10
  } from "key-value-transformer";
11
11
  import { Packager } from "./packager.mjs";
12
- import { copyEntries, transform, fieldProvider } from "../util.mjs";
13
- import { quote, utf8StreamOptions } from "../util.mjs";
12
+ import {
13
+ copyEntries,
14
+ transform,
15
+ fieldProvider,
16
+ createPropertiesInterceptor,
17
+ quote,
18
+ utf8StreamOptions
19
+ } from "../util.mjs";
14
20
 
15
21
  /**
16
22
  * @type KeyValueTransformOptions
@@ -43,8 +49,7 @@ export class ARCH extends Packager {
43
49
  return "arch";
44
50
  }
45
51
 
46
- static get description()
47
- {
52
+ static get description() {
48
53
  return "generate Arch-Linux package";
49
54
  }
50
55
 
@@ -89,18 +94,13 @@ package() {
89
94
  }
90
95
 
91
96
  if (properties.hooks) {
92
- async function* transformer(expression, remainder, source, cb) {
93
- const value = properties[expression];
94
- yield value === undefined ? "" : value;
95
- }
96
-
97
97
  await pipeline(
98
98
  iterableStringInterceptor(
99
99
  createReadStream(
100
100
  join(options.pkgdir, properties.hooks),
101
101
  utf8StreamOptions
102
102
  ),
103
- transformer
103
+ createPropertiesInterceptor(properties)
104
104
  ),
105
105
  createWriteStream(join(staging, properties.install), utf8StreamOptions)
106
106
  );
@@ -109,6 +109,7 @@ package() {
109
109
  const fp = fieldProvider(properties, fields);
110
110
 
111
111
  transformer.push({
112
+ name: "PKGBUILD",
112
113
  match: entry => entry.name === "PKGBUILD",
113
114
  transform: async entry =>
114
115
  new ReadableStreamContentEntry(
@@ -32,7 +32,7 @@ export class DEB extends Packager {
32
32
  const properties = this.properties;
33
33
  const staging = await this.tmpdir;
34
34
 
35
- transformer.push(createModeTransformer(0o775, entry => entry.name.match(/DEBIAN\/.*(inst|rm)/)));
35
+ transformer.push(createModeTransformer(0o775, entry => entry.name.match(/DEBIAN\/.*(inst|rm)/) ? true: false));
36
36
 
37
37
  const fp = fieldProvider(properties, fields);
38
38
  const debianControlName = "DEBIAN/control";
package/src/util.mjs CHANGED
@@ -58,35 +58,41 @@ export function fieldProvider(properties, fields) {
58
58
  };
59
59
  }
60
60
 
61
-
62
61
  export function createModeTransformer(mode, match) {
63
62
  return {
63
+ name: "mode",
64
64
  match,
65
65
  transform: async entry => Object.create(entry, { mode: { value: mode } })
66
66
  };
67
67
  }
68
68
 
69
- export function createExpressionTransformer(
70
- properties,
71
- match = entry => entry.name.match(/\.(conf|json|html|txt|service|socket)$/)
72
- ) {
73
- async function* transformer(expression, remainder, source, cb) {
69
+ export function createPropertiesInterceptor(properties) {
70
+ return async function* transformer(expression, remainder, source, cb) {
74
71
  const value = properties[expression];
75
72
  yield value === undefined ? "" : value;
76
- }
73
+ };
74
+ }
77
75
 
76
+ export function createExpressionTransformer(
77
+ properties,
78
+ match = entry =>
79
+ entry.name.match(/\.(conf|json|html|txt|service|socket)$/) ? true : false
80
+ ) {
78
81
  return {
82
+ name: "expression",
79
83
  match,
80
84
  transform: async entry => {
85
+ //console.log("TRANSFORM",entry.name);
81
86
  const ne = new ReadableStreamContentEntry(
82
87
  entry.name,
83
88
  iterableStringInterceptor(
84
89
  await entry.getReadStream(utf8StreamOptions),
85
- transformer
90
+ createPropertiesInterceptor(properties)
86
91
  )
87
92
  );
88
93
  ne.destination = entry.destination; // TODO all the other attributes ?
89
94
  return ne;
95
+ //return Object.assign(entry,ne);
90
96
  }
91
97
  };
92
98
  }
@@ -101,18 +107,17 @@ export async function* transform(source, transformers = [], onlyMatching) {
101
107
  const usedTransformers = new Set();
102
108
 
103
109
  for await (let entry of source) {
110
+ let didMatch = false;
104
111
  for (const t of transformers) {
112
+ //console.log(t.name,entry.name,t.match(entry));
105
113
  if (t.match(entry)) {
114
+ didMatch = true;
106
115
  entry = await t.transform(entry);
107
116
  usedTransformers.add(t);
108
-
109
- if (onlyMatching) {
110
- yield entry;
111
- }
112
117
  }
113
118
  }
114
119
 
115
- if (!onlyMatching) {
120
+ if ((onlyMatching && didMatch) || !onlyMatching) {
116
121
  yield entry;
117
122
  }
118
123
  }