pmcf 1.61.11 → 1.62.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 +2 -2
- package/src/base.mjs +19 -13
- package/src/host.mjs +5 -4
- package/src/location.mjs +6 -4
- package/types/base.d.mts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmcf",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.62.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.
|
|
41
|
+
"npm-pkgbuild": "^17.3.0",
|
|
42
42
|
"pacc": "^3.3.0",
|
|
43
43
|
"pkg-dir": "^8.0.0"
|
|
44
44
|
},
|
package/src/base.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { createReadStream } from "node:fs";
|
|
3
|
+
import { allOutputs, extractFunctions } from "npm-pkgbuild";
|
|
3
4
|
import { getAttribute } from "pacc";
|
|
4
5
|
import { addType, primitives } from "./types.mjs";
|
|
5
6
|
|
|
@@ -203,20 +204,18 @@ export class Base {
|
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
206
|
|
|
206
|
-
named(name)
|
|
207
|
-
{
|
|
208
|
-
}
|
|
207
|
+
named(name) {}
|
|
209
208
|
|
|
210
209
|
typeNamed(typeName, name) {
|
|
211
210
|
if (this.owner) {
|
|
212
211
|
const object = this.owner.typeNamed(typeName, name); // TODO split
|
|
213
|
-
if(object) {
|
|
212
|
+
if (object) {
|
|
214
213
|
return object;
|
|
215
214
|
}
|
|
216
215
|
}
|
|
217
216
|
|
|
218
217
|
const object = this.named(name);
|
|
219
|
-
if(object?.typeName === typeName) {
|
|
218
|
+
if (object?.typeName === typeName) {
|
|
220
219
|
return object;
|
|
221
220
|
}
|
|
222
221
|
}
|
|
@@ -337,18 +336,25 @@ export class Base {
|
|
|
337
336
|
return this.#packaging;
|
|
338
337
|
}
|
|
339
338
|
|
|
339
|
+
#packageHooks = {};
|
|
340
340
|
|
|
341
|
-
|
|
341
|
+
get packageHooks() {
|
|
342
|
+
return this.#packageHooks;
|
|
343
|
+
}
|
|
342
344
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if(hook) {
|
|
347
|
-
content = hook + content;
|
|
345
|
+
async loadPackageHooks(file) {
|
|
346
|
+
for await (const f of extractFunctions(createReadStream(file, "utf8"))) {
|
|
347
|
+
this.addPackageHook(f.name, f.body);
|
|
348
348
|
}
|
|
349
|
+
}
|
|
349
350
|
|
|
350
|
-
|
|
351
|
+
addPackageHook(name, content) {
|
|
352
|
+
const hook = this.#packageHooks[name];
|
|
353
|
+
if (hook) {
|
|
354
|
+
content = hook + "\n" + content;
|
|
355
|
+
}
|
|
351
356
|
|
|
357
|
+
this.#packageHooks[name] = content;
|
|
352
358
|
}
|
|
353
359
|
|
|
354
360
|
get outputs() {
|
package/src/host.mjs
CHANGED
|
@@ -346,6 +346,10 @@ export class Host extends Base {
|
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
async *preparePackages(stagingDir) {
|
|
349
|
+
await this.loadPackageHooks(
|
|
350
|
+
new URL("host.install", import.meta.url).pathname
|
|
351
|
+
);
|
|
352
|
+
|
|
349
353
|
for await (const result of super.preparePackages(stagingDir)) {
|
|
350
354
|
await generateNetworkDefs(this, stagingDir);
|
|
351
355
|
await generateMachineInfo(this, stagingDir);
|
|
@@ -363,10 +367,7 @@ export class Host extends Base {
|
|
|
363
367
|
result.properties.provides = [...this.provides];
|
|
364
368
|
result.properties.replaces = [`mf-${this.hostName}`, ...this.replaces];
|
|
365
369
|
result.properties.backup = "root/.ssh/known_hosts";
|
|
366
|
-
result.properties.hooks =
|
|
367
|
-
"host.install",
|
|
368
|
-
import.meta.url
|
|
369
|
-
).pathname;
|
|
370
|
+
result.properties.hooks = this.packageHooks;
|
|
370
371
|
|
|
371
372
|
result.sources.push(
|
|
372
373
|
new FileContentProvider(stagingDir + "/")[Symbol.asyncIterator]()
|
package/src/location.mjs
CHANGED
|
@@ -47,6 +47,11 @@ export class Location extends Owner {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
async *preparePackages(stagingDir) {
|
|
50
|
+
|
|
51
|
+
await this.loadPackageHooks(
|
|
52
|
+
new URL("location.install", import.meta.url).pathname
|
|
53
|
+
);
|
|
54
|
+
|
|
50
55
|
for await (const result of super.preparePackages(stagingDir)) {
|
|
51
56
|
await writeLines(
|
|
52
57
|
join(stagingDir, "etc/systemd/resolved.conf.d"),
|
|
@@ -97,10 +102,7 @@ export class Location extends Owner {
|
|
|
97
102
|
new FileContentProvider(stagingDir + "/")[Symbol.asyncIterator]()
|
|
98
103
|
);
|
|
99
104
|
|
|
100
|
-
result.properties.hooks =
|
|
101
|
-
"location.install",
|
|
102
|
-
import.meta.url
|
|
103
|
-
).pathname;
|
|
105
|
+
result.properties.hooks = this.packageHooks;
|
|
104
106
|
|
|
105
107
|
yield result;
|
|
106
108
|
}
|
package/types/base.d.mts
CHANGED
|
@@ -70,6 +70,8 @@ export class Base {
|
|
|
70
70
|
set packaging(value: Set<any>);
|
|
71
71
|
get packaging(): Set<any>;
|
|
72
72
|
get derivedPackaging(): any;
|
|
73
|
+
get packageHooks(): {};
|
|
74
|
+
loadPackageHooks(file: any): Promise<void>;
|
|
73
75
|
addPackageHook(name: any, content: any): void;
|
|
74
76
|
get outputs(): Set<typeof import("npm-pkgbuild").ARCH | typeof import("npm-pkgbuild").DOCKER>;
|
|
75
77
|
preparePackages(stagingDir: any): AsyncGenerator<{
|