mm_machine 2.5.6 → 2.5.7

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.
Files changed (3) hide show
  1. package/drive.js +14 -2
  2. package/index.js +11 -0
  3. package/package.json +4 -4
package/drive.js CHANGED
@@ -418,16 +418,28 @@ Drive.prototype.getModel = function (type) {
418
418
  /**
419
419
  * 创建配置文件
420
420
  * @param {string} file 目标文件路径
421
+ * @param {object} model 模块模型
421
422
  * @returns {string} 配置文件内容
422
423
  */
423
- Drive.prototype._createConfigFile = function (file) {
424
+ Drive.prototype._createConfigFile = function (file, model) {
424
425
  var tpl = this._getConfigTpl();
425
- var content = $.tpl.render(tpl, this.getModel('config'));
426
+ var content = $.tpl.render(tpl, model || this.getModel('config'));
426
427
  let code = this.prettyCode(content, 'json');
427
428
  file.saveText(code);
428
429
  return file;
429
430
  };
430
431
 
432
+ /**
433
+ * 创建配置文件
434
+ * @param {string} file 目标文件路径
435
+ * @param {object} model 模块模型
436
+ * @returns {string} 配置文件内容
437
+ */
438
+ Drive.prototype.createConfigFile = function (file, model) {
439
+ file.addDir();
440
+ return this._createConfigFile(file, model);
441
+ };
442
+
431
443
  /**
432
444
  * 获取配置模板
433
445
  * @returns {string} 配置模板内容
package/index.js CHANGED
@@ -900,6 +900,17 @@ Manager.prototype.offEvent = function (event) {
900
900
  this.getEventer()?.off(event);
901
901
  };
902
902
 
903
+ /**
904
+ * 创建模块
905
+ * @param {Object} config 模块配置
906
+ */
907
+ Manager.prototype.createFile = function (config) {
908
+ let mod = new this.Drive(config, this);
909
+ let file = `${config.name}/${this.config.filename}`.fullname(this.config.dir);
910
+ mod.createConfigFile(file, config);
911
+ return mod;
912
+ };
913
+
903
914
  module.exports = {
904
915
  Manager,
905
916
  Drive,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "2.5.6",
3
+ "version": "2.5.7",
4
4
  "description": "A flexible Node.js plugin mechanism system for dynamic loading, management and execution of modules. Supports hot reload, lifecycle management, and modern JavaScript features.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -34,12 +34,12 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@prettier/sync": "^0.6.1",
37
- "mm_config": "^2.3.1",
38
- "mm_hot_reload": "^1.3.1",
37
+ "mm_config": "^2.3.2",
38
+ "mm_hot_reload": "^1.3.2",
39
39
  "mm_tpl": "^2.5.0"
40
40
  },
41
41
  "devDependencies": {
42
- "eslint": "^10.2.0",
42
+ "eslint": "^10.2.1",
43
43
  "eslint-plugin-jsdoc": "^62.9.0",
44
44
  "mm_eslint": "^1.7.1"
45
45
  }