MCPcopy
hub / github.com/rpamis/comet / installCodegraph

Function installCodegraph

src/core/codegraph.ts:78–131  ·  view source on GitHub ↗
(
  projectPath: string,
  scope: InstallScope,
  shouldInstallCli = true,
)

Source from the content-addressed store, hash-verified

76}
77
78async function installCodegraph(
79 projectPath: string,
80 scope: InstallScope,
81 shouldInstallCli = true,
82): Promise<'installed' | 'failed' | 'skipped'> {
83 if (hasCodegraphProjectIndex(projectPath)) {
84 console.log(' CodeGraph: existing .codegraph index detected');
85 return 'skipped';
86 }
87
88 const codegraphCommand = await ensureCodegraphCli(projectPath, shouldInstallCli);
89 if (!codegraphCommand) {
90 if (!shouldInstallCli) {
91 console.log(' CodeGraph CLI not installed, skipping setup');
92 return 'skipped';
93 }
94 console.error(
95 ' CodeGraph CLI not available. Install manually: npm install -g @colbymchenry/codegraph',
96 );
97 return 'failed';
98 }
99
100 try {
101 console.log(' Running: codegraph install --yes');
102 execFileSync(codegraphCommand, ['install', '--yes'], {
103 cwd: projectPath,
104 stdio: 'inherit',
105 timeout: 120_000,
106 shell: process.platform === 'win32',
107 });
108 } catch (error) {
109 console.error(` CodeGraph install failed: ${(error as Error).message}`);
110 printCommandErrorDetails(error);
111 return 'failed';
112 }
113
114 if (scope === 'project') {
115 try {
116 console.log(' Running: codegraph init -i');
117 execFileSync(codegraphCommand, ['init', '-i'], {
118 cwd: projectPath,
119 stdio: 'inherit',
120 timeout: 300_000,
121 shell: process.platform === 'win32',
122 });
123 } catch (error) {
124 console.error(` CodeGraph init failed: ${(error as Error).message}`);
125 printCommandErrorDetails(error);
126 return 'failed';
127 }
128 }
129
130 return 'installed';
131}
132
133export { installCodegraph, hasCodegraphProjectIndex, resolveCodegraphCommand };

Callers 3

codegraph.test.tsFile · 0.85
updateCommandFunction · 0.85
initCommandFunction · 0.85

Calls 3

hasCodegraphProjectIndexFunction · 0.85
ensureCodegraphCliFunction · 0.85
printCommandErrorDetailsFunction · 0.85

Tested by

no test coverage detected