pmcf 1.2.0 → 1.2.2

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/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  [![npm](https://img.shields.io/npm/v/pmcf.svg)](https://www.npmjs.com/package/pmcf)
2
2
  [![License](https://img.shields.io/badge/License-0BSD-blue.svg)](https://spdx.org/licenses/0BSD.html)
3
+ [![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript\&label\&labelColor=blue\&color=555555)](https://typescriptlang.org)
3
4
  [![bundlejs](https://deno.bundlejs.com/?q=pmcf\&badge=detailed)](https://bundlejs.com/?q=pmcf)
4
5
  [![downloads](http://img.shields.io/npm/dm/pmcf.svg?style=flat-square)](https://npmjs.org/package/pmcf)
5
6
  [![GitHub Issues](https://img.shields.io/github/issues/arlac77/pmcf.svg?style=flat-square)](https://github.com/arlac77/pmcf/issues)
@@ -4,12 +4,11 @@ import { World } from "../src/model.mjs";
4
4
 
5
5
  const world = new World(argv[2] || cwd());
6
6
 
7
- const locationName = argv[3];
7
+ const objectName = argv[3];
8
8
 
9
- if (locationName) {
10
- const location = await world.location(locationName);
11
- await location.load();
12
- console.log(location.toJSON());
9
+ if (objectName) {
10
+ const object = await world.named(objectName);
11
+ console.log(object.toJSON());
13
12
  } else {
14
13
  for await (const location of world.locations()) {
15
14
  console.log(location.name);
package/package.json CHANGED
@@ -1,13 +1,18 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
+ "exports": {
8
+ ".": {
9
+ "default": "./src/model.mjs"
10
+ }
11
+ },
7
12
  "description": "Poor mans configuration management",
8
13
  "keywords": [
9
- "config management",
10
- "config"
14
+ "config",
15
+ "config management"
11
16
  ],
12
17
  "contributors": [
13
18
  {
@@ -17,26 +22,30 @@
17
22
  ],
18
23
  "license": "0BSD",
19
24
  "bin": {
20
- "gen-host-defs": "./bin/gen-host-defs",
21
- "gen-location-defs": "./bin/gen-location-defs",
22
- "gen-named-defs": "./bin/gen-named-defs",
23
- "host-info": "./bin/host-info",
24
- "location-info": "./bin/location-info",
25
- "network": "./bin/network"
25
+ "pmcf-host-defs": "./bin/pmcf-host-defs",
26
+ "pmcf-location-defs": "./bin/pmcf-location-defs",
27
+ "pmcf-named-defs": "./bin/pmcf-named-defs",
28
+ "pmcf-info": "./bin/pmcf-info",
29
+ "pmcf-network": "./bin/pmcf-network"
26
30
  },
27
31
  "scripts": {
32
+ "prepare": "node --run prepare:typescript",
33
+ "prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types --resolveJsonModule --target es2024 --lib es2024 -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
28
34
  "test": "node --run test:ava",
29
35
  "test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
30
36
  "cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp",
31
37
  "docs": "documentation readme --section=API ./src**/*.mjs",
32
- "lint": "node --run lint:docs",
33
- "lint:docs": "documentation lint ./src**/*.mjs"
38
+ "lint": "node --run lint:docs && node --run lint:typescript",
39
+ "lint:docs": "documentation lint ./src**/*.mjs",
40
+ "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target es2024 --lib es2024 -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
34
41
  },
35
42
  "devDependencies": {
43
+ "@types/node": "^22.10.7",
36
44
  "ava": "^6.2.0",
37
45
  "c8": "^10.1.3",
38
46
  "documentation": "^14.0.3",
39
- "semantic-release": "^24.2.1"
47
+ "semantic-release": "^24.2.1",
48
+ "typescript": "^5.7.3"
40
49
  },
41
50
  "engines": {
42
51
  "node": ">=22.13.0"
@@ -52,7 +61,8 @@
52
61
  "template": {
53
62
  "inheritFrom": [
54
63
  "arlac77/template-arlac77-github",
55
- "arlac77/template-node-app"
64
+ "arlac77/template-node-app",
65
+ "arlac77/template-typescript"
56
66
  ]
57
67
  }
58
68
  }
package/src/model.mjs CHANGED
@@ -114,8 +114,6 @@ export class World {
114
114
  directory;
115
115
  #byName = new Map();
116
116
 
117
- /** @typedef {Map<string,Host>} */ #hosts = new Map();
118
-
119
117
  constructor(directory) {
120
118
  this.directory = directory;
121
119
  }
@@ -137,10 +135,7 @@ export class World {
137
135
 
138
136
  data.name = baseName;
139
137
 
140
- const t2 = type.refinedType(data);
141
- if (t2) {
142
- type = t2;
143
- }
138
+ type = type.refinedType(data);
144
139
  const object = new type(this, data);
145
140
  this.#byName.set(data.name, object);
146
141
  }
@@ -188,7 +183,6 @@ export class World {
188
183
  await this.load();
189
184
  return this.#byName.get(Host.baseName(name));
190
185
  /*
191
-
192
186
  if (!data.name) {
193
187
  data.name = name;
194
188
  } else {
@@ -0,0 +1,161 @@
1
+ export function writeLines(dir: any, name: any, lines: any): Promise<void>;
2
+ export function sectionLines(sectionName: any, values: any): string[];
3
+ export class Base {
4
+ static get typeName(): string;
5
+ static get typeFileName(): string;
6
+ static get fileNameGlob(): string;
7
+ static refinedType(data: any): typeof Base;
8
+ static baseName(name: any): any;
9
+ constructor(owner: any, data: any);
10
+ owner: any;
11
+ name: any;
12
+ description: any;
13
+ get typeName(): any;
14
+ get host(): any;
15
+ get network(): any;
16
+ set directory(directory: any);
17
+ get directory(): any;
18
+ expand(object: any): any;
19
+ toString(): string;
20
+ toJSON(): {
21
+ name: any;
22
+ directory: any;
23
+ owner: any;
24
+ description: any;
25
+ };
26
+ #private;
27
+ }
28
+ export class World {
29
+ static get types(): {
30
+ [k: string]: typeof Host | typeof Network | typeof Location | typeof Subnet | typeof Service;
31
+ };
32
+ constructor(directory: any);
33
+ directory: any;
34
+ get name(): string;
35
+ load(): Promise<void>;
36
+ named(name: any): Promise<any>;
37
+ locations(): AsyncGenerator<Location, void, unknown>;
38
+ hosts(): AsyncGenerator<Host, void, unknown>;
39
+ domains(): AsyncGenerator<any, void, unknown>;
40
+ location(name: any): Promise<any>;
41
+ host(name: any): Promise<any>;
42
+ subnets(): AsyncGenerator<any, void, unknown>;
43
+ networkAddresses(): AsyncGenerator<{
44
+ address: any;
45
+ networkInterface: any;
46
+ }, void, unknown>;
47
+ #private;
48
+ }
49
+ export class Host extends Base {
50
+ static refinedType(data: any): typeof Host;
51
+ networkInterfaces: {};
52
+ services: {};
53
+ postinstall: any[];
54
+ location: any;
55
+ get deployment(): any;
56
+ get extends(): any[];
57
+ get provides(): Set<any>;
58
+ get replaces(): Set<any>;
59
+ get _depends(): Set<any>;
60
+ get depends(): any;
61
+ get master(): boolean;
62
+ get os(): any;
63
+ get distribution(): any;
64
+ get model(): Model;
65
+ get domain(): any;
66
+ get modelName(): any;
67
+ get hostName(): any;
68
+ get domainName(): string;
69
+ networkAddresses(): Generator<{
70
+ address: any;
71
+ networkInterface: any;
72
+ }, void, unknown>;
73
+ get ipAddress(): any;
74
+ publicKey(type?: string): Promise<string>;
75
+ toJSON(): {
76
+ extends: any[];
77
+ services: any;
78
+ name: any;
79
+ directory: any;
80
+ owner: any;
81
+ description: any;
82
+ };
83
+ #private;
84
+ }
85
+ export class Model extends Host {
86
+ }
87
+ export class Location extends Base {
88
+ domain: any;
89
+ dns: any;
90
+ load(): Promise<void>;
91
+ hosts(): AsyncGenerator<any, void, unknown>;
92
+ service(filter: any): Promise<any>;
93
+ services(filter: any): AsyncGenerator<any, void, unknown>;
94
+ network(name: any): any;
95
+ networkAddresses(): AsyncGenerator<any, void, unknown>;
96
+ networks(): AsyncGenerator<any, void, unknown>;
97
+ subnets(): AsyncGenerator<any, void, unknown>;
98
+ addNetwork(data: any): any;
99
+ addHost(host: any): void;
100
+ get dnsAllowedUpdates(): any;
101
+ get dnsRecordTTL(): any;
102
+ get administratorEmail(): any;
103
+ toJSON(): {
104
+ domain: any;
105
+ hosts: any[];
106
+ name: any;
107
+ directory: any;
108
+ owner: any;
109
+ description: any;
110
+ };
111
+ #private;
112
+ }
113
+ export class Network extends Base {
114
+ kind: any;
115
+ scope: any;
116
+ metric: any;
117
+ ipv4: any;
118
+ ipv4_netmask: any;
119
+ subnet: any;
120
+ get subnetAddress(): any;
121
+ hosts(): AsyncGenerator<any, void, unknown>;
122
+ addHost(host: any): void;
123
+ toJSON(): {
124
+ kind: any;
125
+ ipv4: any;
126
+ scope: any;
127
+ metric: any;
128
+ name: any;
129
+ directory: any;
130
+ owner: any;
131
+ description: any;
132
+ };
133
+ #private;
134
+ }
135
+ export class Subnet extends Base {
136
+ networks: Set<any>;
137
+ get address(): any;
138
+ }
139
+ export class Service extends Base {
140
+ alias: any;
141
+ get prefix(): any;
142
+ get ipAddress(): any;
143
+ get port(): any;
144
+ get priority(): any;
145
+ get weight(): any;
146
+ get master(): any;
147
+ get type(): any;
148
+ toJSON(): {
149
+ ipAddress: any;
150
+ alias: any;
151
+ type: any;
152
+ master: any;
153
+ priority: any;
154
+ weight: any;
155
+ name: any;
156
+ directory: any;
157
+ owner: any;
158
+ description: any;
159
+ };
160
+ #private;
161
+ }
package/bin/host-info DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env node
2
- import { cwd, argv } from "node:process";
3
- import { World } from "../src/model.mjs";
4
-
5
- const world = new World(argv[2] || cwd());
6
-
7
- const hostName = argv[3];
8
-
9
- if (hostName) {
10
- const host = await world.host(hostName);
11
- console.log(host.toJSON());
12
- } else {
13
- for await (const host of world.hosts()) {
14
- console.log(host.name);
15
- }
16
- }
File without changes
File without changes
File without changes
File without changes