@ibgib/vcs-gib 0.0.47 → 0.0.51

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 (70) hide show
  1. package/README.md +1 -1
  2. package/VCS_CLI_USER_GUIDE.md +12 -7
  3. package/dist/AUTO-GENERATED-version.d.mts +1 -1
  4. package/dist/AUTO-GENERATED-version.mjs +1 -1
  5. package/dist/bootstrap/node-bootstrap.mjs +6 -6
  6. package/dist/bootstrap/node-bootstrap.mjs.map +1 -1
  7. package/dist/cli/cli-arg-parser.d.mts +2 -0
  8. package/dist/cli/cli-arg-parser.d.mts.map +1 -1
  9. package/dist/cli/cli-arg-parser.mjs +12 -1
  10. package/dist/cli/cli-arg-parser.mjs.map +1 -1
  11. package/dist/cli/cli-constants.d.mts +2 -0
  12. package/dist/cli/cli-constants.d.mts.map +1 -1
  13. package/dist/cli/cli-constants.mjs +15 -1
  14. package/dist/cli/cli-constants.mjs.map +1 -1
  15. package/dist/cli/commands/cli-add-cmd.mjs +3 -3
  16. package/dist/cli/commands/cli-add-cmd.mjs.map +1 -1
  17. package/dist/cli/commands/cli-branch-cmd.mjs +3 -3
  18. package/dist/cli/commands/cli-branch-cmd.mjs.map +1 -1
  19. package/dist/cli/commands/cli-commit-cmd.d.mts +2 -1
  20. package/dist/cli/commands/cli-commit-cmd.d.mts.map +1 -1
  21. package/dist/cli/commands/cli-commit-cmd.mjs +4 -3
  22. package/dist/cli/commands/cli-commit-cmd.mjs.map +1 -1
  23. package/dist/cli/commands/cli-init-cmd.mjs +6 -6
  24. package/dist/cli/commands/cli-init-cmd.mjs.map +1 -1
  25. package/dist/cli/commands/cli-log-cmd.d.mts.map +1 -1
  26. package/dist/cli/commands/cli-log-cmd.mjs +2 -18
  27. package/dist/cli/commands/cli-log-cmd.mjs.map +1 -1
  28. package/dist/cli/commands/cli-merge-cmd.mjs +3 -3
  29. package/dist/cli/commands/cli-merge-cmd.mjs.map +1 -1
  30. package/dist/cli/commands/cli-reset-cmd.d.mts +1 -1
  31. package/dist/cli/commands/cli-reset-cmd.mjs +9 -9
  32. package/dist/cli/commands/cli-reset-cmd.mjs.map +1 -1
  33. package/dist/cli/commands/cli-restore-cmd.mjs +3 -3
  34. package/dist/cli/commands/cli-restore-cmd.mjs.map +1 -1
  35. package/dist/cli/commands/cli-status-cmd.d.mts +1 -1
  36. package/dist/cli/commands/cli-status-cmd.d.mts.map +1 -1
  37. package/dist/cli/commands/cli-status-cmd.mjs +5 -2
  38. package/dist/cli/commands/cli-status-cmd.mjs.map +1 -1
  39. package/dist/cli/vcs-cli-main.d.mts.map +1 -1
  40. package/dist/cli/vcs-cli-main.mjs +6 -5
  41. package/dist/cli/vcs-cli-main.mjs.map +1 -1
  42. package/dist/cli/vcs-repo-helper.d.mts.map +1 -1
  43. package/dist/cli/vcs-repo-helper.mjs +7 -7
  44. package/dist/cli/vcs-repo-helper.mjs.map +1 -1
  45. package/package.json +6 -6
  46. package/src/AUTO-GENERATED-version.mts +1 -1
  47. package/src/bootstrap/node-bootstrap.mts +6 -6
  48. package/src/cli/cli-arg-parser.mts +14 -0
  49. package/src/cli/cli-constants.mts +19 -2
  50. package/src/cli/cli-e2e.respec.mts +7 -7
  51. package/src/cli/commands/cli-add-cmd.mts +3 -3
  52. package/src/cli/commands/cli-branch-cmd.mts +3 -3
  53. package/src/cli/commands/cli-commit-cmd.mts +5 -2
  54. package/src/cli/commands/cli-init-cmd.mts +6 -6
  55. package/src/cli/commands/cli-log-cmd.mts +2 -23
  56. package/src/cli/commands/cli-merge-cmd.mts +3 -3
  57. package/src/cli/commands/cli-reset-cmd.mts +9 -9
  58. package/src/cli/commands/cli-restore-cmd.mts +3 -3
  59. package/src/cli/commands/cli-status-cmd.mts +5 -2
  60. package/src/cli/commands/commit-log-cmd.respec.mts +11 -11
  61. package/src/cli/commands/delete-files.respec.mts +366 -0
  62. package/src/cli/commands/init-cmd.respec.mts +1 -1
  63. package/src/cli/commands/reset-restore-cmd.respec.mts +3 -3
  64. package/src/cli/commands/status-add-cmd.respec.mts +4 -4
  65. package/src/cli/vcs-cli-main.mts +6 -5
  66. package/src/cli/vcs-repo-helper.mts +7 -8
  67. package/src/vcs-gib.respec.mts +9 -9
  68. package/tsconfig.test.tsbuildinfo +1 -1
  69. package/tsconfig.tsbuildinfo +1 -1
  70. package/vcs-gib_test_output.md +18 -18
