npm-pkgbuild 7.4.1 → 7.4.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.4.1",
3
+ "version": "7.4.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,3 +1,4 @@
1
+ import { join } from "path";
1
2
  import { execa } from "execa";
2
3
  import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
3
4
  import {
@@ -18,7 +19,7 @@ export const pkgKeyValuePairOptions = {
18
19
  extractKeyValue: line => {
19
20
  const m = line.match(/^(\w+)=\s*\((.*)\)|(.*)/);
20
21
  if (m) {
21
- return [m[1], m[2] ? [m[2]] : m[3]];
22
+ return [m[1], m[2] ? [m[2].split(/\s*,\s*/)] : m[3]];
22
23
  }
23
24
  },
24
25
  keyValueLine: (key, value, lineEnding) =>
@@ -49,6 +50,9 @@ export class PKG extends Packager {
49
50
 
50
51
  async execute(sources, options) {
51
52
  const properties = this.properties;
53
+
54
+ //properties.depends = makeDepends({ ...pkg.engines });
55
+
52
56
  const mandatoryFields = this.mandatoryFields;
53
57
  const staging = await this.tmpdir;
54
58
 
@@ -73,7 +77,9 @@ package() {
73
77
  `;
74
78
  }
75
79
 
76
- const transformers = [
80
+ await copyEntries(transform(sources, []), join(staging, "src"));
81
+
82
+ const metaTransformers = [
77
83
  {
78
84
  match: entry => entry.name === "PKGBUILD",
79
85
  transform: async entry =>
@@ -88,11 +94,11 @@ package() {
88
94
  }
89
95
  ];
90
96
 
91
- const [meta,content] = split(transform(sources, transformers),);
92
-
93
- await copyEntries(transform(sources, transformers), staging);
97
+ await copyEntries(transform(sources, metaTransformers, true), staging);
94
98
 
95
99
  await execa("makepkg", ["-f"], { cwd: staging });
100
+
101
+ return join(options.destination, this.packageFileName);
96
102
  }
97
103
  }
98
104
 
@@ -107,7 +113,7 @@ const fields = {
107
113
  pkgdesc: { alias: "description", type: "string", mandatory: true },
108
114
  arch: { default: ["any"], type: "string[]", mandatory: true },
109
115
 
110
- license: { type: "string[]", mandatory: true },
116
+ license: { default: [], type: "string[]", mandatory: true },
111
117
  source: { default: [], type: "string[]" },
112
118
  validpgpkeys: { type: "string[]" },
113
119
  noextract: { type: "string[]" },
@@ -134,12 +140,6 @@ const fields = {
134
140
  };
135
141
 
136
142
  /*
137
- const properties = {
138
- makedepends: "git"
139
- };
140
-
141
- properties.depends = makeDepends({ ...pkg.engines });
142
-
143
143
  out.write(
144
144
  `# ${pkg.contributors
145
145
  .map(
@@ -171,19 +171,8 @@ package() {
171
171
  }
172
172
  `
173
173
  );
174
-
175
- function makeDepends(d) {
176
- if (d === undefined) {
177
- return [];
178
- }
179
-
180
- return Object.keys(d).reduce((a, c) => {
181
- const mapping = {
182
- node: "nodejs"
183
- };
184
-
185
- a.push(`${mapping[c] ? mapping[c] : c}${d[c].replace(/\-([\w\d]+)$/, "")}`);
186
- return a;
187
- }, []);
188
- }
189
174
  */
175
+
176
+ const mapping = {
177
+ node: "nodejs"
178
+ };
package/src/util.mjs CHANGED
@@ -53,6 +53,7 @@ export function extractFromPackage(pkg) {
53
53
  properties.source = pkg.repository.url;
54
54
  }
55
55
 
56
+ let dependencies = { ...pkg.engines };
56
57
  let sources = [];
57
58
 
58
59
  if (pkg.pkgbuild) {
@@ -67,9 +68,11 @@ export function extractFromPackage(pkg) {
67
68
  destination
68
69
  ]);
69
70
  }
71
+
72
+ Object.assign(dependencies,pkgbuild.depends)
70
73
  }
71
74
 
72
- return { properties, sources };
75
+ return { properties, sources, dependencies};
73
76
  }
74
77
 
75
78
  /**
@@ -77,7 +80,7 @@ export function extractFromPackage(pkg) {
77
80
  * @param {AsyncIterator<ContentEntry>} source
78
81
  * @param {Transformer[]} transformers
79
82
  */
80
- export async function* transform(source, transformers) {
83
+ export async function* transform(source, transformers=[], onlyMatching) {
81
84
  const usedTransformers = new Set();
82
85
 
83
86
  for await (let entry of source) {
@@ -85,10 +88,16 @@ export async function* transform(source, transformers) {
85
88
  if (t.match(entry)) {
86
89
  entry = await t.transform(entry);
87
90
  usedTransformers.add(t);
91
+
92
+ if(onlyMatching) {
93
+ yield entry;
94
+ }
88
95
  }
89
96
  }
90
97
 
91
- yield entry;
98
+ if(!onlyMatching) {
99
+ yield entry;
100
+ }
92
101
  }
93
102
 
94
103
  for (const t of transformers) {