npm-pkgbuild 13.3.0 → 13.4.0

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": "13.3.0",
3
+ "version": "13.4.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -39,7 +39,8 @@
39
39
  "npm-pkgbuild": "src/npm-pkgbuild-cli.mjs"
40
40
  },
41
41
  "scripts": {
42
- "prepare": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types -t esnext -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
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
44
  "test": "npm run test:ava",
44
45
  "test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
45
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",
@@ -1,11 +1,8 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env -S node --no-warnings
2
2
 
3
- import { readFileSync } from "node:fs";
4
- import { fileURLToPath } from "node:url";
5
3
  import { program, Option } from "commander";
6
4
  import { createExpressionTransformer } from "content-entry-transform";
7
5
  import { UTIController } from "uti";
8
- import { utf8StreamOptions } from "./util.mjs";
9
6
  import additionalUTIs from "./utis.mjs";
10
7
  import {
11
8
  FileContentProvider,
@@ -14,15 +11,9 @@ import {
14
11
  extractFromPackage,
15
12
  preparePublish
16
13
  } from "npm-pkgbuild";
14
+ import pkg from "../package.json" assert { type: "json" };
17
15
 
18
- const { version, description } = JSON.parse(
19
- readFileSync(
20
- fileURLToPath(new URL("../package.json", import.meta.url)),
21
- utf8StreamOptions
22
- )
23
- );
24
-
25
- program.description(description).version(version);
16
+ program.description(pkg.description).version(pkg.version);
26
17
 
27
18
  allOutputs.forEach(o => {
28
19
  program.option(`--${o.name}`, o.description);
@@ -97,7 +88,7 @@ program
97
88
  output?.[outputFactory.name]?.properties,
98
89
  {
99
90
  type: outputFactory.name,
100
- "user-agent": `npm-pkgbuild-${version}`
91
+ "user-agent": `npm-pkgbuild-${pkg.version}`
101
92
  },
102
93
  options.define
103
94
  );
@@ -147,9 +138,7 @@ program
147
138
  );
148
139
 
149
140
  if (!options.dry) {
150
- for (const p of options.publish) {
151
- await o.publish(artifact, p, o.properties);
152
- }
141
+ await Promise.all(options.publish.map(pl => o.publish(artifact, pl, o.properties)));
153
142
  }
154
143
  } catch (e) {
155
144
  handleError(e, options);
@@ -166,7 +166,7 @@ export class DOCKER extends Packager {
166
166
  return image;
167
167
  }
168
168
 
169
- async publish(artifact, destination, properties,logger) {
169
+ async publish(artifact, destination, properties,logger=console.log) {
170
170
 
171
171
  const publish = analysePublish(destination, properties);
172
172
 
@@ -112,7 +112,7 @@ export class Packager {
112
112
 
113
113
  out.destination = publish.scheme === "file:" ? publish.url : tmpdir;
114
114
 
115
- await mkdir(out.destination, { recursive: true });
115
+ await mkdir(out.destination, mdo);
116
116
  }
117
117
  }
118
118
 
package/src/publish.mjs CHANGED
@@ -4,7 +4,7 @@ import { mkdir, copyFile } from "node:fs/promises";
4
4
  import { decodePassword } from "./util.mjs";
5
5
 
6
6
  export function analysePublish(publish, properties) {
7
- publish = Object.assign({}, publish);
7
+ publish = { ...publish };
8
8
 
9
9
  publish.url = publish.url.replace(
10
10
  /\{\{(\w+)\}\}/gm,
@@ -18,7 +18,12 @@ export function analysePublish(publish, properties) {
18
18
  return publish;
19
19
  }
20
20
 
21
- export async function publish(fileName, destination, properties, logger=console.log) {
21
+ export async function publish(
22
+ fileName,
23
+ destination,
24
+ properties,
25
+ logger = console.log
26
+ ) {
22
27
  if (!destination) {
23
28
  return;
24
29
  }
@@ -52,7 +57,7 @@ export async function publish(fileName, destination, properties, logger=console.
52
57
  const response = await fetch(url, {
53
58
  method: "PUT",
54
59
  headers,
55
- duplex: 'half',
60
+ duplex: "half",
56
61
  body: createReadStream(fileName)
57
62
  });
58
63
 
@@ -66,15 +71,13 @@ export async function publish(fileName, destination, properties, logger=console.
66
71
  }
67
72
 
68
73
  export function preparePublish(publish = [], env = {}) {
69
- function vm(k) {
70
- return env[k] || k;
71
- }
72
-
73
74
  const e = env["PKGBUILD_PUBLISH"];
74
75
  if (e) {
75
76
  publish.push(e);
76
77
  }
77
78
 
79
+ const vm = k => env[k] || k;
80
+
78
81
  return publish.map(value => {
79
82
  let values = value.split(/,/);
80
83
  if (values.length > 1) {
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env -S node --no-warnings
2
2
  export {};
@@ -34,5 +34,9 @@ export class DOCKER extends Packager {
34
34
  arch: string;
35
35
  }): Promise<boolean>;
36
36
  execute(sources: any, transformer: any, dependencies: any, options: any, expander?: (v: any) => any): Promise<string>;
37
+ publish(artifact: any, destination: any, properties: any, logger?: {
38
+ (...data: any[]): void;
39
+ (message?: any, ...optionalParams: any[]): void;
40
+ }): Promise<void>;
37
41
  }
38
42
  import { Packager } from "./packager.mjs";