@ibgib/vcs-gib 0.0.32 → 0.0.34

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 (133) hide show
  1. package/README.md +14 -7
  2. package/dist/AUTO-GENERATED-version.d.mts +1 -1
  3. package/dist/AUTO-GENERATED-version.mjs +1 -1
  4. package/dist/bootstrap/node-bootstrap.d.mts.map +1 -1
  5. package/dist/bootstrap/node-bootstrap.mjs +6 -20
  6. package/dist/bootstrap/node-bootstrap.mjs.map +1 -1
  7. package/dist/cli/commands/{add-cmd.d.mts → cli-add-cmd.d.mts} +1 -1
  8. package/dist/cli/commands/cli-add-cmd.d.mts.map +1 -0
  9. package/dist/cli/commands/cli-add-cmd.mjs +45 -0
  10. package/dist/cli/commands/cli-add-cmd.mjs.map +1 -0
  11. package/dist/cli/commands/{branch-cmd.d.mts → cli-branch-cmd.d.mts} +1 -1
  12. package/dist/cli/commands/cli-branch-cmd.d.mts.map +1 -0
  13. package/dist/cli/commands/cli-branch-cmd.mjs +59 -0
  14. package/dist/cli/commands/cli-branch-cmd.mjs.map +1 -0
  15. package/dist/cli/commands/{checkout-cmd.d.mts → cli-checkout-cmd.d.mts} +4 -3
  16. package/dist/cli/commands/cli-checkout-cmd.d.mts.map +1 -0
  17. package/dist/cli/commands/cli-checkout-cmd.mjs +50 -0
  18. package/dist/cli/commands/cli-checkout-cmd.mjs.map +1 -0
  19. package/dist/cli/commands/{commit-cmd.d.mts → cli-commit-cmd.d.mts} +1 -1
  20. package/dist/cli/commands/cli-commit-cmd.d.mts.map +1 -0
  21. package/dist/cli/commands/cli-commit-cmd.mjs +52 -0
  22. package/dist/cli/commands/cli-commit-cmd.mjs.map +1 -0
  23. package/dist/cli/commands/{generate-comment-cmd.d.mts → cli-generate-comment-cmd.d.mts} +1 -1
  24. package/dist/cli/commands/cli-generate-comment-cmd.d.mts.map +1 -0
  25. package/dist/cli/commands/{generate-comment-cmd.mjs → cli-generate-comment-cmd.mjs} +8 -6
  26. package/dist/cli/commands/cli-generate-comment-cmd.mjs.map +1 -0
  27. package/dist/cli/commands/{init-cmd.d.mts → cli-init-cmd.d.mts} +1 -1
  28. package/dist/cli/commands/cli-init-cmd.d.mts.map +1 -0
  29. package/dist/cli/commands/cli-init-cmd.mjs +47 -0
  30. package/dist/cli/commands/cli-init-cmd.mjs.map +1 -0
  31. package/dist/cli/commands/{log-cmd.d.mts → cli-log-cmd.d.mts} +1 -1
  32. package/dist/cli/commands/cli-log-cmd.d.mts.map +1 -0
  33. package/dist/cli/commands/{log-cmd.mjs → cli-log-cmd.mjs} +14 -44
  34. package/dist/cli/commands/cli-log-cmd.mjs.map +1 -0
  35. package/dist/cli/commands/{merge-cmd.d.mts → cli-merge-cmd.d.mts} +1 -1
  36. package/dist/cli/commands/cli-merge-cmd.d.mts.map +1 -0
  37. package/dist/cli/commands/cli-merge-cmd.mjs +66 -0
  38. package/dist/cli/commands/cli-merge-cmd.mjs.map +1 -0
  39. package/dist/cli/commands/{reset-cmd.d.mts → cli-reset-cmd.d.mts} +1 -1
  40. package/dist/cli/commands/cli-reset-cmd.d.mts.map +1 -0
  41. package/dist/cli/commands/cli-reset-cmd.mjs +63 -0
  42. package/dist/cli/commands/cli-reset-cmd.mjs.map +1 -0
  43. package/dist/cli/commands/{restore-cmd.d.mts → cli-restore-cmd.d.mts} +1 -1
  44. package/dist/cli/commands/cli-restore-cmd.d.mts.map +1 -0
  45. package/dist/cli/commands/cli-restore-cmd.mjs +55 -0
  46. package/dist/cli/commands/cli-restore-cmd.mjs.map +1 -0
  47. package/dist/cli/commands/{status-cmd.d.mts → cli-status-cmd.d.mts} +1 -1
  48. package/dist/cli/commands/cli-status-cmd.d.mts.map +1 -0
  49. package/dist/cli/commands/{status-cmd.mjs → cli-status-cmd.mjs} +4 -41
  50. package/dist/cli/commands/cli-status-cmd.mjs.map +1 -0
  51. package/dist/cli/vcs-cli-main.d.mts.map +1 -1
  52. package/dist/cli/vcs-cli-main.mjs +18 -15
  53. package/dist/cli/vcs-cli-main.mjs.map +1 -1
  54. package/dist/cli/vcs-projection-helper.mjs +7 -7
  55. package/dist/cli/vcs-projection-helper.mjs.map +1 -1
  56. package/dist/cli/vcs-repo-helper.d.mts +19 -0
  57. package/dist/cli/vcs-repo-helper.d.mts.map +1 -0
  58. package/dist/cli/vcs-repo-helper.mjs +84 -0
  59. package/dist/cli/vcs-repo-helper.mjs.map +1 -0
  60. package/dist/test/test-helpers.d.mts +9 -0
  61. package/dist/test/test-helpers.d.mts.map +1 -1
  62. package/dist/test/test-helpers.mjs +35 -0
  63. package/dist/test/test-helpers.mjs.map +1 -1
  64. package/package.json +6 -6
  65. package/src/AUTO-GENERATED-version.mts +1 -1
  66. package/src/bootstrap/node-bootstrap.mts +6 -20
  67. package/src/bootstrap/node-bootstrap.respec.mts +2 -2
  68. package/src/cli/cli-arg-parser.respec.mts +2 -2
  69. package/src/cli/cli-e2e.respec.mts +15 -14
  70. package/src/cli/commands/branch-checkout-cmd.respec.mts +28 -14
  71. package/src/cli/commands/cli-add-cmd.mts +65 -0
  72. package/src/cli/commands/cli-branch-cmd.mts +87 -0
  73. package/src/cli/commands/cli-checkout-cmd.mts +72 -0
  74. package/src/cli/commands/cli-commit-cmd.mts +77 -0
  75. package/src/cli/commands/{generate-comment-cmd.mts → cli-generate-comment-cmd.mts} +8 -6
  76. package/src/cli/commands/cli-init-cmd.mts +78 -0
  77. package/src/cli/commands/{log-cmd.mts → cli-log-cmd.mts} +14 -47
  78. package/src/cli/commands/cli-merge-cmd.mts +99 -0
  79. package/src/cli/commands/cli-reset-cmd.mts +94 -0
  80. package/src/cli/commands/cli-restore-cmd.mts +87 -0
  81. package/src/cli/commands/{status-cmd.mts → cli-status-cmd.mts} +3 -45
  82. package/src/cli/commands/commit-log-cmd.respec.mts +84 -34
  83. package/src/cli/commands/init-cmd.respec.mts +3 -3
  84. package/src/cli/commands/reset-restore-cmd.respec.mts +9 -9
  85. package/src/cli/commands/status-add-cmd.respec.mts +13 -9
  86. package/src/cli/vcs-cli-main.mts +18 -15
  87. package/src/cli/vcs-projection-helper.mts +8 -8
  88. package/src/cli/vcs-repo-helper.mts +113 -0
  89. package/src/engine/branch/branch-space.respec.mts +22 -20
  90. package/src/engine/merge/b2tfs-sync-comments.respec.mts +10 -10
  91. package/src/test/test-helpers.mts +49 -1
  92. package/src/vcs-gib.respec.mts +21 -15
  93. package/tsconfig.test.tsbuildinfo +1 -1
  94. package/tsconfig.tsbuildinfo +1 -1
  95. package/vcs-gib_test_output.md +77 -0
  96. package/dist/cli/commands/add-cmd.d.mts.map +0 -1
  97. package/dist/cli/commands/add-cmd.mjs +0 -93
  98. package/dist/cli/commands/add-cmd.mjs.map +0 -1
  99. package/dist/cli/commands/branch-cmd.d.mts.map +0 -1
  100. package/dist/cli/commands/branch-cmd.mjs +0 -107
  101. package/dist/cli/commands/branch-cmd.mjs.map +0 -1
  102. package/dist/cli/commands/checkout-cmd.d.mts.map +0 -1
  103. package/dist/cli/commands/checkout-cmd.mjs +0 -95
  104. package/dist/cli/commands/checkout-cmd.mjs.map +0 -1
  105. package/dist/cli/commands/commit-cmd.d.mts.map +0 -1
  106. package/dist/cli/commands/commit-cmd.mjs +0 -99
  107. package/dist/cli/commands/commit-cmd.mjs.map +0 -1
  108. package/dist/cli/commands/generate-comment-cmd.d.mts.map +0 -1
  109. package/dist/cli/commands/generate-comment-cmd.mjs.map +0 -1
  110. package/dist/cli/commands/init-cmd.d.mts.map +0 -1
  111. package/dist/cli/commands/init-cmd.mjs +0 -69
  112. package/dist/cli/commands/init-cmd.mjs.map +0 -1
  113. package/dist/cli/commands/log-cmd.d.mts.map +0 -1
  114. package/dist/cli/commands/log-cmd.mjs.map +0 -1
  115. package/dist/cli/commands/merge-cmd.d.mts.map +0 -1
  116. package/dist/cli/commands/merge-cmd.mjs +0 -106
  117. package/dist/cli/commands/merge-cmd.mjs.map +0 -1
  118. package/dist/cli/commands/reset-cmd.d.mts.map +0 -1
  119. package/dist/cli/commands/reset-cmd.mjs +0 -91
  120. package/dist/cli/commands/reset-cmd.mjs.map +0 -1
  121. package/dist/cli/commands/restore-cmd.d.mts.map +0 -1
  122. package/dist/cli/commands/restore-cmd.mjs +0 -97
  123. package/dist/cli/commands/restore-cmd.mjs.map +0 -1
  124. package/dist/cli/commands/status-cmd.d.mts.map +0 -1
  125. package/dist/cli/commands/status-cmd.mjs.map +0 -1
  126. package/src/cli/commands/add-cmd.mts +0 -120
  127. package/src/cli/commands/branch-cmd.mts +0 -142
  128. package/src/cli/commands/checkout-cmd.mts +0 -123
  129. package/src/cli/commands/commit-cmd.mts +0 -130
  130. package/src/cli/commands/init-cmd.mts +0 -99
  131. package/src/cli/commands/merge-cmd.mts +0 -143
  132. package/src/cli/commands/reset-cmd.mts +0 -126
  133. package/src/cli/commands/restore-cmd.mts +0 -135
