npm-pkgbuild 14.0.1 → 14.0.3

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
@@ -97,28 +97,28 @@ See [mf-hosting](https://www.npmjs.com/package/mf-hosting) or [mf-hosting-fronte
97
97
  * [FileContentProvider](#filecontentprovider)
98
98
  * [Parameters](#parameters-1)
99
99
  * [name](#name)
100
- * [utf8StreamOptions](#utf8streamoptions)
100
+ * [NFTContentProvider](#nftcontentprovider)
101
+ * [Parameters](#parameters-2)
102
+ * [name](#name-1)
103
+ * [NodeModulesContentProvider](#nodemodulescontentprovider)
104
+ * [Parameters](#parameters-3)
101
105
  * [Properties](#properties-1)
106
+ * [name](#name-2)
107
+ * [utf8StreamOptions](#utf8streamoptions)
108
+ * [Properties](#properties-2)
102
109
  * [packageNameMapping](#packagenamemapping)
103
110
  * [decodePassword](#decodepassword)
104
- * [Parameters](#parameters-2)
111
+ * [Parameters](#parameters-4)
105
112
  * [FunctionDecl](#functiondecl)
106
- * [Properties](#properties-2)
113
+ * [Properties](#properties-3)
107
114
  * [extractFunctions](#extractfunctions)
108
- * [Parameters](#parameters-3)
109
- * [fieldProvider](#fieldprovider)
110
- * [Parameters](#parameters-4)
111
- * [Expander](#expander)
112
115
  * [Parameters](#parameters-5)
113
- * [copyEntries](#copyentries)
116
+ * [fieldProvider](#fieldprovider)
114
117
  * [Parameters](#parameters-6)
115
- * [NFTContentProvider](#nftcontentprovider)
118
+ * [Expander](#expander)
116
119
  * [Parameters](#parameters-7)
117
- * [name](#name-1)
118
- * [NodeModulesContentProvider](#nodemodulescontentprovider)
120
+ * [copyEntries](#copyentries)
119
121
  * [Parameters](#parameters-8)
120
- * [Properties](#properties-3)
121
- * [name](#name-2)
122
122
  * [NPMPackContentProvider](#npmpackcontentprovider)
123
123
  * [Parameters](#parameters-9)
124
124
  * [Properties](#properties-4)
@@ -134,22 +134,25 @@ See [mf-hosting](https://www.npmjs.com/package/mf-hosting) or [mf-hosting-fronte
134
134
  * [DEBIAN](#debian)
135
135
  * [prepare](#prepare)
136
136
  * [Parameters](#parameters-10)
137
- * [prepare](#prepare-1)
138
- * [Parameters](#parameters-11)
137
+ * [DOCKER](#docker)
138
+ * [prepare](#prepare-1)
139
+ * [Parameters](#parameters-11)
140
+ * [publish](#publish)
141
+ * [Parameters](#parameters-12)
139
142
  * [OCI](#oci)
140
143
  * [Field](#field)
141
144
  * [Properties](#properties-5)
142
145
  * [Packager](#packager)
143
- * [Parameters](#parameters-12)
146
+ * [Parameters](#parameters-13)
144
147
  * [tmpdir](#tmpdir)
145
148
  * [execute](#execute)
146
- * [Parameters](#parameters-13)
149
+ * [Parameters](#parameters-14)
147
150
  * [workspaceLayout](#workspacelayout)
148
151
  * [prepare](#prepare-2)
149
- * [Parameters](#parameters-14)
152
+ * [Parameters](#parameters-15)
150
153
  * [RPM](#rpm)
151
154
  * [prepare](#prepare-3)
152
- * [Parameters](#parameters-15)
155
+ * [Parameters](#parameters-16)
153
156
 
154
157
  ## ContentProvider
155
158
 
@@ -189,6 +192,44 @@ Content provided form the file system.
189
192
 
190
193
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the content provider
191
194
 
195
+ ## NFTContentProvider
196
+
197
+ **Extends ContentProvider**
198
+
199
+ Content provided form the file system.
200
+
201
+ ### Parameters
202
+
203
+ * `definitions` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))** 
204
+
205
+ * `definitions.pattern` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>)**&#x20;
206
+ * `definitions.base` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** base directory where to find the files
207
+ * `entryProperties` &#x20;
208
+
209
+ ### name
210
+
211
+ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the content provider
212
+
213
+ ## NodeModulesContentProvider
214
+
215
+ **Extends ContentProvider**
216
+
217
+ Content from node\_modules.
218
+ Requires .npmrc or NPM\_TOKEN environment
219
+
220
+ ### Parameters
221
+
222
+ * `definitions` &#x20;
223
+ * `entryProperties` &#x20;
224
+
225
+ ### Properties
226
+
227
+ * `withoutDevelpmentDependencies` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**&#x20;
228
+
229
+ ### name
230
+
231
+ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the content provider
232
+
192
233
  ## utf8StreamOptions
193
234
 
194
235
  Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
@@ -218,7 +259,7 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
218
259
  ### Properties
219
260
 
220
261
  * `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
221
- * `body` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**&#x20;
262
+ * `body` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
222
263
 
223
264
  ## extractFunctions
224
265
 
@@ -260,44 +301,6 @@ Destination paths a generated without leading '/' (as for entry names too).
260
301
  * `destinationDirectory` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
261
302
  * `expander` **[Expander](#expander)** (optional, default `v=>v`)
262
303
 
263
- ## NFTContentProvider
264
-
265
- **Extends ContentProvider**
266
-
267
- Content provided form the file system.
268
-
269
- ### Parameters
270
-
271
- * `definitions` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))**&#x20;
272
-
273
- * `definitions.pattern` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>)**&#x20;
274
- * `definitions.base` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** base directory where to find the files
275
- * `entryProperties` &#x20;
276
-
277
- ### name
278
-
279
- Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the content provider
280
-
281
- ## NodeModulesContentProvider
282
-
283
- **Extends ContentProvider**
284
-
285
- Content from node\_modules.
286
- Requires .npmrc or NPM\_TOKEN environment
287
-
288
- ### Parameters
289
-
290
- * `definitions` &#x20;
291
- * `entryProperties` &#x20;
292
-
293
- ### Properties
294
-
295
- * `withoutDevelpmentDependencies` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**&#x20;
296
-
297
- ### name
298
-
299
- Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the content provider
300
-
301
304
  ## NPMPackContentProvider
302
305
 
303
306
  **Extends ContentProvider**
@@ -370,11 +373,17 @@ Create .deb packages
370
373
 
371
374
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)>**&#x20;
372
375
 
373
- ## prepare
376
+ ## DOCKER
377
+
378
+ **Extends Packager**
379
+
380
+ docker image build
381
+
382
+ ### prepare
374
383
 
375
384
  Check for docker presence.
376
385
 
377
- ### Parameters
386
+ #### Parameters
378
387
 
379
388
  * `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
380
389
  * `variant` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
@@ -383,6 +392,15 @@ Check for docker presence.
383
392
 
384
393
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)>** true when docker executable is present
385
394
 
395
+ ## publish
396
+
397
+ ### Parameters
398
+
399
+ * `fileName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
400
+ * `destination` **any**&#x20;
401
+ * `properties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
402
+ * `logger` **function (any): void** (optional, default `console.log`)
403
+
386
404
  ## OCI
387
405
 
388
406
  **Extends Packager**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-pkgbuild",
3
- "version": "14.0.1",
3
+ "version": "14.0.3",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -40,14 +40,14 @@
40
40
  },
41
41
  "scripts": {
42
42
  "prepare": "npm run prepare:typescript",
43
- "prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types -t esnext -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
43
+ "prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types --resolveJsonModule -t esnext -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
44
44
  "test": "npm run test:ava",
45
45
  "test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
46
46
  "cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp",
47
47
  "docs": "documentation readme --section=API ./src/**/*.mjs",
48
48
  "lint": "npm run lint:docs && npm run lint:typescript",
49
49
  "lint:docs": "documentation lint ./src/**/*.mjs",
50
- "lint:typescript": "tsc --allowJs --checkJs --noEmit -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs",
50
+ "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs",
51
51
  "tsc:types": "tsc -d --allowJs --declarationDir dist --emitDeclarationOnly ./src/extract-from-package.mjs"
52
52
  },
53
53
  "dependencies": {
@@ -56,7 +56,7 @@
56
56
  "aggregate-async-iterator": "^1.2.0",
57
57
  "commander": "^12.0.0",
58
58
  "compare-versions": "^6.1.0",
59
- "content-entry": "^9.0.1",
59
+ "content-entry": "^9.0.2",
60
60
  "content-entry-filesystem": "^6.0.0",
61
61
  "content-entry-transform": "^1.4.29",
62
62
  "execa": "^8.0.1",
@@ -70,7 +70,7 @@
70
70
  "pacote": "^17.0.6",
71
71
  "pkg-dir": "^8.0.0",
72
72
  "tar-stream": "^3.1.7",
73
- "uti": "^8.4.0"
73
+ "uti": "^8.4.1"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/node": "^20.11.25",
@@ -2,6 +2,7 @@ import { tmpdir, homedir } from "node:os";
2
2
  import { join } from "node:path";
3
3
  import { mkdtemp, readFile, writeFile } from "node:fs/promises";
4
4
  import { globby } from "globby";
5
+ import { execa } from "execa";
5
6
  import Arborist from "@npmcli/arborist";
6
7
  import { parse } from "ini";
7
8
  import { StringContentEntry } from "content-entry";
@@ -71,7 +72,9 @@ export class NodeModulesContentProvider extends ContentProvider {
71
72
  if (process.env.NPM_TOKEN) {
72
73
  npmrc["_authToken"] = process.env.NPM_TOKEN;
73
74
  } else {
74
- throw new Error(`.npmrc not found in ${searchDirs} (neither NPM_TOKEN in envinronment)`);
75
+ throw new Error(
76
+ `.npmrc not found in ${searchDirs} (neither NPM_TOKEN in envinronment)`
77
+ );
75
78
  }
76
79
  }
77
80
 
@@ -110,6 +113,13 @@ export class NodeModulesContentProvider extends ContentProvider {
110
113
  console.error(e, name);
111
114
  }
112
115
  }
116
+ if (name.endsWith(".node")) {
117
+ const proc = await execa("file", ["-b", name], {
118
+ cwd: pkgSourceDir
119
+ });
120
+ const arch = proc.stdout.split(/\s*,\s*/)[1];
121
+ console.log(name, arch);
122
+ }
113
123
 
114
124
  yield Object.assign(
115
125
  new FileSystemEntry(name, pkgSourceDir),
@@ -35,6 +35,9 @@ const dependenciesToFrom = {
35
35
  nginx: "nginx"
36
36
  };
37
37
 
38
+ /**
39
+ * docker image build
40
+ */
38
41
  export class DOCKER extends Packager {
39
42
  static get name() {
40
43
  return "docker";
@@ -170,16 +173,15 @@ export class DOCKER extends Packager {
170
173
  const publish = analysePublish(destination, properties);
171
174
 
172
175
  try {
173
- const url = new URL(publish.url);
174
- const repoLocation = `${url.host}/${url.pathname}`;
175
- const name = `${properties.name}:${properties.version}`;
176
+ const url = new URL(publish.url);
177
+ const repoLocation = `${url.host}/${publish.username}`;
178
+ const name = `${properties.name}:${properties.version}`;
176
179
 
177
- logger(`Publishing to ${repoLocation}`);
180
+ logger(`Publishing to ${repoLocation}`);
178
181
 
179
- console.log(`docker tag ${artifact} ${repoLocation}/${name}`);
180
- console.log(`docker push ${name}`);
181
- }
182
- catch(e) {
182
+ console.log(`docker tag ${artifact} ${repoLocation}/${name}`);
183
+ console.log(`docker push ${repoLocation}/${name}`);
184
+ } catch (e) {
183
185
  console.log(e, publish.url);
184
186
  }
185
187
  }
package/src/package.mjs CHANGED
@@ -179,6 +179,12 @@ const skipPattern = [
179
179
 
180
180
  const defaultOptions = { dry: false };
181
181
 
182
+ /**
183
+ *
184
+ * @param {string} source
185
+ * @param {string} dest
186
+ * @param {Object} options
187
+ */
182
188
  export async function* copyNodeModules(source, dest, options = defaultOptions) {
183
189
  for await (const name of globbyStream(["node_modules/**/package.json"], {
184
190
  cwd: source
package/src/publish.mjs CHANGED
@@ -3,21 +3,33 @@ import { createReadStream } from "node:fs";
3
3
  import { mkdir, copyFile } from "node:fs/promises";
4
4
  import { decodePassword } from "./util.mjs";
5
5
 
6
+ /**
7
+ * @param {Object} publish
8
+ * @param {Object} properties
9
+ * @return {{scheme: string, url: string }}
10
+ */
6
11
  export function analysePublish(publish, properties) {
7
- publish = { ...publish };
12
+ const result = { ...publish };
8
13
 
9
- publish.url = publish.url.replace(
14
+ result.url = result.url.replace(
10
15
  /\{\{(\w+)\}\}/gm,
11
16
  (match, key, offset, string) => properties[key] || "{{" + key + "}}"
12
17
  );
13
18
 
14
- const m = publish.url.match(/^([^:]+:)\/\/(.*)/);
19
+ const m = result.url.match(/^([^:]+:)\/\/(.*)/);
15
20
 
16
- publish.scheme = m ? m[1] : "file:";
21
+ result.scheme = m ? m[1] : "file:";
17
22
 
18
- return publish;
23
+ return result;
19
24
  }
20
25
 
26
+ /**
27
+ *
28
+ * @param {string} fileName
29
+ * @param {*} destination
30
+ * @param {Object} properties
31
+ * @param {function(any):void} logger
32
+ */
21
33
  export async function publish(
22
34
  fileName,
23
35
  destination,
@@ -70,6 +82,12 @@ export async function publish(
70
82
  }
71
83
  }
72
84
 
85
+ /**
86
+ *
87
+ * @param {*} publish
88
+ * @param {*} env
89
+ * @returns {{url:string, password:string|undefined, username:string|undefined}}
90
+ */
73
91
  export function preparePublish(publish = [], env = {}) {
74
92
  const e = env["PKGBUILD_PUBLISH"];
75
93
  if (e) {
package/src/util.mjs CHANGED
@@ -63,7 +63,7 @@ export function decodePassword(password) {
63
63
  /**
64
64
  * @typedef {Object} FunctionDecl
65
65
  * @property {string} name
66
- * @property {string[]} body
66
+ * @property {string} body
67
67
  */
68
68
 
69
69
  /**
@@ -1,3 +1,6 @@
1
+ /**
2
+ * docker image build
3
+ */
1
4
  export class DOCKER extends Packager {
2
5
  static get description(): string;
3
6
  static get fields(): {
@@ -1,6 +1,10 @@
1
- export function copyNodeModules(source: any, dest: any, options?: {
2
- dry: boolean;
3
- }): AsyncGenerator<never, void, unknown>;
1
+ /**
2
+ *
3
+ * @param {string} source
4
+ * @param {string} dest
5
+ * @param {Object} options
6
+ */
7
+ export function copyNodeModules(source: string, dest: string, options?: any): AsyncGenerator<never, void, unknown>;
4
8
  export function copyNodeModule(source: any, dest: any, options?: {
5
9
  dry: boolean;
6
10
  }): AsyncGenerator<string, void, unknown>;
@@ -1,19 +1,28 @@
1
- export function analysePublish(publish: any, properties: any): any;
2
- export function publish(fileName: any, destination: any, properties: any, logger?: {
3
- (...data: any[]): void;
4
- (message?: any, ...optionalParams: any[]): void;
5
- }): Promise<void>;
6
- export function preparePublish(publish?: any[], env?: {}): ({
7
- url: any;
8
- user: any;
9
- password: string;
10
- } | {
11
- username?: any;
12
- password?: string;
1
+ /**
2
+ * @param {Object} publish
3
+ * @param {Object} properties
4
+ * @return {{scheme: string, url: string }}
5
+ */
6
+ export function analysePublish(publish: any, properties: any): {
7
+ scheme: string;
13
8
  url: string;
14
- user?: undefined;
15
- } | {
16
- url: any;
17
- user?: undefined;
18
- password?: undefined;
19
- })[];
9
+ };
10
+ /**
11
+ *
12
+ * @param {string} fileName
13
+ * @param {*} destination
14
+ * @param {Object} properties
15
+ * @param {function(any):void} logger
16
+ */
17
+ export function publish(fileName: string, destination: any, properties: any, logger?: (arg0: any) => void): Promise<void>;
18
+ /**
19
+ *
20
+ * @param {*} publish
21
+ * @param {*} env
22
+ * @returns {{url:string, password:string|undefined, username:string|undefined}}
23
+ */
24
+ export function preparePublish(publish?: any, env?: any): {
25
+ url: string;
26
+ password: string | undefined;
27
+ username: string | undefined;
28
+ };
package/types/util.d.mts CHANGED
@@ -9,7 +9,7 @@ export function decodePassword(password: string): string;
9
9
  /**
10
10
  * @typedef {Object} FunctionDecl
11
11
  * @property {string} name
12
- * @property {string[]} body
12
+ * @property {string} body
13
13
  */
14
14
  /**
15
15
  * Extract shell functions from a given text.
@@ -49,7 +49,7 @@ export namespace packageNameMapping {
49
49
  }
50
50
  export type FunctionDecl = {
51
51
  name: string;
52
- body: string[];
52
+ body: string;
53
53
  };
54
54
  export type Expander = Function;
55
55
  import { ContentEntry } from "content-entry";