mm_machine 2.0.7 → 2.0.9
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 +17 -17
- package/item.js +11 -11
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -75,7 +75,7 @@ class Index {
|
|
|
75
75
|
|
|
76
76
|
return ret;
|
|
77
77
|
} catch (err) {
|
|
78
|
-
$.log.error(
|
|
78
|
+
$.log.error(`[${this.type}] 执行模块方法失败: `, err);
|
|
79
79
|
return null;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -102,7 +102,7 @@ Index.prototype.Drive = Item;
|
|
|
102
102
|
*/
|
|
103
103
|
Index.prototype.loadItem = async function(dir, cg, file) {
|
|
104
104
|
if (!dir || !file) {
|
|
105
|
-
$.log.error(
|
|
105
|
+
$.log.error(`[${this.type}] load: 缺少必要参数`);
|
|
106
106
|
return null;
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -132,8 +132,8 @@ Index.prototype.loadItem = async function(dir, cg, file) {
|
|
|
132
132
|
}
|
|
133
133
|
return json;
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
$.log.error(
|
|
135
|
+
} catch (err) {
|
|
136
|
+
$.log.error(`[${this.type}] 加载项失败: `, err);
|
|
137
137
|
return null;
|
|
138
138
|
}
|
|
139
139
|
};
|
|
@@ -146,7 +146,7 @@ Index.prototype.loadItem = async function(dir, cg, file) {
|
|
|
146
146
|
Index.prototype.loads = async function(list) {
|
|
147
147
|
// 遍历文件路径
|
|
148
148
|
if (!Array.isArray(list)) {
|
|
149
|
-
$.log.error(
|
|
149
|
+
$.log.error(`[${this.type}] loads: 列表参数必须是数组`);
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
152
|
|
|
@@ -204,7 +204,7 @@ Index.prototype.updateConfigAll = async function(searchPath, accurate) {
|
|
|
204
204
|
// 这样可以确保找到test1和test2目录
|
|
205
205
|
list_scope = $.dir.getAll(normalizedPath);
|
|
206
206
|
} catch (err) {
|
|
207
|
-
$.log.error(
|
|
207
|
+
$.log.error(`[${this.type}] 检索目录失败!`, err);
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
// 处理找到的目录
|
|
@@ -224,7 +224,7 @@ Index.prototype.updateConfigAll = async function(searchPath, accurate) {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
} catch (err) {
|
|
227
|
-
$.log.error(
|
|
227
|
+
$.log.error(`[${this.type}] 更新所有配置失败: `, err);
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
230
|
|
|
@@ -252,7 +252,7 @@ Index.prototype.updateConfigHave = async function(dir) {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
} catch (err) {
|
|
255
|
-
$.log.error(
|
|
255
|
+
$.log.error(`[${this.type}] 更新配置失败: `, err);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
}
|
|
@@ -276,7 +276,7 @@ Index.prototype.updateConfig = async function(dir, accurate = false, clear = fal
|
|
|
276
276
|
}
|
|
277
277
|
this.sort();
|
|
278
278
|
} catch (err) {
|
|
279
|
-
$.log.error(
|
|
279
|
+
$.log.error(`[${this.type}] 配置更新失败: `, err);
|
|
280
280
|
}
|
|
281
281
|
};
|
|
282
282
|
|
|
@@ -357,7 +357,7 @@ Index.prototype.save = async function() {
|
|
|
357
357
|
try {
|
|
358
358
|
await o.exec('save');
|
|
359
359
|
} catch (err) {
|
|
360
|
-
$.log.error(
|
|
360
|
+
$.log.error(`[${this.type}] 保存失败: `, err);
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
363
|
return true;
|
|
@@ -370,7 +370,7 @@ Index.prototype.save = async function() {
|
|
|
370
370
|
*/
|
|
371
371
|
Index.prototype.add = async function(config) {
|
|
372
372
|
if (!config || !config.name) {
|
|
373
|
-
$.log.error(
|
|
373
|
+
$.log.error(`[${this.type}] 添加插件失败: 缺少必要的配置信息`);
|
|
374
374
|
return null;
|
|
375
375
|
}
|
|
376
376
|
|
|
@@ -387,7 +387,7 @@ Index.prototype.add = async function(config) {
|
|
|
387
387
|
this.sort();
|
|
388
388
|
return item;
|
|
389
389
|
} catch (err) {
|
|
390
|
-
$.log.error(
|
|
390
|
+
$.log.error(`[${this.type}] 添加插件失败: `, err);
|
|
391
391
|
return null;
|
|
392
392
|
}
|
|
393
393
|
};
|
|
@@ -409,7 +409,7 @@ Index.prototype.del = async function(name) {
|
|
|
409
409
|
this.list.splice(index, 1);
|
|
410
410
|
return true;
|
|
411
411
|
} catch (err) {
|
|
412
|
-
$.log.error(
|
|
412
|
+
$.log.error(`[${this.type}] 删除插件失败: `, err);
|
|
413
413
|
return false;
|
|
414
414
|
}
|
|
415
415
|
};
|
|
@@ -431,7 +431,7 @@ Index.prototype.load = async function(name) {
|
|
|
431
431
|
}
|
|
432
432
|
return item;
|
|
433
433
|
} catch (err) {
|
|
434
|
-
$.log.error(
|
|
434
|
+
$.log.error(`[${this.type}] 加载插件 ${name} 失败: `, err);
|
|
435
435
|
return null;
|
|
436
436
|
}
|
|
437
437
|
};
|
|
@@ -451,7 +451,7 @@ Index.prototype.unload = async function(name) {
|
|
|
451
451
|
await item.exec('unload');
|
|
452
452
|
return true;
|
|
453
453
|
} catch (err) {
|
|
454
|
-
$.log.error(
|
|
454
|
+
$.log.error(`[${this.type}] 卸载插件 ${name} 失败: `, err);
|
|
455
455
|
return false;
|
|
456
456
|
}
|
|
457
457
|
};
|
|
@@ -471,7 +471,7 @@ Index.prototype.reload = async function(name) {
|
|
|
471
471
|
await item.exec('reload');
|
|
472
472
|
return item;
|
|
473
473
|
} catch (err) {
|
|
474
|
-
$.log.error(
|
|
474
|
+
$.log.error(`[${this.type}] 重新加载插件 ${name} 失败: `, err);
|
|
475
475
|
return null;
|
|
476
476
|
}
|
|
477
477
|
};
|
|
@@ -503,7 +503,7 @@ Index.prototype.loadFile = async function(file, create = false) {
|
|
|
503
503
|
}
|
|
504
504
|
return null;
|
|
505
505
|
} catch (err) {
|
|
506
|
-
$.log.error(
|
|
506
|
+
$.log.error(`[${this.type}] 加载文件失败: `, err);
|
|
507
507
|
return `加载文件失败: ${err.message}`;
|
|
508
508
|
}
|
|
509
509
|
};
|
package/item.js
CHANGED
|
@@ -165,7 +165,7 @@ Item.prototype._remove = function (module) {
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
} catch (err) {
|
|
168
|
-
$.log.error(
|
|
168
|
+
$.log.error(`[${this.config.name}] 移除模块失败: `, err);
|
|
169
169
|
}
|
|
170
170
|
};
|
|
171
171
|
|
|
@@ -268,7 +268,7 @@ Item.prototype.loadScript = function (file, name = '') {
|
|
|
268
268
|
|
|
269
269
|
return cs;
|
|
270
270
|
} catch (err) {
|
|
271
|
-
$.log.error(
|
|
271
|
+
$.log.error(`[${this.config.name}] 加载脚本失败: `, err);
|
|
272
272
|
return null;
|
|
273
273
|
}
|
|
274
274
|
};
|
|
@@ -325,7 +325,7 @@ Item.prototype.loadFile = function (file, name) {
|
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
} catch (err) {
|
|
328
|
-
$.log.error(
|
|
328
|
+
$.log.error(`[${this.config.name}] 配置热更新失败: `, err);
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
}.bind(this));
|
|
@@ -344,7 +344,7 @@ Item.prototype.loadFile = function (file, name) {
|
|
|
344
344
|
this.filename = fullPath;
|
|
345
345
|
return config;
|
|
346
346
|
} catch (err) {
|
|
347
|
-
$.log.error(
|
|
347
|
+
$.log.error(`[${this.config.name}] 加载配置文件失败: `, err);
|
|
348
348
|
return null;
|
|
349
349
|
}
|
|
350
350
|
};
|
|
@@ -399,7 +399,7 @@ Item.prototype.removeFile = function () {
|
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
401
|
} catch (err) {
|
|
402
|
-
$.log.error(
|
|
402
|
+
$.log.error(`[${this.config.name}] 删除文件失败: `, err);
|
|
403
403
|
errorMessage = `删除失败: ${err.message}`;
|
|
404
404
|
}
|
|
405
405
|
return errorMessage;
|
|
@@ -426,7 +426,7 @@ Item.prototype.loadConfig = function (configData, name) {
|
|
|
426
426
|
this.setConfig(config);
|
|
427
427
|
this.setConfig_after();
|
|
428
428
|
} catch (err) {
|
|
429
|
-
$.log.error(
|
|
429
|
+
$.log.error(`[${this.config.name}] 载入配置失败: `, err);
|
|
430
430
|
}
|
|
431
431
|
};
|
|
432
432
|
|
|
@@ -440,7 +440,7 @@ Item.prototype.load_before = async function () {
|
|
|
440
440
|
this.complete = true;
|
|
441
441
|
}
|
|
442
442
|
} catch (err) {
|
|
443
|
-
$.log.error(
|
|
443
|
+
$.log.error(`[${this.config.name}] 加载前处理失败: `, err);
|
|
444
444
|
this.complete = false;
|
|
445
445
|
}
|
|
446
446
|
};
|
|
@@ -490,7 +490,7 @@ Item.prototype.save = function () {
|
|
|
490
490
|
// 单对象格式配置,直接保存
|
|
491
491
|
fullPath.saveText(JSON.stringify(this.config, null, 4));
|
|
492
492
|
} catch (err) {
|
|
493
|
-
$.log.error(
|
|
493
|
+
$.log.error(`[${this.config.name}] 保存配置失败: `, err);
|
|
494
494
|
}
|
|
495
495
|
};
|
|
496
496
|
|
|
@@ -547,7 +547,7 @@ Item.prototype.exec = async function (method, ...params) {
|
|
|
547
547
|
result = await result;
|
|
548
548
|
}
|
|
549
549
|
} catch (err) {
|
|
550
|
-
$.log.error(
|
|
550
|
+
$.log.error(`[${this.config.name}] 执行前置钩子 ${beforeMethod} 失败: `, err);
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
553
|
|
|
@@ -573,11 +573,11 @@ Item.prototype.exec = async function (method, ...params) {
|
|
|
573
573
|
result = afterResult;
|
|
574
574
|
}
|
|
575
575
|
} catch (err) {
|
|
576
|
-
$.log.error(
|
|
576
|
+
$.log.error(`[${this.config.name}] 执行后置钩子 ${afterMethod} 失败: `, err);
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
579
|
} catch (err) {
|
|
580
|
-
$.log.error(
|
|
580
|
+
$.log.error(`[${this.config.name}] 执行方法 ${method} 失败: `, err);
|
|
581
581
|
return null;
|
|
582
582
|
}
|
|
583
583
|
return result;
|