npm-pkgbuild 7.3.1 → 7.3.5

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.3.1",
3
+ "version": "7.3.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -40,9 +40,9 @@
40
40
  "dependencies": {
41
41
  "aggregate-async-iterator": "^1.1.7",
42
42
  "commander": "^8.3.0",
43
- "content-entry": "^2.7.1",
44
- "content-entry-filesystem": "^3.0.1",
45
- "execa": "^5.1.1",
43
+ "content-entry": "^2.9.6",
44
+ "content-entry-filesystem": "^3.1.9",
45
+ "execa": "^6.0.0",
46
46
  "expression-expander": "^7.0.9",
47
47
  "globby": "^12.0.2",
48
48
  "iterable-string-interceptor": "^1.0.8",
@@ -55,11 +55,11 @@
55
55
  "ava": "^3.15.0",
56
56
  "c8": "^7.10.0",
57
57
  "documentation": "^13.2.5",
58
- "semantic-release": "^18.0.0",
58
+ "semantic-release": "^18.0.1",
59
59
  "stream-buffers": "^3.0.2"
60
60
  },
61
61
  "engines": {
62
- "node": ">=16.12.0"
62
+ "node": ">=16.13.0"
63
63
  },
64
64
  "repository": {
65
65
  "type": "git",
@@ -1,3 +1,4 @@
1
+ import { dirname } from "path";
1
2
  import { globby } from "globby";
2
3
  import { FileSystemEntry } from "content-entry-filesystem";
3
4
  import { asArray } from "../util.mjs";
@@ -10,13 +11,20 @@ export class FileContentProvider extends ContentProvider {
10
11
  constructor(definitions) {
11
12
  super();
12
13
 
13
- this.definitions = { pattern: ["**/*"], ...definitions };
14
- this.definitions.pattern = asArray(this.definitions.pattern);
14
+ if (typeof definitions === "string") {
15
+ const base = dirname(definitions);
16
+ this.definitions = {
17
+ base,
18
+ pattern: [definitions.substring(base.length)]
19
+ };
20
+ } else {
21
+ this.definitions = { pattern: ["**/*"], ...definitions };
22
+ this.definitions.pattern = asArray(this.definitions.pattern);
23
+ }
15
24
  }
16
25
 
17
- async *entries() {
26
+ async *[Symbol.asyncIterator]() {
18
27
  const definitions = this.definitions;
19
-
20
28
  const base = definitions.base;
21
29
 
22
30
  for (const name of await globby(definitions.pattern, {
@@ -7,7 +7,7 @@ import program from "commander";
7
7
  import { aggregateFifo } from "aggregate-async-iterator";
8
8
  import { packageDirectory } from "pkg-dir";
9
9
  import { utf8StreamOptions, extractFromPackage } from "./util.mjs";
10
- import { FileContentProvider, Deb, PKG, RPM } from "npm-pkgbuild";
10
+ import { FileContentProvider, DEB, PKG, RPM } from "npm-pkgbuild";
11
11
 
12
12
  const { version, description } = JSON.parse(
13
13
  readFileSync(new URL("../package.json", import.meta.url).pathname),
@@ -16,7 +16,7 @@ const { version, description } = JSON.parse(
16
16
 
17
17
  const cwd = process.cwd();
18
18
 
19
- const outputs = [Deb, PKG, RPM];
19
+ const outputs = [DEB, PKG, RPM];
20
20
 
21
21
  program.description(description).version(version);
22
22
 
@@ -26,7 +26,7 @@ outputs.forEach(o =>
26
26
 
27
27
  program
28
28
  .option("--pkgver <version>", "package version")
29
- .option("-p --package <dir>", "where to put the package(s)", cwd)
29
+ .option("-d --destination <dir>", "where to put the package(s)", cwd)
30
30
  .option("-s --staging <dir>", "staging directory", "build")
31
31
  .option(
32
32
  "-c --content <dir>",
@@ -70,7 +70,7 @@ program
70
70
  properties
71
71
  );
72
72
 
73
- const fileName = await output.execute();
73
+ const fileName = await output.execute(options);
74
74
 
75
75
  console.log(fileName);
76
76
  }
@@ -3,19 +3,21 @@ import { tmpdir } from "os";
3
3
  import { createWriteStream } from "fs";
4
4
  import { mkdtemp, mkdir, chmod } from "fs/promises";
5
5
  import { pipeline } from "stream/promises";
6
- import execa from "execa";
6
+ import { execa } from "execa";
7
7
  import { EmptyContentEntry } from "content-entry";
8
8
  import { Packager } from "./packager.mjs";
9
9
  import { keyValueTransformer } from "../key-value-transformer.mjs";
10
10
 
11
+ const executableAttributes = { chmod: "0775" };
12
+
11
13
  const permissions = {
12
- "DEBIAN/preinst": { chmod: "0775" },
13
- "DEBIAN/postinst": { chmod: "0775" },
14
- "DEBIAN/prerm": { chmod: "0775" },
15
- "DEBIAN/postrm": { chmod: "0775" }
14
+ "DEBIAN/preinst": executableAttributes,
15
+ "DEBIAN/postinst": executableAttributes,
16
+ "DEBIAN/prerm": executableAttributes,
17
+ "DEBIAN/postrm": executableAttributes
16
18
  };
17
19
 
18
- export class Deb extends Packager {
20
+ export class DEB extends Packager {
19
21
  static get name() {
20
22
  return "deb";
21
23
  }
@@ -24,7 +26,11 @@ export class Deb extends Packager {
24
26
  return ".deb";
25
27
  }
26
28
 
27
- async execute() {
29
+ get packageFileName() {
30
+ return `${this.properties.name}_${this.properties.version}_${this.properties.arch}${this.constructor.fileNameExtension}`;
31
+ }
32
+
33
+ async execute(options) {
28
34
  const properties = this.properties;
29
35
 
30
36
  Object.entries(fields).forEach(([k, v]) => {
@@ -32,6 +38,11 @@ export class Deb extends Packager {
32
38
  if (e !== undefined) {
33
39
  properties[k] = e;
34
40
  }
41
+ else {
42
+ if(v.default !== undefined) {
43
+ properties[v.alias] = v.default;
44
+ }
45
+ }
35
46
  });
36
47
 
37
48
  const tmp = await mkdtemp(join(tmpdir(), "deb-"));
@@ -56,8 +67,6 @@ export class Deb extends Packager {
56
67
  }
57
68
  }
58
69
 
59
- const output = `${staging}${this.constructor.fileNameExtension}`;
60
-
61
70
  let debianControlEntry;
62
71
 
63
72
  for await (const entry of this.source) {
@@ -68,10 +77,8 @@ export class Deb extends Packager {
68
77
  if (entry.name === "DEBIAN/control") {
69
78
  debianControlEntry = entry;
70
79
  } else {
71
- await pipeline(
72
- await entry.getReadStream(),
73
- createWriteStream(destName)
74
- );
80
+ console.log("ENTRY", entry.name, entry.basename);
81
+ await pipeline(await entry.readStream, createWriteStream(destName));
75
82
 
76
83
  await Promise.all(
77
84
  Object.entries(permissions).map(async ([pattern, option]) => {
@@ -94,15 +101,15 @@ export class Deb extends Packager {
94
101
 
95
102
  await pipeline(
96
103
  keyValueTransformer(
97
- await debianControlEntry.getReadStream(),
104
+ await debianControlEntry.readStream,
98
105
  controlProperties
99
106
  ),
100
107
  createWriteStream(destName)
101
108
  );
102
109
 
103
- await execa("dpkg", ["-b", staging]);
110
+ await execa("dpkg", ["-b", staging, options.destination]);
104
111
 
105
- return output;
112
+ return join(options.destination, this.packageFileName);
106
113
  }
107
114
  }
108
115
 
@@ -120,7 +127,7 @@ const fields = {
120
127
  Priority: { type: "string", recommended: true },
121
128
  Essential: { type: "boolean" },
122
129
  Origin: { type: "string" },
123
- Architecture: { type: "string", default: "any", mandatory: true },
130
+ Architecture: { alias: "arch", type: "string", default: "any", mandatory: true },
124
131
  Homepage: { alias: "homepage", type: "string" },
125
132
  Bugs: { alias: "bugs", type: "string" },
126
133
  Depends: { alias: "depends", type: "packageList" },
@@ -1,24 +1,36 @@
1
1
  import { join, dirname } from "path";
2
+ import { createWriteStream } from "fs";
2
3
  import { tmpdir } from "os";
3
4
  import { finished } from "stream";
4
5
  import { promisify } from "util";
5
6
  import { mkdtemp, mkdir, chmod } from "fs/promises";
6
- import execa from "execa";
7
+ import { execa } from "execa";
7
8
  import { Packager } from "./packager.mjs";
8
9
  import { quote } from "../util.mjs";
9
10
 
10
11
  export class PKG extends Packager {
11
-
12
- static get name() { return "pkg"; }
12
+ static get name() {
13
+ return "pkg";
14
+ }
13
15
 
14
16
  static get fileNameExtension() {
15
17
  return ".pkg.tar";
16
18
  }
17
19
 
18
- async execute() {
19
-
20
+ async execute(options) {
20
21
  const tmp = await mkdtemp(join(tmpdir(), "pkg-"));
21
22
 
23
+ const pkgbuild = join(tmp, "PKGBUILD");
24
+
25
+ console.log(pkgbuild);
26
+
27
+ const out = createWriteStream(pkgbuild, { encoding: "utf8" });
28
+ out.write(`
29
+ package() {
30
+ cp -r $srcdir/* "$pkgdir"
31
+ }
32
+ `);
33
+
22
34
  await execa("makepkg", [], { cwd: tmp });
23
35
  }
24
36
  }