npm-pkgbuild 7.7.1 → 7.7.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
@@ -11,7 +11,7 @@
11
11
 
12
12
  ## npm-pkgbuild
13
13
 
14
- create ArchLinux packages from npm packages
14
+ create ArchLinux, RPM and debian packages from npm packages.
15
15
 
16
16
  # usage
17
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-pkgbuild",
3
- "version": "7.7.1",
3
+ "version": "7.7.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -8,7 +8,7 @@
8
8
  "exports": {
9
9
  ".": "./src/module.mjs"
10
10
  },
11
- "description": "create packages from npm packages",
11
+ "description": "create ArchLinux, RPM and debian packages from npm packages",
12
12
  "keywords": [
13
13
  "ArchLinux",
14
14
  "arch-linux",
@@ -7,7 +7,7 @@ import {
7
7
  } from "key-value-transformer";
8
8
  import { Packager } from "./packager.mjs";
9
9
  import { copyEntries, transform } from "../util.mjs";
10
- import { quote, createPropertyTransformer } from "../util.mjs";
10
+ import { quote, createExpressionTransformer } from "../util.mjs";
11
11
 
12
12
  /**
13
13
  * @type KeyValueTransformOptions
@@ -77,10 +77,9 @@ package() {
77
77
  `;
78
78
  }
79
79
 
80
- await copyEntries(transform(sources, []), join(staging, "src"), expander);
80
+ await copyEntries(transform(sources, [createExpressionTransformer(properties)]), join(staging, "src"), expander);
81
81
 
82
82
  const metaTransformers = [
83
- createPropertyTransformer(properties),
84
83
  {
85
84
  match: entry => entry.name === "PKGBUILD",
86
85
  transform: async entry =>
@@ -1,5 +1,5 @@
1
1
  import { join } from "path";
2
- import { mkdir } from "fs/promises";
2
+ import { mkdir, cp } from "fs/promises";
3
3
  import { execa } from "execa";
4
4
  import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
5
5
  import {
@@ -78,7 +78,7 @@ export class RPM extends Packager {
78
78
 
79
79
  await copyEntries(transform(sources, transformers), staging, expander);
80
80
 
81
- await execa("rpmbuild", [
81
+ const rpmbuild = await execa("rpmbuild", [
82
82
  "--define",
83
83
  `_topdir ${tmp}`,
84
84
  "-vv",
@@ -86,6 +86,11 @@ export class RPM extends Packager {
86
86
  join(staging, specFileName)
87
87
  ]);
88
88
 
89
+ await cp(
90
+ join(tmp, "RPMS", properties.arch, this.packageFileName),
91
+ join(options.destination, this.packageFileName),
92
+ {preserveTimestamps :true }
93
+ );
89
94
  return join(options.destination, this.packageFileName);
90
95
  }
91
96
  }
package/src/util.mjs CHANGED
@@ -3,6 +3,7 @@ import { mkdir } from "fs/promises";
3
3
  import { pipeline } from "stream/promises";
4
4
  import { createWriteStream } from "fs";
5
5
  import { iterableStringInterceptor } from "iterable-string-interceptor";
6
+ import { ReadableStreamContentEntry } from "content-entry";
6
7
  import { FileContentProvider } from "npm-pkgbuild";
7
8
  import { packageWalker } from "npm-package-walker";
8
9
 
@@ -58,13 +59,13 @@ export async function extractFromPackage(pkg, dir) {
58
59
  let dependencies = { ...pkg.engines };
59
60
  let sources = [];
60
61
  let output = {};
61
-
62
+
62
63
  const processPkg = pkg => {
63
64
  if (pkg.pkgbuild) {
64
65
  const pkgbuild = pkg.pkgbuild;
65
66
 
66
67
  Object.assign(output, pkgbuild.output);
67
-
68
+
68
69
  Object.entries(pkgbuild)
69
70
  .filter(([k, v]) => typeof v === "string")
70
71
  .forEach(([k, v]) => (properties[k] = v));
@@ -81,7 +82,7 @@ export async function extractFromPackage(pkg, dir) {
81
82
  };
82
83
 
83
84
  await packageWalker(async (pkg, base, modulePath) => {
84
- processPkg(pkg)
85
+ processPkg(pkg);
85
86
  return true;
86
87
  }, dir);
87
88
 
@@ -90,10 +91,11 @@ export async function extractFromPackage(pkg, dir) {
90
91
  return { properties, sources, dependencies, output };
91
92
  }
92
93
 
93
- export function createPropertyTransformer(properties) {
94
+ export function createExpressionTransformer(properties) {
94
95
  async function* transformer(expression, remainder, source, cb) {
95
- console.log("EXPRESSION", expression);
96
- yield properties[expression];
96
+ const value = properties[expression];
97
+ console.log("EXPRESSION", expression, value);
98
+ yield value === undefined ? "" : value;
97
99
  }
98
100
 
99
101
  return {
@@ -101,7 +103,10 @@ export function createPropertyTransformer(properties) {
101
103
  transform: async entry =>
102
104
  new ReadableStreamContentEntry(
103
105
  entry.name,
104
- iterableStringInterceptor(transformer)
106
+ iterableStringInterceptor(
107
+ await entry.getReadStream(utf8StreamOptions),
108
+ transformer
109
+ )
105
110
  )
106
111
  };
107
112
  }