MCPcopy Create free account
hub / github.com/msgbyte/tailchat / handler

Function handler

apps/cli/src/commands/declaration.ts:20–66  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

18 choices: ['empty', 'github'],
19 }),
20 async handler(args) {
21 let source = String(args.source);
22
23 if (!source) {
24 const res = await inquirer.prompt([
25 {
26 type: 'list',
27 name: 'source',
28 message: 'Select type source',
29 choices: [
30 {
31 name: 'Empty',
32 value: 'empty',
33 },
34 {
35 name: 'Download the full statement from Github',
36 value: 'github',
37 },
38 ],
39 },
40 ]);
41 source = String(res.source);
42 }
43
44 let content = '';
45 if (source === 'empty') {
46 content =
47 "declare module '@capital/common';\ndeclare module '@capital/component';\n";
48 } else if (source === 'github') {
49 const url = onlineDeclarationUrl;
50
51 const spinner = ora(
52 `Downloading plugin type declarations from Github: ${url}`
53 ).start();
54
55 content = await got.get(url).then((res) => res.body);
56
57 spinner.succeed('The declaration file has been downloaded');
58 }
59
60 if (content !== '') {
61 const target = path.resolve(process.cwd(), './types/tailchat.d.ts');
62 await mkdirp(path.dirname(target));
63 await fs.writeFile(target, content);
64 console.log('Writing type file complete:', target);
65 }
66 },
67};

Callers

nothing calls this directly

Calls 3

startMethod · 0.80
logMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected