@ibgib/vcs-gib 0.0.6

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 (202) hide show
  1. package/README.md +94 -0
  2. package/VCS_CLI_USER_GUIDE.md +198 -0
  3. package/dist/AUTO-GENERATED-version.d.mts +6 -0
  4. package/dist/AUTO-GENERATED-version.d.mts.map +1 -0
  5. package/dist/AUTO-GENERATED-version.mjs +6 -0
  6. package/dist/AUTO-GENERATED-version.mjs.map +1 -0
  7. package/dist/assumptions.respec.d.mts +2 -0
  8. package/dist/assumptions.respec.d.mts.map +1 -0
  9. package/dist/assumptions.respec.mjs +41 -0
  10. package/dist/assumptions.respec.mjs.map +1 -0
  11. package/dist/bootstrap/node-bootstrap.d.mts +35 -0
  12. package/dist/bootstrap/node-bootstrap.d.mts.map +1 -0
  13. package/dist/bootstrap/node-bootstrap.mjs +165 -0
  14. package/dist/bootstrap/node-bootstrap.mjs.map +1 -0
  15. package/dist/bootstrap/node-bootstrap.respec.node.d.mts +7 -0
  16. package/dist/bootstrap/node-bootstrap.respec.node.d.mts.map +1 -0
  17. package/dist/bootstrap/node-bootstrap.respec.node.mjs +28 -0
  18. package/dist/bootstrap/node-bootstrap.respec.node.mjs.map +1 -0
  19. package/dist/cli/cli-arg-parser.d.mts +27 -0
  20. package/dist/cli/cli-arg-parser.d.mts.map +1 -0
  21. package/dist/cli/cli-arg-parser.mjs +96 -0
  22. package/dist/cli/cli-arg-parser.mjs.map +1 -0
  23. package/dist/cli/cli-arg-parser.respec.node.d.mts +7 -0
  24. package/dist/cli/cli-arg-parser.respec.node.d.mts.map +1 -0
  25. package/dist/cli/cli-arg-parser.respec.node.mjs +35 -0
  26. package/dist/cli/cli-arg-parser.respec.node.mjs.map +1 -0
  27. package/dist/cli/cli-constants.d.mts +26 -0
  28. package/dist/cli/cli-constants.d.mts.map +1 -0
  29. package/dist/cli/cli-constants.mjs +67 -0
  30. package/dist/cli/cli-constants.mjs.map +1 -0
  31. package/dist/cli/cli-e2e.respec.node.d.mts +8 -0
  32. package/dist/cli/cli-e2e.respec.node.d.mts.map +1 -0
  33. package/dist/cli/cli-e2e.respec.node.mjs +263 -0
  34. package/dist/cli/cli-e2e.respec.node.mjs.map +1 -0
  35. package/dist/cli/commands/add-cmd.d.mts +20 -0
  36. package/dist/cli/commands/add-cmd.d.mts.map +1 -0
  37. package/dist/cli/commands/add-cmd.mjs +333 -0
  38. package/dist/cli/commands/add-cmd.mjs.map +1 -0
  39. package/dist/cli/commands/branch-checkout-cmd.respec.node.d.mts +7 -0
  40. package/dist/cli/commands/branch-checkout-cmd.respec.node.d.mts.map +1 -0
  41. package/dist/cli/commands/branch-checkout-cmd.respec.node.mjs +288 -0
  42. package/dist/cli/commands/branch-checkout-cmd.respec.node.mjs.map +1 -0
  43. package/dist/cli/commands/branch-cmd.d.mts +25 -0
  44. package/dist/cli/commands/branch-cmd.d.mts.map +1 -0
  45. package/dist/cli/commands/branch-cmd.mjs +187 -0
  46. package/dist/cli/commands/branch-cmd.mjs.map +1 -0
  47. package/dist/cli/commands/checkout-cmd.d.mts +21 -0
  48. package/dist/cli/commands/checkout-cmd.d.mts.map +1 -0
  49. package/dist/cli/commands/checkout-cmd.mjs +154 -0
  50. package/dist/cli/commands/checkout-cmd.mjs.map +1 -0
  51. package/dist/cli/commands/commit-cmd.d.mts +23 -0
  52. package/dist/cli/commands/commit-cmd.d.mts.map +1 -0
  53. package/dist/cli/commands/commit-cmd.mjs +326 -0
  54. package/dist/cli/commands/commit-cmd.mjs.map +1 -0
  55. package/dist/cli/commands/commit-log-cmd.respec.node.d.mts +7 -0
  56. package/dist/cli/commands/commit-log-cmd.respec.node.d.mts.map +1 -0
  57. package/dist/cli/commands/commit-log-cmd.respec.node.mjs +251 -0
  58. package/dist/cli/commands/commit-log-cmd.respec.node.mjs.map +1 -0
  59. package/dist/cli/commands/init-cmd.d.mts +20 -0
  60. package/dist/cli/commands/init-cmd.d.mts.map +1 -0
  61. package/dist/cli/commands/init-cmd.mjs +119 -0
  62. package/dist/cli/commands/init-cmd.mjs.map +1 -0
  63. package/dist/cli/commands/init-cmd.respec.node.d.mts +7 -0
  64. package/dist/cli/commands/init-cmd.respec.node.d.mts.map +1 -0
  65. package/dist/cli/commands/init-cmd.respec.node.mjs +40 -0
  66. package/dist/cli/commands/init-cmd.respec.node.mjs.map +1 -0
  67. package/dist/cli/commands/log-cmd.d.mts +27 -0
  68. package/dist/cli/commands/log-cmd.d.mts.map +1 -0
  69. package/dist/cli/commands/log-cmd.mjs +146 -0
  70. package/dist/cli/commands/log-cmd.mjs.map +1 -0
  71. package/dist/cli/commands/status-add-cmd.respec.node.d.mts +7 -0
  72. package/dist/cli/commands/status-add-cmd.respec.node.d.mts.map +1 -0
  73. package/dist/cli/commands/status-add-cmd.respec.node.mjs +215 -0
  74. package/dist/cli/commands/status-add-cmd.respec.node.mjs.map +1 -0
  75. package/dist/cli/commands/status-cmd.d.mts +25 -0
  76. package/dist/cli/commands/status-cmd.d.mts.map +1 -0
  77. package/dist/cli/commands/status-cmd.mjs +286 -0
  78. package/dist/cli/commands/status-cmd.mjs.map +1 -0
  79. package/dist/cli/vcs-cli-main.d.mts +14 -0
  80. package/dist/cli/vcs-cli-main.d.mts.map +1 -0
  81. package/dist/cli/vcs-cli-main.mjs +136 -0
  82. package/dist/cli/vcs-cli-main.mjs.map +1 -0
  83. package/dist/engine/branch/branch-graph-helper.d.mts +19 -0
  84. package/dist/engine/branch/branch-graph-helper.d.mts.map +1 -0
  85. package/dist/engine/branch/branch-graph-helper.mjs +49 -0
  86. package/dist/engine/branch/branch-graph-helper.mjs.map +1 -0
  87. package/dist/engine/branch/branch-helper.d.mts +26 -0
  88. package/dist/engine/branch/branch-helper.d.mts.map +1 -0
  89. package/dist/engine/branch/branch-helper.mjs +57 -0
  90. package/dist/engine/branch/branch-helper.mjs.map +1 -0
  91. package/dist/engine/branch/branch-space-helper.d.mts +22 -0
  92. package/dist/engine/branch/branch-space-helper.d.mts.map +1 -0
  93. package/dist/engine/branch/branch-space-helper.mjs +77 -0
  94. package/dist/engine/branch/branch-space-helper.mjs.map +1 -0
  95. package/dist/engine/branch/branch-space.respec.node.d.mts +8 -0
  96. package/dist/engine/branch/branch-space.respec.node.d.mts.map +1 -0
  97. package/dist/engine/branch/branch-space.respec.node.mjs +138 -0
  98. package/dist/engine/branch/branch-space.respec.node.mjs.map +1 -0
  99. package/dist/engine/branch/branch-types.d.mts +26 -0
  100. package/dist/engine/branch/branch-types.d.mts.map +1 -0
  101. package/dist/engine/branch/branch-types.mjs +7 -0
  102. package/dist/engine/branch/branch-types.mjs.map +1 -0
  103. package/dist/engine/diff/line-diff-helper.d.mts +76 -0
  104. package/dist/engine/diff/line-diff-helper.d.mts.map +1 -0
  105. package/dist/engine/diff/line-diff-helper.mjs +144 -0
  106. package/dist/engine/diff/line-diff-helper.mjs.map +1 -0
  107. package/dist/engine/diff/line-diff-helper.respec.node.d.mts +7 -0
  108. package/dist/engine/diff/line-diff-helper.respec.node.d.mts.map +1 -0
  109. package/dist/engine/diff/line-diff-helper.respec.node.mjs +66 -0
  110. package/dist/engine/diff/line-diff-helper.respec.node.mjs.map +1 -0
  111. package/dist/engine/filter/glob-helper.d.mts +51 -0
  112. package/dist/engine/filter/glob-helper.d.mts.map +1 -0
  113. package/dist/engine/filter/glob-helper.mjs +132 -0
  114. package/dist/engine/filter/glob-helper.mjs.map +1 -0
  115. package/dist/engine/filter/glob-helper.respec.node.d.mts +7 -0
  116. package/dist/engine/filter/glob-helper.respec.node.d.mts.map +1 -0
  117. package/dist/engine/filter/glob-helper.respec.node.mjs +78 -0
  118. package/dist/engine/filter/glob-helper.respec.node.mjs.map +1 -0
  119. package/dist/engine/index/index-helper.d.mts +78 -0
  120. package/dist/engine/index/index-helper.d.mts.map +1 -0
  121. package/dist/engine/index/index-helper.mjs +289 -0
  122. package/dist/engine/index/index-helper.mjs.map +1 -0
  123. package/dist/engine/index/index-types.d.mts +63 -0
  124. package/dist/engine/index/index-types.d.mts.map +1 -0
  125. package/dist/engine/index/index-types.mjs +7 -0
  126. package/dist/engine/index/index-types.mjs.map +1 -0
  127. package/dist/engine/item/item-atom-helper.d.mts +20 -0
  128. package/dist/engine/item/item-atom-helper.d.mts.map +1 -0
  129. package/dist/engine/item/item-atom-helper.mjs +30 -0
  130. package/dist/engine/item/item-atom-helper.mjs.map +1 -0
  131. package/dist/engine/item/item-helper.d.mts +37 -0
  132. package/dist/engine/item/item-helper.d.mts.map +1 -0
  133. package/dist/engine/item/item-helper.mjs +194 -0
  134. package/dist/engine/item/item-helper.mjs.map +1 -0
  135. package/dist/engine/item/item-types.d.mts +127 -0
  136. package/dist/engine/item/item-types.d.mts.map +1 -0
  137. package/dist/engine/item/item-types.mjs +16 -0
  138. package/dist/engine/item/item-types.mjs.map +1 -0
  139. package/dist/index.d.mts +7 -0
  140. package/dist/index.d.mts.map +1 -0
  141. package/dist/index.mjs +7 -0
  142. package/dist/index.mjs.map +1 -0
  143. package/dist/respec-gib.node.d.mts +7 -0
  144. package/dist/respec-gib.node.d.mts.map +1 -0
  145. package/dist/respec-gib.node.mjs +11 -0
  146. package/dist/respec-gib.node.mjs.map +1 -0
  147. package/dist/vcs-gib-constants.d.mts +7 -0
  148. package/dist/vcs-gib-constants.d.mts.map +1 -0
  149. package/dist/vcs-gib-constants.mjs +7 -0
  150. package/dist/vcs-gib-constants.mjs.map +1 -0
  151. package/dist/vcs-gib.respec.node.d.mts +8 -0
  152. package/dist/vcs-gib.respec.node.d.mts.map +1 -0
  153. package/dist/vcs-gib.respec.node.mjs +82 -0
  154. package/dist/vcs-gib.respec.node.mjs.map +1 -0
  155. package/generate-version-file.js +20 -0
  156. package/package.json +28 -0
  157. package/src/AUTO-GENERATED-version.mts +5 -0
  158. package/src/assumptions.respec.mts +50 -0
  159. package/src/bootstrap/node-bootstrap.mts +198 -0
  160. package/src/bootstrap/node-bootstrap.respec.node.mts +35 -0
  161. package/src/cli/cli-arg-parser.mts +119 -0
  162. package/src/cli/cli-arg-parser.respec.node.mts +45 -0
  163. package/src/cli/cli-constants.mts +77 -0
  164. package/src/cli/cli-e2e.respec.node.mts +318 -0
  165. package/src/cli/commands/add-cmd.mts +415 -0
  166. package/src/cli/commands/branch-checkout-cmd.respec.node.mts +322 -0
  167. package/src/cli/commands/branch-cmd.mts +243 -0
  168. package/src/cli/commands/checkout-cmd.mts +202 -0
  169. package/src/cli/commands/commit-cmd.mts +421 -0
  170. package/src/cli/commands/commit-log-cmd.respec.node.mts +276 -0
  171. package/src/cli/commands/init-cmd.mts +152 -0
  172. package/src/cli/commands/init-cmd.respec.node.mts +49 -0
  173. package/src/cli/commands/log-cmd.mts +197 -0
  174. package/src/cli/commands/status-add-cmd.respec.node.mts +246 -0
  175. package/src/cli/commands/status-cmd.mts +366 -0
  176. package/src/cli/vcs-cli-main.mts +153 -0
  177. package/src/engine/branch/branch-graph-helper.mts +69 -0
  178. package/src/engine/branch/branch-helper.mts +79 -0
  179. package/src/engine/branch/branch-space-helper.mts +104 -0
  180. package/src/engine/branch/branch-space.respec.node.mts +158 -0
  181. package/src/engine/branch/branch-types.mts +29 -0
  182. package/src/engine/diff/line-diff-helper.mts +210 -0
  183. package/src/engine/diff/line-diff-helper.respec.node.mts +84 -0
  184. package/src/engine/filter/glob-helper.mts +165 -0
  185. package/src/engine/filter/glob-helper.respec.node.mts +94 -0
  186. package/src/engine/index/index-helper.mts +378 -0
  187. package/src/engine/index/index-types.mts +66 -0
  188. package/src/engine/item/item-atom-helper.mts +30 -0
  189. package/src/engine/item/item-helper.mts +239 -0
  190. package/src/engine/item/item-types.mts +136 -0
  191. package/src/index.mts +7 -0
  192. package/src/respec-gib.node.mts +12 -0
  193. package/src/vcs-gib-constants.mts +7 -0
  194. package/src/vcs-gib.respec.node.mts +96 -0
  195. package/test_runs/001-hello-node/20260728_090100_0001-flow-core-main.md +39 -0
  196. package/test_runs/001-hello-node/20260728_090200_0003-flow-branching-worktree.md +54 -0
  197. package/test_runs/001-hello-node/20260728_090300_0002-flow-selective-add.md +45 -0
  198. package/test_runs/001-hello-node/20260728_142100_0007-flow-edge-cases.md +44 -0
  199. package/test_runs/001-hello-node/20260728_142400_0005-flow-hardcoded-ignores.md +36 -0
  200. package/tools/pack-for-test.mjs +73 -0
  201. package/tsconfig.json +18 -0
  202. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @module glob-helper