@@ -0,0 +1,87 @@
1
+ /**
2
+ * @module restore-cmd
3
+ *
4
+ * CLI command handler for `vcs restore [path...]`.
5
+ * Delegates to executeVcsRestore and formats terminal output.
6
+ */
7
+
8
+ import path from 'node:path';
9
+ import fs from 'node:fs/promises';
10
+
11
+ import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
12
+ import { openVcsRepository } from '../vcs-repo-helper.mjs';
13
+ import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
14
+
15
+ const lcFile = `[restore-cmd]`;
16
+ const logalot = GLOBAL_LOG_A_LOT;
17
+
18
+ export interface RestoreCmdOpts {
19
+ paths?: string[];
20
+ staged?: boolean;
21
+ worktree?: boolean;
22
+ all?: boolean;
23
+ yes?: boolean;
24
+ force?: boolean;
25
+ targetDir?: string;
26
+ vcsFolderName?: string;
27
+ quiet?: boolean;
28
+ }
29
+
30
+ export interface RestoreCmdResult {
31
+ restoredPaths: string[];
32
+ unstagedPaths: string[];
33
+ }
34
+
35
+ export async function executeRestoreCmd({
36
+ paths = [],
37
+ staged = false,
38
+ worktree = false,
39
+ all = false,
40
+ yes = false,
41
+ force = false,
42
+ targetDir = process.cwd(),
43
+ vcsFolderName = '.vcsgib',
44
+ quiet = false,
45
+ }: RestoreCmdOpts = {}): Promise<RestoreCmdResult> {
46
+ const lc = `${lcFile}[${executeRestoreCmd.name}]`;
47
+ try {
48
+ if (logalot) {
49
+ console.log(`${lc} starting... (I: genuuid)`);
50
+ }
51
+
52
+ const absTargetDir = path.resolve(targetDir);
53
+ const { repo, activeWorktreeDir } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
54
+
55
+ const restoreRes = await repo.restore({
56
+ paths,
57
+ staged,
58
+ all,
59
+ targetDir: absTargetDir,
60
+ activeWorktreeDir,
61
+ });
62
+
63
+ if (!quiet) {
64
+ if (staged) {
65
+ for (const unstagedPath of restoreRes.unstagedPaths) {
66
+ console.log(`unstaged: ${unstagedPath}`);
67
+ }
68
+ } else {
69
+ for (const restoredPath of restoreRes.restoredPaths) {
70
+ console.log(`restored: ${restoredPath}`);
71
+ }
72
+ }
73
+ }
74
+
75
+ return {
76
+ restoredPaths: restoreRes.restoredPaths,
77
+ unstagedPaths: restoreRes.unstagedPaths,
78
+ };
79
+ } catch (error) {
80
+ console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
81
+ throw error;
82
+ } finally {
83
+ if (logalot) {
84
+ console.log(`${lc} complete. (I: genuuid)`);
85
+ }
86
+ }
87
+ }
@@ -6,17 +6,10 @@
6
6
  */
