@nocobase/plugin-async-task-manager 2.0.0-alpha.43 → 2.0.0-alpha.45

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.
@@ -8,14 +8,14 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.0.0-alpha.43",
11
+ "@nocobase/client": "2.0.0-alpha.45",
12
12
  "react": "18.2.0",
13
- "@nocobase/utils": "2.0.0-alpha.43",
13
+ "@nocobase/utils": "2.0.0-alpha.45",
14
14
  "lodash": "4.17.21",
15
- "@nocobase/server": "2.0.0-alpha.43",
16
- "@nocobase/logger": "2.0.0-alpha.43",
17
- "@nocobase/database": "2.0.0-alpha.43",
15
+ "@nocobase/server": "2.0.0-alpha.45",
16
+ "@nocobase/logger": "2.0.0-alpha.45",
17
+ "@nocobase/database": "2.0.0-alpha.45",
18
18
  "antd": "5.24.2",
19
19
  "dayjs": "1.11.13",
20
- "@nocobase/actions": "2.0.0-alpha.43"
20
+ "@nocobase/actions": "2.0.0-alpha.45"
21
21
  };
@@ -9,6 +9,7 @@
9
9
  /// <reference types="node" />
10
10
  import { Worker } from 'worker_threads';
11
11
  import { TaskType } from './task-type';
12
+ export declare function parseArgv(list: string[]): any;
12
13
  export declare class CommandTaskType extends TaskType {
13
14
  static type: string;
14
15
  workerThread: Worker;
@@ -36,7 +36,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
37
  var command_task_type_exports = {};
38
38
  __export(command_task_type_exports, {
39
- CommandTaskType: () => CommandTaskType
39
+ CommandTaskType: () => CommandTaskType,
40
+ parseArgv: () => parseArgv
40
41
  });
41
42
  module.exports = __toCommonJS(command_task_type_exports);
42
43
  var import_async_task_manager = require("./interfaces/async-task-manager");
@@ -44,6 +45,37 @@ var import_node_process = __toESM(require("node:process"));
44
45
  var import_worker_threads = require("worker_threads");
45
46
  var import_path = __toESM(require("path"));
46
47
  var import_task_type = require("./task-type");
48
+ function parseArgv(list) {
49
+ const argv = {};
50
+ for (const item of list) {
51
+ const match = item.match(/^--([^=]+)=(.*)$/);
52
+ if (match) {
53
+ const key = match[1];
54
+ let value = match[2];
55
+ if (value.startsWith("{") || value.startsWith("[")) {
56
+ try {
57
+ value = JSON.parse(value);
58
+ } catch (err) {
59
+ }
60
+ } else {
61
+ if (value === "true") {
62
+ value = true;
63
+ } else if (value === "false") {
64
+ value = false;
65
+ }
66
+ }
67
+ argv[key] = value;
68
+ continue;
69
+ }
70
+ const parts = item.split(":");
71
+ if (parts.length === 2) {
72
+ const command = parts[0];
73
+ const commandValue = parts[1];
74
+ argv[command] = commandValue;
75
+ }
76
+ }
77
+ return argv;
78
+ }
47
79
  class CommandTaskType extends import_task_type.TaskType {
48
80
  static type = "command";
49
81
  workerThread;
@@ -55,6 +87,7 @@ class CommandTaskType extends import_task_type.TaskType {
55
87
  async execute() {
56
88
  var _a;
57
89
  const { argv } = this.record.params;
90
+ const parsedArgv = parseArgv(argv);
58
91
  const isDev = (((_a = import_node_process.default.argv[1]) == null ? void 0 : _a.endsWith(".ts")) || import_node_process.default.argv[1].includes("tinypool")) ?? false;
59
92
  const appRoot = import_node_process.default.env.APP_PACKAGE_ROOT || "packages/core/app";
60
93
  const workerPath = import_path.default.resolve(import_node_process.default.cwd(), appRoot, isDev ? "src/index.ts" : "lib/index.js");
@@ -73,7 +106,8 @@ class CommandTaskType extends import_task_type.TaskType {
73
106
  },
74
107
  env: {
75
108
  ...import_node_process.default.env,
76
- WORKER_MODE: "-"
109
+ WORKER_MODE: "-",
110
+ ...parsedArgv.app && parsedArgv.app !== "main" ? { STARTUP_SUBAPP: parsedArgv.app } : {}
77
111
  }
78
112
  });
79
113
  this.workerThread = worker;
@@ -128,5 +162,6 @@ class CommandTaskType extends import_task_type.TaskType {
128
162
  }
129
163
  // Annotate the CommonJS export names for ESM import in node:
130
164
  0 && (module.exports = {
131
- CommandTaskType
165
+ CommandTaskType,
166
+ parseArgv
132
167
  });
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Manage and monitor asynchronous tasks such as data import/export. Support task progress tracking and notification.",
7
7
  "description.ru-RU": "Управление асинхронными задачами и мониторинг (например, импорт/экспорт данных). Поддержка отслеживания прогресса и уведомлений о задачах.",
8
8
  "description.zh-CN": "管理和监控数据导入导出等异步任务。支持任务进度跟踪和通知。",
9
- "version": "2.0.0-alpha.43",
9
+ "version": "2.0.0-alpha.45",
10
10
  "main": "dist/server/index.js",
11
11
  "peerDependencies": {
12
12
  "@nocobase/client": "2.x",
@@ -17,5 +17,5 @@
17
17
  "dependencies": {
18
18
  "p-queue": "^6.6.2"
19
19
  },
20
- "gitHead": "5e1b7446db50446b80427240a38a9417f3742c05"
20
+ "gitHead": "ddb6d6b89f4f3dc49dc942d46901e9e6f159be58"
21
21
  }