momo-ai 1.0.0 → 1.0.1
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/README.md +116 -0
- package/package.json +2 -1
- package/src/_template/LAIN/.momo/advanced/actor.md +42 -0
- package/src/_template/LAIN/.momo/scripts/submodule-clean.sh +56 -0
- package/src/_template/LAIN/AGENTS.md +103 -0
- package/src/_template/LAIN/changes/proposal.md +39 -0
- package/src/_template/LAIN/changes/tasks/task-detail.md +45 -0
- package/src/_template/LAIN/changes/tasks.md +49 -0
- package/src/_template/LAIN/execute/admin-n-f-dashboard.md +53 -0
- package/src/_template/LAIN/execute/admin-n-f-form.md +51 -0
- package/src/_template/LAIN/execute/admin-n-f-home.md +49 -0
- package/src/_template/LAIN/execute/admin-n-f-list.md +52 -0
- package/src/_template/LAIN/execute/admin-n-f-login.md +56 -0
- package/src/_template/LAIN/specification/project-model.md +13 -0
- package/src/_template/LAIN/specification/project.md +73 -0
- package/src/_template/LAIN/specification/requirement.md +25 -0
- package/src/_template/PROMPT/add.md.ejs +5 -0
- package/src/_template/PROMPT/plan.md.ejs +5 -0
- package/src/_template/PROMPT/run.md.ejs +9 -0
- package/src/_template/PROMPT/tasks.md.ejs +5 -0
- package/src/commander/actor.json +12 -0
- package/src/commander/actors.json +6 -0
- package/src/commander/add.json +12 -0
- package/src/commander/archive.json +12 -0
- package/src/commander/env.json +7 -0
- package/src/commander/help.json +7 -0
- package/src/commander/init.json +13 -0
- package/src/commander/list.json +7 -0
- package/src/commander/open.json +7 -0
- package/src/commander/plan.json +12 -0
- package/src/commander/repo.json +18 -0
- package/src/commander/run.json +18 -0
- package/src/commander/show.json +12 -0
- package/src/commander/tasks.json +18 -0
- package/src/commander/unlock.json +6 -0
- package/src/commander/validate.json +12 -0
- package/src/epic/history/ai.economy.impl.fn.excel.js +148 -0
- package/src/epic/history/ai.economy.impl.fn.execute.js +117 -0
- package/src/epic/history/ai.economy.impl.fn.java.js +140 -0
- package/src/epic/history/ai.economy.impl.fn.json.js +23 -0
- package/src/epic/history/ai.economy.impl.fn.plugin.js +160 -0
- package/src/epic/history/ai.economy.impl.fn.react.js +219 -0
- package/src/epic/history/ai.export.impl.fn.parse.js +345 -0
- package/src/epic/history/ai.export.impl.fn.seek.js +42 -0
- package/src/epic/history/ai.export.interface.fn.string.js +5 -0
- package/src/epic/history/ai.export.interface.io.js +69 -0
- package/src/epic/history/ai.export.interface.util.js +17 -0
- package/src/epic/history/ai.parse.metadata.js +94 -0
- package/src/epic/history/ai.path.fn.dir.operation.js +87 -0
- package/src/epic/history/ai.path.fn.io.command.js +43 -0
- package/src/epic/history/ai.path.fn.io.specification.js +59 -0
- package/src/epic/history/ai.path.fn.io.typed.js +63 -0
- package/src/epic/history/ai.path.fn.out.content.js +47 -0
- package/src/epic/history/ai.string.fn.str.util.js +63 -0
- package/src/epic/history/ai.uncork.fn.element.feature.js +52 -0
- package/src/epic/history/ai.uncork.fn.it.feature.js +118 -0
- package/src/epic/history/ai.uncork.fn.to.typed.js +74 -0
- package/src/epic/history/ai.under.fn.cx.evaluate.js +81 -0
- package/src/epic/history/ai.under.fn.fx.terminal.js +143 -0
- package/src/epic/history/ai.unified.fn.fn.error.code.js +108 -0
- package/src/epic/history/ai.unified.fn.is.decision.js +20 -0
- package/src/epic/history/ai.unified.fn.sorter.element.js +26 -0
- package/src/epic/history/zero.__.fn.find.util.js +37 -0
- package/src/epic/history/zero.__.v.constant.js +5 -0
- package/src/epic/index.js +50 -0
- package/src/epic/lain.fn.execute.js +116 -0
- package/src/epic/lain.fn.parse.js +94 -0
- package/src/epic/momo.fn.cx.js +81 -0
- package/src/epic/momo.fn.dir.js +87 -0
- package/src/epic/momo.fn.element.js +52 -0
- package/src/epic/momo.fn.find.js +37 -0
- package/src/epic/momo.fn.fx.js +143 -0
- package/src/epic/momo.fn.io.js +157 -0
- package/src/epic/momo.fn.is.js +20 -0
- package/src/epic/momo.fn.it.js +118 -0
- package/src/epic/momo.fn.log.js +50 -0
- package/src/epic/momo.fn.out.js +47 -0
- package/src/epic/momo.fn.sorter.js +26 -0
- package/src/epic/momo.fn.str.js +63 -0
- package/src/epic/momo.fn.to.js +74 -0
- package/src/epic/momo.v.constant.js +5 -0
- package/src/epic/momo.v.errorcode.js +108 -0
- package/src/executor/executeActor.js +113 -0
- package/src/executor/executeActors.js +58 -0
- package/src/executor/executeAdd.js +248 -0
- package/src/executor/executeArchive.js +124 -0
- package/src/executor/executeEnv.js +158 -0
- package/src/executor/executeHelp.js +23 -0
- package/src/executor/executeInit.js +321 -0
- package/src/executor/executeList.js +111 -0
- package/src/executor/executeOpen.js +130 -0
- package/src/executor/executePlan.js +134 -0
- package/src/executor/executeRepo.js +234 -0
- package/src/executor/executeRun.js +321 -0
- package/src/executor/executeShow.js +164 -0
- package/src/executor/executeTasks.js +260 -0
- package/src/executor/executeUnlock.js +110 -0
- package/src/executor/executeValidate.js +210 -0
- package/src/executor/index.js +35 -0
- package/src/momo.js +39 -1
- package/.idea/copilot.data.migration.agent.xml +0 -6
- package/.idea/copilot.data.migration.ask.xml +0 -6
- package/.idea/copilot.data.migration.ask2agent.xml +0 -6
- package/.idea/copilot.data.migration.edit.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/r2mo-lain.iml +0 -12
- package/.idea/vcs.xml +0 -6
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# 管理型前端登录页开发执行步骤
|
|
2
|
+
|
|
3
|
+
## 任务准备阶段
|
|
4
|
+
|
|
5
|
+
1. 检查 `specification/.activities/` 目录下是否存在空闲的任务项目
|
|
6
|
+
2. 若不存在,则创建新任务目录:`{actor}@{changeId}`
|
|
7
|
+
3. 确认 `source/` 目录中是否有足够的项目副本
|
|
8
|
+
4. 查看 `specification/changes/{changeId}/proposal.md` 了解需求背景
|
|
9
|
+
5. 查看 `specification/changes/{changeId}/tasks.md` 明确任务清单
|
|
10
|
+
|
|
11
|
+
## 任务执行阶段
|
|
12
|
+
|
|
13
|
+
### 登录页开发
|
|
14
|
+
|
|
15
|
+
1. 创建登录页组件
|
|
16
|
+
2. 添加用户名输入框
|
|
17
|
+
3. 添加密码输入框
|
|
18
|
+
4. 添加登录按钮
|
|
19
|
+
5. 配置路由
|
|
20
|
+
6. 对接登录认证接口
|
|
21
|
+
7. 实现表单验证
|
|
22
|
+
8. 实现登录成功跳转
|
|
23
|
+
9. 实现登录失败提示
|
|
24
|
+
|
|
25
|
+
### 安全性考虑
|
|
26
|
+
|
|
27
|
+
1. 确保密码输入框使用密码类型
|
|
28
|
+
|
|
29
|
+
### 质量保证
|
|
30
|
+
|
|
31
|
+
1. 确保代码符合项目规范
|
|
32
|
+
2. 进行必要的代码检查
|
|
33
|
+
|
|
34
|
+
## 任务完成阶段
|
|
35
|
+
|
|
36
|
+
1. 提交代码到版本控制系统
|
|
37
|
+
2. 使用命令执行任务:`momo:run -a {actor} -t {task}`
|
|
38
|
+
3. 更新 `specification/changes/{changeId}/tasks.md` 中的任务状态
|
|
39
|
+
4. 使用命令查看任务状态:`momo:tasks`
|
|
40
|
+
5. 归档需求:`momo archive -n "{changeId}"`
|
|
41
|
+
|
|
42
|
+
## 变更结构参考
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
specification/
|
|
46
|
+
changes/
|
|
47
|
+
{changeId}/
|
|
48
|
+
proposal.md # 变更提案说明文件
|
|
49
|
+
tasks.md # 变更任务列表说明
|
|
50
|
+
design.md # 变更设计说明文件(可选)
|
|
51
|
+
tasks/ # 任务详细内容
|
|
52
|
+
M01-T001-01.md # 具体任务文件
|
|
53
|
+
specs/ # 能力变更详情
|
|
54
|
+
[capability]/
|
|
55
|
+
spec.md # ADDED/MODIFIED/REMOVED需求
|
|
56
|
+
```
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# [项目名称]
|
|
2
|
+
|
|
3
|
+
## 概述
|
|
4
|
+
|
|
5
|
+
[在此处描述项目的总体情况,包括项目的核心价值、解决的问题以及主要功能]
|
|
6
|
+
|
|
7
|
+
- 项目名称: [在此处填写项目名称]
|
|
8
|
+
- 项目类型: [Web应用/移动应用/桌面应用/API服务/混合型等]
|
|
9
|
+
- 项目范围: [描述项目的功能边界和涵盖的业务领域]
|
|
10
|
+
- 项目目标: [列出项目的主要目标和预期成果]
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 技术栈
|
|
15
|
+
|
|
16
|
+
[列出项目使用的主要技术栈信息]
|
|
17
|
+
|
|
18
|
+
- 编程语言: [主要使用的编程语言]
|
|
19
|
+
- 主要框架: [前端/后端框架]
|
|
20
|
+
- 数据库: [数据库类型及名称]
|
|
21
|
+
- 其他关键技术: [其他重要技术组件]
|
|
22
|
+
|
|
23
|
+
## 代码风格
|
|
24
|
+
|
|
25
|
+
[描述代码风格和规范]
|
|
26
|
+
|
|
27
|
+
- 命名规范: [变量、函数、类等的命名约定]
|
|
28
|
+
- 缩进规范: [使用的缩进方式]
|
|
29
|
+
- 注释规范: [代码注释的要求和格式]
|
|
30
|
+
- 其他代码质量要求: [其他代码质量标准]
|
|
31
|
+
|
|
32
|
+
## 架构目标
|
|
33
|
+
|
|
34
|
+
[描述架构设计的目标]
|
|
35
|
+
|
|
36
|
+
- 可扩展性: [系统扩展性要求]
|
|
37
|
+
- 可维护性: [代码可维护性目标]
|
|
38
|
+
- 性能目标: [系统性能指标]
|
|
39
|
+
- 安全性考虑: [安全相关要求]
|
|
40
|
+
|
|
41
|
+
## 测试策略
|
|
42
|
+
|
|
43
|
+
[描述测试策略和方法]
|
|
44
|
+
|
|
45
|
+
- 单元测试覆盖率要求: [期望的代码覆盖率]
|
|
46
|
+
- 集成测试策略: [模块间交互测试方法]
|
|
47
|
+
- 端到端测试方法: [用户行为模拟测试]
|
|
48
|
+
- 使用的测试框架: [测试工具选择]
|
|
49
|
+
|
|
50
|
+
## 核心约束
|
|
51
|
+
|
|
52
|
+
[描述项目的核心约束条件]
|
|
53
|
+
|
|
54
|
+
- 部署环境: [服务器环境要求]
|
|
55
|
+
- 浏览器兼容性要求: [需要支持的浏览器]
|
|
56
|
+
- 第三方服务依赖: [外部服务依赖]
|
|
57
|
+
- 法规合规要求: [法律法规遵循要求]
|
|
58
|
+
|
|
59
|
+
## 外部依赖
|
|
60
|
+
|
|
61
|
+
[列出项目的外部依赖]
|
|
62
|
+
|
|
63
|
+
- API服务: [需要调用的API]
|
|
64
|
+
- 云服务: [使用的云平台服务]
|
|
65
|
+
- 开源库: [依赖的开源组件]
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 领域上下文
|
|
70
|
+
|
|
71
|
+
[描述项目的业务领域背景,包括行业的特点、业务流程、专业术语等]
|
|
72
|
+
|
|
73
|
+
[说明项目所属的行业领域以及解决的具体业务问题]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# [项目名称] 需求说明
|
|
2
|
+
|
|
3
|
+
## 用户群描述
|
|
4
|
+
|
|
5
|
+
[描述用户群,包括用户分类、用户画像、不同用户需求群的差异信息]
|
|
6
|
+
|
|
7
|
+
## 场景描述
|
|
8
|
+
|
|
9
|
+
[描述用户在使用产品时的典型场景,包括使用环境、使用频率、使用目的等]
|
|
10
|
+
|
|
11
|
+
## 产品功能描述
|
|
12
|
+
|
|
13
|
+
[描述产品的核心功能和附加功能,明确每个功能的具体需求和预期效果]
|
|
14
|
+
|
|
15
|
+
## 设备对接
|
|
16
|
+
|
|
17
|
+
[描述产品需要对接的硬件设备类型、通信协议、数据格式等技术细节]
|
|
18
|
+
|
|
19
|
+
## 集成需求
|
|
20
|
+
|
|
21
|
+
[描述产品需要集成的其他系统或平台,包括集成方式、数据交换要求等]
|
|
22
|
+
|
|
23
|
+
## 性能需求
|
|
24
|
+
|
|
25
|
+
[描述产品在性能方面的具体要求,如响应时间、处理能力、并发用户数等]
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# 添加需求提示词
|
|
2
|
+
|
|
3
|
+
<!-- BEGIN -->
|
|
4
|
+
阅读 specification/project.md 中的基本需求信息,根据 <%= NAME %> 的描述信息,重新制定需求的开发计划,更改掉 specification/changes/<%= NAME %>/ 目录中的需求说明,重新制定任务清单并且更新(子任务清单在specification/changes/<%= NAME %>/tasks/目录下),项目本身的技术栈和数据模型可参考 specification/project-model.md 文件。
|
|
5
|
+
<!-- END -->
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# 任务执行需求
|
|
2
|
+
|
|
3
|
+
<!-- BEGIN -->
|
|
4
|
+
在 source/<%= ROOT %> 目录下完成任务 <%= TASK %> 的开发工作(任务详情:specification/changes/<%= REQ %>/tasks/<%= TASK %>.md)。
|
|
5
|
+
|
|
6
|
+
任务完成后,请记得删除以下两个锁文件:
|
|
7
|
+
1. 任务锁文件: specification/changes/<%= REQ %>/tasks/<%= TASK %>.lock
|
|
8
|
+
2. 任务空间锁文件: source/<%= ROOT %>.lock
|
|
9
|
+
<!-- END -->
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"executor": "executeRepo",
|
|
3
|
+
"description": "Clone 仓库中的代码到工作区!",
|
|
4
|
+
"command": "repo",
|
|
5
|
+
"options": [
|
|
6
|
+
{
|
|
7
|
+
"name": "address",
|
|
8
|
+
"alias": "a",
|
|
9
|
+
"description": "当前项目的远程 Git 仓库地址!"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "i",
|
|
13
|
+
"alias": "instance",
|
|
14
|
+
"description": "需要 Clone 的远程仓库的实例副本数量!",
|
|
15
|
+
"default": 10
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"executor": "executeRun",
|
|
3
|
+
"description": "执行指定的任务!",
|
|
4
|
+
"command": "run",
|
|
5
|
+
"options": [
|
|
6
|
+
{
|
|
7
|
+
"name": "actor",
|
|
8
|
+
"alias": "a",
|
|
9
|
+
"description": "指定执行任务的 Actor 名称",
|
|
10
|
+
"default": "unknown"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "task",
|
|
14
|
+
"alias": "t",
|
|
15
|
+
"description": "任务名称"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"executor": "executeTasks",
|
|
3
|
+
"description": "(CV)枚举所有任务信息!",
|
|
4
|
+
"command": "tasks",
|
|
5
|
+
"options": [
|
|
6
|
+
{
|
|
7
|
+
"name": "actor",
|
|
8
|
+
"alias": "a",
|
|
9
|
+
"description": "指定执行任务的 Actor 名称",
|
|
10
|
+
"default": "unknown"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "task",
|
|
14
|
+
"alias": "t",
|
|
15
|
+
"description": "任务名称"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
const __LOG = require('../momo.fn.log');
|
|
2
|
+
const __STR = require('./ai.export.interface.fn.string');
|
|
3
|
+
const __IO = require('./ai.export.interface.io');
|
|
4
|
+
const Excel = require('exceljs');
|
|
5
|
+
const path = require("path");
|
|
6
|
+
// ==========================================================
|
|
7
|
+
// Excel
|
|
8
|
+
// ==========================================================
|
|
9
|
+
|
|
10
|
+
const excelLog = (index, message) => __LOG.info(`Zero AI `.cyan + `「${index}」`.red + message)
|
|
11
|
+
const excelGenerate = async (config = {}, file, index, prefix) => {
|
|
12
|
+
const {role, out} = config;
|
|
13
|
+
excelLog(index, ` -> 加载数据中`);
|
|
14
|
+
const workbook = new Excel.Workbook();
|
|
15
|
+
await workbook.xlsx.readFile(file);
|
|
16
|
+
excelLog(index, ` 读取原始文件:${file.blue}`)
|
|
17
|
+
if (workbook) {
|
|
18
|
+
const worksheetRef = workbook.getWorksheet("DATA-PERM");
|
|
19
|
+
if (worksheetRef) {
|
|
20
|
+
const maxRow = worksheetRef['_rows'].length;
|
|
21
|
+
const maxColumn = worksheetRef['_columns'].length;
|
|
22
|
+
excelLog(index, ` 分析结果:最大行 - ${maxRow.toString().blue},最大列 - ${maxColumn.toString().blue}。`);
|
|
23
|
+
worksheetRef.eachRow((rowRef, rowNumber) => {
|
|
24
|
+
rowRef.eachCell((cellRef, cellNumber) => {
|
|
25
|
+
const original = cellRef.value;
|
|
26
|
+
if ("#ROLE_ID#" === original) {
|
|
27
|
+
cellRef.value = role;
|
|
28
|
+
} else if ("e501b47a-c08b-4c83-b12b-95ad82873e96" === original) {
|
|
29
|
+
cellRef.value = role;
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
const segment = file.split(path.sep);
|
|
34
|
+
const filename = segment[segment.length - 1];
|
|
35
|
+
const target = prefix ? `${out}${path.sep}${prefix}.${filename}` : `${out}${path.sep}${filename}`;
|
|
36
|
+
excelLog(index, `创建新数据文件 ${target}`);
|
|
37
|
+
await workbook.xlsx.writeFile(target);
|
|
38
|
+
} else {
|
|
39
|
+
excelLog(index, `文件读取有问题:${file}`.red);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const excelRun = (config = {}) => {
|
|
44
|
+
__LOG.info(`Zero AI `.cyan + ` 1. 准备生成角色对应权限:ID = "${config.role.green}" ...`);
|
|
45
|
+
__IO.dirCreate(`${process.cwd()}${path.sep}${config.out}`);
|
|
46
|
+
// 1. 执行替换
|
|
47
|
+
const {files = [], filesInput = []} = config;
|
|
48
|
+
__LOG.info(`Zero AI `.cyan + ` 2. 生成 Zero Extension 权限...`.yellow);
|
|
49
|
+
files.forEach((file, index) => excelGenerate(config, file, index))
|
|
50
|
+
__LOG.info(`Zero AI `.cyan + ` 3. 生成 输入文件 权限...`.yellow);
|
|
51
|
+
filesInput.forEach((file, index) => excelGenerate(config, file, index, "input"))
|
|
52
|
+
}
|
|
53
|
+
const excelResource = async (config = {}, parameters = {}, pid = [], sheetName = "DATA-RES") => {
|
|
54
|
+
const workbook = new Excel.Workbook();
|
|
55
|
+
await workbook.xlsx.readFile(config.resource);
|
|
56
|
+
__LOG.info(`Zero AI `.cyan + ` 2.1. 数据加载中,替换原始文件……`);
|
|
57
|
+
if (workbook) {
|
|
58
|
+
const worksheetRef = workbook.getWorksheet(sheetName);
|
|
59
|
+
if (worksheetRef) {
|
|
60
|
+
const maxRow = worksheetRef['_rows'].length;
|
|
61
|
+
const maxColumn = worksheetRef['_columns'].length;
|
|
62
|
+
__LOG.info(`Zero AI `.cyan + ` 2.2. 分析结果:最大行 - ${maxRow.toString().blue},最大列 - ${maxColumn.toString().blue}。`);
|
|
63
|
+
|
|
64
|
+
const pidSet = new Set();
|
|
65
|
+
const generate = 0 === pid.length
|
|
66
|
+
worksheetRef.eachRow((rowRef, rowNumber) => {
|
|
67
|
+
rowRef.eachCell((cellRef, cellNumber) => {
|
|
68
|
+
const original = cellRef.value;
|
|
69
|
+
if ("string" === typeof original) {
|
|
70
|
+
if ("#GUID#" === original) {
|
|
71
|
+
cellRef.value = __STR.strUuid();
|
|
72
|
+
} else if ("#PID#" === original) {
|
|
73
|
+
if (generate) {
|
|
74
|
+
const permId = __STR.strUuid();
|
|
75
|
+
cellRef.value = permId;
|
|
76
|
+
pid.push(permId)
|
|
77
|
+
} else {
|
|
78
|
+
let found;
|
|
79
|
+
for (let idx = 0; idx < pid.length; idx++) {
|
|
80
|
+
if (!pidSet.has(pid[idx])) {
|
|
81
|
+
pidSet.add(pid[idx]);
|
|
82
|
+
found = pid[idx];
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
cellRef.value = found;
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
cellRef.value = __STR.strExpr(original, parameters)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
__LOG.info(`Zero AI `.cyan + ` 2.3. 正在解析表达式......`);
|
|
95
|
+
worksheetRef.eachRow((rowRef, rowNumber) => {
|
|
96
|
+
rowRef.eachCell((cellRef, cellNumber) => {
|
|
97
|
+
const original = cellRef.value;
|
|
98
|
+
if (original?.sharedFormula || original?.formula) {
|
|
99
|
+
let formula;
|
|
100
|
+
if (original.sharedFormula) {
|
|
101
|
+
formula = original.sharedFormula;
|
|
102
|
+
} else if (original.formula) {
|
|
103
|
+
formula = original.formula;
|
|
104
|
+
}
|
|
105
|
+
const cell = worksheetRef.getCell(formula);
|
|
106
|
+
if ("string" === typeof cell?.value) {
|
|
107
|
+
original.result = cell.value;
|
|
108
|
+
cellRef.value = original;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
__LOG.info(`Zero AI `.cyan + ` 2.4. 创建新数据文件......`.rainbow);
|
|
114
|
+
const targetFile = `./${config.identifier}.xlsx`;
|
|
115
|
+
__LOG.info(`Zero AI `.cyan + ` 执行Worksheet:${targetFile.blue}。`);
|
|
116
|
+
await workbook.xlsx.writeFile(targetFile);
|
|
117
|
+
} else {
|
|
118
|
+
__LOG.info(`Zero AI `.cyan + ` ERROR,文件读取有错!!`.red);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const excelRes = (file = {}, parameters = {}) => {
|
|
123
|
+
__LOG.info(`Zero AI `.cyan + ` 1. 准备生成资源信息..., ${JSON.stringify(parameters)}`);
|
|
124
|
+
__LOG.info(`Zero AI `.cyan + ` 2. 生成 Zero Extension 资源文件...`.yellow);
|
|
125
|
+
const pid = []
|
|
126
|
+
excelResource(file, parameters, pid).then(result => {
|
|
127
|
+
__LOG.info(`Zero AI `.cyan + ` 3. 资源生成完成...`.green);
|
|
128
|
+
return Promise.resolve(result)
|
|
129
|
+
}).then(nil => {
|
|
130
|
+
__LOG.info(`Zero AI `.cyan + ` 4. 准备生成权限信息..., ${JSON.stringify(parameters)}`);
|
|
131
|
+
const res = {};
|
|
132
|
+
res.resource = file.auth;
|
|
133
|
+
res.identifier = "falcon." + file.identifier;
|
|
134
|
+
return excelResource(res, parameters, pid, "DATA-PERM");
|
|
135
|
+
}).then(nil => {
|
|
136
|
+
__LOG.info(`Zero AI `.cyan + ` 5. 权限文件生成完成...`.green);
|
|
137
|
+
const viewJson = __IO.ioJObject(file.json);
|
|
138
|
+
viewJson.data.identifier = file.identifier;
|
|
139
|
+
const targetFile = `./${file.identifier}.json`;
|
|
140
|
+
__IO.outJson(targetFile, viewJson);
|
|
141
|
+
__LOG.info(`Zero AI `.cyan + ` 执行完成...`.green);
|
|
142
|
+
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
module.exports = {
|
|
146
|
+
excelRun,
|
|
147
|
+
excelRes
|
|
148
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const program = require('commander');
|
|
2
|
+
const U = require('underscore');
|
|
3
|
+
const co = require('co');
|
|
4
|
+
const Immutable = require('immutable');
|
|
5
|
+
const __LOG = require('../momo.fn.log');
|
|
6
|
+
const __IT = require('./ai.uncork.fn.it.feature');
|
|
7
|
+
const __FX = require('./ai.under.fn.fx.terminal');
|
|
8
|
+
const __PR = require('./ai.export.impl.fn.parse');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const _buildOption = (options = []) => {
|
|
12
|
+
let optionStr = "";
|
|
13
|
+
const optionItem = [];
|
|
14
|
+
options.forEach((option, index) => {
|
|
15
|
+
const keys = Object.keys(option);
|
|
16
|
+
const key0 = keys[0].toString();
|
|
17
|
+
const key1 = keys[1] ? keys[1].toString() : undefined;
|
|
18
|
+
if (key1) {
|
|
19
|
+
const short = key0.length < key1.length ? key0 : key1;
|
|
20
|
+
const long = key0.length > key1.length ? key0 : key1;
|
|
21
|
+
const key = `-${short}, --${long}`;
|
|
22
|
+
const opt = {};
|
|
23
|
+
opt.key = key;
|
|
24
|
+
opt.desc = option[short] ? option[short] : option[long];
|
|
25
|
+
optionItem.push(opt);
|
|
26
|
+
optionStr += key;
|
|
27
|
+
if (index < options.length - 1) {
|
|
28
|
+
optionStr += ' | ';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
item: optionItem,
|
|
34
|
+
usage: optionStr
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const _validateArgs = (keys = []) => {
|
|
39
|
+
const commandArg = process.argv[2];
|
|
40
|
+
const skip = Immutable.fromJS(["-h", '-V', '--version', '--help']);
|
|
41
|
+
if (!skip.contains(commandArg)) {
|
|
42
|
+
const $keys = Immutable.fromJS(keys.concat(['help']));
|
|
43
|
+
const isError = !$keys.contains(commandArg);
|
|
44
|
+
// 检测未通过时,打印错误信息
|
|
45
|
+
__FX.fxError(isError, 10005, commandArg, keys);
|
|
46
|
+
return !isError;
|
|
47
|
+
} else {
|
|
48
|
+
// 直接跳过,检测未通过
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* ## `Ec.executeHeader`
|
|
54
|
+
*
|
|
55
|
+
* 执行命令时打印头信息
|
|
56
|
+
*
|
|
57
|
+
* @memberOf module:_epic
|
|
58
|
+
* @param {String} app 应用程序名
|
|
59
|
+
*/
|
|
60
|
+
const executeHeader = (app) => {
|
|
61
|
+
const appInfo = require('../../../package.json');
|
|
62
|
+
program.allowUnknownOption();
|
|
63
|
+
program.version(appInfo.version);
|
|
64
|
+
__LOG.info(`----------------- Rachel Momo / AI工具项 ------------------`.rainbow);
|
|
65
|
+
__LOG.info('应用名称: '.bold + app);
|
|
66
|
+
__LOG.info('工具主页: '.bold + appInfo.homepage.blue);
|
|
67
|
+
__LOG.info(`工具版本: ` + `${appInfo.version}`.red + ' ' + `( Node >= 22.x )`.yellow);
|
|
68
|
+
__LOG.info();
|
|
69
|
+
__LOG.info("----------------- AI 系统启动…… ----------------------------".rainbow);
|
|
70
|
+
if (3 > process.argv.length) {
|
|
71
|
+
__LOG.error("命令缺失,请输入正确的命令!");
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* ## `Ec.executeBody`
|
|
76
|
+
*
|
|
77
|
+
* 执行命令的主方法
|
|
78
|
+
*
|
|
79
|
+
* @memberOf module:_epic
|
|
80
|
+
* @param {Array} commanders 指令集
|
|
81
|
+
* @param {Object} Executor 指令执行集`field = Function`格式
|
|
82
|
+
*/
|
|
83
|
+
const executeBody = (commanders = [], Executor = {}) => {
|
|
84
|
+
if (_validateArgs(commanders.map(commander => commander.command))) {
|
|
85
|
+
__IT.itArray(commanders, (commander) => {
|
|
86
|
+
if (!commander.options) commander.options = [];
|
|
87
|
+
const executor = Executor[commander.executor];
|
|
88
|
+
__FX.fxError(!U.isFunction(executor), 10004, commander.command);
|
|
89
|
+
const option = _buildOption(commander.options);
|
|
90
|
+
const cmd = program.command(commander.command)
|
|
91
|
+
.description(commander.description)
|
|
92
|
+
.usage(`[options] [${option.usage}]`);
|
|
93
|
+
__FX.fxContinue(0 < commander.options.length, () => {
|
|
94
|
+
// 设置选项
|
|
95
|
+
commander.options.forEach(option => {
|
|
96
|
+
cmd.option(`-${option.alias}`, option.description);
|
|
97
|
+
cmd.option(`--${option.name}`, option.description);
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
cmd.action(() => co(() => executor(commander.options)));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* ## `Ec.executeEnd`
|
|
106
|
+
*
|
|
107
|
+
* @memberOf module:_epic
|
|
108
|
+
* 执行命令时打印尾信息
|
|
109
|
+
*/
|
|
110
|
+
const executeEnd = () => {
|
|
111
|
+
program.parse(process.argv);
|
|
112
|
+
};
|
|
113
|
+
module.exports = {
|
|
114
|
+
executeHeader,
|
|
115
|
+
executeBody,
|
|
116
|
+
executeEnd,
|
|
117
|
+
};
|