hologit 0.48.0 → 0.49.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/lib/BlobObject.js CHANGED
@@ -3,11 +3,9 @@ class BlobObject {
3
3
 
4
4
  static async write (repo, content) {
5
5
  const git = await repo.getGit();
6
- const hashObject = await git.hashObject({ w: true, stdin: true, $spawn: true });
6
+ const hash = await git.hashObjectInternally(content, { write: true });
7
7
 
8
- return new BlobObject(repo, {
9
- hash: await hashObject.captureOutputTrimmed(content)
10
- });
8
+ return new BlobObject(repo, { hash });
11
9
  }
12
10
 
13
11
  static async writeFromFile (repo, filePath) {
package/lib/TreeObject.js CHANGED
@@ -10,12 +10,20 @@ const EMPTY_TREE_HASH = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
10
10
 
11
11
  const cache = {};
12
12
 
13
+ const stats = { treesWritten: 0, treesSkippedClean: 0, treesSkippedCached: 0, cacheHits: 0, cacheMisses: 0 };
14
+
13
15
  function cacheRead (hash) {
14
16
  if (hash == EMPTY_TREE_HASH) {
15
17
  return {};
16
18
  }
17
19
 
18
- return cache[hash] || null;
20
+ const result = cache[hash] || null;
21
+ if (result) {
22
+ stats.cacheHits++;
23
+ } else {
24
+ stats.cacheMisses++;
25
+ }
26
+ return result;
19
27
  }
20
28
 
21
29
  function cacheWrite (hash, children) {
@@ -155,10 +163,16 @@ class TreeObject {
155
163
 
156
164
  cacheWrite(this.hash, cachedHashChildren);
157
165
 
166
+ // populate git-client's known-objects cache
167
+ for (const name in cachedHashChildren) {
168
+ git.knowObject(cachedHashChildren[name].hash);
169
+ }
170
+
158
171
  if (preloadChildren) {
159
172
  for (const treePath in preloadedTrees) {
160
173
  const tree = preloadedTrees[treePath];
161
174
  cacheWrite(tree.hash, tree.children);
175
+ git.knowObject(tree.hash);
162
176
  }
163
177
  }
164
178
  }
@@ -368,7 +382,8 @@ class TreeObject {
368
382
  this.hash = EMPTY_TREE_HASH;
369
383
  } else {
370
384
  const git = await this.repo.getGit();
371
- this.hash = await git.mktreeBatch(lines);
385
+ this.hash = await git.mktreeNative(lines);
386
+ stats.treesWritten++;
372
387
  }
373
388
 
374
389
 
@@ -546,6 +561,8 @@ class TreeObject {
546
561
  }
547
562
 
548
563
  TreeObject.treeLineRe = treeLineRe;
564
+ TreeObject.stats = stats;
565
+ TreeObject.resetStats = () => Object.keys(stats).forEach(k => stats[k] = 0);
549
566
 
550
567
  TreeObject.prototype.isTree = true;
551
568
  TreeObject.prototype.type = 'tree';
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
- // process trees or files ending in .toml
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
- name = childName;
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.0",
3
+ "version": "0.49.0",
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",
@@ -11,18 +11,18 @@
11
11
  "dependencies": {
12
12
  "@iarna/toml": "^2.2.5",
13
13
  "async-exit-hook": "^2.0.1",
14
- "axios": "^1.13.5",
14
+ "axios": "^1.13.6",
15
15
  "chokidar": "^5.0.0",
16
16
  "debounce": "^3.0.0",
17
17
  "fb-watchman": "^2.0.2",
18
- "git-client": "^1.9.4",
18
+ "git-client": "^1.10.1",
19
19
  "hab-client": "^1.1.3",
20
20
  "handlebars": "^4.7.8",
21
- "minimatch": "^10.2.2",
21
+ "minimatch": "^10.2.4",
22
22
  "mz": "^2.7.0",
23
23
  "mz-modules": "^2.1.0",
24
24
  "object-squish": "^1.1.0",
25
- "parse-url": "^10.0.3",
25
+ "parse-url": "^11.1.0",
26
26
  "shell-quote-word": "^1.0.1",
27
27
  "sort-keys": "^6.0.0",
28
28
  "toposort": "^2.0.2",
@@ -49,9 +49,10 @@
49
49
  ],
50
50
  "devDependencies": {
51
51
  "@types/jest": "^30.0.0",
52
- "jest": "^30.2.0"
52
+ "jest": "^30.3.0"
53
53
  },
54
54
  "scripts": {
55
- "test": "jest"
55
+ "test": "jest",
56
+ "bench": "node test/benchmark/projection.bench.js"
56
57
  }
57
58
  }