mm_config 2.5.3 → 2.8.0
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/index.js +10 -6
- package/lib/run_path_logic.js +134 -0
- package/lib/tools/config/index.js +100 -0
- package/lib/tools/get_run_path/index.js +7 -0
- package/lib/tools/index.js +16 -0
- package/lib/tools/path/index.js +147 -0
- package/package.json +63 -59
- package/tool/config/index.js +7 -0
- package/tool/config/tool.json +80 -0
- package/tool/get_run_path/index.js +7 -0
- package/tool/get_run_path/tool.json +49 -0
- package/tool/path/index.js +7 -0
- package/tool/path/tool.json +99 -0
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { reg } = require('mm_admin');
|
|
2
2
|
const Config = require('./lib/config.js');
|
|
3
3
|
const all = require('./lib/conf.js');
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const admin = reg('config');
|
|
6
6
|
admin.setClass(Config);
|
|
7
7
|
|
|
8
8
|
module.exports = {
|
|
@@ -10,9 +10,13 @@ module.exports = {
|
|
|
10
10
|
Config,
|
|
11
11
|
admin,
|
|
12
12
|
configAdmin(scope, config) {
|
|
13
|
-
|
|
14
|
-
scope = 'os';
|
|
15
|
-
}
|
|
16
|
-
return admin.get(scope, config);
|
|
13
|
+
return admin.get(scope || 'os', config);
|
|
17
14
|
}
|
|
18
15
|
};
|
|
16
|
+
|
|
17
|
+
/* mm-tool-logic-export 工具能力层:其它模块可 require("<pkg>").tools.<name> 直接引用 */
|
|
18
|
+
Object.defineProperty(module.exports, 'tools', { enumerable: true, configurable: true,
|
|
19
|
+
get: function () { return require('./lib/tools'); } });
|
|
20
|
+
|
|
21
|
+
/* S1 能力下沉:业务实现可在模块之间直接引用(不经过工具注册面) */
|
|
22
|
+
Object.defineProperty(module.exports, 'runPathLogic', { enumerable: true, value: require('./lib/run_path_logic.js') });
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* get_run_path - 获取当前程序运行根目录
|
|
3
|
+
*
|
|
4
|
+
* 检测当前运行路径是否为mm_os项目,若是则返回关键路径信息,
|
|
5
|
+
* 方便智能体直接在当前项目下开发插件/应用/API等模块。
|
|
6
|
+
*/
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 判断指定目录是否为mm_os项目
|
|
12
|
+
*/
|
|
13
|
+
function checkIsMmOs(dir_path) {
|
|
14
|
+
// 检测指标1: index.js中存在 MM_os 或 require('mm_os')
|
|
15
|
+
const index_js_path = path.join(dir_path, 'index.js');
|
|
16
|
+
if (fs.existsSync(index_js_path)) {
|
|
17
|
+
try {
|
|
18
|
+
const content = fs.readFileSync(index_js_path, 'utf-8');
|
|
19
|
+
if (content.includes('MM_os') || content.includes("require('mm_os')") || content.includes('require("mm_os")')) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
} catch (e) {
|
|
23
|
+
// 忽略读取错误
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 检测指标2: node_modules/mm_os 存在
|
|
28
|
+
const mm_os_module_path = path.join(dir_path, 'node_modules', 'mm_os');
|
|
29
|
+
if (fs.existsSync(mm_os_module_path)) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 检测指标3: app/ 目录 + config/ 目录同时存在(典型mm_os结构)
|
|
34
|
+
const app_path = path.join(dir_path, 'app');
|
|
35
|
+
const config_path = path.join(dir_path, 'config');
|
|
36
|
+
if (fs.existsSync(app_path) && fs.existsSync(config_path)) {
|
|
37
|
+
// 进一步验证:检查app下是否有多个应用模块目录
|
|
38
|
+
try {
|
|
39
|
+
const apps = fs.readdirSync(app_path);
|
|
40
|
+
const has_app_modules = apps.some(name => {
|
|
41
|
+
const app_dir = path.join(app_path, name);
|
|
42
|
+
return fs.statSync(app_dir).isDirectory() &&
|
|
43
|
+
(fs.existsSync(path.join(app_dir, 'app.json')) || fs.existsSync(path.join(app_dir, 'index.js')));
|
|
44
|
+
});
|
|
45
|
+
if (has_app_modules) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
} catch (e) {
|
|
49
|
+
// 忽略
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 获取mm_os版本号
|
|
58
|
+
*/
|
|
59
|
+
function getMmOsVersion(dir_path) {
|
|
60
|
+
try {
|
|
61
|
+
const pkg_path = path.join(dir_path, 'node_modules', 'mm_os', 'package.json');
|
|
62
|
+
if (fs.existsSync(pkg_path)) {
|
|
63
|
+
const pkg = JSON.parse(fs.readFileSync(pkg_path, 'utf-8'));
|
|
64
|
+
return pkg.version || '';
|
|
65
|
+
}
|
|
66
|
+
} catch (e) {
|
|
67
|
+
// 忽略
|
|
68
|
+
}
|
|
69
|
+
return '';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 获取mm_os项目的关键子目录路径
|
|
74
|
+
*/
|
|
75
|
+
function getProjectPaths(dir_path) {
|
|
76
|
+
return {
|
|
77
|
+
app: path.join(dir_path, 'app'),
|
|
78
|
+
config: path.join(dir_path, 'config'),
|
|
79
|
+
com: path.join(dir_path, 'com'),
|
|
80
|
+
static: path.join(dir_path, 'static')
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 主函数
|
|
86
|
+
*/
|
|
87
|
+
async function main(params, ctx, options) {
|
|
88
|
+
try {
|
|
89
|
+
const check_only = params && params.check_only === true;
|
|
90
|
+
const run_path = process.cwd() + path.sep;
|
|
91
|
+
|
|
92
|
+
// 检测是否为mm_os项目
|
|
93
|
+
const is_mm_os = checkIsMmOs(run_path);
|
|
94
|
+
|
|
95
|
+
let result = {
|
|
96
|
+
run_path: run_path,
|
|
97
|
+
is_mm_os: is_mm_os,
|
|
98
|
+
code: 0,
|
|
99
|
+
msg: is_mm_os ? '当前为mm_os项目' : '当前不是mm_os项目'
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
if (is_mm_os && !check_only) {
|
|
103
|
+
// 获取mm_os版本
|
|
104
|
+
result.mm_os_version = getMmOsVersion(run_path);
|
|
105
|
+
|
|
106
|
+
// 获取关键子目录路径
|
|
107
|
+
const sub_paths = getProjectPaths(run_path);
|
|
108
|
+
result.paths = {};
|
|
109
|
+
|
|
110
|
+
// 只返回实际存在的目录
|
|
111
|
+
for (const [key, dir_path] of Object.entries(sub_paths)) {
|
|
112
|
+
if (fs.existsSync(dir_path)) {
|
|
113
|
+
result.paths[key] = dir_path;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return result;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
return {
|
|
121
|
+
run_path: process.cwd(),
|
|
122
|
+
is_mm_os: false,
|
|
123
|
+
code: -1,
|
|
124
|
+
msg: '获取运行路径失败: ' + error.message,
|
|
125
|
+
error: {
|
|
126
|
+
name: error.name,
|
|
127
|
+
message: error.message,
|
|
128
|
+
stack: error.stack
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
exports.main = main;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
const mm_config = require('mm_config');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 配置管理器
|
|
5
|
+
* 基于 mm_config 实现文件持久化配置,支持 scope 命名空间
|
|
6
|
+
* @param {object} ctx 上下文对象
|
|
7
|
+
* @param {object} params 步骤参数
|
|
8
|
+
*/
|
|
9
|
+
async function main(params, ctx, options) {
|
|
10
|
+
var action = params.action || 'get';
|
|
11
|
+
var key = params.key;
|
|
12
|
+
var value = params.value;
|
|
13
|
+
var scope = params.scope || 'default';
|
|
14
|
+
|
|
15
|
+
var file_path = _getFilePath(params, this);
|
|
16
|
+
// 从磁盘加载已有配置,避免每次 create 新建空配置导致数据丢失
|
|
17
|
+
var loaded = {};
|
|
18
|
+
try {
|
|
19
|
+
loaded = file_path.loadJson() || {};
|
|
20
|
+
} catch (_e) {
|
|
21
|
+
void _e;
|
|
22
|
+
}
|
|
23
|
+
var config = mm_config.create(file_path, loaded);
|
|
24
|
+
|
|
25
|
+
var scope_obj;
|
|
26
|
+
switch (action) {
|
|
27
|
+
case 'get':
|
|
28
|
+
scope_obj = config[scope] || {};
|
|
29
|
+
ctx.output = { obj: scope_obj[key] };
|
|
30
|
+
break;
|
|
31
|
+
case 'list':
|
|
32
|
+
scope_obj = config[scope] || {};
|
|
33
|
+
ctx.output = { list: Object.keys(scope_obj), count: Object.keys(scope_obj).length };
|
|
34
|
+
break;
|
|
35
|
+
case 'values':
|
|
36
|
+
scope_obj = config[scope] || {};
|
|
37
|
+
ctx.output = { list: Object.values(scope_obj), count: Object.keys(scope_obj).length };
|
|
38
|
+
break;
|
|
39
|
+
case 'set':
|
|
40
|
+
scope_obj = config[scope] || {};
|
|
41
|
+
scope_obj[key] = value;
|
|
42
|
+
config[scope] = scope_obj;
|
|
43
|
+
ctx.output = { msg: '配置设置成功' };
|
|
44
|
+
break;
|
|
45
|
+
case 'update':
|
|
46
|
+
scope_obj = config[scope] || {};
|
|
47
|
+
scope_obj[key] = { ...(scope_obj[key] || {}), ...value };
|
|
48
|
+
config[scope] = scope_obj;
|
|
49
|
+
ctx.output = { msg: '配置更新成功' };
|
|
50
|
+
break;
|
|
51
|
+
case 'clear':
|
|
52
|
+
config[scope] = {};
|
|
53
|
+
ctx.output = { msg: '配置清空成功' };
|
|
54
|
+
break;
|
|
55
|
+
case 'del':
|
|
56
|
+
scope_obj = config[scope] || {};
|
|
57
|
+
if (key in scope_obj) {
|
|
58
|
+
delete scope_obj[key];
|
|
59
|
+
config[scope] = scope_obj;
|
|
60
|
+
ctx.output = { msg: '配置删除成功' };
|
|
61
|
+
} else {
|
|
62
|
+
ctx.output = { msg: '配置删除失败' };
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
case 'has':
|
|
66
|
+
scope_obj = config[scope] || {};
|
|
67
|
+
ctx.output = { obj: key in scope_obj };
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
ctx.output = {
|
|
71
|
+
error: { code: 'MGR_UNKNOWN_ACTION', message: '不支持的操作: ' + action }
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return ctx.output;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 获取配置文件路径
|
|
80
|
+
* 优先从 params.file_path 获取,fallback 到模块 options 配置
|
|
81
|
+
* @param {object} params 步骤参数
|
|
82
|
+
* @param {object} ctx_this 模块上下文
|
|
83
|
+
* @returns {string} 配置文件路径
|
|
84
|
+
*/
|
|
85
|
+
function _getFilePath(params, ctx_this) {
|
|
86
|
+
var opts = (ctx_this && ctx_this.config && ctx_this.config.options) || {};
|
|
87
|
+
var default_path = './config';
|
|
88
|
+
if (
|
|
89
|
+
opts.file_path &&
|
|
90
|
+
typeof opts.file_path === 'object' &&
|
|
91
|
+
opts.file_path.default !== undefined
|
|
92
|
+
) {
|
|
93
|
+
default_path = opts.file_path.default;
|
|
94
|
+
} else if (opts.file_path) {
|
|
95
|
+
default_path = opts.file_path;
|
|
96
|
+
}
|
|
97
|
+
return params.file_path || default_path;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
module.exports = { main };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
/** 模块能力层:懒加载工具实现,避免模块入口被 require 时加载全部实现 */
|
|
5
|
+
module.exports = new Proxy({}, {
|
|
6
|
+
get(_t, key) {
|
|
7
|
+
if (typeof key !== 'string') return undefined;
|
|
8
|
+
if (!fs.existsSync(path.join(__dirname, key, 'index.js'))) return undefined;
|
|
9
|
+
return require('./' + key);
|
|
10
|
+
},
|
|
11
|
+
has(_t, key) {
|
|
12
|
+
return typeof key === 'string' && fs.existsSync(path.join(__dirname, key, 'index.js'));
|
|
13
|
+
},
|
|
14
|
+
ownKeys() { return fs.readdirSync(__dirname, { withFileTypes: true }).filter(e => e.isDirectory()).map(e => e.name); },
|
|
15
|
+
getOwnPropertyDescriptor(_t, key) { return this.has(_t, key) ? { enumerable: true, configurable: true } : undefined; }
|
|
16
|
+
});
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 路径查询器
|
|
3
|
+
* 获取应用运行路径、当前模块根路径、项目模块目录等关键路径,
|
|
4
|
+
* 支持相对路径转绝对路径与存在性判断
|
|
5
|
+
* 运行路径读取本包 configAdmin('os') 的 run_path 配置,缺省回落到 process.cwd()
|
|
6
|
+
* @param {object} params 步骤参数
|
|
7
|
+
* @param {object} ctx 上下文对象
|
|
8
|
+
* @param {object} options 模块配置
|
|
9
|
+
* @returns {object} 查询结果
|
|
10
|
+
*/
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const { configAdmin } = require('../../../index.js');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 获取应用运行路径
|
|
17
|
+
* @returns {Promise<string>} 应用运行路径
|
|
18
|
+
*/
|
|
19
|
+
async function _getRunPath() {
|
|
20
|
+
var run_path = (await configAdmin('os').get('run_path')) || '';
|
|
21
|
+
return run_path || process.cwd();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 获取当前模块根路径
|
|
26
|
+
* 优先取模块 options.self_path 配置,缺省回落到应用运行路径
|
|
27
|
+
* @param {object} mod 模块实例(this)
|
|
28
|
+
* @returns {Promise<string>} 模块根路径
|
|
29
|
+
*/
|
|
30
|
+
async function _getSelfPath(mod) {
|
|
31
|
+
var opts = (mod && typeof mod.getOptions === 'function' && mod.getOptions()) || {};
|
|
32
|
+
if (opts.self_path) return opts.self_path;
|
|
33
|
+
return await _getRunPath();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 获取应用运行路径下的子目录
|
|
38
|
+
* @param {string} sub 子路径
|
|
39
|
+
* @returns {Promise<string>} 子目录绝对路径
|
|
40
|
+
*/
|
|
41
|
+
async function _getAppSubPath(sub) {
|
|
42
|
+
return path.join(await _getRunPath(), sub);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 相对路径转绝对路径,绝对路径原样返回
|
|
47
|
+
* base 为 self 时基于当前模块根路径解析,否则基于应用运行路径
|
|
48
|
+
* @param {string} target 目标路径
|
|
49
|
+
* @param {string} base 基准目录: run/self
|
|
50
|
+
* @param {string} self_path 当前模块根路径
|
|
51
|
+
* @returns {Promise<string>} 绝对路径
|
|
52
|
+
*/
|
|
53
|
+
async function _getAbsolute(target, base, self_path) {
|
|
54
|
+
if (path.isAbsolute(target)) return target;
|
|
55
|
+
var root = base === 'self' ? self_path : await _getRunPath();
|
|
56
|
+
return path.resolve(root, target);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 判断路径是否存在
|
|
61
|
+
* @param {string} file_path 文件路径
|
|
62
|
+
* @returns {boolean} 是否存在
|
|
63
|
+
*/
|
|
64
|
+
function _exists(file_path) {
|
|
65
|
+
try {
|
|
66
|
+
return fs.existsSync(file_path);
|
|
67
|
+
} catch (_e) {
|
|
68
|
+
void _e;
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 获取全部关键路径
|
|
75
|
+
* @param {string} self_path 当前模块根路径
|
|
76
|
+
* @returns {Promise<object>} 路径集合对象
|
|
77
|
+
*/
|
|
78
|
+
async function _getAllPaths(self_path) {
|
|
79
|
+
var run_path = await _getRunPath();
|
|
80
|
+
return {
|
|
81
|
+
run_path: run_path,
|
|
82
|
+
module_dir: path.join(run_path, 'common', 'mod'),
|
|
83
|
+
workflow_dir: path.join(run_path, 'common', 'workflow'),
|
|
84
|
+
script_dir: path.join(run_path, 'common', 'script'),
|
|
85
|
+
templates_dir: path.join(run_path, 'templates'),
|
|
86
|
+
data_dir: path.join(run_path, 'data'),
|
|
87
|
+
self_path: self_path,
|
|
88
|
+
self_module_dir: path.join(self_path, 'common', 'mod'),
|
|
89
|
+
self_templates_dir: path.join(self_path, 'templates')
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function main(params, ctx, options) {
|
|
94
|
+
var action = params.action || 'info';
|
|
95
|
+
var target = params.target || '';
|
|
96
|
+
var base = params.base || 'run';
|
|
97
|
+
var self_path = await _getSelfPath(this);
|
|
98
|
+
|
|
99
|
+
switch (action) {
|
|
100
|
+
case 'info':
|
|
101
|
+
ctx.output = await _getAllPaths(self_path);
|
|
102
|
+
break;
|
|
103
|
+
case 'run':
|
|
104
|
+
ctx.output = { path: await _getRunPath() };
|
|
105
|
+
break;
|
|
106
|
+
case 'module':
|
|
107
|
+
ctx.output = { path: await _getAppSubPath('common/mod') };
|
|
108
|
+
break;
|
|
109
|
+
case 'workflow':
|
|
110
|
+
ctx.output = { path: await _getAppSubPath('common/workflow') };
|
|
111
|
+
break;
|
|
112
|
+
case 'script':
|
|
113
|
+
ctx.output = { path: await _getAppSubPath('common/script') };
|
|
114
|
+
break;
|
|
115
|
+
case 'templates':
|
|
116
|
+
ctx.output = { path: await _getAppSubPath('templates') };
|
|
117
|
+
break;
|
|
118
|
+
case 'data':
|
|
119
|
+
ctx.output = { path: await _getAppSubPath('data') };
|
|
120
|
+
break;
|
|
121
|
+
case 'self':
|
|
122
|
+
ctx.output = { path: self_path };
|
|
123
|
+
break;
|
|
124
|
+
case 'self_module':
|
|
125
|
+
ctx.output = { path: path.join(self_path, 'common', 'mod') };
|
|
126
|
+
break;
|
|
127
|
+
case 'self_templates':
|
|
128
|
+
ctx.output = { path: path.join(self_path, 'templates') };
|
|
129
|
+
break;
|
|
130
|
+
case 'absolute': {
|
|
131
|
+
var abs_path = await _getAbsolute(target, base, self_path);
|
|
132
|
+
ctx.output = { path: abs_path, exists: _exists(abs_path) };
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case 'exists':
|
|
136
|
+
ctx.output = { obj: _exists(await _getAbsolute(target, base, self_path)) };
|
|
137
|
+
break;
|
|
138
|
+
default:
|
|
139
|
+
ctx.output = {
|
|
140
|
+
error: { code: 'QUERY_UNKNOWN_ACTION', message: '不支持的操作: ' + action }
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return ctx.output;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
module.exports = { main };
|
package/package.json
CHANGED
|
@@ -1,59 +1,63 @@
|
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "mm_config",
|
|
3
|
+
"version": "2.8.0",
|
|
4
|
+
"description": "Super Meimei Configuration Synchronizer - Automatically sync configuration changes to JSON files",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "node test.js",
|
|
8
|
+
"lint": "eslint index.js",
|
|
9
|
+
"lint:fix": "eslint index.js --fix"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://gitee.com/qiuwenwu91/mm_config.git"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"mm_mod",
|
|
17
|
+
"mm_infra",
|
|
18
|
+
"mm_config",
|
|
19
|
+
"config",
|
|
20
|
+
"JSON",
|
|
21
|
+
"file",
|
|
22
|
+
"sync",
|
|
23
|
+
"async",
|
|
24
|
+
"debounce",
|
|
25
|
+
"json5",
|
|
26
|
+
"configuration",
|
|
27
|
+
"settings",
|
|
28
|
+
"automation"
|
|
29
|
+
],
|
|
30
|
+
"layer": "infrastructure",
|
|
31
|
+
"group": "state",
|
|
32
|
+
"author": "邱文武",
|
|
33
|
+
"license": "ISC",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://gitee.com/qiuwenwu91/mm_config/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://gitee.com/qiuwenwu91/mm_config#readme",
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=14.0.0"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"index.js",
|
|
43
|
+
"lib",
|
|
44
|
+
"tool",
|
|
45
|
+
"ai_tool",
|
|
46
|
+
"README.md",
|
|
47
|
+
"README_EN.md",
|
|
48
|
+
"LICENSE"
|
|
49
|
+
],
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"mm_admin": "^1.1.0",
|
|
52
|
+
"mm_eslint": "^1.0.0",
|
|
53
|
+
"mm_helper": "^1.0.0",
|
|
54
|
+
"mm_kv_store": "^1.0.0",
|
|
55
|
+
"mm_mod": "^1.0.1",
|
|
56
|
+
"mm_os": "^1.0.0"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"eslint": "^10.9.1",
|
|
60
|
+
"eslint-plugin-jsdoc": "^64.2.1",
|
|
61
|
+
"mm_eslint": "^1.7.7"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "config",
|
|
3
|
+
"handler": "manager",
|
|
4
|
+
"title": "配置管理器",
|
|
5
|
+
"description": "管理系统配置项的读取与更新。适用场景:需要动态读写全局或分组的键值配置时。工作流提示:action 选 get/set/update/list/values/clear/del/has,scope 指定分组作用域,key 指定配置键、value 传配置值,读取结果在 obj/list、写入结果在 msg。",
|
|
6
|
+
"type": "data",
|
|
7
|
+
"params": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"action": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "操作类型: get/set/update/list/values/clear/del/has",
|
|
13
|
+
"enum": [
|
|
14
|
+
"get",
|
|
15
|
+
"set",
|
|
16
|
+
"update",
|
|
17
|
+
"list",
|
|
18
|
+
"values",
|
|
19
|
+
"clear",
|
|
20
|
+
"del",
|
|
21
|
+
"has"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"scope": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "配置分组作用域",
|
|
27
|
+
"default": "default"
|
|
28
|
+
},
|
|
29
|
+
"key": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "配置键"
|
|
32
|
+
},
|
|
33
|
+
"value": {
|
|
34
|
+
"description": "配置值(set时必填)"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"required": [
|
|
38
|
+
"action"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"returns": {
|
|
42
|
+
"description": "管理操作结果,读操作返回 obj 或 list+count,写操作返回 msg,异常时返回 error",
|
|
43
|
+
"type": "object",
|
|
44
|
+
"properties": {
|
|
45
|
+
"obj": {
|
|
46
|
+
"description": "读取操作的单条结果(get/has 操作)"
|
|
47
|
+
},
|
|
48
|
+
"list": {
|
|
49
|
+
"type": "array",
|
|
50
|
+
"description": "列表结果(list 操作)"
|
|
51
|
+
},
|
|
52
|
+
"count": {
|
|
53
|
+
"type": "number",
|
|
54
|
+
"description": "列表条目数(list 操作)"
|
|
55
|
+
},
|
|
56
|
+
"msg": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"description": "写操作的结果描述(set/del 操作)"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"options": {
|
|
63
|
+
"store_type": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"description": "存储方式: file/db/redis",
|
|
66
|
+
"default": "file",
|
|
67
|
+
"enum": [
|
|
68
|
+
"file",
|
|
69
|
+
"db",
|
|
70
|
+
"redis"
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
"file_path": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"description": "配置文件路径(store_type=file时有效)",
|
|
76
|
+
"default": "./config"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"group": "system"
|
|
80
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "get_run_path",
|
|
3
|
+
"title": "获取运行根目录",
|
|
4
|
+
"description": "获取当前程序运行根目录,检测是否为mm_os项目并返回关键路径信息。当需要进行mm_os开发(应用/插件/API接口/定时任务/挂件)时优先调用此工具,判断当前系统是否基于mm_os开发,如果是则直接在当前运行路径下开发所需功能模块。触发关键词:运行路径、根目录、运行目录、项目路径、mm_os路径、项目根目录、检测mm_os",
|
|
5
|
+
"category": "系统工具",
|
|
6
|
+
"group": "system",
|
|
7
|
+
"type": "function",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"params": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"check_only": {
|
|
13
|
+
"type": "boolean",
|
|
14
|
+
"description": "是否仅检查是否为mm_os项目,不返回详细路径信息。设为true只返回is_mm_os判断结果",
|
|
15
|
+
"default": false
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"returns": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"properties": {
|
|
22
|
+
"run_path": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "当前程序运行根目录的绝对路径"
|
|
25
|
+
},
|
|
26
|
+
"is_mm_os": {
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"description": "是否为mm_os框架项目"
|
|
29
|
+
},
|
|
30
|
+
"mm_os_version": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "mm_os框架版本号(安装在node_modules中的mm_os版本),非mm_os项目时为空"
|
|
33
|
+
},
|
|
34
|
+
"paths": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"description": "mm_os项目的关键子目录路径,仅is_mm_os为true时返回"
|
|
37
|
+
},
|
|
38
|
+
"code": {
|
|
39
|
+
"type": "number",
|
|
40
|
+
"description": "状态码,0成功"
|
|
41
|
+
},
|
|
42
|
+
"msg": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"description": "状态信息"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"handler": "manager"
|
|
49
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "path",
|
|
3
|
+
"handler": "querier",
|
|
4
|
+
"title": "路径查询器",
|
|
5
|
+
"description": "获取应用运行路径、当前模块路径、项目模块目录等关键路径,支持相对路径转绝对路径。适用场景:定位项目文件、拼接 SQL 脚本路径、判断资源是否存在。工作流提示:action 选 info/run/module/workflow/script/templates/data/self/self_module/self_templates/absolute/exists,absolute/exists 需传 target 相对路径与 base 基准(run/self),读在 path、exists 在 obj。",
|
|
6
|
+
"type": "core",
|
|
7
|
+
"params": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"action": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"enum": [
|
|
13
|
+
"info",
|
|
14
|
+
"run",
|
|
15
|
+
"module",
|
|
16
|
+
"workflow",
|
|
17
|
+
"script",
|
|
18
|
+
"templates",
|
|
19
|
+
"data",
|
|
20
|
+
"self",
|
|
21
|
+
"self_module",
|
|
22
|
+
"self_templates",
|
|
23
|
+
"absolute",
|
|
24
|
+
"exists"
|
|
25
|
+
],
|
|
26
|
+
"description": "操作类型: info(全部关键路径)/run(应用运行路径)/module(应用模块目录)/workflow(应用工作流目录)/script(应用脚本目录)/templates(应用模板目录)/data(应用数据目录)/self(当前模块根路径)/self_module(当前模块模块目录)/self_templates(当前模块模板目录)/absolute(相对路径转绝对路径)/exists(判断路径是否存在)",
|
|
27
|
+
"default": "info"
|
|
28
|
+
},
|
|
29
|
+
"target": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "目标相对路径(absolute/exists 操作使用,基于 base 基准解析,绝对路径原样返回)"
|
|
32
|
+
},
|
|
33
|
+
"base": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"enum": [
|
|
36
|
+
"run",
|
|
37
|
+
"self"
|
|
38
|
+
],
|
|
39
|
+
"description": "相对路径基准目录: run(应用运行路径)/self(当前模块根路径),默认 run",
|
|
40
|
+
"default": "run"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"returns": {
|
|
45
|
+
"description": "路径获取结果,path 为目录绝对路径,info 返回路径集合对象,exists 返回 obj 布尔值",
|
|
46
|
+
"type": "object",
|
|
47
|
+
"properties": {
|
|
48
|
+
"path": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "绝对路径(run/module/workflow/script/templates/data/self/self_module/self_templates/absolute 操作)"
|
|
51
|
+
},
|
|
52
|
+
"run_path": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "应用运行路径(info 操作)"
|
|
55
|
+
},
|
|
56
|
+
"module_dir": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"description": "应用模块目录(info 操作)"
|
|
59
|
+
},
|
|
60
|
+
"workflow_dir": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"description": "应用工作流目录(info 操作)"
|
|
63
|
+
},
|
|
64
|
+
"script_dir": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"description": "应用脚本目录(info 操作)"
|
|
67
|
+
},
|
|
68
|
+
"templates_dir": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"description": "应用模板目录(info 操作)"
|
|
71
|
+
},
|
|
72
|
+
"data_dir": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"description": "应用数据目录(info 操作)"
|
|
75
|
+
},
|
|
76
|
+
"self_path": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "当前模块根路径(info 操作)"
|
|
79
|
+
},
|
|
80
|
+
"self_module_dir": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"description": "当前模块模块目录(info 操作)"
|
|
83
|
+
},
|
|
84
|
+
"self_templates_dir": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"description": "当前模块模板目录(info 操作)"
|
|
87
|
+
},
|
|
88
|
+
"exists": {
|
|
89
|
+
"type": "boolean",
|
|
90
|
+
"description": "路径是否存在(absolute 操作附带)"
|
|
91
|
+
},
|
|
92
|
+
"obj": {
|
|
93
|
+
"type": "boolean",
|
|
94
|
+
"description": "路径是否存在(exists 操作)"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"group": "system"
|
|
99
|
+
}
|