hologit 0.48.0 → 0.48.1
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/lib/Workspace.js +39 -8
- package/package.json +1 -1
package/lib/Workspace.js
CHANGED
|
@@ -107,28 +107,30 @@ class Workspace extends Configurable {
|
|
|
107
107
|
const children = tree ? await tree.getChildren() : {};
|
|
108
108
|
|
|
109
109
|
|
|
110
|
-
// build unsorted map
|
|
110
|
+
// build unsorted map via recursive discovery
|
|
111
111
|
const childNameRe = /^([^\/]+)\.toml$/;
|
|
112
112
|
const map = new Map();
|
|
113
|
-
for (const childName in children) {
|
|
114
|
-
let name;
|
|
115
113
|
|
|
116
|
-
|
|
114
|
+
for (const childName in children) {
|
|
117
115
|
if (children[childName].isTree) {
|
|
118
116
|
// skip .lenses directories (e.g. "docs-site.lenses")
|
|
119
117
|
if (childName.endsWith('.lenses')) {
|
|
120
118
|
continue;
|
|
121
119
|
}
|
|
122
|
-
|
|
120
|
+
|
|
121
|
+
// peek inside: if directory contains .toml files it defines
|
|
122
|
+
// a branch's mappings; otherwise it's a namespace — recurse
|
|
123
|
+
await this._discoverBranches(
|
|
124
|
+
children[childName], childName, childNameRe, map
|
|
125
|
+
);
|
|
123
126
|
} else {
|
|
124
127
|
const nameMatches = childName.match(childNameRe);
|
|
125
128
|
if (!nameMatches) {
|
|
126
129
|
continue;
|
|
127
130
|
}
|
|
128
|
-
[,name] = nameMatches;
|
|
131
|
+
const [,name] = nameMatches;
|
|
132
|
+
map.set(name, this.getBranch(name));
|
|
129
133
|
}
|
|
130
|
-
|
|
131
|
-
map.set(name, this.getBranch(name));
|
|
132
134
|
}
|
|
133
135
|
|
|
134
136
|
|
|
@@ -137,6 +139,35 @@ class Workspace extends Configurable {
|
|
|
137
139
|
return map;
|
|
138
140
|
}
|
|
139
141
|
|
|
142
|
+
async _discoverBranches (tree, prefix, childNameRe, map) {
|
|
143
|
+
const treeChildren = await tree.getChildren();
|
|
144
|
+
|
|
145
|
+
// check if this directory contains any .toml files directly
|
|
146
|
+
let hasTomlFiles = false;
|
|
147
|
+
for (const name in treeChildren) {
|
|
148
|
+
if (!treeChildren[name].isTree && childNameRe.test(name)) {
|
|
149
|
+
hasTomlFiles = true;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (hasTomlFiles) {
|
|
155
|
+
// directory contains mappings — it defines a branch
|
|
156
|
+
map.set(prefix, this.getBranch(prefix));
|
|
157
|
+
} else {
|
|
158
|
+
// no .toml files — it's a namespace, recurse into subdirectories
|
|
159
|
+
for (const name in treeChildren) {
|
|
160
|
+
if (!treeChildren[name].isTree || name.endsWith('.lenses')) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
await this._discoverBranches(
|
|
165
|
+
treeChildren[name], prefix + '/' + name, childNameRe, map
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
140
171
|
getSource (name) {
|
|
141
172
|
let cache = sourceCache.get(this);
|
|
142
173
|
const cachedSource = cache && cache.get(name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hologit",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.1",
|
|
4
4
|
"description": "Hologit automates the projection of layered composite file trees based on flat, declarative plans",
|
|
5
5
|
"repository": "https://github.com/JarvusInnovations/hologit",
|
|
6
6
|
"main": "lib/index.js",
|