pmcf 4.5.4 → 4.6.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 +28 -1
- package/src/hooks.mjs +8 -8
- package/src/host.mjs +7 -7
- package/src/location.mjs +6 -5
- package/src/services/openldap.mjs +9 -44
- package/types/base.d.mts +1 -0
- package/types/hooks.d.mts +2 -2
- package/types/host.d.mts +0 -1
- package/types/location.d.mts +0 -1
- package/types/services/openldap.d.mts +4 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmcf",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"content-entry-transform": "^1.
|
|
56
|
+
"content-entry-transform": "^1.6.0",
|
|
57
57
|
"ip-utilties": "^2.0.2",
|
|
58
58
|
"npm-pkgbuild": "^20.0.1",
|
|
59
59
|
"pacc": "^8.0.2",
|
package/src/base.mjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { allOutputs } from "npm-pkgbuild";
|
|
3
|
+
import {
|
|
4
|
+
createExpressionTransformer,
|
|
5
|
+
transform
|
|
6
|
+
} from "content-entry-transform";
|
|
7
|
+
import { FileContentProvider } from "npm-pkgbuild";
|
|
3
8
|
import {
|
|
4
9
|
getAttribute,
|
|
5
10
|
typeFactory,
|
|
@@ -19,7 +24,6 @@ import {
|
|
|
19
24
|
description_attribute_writable,
|
|
20
25
|
boolean_attribute_writable
|
|
21
26
|
} from "pacc";
|
|
22
|
-
|
|
23
27
|
import { asArray } from "./utils.mjs";
|
|
24
28
|
|
|
25
29
|
/**
|
|
@@ -560,6 +564,29 @@ export class Base {
|
|
|
560
564
|
|
|
561
565
|
async *preparePackages(stagingDir) {}
|
|
562
566
|
|
|
567
|
+
templateContent(entryProperties, directoryProperties) {
|
|
568
|
+
const transformers = [
|
|
569
|
+
createExpressionTransformer(
|
|
570
|
+
e => e.isBlob,
|
|
571
|
+
expression =>
|
|
572
|
+
parse(expression, {
|
|
573
|
+
root: this,
|
|
574
|
+
getGlobal: id => this.getGlobal(id)
|
|
575
|
+
})
|
|
576
|
+
)
|
|
577
|
+
];
|
|
578
|
+
|
|
579
|
+
return [...this.allExtends(), this].map(e => {
|
|
580
|
+
const dir = join(e.directory, "content") + "/";
|
|
581
|
+
console.log("DIR", dir);
|
|
582
|
+
|
|
583
|
+
return transform(
|
|
584
|
+
new FileContentProvider(dir, entryProperties, directoryProperties),
|
|
585
|
+
transformers
|
|
586
|
+
);
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
|
|
563
590
|
get tags() {
|
|
564
591
|
return this._tags;
|
|
565
592
|
}
|
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(
|
|
4
|
+
export async function loadHooks(packageData, file) {
|
|
5
5
|
for await (const f of extractFunctions(createReadStream(file, "utf8"))) {
|
|
6
|
-
addHook(
|
|
6
|
+
addHook(packageData, f.name, f.body);
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
return hooks;
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
export function addHook(
|
|
13
|
-
|
|
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
|
|
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
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
1
|
import { FileContentProvider } from "npm-pkgbuild";
|
|
3
2
|
import {
|
|
4
3
|
string_attribute_writable,
|
|
@@ -9,10 +8,6 @@ import {
|
|
|
9
8
|
import { addServiceType } from "pmcf";
|
|
10
9
|
import { ServiceTypeDefinition, Service } from "../service.mjs";
|
|
11
10
|
import { addHook } from "../hooks.mjs";
|
|
12
|
-
import {
|
|
13
|
-
createExpressionTransformer,
|
|
14
|
-
transform
|
|
15
|
-
} from "content-entry-transform";
|
|
16
11
|
|
|
17
12
|
const OpenLDAPServiceTypeDefinition = {
|
|
18
13
|
name: "openldap",
|
|
@@ -21,8 +16,7 @@ const OpenLDAPServiceTypeDefinition = {
|
|
|
21
16
|
owners: ServiceTypeDefinition.owners,
|
|
22
17
|
key: "name",
|
|
23
18
|
attributes: {
|
|
24
|
-
|
|
25
|
-
rootDN: string_attribute_writable,
|
|
19
|
+
base: string_attribute_writable,
|
|
26
20
|
uri: string_attribute_writable,
|
|
27
21
|
|
|
28
22
|
DB_CONFIG: {
|
|
@@ -67,27 +61,18 @@ export class OpenLDAPService extends Service {
|
|
|
67
61
|
return OpenLDAPServiceTypeDefinition;
|
|
68
62
|
}
|
|
69
63
|
|
|
70
|
-
|
|
71
|
-
_rootDN;
|
|
64
|
+
_base;
|
|
72
65
|
|
|
73
66
|
get type() {
|
|
74
67
|
return OpenLDAPServiceTypeDefinition.name;
|
|
75
68
|
}
|
|
76
69
|
|
|
77
|
-
get
|
|
78
|
-
return this.expand(this.
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
set baseDN(value) {
|
|
82
|
-
this._baseDN = value;
|
|
70
|
+
get base() {
|
|
71
|
+
return this.expand(this._base);
|
|
83
72
|
}
|
|
84
73
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
set rootDN(value) {
|
|
90
|
-
this._rootDN = value;
|
|
74
|
+
set base(value) {
|
|
75
|
+
this._base = value;
|
|
91
76
|
}
|
|
92
77
|
|
|
93
78
|
get uri() {
|
|
@@ -98,25 +83,6 @@ export class OpenLDAPService extends Service {
|
|
|
98
83
|
this._uri = value;
|
|
99
84
|
}
|
|
100
85
|
|
|
101
|
-
templateContent(entryProperties, directoryProperties) {
|
|
102
|
-
const transformers = [
|
|
103
|
-
createExpressionTransformer(e => true, {
|
|
104
|
-
base: this.baseDN,
|
|
105
|
-
uri: this.uri
|
|
106
|
-
})
|
|
107
|
-
];
|
|
108
|
-
|
|
109
|
-
return [...this.allExtends(), this].map(e => {
|
|
110
|
-
const dir = join(e.directory, "content") + "/";
|
|
111
|
-
console.log("DIR", dir);
|
|
112
|
-
|
|
113
|
-
return transform(
|
|
114
|
-
new FileContentProvider(dir, entryProperties, directoryProperties),
|
|
115
|
-
transformers
|
|
116
|
-
);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
86
|
async *preparePackages(dir) {
|
|
121
87
|
const host = this.host;
|
|
122
88
|
const name = host.name;
|
|
@@ -145,19 +111,18 @@ export class OpenLDAPService extends Service {
|
|
|
145
111
|
name: `${this.typeName}-${this.location.name}-${name}`,
|
|
146
112
|
description: `${this.typeName} definitions for ${this.fullName}@${name}`,
|
|
147
113
|
access: "private",
|
|
148
|
-
dependencies: ["openldap>=2.6.10"]
|
|
149
|
-
hooks: {}
|
|
114
|
+
dependencies: ["openldap>=2.6.10"]
|
|
150
115
|
}
|
|
151
116
|
};
|
|
152
117
|
|
|
153
118
|
addHook(
|
|
154
|
-
packageData
|
|
119
|
+
packageData,
|
|
155
120
|
"post_upgrade",
|
|
156
121
|
`setfacl -m u:${owner}:r /etc/letsencrypt/archive/*/privkey*.pem`
|
|
157
122
|
);
|
|
158
123
|
|
|
159
124
|
addHook(
|
|
160
|
-
packageData
|
|
125
|
+
packageData,
|
|
161
126
|
"post_install",
|
|
162
127
|
`setfacl -m u:${owner}:r /etc/letsencrypt/archive/*/privkey*.pem`
|
|
163
128
|
);
|
package/types/base.d.mts
CHANGED
|
@@ -123,6 +123,7 @@ export class Base {
|
|
|
123
123
|
get derivedPackaging(): any;
|
|
124
124
|
get outputs(): Set<typeof import("npm-pkgbuild").OCI | typeof import("npm-pkgbuild").DOCKER>;
|
|
125
125
|
preparePackages(stagingDir: any): AsyncGenerator<never, void, unknown>;
|
|
126
|
+
templateContent(entryProperties: any, directoryProperties: any): any[];
|
|
126
127
|
set tags(value: Set<any>);
|
|
127
128
|
get tags(): Set<any>;
|
|
128
129
|
get isTemplate(): any;
|
package/types/hooks.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export function loadHooks(
|
|
2
|
-
export function addHook(
|
|
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
package/types/location.d.mts
CHANGED
|
@@ -743,8 +743,7 @@ export class OpenLDAPService extends Service {
|
|
|
743
743
|
})[];
|
|
744
744
|
key: string;
|
|
745
745
|
attributes: {
|
|
746
|
-
|
|
747
|
-
rootDN: import("pacc").AttributeDefinition;
|
|
746
|
+
base: import("pacc").AttributeDefinition;
|
|
748
747
|
uri: import("pacc").AttributeDefinition;
|
|
749
748
|
DB_CONFIG: {
|
|
750
749
|
attributes: {
|
|
@@ -864,17 +863,13 @@ export class OpenLDAPService extends Service {
|
|
|
864
863
|
services: {};
|
|
865
864
|
};
|
|
866
865
|
};
|
|
867
|
-
|
|
868
|
-
_rootDN: any;
|
|
866
|
+
_base: any;
|
|
869
867
|
get type(): string;
|
|
870
|
-
set
|
|
871
|
-
get
|
|
872
|
-
set rootDN(value: any);
|
|
873
|
-
get rootDN(): any;
|
|
868
|
+
set base(value: any);
|
|
869
|
+
get base(): any;
|
|
874
870
|
set uri(value: any);
|
|
875
871
|
get uri(): any;
|
|
876
872
|
_uri: any;
|
|
877
|
-
templateContent(entryProperties: any, directoryProperties: any): any[];
|
|
878
873
|
preparePackages(dir: any): AsyncGenerator<{
|
|
879
874
|
dir: any;
|
|
880
875
|
sources: any[];
|
|
@@ -884,7 +879,6 @@ export class OpenLDAPService extends Service {
|
|
|
884
879
|
description: string;
|
|
885
880
|
access: string;
|
|
886
881
|
dependencies: string[];
|
|
887
|
-
hooks: {};
|
|
888
882
|
};
|
|
889
883
|
}, void, unknown>;
|
|
890
884
|
}
|