@ibgib/vcs-gib 0.0.39 → 0.0.45

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.
@@ -1,91 +0,0 @@
1
- /**
2
- * @module vcs-projection-helper
3
- *
4
- * CLI-specific filesystem projection helpers for reading and writing `.vcsgib/vcs_index_projection.json`.
5
- * Strictly housed in `apps/vcs-gib` CLI layer to maintain pure isolation from `core-gib`.
6
- */
7
- import path from 'node:path';
8
- import fs from 'node:fs/promises';
9
- import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
10
- import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
11
- import { getIbGibsFromCache_fallbackToSpaces } from '@ibgib/core-gib/dist/common/other/ibgib-helper.mjs';
12
- import { GLOBAL_LOG_A_LOT } from '../vcs-gib-constants.mjs';
13
- const lcFile = `[vcs-projection-helper]`;
14
- const logalot = GLOBAL_LOG_A_LOT;
15
- /**
16
- * Retrieves authoritative B2tFSIndexIbGib_V1 from space by reading the `.vcsgib/vcs_index_projection.json` pointer on disk.
17
- */
18
- export async function readVcsIndexProjectionFromDisk({ vcsPath, space, }) {
19
- const lc = `${lcFile}[${readVcsIndexProjectionFromDisk.name}]`;
20
- try {
21
- if (logalot) {
22
- console.log(`${lc} starting... (I: genuuid)`);
23
- }
24
- if (!vcsPath) {
25
- return undefined;
26
- }
27
- const projPath = path.join(vcsPath, 'vcs_index_projection.json');
28
- let indexAddr;
29
- try {
30
- const raw = await fs.readFile(projPath, 'utf8');
31
- const parsed = JSON.parse(raw);
32
- indexAddr = parsed.indexAddr;
33
- }
34
- catch {
35
- return undefined;
36
- }
37
- if (!indexAddr) {
38
- return undefined;
39
- }
40
- const ibgibs = await getIbGibsFromCache_fallbackToSpaces({
41
- addrs: [indexAddr],
42
- space,
43
- });
44
- const indexIbGib = ibgibs?.at(0);
45
- return indexIbGib;
46
- }
47
- catch (error) {
48
- console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
49
- throw error;
50
- }
51
- finally {
52
- if (logalot) {
53
- console.log(`${lc} complete. (I: genuuid)`);
54
- }
55
- }
56
- }
57
- /**
58
- * Writes read-only JSON projection cache of repository index to disk.
59
- */
60
- export async function writeVcsIndexProjectionToDisk({ vcsPath, indexIbGib, }) {
61
- const lc = `${lcFile}[${writeVcsIndexProjectionToDisk.name}]`;
62
- try {
63
- if (logalot) {
64
- console.log(`${lc} starting... (I: 06da189dd09843652865d2c82e415826)`);
65
- }
66
- await fs.mkdir(vcsPath, { recursive: true });
67
- const indexAddr = getIbGibAddr({ ibGib: indexIbGib });
68
- const projectionObj = {
69
- _isReadOnlyProjection: true,
70
- _comment: 'STRICTLY READ-ONLY PROJECTION GENERATED FROM B2TFSINDEXIBGIB_V1 IN LOCALSPACE',
71
- indexAddr,
72
- spaceId: indexIbGib.data?.mySpaceId,
73
- activeBranchName: indexIbGib.data?.activeBranchName || 'main',
74
- stagedCount: (indexIbGib.data?.staged_item || []).length,
75
- stagedPaths: indexIbGib.data?.stagedPaths || {},
76
- updatedAt: new Date().toISOString(),
77
- };
78
- const projFile = path.join(vcsPath, 'vcs_index_projection.json');
79
- await fs.writeFile(projFile, JSON.stringify(projectionObj, null, 2), 'utf8');
80
- }
81
- catch (error) {
82
- console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
83
- throw error;
84
- }
85
- finally {
86
- if (logalot) {
87
- console.log(`${lc} complete. (I: genuuid)`);
88
- }
89
- }
90
- }
91
- //# sourceMappingURL=vcs-projection-helper.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vcs-projection-helper.mjs","sourceRoot":"","sources":["../../src/cli/vcs-projection-helper.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,EAAE,YAAY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CAAC;QACjE,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACjF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,eAAe,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC9D,MAAM,KAAK,CAAC;IAChB,CAAC;YAAS,CAAC;QACP,IAAI,OAAO,EAAE,CAAC;YACV,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,yBAAyB,CAAC,CAAC;QAChD,CAAC;IACL,CAAC;AACL,CAAC"}
@@ -1,112 +0,0 @@
1
- /**
2
- * @module vcs-projection-helper
3
- *
4
- * CLI-specific filesystem projection helpers for reading and writing `.vcsgib/vcs_index_projection.json`.
5
- * Strictly housed in `apps/vcs-gib` CLI layer to maintain pure isolation from `core-gib`.
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 { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
13
- import { IbGibSpaceAny } from '@ibgib/core-gib/dist/witness/space/space-base-v1.mjs';
14
- import { getIbGibsFromCache_fallbackToSpaces } from '@ibgib/core-gib/dist/common/other/ibgib-helper.mjs';
15
- import { B2tFSIndexIbGib_V1 } from '@ibgib/core-gib/dist/vcs/index/index-types.mjs';
16
- import { GLOBAL_LOG_A_LOT } from '../vcs-gib-constants.mjs';
17
-
18
- const lcFile = `[vcs-projection-helper]`;
19
- const logalot = GLOBAL_LOG_A_LOT;
20
-
21
- /**
22
- * Retrieves authoritative B2tFSIndexIbGib_V1 from space by reading the `.vcsgib/vcs_index_projection.json` pointer on disk.
23
- */
24
- export async function readVcsIndexProjectionFromDisk({
25
- vcsPath,
26
- space,
27
- }: {
28
- vcsPath: string;
29
- space: IbGibSpaceAny;
30
- }): Promise<B2tFSIndexIbGib_V1 | undefined> {
31
- const lc = `${lcFile}[${readVcsIndexProjectionFromDisk.name}]`;
32
- try {
33
- if (logalot) {
34
- console.log(`${lc} starting... (I: genuuid)`);
35
- }
36
-
37
- if (!vcsPath) {
38
- return undefined;
39
- }
40
-
41
- const projPath = path.join(vcsPath, 'vcs_index_projection.json');
42
- let indexAddr: string | undefined;
43
- try {
44
- const raw = await fs.readFile(projPath, 'utf8');
45
- const parsed = JSON.parse(raw);
46
- indexAddr = parsed.indexAddr;
47
- } catch {
48
- return undefined;
49
- }
50
-
51
- if (!indexAddr) {
52
- return undefined;
53
- }
54
-
55
- const ibgibs = await getIbGibsFromCache_fallbackToSpaces({
56
- addrs: [indexAddr],
57
- space,
58
- });
59
-
60
- const indexIbGib = ibgibs?.at(0) as B2tFSIndexIbGib_V1;
61
- return indexIbGib;
62
- } catch (error) {
63
- console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
64
- throw error;
65
- } finally {
66
- if (logalot) {
67
- console.log(`${lc} complete. (I: genuuid)`);
68
- }
69
- }
70
- }
71
-
72
- /**
73
- * Writes read-only JSON projection cache of repository index to disk.
74
- */
75
- export async function writeVcsIndexProjectionToDisk({
76
- vcsPath,
77
- indexIbGib,
78
- }: {
79
- vcsPath: string;
80
- indexIbGib: B2tFSIndexIbGib_V1;
81
- }): Promise<void> {
82
- const lc = `${lcFile}[${writeVcsIndexProjectionToDisk.name}]`;
83
- try {
84
- if (logalot) {
85
- console.log(`${lc} starting... (I: 06da189dd09843652865d2c82e415826)`);
86
- }
87
-
88
- await fs.mkdir(vcsPath, { recursive: true });
89
-
90
- const indexAddr = getIbGibAddr({ ibGib: indexIbGib });
91
- const projectionObj = {
92
- _isReadOnlyProjection: true,
93
- _comment: 'STRICTLY READ-ONLY PROJECTION GENERATED FROM B2TFSINDEXIBGIB_V1 IN LOCALSPACE',
94
- indexAddr,
95
- spaceId: indexIbGib.data?.mySpaceId,
96
- activeBranchName: indexIbGib.data?.activeBranchName || 'main',
97
- stagedCount: (indexIbGib.data?.staged_item || []).length,
98
- stagedPaths: indexIbGib.data?.stagedPaths || {},
99
- updatedAt: new Date().toISOString(),
100
- };
101
-
102
- const projFile = path.join(vcsPath, 'vcs_index_projection.json');
103
- await fs.writeFile(projFile, JSON.stringify(projectionObj, null, 2), 'utf8');
104
- } catch (error) {
105
- console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
106
- throw error;
107
- } finally {
108
- if (logalot) {
109
- console.log(`${lc} complete. (I: genuuid)`);
110
- }
111
- }
112
- }