npm-pkgbuild 7.27.0 → 7.28.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/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
- * [extractFunctions](#extractfunctions)
56
+ * [decodePassword](#decodepassword)
57
57
  * [Parameters](#parameters-5)
58
- * [fieldProvider](#fieldprovider)
58
+ * [extractFunctions](#extractfunctions)
59
59
  * [Parameters](#parameters-6)
60
- * [Expander](#expander)
60
+ * [fieldProvider](#fieldprovider)
61
61
  * [Parameters](#parameters-7)
62
- * [copyEntries](#copyentries)
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.27.0",
3
+ "version": "7.28.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,13 +1,31 @@
1
1
  import { join } from "path";
2
+ import { createReadStream } from "fs";
2
3
  import { execa } from "execa";
3
- import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
4
+ import {
5
+ EmptyContentEntry,
6
+ ReadableStreamContentEntry,
7
+ StringContentEntry
8
+ } from "content-entry";
4
9
  import {
5
10
  transform,
6
11
  createPropertiesTransformer
7
12
  } from "content-entry-transform";
8
13
  import { keyValueTransformer } from "key-value-transformer";
9
14
  import { Packager } from "./packager.mjs";
10
- import { copyEntries, fieldProvider } from "../util.mjs";
15
+ import {
16
+ copyEntries,
17
+ fieldProvider,
18
+ extractFunctions,
19
+ utf8StreamOptions
20
+ } from "../util.mjs";
21
+
22
+ /**
23
+ * map install hook named from arch to deb
24
+ */
25
+ const hookMapping = {
26
+ post_install: "DEBIAN/postinst",
27
+ post_remove: "DEBIAN/postrm"
28
+ };
11
29
 
12
30
  export class DEB extends Packager {
13
31
  static get name() {
@@ -41,7 +59,36 @@ export class DEB extends Packager {
41
59
  }
42
60
 
43
61
  async execute(sources, transformer, dependencies, options, expander) {
44
- const { properties, staging, destination } = await this.prepareExecute(options);
62
+ const { properties, staging, destination } = await this.prepareExecute(
63
+ options
64
+ );
65
+
66
+ if (properties.hooks) {
67
+ for await (const f of extractFunctions(
68
+ createReadStream(properties.hooks, utf8StreamOptions)
69
+ )) {
70
+ const name = hookMapping[f.name];
71
+ if (name) {
72
+ transformer.push({
73
+ match: entry => entry.name === name,
74
+ transform: async entry =>
75
+ new ReadableStreamContentEntry(
76
+ entry.name,
77
+ keyValueTransformer(await entry.readStream, fp)
78
+ ),
79
+ createEntryWhenMissing: () =>
80
+ new StringContentEntry(
81
+ name,
82
+ f.body.replace(
83
+ /\{\{(\w+)\}\}/m,
84
+ (match, key, offset, string) =>
85
+ properties[key] || "{{" + key + "}}"
86
+ )
87
+ )
88
+ });
89
+ }
90
+ }
91
+ }
45
92
 
46
93
  transformer.push(
47
94
  createPropertiesTransformer(
@@ -20,7 +20,7 @@ import {
20
20
  * map install hook named from arch to rpm
21
21
  */
22
22
  const hookMapping = {
23
- pre_instll: "pre",
23
+ pre_install: "pre",
24
24
  post_install: "post",
25
25
  pre_remove: "preun",
26
26
  post_remove: "postun"