@ibgib/vcs-gib 0.0.41 → 0.0.46
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/cli/commands/cli-generate-comment-cmd.d.mts.map +1 -1
- package/dist/cli/commands/cli-generate-comment-cmd.mjs +17 -105
- package/dist/cli/commands/cli-generate-comment-cmd.mjs.map +1 -1
- package/dist/cli/commands/cli-init-cmd.d.mts.map +1 -1
- package/dist/cli/commands/cli-init-cmd.mjs +1 -1
- package/dist/cli/commands/cli-init-cmd.mjs.map +1 -1
- package/package.json +3 -3
- package/src/AUTO-GENERATED-version.mts +1 -1
- package/src/cli/commands/cli-generate-comment-cmd.mts +18 -113
- package/src/cli/commands/cli-init-cmd.mts +1 -2
- package/tsconfig.test.tsbuildinfo +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/cli/vcs-projection-helper.d.mts +0 -23
- package/dist/cli/vcs-projection-helper.d.mts.map +0 -1
- package/dist/cli/vcs-projection-helper.mjs +0 -91
- package/dist/cli/vcs-projection-helper.mjs.map +0 -1
- package/src/cli/vcs-projection-helper.mts +0 -112
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-generate-comment-cmd.d.mts","sourceRoot":"","sources":["../../../src/cli/commands/cli-generate-comment-cmd.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"cli-generate-comment-cmd.d.mts","sourceRoot":"","sources":["../../../src/cli/commands/cli-generate-comment-cmd.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,MAAM,WAAW,sBAAsB;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,wBAAwB;IACrC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,wBAAsB,yBAAyB,CAAC,EAC5C,SAAyB,EACzB,aAAyB,EACzB,KAAU,EACV,WAAqB,EACrB,KAAa,GAChB,GAAE,sBAA2B,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA8CjE"}
|
|
@@ -5,140 +5,52 @@
|
|
|
5
5
|
* Scans repository status or target paths and creates `.ib.<file>.md` or `.ib.<topic>.md` companion metadata files.
|
|
6
6
|
*/
|
|
7
7
|
import path from 'node:path';
|
|
8
|
-
import fs from 'node:fs/promises';
|
|
9
8
|
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
10
|
-
import {
|
|
9
|
+
import { openVcsRepository } from '../vcs-repo-helper.mjs';
|
|
11
10
|
import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
|
|
12
|
-
import { getRepoStatus } from '@ibgib/core-gib/dist/vcs/status/status-helper.mjs';
|
|
13
|
-
import { getB2tFSIndexIbGib } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
|
|
14
|
-
import { readVcsIndexProjectionFromDisk } from '../vcs-projection-helper.mjs';
|
|
15
11
|
const lcFile = `[generate-comment-cmd]`;
|
|
16
12
|
const logalot = GLOBAL_LOG_A_LOT;
|
|
17
13
|
export async function executeGenerateCommentCmd({ targetDir = process.cwd(), vcsFolderName = '.vcsgib', paths = [], folderTopic = 'notes', quiet = false, } = {}) {
|
|
18
14
|
const lc = `${lcFile}[${executeGenerateCommentCmd.name}]`;
|
|
19
15
|
try {
|
|
20
16
|
if (logalot) {
|
|
21
|
-
console.log(`${lc} starting... (I:
|
|
17
|
+
console.log(`${lc} starting... (I: 2e8b09f7a6344adca26e846174d81226)`);
|
|
22
18
|
}
|
|
23
19
|
const absTargetDir = path.resolve(targetDir);
|
|
24
|
-
const {
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
const { repo } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
|
|
21
|
+
const res = await repo.generateComment({
|
|
22
|
+
paths,
|
|
23
|
+
folderTopic,
|
|
24
|
+
targetDir: absTargetDir,
|
|
27
25
|
});
|
|
28
|
-
// Verify repo exists
|
|
29
|
-
try {
|
|
30
|
-
await fs.access(vcsPath);
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: genuuid)`);
|
|
34
|
-
}
|
|
35
|
-
const indexIbGib = (await getB2tFSIndexIbGib({ space: localSpace, metaspace }))
|
|
36
|
-
|| (await readVcsIndexProjectionFromDisk({ vcsPath, space: localSpace }));
|
|
37
|
-
const statusRes = await getRepoStatus({
|
|
38
|
-
metaspace,
|
|
39
|
-
localSpace,
|
|
40
|
-
indexIbGib,
|
|
41
|
-
vcsPath,
|
|
42
|
-
repoRoot,
|
|
43
|
-
vcsFolderName,
|
|
44
|
-
});
|
|
45
|
-
const activeWorktreeDir = statusRes.activeWorktreeDir;
|
|
46
|
-
const targetRelPaths = [];
|
|
47
|
-
if (paths.length > 0) {
|
|
48
|
-
for (const p of paths) {
|
|
49
|
-
const absP = path.resolve(activeWorktreeDir, p);
|
|
50
|
-
const relP = path.relative(activeWorktreeDir, absP).replace(/\\/g, '/');
|
|
51
|
-
if (relP && !targetRelPaths.includes(relP)) {
|
|
52
|
-
targetRelPaths.push(relP);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
// Auto-detect from staged and modified items
|
|
58
|
-
for (const s of statusRes.staged) {
|
|
59
|
-
if (!targetRelPaths.includes(s.path)) {
|
|
60
|
-
targetRelPaths.push(s.path);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
for (const m of statusRes.modified) {
|
|
64
|
-
if (!targetRelPaths.includes(m.path)) {
|
|
65
|
-
targetRelPaths.push(m.path);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
for (const u of statusRes.untracked) {
|
|
69
|
-
if (!targetRelPaths.includes(u.path)) {
|
|
70
|
-
targetRelPaths.push(u.path);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
const createdFiles = [];
|
|
75
|
-
const skippedFiles = [];
|
|
76
|
-
for (const relP of targetRelPaths) {
|
|
77
|
-
const absP = path.join(activeWorktreeDir, relP);
|
|
78
|
-
let isDirectory = false;
|
|
79
|
-
try {
|
|
80
|
-
const stat = await fs.stat(absP);
|
|
81
|
-
isDirectory = stat.isDirectory();
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
// If path doesn't exist yet on disk, guess based on extension
|
|
85
|
-
isDirectory = !path.extname(relP);
|
|
86
|
-
}
|
|
87
|
-
let commentFileName;
|
|
88
|
-
let commentDirPath;
|
|
89
|
-
if (isDirectory) {
|
|
90
|
-
commentDirPath = absP;
|
|
91
|
-
commentFileName = `.ib.${folderTopic}.md`;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
commentDirPath = path.dirname(absP);
|
|
95
|
-
const baseName = path.basename(absP);
|
|
96
|
-
commentFileName = `.ib.${baseName}.md`;
|
|
97
|
-
}
|
|
98
|
-
const commentFullPath = path.join(commentDirPath, commentFileName);
|
|
99
|
-
const commentRelPath = path.relative(activeWorktreeDir, commentFullPath).replace(/\\/g, '/');
|
|
100
|
-
try {
|
|
101
|
-
await fs.access(commentFullPath);
|
|
102
|
-
// Already exists
|
|
103
|
-
skippedFiles.push(commentRelPath);
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
// Does not exist -> create boilerplate template
|
|
107
|
-
const headerTarget = relP ? `\`${relP}\`` : 'root';
|
|
108
|
-
const boilerplate = `# ${headerTarget}\n\n(Enter contemporaneous notes/comments here)\n`;
|
|
109
|
-
await fs.mkdir(commentDirPath, { recursive: true });
|
|
110
|
-
await fs.writeFile(commentFullPath, boilerplate, 'utf8');
|
|
111
|
-
createdFiles.push(commentRelPath);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
26
|
if (!quiet) {
|
|
115
|
-
if (createdFiles.length > 0) {
|
|
116
|
-
console.log(`Generated ${createdFiles.length} comment file(s):`);
|
|
117
|
-
for (const f of createdFiles) {
|
|
27
|
+
if (res.createdFiles.length > 0) {
|
|
28
|
+
console.log(`Generated ${res.createdFiles.length} comment file(s):`);
|
|
29
|
+
for (const f of res.createdFiles) {
|
|
118
30
|
console.log(` created: ${f}`);
|
|
119
31
|
}
|
|
120
32
|
}
|
|
121
|
-
if (skippedFiles.length > 0) {
|
|
122
|
-
for (const f of skippedFiles) {
|
|
33
|
+
if (res.skippedFiles.length > 0) {
|
|
34
|
+
for (const f of res.skippedFiles) {
|
|
123
35
|
console.log(` already exists: ${f}`);
|
|
124
36
|
}
|
|
125
37
|
}
|
|
126
|
-
if (createdFiles.length === 0 && skippedFiles.length === 0) {
|
|
38
|
+
if (res.createdFiles.length === 0 && res.skippedFiles.length === 0) {
|
|
127
39
|
console.log(`No modified or staged files found to generate comments for.`);
|
|
128
40
|
}
|
|
129
41
|
}
|
|
130
42
|
return {
|
|
131
|
-
createdFiles,
|
|
132
|
-
skippedFiles,
|
|
43
|
+
createdFiles: res.createdFiles,
|
|
44
|
+
skippedFiles: res.skippedFiles,
|
|
133
45
|
};
|
|
134
46
|
}
|
|
135
47
|
catch (error) {
|
|
136
|
-
console.error(`${lc} ${extractErrorMsg(error)} (E:
|
|
48
|
+
console.error(`${lc} ${extractErrorMsg(error)} (E: d23e082728cb489e830e9d6d5a1b3c4f)`);
|
|
137
49
|
throw error;
|
|
138
50
|
}
|
|
139
51
|
finally {
|
|
140
52
|
if (logalot) {
|
|
141
|
-
console.log(`${lc} complete. (I:
|
|
53
|
+
console.log(`${lc} complete. (I: a3b71946358e469d80fc4ef2b281c726)`);
|
|
142
54
|
}
|
|
143
55
|
}
|
|
144
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-generate-comment-cmd.mjs","sourceRoot":"","sources":["../../../src/cli/commands/cli-generate-comment-cmd.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-generate-comment-cmd.mjs","sourceRoot":"","sources":["../../../src/cli/commands/cli-generate-comment-cmd.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,MAAM,MAAM,GAAG,wBAAwB,CAAC;AACxC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAejC,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,EAC5C,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,EACzB,aAAa,GAAG,SAAS,EACzB,KAAK,GAAG,EAAE,EACV,WAAW,GAAG,OAAO,EACrB,KAAK,GAAG,KAAK,GAChB,GAA2B,EAAE;IAC1B,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,yBAAyB,CAAC,IAAI,GAAG,CAAC;IAE1D,IAAI,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YACV,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,oDAAoD,CAAC,CAAC;QAC3E,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC7C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,iBAAiB,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC,CAAC;QAErF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC;YACnC,KAA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
-
{"version":3,"file":"cli-init-cmd.d.mts","sourceRoot":"","sources":["../../../src/cli/commands/cli-init-cmd.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"cli-init-cmd.d.mts","sourceRoot":"","sources":["../../../src/cli/commands/cli-init-cmd.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,MAAM,WAAW,WAAW;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,wBAAsB,cAAc,CAAC,EACjC,SAAyB,EACzB,aAAyB,EACzB,iBAA6C,EAC7C,KAAa,GAChB,GAAE,WAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,CAoD3C"}
|
|
@@ -8,9 +8,9 @@ import path from 'node:path';
|
|
|
8
8
|
import fs from 'node:fs/promises';
|
|
9
9
|
import { VcsRepository } from '@ibgib/core-gib/dist/vcs/vcs-repository.mjs';
|
|
10
10
|
import { B2TFS_BRANCH_DEFAULT_NAME } from '@ibgib/core-gib/dist/vcs/branch/branch-constants.mjs';
|
|
11
|
+
import { getB2tFSIndexIbGib } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
|
|
11
12
|
import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
|
|
12
13
|
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
13
|
-
import { getB2tFSIndexIbGib } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
|
|
14
14
|
const lcFile = `[init-cmd]`;
|
|
15
15
|
const logalot = GLOBAL_LOG_A_LOT;
|
|
16
16
|
export async function executeInitCmd({ targetDir = process.cwd(), vcsFolderName = '.vcsgib', defaultBranchName = B2TFS_BRANCH_DEFAULT_NAME, quiet = false, } = {}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-init-cmd.mjs","sourceRoot":"","sources":["../../../src/cli/commands/cli-init-cmd.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGlC,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,sDAAsD,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-init-cmd.mjs","sourceRoot":"","sources":["../../../src/cli/commands/cli-init-cmd.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGlC,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,sDAAsD,CAAC;AACjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AAErF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,MAAM,MAAM,GAAG,YAAY,CAAC;AAC5B,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAgBjC,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACjC,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,EACzB,aAAa,GAAG,SAAS,EACzB,iBAAiB,GAAG,yBAAyB,EAC7C,KAAK,GAAG,KAAK,GAChB,GAAgB,EAAE;IACf,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC7C,MAAM,OA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AAC;QACT,OAAO,CAAC,GAAG,CAAC,yCAAyC,OAAO,aAAa,iBAAiB,GAAG,CAAC,CAAC;IACnG,CAAC;IAED,OAAO;QACH,OAAO;QACP,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE;KAClC,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibgib/vcs-gib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@ibgib/helper-gib": "^0.0.39",
|
|
23
23
|
"@ibgib/ts-gib": "^0.5.36",
|
|
24
24
|
"@ibgib/encrypt-gib": "^0.3.3",
|
|
25
|
-
"@ibgib/core-gib": "^0.1.
|
|
26
|
-
"@ibgib/node-gib": "^0.0.
|
|
25
|
+
"@ibgib/core-gib": "^0.1.86",
|
|
26
|
+
"@ibgib/node-gib": "^0.0.32"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -6,14 +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 {
|
|
11
|
+
import { openVcsRepository } from '../vcs-repo-helper.mjs';
|
|
13
12
|
import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
|
|
14
|
-
import { getRepoStatus } from '@ibgib/core-gib/dist/vcs/status/status-helper.mjs';
|
|
15
|
-
import { getB2tFSIndexIbGib } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
|
|
16
|
-
import { readVcsIndexProjectionFromDisk } from '../vcs-projection-helper.mjs';
|
|
17
13
|
|
|
18
14
|
const lcFile = `[generate-comment-cmd]`;
|
|
19
15
|
const logalot = GLOBAL_LOG_A_LOT;
|
|
@@ -42,136 +38,45 @@ export async function executeGenerateCommentCmd({
|
|
|
42
38
|
|
|
43
39
|
try {
|
|
44
40
|
if (logalot) {
|
|
45
|
-
console.log(`${lc} starting... (I:
|
|
41
|
+
console.log(`${lc} starting... (I: 2e8b09f7a6344adca26e846174d81226)`);
|
|
46
42
|
}
|
|
47
43
|
|
|
48
44
|
const absTargetDir = path.resolve(targetDir);
|
|
45
|
+
const { repo } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
|
|
49
46
|
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
const res = await repo.generateComment({
|
|
48
|
+
paths,
|
|
49
|
+
folderTopic,
|
|
50
|
+
targetDir: absTargetDir,
|
|
53
51
|
});
|
|
54
52
|
|
|
55
|
-
// Verify repo exists
|
|
56
|
-
try {
|
|
57
|
-
await fs.access(vcsPath);
|
|
58
|
-
} catch {
|
|
59
|
-
throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: genuuid)`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const indexIbGib = (await getB2tFSIndexIbGib({ space: localSpace, metaspace }))
|
|
63
|
-
|| (await readVcsIndexProjectionFromDisk({ vcsPath, space: localSpace }));
|
|
64
|
-
|
|
65
|
-
const statusRes = await getRepoStatus({
|
|
66
|
-
metaspace,
|
|
67
|
-
localSpace,
|
|
68
|
-
indexIbGib,
|
|
69
|
-
vcsPath,
|
|
70
|
-
repoRoot,
|
|
71
|
-
vcsFolderName,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const activeWorktreeDir = statusRes.activeWorktreeDir;
|
|
75
|
-
const targetRelPaths: string[] = [];
|
|
76
|
-
|
|
77
|
-
if (paths.length > 0) {
|
|
78
|
-
for (const p of paths) {
|
|
79
|
-
const absP = path.resolve(activeWorktreeDir, p);
|
|
80
|
-
const relP = path.relative(activeWorktreeDir, absP).replace(/\\/g, '/');
|
|
81
|
-
if (relP && !targetRelPaths.includes(relP)) {
|
|
82
|
-
targetRelPaths.push(relP);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
// Auto-detect from staged and modified items
|
|
87
|
-
for (const s of statusRes.staged) {
|
|
88
|
-
if (!targetRelPaths.includes(s.path)) {
|
|
89
|
-
targetRelPaths.push(s.path);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
for (const m of statusRes.modified) {
|
|
93
|
-
if (!targetRelPaths.includes(m.path)) {
|
|
94
|
-
targetRelPaths.push(m.path);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
for (const u of statusRes.untracked) {
|
|
98
|
-
if (!targetRelPaths.includes(u.path)) {
|
|
99
|
-
targetRelPaths.push(u.path);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const createdFiles: string[] = [];
|
|
105
|
-
const skippedFiles: string[] = [];
|
|
106
|
-
|
|
107
|
-
for (const relP of targetRelPaths) {
|
|
108
|
-
const absP = path.join(activeWorktreeDir, relP);
|
|
109
|
-
|
|
110
|
-
let isDirectory = false;
|
|
111
|
-
try {
|
|
112
|
-
const stat = await fs.stat(absP);
|
|
113
|
-
isDirectory = stat.isDirectory();
|
|
114
|
-
} catch {
|
|
115
|
-
// If path doesn't exist yet on disk, guess based on extension
|
|
116
|
-
isDirectory = !path.extname(relP);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
let commentFileName: string;
|
|
120
|
-
let commentDirPath: string;
|
|
121
|
-
|
|
122
|
-
if (isDirectory) {
|
|
123
|
-
commentDirPath = absP;
|
|
124
|
-
commentFileName = `.ib.${folderTopic}.md`;
|
|
125
|
-
} else {
|
|
126
|
-
commentDirPath = path.dirname(absP);
|
|
127
|
-
const baseName = path.basename(absP);
|
|
128
|
-
commentFileName = `.ib.${baseName}.md`;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const commentFullPath = path.join(commentDirPath, commentFileName);
|
|
132
|
-
const commentRelPath = path.relative(activeWorktreeDir, commentFullPath).replace(/\\/g, '/');
|
|
133
|
-
|
|
134
|
-
try {
|
|
135
|
-
await fs.access(commentFullPath);
|
|
136
|
-
// Already exists
|
|
137
|
-
skippedFiles.push(commentRelPath);
|
|
138
|
-
} catch {
|
|
139
|
-
// Does not exist -> create boilerplate template
|
|
140
|
-
const headerTarget = relP ? `\`${relP}\`` : 'root';
|
|
141
|
-
const boilerplate = `# ${headerTarget}\n\n(Enter contemporaneous notes/comments here)\n`;
|
|
142
|
-
await fs.mkdir(commentDirPath, { recursive: true });
|
|
143
|
-
await fs.writeFile(commentFullPath, boilerplate, 'utf8');
|
|
144
|
-
createdFiles.push(commentRelPath);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
53
|
if (!quiet) {
|
|
149
|
-
if (createdFiles.length > 0) {
|
|
150
|
-
console.log(`Generated ${createdFiles.length} comment file(s):`);
|
|
151
|
-
for (const f of createdFiles) {
|
|
54
|
+
if (res.createdFiles.length > 0) {
|
|
55
|
+
console.log(`Generated ${res.createdFiles.length} comment file(s):`);
|
|
56
|
+
for (const f of res.createdFiles) {
|
|
152
57
|
console.log(` created: ${f}`);
|
|
153
58
|
}
|
|
154
59
|
}
|
|
155
|
-
if (skippedFiles.length > 0) {
|
|
156
|
-
for (const f of skippedFiles) {
|
|
60
|
+
if (res.skippedFiles.length > 0) {
|
|
61
|
+
for (const f of res.skippedFiles) {
|
|
157
62
|
console.log(` already exists: ${f}`);
|
|
158
63
|
}
|
|
159
64
|
}
|
|
160
|
-
if (createdFiles.length === 0 && skippedFiles.length === 0) {
|
|
65
|
+
if (res.createdFiles.length === 0 && res.skippedFiles.length === 0) {
|
|
161
66
|
console.log(`No modified or staged files found to generate comments for.`);
|
|
162
67
|
}
|
|
163
68
|
}
|
|
164
69
|
|
|
165
70
|
return {
|
|
166
|
-
createdFiles,
|
|
167
|
-
skippedFiles,
|
|
71
|
+
createdFiles: res.createdFiles,
|
|
72
|
+
skippedFiles: res.skippedFiles,
|
|
168
73
|
};
|
|
169
74
|
} catch (error) {
|
|
170
|
-
console.error(`${lc} ${extractErrorMsg(error)} (E:
|
|
75
|
+
console.error(`${lc} ${extractErrorMsg(error)} (E: d23e082728cb489e830e9d6d5a1b3c4f)`);
|
|
171
76
|
throw error;
|
|
172
77
|
} finally {
|
|
173
78
|
if (logalot) {
|
|
174
|
-
console.log(`${lc} complete. (I:
|
|
79
|
+
console.log(`${lc} complete. (I: a3b71946358e469d80fc4ef2b281c726)`);
|
|
175
80
|
}
|
|
176
81
|
}
|
|
177
|
-
}
|
|
82
|
+
}
|
|
@@ -11,11 +11,10 @@ import fs from 'node:fs/promises';
|
|
|
11
11
|
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
12
12
|
import { VcsRepository } from '@ibgib/core-gib/dist/vcs/vcs-repository.mjs';
|
|
13
13
|
import { B2TFS_BRANCH_DEFAULT_NAME } from '@ibgib/core-gib/dist/vcs/branch/branch-constants.mjs';
|
|
14
|
+
import { getB2tFSIndexIbGib } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
|
|
14
15
|
|
|
15
16
|
import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
|
|
16
17
|
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
17
|
-
import { getB2tFSIndexIbGib } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
|
|
18
|
-
import { writeVcsIndexProjectionToDisk } from '../vcs-projection-helper.mjs';
|
|
19
18
|
|
|
20
19
|
const lcFile = `[init-cmd]`;
|
|
21
20
|
const logalot = GLOBAL_LOG_A_LOT;
|