alemonjs 1.0.3 → 1.0.4

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.
Files changed (63) hide show
  1. package/README.md +7 -9
  2. package/bin/main.js +17 -0
  3. package/lib/alemon/dealmsg.js +66 -18
  4. package/lib/alemon/puppeteer.js +9 -16
  5. package/lib/config/index.js +1 -1
  6. package/lib/config/login.js +21 -82
  7. package/lib/config/pup.js +75 -0
  8. package/lib/config/types.js +1 -10
  9. package/lib/default/login/discord.js +16 -0
  10. package/lib/default/login/kook.js +5 -0
  11. package/lib/default/login/ntqq.js +17 -0
  12. package/lib/default/login/qq.js +16 -0
  13. package/lib/default/login/villa.js +13 -0
  14. package/lib/default/mysql.js +7 -0
  15. package/lib/default/pup.js +15 -0
  16. package/lib/default/redis.js +6 -0
  17. package/lib/default/server.js +4 -0
  18. package/lib/default/types.js +16 -0
  19. package/lib/define/api.js +23 -0
  20. package/lib/define/child_process.js +10 -0
  21. package/lib/define/command.js +22 -0
  22. package/lib/define/index.js +7 -0
  23. package/lib/define/main.js +205 -0
  24. package/lib/{map.js → define/map.js} +8 -6
  25. package/lib/define/plugin.js +25 -0
  26. package/lib/define/types.js +1 -0
  27. package/lib/discord/login.js +18 -62
  28. package/lib/index.js +22 -8
  29. package/lib/kook/login.js +7 -39
  30. package/lib/ntqq/index.js +1 -1
  31. package/lib/ntqq/login.js +15 -62
  32. package/lib/ntqq/sdk/wss.js +0 -1
  33. package/lib/qq/index.js +13 -2
  34. package/lib/qq/login.js +3 -124
  35. package/lib/villa/login.js +11 -51
  36. package/package.json +61 -59
  37. package/types/alemon/dealmsg.d.ts +10 -0
  38. package/types/config/index.d.ts +1 -1
  39. package/types/config/pup.d.ts +7 -0
  40. package/types/config/types.d.ts +9 -117
  41. package/types/default/login/discord.d.ts +8 -0
  42. package/types/default/login/kook.d.ts +6 -0
  43. package/types/default/login/ntqq.d.ts +16 -0
  44. package/types/default/login/qq.d.ts +12 -0
  45. package/types/default/login/villa.d.ts +14 -0
  46. package/types/default/mysql.d.ts +8 -0
  47. package/types/default/pup.d.ts +3 -0
  48. package/types/default/redis.d.ts +7 -0
  49. package/types/default/server.d.ts +5 -0
  50. package/types/default/types.d.ts +300 -0
  51. package/types/define/api.d.ts +30 -0
  52. package/types/define/child_process.d.ts +1 -0
  53. package/types/define/command.d.ts +1 -0
  54. package/types/define/index.d.ts +7 -0
  55. package/types/define/main.d.ts +20 -0
  56. package/types/{map.d.ts → define/map.d.ts} +3 -1
  57. package/types/define/plugin.d.ts +4 -0
  58. package/types/define/types.d.ts +111 -0
  59. package/types/index.d.ts +16 -2
  60. package/lib/bot.js +0 -66
  61. package/lib/config/toml.js +0 -25
  62. package/types/bot.d.ts +0 -20
  63. package/types/config/toml.d.ts +0 -12
package/README.md CHANGED
@@ -4,8 +4,6 @@
4
4
 
5
5
  > 支持 NtQQ、QQ 频道、Discord、米游社大别野、KOOK
6
6
 
