pmcf 4.5.4 → 4.5.5

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": "pmcf",
3
- "version": "4.5.4",
3
+ "version": "4.5.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/hooks.mjs CHANGED
@@ -1,21 +1,21 @@
1
1
  import { createReadStream } from "node:fs";
2
2
  import { extractFunctions } from "npm-pkgbuild";
3
3
 
4
- export async function loadHooks(hooks, file) {
4
+ export async function loadHooks(packageData, file) {
5
5
  for await (const f of extractFunctions(createReadStream(file, "utf8"))) {
6
- addHook(hooks, f.name, f.body);
6
+ addHook(packageData, f.name, f.body);
7
7
  }
8
-
9
- return hooks;
10
8
  }
11
9
 
12
- export function addHook(hooks, name, content) {
13
- const hook = hooks[name];
10
+ export function addHook(packageData, name, content) {
11
+ packageData.properties.hooks ||= {};
12
+
13
+ const hook = packageData.properties.hooks[name];
14
14
  if (hook) {
15
15
  content = hook + "\n" + content;
16
16
  }
17
17
 
18
- hooks[name] = content;
18
+ packageData.properties.hooks[name] = content;
19
19
 
20
- return hooks;
20
+ return packageData.properties.hooks;
21
21
  }
package/src/host.mjs CHANGED
@@ -17,7 +17,6 @@ import {
17
17
  domainFromDominName,
18
18
  domainName,
19
19
  writeLines,
20
- sectionLines,
21
20
  asArray
22
21
  } from "./utils.mjs";
23
22
  import { loadHooks } from "./hooks.mjs";
@@ -451,14 +450,15 @@ export class Host extends ServiceOwner {
451
450
  provides: [...this.provides],
452
451
  replaces: [...this.replaces],
453
452
  requires: [],
454
- backup: "root/.ssh/known_hosts",
455
- hooks: await loadHooks(
456
- {},
457
- new URL("host.install", import.meta.url).pathname
458
- )
453
+ backup: "root/.ssh/known_hosts"
459
454
  }
460
455
  };
461
456
 
457
+ await loadHooks(
458
+ packageData,
459
+ new URL("host.install", import.meta.url).pathname
460
+ );
461
+
462
462
  for (const ni of this.networkInterfaces.values()) {
463
463
  await ni.systemdDefinitions(packageData);
464
464
  }
@@ -478,7 +478,7 @@ export class Host extends ServiceOwner {
478
478
  await writeLines(dir, configFileName, content);
479
479
 
480
480
  addHook(
481
- packageData.properties.hooks,
481
+ packageData,
482
482
  "post_install",
483
483
  `systemctl enable ${serviceName}`
484
484
  );
package/src/location.mjs CHANGED
@@ -55,14 +55,15 @@ export class Location extends Owner {
55
55
  access: "private",
56
56
  dependencies: { jq: ">=1.8" },
57
57
  provides: ["location", "mf-location"],
58
- replaces: [`mf-location-${this.name}`],
59
- hooks: await loadHooks(
60
- {},
61
- new URL("location.install", import.meta.url).pathname
62
- )
58
+ replaces: [`mf-location-${this.name}`]
63
59
  }
64
60
  };
65
61
 
62
+ await loadHooks(
63
+ packageData,
64
+ new URL("location.install", import.meta.url).pathname
65
+ );
66
+
66
67
  yield packageData;
67
68
  }
68
69
  }
@@ -145,19 +145,18 @@ export class OpenLDAPService extends Service {
145
145
  name: `${this.typeName}-${this.location.name}-${name}`,
146
146
  description: `${this.typeName} definitions for ${this.fullName}@${name}`,
147
147
  access: "private",
148
- dependencies: ["openldap>=2.6.10"],
149
- hooks: {}
148
+ dependencies: ["openldap>=2.6.10"]
150
149
  }
151
150
  };
152
151
 
153
152
  addHook(
154
- packageData.properties.hooks,
153
+ packageData,
155
154
  "post_upgrade",
156
155
  `setfacl -m u:${owner}:r /etc/letsencrypt/archive/*/privkey*.pem`
157
156
  );
158
157
 
159
158
  addHook(
160
- packageData.properties.hooks,
159
+ packageData,
161
160
  "post_install",
162
161
  `setfacl -m u:${owner}:r /etc/letsencrypt/archive/*/privkey*.pem`
163
162
  );
package/types/hooks.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export function loadHooks(hooks: any, file: any): Promise<any>;
2
- export function addHook(hooks: any, name: any, content: any): any;
1
+ export function loadHooks(packageData: any, file: any): Promise<void>;
2
+ export function addHook(packageData: any, name: any, content: any): any;
package/types/host.d.mts CHANGED
@@ -265,7 +265,6 @@ export class Host extends ServiceOwner {
265
265
  replaces: any[];
266
266
  requires: any[];
267
267
  backup: string;
268
- hooks: any;
269
268
  };
270
269
  }, void, unknown>;
271
270
  }
@@ -362,7 +362,6 @@ export class Location extends Owner {
362
362
  };
363
363
  provides: string[];
364
364
  replaces: string[];
365
- hooks: any;
366
365
  };
367
366
  }, void, unknown>;
368
367
  }
@@ -884,7 +884,6 @@ export class OpenLDAPService extends Service {
884
884
  description: string;
885
885
  access: string;
886
886
  dependencies: string[];
887
- hooks: {};
888
887
  };
889
888
  }, void, unknown>;
890
889
  }