pmcf 1.54.13 → 1.56.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/bin/pmcf-package +33 -28
- package/package.json +2 -2
- package/src/base.mjs +5 -0
- package/src/dns.mjs +4 -4
- package/src/host.mjs +23 -6
- package/src/location.mjs +11 -6
- package/src/owner.mjs +9 -0
- package/types/base.d.mts +2 -0
- package/types/host.d.mts +8 -0
package/bin/pmcf-package
CHANGED
|
@@ -4,11 +4,7 @@ import { join } from "node:path";
|
|
|
4
4
|
import { readFile, mkdtemp } from "node:fs/promises";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
6
6
|
import { packageDirectory } from "pkg-dir";
|
|
7
|
-
import {
|
|
8
|
-
FileContentProvider,
|
|
9
|
-
createPublishingDetails,
|
|
10
|
-
ARCH
|
|
11
|
-
} from "npm-pkgbuild";
|
|
7
|
+
import { FileContentProvider, createPublishingDetails } from "npm-pkgbuild";
|
|
12
8
|
import { prepare } from "../src/cmd.mjs";
|
|
13
9
|
|
|
14
10
|
const { root, args, options } = await prepare();
|
|
@@ -25,28 +21,37 @@ const publishingDetails = createPublishingDetails(options.publish, process.env);
|
|
|
25
21
|
for (const name of args) {
|
|
26
22
|
const object = await root.load(name);
|
|
27
23
|
const stagingDir = join(options.output, object.fullName);
|
|
28
|
-
const { properties } = await object.preparePackage(stagingDir);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
24
|
+
const { properties, outputs } = await object.preparePackage(stagingDir);
|
|
25
|
+
|
|
26
|
+
for (const outputFactory of outputs) {
|
|
27
|
+
properties.version = pkg.version;
|
|
28
|
+
properties.license = pkg.license;
|
|
29
|
+
|
|
30
|
+
if (properties.verbose) {
|
|
31
|
+
console.log(properties);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const sources = [
|
|
35
|
+
new FileContentProvider(stagingDir + "/")[Symbol.asyncIterator]()
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
const output = new outputFactory(properties);
|
|
39
|
+
|
|
40
|
+
const artifact = await output.create(
|
|
41
|
+
sources,
|
|
42
|
+
[],
|
|
43
|
+
publishingDetails,
|
|
44
|
+
options
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
if (properties.verbose) {
|
|
48
|
+
console.log(artifact);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
await Promise.all(
|
|
52
|
+
publishingDetails.map(publishDetail =>
|
|
53
|
+
output.publish(artifact, publishDetail)
|
|
54
|
+
)
|
|
55
|
+
);
|
|
45
56
|
}
|
|
46
|
-
|
|
47
|
-
await Promise.all(
|
|
48
|
-
publishingDetails.map(publishDetail =>
|
|
49
|
-
output.publish(artifact, publishDetail)
|
|
50
|
-
)
|
|
51
|
-
);
|
|
52
57
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmcf",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.56.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target es2024 --lib esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"npm-pkgbuild": "^17.1.
|
|
41
|
+
"npm-pkgbuild": "^17.1.1",
|
|
42
42
|
"pacc": "^3.3.0",
|
|
43
43
|
"pkg-dir": "^8.0.0"
|
|
44
44
|
},
|
package/src/base.mjs
CHANGED
|
@@ -288,8 +288,13 @@ export class Base {
|
|
|
288
288
|
return `${this.constructor.typeDefinition.name}-${this.name}`;
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
+
get outputs() {
|
|
292
|
+
return new Set();
|
|
293
|
+
}
|
|
294
|
+
|
|
291
295
|
async preparePackage(stagingDir) {
|
|
292
296
|
return {
|
|
297
|
+
outputs: this.outputs,
|
|
293
298
|
properties: {
|
|
294
299
|
name: this.packageName,
|
|
295
300
|
description: `${this.constructor.typeDefinition.name} definitions for ${this.fullName}`,
|
package/src/dns.mjs
CHANGED
|
@@ -104,14 +104,14 @@ export class DNSService extends Base {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
async preparePackage(stagingDir) {
|
|
107
|
-
const
|
|
107
|
+
const result = await super.preparePackage(stagingDir);
|
|
108
108
|
|
|
109
109
|
await generateNamedDefs(this, stagingDir);
|
|
110
110
|
|
|
111
|
-
properties.dependencies = ["mf-named"];
|
|
112
|
-
properties.replaces = ["mf-named-zones"];
|
|
111
|
+
result.properties.dependencies = ["mf-named"];
|
|
112
|
+
result.properties.replaces = ["mf-named-zones"];
|
|
113
113
|
|
|
114
|
-
return
|
|
114
|
+
return result;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
package/src/host.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import { allOutputs } from "npm-pkgbuild";
|
|
3
4
|
import { Base } from "./base.mjs";
|
|
4
5
|
import { networkProperties } from "./network-support.mjs";
|
|
5
6
|
import {
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
copySshKeys,
|
|
18
19
|
generateKnownHosts
|
|
19
20
|
} from "./host-utils.mjs";
|
|
21
|
+
import { OutputFileType } from "typescript";
|
|
20
22
|
|
|
21
23
|
const HostTypeDefinition = {
|
|
22
24
|
name: "host",
|
|
@@ -38,6 +40,7 @@ const HostTypeDefinition = {
|
|
|
38
40
|
serial: { type: "string", collection: false, writeable: true },
|
|
39
41
|
vendor: { type: "string", collection: false, writeable: true },
|
|
40
42
|
chassis: { type: "string", collection: false, writeable: true },
|
|
43
|
+
packaging: { type: "string", collection: false, writeable: true },
|
|
41
44
|
priority: { type: "number", collection: false, writeable: true },
|
|
42
45
|
replaces: { type: "string", collection: true, writeable: true },
|
|
43
46
|
depends: { type: "string", collection: true, writeable: true },
|
|
@@ -66,6 +69,7 @@ export class Host extends Base {
|
|
|
66
69
|
#deployment;
|
|
67
70
|
#chassis;
|
|
68
71
|
#vendor;
|
|
72
|
+
#packaging;
|
|
69
73
|
|
|
70
74
|
static {
|
|
71
75
|
addType(this);
|
|
@@ -142,6 +146,14 @@ export class Host extends Base {
|
|
|
142
146
|
return this.#vendor || this.extends.find(e => e.vendor)?.vendor;
|
|
143
147
|
}
|
|
144
148
|
|
|
149
|
+
set packaging(value) {
|
|
150
|
+
this.#packaging = value;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
get packaging() {
|
|
154
|
+
return this.#packaging || this.extends.find(e => e.packaging)?.packaging;
|
|
155
|
+
}
|
|
156
|
+
|
|
145
157
|
get isTemplate() {
|
|
146
158
|
return this.isModel || this.name.match(/services\//); // TODO
|
|
147
159
|
}
|
|
@@ -325,8 +337,13 @@ export class Host extends Base {
|
|
|
325
337
|
return readFile(join(this.directory, `ssh_host_${type}_key.pub`), "utf8");
|
|
326
338
|
}
|
|
327
339
|
|
|
340
|
+
get outputs()
|
|
341
|
+
{
|
|
342
|
+
return new Set(allOutputs.filter(o=>o.name === this.packaging));
|
|
343
|
+
}
|
|
344
|
+
|
|
328
345
|
async preparePackage(stagingDir) {
|
|
329
|
-
const
|
|
346
|
+
const result = await super.preparePackage(stagingDir);
|
|
330
347
|
await generateNetworkDefs(this, stagingDir);
|
|
331
348
|
await generateMachineInfo(this, stagingDir);
|
|
332
349
|
await copySshKeys(this, stagingDir);
|
|
@@ -335,12 +352,12 @@ export class Host extends Base {
|
|
|
335
352
|
join(stagingDir, "root", ".ssh")
|
|
336
353
|
);
|
|
337
354
|
|
|
338
|
-
properties.dependencies = [this.location.packageName, ...this.depends];
|
|
339
|
-
properties.provides = [...this.provides];
|
|
340
|
-
properties.replaces = [`mf-${this.hostName}`, ...this.replaces];
|
|
341
|
-
properties.backup = "root/.ssh/known_hosts";
|
|
355
|
+
result.properties.dependencies = [this.location.packageName, ...this.depends];
|
|
356
|
+
result.properties.provides = [...this.provides];
|
|
357
|
+
result.properties.replaces = [`mf-${this.hostName}`, ...this.replaces];
|
|
358
|
+
result.properties.backup = "root/.ssh/known_hosts";
|
|
342
359
|
|
|
343
|
-
return
|
|
360
|
+
return result;
|
|
344
361
|
}
|
|
345
362
|
}
|
|
346
363
|
|
package/src/location.mjs
CHANGED
|
@@ -46,7 +46,7 @@ export class Location extends Owner {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
async preparePackage(stagingDir) {
|
|
49
|
-
const
|
|
49
|
+
const result = await super.preparePackage(stagingDir);
|
|
50
50
|
|
|
51
51
|
await writeLines(
|
|
52
52
|
join(stagingDir, "etc/systemd/resolved.conf.d"),
|
|
@@ -83,21 +83,26 @@ export class Location extends Owner {
|
|
|
83
83
|
join(locationDir, "location.json")
|
|
84
84
|
);
|
|
85
85
|
|
|
86
|
-
properties.provides = [
|
|
86
|
+
result.properties.provides = [
|
|
87
87
|
"location",
|
|
88
88
|
"mf-location",
|
|
89
89
|
`mf-location-${this.name}`
|
|
90
90
|
];
|
|
91
|
-
properties.replaces = [`mf-location-${this.name}`];
|
|
91
|
+
result.properties.replaces = [`mf-location-${this.name}`];
|
|
92
92
|
|
|
93
|
+
/*
|
|
93
94
|
const install = "location.install";
|
|
95
|
+
|
|
96
|
+
console.log(new URL(install, import.meta.url));
|
|
97
|
+
|
|
94
98
|
await copyFile(
|
|
95
99
|
new URL(install, import.meta.url),
|
|
96
100
|
join(stagingDir, install)
|
|
97
101
|
);
|
|
98
102
|
|
|
99
|
-
properties.install = install;
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
result.properties.install = install;
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
return result;
|
|
102
107
|
}
|
|
103
108
|
}
|
package/src/owner.mjs
CHANGED
|
@@ -278,6 +278,15 @@ export class Owner extends Base {
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
+
get outputs() {
|
|
282
|
+
let all = new Set();
|
|
283
|
+
for (const host of this.hosts()) {
|
|
284
|
+
all = all.union(host.outputs);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return all;
|
|
288
|
+
}
|
|
289
|
+
|
|
281
290
|
*networkAddresses() {
|
|
282
291
|
for (const host of this.hosts()) {
|
|
283
292
|
yield* host.networkAddresses();
|
package/types/base.d.mts
CHANGED
package/types/host.d.mts
CHANGED
|
@@ -86,6 +86,11 @@ export class Host extends Base {
|
|
|
86
86
|
collection: boolean;
|
|
87
87
|
writeable: boolean;
|
|
88
88
|
};
|
|
89
|
+
packaging: {
|
|
90
|
+
type: string;
|
|
91
|
+
collection: boolean;
|
|
92
|
+
writeable: boolean;
|
|
93
|
+
};
|
|
89
94
|
priority: {
|
|
90
95
|
type: string;
|
|
91
96
|
collection: boolean;
|
|
@@ -155,6 +160,8 @@ export class Host extends Base {
|
|
|
155
160
|
get chassis(): any;
|
|
156
161
|
set vendor(value: any);
|
|
157
162
|
get vendor(): any;
|
|
163
|
+
set packaging(value: any);
|
|
164
|
+
get packaging(): any;
|
|
158
165
|
get isTemplate(): true | RegExpMatchArray;
|
|
159
166
|
get isModel(): boolean;
|
|
160
167
|
get model(): any;
|
|
@@ -182,6 +189,7 @@ export class Host extends Base {
|
|
|
182
189
|
get rawAddresses(): any[];
|
|
183
190
|
get cidrAddresses(): any[];
|
|
184
191
|
publicKey(type?: string): Promise<string>;
|
|
192
|
+
get outputs(): Set<typeof import("npm-pkgbuild").OCI | typeof import("npm-pkgbuild").DOCKER>;
|
|
185
193
|
#private;
|
|
186
194
|
}
|
|
187
195
|
export class NetworkInterface extends Base {
|