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

Function updateCommand

src/commands/update.ts:229–426  ·  view source on GitHub ↗
(
  targetPath: string,
  options: UpdateOptions = {},
)

Source from the content-addressed store, hash-verified

227}
228
229export async function updateCommand(
230 targetPath: string,
231 options: UpdateOptions = {},
232): Promise<void> {
233 const projectPath = path.resolve(targetPath);
234 const log = options.json ? () => undefined : console.log;
235
236 const lang = options.language ?? 'en';
237
238 log(`\n ${t(lang, 'updateTitle')}`);
239 if (!options.json) {
240 await printVersionInfo(log);
241 }
242 log('');
243
244 const packageScope = options.scope ?? (await detectCometPackageScope(projectPath));
245 let npmStatus: 'updated' | 'failed' | 'skipped' = 'skipped';
246 if (!options.skipNpm) {
247 log(` ${t(lang, 'updatingNpmPackage')} (${packageScope} scope)...`);
248 log(` $ ${formatNpmUpdateCommand(packageScope)}`);
249 const npmUpdated = await updateCometNpmPackage(
250 packageScope,
251 projectPath,
252 log,
253 options.json === true,
254 );
255 if (npmUpdated) {
256 npmStatus = 'updated';
257 log(` ${t(lang, 'npmPackageUpdated')} ${PACKAGE_NAME}`);
258 } else {
259 npmStatus = 'failed';
260 log(` ${t(lang, 'npmPackageFailed')}`);
261 }
262 }
263
264 const targets = await detectInstalledCometTargets(projectPath, {
265 scopes: options.scope ? [options.scope] : undefined,
266 });
267
268 if (targets.length === 0) {
269 if (options.json) {
270 console.log(
271 JSON.stringify(
272 {
273 npm: {
274 scope: options.skipNpm ? 'skipped' : packageScope,
275 status: npmStatus,
276 command: options.skipNpm ? null : formatNpmUpdateCommand(packageScope),
277 },
278 skills: { totalCopied: 0, targets: [] },
279 rules: { totalCopied: 0 },
280 hooks: { totalInstalled: 0 },
281 codegraph: 'skipped',
282 },
283 null,
284 2,
285 ),
286 );

Callers 2

update.test.tsFile · 0.85
index.tsFile · 0.85

Calls 15

logFunction · 0.85
tFunction · 0.85
printVersionInfoFunction · 0.85
detectCometPackageScopeFunction · 0.85
formatNpmUpdateCommandFunction · 0.85
updateCometNpmPackageFunction · 0.85
languageToSkillsDirFunction · 0.85
formatSkillUpdateCommandFunction · 0.85
getManifestSkillsFunction · 0.85
getBaseDirFunction · 0.85

Tested by

no test coverage detected