@ibgib/vcs-gib 0.0.32 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AUTO-GENERATED-version.d.mts +1 -1
- package/dist/AUTO-GENERATED-version.mjs +1 -1
- package/dist/bootstrap/node-bootstrap.d.mts.map +1 -1
- package/dist/bootstrap/node-bootstrap.mjs +6 -20
- package/dist/bootstrap/node-bootstrap.mjs.map +1 -1
- package/dist/cli/commands/{add-cmd.d.mts → cli-add-cmd.d.mts} +1 -1
- package/dist/cli/commands/cli-add-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-add-cmd.mjs +45 -0
- package/dist/cli/commands/cli-add-cmd.mjs.map +1 -0
- package/dist/cli/commands/{branch-cmd.d.mts → cli-branch-cmd.d.mts} +1 -1
- package/dist/cli/commands/cli-branch-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-branch-cmd.mjs +59 -0
- package/dist/cli/commands/cli-branch-cmd.mjs.map +1 -0
- package/dist/cli/commands/{checkout-cmd.d.mts → cli-checkout-cmd.d.mts} +4 -3
- package/dist/cli/commands/cli-checkout-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-checkout-cmd.mjs +50 -0
- package/dist/cli/commands/cli-checkout-cmd.mjs.map +1 -0
- package/dist/cli/commands/{commit-cmd.d.mts → cli-commit-cmd.d.mts} +1 -1
- package/dist/cli/commands/cli-commit-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-commit-cmd.mjs +52 -0
- package/dist/cli/commands/cli-commit-cmd.mjs.map +1 -0
- package/dist/cli/commands/{generate-comment-cmd.d.mts → cli-generate-comment-cmd.d.mts} +1 -1
- package/dist/cli/commands/cli-generate-comment-cmd.d.mts.map +1 -0
- package/dist/cli/commands/{generate-comment-cmd.mjs → cli-generate-comment-cmd.mjs} +8 -6
- package/dist/cli/commands/cli-generate-comment-cmd.mjs.map +1 -0
- package/dist/cli/commands/{init-cmd.d.mts → cli-init-cmd.d.mts} +1 -1
- package/dist/cli/commands/cli-init-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-init-cmd.mjs +47 -0
- package/dist/cli/commands/cli-init-cmd.mjs.map +1 -0
- package/dist/cli/commands/{log-cmd.d.mts → cli-log-cmd.d.mts} +1 -1
- package/dist/cli/commands/cli-log-cmd.d.mts.map +1 -0
- package/dist/cli/commands/{log-cmd.mjs → cli-log-cmd.mjs} +14 -44
- package/dist/cli/commands/cli-log-cmd.mjs.map +1 -0
- package/dist/cli/commands/{merge-cmd.d.mts → cli-merge-cmd.d.mts} +1 -1
- package/dist/cli/commands/cli-merge-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-merge-cmd.mjs +66 -0
- package/dist/cli/commands/cli-merge-cmd.mjs.map +1 -0
- package/dist/cli/commands/{reset-cmd.d.mts → cli-reset-cmd.d.mts} +1 -1
- package/dist/cli/commands/cli-reset-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-reset-cmd.mjs +63 -0
- package/dist/cli/commands/cli-reset-cmd.mjs.map +1 -0
- package/dist/cli/commands/{restore-cmd.d.mts → cli-restore-cmd.d.mts} +1 -1
- package/dist/cli/commands/cli-restore-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-restore-cmd.mjs +55 -0
- package/dist/cli/commands/cli-restore-cmd.mjs.map +1 -0
- package/dist/cli/commands/{status-cmd.d.mts → cli-status-cmd.d.mts} +1 -1
- package/dist/cli/commands/cli-status-cmd.d.mts.map +1 -0
- package/dist/cli/commands/{status-cmd.mjs → cli-status-cmd.mjs} +4 -41
- package/dist/cli/commands/cli-status-cmd.mjs.map +1 -0
- package/dist/cli/vcs-cli-main.d.mts.map +1 -1
- package/dist/cli/vcs-cli-main.mjs +18 -15
- package/dist/cli/vcs-cli-main.mjs.map +1 -1
- package/dist/cli/vcs-projection-helper.mjs +7 -7
- package/dist/cli/vcs-projection-helper.mjs.map +1 -1
- package/dist/cli/vcs-repo-helper.d.mts +19 -0
- package/dist/cli/vcs-repo-helper.d.mts.map +1 -0
- package/dist/cli/vcs-repo-helper.mjs +74 -0
- package/dist/cli/vcs-repo-helper.mjs.map +1 -0
- package/dist/test/test-helpers.d.mts +9 -0
- package/dist/test/test-helpers.d.mts.map +1 -1
- package/dist/test/test-helpers.mjs +35 -0
- package/dist/test/test-helpers.mjs.map +1 -1
- package/package.json +6 -6
- package/src/AUTO-GENERATED-version.mts +1 -1
- package/src/bootstrap/node-bootstrap.mts +6 -20
- package/src/bootstrap/node-bootstrap.respec.mts +2 -2
- package/src/cli/cli-arg-parser.respec.mts +2 -2
- package/src/cli/cli-e2e.respec.mts +8 -8
- package/src/cli/commands/branch-checkout-cmd.respec.mts +426 -412
- package/src/cli/commands/cli-add-cmd.mts +65 -0
- package/src/cli/commands/cli-branch-cmd.mts +87 -0
- package/src/cli/commands/cli-checkout-cmd.mts +72 -0
- package/src/cli/commands/cli-commit-cmd.mts +77 -0
- package/src/cli/commands/{generate-comment-cmd.mts → cli-generate-comment-cmd.mts} +8 -6
- package/src/cli/commands/cli-init-cmd.mts +78 -0
- package/src/cli/commands/{log-cmd.mts → cli-log-cmd.mts} +14 -47
- package/src/cli/commands/cli-merge-cmd.mts +99 -0
- package/src/cli/commands/cli-reset-cmd.mts +94 -0
- package/src/cli/commands/cli-restore-cmd.mts +87 -0
- package/src/cli/commands/{status-cmd.mts → cli-status-cmd.mts} +3 -45
- package/src/cli/commands/commit-log-cmd.respec.mts +82 -29
- package/src/cli/commands/init-cmd.respec.mts +3 -3
- package/src/cli/commands/reset-restore-cmd.respec.mts +9 -9
- package/src/cli/commands/status-add-cmd.respec.mts +20 -16
- package/src/cli/vcs-cli-main.mts +18 -15
- package/src/cli/vcs-projection-helper.mts +8 -8
- package/src/cli/vcs-repo-helper.mts +99 -0
- package/src/engine/branch/branch-space.respec.mts +22 -20
- package/src/engine/merge/b2tfs-sync-comments.respec.mts +10 -10
- package/src/test/test-helpers.mts +49 -1
- package/src/vcs-gib.respec.mts +21 -15
- package/tsconfig.test.tsbuildinfo +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/vcs-gib_test_output.md +58 -0
- package/dist/cli/commands/add-cmd.d.mts.map +0 -1
- package/dist/cli/commands/add-cmd.mjs +0 -93
- package/dist/cli/commands/add-cmd.mjs.map +0 -1
- package/dist/cli/commands/branch-cmd.d.mts.map +0 -1
- package/dist/cli/commands/branch-cmd.mjs +0 -107
- package/dist/cli/commands/branch-cmd.mjs.map +0 -1
- package/dist/cli/commands/checkout-cmd.d.mts.map +0 -1
- package/dist/cli/commands/checkout-cmd.mjs +0 -95
- package/dist/cli/commands/checkout-cmd.mjs.map +0 -1
- package/dist/cli/commands/commit-cmd.d.mts.map +0 -1
- package/dist/cli/commands/commit-cmd.mjs +0 -99
- package/dist/cli/commands/commit-cmd.mjs.map +0 -1
- package/dist/cli/commands/generate-comment-cmd.d.mts.map +0 -1
- package/dist/cli/commands/generate-comment-cmd.mjs.map +0 -1
- package/dist/cli/commands/init-cmd.d.mts.map +0 -1
- package/dist/cli/commands/init-cmd.mjs +0 -69
- package/dist/cli/commands/init-cmd.mjs.map +0 -1
- package/dist/cli/commands/log-cmd.d.mts.map +0 -1
- package/dist/cli/commands/log-cmd.mjs.map +0 -1
- package/dist/cli/commands/merge-cmd.d.mts.map +0 -1
- package/dist/cli/commands/merge-cmd.mjs +0 -106
- package/dist/cli/commands/merge-cmd.mjs.map +0 -1
- package/dist/cli/commands/reset-cmd.d.mts.map +0 -1
- package/dist/cli/commands/reset-cmd.mjs +0 -91
- package/dist/cli/commands/reset-cmd.mjs.map +0 -1
- package/dist/cli/commands/restore-cmd.d.mts.map +0 -1
- package/dist/cli/commands/restore-cmd.mjs +0 -97
- package/dist/cli/commands/restore-cmd.mjs.map +0 -1
- package/dist/cli/commands/status-cmd.d.mts.map +0 -1
- package/dist/cli/commands/status-cmd.mjs.map +0 -1
- package/src/cli/commands/add-cmd.mts +0 -120
- package/src/cli/commands/branch-cmd.mts +0 -142
- package/src/cli/commands/checkout-cmd.mts +0 -123
- package/src/cli/commands/commit-cmd.mts +0 -130
- package/src/cli/commands/init-cmd.mts +0 -99
- package/src/cli/commands/merge-cmd.mts +0 -143
- package/src/cli/commands/reset-cmd.mts +0 -126
- package/src/cli/commands/restore-cmd.mts +0 -135
|
@@ -1,135 +0,0 @@
|
|
|
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 { executeVcsRestore } from '@ibgib/core-gib/dist/vcs/commands/restore-cmd.mjs';
|
|
13
|
-
import { resolveContextualBranchName } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
|
|
14
|
-
|
|
15
|
-
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
16
|
-
import { getOrCreateBranchSpace } from '@ibgib/node-gib/dist/vcs/branch-space-helper.mjs';
|
|
17
|
-
import { getOrCreateWorkspaceProjectionSpace } from '@ibgib/node-gib/dist/vcs/workspace-space-helper.mjs';
|
|
18
|
-
import { readVcsIndexProjectionFromDisk, writeVcsIndexProjectionToDisk } from '../vcs-projection-helper.mjs';
|
|
19
|
-
import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
|
|
20
|
-
|
|
21
|
-
const lcFile = `[restore-cmd]`;
|
|
22
|
-
const logalot = GLOBAL_LOG_A_LOT;
|
|
23
|
-
|
|
24
|
-
export interface RestoreCmdOpts {
|
|
25
|
-
paths?: string[];
|
|
26
|
-
staged?: boolean;
|
|
27
|
-
worktree?: boolean;
|
|
28
|
-
all?: boolean;
|
|
29
|
-
yes?: boolean;
|
|
30
|
-
force?: boolean;
|
|
31
|
-
targetDir?: string;
|
|
32
|
-
vcsFolderName?: string;
|
|
33
|
-
quiet?: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface RestoreCmdResult {
|
|
37
|
-
restoredPaths: string[];
|
|
38
|
-
unstagedPaths: string[];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export async function executeRestoreCmd({
|
|
42
|
-
paths = [],
|
|
43
|
-
staged = false,
|
|
44
|
-
worktree = false,
|
|
45
|
-
all = false,
|
|
46
|
-
yes = false,
|
|
47
|
-
force = false,
|
|
48
|
-
targetDir = process.cwd(),
|
|
49
|
-
vcsFolderName = '.vcsgib',
|
|
50
|
-
quiet = false,
|
|
51
|
-
}: RestoreCmdOpts = {}): Promise<RestoreCmdResult> {
|
|
52
|
-
const lc = `${lcFile}[${executeRestoreCmd.name}]`;
|
|
53
|
-
try {
|
|
54
|
-
if (logalot) {
|
|
55
|
-
console.log(`${lc} starting... (I: 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d)`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const absTargetDir = path.resolve(targetDir);
|
|
59
|
-
|
|
60
|
-
const { metaspace, localSpace, vcsPath, repoRoot } = await bootstrapVcsMetaspace({
|
|
61
|
-
repoPath: absTargetDir,
|
|
62
|
-
vcsFolderName,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Verify repo exists
|
|
66
|
-
try {
|
|
67
|
-
await fs.access(vcsPath);
|
|
68
|
-
} catch {
|
|
69
|
-
throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: 2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d)`);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Retrieve authoritative B2tFSIndexIbGib_V1 from space
|
|
73
|
-
const indexIbGib = await readVcsIndexProjectionFromDisk({ vcsPath, space: localSpace });
|
|
74
|
-
if (!indexIbGib) {
|
|
75
|
-
throw new Error(`Repository not initialized. Run 'vcs init' first. (E: 3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d)`);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const activeBranch = resolveContextualBranchName({ targetDir: absTargetDir, repoRoot, indexIbGib });
|
|
79
|
-
const activeWorktreeDir = activeBranch === 'main' ? repoRoot : path.join(repoRoot, 'b', activeBranch);
|
|
80
|
-
|
|
81
|
-
const { space: activeBranchSpace } = await getOrCreateBranchSpace({
|
|
82
|
-
metaspace,
|
|
83
|
-
vcsPath,
|
|
84
|
-
branchName: activeBranch,
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const { space: workspaceSpace } = await getOrCreateWorkspaceProjectionSpace({
|
|
88
|
-
metaspace,
|
|
89
|
-
workspaceRoot: activeWorktreeDir,
|
|
90
|
-
vcsFolderName,
|
|
91
|
-
backingSpace: activeBranchSpace,
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const restoreRes = await executeVcsRestore({
|
|
95
|
-
metaspace,
|
|
96
|
-
localSpace,
|
|
97
|
-
activeBranchSpace,
|
|
98
|
-
workspaceSpace,
|
|
99
|
-
indexIbGib,
|
|
100
|
-
paths,
|
|
101
|
-
staged,
|
|
102
|
-
all,
|
|
103
|
-
targetDir: absTargetDir,
|
|
104
|
-
activeWorktreeDir,
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
if (staged && restoreRes.updatedIndex) {
|
|
108
|
-
await writeVcsIndexProjectionToDisk({ vcsPath, indexIbGib: restoreRes.updatedIndex });
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (!quiet) {
|
|
112
|
-
if (staged) {
|
|
113
|
-
for (const unstagedPath of restoreRes.unstagedPaths) {
|
|
114
|
-
console.log(`unstaged: ${unstagedPath}`);
|
|
115
|
-
}
|
|
116
|
-
} else {
|
|
117
|
-
for (const restoredPath of restoreRes.restoredPaths) {
|
|
118
|
-
console.log(`restored: ${restoredPath}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
restoredPaths: restoreRes.restoredPaths,
|
|
125
|
-
unstagedPaths: restoreRes.unstagedPaths,
|
|
126
|
-
};
|
|
127
|
-
} catch (error) {
|
|
128
|
-
console.error(`${lc} ${extractErrorMsg(error)} (E: 9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4e)`);
|
|
129
|
-
throw error;
|
|
130
|
-
} finally {
|
|
131
|
-
if (logalot) {
|
|
132
|
-
console.log(`${lc} complete. (I: 0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5f)`);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|