pmcf 2.36.2 → 2.37.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 CHANGED
@@ -1,19 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { join } from "node:path";
3
+ import { join, resolve } from "node:path";
4
4
  import { readFile, mkdtemp } from "node:fs/promises";
5
5
  import { tmpdir } from "node:os";
6
- import { env } from "node:process";
6
+ import { cwd, env } from "node:process";
7
7
  import { packageDirectory } from "pkg-dir";
8
8
  import { createPublishingDetails } from "npm-pkgbuild";
9
9
  import { prepare } from "../src/cli.mjs";
10
10
  import { asArray } from "../src/utils.mjs";
11
11
 
12
- const { root, args, options } = await prepare();
12
+ const { root, args, options } = await prepare({
13
+ publish: {
14
+ type: "string"
15
+ },
16
+ output: {
17
+ type: "string",
18
+ short: "o"
19
+ }
20
+ });
13
21
 
14
- if (!options.output) {
15
- options.output = await mkdtemp(join(tmpdir(), "pmcf"));
16
- }
22
+ options.output = options.output
23
+ ? resolve(cwd(), options.output)
24
+ : await mkdtemp(join(tmpdir(), "pmcf"));
17
25
 
18
26
  const pkgDir = await packageDirectory({ cwd: options.root });
19
27
  const pkg = JSON.parse(await readFile(join(pkgDir, "package.json"), "utf8"));
@@ -43,7 +51,7 @@ for (const name of args) {
43
51
  const output = new outputFactory(properties);
44
52
 
45
53
  const artifact = await output.create(
46
- sources.map(source=>source[Symbol.asyncIterator]()),
54
+ sources.map(source => source[Symbol.asyncIterator]()),
47
55
  [],
48
56
  publishingDetails,
49
57
  options
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "2.36.2",
3
+ "version": "2.37.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/cli.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import { parseArgs } from "node:util";
2
- import { resolve } from "node:path";
3
2
  import { argv, cwd, env } from "node:process";
4
3
  import { Root } from "./module.mjs";
5
4
 
@@ -17,26 +16,15 @@ export async function prepare(options = {}) {
17
16
  type: "boolean",
18
17
  default: false
19
18
  },
20
- publish: {
21
- type: "string"
22
- },
23
19
  root: {
24
20
  type: "string",
25
21
  short: "r",
26
22
  default: env.PMCF_ROOT || cwd()
27
- },
28
- output: {
29
- type: "string",
30
- short: "o"
31
23
  }
32
24
  },
33
25
  allowPositionals: true
34
26
  });
35
27
 
36
- if (values.output) {
37
- values.output = resolve(cwd(), values.output);
38
- }
39
-
40
28
  const root = new Root(values.root);
41
29
 
42
30
  await root.loadAll();
package/src/endpoint.mjs CHANGED
@@ -53,3 +53,12 @@ export class DomainNameEndpoint {
53
53
  return `${this.address}[${this.port}]`;
54
54
  }
55
55
  }
56
+
57
+ export class HTTPEndpoint {
58
+ constructor(service, url, data) {
59
+ this.service = service;
60
+ this.url = url;
61
+ Object.assign(this, data);
62
+ }
63
+
64
+ }
package/src/service.mjs CHANGED
@@ -10,6 +10,9 @@ import {
10
10
  } from "./dns-utils.mjs";
11
11
 
12
12
  const ServiceTypes = {
13
+ "pacman-repo": {
14
+ extends: ["https"]
15
+ },
13
16
  ntp: { endpoints: [{ protocol: "udp", port: 123, tls: false }] },
14
17
  dns: { endpoints: [{ protocol: "udp", port: 53, tls: false }] },
15
18
  ldap: { endpoints: [{ protocol: "tcp", port: 389, tls: false }] },
@@ -22,7 +25,6 @@ const ServiceTypes = {
22
25
  http3: {
23
26
  extends: ["https"],
24
27
  type: "https",
25
- endpoints: [{ protocol: "tcp", port: 443, tls: true }],
26
28
  dnsRecord: {
27
29
  type: "HTTPS",
28
30
  parameters: { "no-default-alpn": undefined, alpn: "h3" }
@@ -61,6 +63,23 @@ const ServiceTypes = {
61
63
  }
62
64
  };
63
65
 
66
+ function serviceTypeEndpoints(type) {
67
+ let st = ServiceTypes[type];
68
+ if (st) {
69
+ if (st.extends) {
70
+ let ste = ServiceTypes[st.extends];
71
+
72
+ if (ste.endpoints) {
73
+ return st.endpoints
74
+ ? [...st.endpoints, ...ste.endpoints]
75
+ : ste.endpoints;
76
+ }
77
+ }
78
+
79
+ return st.endpoints;
80
+ }
81
+ }
82
+
64
83
  export const endpointProperties = {
65
84
  port: { type: "number", collection: false, writeable: true },
66
85
  protocol: {
@@ -173,7 +192,7 @@ export class Service extends Base {
173
192
  ? { type: this.type }
174
193
  : { type: this.type, port: this._port };
175
194
 
176
- const data = ServiceTypes[this.type]?.endpoints || [
195
+ const data = serviceTypeEndpoints(this.type) || [
177
196
  {
178
197
  tls: false
179
198
  }
@@ -318,9 +337,9 @@ export function serviceEndpoints(sources, options = {}) {
318
337
 
319
338
  const res = [...new Set(options.select ? all.map(options.select) : all)];
320
339
 
321
- if(options.limit < res.length) {
340
+ if (options.limit < res.length) {
322
341
  res.length = options.limit;
323
342
  }
324
-
343
+
325
344
  return options.join ? res.join(options.join) : res;
326
345
  }
package/types/cli.d.mts CHANGED
@@ -3,9 +3,7 @@ export function prepare(options?: {}): Promise<{
3
3
  options: {
4
4
  verbose: boolean;
5
5
  dry: boolean;
6
- publish: string;
7
6
  root: string;
8
- output: string;
9
7
  };
10
8
  args: string[];
11
9
  }>;
@@ -18,3 +18,8 @@ export class DomainNameEndpoint {
18
18
  get address(): any;
19
19
  toString(): string;
20
20
  }
21
+ export class HTTPEndpoint {
22
+ constructor(service: any, url: any, data: any);
23
+ service: any;
24
+ url: any;
25
+ }