7
- [☞Alemon 文档](https://alemonjs.com)
8
-
9
7
  | 分支 | 类型 | 说明 |
10
8
  | ----- | ------ | -------------------- |
11
9
  | main | 核心 | 机器实例 |
@@ -13,21 +11,21 @@
13
11
  | cli | 脚手架 | 开发模板脚手架 |
14
12
  | web | 网站 | 共享平台插件贡献地址 |
15
13
 
16
- ## 配置管理
14
+ > 需要配置机器人才可启动
15
+
16
+ 文档查看 OPEN[alemonjs.com](https://alemonjs.com)
17
17
 
18
- 参考配置说明进行
18
+ 开发模板 GITEE[create-alemonjs](https://gitee.com/ningmengchongshui/alemon/tree/cli/bin/template)
19
19
 
20
- 更改[alemon.toml](./alemon.md)
20
+ 开发模板 GITHUB[create-alemonjs](https://github.com/ningmengchongshui/alemon/tree/cli/bin/template)
21
21
 
22
22
  ### 共享平台
23
23
 
24
24
  > 仓库只做资源收集,对齐安全性不做任何检查,请谨慎选择
25
25
 
26
- [Gitee ☞ 贡献资源](https://gitee.com/ningmengchongshui/alemon/blob/web/docs/about/plugins.md)
27
-
28
- [Github ☞ 贡献资源](https://gitee.com/ningmengchongshui/alemon/blob/web/docs/about/plugins.md)
26
+ 贡献资源 OPEN[Gitee](https://gitee.com/ningmengchongshui/alemon/blob/web/docs/about/plugins.md)
29
27
 
30
- ### 平台推送
28
+ 贡献资源 OPEN[Github](https://gitee.com/ningmengchongshui/alemon/blob/web/docs/about/plugins.md)
31
29
 
32
30
  > 仅限签署开源协议的仓库、不开源将不做考虑范围内
33
31
 
package/bin/main.js ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawn } from 'child_process'
4
+
5
+ const ars = process.argv.slice(2)
6
+
7
+ const command = spawn(`npx ts-node alemon.config.ts ${ars}`, {
8
+ shell: true
9
+ })
10
+
11
+ command.stdout.on('data', data => {
12
+ process.stdout.write(data.toString())
13
+ })
14
+
15
+ command.stderr.on('data', data => {
16
+ process.stderr.write(data.toString())
17
+ })
@@ -34,6 +34,21 @@ let addressMenu = join(process.cwd(), route);
34
34
  * 大正则
35
35
  */
36
36
  let mergedRegex;
37
+ let appRegex = /./;
38
+ let appRegexClose;
39
+ /**
40
+ * 插件名匹配
41
+ * @param val
42
+ */
43
+ export function setAppRegex(val) {
44
+ const { RegexOpen, RegexClose } = val;
45
+ if (RegexOpen) {
46
+ appRegex = RegexOpen;
47
+ }
48
+ if (RegexClose) {
49
+ appRegexClose = RegexClose;
50
+ }
51
+ }
37
52
  /**
38
53
  * 设置指令json地址
39
54
  * @param rt '/public/defset'
@@ -52,17 +67,32 @@ export function getPluginHelp(AppName) {
52
67
  }
53
68
  /**
54
69
  * 创建机器人帮助
70
+ * 存在且得到的app不为[]时才会创建json
55
71
  */
56
72
  function createPluginHelp() {
57
- // 不存在
58
- if (!existsSync(addressMenu))
59
- mkdirSync(addressMenu, { recursive: true });
60
- // 创建help
61
- for (const item in plugins) {
62
- const basePath = join(addressMenu, `${item}.json`);
63
- const jsonData = JSON.stringify(plugins[item], null, 2);
64
- // 异步创建避免阻塞
65
- writeFile(basePath, jsonData, 'utf-8');
73
+ // 存在app才创建
74
+ if (Object.values(plugins).length != 0) {
75
+ // 同时key不能是空数组
76
+ let t = false;
77
+ for (const item in plugins) {
78
+ if (plugins[item] && plugins[item].length != 0) {
79
+ t = true;
80
+ }
81
+ }
82
+ if (t) {
83
+ // 不存在
84
+ if (!existsSync(addressMenu))
85
+ mkdirSync(addressMenu, { recursive: true });
86
+ // 创建help
87
+ for (const item in plugins) {
88
+ if (plugins[item] && plugins[item].length != 0) {
89
+ const basePath = join(addressMenu, `${item}.json`);
90
+ const jsonData = JSON.stringify(plugins[item], null, 2);
91
+ // 异步创建避免阻塞
92
+ writeFile(basePath, jsonData, 'utf-8');
93
+ }
94
+ }
95
+ }
66
96
  }
67
97
  }
68
98
  /**
@@ -167,13 +197,34 @@ async function synthesis(AppsObj, appname, belong) {
167
197
  * @param dir
168
198
  */
169
199
  async function loadPlugins(dir) {
170
- if (!existsSync(dir))
171
- mkdirSync(dir, { recursive: true });
200
+ /**
201
+ * ********************
202
+ * 没有该文件夹直接返回
203
+ * *******************
204
+ */
205
+ if (!existsSync(dir)) {
206
+ return;
207
+ }
172
208
  const flies = readdirSync(dir);
209
+ if (flies.length == 0) {
210
+ return;
211
+ }
212
+ const app = flies
213
+ .filter(item => appRegex.test(item))
214
+ .filter(item => {
215
+ // 关闭符合条件的
216
+ if (!appRegexClose) {
217
+ return true;
218
+ }
219
+ if (appRegexClose.test(item)) {
220
+ return false;
221
+ }
222
+ return true;
223
+ });
173
224
  /**
174
225
  * 识别并执行插件
175
226
  */
176
- for await (const appname of flies) {
227
+ for await (const appname of app) {
177
228
  if (existsSync(`${dir}/${appname}/index.ts`)) {
178
229
  /**
179
230
  * 优先考虑ts
@@ -356,8 +407,7 @@ export async function InstructionMatching(e) {
356
407
  return res;
357
408
  })
358
409
  .catch((err) => {
359
- console.error(`\n[${data.event}][${data.belong}][${data.AppName}][${data.fncName}][${err}]`);
360
- console.error(`\n[${data.event}][${data.belong}][${data.AppName}][${data.fncName}][${false}]`);
410
+ console.error(`\n[${data.event}][${data.belong}][${data.AppName}][${data.fncName}][${false}]\n[${err}]`);
361
411
  return false;
362
412
  });
363
413
  // 不是false都直接中断匹配
@@ -396,8 +446,7 @@ export async function typeMessage(e) {
396
446
  return res;
397
447
  })
398
448
  .catch((err) => {
399
- console.error(err);
400
- console.error(`\n[${data.event}][${data.belong}][${data.AppName}][${data.fncName}][${false}]`);
449
+ console.error(`\n[${data.event}][${data.belong}][${data.AppName}][${data.fncName}][${false}]\n[${err}]`);
401
450
  return false;
402
451
  });
403
452
  if (res) {
@@ -417,7 +466,6 @@ export async function typeMessage(e) {
417
466
  * @param data
418
467
  */
419
468
  function logErr(err, data) {
420
- console.error(err);
421
- console.error(`\n[${data.event}][${data.belong}][${data.AppName}][${data.fncName}][${false}]`);
469
+ console.error(`\n[${data.event}][${data.belong}][${data.AppName}][${data.fncName}][${false}]\n[${err}]`);
422
470
  return;
423
471
  }
@@ -54,9 +54,11 @@ export async function pupStartCheck() {
54
54
  /**
55
55
  * 检测是否开启
56
56
  */
57
- if (isBrowser == false) {
58
- if (!(await startChrom()))
57
+ if (!isBrowser) {
58
+ const T = await startChrom();
59
+ if (!T) {
59
60
  return false;
61
+ }
60
62
  }
61
63
  if (pic <= RestartControl) {
62
64
  /**
@@ -90,18 +92,12 @@ export async function pupStartCheck() {
90
92
  * @returns
91
93
  */
92
94
  export async function screenshotByFile(htmlPath, Options) {
93
- if (!pupStartCheck())
95
+ const T = await pupStartCheck();
96
+ if (!T) {
94
97
  return false;
98
+ }
95
99
  const { SOptions, tab = 'body', timeout = 120000 } = Options;
96
100
  try {
97
- /**
98
- * 开始
99
- */
100
- if (!isBrowser) {
101
- if (!(await startChrom()))
102
- return false;
103
- }
104
- console.info('[puppeteer] start');
105
101
  /**
106
102
  * 实例化
107
103
  */
@@ -148,13 +144,10 @@ export async function screenshotByFile(htmlPath, Options) {
148
144
  * @returns
149
145
  */
150
146
  export async function screenshotByUrl(val) {
151
- if (!pupStartCheck())
147
+ const T = await pupStartCheck();
148
+ if (!T) {
152
149
  return false;
153
- if (!isBrowser) {
154
- if (!(await startChrom()))
155
- return false;
156
150
  }
157
- console.info('[puppeteer] start');
158
151
  const { url, time, rand, params, tab, cache } = val;
159
152
  if (!pageCache[url]) {
160
153
  pageCache[url] = await browser.newPage();
@@ -4,5 +4,5 @@
4
4
  * ********
5
5
  */
6
6
  export * from './login.js';
7
- export * from './toml.js';
8
7
  export * from './types.js';
8
+ export * from './pup.js';
@@ -1,86 +1,25 @@
1
+ import redis from '../default/redis.js';
2
+ import mysql from '../default/mysql.js';
3
+ import server from '../default/server.js';
4
+ import puppeteer from '../default/pup.js';
5
+ import discord from '../default/login/discord.js';
6
+ import kook from '../default/login/kook.js';
7
+ import villa from '../default/login/villa.js';
8
+ import qq from '../default/login/qq.js';
9
+ import ntqq from '../default/login/ntqq.js';
1
10
  /**
2
11
  * bot-config
3
12
  */
4
13
  const config = {
5
- redis: {
6
- host: '127.0.0.1',
7
- port: 6379,
8
- password: '',
9
- db: 1
10
- },
11
- mysql: {
12
- host: '127.0.0.1',
13
- port: 3306,
14
- user: 'root',
15
- password: '',
16
- database: 'alemon'
17
- },
18
- discord: {
19
- token: '',
20
- masterID: '',
21
- password: '',
22
- intents: []
23
- },
24
- kook: {
25
- token: '',
26
- masterID: '',
27
- password: ''
28
- },
29
- villa: {
30
- bot_id: '',
31
- secret: '',
32
- pub_key: '',
33
- masterID: '',
34
- password: '',
35
- http: 'http',
36
- url: '/api/mys/callback',
37
- port: 8080,
38
- size: 999999,
39
- img_url: '/api/mys/img',
40
- IMAGE_DIR: '/data/mys/img'
41
- },
42
- qq: {
43
- appID: '',
44
- token: '',
45
- masterID: '',
46
- password: '',
47
- intents: [],
48
- isPrivate: false,
49
- sandbox: false
50
- },
51
- ntqq: {
52
- appID: '',
53
- token: '',
54
- secret: '',
55
- masterID: '',
56
- password: '',
57
- intents: [],
58
- port: 9090,
59
- size: 999999,
60
- img_url: '/api/mys/img',
61
- IMAGE_DIR: '/data/mys/img',
62
- http: 'http'
63
- },
64
- server: {
65
- host: '127.0.0.1',
66
- port: 5000
67
- },
68
- /**
69
- * pup的配置的繁多的
70
- */
71
- puppeteer: {
72
- headless: 'new',
73
- timeout: 30000,
74
- args: [
75
- '--disable-gpu',
76
- '--disable-dev-shm-usage',
77
- '--disable-setuid-sandbox',
78
- '--no-first-run',
79
- '--no-sandbox',
80
- '--no-zygote',
81
- '--single-process'
82
- ]
83
- }
14
+ redis,
15
+ mysql,
16
+ discord,
17
+ kook,
18
+ villa,
19
+ qq,
20
+ ntqq,
21
+ server,
22
+ puppeteer
84
23
  };
85
24
  /**
86
25
  * 初始化配置
@@ -104,13 +43,13 @@ export function setBotConfig(val) {
104
43
  config[i][j] = val[i][j];
105
44
  }
106
45
  else {
107
- console.log('[alemonjs][存在无效参数]', val[i]);
46
+ console.info('[alemonjs][存在无效参数]', val[i]);
108
47
  }
109
48
  }
110
49
  }
111
50
  }
112
51
  else {
113
- console.log('[alemonjs][存在无效参数]', val[i]);
52
+ console.info('[alemonjs][存在无效参数]', val[i]);
114
53
  }
115
54
  }
116
55
  }
@@ -133,7 +72,7 @@ export function setBotConfigByKey(key, val) {
133
72
  config[key][item] = val[item];
134
73
  }
135
74
  else {
136
- console.log('[alemonjs][存在无效参数]', val[item]);
75
+ console.info('[alemonjs][存在无效参数]', val[item]);
137
76
  }
138
77
  }
139
78
  }
@@ -0,0 +1,75 @@
1
+ import { arch } from 'os';
2
+ import { existsSync, realpathSync } from 'fs';
3
+ import { execSync } from 'child_process';
4
+ const isArch = arch();
5
+ const platform = process.platform;
6
+ const win32Edge = 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe';
7
+ // Downloa
8
+ let skipDownload = false;
9
+ // Path
10
+ let executablePath;
11
+ if (process.platform == 'win32' && existsSync(win32Edge)) {
12
+ // win32 Edge
13
+ skipDownload = true;
14
+ executablePath = win32Edge;
15
+ console.info('[Win32 Edge] start');
16
+ }
17
+ else if (platform == 'linux' || platform == 'android') {
18
+ // linux | android
19
+ const chromium = [
20
+ 'whereis chrome-browser',
21
+ 'whereis chrome',
22
+ 'whereis chromium-browser',
23
+ 'whereis chromium',
24
+ 'whereis firefox'
25
+ ];
26
+ // get path
27
+ for (const item of chromium) {
28
+ try {
29
+ const chromiumPath = execSync(item).toString().split(' ')[1]?.trim();
30
+ if (chromiumPath) {
31
+ skipDownload = true;
32
+ executablePath = realpathSync(chromiumPath);
33
+ console.info('[Chromium] start');
34
+ break;
35
+ }
36
+ }
37
+ catch (error) {
38
+ console.error('Failed to get Chromium path:', error);
39
+ continue;
40
+ }
41
+ }
42
+ // not path
43
+ if (!skipDownload) {
44
+ /**
45
+ * search
46
+ */
47
+ const arr = [
48
+ '/usr/bin/chromium',
49
+ '/snap/bin/chromium',
50
+ '/usr/bin/chromium-browser'
51
+ ];
52
+ for (const item of arr) {
53
+ if (existsSync(item)) {
54
+ skipDownload = true;
55
+ executablePath = item;
56
+ console.info('[Chromium] start');
57
+ break;
58
+ }
59
+ }
60
+ }
61
+ // arm64/arrch64
62
+ if (isArch == 'arm64' || isArch == 'aarch64') {
63
+ console.info('[arm64/aarch64] system');
64
+ skipDownload = true;
65
+ }
66
+ }
67
+ /**
68
+ * @type {import("puppeteer").Configuration}
69
+ */
70
+ export function getPupPath() {
71
+ return {
72
+ skipDownload,
73
+ executablePath
74
+ };
75
+ }
@@ -1,10 +1 @@
1
- /**
2
- * *****
3
- * ntqq
4
- * ****
5
- */
6
- export var NtQQEventsEnum;
7
- (function (NtQQEventsEnum) {
8
- NtQQEventsEnum["GROUP_AT_MESSAGE_CREATE"] = "GROUP_AT_MESSAGE_CREATE";
9
- NtQQEventsEnum["C2C_MESSAGE_CREATE"] = "C2C_MESSAGE_CREATE"; // 单聊消息
10
- })(NtQQEventsEnum = NtQQEventsEnum || (NtQQEventsEnum = {}));
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import { GatewayIntentBits } from 'discord.js';
2
+ export default {
3
+ token: '',
4
+ masterID: '',
5
+ password: '',
6
+ intents: [
7
+ GatewayIntentBits.DirectMessageReactions,
8
+ GatewayIntentBits.DirectMessageTyping,
9
+ GatewayIntentBits.DirectMessages,
10
+ GatewayIntentBits.GuildMessageReactions,
11
+ GatewayIntentBits.GuildMessageTyping,
12
+ GatewayIntentBits.GuildMessages,
13
+ GatewayIntentBits.Guilds,
14
+ GatewayIntentBits.MessageContent // 消息内容
15
+ ]
16
+ };
@@ -0,0 +1,5 @@
1
+ export default {
2
+ token: '',
3
+ masterID: '',
4
+ password: ''
5
+ };
@@ -0,0 +1,17 @@
1
+ export default {
2
+ appID: '',
3
+ token: '',
4
+ secret: '',
5
+ masterID: '',
6
+ password: '',
7
+ intents: [
8
+ 'GROUP_AT_MESSAGE_CREATE',
9
+ 'C2C_MESSAGE_CREATE'
10
+ ],
11
+ shard: [0, 1],
12
+ port: 9090,
13
+ size: 999999,
14
+ img_url: '/api/mys/img',
15
+ IMAGE_DIR: '/data/mys/img',
16
+ http: 'http'
17
+ };
@@ -0,0 +1,16 @@
1
+ import { AvailableIntentsEventsEnum } from 'qq-guild-bot';
2
+ export default {
3
+ appID: '',
4
+ token: '',
5
+ secret: '',
6
+ masterID: '',
7
+ password: '',
8
+ intents: [
9
+ AvailableIntentsEventsEnum.GUILDS,
10
+ AvailableIntentsEventsEnum.PUBLIC_GUILD_MESSAGES,
11
+ AvailableIntentsEventsEnum.DIRECT_MESSAGE,
12
+ AvailableIntentsEventsEnum.GUILD_MEMBERS
13
+ ],
14
+ isPrivate: false,
15
+ sandbox: false
16
+ };
@@ -0,0 +1,13 @@
1
+ export default {
2
+ bot_id: '',
3
+ secret: '',
4
+ pub_key: '',
5
+ masterID: '',
6
+ password: '',
7
+ http: 'http',
8
+ url: '/api/mys/callback',
9
+ port: 8080,
10
+ size: 999999,
11
+ img_url: '/api/mys/img',
12
+ IMAGE_DIR: '/data/mys/img'
13
+ };
@@ -0,0 +1,7 @@
1
+ export default {
2
+ host: 'localhost',
3
+ port: 3306,
4
+ user: 'root',
5
+ password: '',
6
+ database: 'alemonjs'
7
+ };
@@ -0,0 +1,15 @@
1
+ export default {
2
+ headless: 'new',
3
+ timeout: 30000,
4
+ args: [
5
+ '--disable-gpu',
6
+ '--disable-dev-shm-usage',
7
+ '--disable-setuid-sandbox',
8
+ '--no-first-run',
9
+ '--no-sandbox',
10
+ '--no-zygote',
11
+ '--single-process'
12
+ ],
13
+ skipDownload: true,
14
+ executablePath: 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'
15
+ };
@@ -0,0 +1,6 @@
1
+ export default {
2
+ host: '127.0.0.1',
3
+ port: 6379,
4
+ password: '',
5
+ db: 1
6
+ };
@@ -0,0 +1,4 @@
1
+ export default {
2
+ host: 'localhost',
3
+ port: 5000
4
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * *****
3
+ * ntqq订阅
4
+ * ****
5
+ */
6
+ export var NtQQEventsEnum;
7
+ (function (NtQQEventsEnum) {
8
+ /**
9
+ * 群聊消息
10
+ */
11
+ NtQQEventsEnum["GROUP_AT_MESSAGE_CREATE"] = "GROUP_AT_MESSAGE_CREATE";
12
+ /**
13
+ * 单聊消息
14
+ */
15
+ NtQQEventsEnum["C2C_MESSAGE_CREATE"] = "C2C_MESSAGE_CREATE";
16
+ })(NtQQEventsEnum = NtQQEventsEnum || (NtQQEventsEnum = {}));
@@ -0,0 +1,23 @@
1
+ import { ClientAPIByQQ as ClientByNTQQ } from '../ntqq/sdk/index.js';
2
+ import { Client as ClientByVILLA } from 'mys-villa';
3
+ import { KOOKApiClient as ClientByKOOK } from 'kook-ws';
4
+ /**
5
+ * discord客户端
6
+ */
7
+ export const ClientDISCORD = {};
8
+ /**
9
+ * qq客户端
10
+ */
11
+ export const ClientQQ = global.ClientAPIByQQ;
12
+ /**
13
+ * kook客户端
14
+ */
15
+ export const ClientKOOK = ClientByKOOK;
16
+ /**
17
+ * ntqq客户端
18
+ */
19
+ export const ClientNTQQ = ClientByNTQQ;
20
+ /**
21
+ * villa客户端
22
+ */
23
+ export const ClientVILLA = ClientByVILLA;
@@ -0,0 +1,10 @@
1
+ import { spawn } from 'child_process';
2
+ export function nodeScripts(name = 'node', file = '', ars = []) {
3
+ const command = spawn(`${name} ${file} ${ars.join(' ')}`, { shell: true });
4
+ command.stdout.on('data', data => {
5
+ process.stdout.write(data.toString());
6
+ });
7
+ command.stderr.on('data', data => {
8
+ process.stderr.write(data.toString());
9
+ });
10
+ }
@@ -0,0 +1,22 @@
1
+ import { mkdirSync } from 'fs';
2
+ import { execSync } from 'child_process';
3
+ export async function command(cmd) {
4
+ // 错误参数
5
+ if (!cmd)
6
+ process.exit();
7
+ // 锁定位置
8
+ const dirPath = `./`;
9
+ // 没有存在
10
+ mkdirSync(dirPath, { recursive: true });
11
+ console.info('\n');
12
+ try {
13
+ // 切换目录
14
+ process.chdir(dirPath);
15
+ console.info(`[command] ${cmd}`);
16
+ execSync(cmd, { stdio: 'inherit' });
17
+ }
18
+ catch (error) {
19
+ console.info(`${error}`);
20
+ return;
21
+ }
22
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * ********
3
+ * 初始化
4
+ * ******
5
+ */
6
+ export * from './api.js';
7
+ export * from './main.js';