7
7
 
8
8
  import path from 'node:path';
9
- import fs from 'node:fs/promises';
10
9
 
11
10
  import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
12
- import { executeVcsStatus } from '@ibgib/core-gib/dist/vcs/commands/status-cmd.mjs';
13
11
  import { VcsStatusItem, PendingCommentInfo } from '@ibgib/core-gib/dist/vcs/status/status-helper.mjs';
14
- import { resolveContextualBranchName } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
15
-
16
- import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
17
- import { getOrCreateBranchSpace } from '@ibgib/node-gib/dist/vcs/branch-space-helper.mjs';
18
- import { getOrCreateWorkspaceProjectionSpace } from '@ibgib/node-gib/dist/vcs/workspace-space-helper.mjs';
19
- import { readVcsIndexProjectionFromDisk } from '../vcs-projection-helper.mjs';
12
+ import { openVcsRepository } from '../vcs-repo-helper.mjs';
20
13
  import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
21
14
 
22
15
  const lcFile = `[status-cmd]`;
@@ -54,45 +47,10 @@ export async function executeStatusCmd({
54
47
  }
55
48
 
56
49
  const absTargetDir = path.resolve(targetDir);
50
+ const { repo } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
57
51
 
58
- const { metaspace, localSpace, vcsPath, repoRoot } = await bootstrapVcsMetaspace({
59
- repoPath: absTargetDir,
60
- vcsFolderName,
61
- });
62
-
63
- // Verify repo exists
64
- try {
65
- await fs.access(vcsPath);
66
- } catch {
67
- throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: 4d5e6f7a8b9c10d11e12f13a14b15c6d)`);
68
- }
69
-
70
- const indexIbGib = await readVcsIndexProjectionFromDisk({ vcsPath, space: localSpace });
71
- const branchName = resolveContextualBranchName({ targetDir: absTargetDir, repoRoot, indexIbGib });
72
- const activeWorktreeDir = branchName === 'main' ? repoRoot : path.join(repoRoot, 'b', branchName);
73
-
74
- const { space: activeBranchSpace } = await getOrCreateBranchSpace({
75
- metaspace,
76
- vcsPath,
77
- branchName,
78
- });
79
-
80
- const { space: workspaceSpace } = await getOrCreateWorkspaceProjectionSpace({
81
- metaspace,
82
- workspaceRoot: activeWorktreeDir,
83
- vcsFolderName,
84
- backingSpace: activeBranchSpace,
85
- });
86
-
87
- const statusRes = await executeVcsStatus({
88
- metaspace,
89
- localSpace,
90
- activeBranchSpace,
91
- workspaceSpace,
92
- indexIbGib,
93
- repoRoot,
52
+ const statusRes = await repo.status({
94
53
  targetDir: absTargetDir,
95
- vcsFolderName,
96
54
  });
97
55
 
98
56
  const { staged, modified, deleted, untracked, pendingComments } = statusRes;
@@ -11,23 +11,27 @@ import {
11
11
  respecfully, ifWe, ifWeMight, iReckon
12
12
  } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
13
13
 
14
+ import { extractErrorMsg, pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
14
15
  import { getDependencyGraph } from '@ibgib/core-gib/dist/common/other/graph-helper.mjs';
15
- import { getFromSpace } from '@ibgib/core-gib/dist/witness/space/space-helper.mjs';
16
- import { executeInitCmd } from './init-cmd.mjs';
17
- import { executeAddCmd } from './add-cmd.mjs';
18
- import { executeStatusCmd } from './status-cmd.mjs';
19
- import { executeCommitCmd } from './commit-cmd.mjs';
20
- import { executeLogCmd } from './log-cmd.mjs';
21
- import { executeBranchCmd } from './branch-cmd.mjs';
22
- import { executeCheckoutCmd } from './checkout-cmd.mjs';
23
- import { executeMergeCmd } from './merge-cmd.mjs';
24
- import { executeGenerateCommentCmd } from './generate-comment-cmd.mjs';
16
+ import { getLatestAddrs } from '@ibgib/core-gib/dist/witness/space/space-helper.mjs';
17
+ import { getB2tFSIndexIbGib, } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
18
+ import { getOrCreateBranchSpace, parseBranchIb } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
19
+ import { B2tFSBranchIbGib_V1 } from '@ibgib/core-gib/dist/vcs/branch/branch-types.mjs';
20
+ import { B2tFSItemIbGib_V1 } from '@ibgib/core-gib/dist/vcs/item/item-types.mjs';
21
+ import { getIbGibFromSpace, parseSpaceQualifiedIbGibAddr } from '@ibgib/core-gib/dist/common/other/ibgib-helper.mjs';
22
+
23
+ import { executeInitCmd } from './cli-init-cmd.mjs';
24
+ import { executeAddCmd } from './cli-add-cmd.mjs';
25
+ import { executeStatusCmd } from './cli-status-cmd.mjs';
26
+ import { executeCommitCmd } from './cli-commit-cmd.mjs';
27
+ import { executeLogCmd } from './cli-log-cmd.mjs';
28
+ import { executeBranchCmd } from './cli-branch-cmd.mjs';
29
+ import { executeCheckoutCmd } from './cli-checkout-cmd.mjs';
30
+ import { executeMergeCmd } from './cli-merge-cmd.mjs';
31
+ import { executeGenerateCommentCmd } from './cli-generate-comment-cmd.mjs';
25
32
  import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
26
- import { readVcsIndexProjectionFromDisk } from '../vcs-projection-helper.mjs';
27
- import { getOrCreateBranchSpace } from '@ibgib/node-gib/dist/vcs/branch-space-helper.mjs';
28
- import { getIbGibWithMetaspaceFallback } from '@ibgib/core-gib/dist/vcs/item/item-helper.mjs';
29
33
 
30
- const lc = `[apps/vcs-gib/src/cli/commands/commit-log-cmd.respec.node.mts]`;
34
+ const lc = `[apps/vcs-gib/src/cli/commands/commit-log-cmd.respec.mts]`;
31
35
 
32
36
  await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
33
37
 
@@ -115,11 +119,11 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
115
119
  quiet: true,
116
120
  });
117
121
 
118
- const { localSpace: spaceAdd, vcsPath: vcsPathAdd } = await bootstrapVcsMetaspace({
122
+ const { metaspace: metaspaceAdd, localSpace: spaceAdd } = await bootstrapVcsMetaspace({
119
123
  repoPath: testDir,
120
124
  vcsFolderName,
121
125
  });
122
- const indexAdd = await readVcsIndexProjectionFromDisk({ space: spaceAdd, vcsPath: vcsPathAdd });
126
+ const indexAdd = await getB2tFSIndexIbGib({ space: spaceAdd, metaspace: metaspaceAdd });
123
127
  iReckon(lc, Boolean(indexAdd?.data?.staged_item && indexAdd.data.staged_item.length > 0)).isGonnaBeTrue();
124
128
  iReckon(lc, indexAdd?.rel8ns?.staged_item).isGonnaBeFalsy();
125
129
 
@@ -130,11 +134,11 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
130
134
  quiet: true,
131
135
  });
132
136
 
133
- const { localSpace: spaceCommit, vcsPath: vcsPathCommit } = await bootstrapVcsMetaspace({
137
+ const { metaspace: metaspaceCommit, localSpace: spaceCommit } = await bootstrapVcsMetaspace({
134
138
  repoPath: testDir,
135
139
  vcsFolderName,
136
140
  });
137
- const indexCommit = await readVcsIndexProjectionFromDisk({ space: spaceCommit, vcsPath: vcsPathCommit });
141
+ const indexCommit = await getB2tFSIndexIbGib({ space: spaceCommit, metaspace: metaspaceCommit });
138
142
  iReckon(lc, indexCommit?.data?.staged_item).willEqual([]);
139
143
  iReckon(lc, indexCommit?.rel8ns?.staged_item).isGonnaBeFalsy();
140
144
 
@@ -149,9 +153,11 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
149
153
  quiet: true,
150
154
  });
151
155
 
156
+ console.log(`[TEST-LOG] statusRes: staged=${statusRes.staged.length}, modified=${statusRes.modified.length}, untracked=${statusRes.untracked.length}`);
152
157
  iReckon(lc, statusRes.staged.length).willEqual(0);
153
158
  iReckon(lc, statusRes.modified.length).willEqual(0);
154
159
  iReckon(lc, statusRes.untracked.length).willEqual(0);
160
+ console.log(`[TEST-LOG] statusRes assertions complete.`);
155
161
  } finally {
156
162
  await fs.rm(testDir, { recursive: true, force: true });
157
163
  }
@@ -434,7 +440,9 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
434
440
  await executeCommitCmd({ message: 'Main branch update', targetDir: testDir, vcsFolderName, quiet: true });
435
441
 
436
442
  // Merge feature-comments into main
437
- await executeMergeCmd({ incomingBranchName: 'feature-comments', targetDir: testDir, vcsFolderName, quiet: true });
443
+ await executeMergeCmd({
444
+ incomingBranchName: 'feature-comments', targetDir: testDir, vcsFolderName, quiet: true
445
+ });
438
446
 
439
447
  // Check file log on main: both comments should be present!
440
448
  const mergedFileLog = await executeLogCmd({
@@ -445,33 +453,71 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
445
453
  });
446
454
 
447
455
  const allMessages = mergedFileLog.commits.map(c => c.message).join(' -- ');
456
+ console.log(`allMessages: ${pretty(allMessages)}`);
448
457
  iReckon(lc, allMessages).includes('updated b to 200');
449
458
  iReckon(lc, allMessages).includes('updated a to 100');
450
459
 
451
460
  // Verify getDependencyGraph works 100% within main branch space alone (no metaspace fallback)
452
- const { metaspace, vcsPath } = await bootstrapVcsMetaspace({
461
+ const { metaspace, localSpace, vcsPath } = await bootstrapVcsMetaspace({
453
462
  repoPath: testDir,
454
463
  vcsFolderName,
455
464
  });
456
465
  const { space: mainSpace } = await getOrCreateBranchSpace({
457
466
  metaspace,
458
- vcsPath,
459
467
  branchName: 'main',
460
468
  });
461
- const indexIbGib = await readVcsIndexProjectionFromDisk({ space: metaspace.zeroSpace, vcsPath });
462
- const branchAddrs = [
463
- ...(indexIbGib?.rel8ns?.branch || []),
464
- ...(indexIbGib?.rel8ns?.branch_tjp || []),
465
- ];
466
- const mainBranchAddr = branchAddrs.find(a => a.includes('main')) || branchAddrs.at(-1);
467
- const mainBranch = await getIbGibWithMetaspaceFallback({ addr: mainBranchAddr!, space: mainSpace, metaspace });
468
- const mainRootAddr = mainBranch?.rel8ns?.b2tfs_item?.at(-1);
469
- const mainRoot = await getIbGibWithMetaspaceFallback({ addr: mainRootAddr!, space: mainSpace, metaspace });
469
+ const indexIbGib = await getB2tFSIndexIbGib({ space: localSpace, metaspace });
470
+ if (!indexIbGib) { throw new Error(`(UNEXPECTED) indexIbGib falsy? (E: d4ec1b6f86cbf18808fba957b7b83826)`); }
471
+ const branchAddrs_spacequalified = indexIbGib.data['$@branch'] ?? [];
472
+ if (branchAddrs_spacequalified.length === 0) {
473
+ throw new Error(`(UNEXPECTED) indexIbGib doesn't have any branch addrs in data? (E: 7069280124b81c6d1806fc580c704826)`);
474
+ }
475
+ const branchAddrs_spacequalified_main = branchAddrs_spacequalified
476
+ .filter(x => {
477
+ const parsedBranchAddrInfo = parseSpaceQualifiedIbGibAddr({ sqAddr: x });
478
+ if (!parsedBranchAddrInfo) { throw new Error(`(UNEXPECTED) parsedBranchAddrInfo falsy? space-qualified branch addr couldn't be parsed? (E: 779b886c5a6d64b0ce0e8c185952b526)`); }
479
+ const parsedBranchIb = parseBranchIb({ ib: parsedBranchAddrInfo.ib });
480
+ return parsedBranchIb.branchName === 'main';
481
+ });
482
+
483
+ if (branchAddrs_spacequalified_main.length !== 1) { throw new Error(`(UNEXPECTED) branchAddrs_spacequalified_main.length !== 1? (E: 3ec21f70cca8b2347de407abc9062826)`); }
484
+
485
+ const mainBranchAddr_spaceQualified = branchAddrs_spacequalified_main[0];
486
+
487
+ const mainBranchAddrInfo = parseSpaceQualifiedIbGibAddr({
488
+ sqAddr: mainBranchAddr_spaceQualified
489
+ });
490
+ if (!mainBranchAddrInfo) { throw new Error(`(UNEXPECTED) mainBranchAddrInfo falsy? couldn't parse it? (E: ae570ae49e190727fc4464183ab87226)`); }
491
+
492
+ const resLatestMainBranchAddrs = await getLatestAddrs({
493
+ addrs: [mainBranchAddrInfo.ibGibAddr],
494
+ space: mainSpace,
495
+ });
496
+ if (!resLatestMainBranchAddrs) { throw new Error(`resLatestMainBranchAddrs falsy (E: f22b6325ec6804046899e49d8076d826)`); }
497
+ if (!resLatestMainBranchAddrs.data) { throw new Error(`(UNEXPECTED) resLatestMainBranchAddrs.data falsy? (E: 2709383cb8943aeb0801bf2541f91826)`); }
498
+ if (!resLatestMainBranchAddrs.data.latestAddrsMap) { throw new Error(`resLatestMainBranchAddrs.data.latestAddrsMap falsy (E: 4b3824e20968409128270faf093a6826)`); }
499
+ if (Object.keys(resLatestMainBranchAddrs.data.latestAddrsMap).length !== 1) { throw new Error(`(UNEXPECTED) resLatestMainBranchAddrs.data.latestAddrsMap not size 1? (E: bffbbd29f0222027d824e1b810281826)`); }
500
+
501
+ let latestMainAddr =
502
+ Object.values(resLatestMainBranchAddrs.data.latestAddrsMap).at(0) || mainBranchAddrInfo.ibGibAddr;
503
+ const latestMainBranchIbGib = await getIbGibFromSpace<B2tFSBranchIbGib_V1>({ addr: latestMainAddr, space: mainSpace });
504
+ if (!latestMainBranchIbGib) { throw new Error(`(UNEXPECTED) latestMainBranchIbGib? (E: 29b2884d60eac1fb98d512f81af8f826)`); }
505
+
506
+ if (!latestMainBranchIbGib.rel8ns) { throw new Error(`(UNEXPECTED) latestMainBranchIbGib.rel8ns falsy? (E: 3c70081bde0d9cce68b857b829472726)`); }
507
+ if (!latestMainBranchIbGib.rel8ns.b2tfs_item) { throw new Error(`latestMainBranchIbGib.rel8ns.b2tfs_item falsy (E: 6ab0d8c90628c10e020b22b862590f26)`); }
508
+ const mainRootItemAddr = latestMainBranchIbGib.rel8ns.b2tfs_item.at(-1);
509
+ if (!mainRootItemAddr) { throw new Error(`(UNEXPECTED) mainRootItemAddr falsy? we always should have a root item related to the branch ibgib. (E: 7897abafda988af1333d3048aa7a9826)`); }
510
+ const mainRootItem = await getIbGibFromSpace<B2tFSItemIbGib_V1>({ addr: mainRootItemAddr, space: mainSpace, });
511
+ if (!mainRootItem) { throw new Error(`(UNEXPECTED) mainRootItem falsy? (E: 4e5afe38b7fb1f560494b61a82bdd526)`); }
512
+ if (!mainRootItem.rel8ns) { throw new Error(`(UNEXPECTED) mainRootItem.rel8ns falsy? (E: 0301644482a6431419243c528f121826)`); }
513
+
470
514
  let appItem: any;
