@mp-assistant/cli 0.1.1 → 0.1.2

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.
package/dist/bin/index.js CHANGED
@@ -11,12 +11,16 @@ program
11
11
  .description('小程序助手')
12
12
  //
13
13
  .command('start')
14
- .action(() => {
14
+ .option('-e, --executablePath <executablePath>', '浏览器可执行文件路径')
15
+ .option('-h, --headless <headless>', '是否无头模式')
16
+ .option('-p, --port <port>', '端口号 (默认: 3001)')
17
+ .action(async (options) => {
18
+ const { executablePath, headless, port } = options;
15
19
  ConfigStore.instance.setConfig({
16
- executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe',
17
- headless: false,
18
- port: 3001,
20
+ executablePath: executablePath || ConfigStore.instance.config.executablePath,
21
+ headless: headless || ConfigStore.instance.config.headless,
22
+ port: port || ConfigStore.instance.config.port,
19
23
  });
20
- start();
24
+ await start();
21
25
  });
22
26
  program.parse(process.argv);
@@ -1 +1 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../../src/server/api/modules/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAW1C,eAAO,MAAM,iBAAiB,GAAI,SAAS,eAAe,SA2JzD,CAAA"}
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../../src/server/api/modules/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAY1C,eAAO,MAAM,iBAAiB,GAAI,SAAS,eAAe,SAqKzD,CAAA"}
@@ -7,6 +7,7 @@ import { getSuccessApiResponse, getErrorApiResponse } from "@mp-assistant/common
7
7
  import { WSStore } from "../../../store/WSStore.js";
8
8
  import { WSMessage } from "@mp-assistant/common/dist/ws/message.js";
9
9
  import { WSMessageEvent } from "../../../event/WSMessageEvent.js";
10
+ import fs from 'fs';
10
11
  export const registerWorkerApi = (fastify) => {
11
12
  fastify.get(Api.Worker.GetWorkerList.url, async (request, reply) => {
12
13
  const workerInfos = WorkerStore.instance.workerList.map(item => {
@@ -24,6 +25,13 @@ export const registerWorkerApi = (fastify) => {
24
25
  });
25
26
  fastify.post(Api.Worker.AddWorker.url, async (request, reply) => {
26
27
  const { type, name } = request.body;
28
+ const executablePath = ConfigStore.instance.config.executablePath;
29
+ if (!executablePath) {
30
+ return getErrorApiResponse('Executable path not set', 400);
31
+ }
32
+ if (fs.statSync(executablePath, { throwIfNoEntry: false })?.isFile() === false) {
33
+ return getErrorApiResponse('Executable path not found', 400);
34
+ }
27
35
  const worker = createWorker(type, {
28
36
  name,
29
37
  wsMessageEventHandler: WSMessageEvent.instance,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mp-assistant/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -19,14 +19,14 @@
19
19
  "dayjs": "^1.11.13",
20
20
  "fastify": "^5.7.4",
21
21
  "ws": "^8.19.0",
22
- "@mp-assistant/dashboard": "0.1.1",
23
- "@mp-assistant/core": "0.1.1",
24
- "@mp-assistant/common": "0.1.1"
22
+ "@mp-assistant/common": "0.1.2",
23
+ "@mp-assistant/dashboard": "0.1.2",
24
+ "@mp-assistant/core": "0.1.2"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/ws": "^8.18.1",
28
- "@mp-assistant/configuration": "0.1.1",
29
- "@mp-assistant/scripts": "0.1.1"
28
+ "@mp-assistant/configuration": "0.1.2",
29
+ "@mp-assistant/scripts": "0.1.2"
30
30
  },
31
31
  "repository": {
32
32
  "type": "git",