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

Function start

server/scripts/installPlugin.js:24–70  ·  view source on GitHub ↗

* 编译插件并添加到 registry 中

()

Source from the content-addressed store, hash-verified

22 * 编译插件并添加到 registry 中
23 */
24async function start() {
25 if (argv.length === 2) {
26 console.log(`安装方式: pnpm plugin:install [pluginName]`);
27 console.log('所有插件:');
28 dirs.forEach((dir) => {
29 console.log(`- ${dir}`);
30 });
31
32 return;
33 }
34
35 const [, , ...installPlugins] = argv;
36
37 let availableInstallPlugins = [];
38 if (installPlugins.includes('all')) {
39 // 安装所有
40 availableInstallPlugins = [...dirs];
41 } else {
42 // 安装部分
43 availableInstallPlugins = installPlugins.filter((p) => dirs.includes(p));
44 }
45 for (const p of availableInstallPlugins) {
46 console.log('┌ 开始安装:', p);
47 let manifest = await fs.readJSON(
48 path.resolve(containerPath, `./${p}/web/plugins/${p}/manifest.json`)
49 );
50 if (!manifest) {
51 console.error('配置加载失败, 跳转安装');
52 return;
53 }
54
55 // 编译插件文件
56 await execa('pnpm', ['build:web'], {
57 cwd: path.resolve(containerPath, p),
58 stdout: 'inherit',
59 stderr: 'inherit',
60 });
61
62 // 追加前端配置到registry
63 const originRegistry =
64 (await fs.readJSON(registryPath).catch(() => [])) ?? [];
65 const newRegistry = _.uniqBy([manifest, ...originRegistry], (m) => m.name);
66 await fs.writeJSON(registryPath, newRegistry);
67
68 console.log('└ 安装完毕:', p);
69 }
70}
71
72start();

Callers 2

init.tsxFile · 0.85
installPlugin.jsFile · 0.85

Calls 2

errorMethod · 0.80
logMethod · 0.65

Tested by

no test coverage detected