npm-pkgbuild 11.0.5 → 11.1.1

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": "11.0.5",
3
+ "version": "11.1.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -11,6 +11,7 @@ import { DEBIAN } from "./output/debian.mjs";
11
11
  import { ARCH } from "./output/arch.mjs";
12
12
  import { RPM } from "./output/rpm.mjs";
13
13
  import { OCI } from "./output/oci.mjs";
14
+ import { DOCKER } from "./output/docker.mjs";
14
15
 
15
16
  /**
16
17
  * All content providers
@@ -24,7 +25,7 @@ export const allInputs = [
24
25
  /**
25
26
  * All output formats
26
27
  */
27
- export const allOutputs = [DEBIAN, ARCH, RPM, OCI];
28
+ export const allOutputs = [DEBIAN, ARCH, RPM, OCI, DOCKER];
28
29
 
29
30
  /**
30
31
  * Node architecture name to os native arch name mapping
@@ -287,7 +288,7 @@ export async function* extractFromPackage(options = {}, env = {}) {
287
288
 
288
289
  const result = {
289
290
  context,
290
- variant: { name },
291
+ variant: { name, priority: variant.priority },
291
292
  sources,
292
293
  output,
293
294
  dependencies: depends,
package/src/module.mjs CHANGED
@@ -11,4 +11,5 @@ export * from "./output/debian.mjs";
11
11
  export * from "./output/rpm.mjs";
12
12
  export * from "./output/arch.mjs";
13
13
  export * from "./output/oci.mjs";
14
+ export * from "./output/docker.mjs";
14
15
  export * from "./output/packager.mjs";
@@ -0,0 +1,60 @@
1
+ import { join } from "node:path";
2
+ import { execa } from "execa";
3
+ import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
4
+ import {
5
+ keyValueTransformer,
6
+ } from "key-value-transformer";
7
+ import { Packager } from "./packager.mjs";
8
+
9
+ const DOCKERFILE = "Dockerfile";
10
+
11
+ export class DOCKER extends Packager {
12
+ static get name() {
13
+ return "docker";
14
+ }
15
+
16
+ static get description()
17
+ {
18
+ return "generate container image with docker|podman";
19
+ }
20
+
21
+ async execute(
22
+ sources,
23
+ transformer,
24
+ dependencies,
25
+ options,
26
+ expander = v => v
27
+ ) {
28
+ const { properties, staging, destination } = await this.prepareExecute(
29
+ options
30
+ );
31
+
32
+ const fp = fieldProvider(properties, fields);
33
+
34
+ transformer.push({
35
+ name: DOCKERFILE,
36
+ match: entry => entry.name === DOCKERFILE,
37
+ transform: async entry =>
38
+ new ReadableStreamContentEntry(
39
+ "../" + entry.name,
40
+ keyValueTransformer(await entry.readStream, fp)
41
+ ),
42
+ createEntryWhenMissing: () => new EmptyContentEntry(DOCKERFILE)
43
+ });
44
+
45
+ if (!options.dry) {
46
+ const docker = await execa("docker", ["build", "-e"], {
47
+ cwd: staging
48
+ });
49
+
50
+ if (options.verbose) {
51
+ console.log(docker.stdout);
52
+ }
53
+ }
54
+
55
+ return join(destination, this.packageFileName);
56
+ }
57
+ }
58
+
59
+ const fields = {
60
+ };