471
- for (const childAddr of mainRoot?.rel8ns?.b2tfs_child || []) {
472
- const child = await getIbGibWithMetaspaceFallback({ addr: childAddr, space: mainSpace, metaspace });
473
- if (child?.data?.name === 'app.ts') {
474
- appItem = child;
515
+ // Bill: is mainRootItem definitely a folder in this test? someone should double-check this.
516
+ for (const childAddr of mainRootItem?.rel8ns?.b2tfs_child || []) {
517
+ const childOfMainRootItem = await getIbGibFromSpace<B2tFSItemIbGib_V1>({ addr: childAddr, space: mainSpace, metaspace });
518
+ if (!childOfMainRootItem) { throw new Error(`(UNEXPECTED) childOfMainRootItem falsy? (E: 216428e870884ba2e8c854c25f914826)`); }
519
+ if (childOfMainRootItem.data.name === 'app.ts') {
520
+ appItem = childOfMainRootItem;
475
521
  break;
476
522
  }
477
523
  }
@@ -486,6 +532,10 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
486
532
  const graphValues = Object.values(depGraph);
487
533
  const foundCommentB = graphValues.some(x => (x.data as any)?.text === 'feat(feature-comments): updated b to 200');
488
534
  iReckon(lc, foundCommentB).isGonnaBeTruthy();
535
+ } catch (error) {
536
+ const emsg = extractErrorMsg(error);
537
+ console.error(emsg);
538
+ iReckon(lc, true).asTo(emsg).isGonnaBeFalse();
489
539
  } finally {
490
540
  await fs.rm(testDir, { recursive: true, force: true });
491
541
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module init-cmd.respec
3
- *
3
+ *
4
4
  * Unit tests for `vcs init` command handler.
5
5
  */
6
6
 
@@ -12,9 +12,9 @@ import {
12
12
  respecfully, ifWe, iReckon
13
13
  } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
14
14
 
15
- import { executeInitCmd } from './init-cmd.mjs';
15
+ import { executeInitCmd } from './cli-init-cmd.mjs';
16
16
 
17
- const lc = `[apps/vcs-gib/src/cli/commands/init-cmd.respec.node.mts]`;
17
+ const lc = `[apps/vcs-gib/src/cli/commands/init-cmd.respec.mts]`;
18
18
 
19
19
  await respecfully(lc, `vcs init Command Handler`, async () => {
20
20
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module reset-restore-cmd.respec
3
- *
3
+ *
4
4
  * Unit tests for `vcs reset` and `vcs restore` command handlers.
5
5
  */
6
6
 
@@ -8,17 +8,17 @@ import path from 'node:path';
8
8
  import fs from 'node:fs/promises';
9
9
 
10
10
  import {
11
- respecfully, ifWe, iReckon
11
+ respecfully, ifWe, iReckon, ifWeMight, // don't remove unused ifWe or ifWeMight
12
12
  } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
13
13
 
14
- import { executeInitCmd } from './init-cmd.mjs';
15
- import { executeAddCmd } from './add-cmd.mjs';
16
- import { executeCommitCmd } from './commit-cmd.mjs';
17
- import { executeStatusCmd } from './status-cmd.mjs';
18
- import { executeResetCmd } from './reset-cmd.mjs';
19
- import { executeRestoreCmd } from './restore-cmd.mjs';
14
+ import { executeInitCmd } from './cli-init-cmd.mjs';
15
+ import { executeAddCmd } from './cli-add-cmd.mjs';
16
+ import { executeCommitCmd } from './cli-commit-cmd.mjs';
17
+ import { executeStatusCmd } from './cli-status-cmd.mjs';
18
+ import { executeResetCmd } from './cli-reset-cmd.mjs';
19
+ import { executeRestoreCmd } from './cli-restore-cmd.mjs';
20
20
 
21
- const lc = `[apps/vcs-gib/src/cli/commands/reset-restore-cmd.respec.node.mts]`;
21
+ const lc = `[apps/vcs-gib/src/cli/commands/reset-restore-cmd.respec.mts]`;
22
22
 
23
23
  await respecfully(lc, `vcs reset and vcs restore Command Handlers`, async () => {
24
24
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module status-add-cmd.respec
3
- *
3
+ *
4
4
  * Unit tests for `vcs status` and `vcs add` command handlers.
5
5
  */
6
6
 
@@ -11,14 +11,16 @@ import {
11
11
  respecfully, ifWe, ifWeMight, iReckon
12
12
  } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
13
13
 
14
- import { executeInitCmd } from './init-cmd.mjs';
15
- import { executeStatusCmd } from './status-cmd.mjs';
16
- import { executeAddCmd } from './add-cmd.mjs';
17
- import { executeCommitCmd } from './commit-cmd.mjs';
14
+ import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
15
+ import { getB2tFSIndexIbGib } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
16
+
17
+ import { executeInitCmd } from './cli-init-cmd.mjs';
18
+ import { executeStatusCmd } from './cli-status-cmd.mjs';
19
+ import { executeAddCmd } from './cli-add-cmd.mjs';
20
+ import { executeCommitCmd } from './cli-commit-cmd.mjs';
18
21
  import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
19
- import { readVcsIndexProjectionFromDisk } from '../vcs-projection-helper.mjs';
20
22
 
21
- const lc = `[apps/vcs-gib/src/cli/commands/status-add-cmd.respec.node.mts]`;
23
+ const lc = `[apps/vcs-gib/src/cli/commands/status-add-cmd.respec.mts]`;
22
24
 
23
25
  await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
24
26
 
@@ -138,11 +140,11 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
138
140
 
139
141
  iReckon(lc, addRes.stagedPaths).includes('file1.txt');
140
142
 
141
- const { localSpace, vcsPath } = await bootstrapVcsMetaspace({
143
+ const { metaspace, localSpace } = await bootstrapVcsMetaspace({
142
144
  repoPath: testDir,
143
145
  vcsFolderName,
144
146
  });
145
- const indexIbGib = await readVcsIndexProjectionFromDisk({ space: localSpace, vcsPath });
147
+ const indexIbGib = await getB2tFSIndexIbGib({ space: localSpace, metaspace });
146
148
  iReckon(lc, Boolean(indexIbGib?.data?.staged_item && indexIbGib.data.staged_item.length > 0)).isGonnaBeTrue();
147
149
  iReckon(lc, indexIbGib?.rel8ns?.staged_item).isGonnaBeFalsy();
148
150
 
@@ -266,6 +268,8 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
266
268
  });
267
269
 
268
270
  iReckon(lc, addRes.stagedPaths).includes('src/utils/math.js');
271
+ } catch (error) {
272
+ iReckon(lc, true).asTo(extractErrorMsg(error)).isGonnaBeFalse();
269
273
  } finally {
270
274
  await fs.rm(testDir, { recursive: true, force: true });
271
275
  }
@@ -10,17 +10,17 @@ import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs
10
10
 
11
11
  import { parseVcsArgs } from './cli-arg-parser.mjs';
12
12
  import { VCS_SUBCOMMANDS } from './cli-constants.mjs';
13
- import { executeInitCmd } from './commands/init-cmd.mjs';
14
- import { executeStatusCmd } from './commands/status-cmd.mjs';
15
- import { executeAddCmd } from './commands/add-cmd.mjs';
16
- import { executeCommitCmd } from './commands/commit-cmd.mjs';
17
- import { executeLogCmd } from './commands/log-cmd.mjs';
18
- import { executeBranchCmd } from './commands/branch-cmd.mjs';
19
- import { executeCheckoutCmd } from './commands/checkout-cmd.mjs';
20
- import { executeMergeCmd } from './commands/merge-cmd.mjs';
21
- import { executeResetCmd } from './commands/reset-cmd.mjs';
22
- import { executeRestoreCmd } from './commands/restore-cmd.mjs';
23
- import { executeGenerateCommentCmd } from './commands/generate-comment-cmd.mjs';
13
+ import { executeInitCmd } from './commands/cli-init-cmd.mjs';
14
+ import { executeStatusCmd } from './commands/cli-status-cmd.mjs';
15
+ import { executeAddCmd } from './commands/cli-add-cmd.mjs';
16
+ import { executeCommitCmd } from './commands/cli-commit-cmd.mjs';
17
+ import { executeLogCmd } from './commands/cli-log-cmd.mjs';
18
+ import { executeBranchCmd } from './commands/cli-branch-cmd.mjs';
19
+ import { executeCheckoutCmd } from './commands/cli-checkout-cmd.mjs';
20
+ import { executeMergeCmd } from './commands/cli-merge-cmd.mjs';
21
+ import { executeResetCmd } from './commands/cli-reset-cmd.mjs';
22
+ import { executeRestoreCmd } from './commands/cli-restore-cmd.mjs';
23
+ import { executeGenerateCommentCmd } from './commands/cli-generate-comment-cmd.mjs';
24
24
  import { AUTO_GENERATED_VERSION } from '../AUTO-GENERATED-version.mjs';
25
25
  import { GLOBAL_LOG_A_LOT } from '../vcs-gib-constants.mjs';
26
26
 
@@ -76,7 +76,7 @@ export async function main({
76
76
  const lc = `${lcFile}[${main.name}]`;
77
77
  try {
78
78
  if (logalot) {
79
- console.log(`${lc} starting... (I: 4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e)`);
79
+ console.log(`${lc} starting... (I: genuuid)`);
80
80
  }
81
81
 
82
82
  const parsed = parseVcsArgs(argv);
@@ -140,7 +140,10 @@ export async function main({
140
140
  }
141
141
  case VCS_SUBCOMMANDS.CHECKOUT: {
142
142
  const branchName = parsed.positionals[0] || parsed.flags.branchName;
143
- await executeCheckoutCmd({ branchName });
143
+ await executeCheckoutCmd({
144
+ branchName,
145
+ force: parsed.flags.force,
146
+ });
144
147
  break;
145
148
  }
146
149
  case VCS_SUBCOMMANDS.MERGE: {
@@ -180,11 +183,11 @@ export async function main({
180
183
 
181
184
  return 0;
182
185
  } catch (error) {
183
- console.error(`Error: ${extractErrorMsg(error)} (E: 8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d)`);
186
+ console.error(`Error: ${extractErrorMsg(error)} (E: genuuid)`);
184
187
  return 1;
185
188
  } finally {
186
189
  if (logalot) {
187
- console.log(`${lc} complete. (I: 9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c)`);
190
+ console.log(`${lc} complete. (I: genuuid)`);
188
191
  }
189
192
  }
190
193
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module vcs-projection-helper
3
- *
3
+ *
4
4
  * CLI-specific filesystem projection helpers for reading and writing `.vcsgib/vcs_index_projection.json`.
5
5
  * Strictly housed in `apps/vcs-gib` CLI layer to maintain pure isolation from `core-gib`.
6
6
  */
@@ -31,7 +31,7 @@ export async function readVcsIndexProjectionFromDisk({
31
31
  const lc = `${lcFile}[${readVcsIndexProjectionFromDisk.name}]`;
32
32
  try {
33
33
  if (logalot) {
34
- console.log(`${lc} starting... (I: 7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b)`);
34
+ console.log(`${lc} starting... (I: genuuid)`);
35
35
  }
36
36
 
37
37
  if (!vcsPath) {
@@ -60,11 +60,11 @@ export async function readVcsIndexProjectionFromDisk({
60
60
  const indexIbGib = ibgibs?.at(0) as B2tFSIndexIbGib_V1;
61
61
  return indexIbGib;
62
62
  } catch (error) {
63
- console.error(`${lc} ${extractErrorMsg(error)} (E: 8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c)`);
63
+ console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
64
64
  throw error;
65
65
  } finally {
66
66
  if (logalot) {
67
- console.log(`${lc} complete. (I: 9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d)`);
67
+ console.log(`${lc} complete. (I: genuuid)`);
68
68
  }
69
69
  }
70
70
  }
@@ -82,7 +82,7 @@ export async function writeVcsIndexProjectionToDisk({
82
82
  const lc = `${lcFile}[${writeVcsIndexProjectionToDisk.name}]`;
83
83
  try {
84
84
  if (logalot) {
85
- console.log(`${lc} starting... (I: 3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b)`);
85
+ console.log(`${lc} starting... (I: 06da189dd09843652865d2c82e415826)`);
86
86
  }
87
87
 
88
88
  await fs.mkdir(vcsPath, { recursive: true });
@@ -93,7 +93,7 @@ export async function writeVcsIndexProjectionToDisk({
93
93
  _comment: 'STRICTLY READ-ONLY PROJECTION GENERATED FROM B2TFSINDEXIBGIB_V1 IN LOCALSPACE',
94
94
  indexAddr,
95
95
  spaceId: indexIbGib.data?.mySpaceId,
96
- activeBranch: indexIbGib.data?.activeBranch || 'main',
96
+ activeBranchName: indexIbGib.data?.activeBranchName || 'main',
97
97
  stagedCount: (indexIbGib.data?.staged_item || []).length,
98
98
  stagedPaths: indexIbGib.data?.stagedPaths || {},
99
99
  updatedAt: new Date().toISOString(),
@@ -102,11 +102,11 @@ export async function writeVcsIndexProjectionToDisk({
102
102
  const projFile = path.join(vcsPath, 'vcs_index_projection.json');
103
103
  await fs.writeFile(projFile, JSON.stringify(projectionObj, null, 2), 'utf8');
104
104
  } catch (error) {
105
- console.error(`${lc} ${extractErrorMsg(error)} (E: 4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c)`);
105
+ console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
106
106
  throw error;
107
107
  } finally {
108
108
  if (logalot) {
109
- console.log(`${lc} complete. (I: 5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d)`);
109
+ console.log(`${lc} complete. (I: genuuid)`);
110
110
  }
111
111
  }
112
112
  }