npm-pkgbuild 7.22.9 → 7.23.2

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.22.9",
3
+ "version": "7.23.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -13,7 +13,7 @@ export const allOutputs = [DEB, ARCH, RPM];
13
13
  const npmArchMapping = {
14
14
  arm64: "aarch64",
15
15
  arm: "armv7h",
16
- x86: "x86_64"
16
+ x64: "x86_64"
17
17
  };
18
18
 
19
19
  /**
@@ -53,7 +53,7 @@ program
53
53
  let values = value.split(/,/);
54
54
  if (values.length > 1) {
55
55
  values = values.map(v => process.env[v] || v);
56
- return { url: value[0], user: value[1], password: value[2] };
56
+ return { url: values[0], user: values[1], password: values[2] };
57
57
  }
58
58
 
59
59
  return { url: value };
@@ -129,7 +129,7 @@ program
129
129
 
130
130
  if (options.verbose) {
131
131
  console.log(output.properties);
132
- console.log(`sources: ${sources}`);
132
+ console.log(`sources: ${sources.join('\n ')}`);
133
133
  }
134
134
 
135
135
  const fileName = await output.execute(
@@ -1,4 +1,5 @@
1
1
  import { join } from "path";
2
+ import { createReadStream } from "fs";
2
3
  import { cp } from "fs/promises";
3
4
  import { execa } from "execa";
4
5
  import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
@@ -8,7 +9,22 @@ import {
8
9
  colonSeparatedKeyValuePairOptions
9
10
  } from "key-value-transformer";
10
11
  import { Packager } from "./packager.mjs";
11
- import { copyEntries, fieldProvider } from "../util.mjs";
12
+ import {
13
+ copyEntries,
14
+ fieldProvider,
15
+ utf8StreamOptions,
16
+ extractFunctions
17
+ } from "../util.mjs";
18
+
19
+ /**
20
+ * map install hook named from arch to rpm
21
+ */
22
+ const hookMapping = {
23
+ pre_instll: "pre",
24
+ post_install: "post",
25
+ pre_remove: "preun",
26
+ post_remove: "postun"
27
+ };
12
28
 
13
29
  export class RPM extends Packager {
14
30
  static get name() {
@@ -64,29 +80,40 @@ export class RPM extends Packager {
64
80
 
65
81
  async function* trailingLines() {
66
82
  yield "%define _unpackaged_files_terminate_build 0\n";
67
-
68
- for (const [name, options] of Object.entries(sections)) {
69
- if (options.mandatory) {
70
- yield `%${name}\n\n`;
71
-
72
- if (name === "files") {
73
- for (const file of files) {
74
- yield "/" + file + "\n";
75
- }
76
-
77
- for await (const file of copyEntries(
78
- transform(sources, transformer),
79
- staging,
80
- expander
81
- )) {
82
- if (options.verbose) {
83
- console.log(file.destination);
84
- }
85
- yield file.destination + "\n";
86
- }
83
+ yield `%description\n\n`;
84
+
85
+ if (properties.hooks) {
86
+ for await (const f of extractFunctions(
87
+ createReadStream(properties.hooks, utf8StreamOptions)
88
+ )) {
89
+ const name = hookMapping[f.name];
90
+ if (name) {
91
+ yield `%${name}\n`;
92
+
93
+ yield f.body.replace(
94
+ /\{\{(\w+)\}\}/m,
95
+ (match, key, offset, string) =>
96
+ properties[key] || "{{" + key + "}}"
97
+ ) + "\n\n";
87
98
  }
88
99
  }
89
100
  }
101
+
102
+ yield `%files\n\n`;
103
+ for (const file of files) {
104
+ yield "/" + file + "\n";
105
+ }
106
+
107
+ for await (const file of copyEntries(
108
+ transform(sources, transformer),
109
+ staging,
110
+ expander
111
+ )) {
112
+ if (options.verbose) {
113
+ console.log(file.destination);
114
+ }
115
+ yield file.destination + "\n";
116
+ }
90
117
  }
91
118
 
92
119
  const fp = fieldProvider(properties, fields);
@@ -159,13 +186,3 @@ const fields = {
159
186
  URL: { alias: "homepage", type: "string" },
160
187
  Requires: { type: "string[]" }
161
188
  };
162
-
163
- const sections = {
164
- description: { mandatory: true },
165
- prep: { mandatory: false },
166
- build: { mandatory: false },
167
- install: { mandatory: false },
168
- check: { mandatory: false },
169
- files: { mandatory: true },
170
- changelog: { mandatory: false }
171
- };