pmcf 1.14.0 → 1.16.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.
Files changed (2) hide show
  1. package/package.json +4 -1
  2. package/src/model.mjs +20 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -64,5 +64,8 @@
64
64
  "arlac77/template-node-app",
65
65
  "arlac77/template-typescript"
66
66
  ]
67
+ },
68
+ "dependencies": {
69
+ "pacc": "^3.1.9"
67
70
  }
68
71
  }
package/src/model.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { readFile, writeFile, mkdir, glob } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
+ import { getAttribute } from "pacc";
3
4
 
4
5
  export class Base {
5
6
  owner;
@@ -89,18 +90,24 @@ export class Base {
89
90
  }
90
91
 
91
92
  expand(object) {
92
- if (typeof object === "string") {
93
- return object.replaceAll(/\$\{([^\}]*)\}/g, (match, m1) => {
94
- return this[m1] || "${" + m1 + "}";
95
- });
96
- }
93
+ switch (typeof object) {
94
+ case "string":
95
+ return object.replaceAll(/\$\{([^\}]*)\}/g, (match, m1) => {
96
+ return getAttribute(this, m1) || "${" + m1 + "}";
97
+ });
98
+
99
+ case "object":
100
+ if (Array.isArray(object)) {
101
+ return object.map(e => this.expand(e));
102
+ }
97
103
 
98
- if (Array.isArray(object)) {
99
- return object.map(e => this.expand(e));
100
- }
104
+ if (object instanceof Set) {
105
+ return new Set([...object].map(e => this.expand(e)));
106
+ }
101
107
 
102
- if (object instanceof Set) {
103
- return new Set([...object].map(e => this.expand(e)));
108
+ /*return Object.fromEntries(
109
+ Object.entries(object).map(([k, v]) => [k, this.expand(v)])
110
+ );*/
104
111
  }
105
112
 
106
113
  return object;
@@ -638,15 +645,15 @@ export class Host extends Base {
638
645
  delete data.master;
639
646
  }
640
647
  if (data.depends !== undefined) {
641
- this.#depends = new Set(data.depends);
648
+ this.#depends = new Set(asArray(data.depends));
642
649
  delete data.depends;
643
650
  }
644
651
  if (data.replaces !== undefined) {
645
- this.#replaces = new Set(data.replaces);
652
+ this.#replaces = new Set(asArray(data.replaces));
646
653
  delete data.replaces;
647
654
  }
648
655
  if (data.provides !== undefined) {
649
- this.#provides = new Set(data.provides);
656
+ this.#provides = new Set(asArray(data.provides));
650
657
  delete data.provides;
651
658
  }
652
659