3
+ *
4
+ * Native, zero-dependency glob pattern matching engine for .ibgibignore and path filtering.
5
+ *
6
+ * Supports:
7
+ * - Basic wildcards: '*' (single path segment), '**' (recursive path matching), '?' (single char)
8
+ * - Negation/Inclusion: '!' prefix (negable matching, last match wins)
9
+ * - Directory matching: trailing '/' (matches directory paths only)
10
+ * - JS RegExp fallback: 'regexp js <pattern>' prefix
11
+ * - Ignore file parsing: stripping '#' comments and blank lines
12
+ * - Hardcoded reserved repository paths: '.vcsgib', 'b', 'ibgib', 'node_modules', '.git'
13
+ */
14
+ /**
15
+ * Hardcoded internal repository paths that are ALWAYS ignored during workspace scans
16
+ * regardless of user .ibgibignore settings.
17
+ */
18
+ export declare const HARDCODED_IGNORED_PATHS: string[];
19
+ /**
20
+ * Converts a glob pattern string into a JavaScript RegExp.
21
+ */
22
+ export declare function globToRegExp(glob: string): RegExp;
23
+ /**
24
+ * Parses raw .ibgibignore file text into an array of active pattern strings.
25
+ * Strips blank lines and '#' comments.
26
+ */
27
+ export declare function parseFilterFileContent(content: string): string[];
28
+ /**
29
+ * Options passed to path filtering check.
30
+ */
31
+ export interface IsPathFilteredOpts {
32
+ /**
33
+ * Relative path from repository root (e.g. 'src/utils/helper.mts' or 'b/feature-auth')
34
+ */
35
+ relativePath: string;
36
+ /**
37
+ * Whether the target path is a directory
38
+ */
39
+ isDirectory?: boolean;
40
+ /**
41
+ * Active filter patterns (e.g. from .ibgibignore)
42
+ */
43
+ filterPatterns?: string[];
44
+ }
45
+ /**
46
+ * Determines whether a relative path is filtered (ignored) based on active pattern rules.
47
+ * Reserved repository paths ('.vcsgib', 'b', 'ibgib') are ALWAYS ignored.
48
+ * Last matching rule wins for user rules (standard gitignore semantics).
49
+ */
50
+ export declare function isPathFiltered({ relativePath, isDirectory, filterPatterns, }: IsPathFilteredOpts): boolean;
51
+ //# sourceMappingURL=glob-helper.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob-helper.d.mts","sourceRoot":"","sources":["../../../src/engine/filter/glob-helper.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH;;;GAGG;AACH,eAAO,MAAM,uBAAuB,UAAoD,CAAC;AAEzF;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAejD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAOhE;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAC3B,YAAY,EACZ,WAAmB,EACnB,cAAmB,GACtB,EAAE,kBAAkB,GAAG,OAAO,CA+E9B"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * @module glob-helper
3
+ *
4
+ * Native, zero-dependency glob pattern matching engine for .ibgibignore and path filtering.
5
+ *
6
+ * Supports:
7
+ * - Basic wildcards: '*' (single path segment), '**' (recursive path matching), '?' (single char)
8
+ * - Negation/Inclusion: '!' prefix (negable matching, last match wins)
9
+ * - Directory matching: trailing '/' (matches directory paths only)
10
+ * - JS RegExp fallback: 'regexp js <pattern>' prefix
11
+ * - Ignore file parsing: stripping '#' comments and blank lines
12
+ * - Hardcoded reserved repository paths: '.vcsgib', 'b', 'ibgib', 'node_modules', '.git'
13
+ */
14
+ import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
15
+ const lcFile = `[glob-helper]`;
16
+ const logalot = GLOBAL_LOG_A_LOT;
17
+ /**
18
+ * Hardcoded internal repository paths that are ALWAYS ignored during workspace scans
19
+ * regardless of user .ibgibignore settings.
20
+ */
21
+ export const HARDCODED_IGNORED_PATHS = ['.vcsgib', 'b', 'ibgib', 'node_modules', '.git'];
22
+ /**
23
+ * Converts a glob pattern string into a JavaScript RegExp.
24
+ */
25
+ export function globToRegExp(glob) {
26
+ const raw = glob.replace(/\\/g, '/');
27
+ let p = raw
28
+ .replace(/\./g, '\\.')
29
+ .replace(/\?/g, '[^/]')
30
+ .replace(/\/\*\*\//g, '(?:/|/.+/)')
31
+ .replace(/\/\*\*/g, '(?:/.*)?')
32
+ .replace(/\*\*\//g, '(?:.*/)?')
33
+ .replace(/\*/g, '[^/]*');
34
+ if (!raw.endsWith('/')) {
35
+ p += '(?:/.*)?';
36
+ }
37
+ return new RegExp(`^${p}$`);
38
+ }
39
+ /**
40
+ * Parses raw .ibgibignore file text into an array of active pattern strings.
41
+ * Strips blank lines and '#' comments.
42
+ */
43
+ export function parseFilterFileContent(content) {
44
+ if (!content) {
45
+ return [];
46
+ }
47
+ return content
48
+ .split(/\r?\n/)
49
+ .map(line => line.trim())
50
+ .filter(line => line.length > 0 && !line.startsWith('#'));
51
+ }
52
+ /**
53
+ * Determines whether a relative path is filtered (ignored) based on active pattern rules.
54
+ * Reserved repository paths ('.vcsgib', 'b', 'ibgib') are ALWAYS ignored.
55
+ * Last matching rule wins for user rules (standard gitignore semantics).
56
+ */
57
+ export function isPathFiltered({ relativePath, isDirectory = false, filterPatterns = [], }) {
58
+ const lc = `${lcFile}[${isPathFiltered.name}]`;
59
+ if (!relativePath) {
60
+ return false;
61
+ }
62
+ // Normalize path separators to forward slashes
63
+ const normalizedPath = relativePath.replace(/\\/g, '/').replace(/^\.\//, '').replace(/\/$/, '');
64
+ const pathBasename = normalizedPath.split('/')[0] || normalizedPath;
65
+ // 0. Hardcoded reserved repository paths (ALWAYS ignored)
66
+ if (HARDCODED_IGNORED_PATHS.includes(pathBasename) || HARDCODED_IGNORED_PATHS.includes(normalizedPath)) {
67
+ return true;
68
+ }
69
+ if (filterPatterns.length === 0) {
70
+ return false;
71
+ }
72
+ let isIgnored = false;
73
+ for (const rawPattern of filterPatterns) {
74
+ if (!rawPattern || rawPattern.trim() === '') {
75
+ continue;
76
+ }
77
+ const pattern = rawPattern.trim();
78
+ // 1. JS RegExp fallback
79
+ if (pattern.startsWith('regexp js ')) {
80
+ const regexText = pattern.substring('regexp js '.length);
81
+ try {
82
+ const rx = new RegExp(regexText);
83
+ if (rx.test(normalizedPath) || rx.test(pathBasename)) {
84
+ isIgnored = true;
85
+ }
86
+ }
87
+ catch (err) {
88
+ console.error(`${lc} Error evaluating regex pattern (${pattern}):`, err);
89
+ }
90
+ continue;
91
+ }
92
+ // 2. Negation / Inclusion rule ('!')
93
+ let isNegated = false;
94
+ let p = pattern;
95
+ if (p.startsWith('!')) {
96
+ isNegated = true;
97
+ p = p.substring(1).trim();
98
+ }
99
+ else if (p.startsWith('include ')) {
100
+ isNegated = true;
101
+ p = p.substring('include '.length).trim();
102
+ }
103
+ // 3. Directory-only pattern check
104
+ const directoryOnly = p.endsWith('/');
105
+ if (directoryOnly && !isDirectory) {
106
+ continue; // Skip directory-only rule for non-directories
107
+ }
108
+ const cleanPattern = directoryOnly ? p.slice(0, -1) : p;
109
+ // 4. Exact basename or path match check
110
+ let matches = false;
111
+ if (cleanPattern === pathBasename || normalizedPath === cleanPattern) {
112
+ matches = true;
113
+ }
114
+ else if (cleanPattern.includes('*') || cleanPattern.includes('?')) {
115
+ const rx = globToRegExp(cleanPattern);
116
+ matches = rx.test(normalizedPath) || rx.test(pathBasename);
117
+ }
118
+ else {
119
+ // Substring directory segment match (e.g., 'node_modules' matches 'a/b/node_modules/c')
120
+ const segments = normalizedPath.split('/');
121
+ matches = segments.includes(cleanPattern) || normalizedPath.endsWith('/' + cleanPattern);
122
+ }
123
+ if (matches) {
124
+ isIgnored = !isNegated;
125
+ }
126
+ }
127
+ if (logalot) {
128
+ console.log(`${lc} relativePath: ${relativePath}, isIgnored: ${isIgnored}`);
129
+ }
130
+ return isIgnored;
131
+ }
132
+ //# sourceMappingURL=glob-helper.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob-helper.mjs","sourceRoot":"","sources":["../../../src/engine/filter/glob-helper.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,MAAM,MAAM,GAAG,eAAe,CAAC;AAC/B,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;AAEzF;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACrC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACrC,IAAI,CAAC,GAAG,GAAG;SACN,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;SACtB,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC;SAClC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC;SAC9B,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC;SAC9B,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAE7B,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,CAAC,IAAI,UAAU,CAAC;IACpB,CAAC;IAED,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAA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+ //# sourceMappingURL=glob-helper.respec.node.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob-helper.respec.node.d.mts","sourceRoot":"","sources":["../../../src/engine/filter/glob-helper.respec.node.mts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @module glob-helper.respec
3
+ *
4
+ * Unit tests for native zero-dependency glob pattern matching engine.
5
+ */
6
+ import { respecfully, ifWe, iReckon } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
7
+ import { globToRegExp, parseFilterFileContent, isPathFiltered } from './glob-helper.mjs';
8
+ const lc = `[apps/vcs-gib/src/engine/filter/glob-helper.respec.node.mts]`;
9
+ await respecfully(lc, `Native Glob Engine (Zero-Dependency)`, async () => {
10
+ await respecfully(lc, `parseFilterFileContent`, async () => {
11
+ await ifWe(lc, `parses filter file and strips comments & blank lines`, async () => {
12
+ const raw = `
13
+ # This is a comment
14
+ node_modules/
15
+ *.log
16
+
17
+ # Another comment
18
+ !important.log
19
+ `;
20
+ const patterns = parseFilterFileContent(raw);
21
+ iReckon(lc, patterns.length).willEqual(3);
22
+ iReckon(lc, patterns[0]).willEqual('node_modules/');
23
+ iReckon(lc, patterns[1]).willEqual('*.log');
24
+ iReckon(lc, patterns[2]).willEqual('!important.log');
25
+ });
26
+ });
27
+ await respecfully(lc, `globToRegExp`, async () => {
28
+ await ifWe(lc, `converts wildcard pattern to RegExp`, async () => {
29
+ const rx = globToRegExp('*.ts');
30
+ iReckon(lc, rx.test('index.ts')).isGonnaBeTrue();
31
+ iReckon(lc, rx.test('index.js')).isGonnaBeFalse();
32
+ });
33
+ await ifWe(lc, `handles recursive double asterisk **`, async () => {
34
+ const rx = globToRegExp('src/**/*.ts');
35
+ iReckon(lc, rx.test('src/index.ts')).isGonnaBeTrue();
36
+ iReckon(lc, rx.test('src/engine/item/item.ts')).isGonnaBeTrue();
37
+ iReckon(lc, rx.test('test/index.ts')).isGonnaBeFalse();
38
+ });
39
+ });
40
+ await respecfully(lc, `isPathFiltered`, async () => {
41
+ await ifWe(lc, `filters node_modules directory`, async () => {
42
+ const patterns = ['node_modules/', '*.log'];
43
+ iReckon(lc, isPathFiltered({
44
+ relativePath: 'node_modules',
45
+ isDirectory: true,
46
+ filterPatterns: patterns
47
+ })).isGonnaBeTrue();
48
+ iReckon(lc, isPathFiltered({
49
+ relativePath: 'src/node_modules/pkg',
50
+ isDirectory: true,
51
+ filterPatterns: patterns
52
+ })).isGonnaBeTrue();
53
+ });
54
+ await ifWe(lc, `honors negation rule ! prefix (last match wins)`, async () => {
55
+ const patterns = ['*.log', '!important.log'];
56
+ iReckon(lc, isPathFiltered({
57
+ relativePath: 'debug.log',
58
+ filterPatterns: patterns
59
+ })).isGonnaBeTrue();
60
+ iReckon(lc, isPathFiltered({
61
+ relativePath: 'important.log',
62
+ filterPatterns: patterns
63
+ })).isGonnaBeFalse();
64
+ });
65
+ await ifWe(lc, `handles JS regex pattern fallback`, async () => {
66
+ const patterns = ['regexp js ^test_.*\\.json$'];
67
+ iReckon(lc, isPathFiltered({
68
+ relativePath: 'test_data.json',
69
+ filterPatterns: patterns
70
+ })).isGonnaBeTrue();
71
+ iReckon(lc, isPathFiltered({
72
+ relativePath: 'prod_data.json',
73
+ filterPatterns: patterns
74
+ })).isGonnaBeFalse();
75
+ });
76
+ });
77
+ });
78
+ //# sourceMappingURL=glob-helper.respec.node.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob-helper.respec.node.mjs","sourceRoot":"","sources":["../../../src/engine/filter/glob-helper.respec.node.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACH,WAAW,EAAE,IAAI,EAAE,OAAO,EAC7B,MAAM,kDAAkD,CAAC;AAE1D,OAAO,EACH,YAAY,EAAE,sBAAsB,EAAE,cAAc,EACvD,MAAM,mBAAmB,CAAC;AAE3B,MAAM,EAAE,GAAG,8DAA8D,CAAC;AAE1E,MAAM,WAAW,CAAC,EAAE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AY,EAAE,eAAe;gBAC7B,cAAc,EAAE,QAAQ;aAC3B,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,EAAE,EAAE,mCAAmC,EAAE,KAAK,IAAI,EAAE;YAC3D,MAAM,QAAQ,GAAG,CAAC,4BAA4B,CAAC,CAAC;YAChD,OAAO,CAAC,EAAE,EAAE,cAAc,CAAC;gBACvB,YAAY,EAAE,gBAAgB;gBAC9B,cAAc,EAAE,QAAQ;aAC3B,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;YAEpB,OAAO,CAAC,EAAE,EAAE,cAAc,CAAC;gBACvB,YAAY,EAAE,gBAAgB;gBAC9B,cAAc,EAAE,QAAQ;aAC3B,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @module index-helper
3
+ *
4
+ * B2tFS Index Helper functions: space-qualified address formatting and branch index tracking.
5
+ */
6
+ import { MetaspaceService } from '@ibgib/core-gib/dist/witness/space/metaspace/metaspace-types.mjs';
7
+ import { IbGibSpaceAny } from '@ibgib/core-gib/dist/witness/space/space-base-v1.mjs';
8
+ import { SpaceQualifiedIbGibAddr, B2tFSIndexIbGib_V1, B2tFSIndexData_V1, B2tFSIndexRel8ns_V1 } from './index-types.mjs';
9
+ export declare const SOFT_ADDR_DATA_KEY_PREFIX = "@";
10
+ export declare const SOFT_ADDR_DATA_KEY_PREFIX_SPACE_QUALIFIED = "$@";
11
+ /**
12
+ * Returns a space-qualified address string.
13
+ * Format: `v:1^spaceId:<spaceId>^<ibGibAddr>`
14
+ */
15
+ export declare function getSpaceQualifiedIbGibAddr(optsOrSpaceId: {
16
+ spaceId: string;
17
+ ibGibAddr: string;
18
+ } | string, rawIbGibAddr?: string): SpaceQualifiedIbGibAddr;
19
+ /**
20
+ * Parses a space-qualified address string into version, spaceId, ibGibAddr, ib, and gib.
21
+ */
22
+ export declare function parseSpaceQualifiedIbGibAddr(optsOrSqAddr: {
23
+ spaceQualifiedAddr: string;
24
+ } | {
25
+ sqAddr: string;
26
+ } | string): {
27
+ version: number;
28
+ spaceId: string;
29
+ ibGibAddr: string;
30
+ ib: string;
31
+ gib: string;
32
+ } | null;
33
+ /**
34
+ * Helper to extract branch name from space-qualified address or raw atom ib string.
35
+ */
36
+ export declare function extractBranchNameFromAddr(addr: string): string | null;
37
+ /**
38
+ * Deduplicates branch entries by branch name and merges new branch addresses into existing addresses
39
+ * without dropping other registered branches.
40
+ */
41
+ export declare function mergeBranchAddrs(existingAddrs?: string[], newAddrs?: string[]): string[];
42
+ /**
43
+ * Creates a new B2tFSIndexIbGib special meta object for a space.
44
+ */
45
+ export declare function createB2tFSIndexIbGib({ spaceId, activeSpaceId, activeBranch, space, metaspace, branchAddr, }: {
46
+ spaceId: string;
47
+ activeSpaceId: string;
48
+ activeBranch?: string;
49
+ space: IbGibSpaceAny;
50
+ metaspace: MetaspaceService;
51
+ branchAddr?: string;
52
+ }): Promise<B2tFSIndexIbGib_V1>;
53
+ /**
54
+ * Retrieves authoritative B2tFSIndexIbGib_V1 from space.
55
+ */
56
+ export declare function getB2tFSIndexIbGib({ space, vcsPath, }: {
57
+ space: IbGibSpaceAny;
58
+ vcsPath?: string;
59
+ }): Promise<B2tFSIndexIbGib_V1 | undefined>;
60
+ /**
61
+ * Updates B2tFSIndexIbGib_V1 in space and updates local projection cache.
62
+ */
63
+ export declare function updateB2tFSIndexIbGib({ space, metaspace, indexIbGib, dataToUpdate, rel8nsToUpdate, vcsPath, }: {
64
+ space: IbGibSpaceAny;
65
+ metaspace: MetaspaceService;
66
+ indexIbGib: B2tFSIndexIbGib_V1;
67
+ dataToUpdate?: Partial<B2tFSIndexData_V1>;
68
+ rel8nsToUpdate?: Partial<B2tFSIndexRel8ns_V1>;
69
+ vcsPath?: string;
70
+ }): Promise<B2tFSIndexIbGib_V1>;
71
+ /**
72
+ * Writes read-only JSON projection cache of repository index.
73
+ */
74
+ export declare function writeVcsIndexProjection({ vcsPath, indexIbGib, }: {
75
+ vcsPath: string;
76
+ indexIbGib: B2tFSIndexIbGib_V1;
77
+ }): Promise<void>;
78
+ //# sourceMappingURL=index-helper.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-helper.d.mts","sourceRoot":"","sources":["../../../src/engine/index/index-helper.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kEAAkE,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,sDAAsD,CAAC;AAIrF,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAKxH,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,yCAAyC,OAAO,CAAC;AAE9D;;;GAGG;AACH,wBAAgB,0BAA0B,CACtC,aAAa,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,EAC9D,YAAY,CAAC,EAAE,MAAM,GACtB,uBAAuB,CAKzB;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CACxC,YAAY,EAAE;IAAE,kBAAkB,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAC3E;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAwCzF;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAarE;AAED;;;GAGG;AACH,wBAAgB,g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CAAC,CA+BhB"}
@@ -0,0 +1,289 @@
1
+ /**
2
+ * @module index-helper
3
+ *
4
+ * B2tFS Index Helper functions: space-qualified address formatting and branch index tracking.
5
+ */
6
+ import path from 'node:path';
7
+ import fs from 'node:fs/promises';
8
+ import { getUUID, extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
9
+ import { ROOT } from '@ibgib/ts-gib/dist/V1/constants.mjs';
10
+ import { Factory_V1 } from '@ibgib/ts-gib/dist/V1/factory.mjs';
11
+ import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
12
+ import { getIbGibsFromCache_fallbackToSpaces } from '@ibgib/core-gib/dist/common/other/ibgib-helper.mjs';
13
+ import { persistTransformResult } from '@ibgib/core-gib/dist/witness/space/space-helper.mjs';
14
+ import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
15
+ const lcFile = `[index-helper]`;
16
+ const logalot = GLOBAL_LOG_A_LOT;
17
+ export const SOFT_ADDR_DATA_KEY_PREFIX = '@';
18
+ export const SOFT_ADDR_DATA_KEY_PREFIX_SPACE_QUALIFIED = '$@';
19
+ /**
20
+ * Returns a space-qualified address string.
21
+ * Format: `v:1^spaceId:<spaceId>^<ibGibAddr>`
22
+ */
23
+ export function getSpaceQualifiedIbGibAddr(optsOrSpaceId, rawIbGibAddr) {
24
+ if (typeof optsOrSpaceId === 'object' && optsOrSpaceId !== null) {
25
+ return `v:1^spaceId:${optsOrSpaceId.spaceId}^${optsOrSpaceId.ibGibAddr}`;
26
+ }
27
+ return `v:1^spaceId:${optsOrSpaceId}^${rawIbGibAddr}`;
28
+ }
29
+ /**
30
+ * Parses a space-qualified address string into version, spaceId, ibGibAddr, ib, and gib.
31
+ */
32
+ export function parseSpaceQualifiedIbGibAddr(optsOrSqAddr) {
33
+ let sqAddr;
34
+ if (typeof optsOrSqAddr === 'string') {
35
+ sqAddr = optsOrSqAddr;
36
+ }
37
+ else if (typeof optsOrSqAddr === 'object' && optsOrSqAddr !== null) {
38
+ sqAddr = optsOrSqAddr.spaceQualifiedAddr || optsOrSqAddr.sqAddr;
39
+ }
40
+ if (!sqAddr || typeof sqAddr !== 'string') {
41
+ return null;
42
+ }
43
+ const match = sqAddr.match(/^v:(\d+)\^spaceId:([^\^]+)\^(.+)$/);
44
+ if (!match) {
45
+ return null;
46
+ }
47
+ const version = parseInt(match[1], 10);
48
+ const spaceId = match[2];
49
+ const ibGibAddr = match[3];
50
+ const lastCaretIndex = ibGibAddr.lastIndexOf('^');
51
+ if (lastCaretIndex === -1) {
52
+ return null;
53
+ }
54
+ const ib = ibGibAddr.substring(0, lastCaretIndex);
55
+ const gib = ibGibAddr.substring(lastCaretIndex + 1);
56
+ if (!ib || !gib) {
57
+ return null;
58
+ }
59
+ return {
60
+ version,
61
+ spaceId,
62
+ ibGibAddr,
63
+ ib,
64
+ gib,
65
+ };
66
+ }
67
+ /**
68
+ * Helper to extract branch name from space-qualified address or raw atom ib string.
69
+ */
70
+ export function extractBranchNameFromAddr(addr) {
71
+ if (!addr) {
72
+ return null;
73
+ }
74
+ const sq = parseSpaceQualifiedIbGibAddr(addr);
75
+ const ib = sq ? sq.ib : (addr.includes('^') ? addr.substring(0, addr.lastIndexOf('^')) : addr);
76
+ if (ib && ib.startsWith('b2tfs_branch ')) {
77
+ const parts = ib.split(' ');
78
+ if (parts.length >= 2 && parts[1]) {
79
+ return parts[1];
80
+ }
81
+ }
82
+ return null;
83
+ }
84
+ /**
85
+ * Deduplicates branch entries by branch name and merges new branch addresses into existing addresses
86
+ * without dropping other registered branches.
87
+ */
88
+ export function mergeBranchAddrs(existingAddrs = [], newAddrs = []) {
89
+ const map = new Map();
90
+ for (const addr of existingAddrs) {
91
+ if (!addr) {
92
+ continue;
93
+ }
94
+ const bName = extractBranchNameFromAddr(addr) || addr;
95
+ map.set(bName, addr);
96
+ }
97
+ for (const addr of newAddrs) {
98
+ if (!addr) {
99
+ continue;
100
+ }
101
+ const bName = extractBranchNameFromAddr(addr) || addr;
102
+ map.set(bName, addr);
103
+ }
104
+ return Array.from(map.values());
105
+ }
106
+ /**
107
+ * Creates a new B2tFSIndexIbGib special meta object for a space.
108
+ */
109
+ export async function createB2tFSIndexIbGib({ spaceId, activeSpaceId, activeBranch, space, metaspace, branchAddr, }) {
110
+ const lc = `${lcFile}[${createB2tFSIndexIbGib.name}]`;
111
+ try {
112
+ if (logalot) {
113
+ console.log(`${lc} starting... (I: 3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d)`);
114
+ }
115
+ const uuid = await getUUID();
116
+ const data = {
117
+ mySpaceId: spaceId,
118
+ activeSpaceId,
119
+ activeBranch,
120
+ uuid,
121
+ classname: 'B2tFSIndexIbGib_V1',
122
+ '$@branch': [],
123
+ stagedPaths: {},
124
+ staged_item: [],
125
+ };
126
+ const rel8ns = {};
127
+ if (branchAddr) {
128
+ const sqBranchAddr = branchAddr.startsWith('v:1^spaceId:')
129
+ ? branchAddr
130
+ : getSpaceQualifiedIbGibAddr({
131
+ spaceId: space.data?.spaceSubPath || space.data?.name || spaceId,
132
+ ibGibAddr: branchAddr,
133
+ });
134
+ rel8ns.branch = [sqBranchAddr];
135
+ rel8ns.branch_tjp = [sqBranchAddr];
136
+ }
137
+ const res = await Factory_V1.firstGen({
138
+ parentIbGib: ROOT,
139
+ ib: `meta special b2tfs_index ${uuid}`,
140
+ data,
141
+ rel8ns: Object.keys(rel8ns).length > 0 ? rel8ns : undefined,
142
+ });
143
+ const indexIbGib = res.newIbGib;
144
+ await persistTransformResult({ resTransform: res, space });
145
+ await metaspace.registerNewIbGib({ ibGib: indexIbGib });
146
+ if (logalot) {
147
+ console.log(`${lc} Created index IbGib: ${indexIbGib.ib} (I: 4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e)`);
148
+ }
149
+ return indexIbGib;
150
+ }
151
+ catch (error) {
152
+ console.error(`${lc} ${extractErrorMsg(error)} (E: 5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f)`);
153
+ throw error;
154
+ }
155
+ finally {
156
+ if (logalot) {
157
+ console.log(`${lc} complete. (I: 6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a)`);
158
+ }
159
+ }
160
+ }
161
+ /**
162
+ * Retrieves authoritative B2tFSIndexIbGib_V1 from space.
163
+ */
164
+ export async function getB2tFSIndexIbGib({ space, vcsPath, }) {
165
+ const lc = `${lcFile}[${getB2tFSIndexIbGib.name}]`;
166
+ try {
167
+ if (logalot) {
168
+ console.log(`${lc} starting... (I: 7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b)`);
169
+ }
170
+ if (!vcsPath) {
171
+ return undefined;
172
+ }
173
+ const projPath = path.join(vcsPath, 'vcs_index_projection.json');
174
+ let indexAddr;
175
+ try {
176
+ const raw = await fs.readFile(projPath, 'utf8');
177
+ const parsed = JSON.parse(raw);
178
+ indexAddr = parsed.indexAddr;
179
+ }
180
+ catch {
181
+ return undefined;
182
+ }
183
+ if (!indexAddr) {
184
+ return undefined;
185
+ }
186
+ const ibgibs = await getIbGibsFromCache_fallbackToSpaces({
187
+ addrs: [indexAddr],
188
+ space,
189
+ });
190
+ const indexIbGib = ibgibs?.at(0);
191
+ return indexIbGib;
192
+ }
193
+ catch (error) {
194
+ console.error(`${lc} ${extractErrorMsg(error)} (E: 8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c)`);
195
+ throw error;
196
+ }
197
+ finally {
198
+ if (logalot) {
199
+ console.log(`${lc} complete. (I: 9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d)`);
200
+ }
201
+ }
202
+ }
203
+ /**
204
+ * Updates B2tFSIndexIbGib_V1 in space and updates local projection cache.
205
+ */
206
+ export async function updateB2tFSIndexIbGib({ space, metaspace, indexIbGib, dataToUpdate, rel8nsToUpdate, vcsPath, }) {
207
+ const lc = `${lcFile}[${updateB2tFSIndexIbGib.name}]`;
208
+ try {
209
+ if (logalot) {
210
+ console.log(`${lc} starting... (I: 0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e)`);
211
+ }
212
+ const mergedData = {
213
+ ...(indexIbGib.data || {
214
+ mySpaceId: space.data?.uuid || '',
215
+ activeSpaceId: '',
216
+ uuid: await getUUID(),
217
+ }),
218
+ ...dataToUpdate,
219
+ };
220
+ const mergedRel8ns = {
221
+ ...(indexIbGib.rel8ns || {}),
222
+ ...rel8nsToUpdate,
223
+ };
224
+ if (rel8nsToUpdate?.branch || indexIbGib.rel8ns?.branch) {
225
+ mergedRel8ns.branch = mergeBranchAddrs(indexIbGib.rel8ns?.branch || [], rel8nsToUpdate?.branch || []);
226
+ }
227
+ if (rel8nsToUpdate?.branch_tjp || indexIbGib.rel8ns?.branch_tjp) {
228
+ mergedRel8ns.branch_tjp = mergeBranchAddrs(indexIbGib.rel8ns?.branch_tjp || [], rel8nsToUpdate?.branch_tjp || []);
229
+ }
230
+ delete mergedRel8ns.past;
231
+ const res = await Factory_V1.firstGen({
232
+ parentIbGib: ROOT,
233
+ ib: indexIbGib.ib,
234
+ data: mergedData,
235
+ rel8ns: mergedRel8ns,
236
+ });
237
+ const newIndexIbGib = res.newIbGib;
238
+ await persistTransformResult({ resTransform: res, space });
239
+ await metaspace.registerNewIbGib({ ibGib: newIndexIbGib });
240
+ if (vcsPath) {
241
+ await writeVcsIndexProjection({ vcsPath, indexIbGib: newIndexIbGib });
242
+ }
243
+ return newIndexIbGib;
244
+ }
245
+ catch (error) {
246
+ console.error(`${lc} ${extractErrorMsg(error)} (E: 1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f)`);
247
+ throw error;
248
+ }
249
+ finally {
250
+ if (logalot) {
251
+ console.log(`${lc} complete. (I: 2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a)`);
252
+ }
253
+ }
254
+ }
255
+ /**
256
+ * Writes read-only JSON projection cache of repository index.
257
+ */
258
+ export async function writeVcsIndexProjection({ vcsPath, indexIbGib, }) {
259
+ const lc = `${lcFile}[${writeVcsIndexProjection.name}]`;
260
+ try {
261
+ if (logalot) {
262
+ console.log(`${lc} starting... (I: 3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b)`);
263
+ }
264
+ await fs.mkdir(vcsPath, { recursive: true });
265
+ const indexAddr = getIbGibAddr({ ibGib: indexIbGib });
266
+ const projectionObj = {
267
+ _isReadOnlyProjection: true,
268
+ _comment: 'STRICTLY READ-ONLY PROJECTION GENERATED FROM B2TFSINDEXIBGIB_V1 IN LOCALSPACE',
269
+ indexAddr,
270
+ spaceId: indexIbGib.data?.mySpaceId,
271
+ activeBranch: indexIbGib.data?.activeBranch || 'main',
272
+ stagedCount: (indexIbGib.data?.staged_item || []).length,
273
+ stagedPaths: indexIbGib.data?.stagedPaths || {},
274
+ updatedAt: new Date().toISOString(),
275
+ };
276
+ const projFile = path.join(vcsPath, 'vcs_index_projection.json');
277
+ await fs.writeFile(projFile, JSON.stringify(projectionObj, null, 2), 'utf8');
278
+ }
279
+ catch (error) {
280
+ console.error(`${lc} ${extractErrorMsg(error)} (E: 4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c)`);
281
+ throw error;
282
+ }
283
+ finally {
284
+ if (logalot) {
285
+ console.log(`${lc} complete. (I: 5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d)`);
286
+ }
287
+ }
288
+ }
289
+ //# sourceMappingURL=index-helper.mjs.map