npm-pkgbuild 13.2.0 → 13.3.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 +1 -1
- package/src/extract-from-package.mjs +5 -0
- package/src/npm-pkgbuild-cli.mjs +2 -3
- package/src/output/docker.mjs +18 -1
- package/src/output/packager.mjs +12 -10
- package/src/util.mjs +7 -0
- package/types/output/packager.d.mts +1 -0
- package/types/util.d.mts +1 -1
package/package.json
CHANGED
|
@@ -360,6 +360,11 @@ export async function* extractFromPackage(options = {}, env = {}) {
|
|
|
360
360
|
...result,
|
|
361
361
|
variant: { ...result.variant, output: name },
|
|
362
362
|
output: { [name]: output },
|
|
363
|
+
// sources: [...result.sources, ...output.sources],
|
|
364
|
+
dependencies: mergeDependencies(
|
|
365
|
+
result.dependencies,
|
|
366
|
+
output.dependencies
|
|
367
|
+
),
|
|
363
368
|
properties: { ...result.properties, ...output.properties }
|
|
364
369
|
};
|
|
365
370
|
}
|
package/src/npm-pkgbuild-cli.mjs
CHANGED
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
allInputs,
|
|
13
13
|
allOutputs,
|
|
14
14
|
extractFromPackage,
|
|
15
|
-
publish,
|
|
16
15
|
preparePublish
|
|
17
16
|
} from "npm-pkgbuild";
|
|
18
17
|
|
|
@@ -139,7 +138,7 @@ program
|
|
|
139
138
|
console.log(kv(dependencies, " "));
|
|
140
139
|
}
|
|
141
140
|
|
|
142
|
-
const
|
|
141
|
+
const artifact = await o.execute(
|
|
143
142
|
sources.map(c => c[Symbol.asyncIterator]()),
|
|
144
143
|
transformer,
|
|
145
144
|
dependencies,
|
|
@@ -149,7 +148,7 @@ program
|
|
|
149
148
|
|
|
150
149
|
if (!options.dry) {
|
|
151
150
|
for (const p of options.publish) {
|
|
152
|
-
await publish(
|
|
151
|
+
await o.publish(artifact, p, o.properties);
|
|
153
152
|
}
|
|
154
153
|
}
|
|
155
154
|
} catch (e) {
|
package/src/output/docker.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
equalSeparatedKeyValuePairOptions
|
|
10
10
|
} from "key-value-transformer";
|
|
11
11
|
import { Packager } from "./packager.mjs";
|
|
12
|
+
import { analysePublish } from "../publish.mjs";
|
|
12
13
|
import {
|
|
13
14
|
fieldProvider,
|
|
14
15
|
copyEntries,
|
|
@@ -139,7 +140,12 @@ export class DOCKER extends Packager {
|
|
|
139
140
|
if (!options.dry) {
|
|
140
141
|
const docker = await execa(
|
|
141
142
|
this.constructor.name,
|
|
142
|
-
[
|
|
143
|
+
[
|
|
144
|
+
"build",
|
|
145
|
+
"--tag",
|
|
146
|
+
tag,
|
|
147
|
+
/*"--output","type=tar,dest=out.tar",*/ staging
|
|
148
|
+
],
|
|
143
149
|
{
|
|
144
150
|
cwd: staging
|
|
145
151
|
}
|
|
@@ -159,6 +165,17 @@ export class DOCKER extends Packager {
|
|
|
159
165
|
|
|
160
166
|
return image;
|
|
161
167
|
}
|
|
168
|
+
|
|
169
|
+
async publish(artifact, destination, properties,logger) {
|
|
170
|
+
|
|
171
|
+
const publish = analysePublish(destination, properties);
|
|
172
|
+
|
|
173
|
+
logger(`Publishing to ${publish.url}`);
|
|
174
|
+
|
|
175
|
+
const name = `${properties.name}:${properties.version}`;
|
|
176
|
+
console.log(`docker tag ${artifact} ${publish.url}/${name}`);
|
|
177
|
+
console.log(`docker push ${name}`);
|
|
178
|
+
}
|
|
162
179
|
}
|
|
163
180
|
|
|
164
181
|
/**
|
package/src/output/packager.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { mkdtemp, mkdir } from "node:fs/promises";
|
|
4
|
-
import { analysePublish } from "../publish.mjs";
|
|
4
|
+
import { analysePublish, publish } from "../publish.mjs";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {Object} Field
|
|
@@ -37,7 +37,7 @@ export class Packager {
|
|
|
37
37
|
* @param {Object} variant
|
|
38
38
|
* @return {Promise<boolean>}
|
|
39
39
|
*/
|
|
40
|
-
static async prepare(options,variant) {
|
|
40
|
+
static async prepare(options, variant) {
|
|
41
41
|
return false;
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -47,11 +47,10 @@ export class Packager {
|
|
|
47
47
|
this.#properties = { ...properties };
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
get fileNameExtension()
|
|
51
|
-
|
|
52
|
-
return this.constructor.fileNameExtension;
|
|
50
|
+
get fileNameExtension() {
|
|
51
|
+
return this.constructor.fileNameExtension;
|
|
53
52
|
}
|
|
54
|
-
|
|
53
|
+
|
|
55
54
|
get fields() {
|
|
56
55
|
return this.constructor.fields;
|
|
57
56
|
}
|
|
@@ -60,7 +59,7 @@ export class Packager {
|
|
|
60
59
|
const properties = this.#properties;
|
|
61
60
|
|
|
62
61
|
Object.entries(this.fields).forEach(([k, v]) => {
|
|
63
|
-
if(v.set && properties[k] !== undefined) {
|
|
62
|
+
if (v.set && properties[k] !== undefined) {
|
|
64
63
|
properties[k] = v.set(properties[k]);
|
|
65
64
|
}
|
|
66
65
|
|
|
@@ -68,7 +67,6 @@ export class Packager {
|
|
|
68
67
|
if (e !== undefined) {
|
|
69
68
|
properties[k] = v.set ? v.set(e) : e;
|
|
70
69
|
} else {
|
|
71
|
-
|
|
72
70
|
const vak = v.alias || k;
|
|
73
71
|
if (v.default !== undefined) {
|
|
74
72
|
if (
|
|
@@ -109,11 +107,11 @@ export class Packager {
|
|
|
109
107
|
}
|
|
110
108
|
|
|
111
109
|
if (options.publish) {
|
|
112
|
-
for(const op of options.publish) {
|
|
110
|
+
for (const op of options.publish) {
|
|
113
111
|
const publish = analysePublish(op, out.properties);
|
|
114
112
|
|
|
115
113
|
out.destination = publish.scheme === "file:" ? publish.url : tmpdir;
|
|
116
|
-
|
|
114
|
+
|
|
117
115
|
await mkdir(out.destination, { recursive: true });
|
|
118
116
|
}
|
|
119
117
|
}
|
|
@@ -134,4 +132,8 @@ export class Packager {
|
|
|
134
132
|
* @return {Promise<string>} location of the resulting package
|
|
135
133
|
*/
|
|
136
134
|
async execute(sources, transformer, dependencies, options, expander) {}
|
|
135
|
+
|
|
136
|
+
async publish(artifact, destination, properties, logger) {
|
|
137
|
+
return publish(artifact, destination, properties, logger);
|
|
138
|
+
}
|
|
137
139
|
}
|
package/src/util.mjs
CHANGED
|
@@ -22,6 +22,13 @@ export function filterOutUnwantedDependencies() {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export function mergeDependencies(a, b) {
|
|
25
|
+
if (!b) {
|
|
26
|
+
return a;
|
|
27
|
+
}
|
|
28
|
+
if (!a) {
|
|
29
|
+
return b;
|
|
30
|
+
}
|
|
31
|
+
|
|
25
32
|
const keys = new Set([...Object.keys(a), ...Object.keys(b)]);
|
|
26
33
|
|
|
27
34
|
const result = {};
|
|
@@ -40,6 +40,7 @@ export class Packager {
|
|
|
40
40
|
* @return {Promise<string>} location of the resulting package
|
|
41
41
|
*/
|
|
42
42
|
execute(sources: any, transformer: any, dependencies: any, options: any, expander: any): Promise<string>;
|
|
43
|
+
publish(artifact: any, destination: any, properties: any, logger: any): Promise<void>;
|
|
43
44
|
#private;
|
|
44
45
|
}
|
|
45
46
|
export type Field = {
|
package/types/util.d.mts
CHANGED