@@ -6,10 +6,8 @@
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 { getAllBranchInfosFromIndex } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
13
11
 
14
12
  import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
15
13
  import { openVcsRepository } from '../vcs-repo-helper.mjs';
@@ -61,30 +59,11 @@ export async function executeLogCmd({
61
59
 
62
60
  const absTargetDir = path.resolve(targetDir);
63
61
  const { repo } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
64
- const indexIbGib = await repo.getIndexIbGib();
65
-
66
- // let resolvedBranchName = branchName;
67
- // let resolvedFilePath = filePath;
68
-
69
- // if (!resolvedBranchName && resolvedFilePath) {
70
- // const branchInfos = await getAllBranchInfosFromIndex({ indexIbGib });
71
- // if (branchInfos.some(b => b.branchName === resolvedFilePath)) {
72
- // resolvedBranchName = resolvedFilePath;
73
- // resolvedFilePath = undefined;
74
- // }
75
- // }
76
-
77
- // const activeBranchSpace = await repo.getActiveBranchSpace({
78
- // indexIbGib,
79
- // targetDir: absTargetDir,
80
- // branchName: resolvedBranchName,
81
- // });
62
+ const galaxyIbGib = await repo.getGalaxyIbGib();
82
63
 
83
64
  const logRes = await repo.log({
84
- indexIbGib,
85
- // branchName: resolvedBranchName,
65
+ galaxyIbGib,
86
66
  branchName,
87
- // filePath: resolvedFilePath,
88
67
  filePath,
89
68
  allComments,
90
69
  targetDir: absTargetDir,
@@ -54,15 +54,15 @@ export async function executeMergeCmd({
54
54
  const { repo, vcsPath, activeWorktreeDir } =
55
55
  await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
56
56
 
57
- const indexIbGib = await repo.getIndexIbGib();
58
- const baseBranchName = await repo.getActiveBranchName({ indexIbGib, targetDir: absTargetDir });
57
+ const galaxyIbGib = await repo.getGalaxyIbGib();
58
+ const baseBranchName = await repo.getActiveBranchName({ galaxyIbGib, targetDir: absTargetDir });
59
59
 
60
60
  const incomingSpaceRes = await getOrCreateBranchSpace({
61
61
  metaspace: repo.metaspace,
62
62
  branchName: trimmedIncomingBranchName,
63
63
  });
64
64
 
65
- const activeBranchSpace = await repo.getActiveBranchSpace({ indexIbGib, targetDir: absTargetDir });
65
+ const activeBranchSpace = await repo.getActiveBranchSpace({ galaxyIbGib, targetDir: absTargetDir });
66
66
  const activeBranchSpaceId = getSpaceIdFromIb(activeBranchSpace.ib);
67
67
 
68
68
  const mergeRes = await repo.merge({
@@ -2,7 +2,7 @@
2
2
  * @module reset-cmd
3
3
  *
4
4
  * CLI command handler for `vcs reset [path...]`.
5
- * Unstages specified files (or all files) from active branch index in localSpace.
5
+ * Unstages specified files (or all files) from active branch galaxy in localSpace.
6
6
  */
7
7
 
8
8
  import path from 'node:path';
@@ -43,30 +43,30 @@ export async function executeResetCmd({
43
43
  const lc = `${lcFile}[${executeResetCmd.name}]`;
44
44
  try {
45
45
  if (logalot) {
46
- console.log(`${lc} starting... (I: genuuid)`);
46
+ console.log(`${lc} starting... (I: 1cd248c3453365b299a5de8aaa83cd26)`);
47
47
  }
48
48
 
49
49
  const absTargetDir = path.resolve(targetDir);
50
50
  const { repo, activeWorktreeDir } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
51
51
 
52
- const indexIbGib = await repo.getIndexIbGib();
53
- const activeBranchSpace = await repo.getActiveBranchSpace(indexIbGib);
52
+ const galaxyIbGib = await repo.getGalaxyIbGib();
53
+ const activeBranchSpace = await repo.getActiveBranchSpace(galaxyIbGib);
54
54
 
55
55
  const skipPrompt = yes || force || quiet || !process.stdin.isTTY;
56
56
  if (!skipPrompt) {
57
- const confirmed = await promptForConfirm({ msg: 'Unstage specified files from index?' });
57
+ const confirmed = await promptForConfirm({ msg: 'Unstage specified files from galaxy?' });
58
58
  if (!confirmed) {
59
59
  if (!quiet) {
60
60
  console.log('Operation cancelled.');
61
61
  }
62
- const stagedCount = Object.keys(indexIbGib.data.stagedPaths || {}).length;
62
+ const stagedCount = Object.keys(galaxyIbGib.data.stagedPaths || {}).length;
63
63
  return { unstagedPaths: [], stagedCount };
64
64
  }
65
65
  }
66
66
 
67
67
  const resetRes = await repo.reset({
68
68
  activeBranchSpace,
69
- indexIbGib,
69
+ galaxyIbGib,
70
70
  paths,
71
71
  all,
72
72
  targetDir: absTargetDir,
@@ -84,11 +84,11 @@ export async function executeResetCmd({
84
84
  stagedCount: resetRes.stagedCount,
85
85
  };
86
86
  } catch (error) {
87
- console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
87
+ console.error(`${lc} ${extractErrorMsg(error)} (E: baac0f845bb883f4555f2d482cfca826)`);
88
88
  throw error;
89
89
  } finally {
90
90
  if (logalot) {
91
- console.log(`${lc} complete. (I: genuuid)`);
91
+ console.log(`${lc} complete. (I: 6a21182695fd4b5e08ae518119929826)`);
92
92
  }
93
93
  }
94
94
  }
@@ -46,7 +46,7 @@ export async function executeRestoreCmd({
46
46
  const lc = `${lcFile}[${executeRestoreCmd.name}]`;
47
47
  try {
48
48
  if (logalot) {
49
- console.log(`${lc} starting... (I: genuuid)`);
49
+ console.log(`${lc} starting... (I: f2ec77129a713122ed9ee0ff8246d826)`);
50
50
  }
51
51
 
52
52
  const absTargetDir = path.resolve(targetDir);
@@ -77,11 +77,11 @@ export async function executeRestoreCmd({
77
77
  unstagedPaths: restoreRes.unstagedPaths,
78
78
  };
79
79
  } catch (error) {
80
- console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
80
+ console.error(`${lc} ${extractErrorMsg(error)} (E: 0b423fc29e538c25988e9ac8f3674726)`);
81
81
  throw error;
82
82
  } finally {
83
83
  if (logalot) {
84
- console.log(`${lc} complete. (I: genuuid)`);
84
+ console.log(`${lc} complete. (I: ba5d22e40298355f44077da8823da826)`);
85
85
  }
86
86
  }
87
87
  }
@@ -2,7 +2,7 @@
2
2
  * @module status-cmd
3
3
  *
4
4
  * CLI command handler for `vcs status`.
5
- * Compares physical workspace state against active branch snapshot tip and in-band index staging area.
5
+ * Compares physical workspace state against active branch snapshot tip and in-band galaxy staging area.
6
6
  */
7
7
 
8
8
  import path from 'node:path';
@@ -73,7 +73,10 @@ export async function executeStatusCmd({
73
73
  console.log(' (use "vcs reset <file>..." to unstage)');
74
74
  for (const item of staged) {
75
75
  const typePrefix = item.fsType === 'folder' ? 'directory: ' : '';
76
- console.log(`\tnew file: ${typePrefix}${item.path}`);
76
+ const label = item.stagedType === 'deleted'
77
+ ? 'deleted: '
78
+ : (item.stagedType === 'modified' ? 'modified: ' : 'new file: ');
79
+ console.log(`\t${label}${typePrefix}${item.path}`);
77
80
  }
78
81
  }
79
82
 
@@ -14,7 +14,7 @@ import {
14
14
  import { extractErrorMsg, pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
15
15
  import { getDependencyGraph } from '@ibgib/core-gib/dist/common/other/graph-helper.mjs';
16
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';
17
+ import { getB2tFSGalaxyIbGib, } from '@ibgib/core-gib/dist/vcs/galaxy/galaxy-helper.mjs';
18
18
  import { getOrCreateBranchSpace, parseBranchIb } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
19
19
  import { B2tFSBranchIbGib_V1 } from '@ibgib/core-gib/dist/vcs/branch/branch-types.mjs';
20
20
  import { B2tFSItemIbGib_V1 } from '@ibgib/core-gib/dist/vcs/item/item-types.mjs';
@@ -123,9 +123,9 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
123
123
  repoPath: testDir,
124
124
  vcsFolderName,
125
125
  });
126
- const indexAdd = await getB2tFSIndexIbGib({ space: spaceAdd, metaspace: metaspaceAdd });
127
- iReckon(lc, Boolean(indexAdd?.data?.staged_item && indexAdd.data.staged_item.length > 0)).isGonnaBeTrue();
128
- iReckon(lc, indexAdd?.rel8ns?.staged_item).isGonnaBeFalsy();
126
+ const galaxyAdd = await getB2tFSGalaxyIbGib({ space: spaceAdd, metaspace: metaspaceAdd });
127
+ iReckon(lc, Boolean(galaxyAdd?.data?.staged_item && galaxyAdd.data.staged_item.length > 0)).isGonnaBeTrue();
128
+ iReckon(lc, galaxyAdd?.rel8ns?.staged_item).isGonnaBeFalsy();
129
129
 
130
130
  const commitRes = await executeCommitCmd({
131
131
  message: 'Initial repository commit',
@@ -138,9 +138,9 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
138
138
  repoPath: testDir,
139
139
  vcsFolderName,
140
140
  });
141
- const indexCommit = await getB2tFSIndexIbGib({ space: spaceCommit, metaspace: metaspaceCommit });
142
- iReckon(lc, indexCommit?.data?.staged_item).willEqual([]);
143
- iReckon(lc, indexCommit?.rel8ns?.staged_item).isGonnaBeFalsy();
141
+ const galaxyCommit = await getB2tFSGalaxyIbGib({ space: spaceCommit, metaspace: metaspaceCommit });
142
+ iReckon(lc, galaxyCommit?.data?.staged_item).willEqual([]);
143
+ iReckon(lc, galaxyCommit?.rel8ns?.staged_item).isGonnaBeFalsy();
144
144
 
145
145
  iReckon(lc, commitRes.branchName).willEqual('main');
146
146
  iReckon(lc, commitRes.committedPaths).includes('hello.txt');
@@ -466,11 +466,11 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
466
466
  metaspace,
467
467
  branchName: 'main',
468
468
  });
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'] ?? [];
469
+ const galaxyIbGib = await getB2tFSGalaxyIbGib({ space: localSpace, metaspace });
470
+ if (!galaxyIbGib) { throw new Error(`(UNEXPECTED) galaxyIbGib falsy? (E: d4ec1b6f86cbf18808fba957b7b83826)`); }
471
+ const branchAddrs_spacequalified = galaxyIbGib.data['$@branch'] ?? [];
472
472
  if (branchAddrs_spacequalified.length === 0) {
473
- throw new Error(`(UNEXPECTED) indexIbGib doesn't have any branch addrs in data? (E: 7069280124b81c6d1806fc580c704826)`);
473
+ throw new Error(`(UNEXPECTED) galaxyIbGib doesn't have any branch addrs in data? (E: 7069280124b81c6d1806fc580c704826)`);
474
474
  }
475
475
  const branchAddrs_spacequalified_main = branchAddrs_spacequalified
476
476
  .filter(x => {
@@ -0,0 +1,366 @@
1
+ /**
2
+ * @module delete-files.respec
3
+ *
4
+ * Unit tests for VCS file and folder deletion workflows:
5
+ * - vcs add <deleted-file>
6
+ * - vcs add -a (auto-staging missing files as deleted)
7
+ * - vcs status (rendering staged & unstaged deletions)
8
+ * - vcs commit (Merkle DAG negative-space pruning)
9
+ * - vcs commit --keep-empty-folders vs --rm-empty-folders
10
+ * - vcs restore <deleted-file> (recovering deleted file to worktree)
11
+ * - vcs reset <deleted-file> (unstaging deletion)
12
+ */
13
+
14
+ import path from 'node:path';
15
+ import fs from 'node:fs/promises';
16
+
17
+ import {
18
+ respecfully, ifWe, iReckon, ifWeMight,
19
+ } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
20
+
21
+ import { executeInitCmd } from './cli-init-cmd.mjs';
22
+ import { executeAddCmd } from './cli-add-cmd.mjs';
23
+ import { executeCommitCmd } from './cli-commit-cmd.mjs';
24
+ import { executeStatusCmd } from './cli-status-cmd.mjs';
25
+ import { executeResetCmd } from './cli-reset-cmd.mjs';
26
+ import { executeRestoreCmd } from './cli-restore-cmd.mjs';
27
+
28
+ const lc = `[apps/vcs-gib/src/cli/commands/delete-files.respec.mts]`;
29
+
30
+ await respecfully(lc, `VCS Deletions Lifecycle Command Handlers`, async () => {
31
+
32
+ await ifWe(lc, `vcs add <deleted-file> stages deletion, and vcs commit prunes it from Merkle tree`, async () => {
33
+ const testDir = path.join(process.cwd(), '.test_delete_single');
34
+ const vcsFolderName = '.vcsgib_test_delete_single';
35
+ try {
36
+ await executeInitCmd({
37
+ targetDir: testDir,
38
+ vcsFolderName,
39
+ quiet: true,
40
+ });
41
+
42
+ await fs.writeFile(path.join(testDir, 'file1.txt'), 'Content 1', 'utf8');
43
+
44
+ await executeAddCmd({
45
+ paths: ['file1.txt'],
46
+ targetDir: testDir,
47
+ vcsFolderName,
48
+ quiet: true,
49
+ });
50
+
51
+ await executeCommitCmd({
52
+ message: 'Add file1.txt',
53
+ targetDir: testDir,
54
+ vcsFolderName,
55
+ quiet: true,
56
+ });
57
+
58
+ // Delete file on disk
59
+ await fs.unlink(path.join(testDir, 'file1.txt'));
60
+
61
+ // Status shows unstaged deletion
62
+ let statusRes = await executeStatusCmd({
63
+ targetDir: testDir,
64
+ vcsFolderName,
65
+ quiet: true,
66
+ });
67
+ iReckon(lc, statusRes.deleted.map(x => x.path)).includes('file1.txt');
68
+
69
+ // Stage deletion via vcs add <path>
70
+ const addRes = await executeAddCmd({
71
+ paths: ['file1.txt'],
72
+ targetDir: testDir,
73
+ vcsFolderName,
74
+ quiet: true,
75
+ });
76
+ iReckon(lc, addRes.stagedPaths).includes('file1.txt');
77
+
78
+ // Status shows staged deletion
79
+ statusRes = await executeStatusCmd({
80
+ targetDir: testDir,
81
+ vcsFolderName,
82
+ quiet: true,
83
+ });
84
+ iReckon(lc, statusRes.staged.map(x => x.path)).includes('file1.txt');
85
+ const stagedItem = statusRes.staged.find(x => x.path === 'file1.txt');
86
+ iReckon(lc, stagedItem?.stagedType).willEqual('deleted');
87
+
88
+ // Commit deletion
89
+ const commitRes = await executeCommitCmd({
90
+ message: 'Delete file1.txt',
91
+ targetDir: testDir,
92
+ vcsFolderName,
93
+ quiet: true,
94
+ });
95
+ iReckon(lc, commitRes.committedPaths).includes('file1.txt');
96
+
97
+ // Status is clean after commit
98
+ statusRes = await executeStatusCmd({
99
+ targetDir: testDir,
100
+ vcsFolderName,
101
+ quiet: true,
102
+ });
103
+ iReckon(lc, statusRes.staged.length).willEqual(0);
104
+ iReckon(lc, statusRes.deleted.length).willEqual(0);
105
+ iReckon(lc, statusRes.modified.length).willEqual(0);
106
+ } finally {
107
+ await fs.rm(testDir, { recursive: true, force: true });
108
+ }
109
+ });
110
+
111
+ await ifWe(lc, `vcs add -a stages multiple deleted files and folder pruning occurs on commit`, async () => {
112
+ const testDir = path.join(process.cwd(), '.test_delete_all');
113
+ const vcsFolderName = '.vcsgib_test_delete_all';
114
+ try {
115
+ await executeInitCmd({
116
+ targetDir: testDir,
117
+ vcsFolderName,
118
+ quiet: true,
119
+ });
120
+
121
+ await fs.mkdir(path.join(testDir, 'src', 'utils'), { recursive: true });
122
+ await fs.writeFile(path.join(testDir, 'src', 'utils', 'math.ts'), 'export const pi = 3.14;', 'utf8');
123
+ await fs.writeFile(path.join(testDir, 'src', 'index.ts'), 'export * from "./utils/math.js";', 'utf8');
124
+ await fs.writeFile(path.join(testDir, 'readme.md'), '# Test Project', 'utf8');
125
+
126
+ await executeAddCmd({
127
+ all: true,
128
+ targetDir: testDir,
129
+ vcsFolderName,
130
+ quiet: true,
131
+ });
132
+
133
+ await executeCommitCmd({
134
+ message: 'Initial project files',
135
+ targetDir: testDir,
136
+ vcsFolderName,
137
+ quiet: true,
138
+ });
139
+
140
+ // Delete math.ts
141
+ await fs.unlink(path.join(testDir, 'src', 'utils', 'math.ts'));
142
+
143
+ // vcs add -a auto-stages the deleted file
144
+ const addRes = await executeAddCmd({
145
+ all: true,
146
+ targetDir: testDir,
147
+ vcsFolderName,
148
+ quiet: true,
149
+ });
150
+ iReckon(lc, addRes.stagedPaths).includes('src/utils/math.ts');
151
+
152
+ // Status shows staged deletion
153
+ let statusRes = await executeStatusCmd({
154
+ targetDir: testDir,
155
+ vcsFolderName,
156
+ quiet: true,
157
+ });
158
+ iReckon(lc, statusRes.staged.map(x => x.path)).includes('src/utils/math.ts');
159
+
160
+ // Commit with default pruning (--rm-empty-folders)
161
+ const commitRes = await executeCommitCmd({
162
+ message: 'Remove math utility',
163
+ targetDir: testDir,
164
+ vcsFolderName,
165
+ quiet: true,
166
+ });
167
+ iReckon(lc, commitRes.committedPaths).includes('src/utils/math.ts');
168
+
169
+ statusRes = await executeStatusCmd({
170
+ targetDir: testDir,
171
+ vcsFolderName,
172
+ quiet: true,
173
+ });
174
+ iReckon(lc, statusRes.staged.length).willEqual(0);
175
+ iReckon(lc, statusRes.deleted.length).willEqual(0);
176
+ } finally {
177
+ await fs.rm(testDir, { recursive: true, force: true });
178
+ }
179
+ });
180
+
181
+ await ifWe(lc, `vcs commit with keepEmptyFolders retains empty folder node in tree`, async () => {
182
+ const testDir = path.join(process.cwd(), '.test_delete_keep_empty');
183
+ const vcsFolderName = '.vcsgib_test_delete_keep_empty';
184
+ try {
185
+ await executeInitCmd({
186
+ targetDir: testDir,
187
+ vcsFolderName,
188
+ quiet: true,
189
+ });
190
+
191
+ await fs.mkdir(path.join(testDir, 'emptyDir'), { recursive: true });
192
+ await fs.writeFile(path.join(testDir, 'emptyDir', 'temp.txt'), 'temporary', 'utf8');
193
+
194
+ await executeAddCmd({
195
+ all: true,
196
+ targetDir: testDir,
197
+ vcsFolderName,
198
+ quiet: true,
199
+ });
200
+
201
+ await executeCommitCmd({
202
+ message: 'Initial with temp.txt',
203
+ targetDir: testDir,
204
+ vcsFolderName,
205
+ quiet: true,
206
+ });
207
+
208
+ // Delete temp.txt
209
+ await fs.unlink(path.join(testDir, 'emptyDir', 'temp.txt'));
210
+
211
+ await executeAddCmd({
212
+ paths: ['emptyDir/temp.txt'],
213
+ targetDir: testDir,
214
+ vcsFolderName,
215
+ quiet: true,
216
+ });
217
+
218
+ // Commit with keepEmptyFolders: true
219
+ const commitRes = await executeCommitCmd({
220
+ message: 'Delete temp keeping empty dir',
221
+ targetDir: testDir,
222
+ vcsFolderName,
223
+ quiet: true,
224
+ keepEmptyFolders: true,
225
+ });
226
+ iReckon(lc, commitRes.committedPaths).includes('emptyDir/temp.txt');
227
+
228
+ const statusRes = await executeStatusCmd({
229
+ targetDir: testDir,
230
+ vcsFolderName,
231
+ quiet: true,
232
+ });
233
+ iReckon(lc, statusRes.staged.length).willEqual(0);
234
+ } finally {
235
+ await fs.rm(testDir, { recursive: true, force: true });
236
+ }
237
+ });
238
+
239
+ await ifWe(lc, `vcs restore <file> restores deleted file from committed snapshot to disk`, async () => {
240
+ const testDir = path.join(process.cwd(), '.test_restore_deleted');
241
+ const vcsFolderName = '.vcsgib_test_restore_deleted';
242
+ try {
243
+ await executeInitCmd({
244
+ targetDir: testDir,
245
+ vcsFolderName,
246
+ quiet: true,
247
+ });
248
+
249
+ await fs.mkdir(path.join(testDir, 'assets', 'css'), { recursive: true });
250
+ await fs.writeFile(path.join(testDir, 'assets', 'css', 'style.css'), 'body { margin: 0; }', 'utf8');
251
+
252
+ await executeAddCmd({
253
+ all: true,
254
+ targetDir: testDir,
255
+ vcsFolderName,
256
+ quiet: true,
257
+ });
258
+
259
+ await executeCommitCmd({
260
+ message: 'Add stylesheet',
261
+ targetDir: testDir,
262
+ vcsFolderName,
263
+ quiet: true,
264
+ });
265
+
266
+ // Delete style.css from disk
267
+ await fs.unlink(path.join(testDir, 'assets', 'css', 'style.css'));
268
+
269
+ let statusRes = await executeStatusCmd({
270
+ targetDir: testDir,
271
+ vcsFolderName,
272
+ quiet: true,
273
+ });
274
+ iReckon(lc, statusRes.deleted.map(x => x.path)).includes('assets/css/style.css');
275
+
276
+ // Restore deleted file from committed snapshot
277
+ const restoreRes = await executeRestoreCmd({
278
+ paths: ['assets/css/style.css'],
279
+ targetDir: testDir,
280
+ vcsFolderName,
281
+ quiet: true,
282
+ });
283
+ iReckon(lc, restoreRes.restoredPaths).includes('assets/css/style.css');
284
+
285
+ // Verify file is back on disk at correct nested path with correct content
286
+ const restoredContent = await fs.readFile(path.join(testDir, 'assets', 'css', 'style.css'), 'utf8');
287
+ iReckon(lc, restoredContent).willEqual('body { margin: 0; }');
288
+
289
+ statusRes = await executeStatusCmd({
290
+ targetDir: testDir,
291
+ vcsFolderName,
292
+ quiet: true,
293
+ });
294
+ iReckon(lc, statusRes.deleted.length).willEqual(0);
295
+ } finally {
296
+ await fs.rm(testDir, { recursive: true, force: true });
297
+ }
298
+ });
299
+
300
+ await ifWe(lc, `vcs reset <file> unstages a staged deletion`, async () => {
301
+ const testDir = path.join(process.cwd(), '.test_reset_deletion');
302
+ const vcsFolderName = '.vcsgib_test_reset_deletion';
303
+ try {
304
+ await executeInitCmd({
305
+ targetDir: testDir,
306
+ vcsFolderName,
307
+ quiet: true,
308
+ });
309
+
310
+ await fs.writeFile(path.join(testDir, 'important.txt'), 'Important data', 'utf8');
311
+
312
+ await executeAddCmd({
313
+ paths: ['important.txt'],
314
+ targetDir: testDir,
315
+ vcsFolderName,
316
+ quiet: true,
317
+ });
318
+
319
+ await executeCommitCmd({
320
+ message: 'Add important file',
321
+ targetDir: testDir,
322
+ vcsFolderName,
323
+ quiet: true,
324
+ });
325
+
326
+ // Delete from disk
327
+ await fs.unlink(path.join(testDir, 'important.txt'));
328
+
329
+ // Stage deletion
330
+ await executeAddCmd({
331
+ paths: ['important.txt'],
332
+ targetDir: testDir,
333
+ vcsFolderName,
334
+ quiet: true,
335
+ });
336
+
337
+ let statusRes = await executeStatusCmd({
338
+ targetDir: testDir,
339
+ vcsFolderName,
340
+ quiet: true,
341
+ });
342
+ iReckon(lc, statusRes.staged.map(x => x.path)).includes('important.txt');
343
+
344
+ // Reset (unstage) deletion
345
+ const resetRes = await executeResetCmd({
346
+ paths: ['important.txt'],
347
+ targetDir: testDir,
348
+ vcsFolderName,
349
+ quiet: true,
350
+ });
351
+ iReckon(lc, resetRes.unstagedPaths).includes('important.txt');
352
+
353
+ statusRes = await executeStatusCmd({
354
+ targetDir: testDir,
355
+ vcsFolderName,
356
+ quiet: true,
357
+ });
358
+ // Should no longer be staged, but still unstaged deleted
359
+ iReckon(lc, statusRes.staged.length).willEqual(0);
360
+ iReckon(lc, statusRes.deleted.map(x => x.path)).includes('important.txt');
361
+ } finally {
362
+ await fs.rm(testDir, { recursive: true, force: true });
363
+ }
364
+ });
365
+
366
+ });
@@ -18,7 +18,7 @@ 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
 
21
- await ifWe(lc, `initializes repository space, branch, and index in target folder`, async () => {
21
+ await ifWe(lc, `initializes repository space, branch, and galaxy in target folder`, async () => {
22
22
  const testDir = path.join(process.cwd(), '.test_init_repo');
23
23
  const vcsFolderName = '.vcsgib_init_test';
24
24
  try {
@@ -22,7 +22,7 @@ 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
 
25
- await ifWe(lc, `vcs reset clears staged file from index while keeping disk file edits intact`, async () => {
25
+ await ifWe(lc, `vcs reset clears staged file from galaxy while keeping disk file edits intact`, async () => {
26
26
  const testDir = path.join(process.cwd(), '.test_reset_1');
27
27
  const vcsFolderName = '.vcsgib_test_reset_1';
28
28
  try {
@@ -79,7 +79,7 @@ await respecfully(lc, `vcs reset and vcs restore Command Handlers`, async () =>
79
79
  }
80
80
  });
81
81
 
82
- await ifWe(lc, `vcs restore --staged unstages file from index while keeping disk edits intact`, async () => {
82
+ await ifWe(lc, `vcs restore --staged unstages file from galaxy while keeping disk edits intact`, async () => {
83
83
  const testDir = path.join(process.cwd(), '.test_restore_staged');
84
84
  const vcsFolderName = '.vcsgib_test_restore_staged';
85
85
  try {
@@ -172,7 +172,7 @@ await respecfully(lc, `vcs reset and vcs restore Command Handlers`, async () =>
172
172
  }
173
173
  });
174
174
 
175
- await ifWe(lc, `vcs reset --all unstages all files from index`, async () => {
175
+ await ifWe(lc, `vcs reset --all unstages all files from galaxy`, async () => {
176
176
  const testDir = path.join(process.cwd(), '.test_reset_all');
177
177
  const vcsFolderName = '.vcsgib_test_reset_all';
178
178
  try {
@@ -12,7 +12,7 @@ import {
12
12
  } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
13
13
 
14
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';
15
+ import { getB2tFSGalaxyIbGib } from '@ibgib/core-gib/dist/vcs/galaxy/galaxy-helper.mjs';
16
16
 
17
17
  import { executeInitCmd } from './cli-init-cmd.mjs';
18
18
  import { executeStatusCmd } from './cli-status-cmd.mjs';
@@ -144,9 +144,9 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
144
144
  repoPath: testDir,
145
145
  vcsFolderName,
146
146
  });
147
- const indexIbGib = await getB2tFSIndexIbGib({ space: localSpace, metaspace });
148
- iReckon(lc, Boolean(indexIbGib?.data?.staged_item && indexIbGib.data.staged_item.length > 0)).isGonnaBeTrue();
149
- iReckon(lc, indexIbGib?.rel8ns?.staged_item).isGonnaBeFalsy();
147
+ const galaxyIbGib = await getB2tFSGalaxyIbGib({ space: localSpace, metaspace });
148
+ iReckon(lc, Boolean(galaxyIbGib?.data?.staged_item && galaxyIbGib.data.staged_item.length > 0)).isGonnaBeTrue();
149
+ iReckon(lc, galaxyIbGib?.rel8ns?.staged_item).isGonnaBeFalsy();
150
150
 
151
151
  const statusRes = await executeStatusCmd({
152
152
  targetDir: testDir,