@jayfong/x-server 1.26.7 → 1.26.8

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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.26.8](https://github.com/jfWorks/x-server/compare/v1.26.7...v1.26.8) (2022-05-07)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * init ([b8f8e44](https://github.com/jfWorks/x-server/commit/b8f8e44ed1cf282293938ab3678796a402832dc2))
11
+
5
12
  ### [1.26.7](https://github.com/jfWorks/x-server/compare/v1.26.6...v1.26.7) (2022-05-07)
6
13
 
7
14
 
@@ -50,7 +50,7 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
50
50
  });
51
51
  }
52
52
 
53
- await _template_util.TemplateUtil.initHelperPackage(process.cwd());
53
+ await _template_util.TemplateUtil.init(process.cwd());
54
54
 
55
55
  const watcher = _chokidar.default.watch(['src', '.env'], {
56
56
  cwd: process.cwd()
@@ -70,7 +70,7 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
70
70
 
71
71
  (0, _vscodeGenerateIndexStandalone.generateManyIndex)({
72
72
  cwd: process.cwd(),
73
- patterns: ['src/**/index.ts', 'node_modules/.x/*.ts', ...(argv.index || [])],
73
+ patterns: ['src/**/index.ts', 'node_modules/.x/*.ts', '!src/handlers/**/*', ...(argv.index || [])],
74
74
  replaceFile: true,
75
75
  onSuccess: filePath => {
76
76
  console.log(`✔️ 索引文件已更新: ${filePath}`);
@@ -107,7 +107,7 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
107
107
  value: 'production',
108
108
  comment: ''
109
109
  });
110
- await _template_util.TemplateUtil.initHelperPackage(process.cwd());
110
+ await _template_util.TemplateUtil.init(process.cwd());
111
111
  await (0, _vscodeGenerateIndexStandalone.generateManyIndex)({
112
112
  cwd: process.cwd(),
113
113
  patterns: ['src/.x/*.ts'],
@@ -14,9 +14,17 @@ var _vtils = require("vtils");
14
14
  var _vscodeGenerateIndexStandalone = require("vscode-generate-index-standalone");
15
15
 
16
16
  class TemplateUtil {
17
+ /**
18
+ * 初始化。
19
+ */
20
+ static async init(cwd) {
21
+ await Promise.all([this.initHelperPackage(cwd), this.initTasks(cwd)]);
22
+ }
17
23
  /**
18
24
  * 初始化辅助包。
19
25
  */
26
+
27
+
20
28
  static async initHelperPackage(cwd) {
21
29
  const fromDir = _path.default.join(__dirname, 'templates');
22
30
 
@@ -31,6 +39,23 @@ class TemplateUtil {
31
39
  replaceFile: true
32
40
  });
33
41
  }
42
+ /**
43
+ * 初始化任务。
44
+ */
45
+
46
+
47
+ static async initTasks(cwd) {
48
+ const tasksDir = _path.default.join(cwd, 'tasks');
49
+
50
+ const tasksIndexFile = _path.default.join(tasksDir, 'index.ts');
51
+
52
+ if (!(await _fsExtra.default.pathExists(tasksIndexFile))) {
53
+ await _fsExtra.default.writeFile(tasksIndexFile, (0, _vtils.dedent)`
54
+ // @index(['./**/*.ts', '!**/*.test.ts', '!**/_*'], f => \`export * from '\${f.path}'\`)
55
+ // @endindex
56
+ `);
57
+ }
58
+ }
34
59
  /**
35
60
  * 初始化模型。
36
61
  */
@@ -1,2 +1 @@
1
- // @index(['../../src/tasks/**/*.ts', '!**/_*'], (f, _) => `import '${f.path}'`)
2
- // @endindex
1
+ import '../../src/tasks/index'
package/lib/cli/cli.js CHANGED
@@ -36,7 +36,7 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
36
36
  });
37
37
  }
38
38
 
39
- await TemplateUtil.initHelperPackage(process.cwd());
39
+ await TemplateUtil.init(process.cwd());
40
40
  const watcher = chokidar.watch(['src', '.env'], {
41
41
  cwd: process.cwd()
42
42
  });
@@ -52,7 +52,7 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
52
52
  });
53
53
  generateManyIndex({
54
54
  cwd: process.cwd(),
55
- patterns: ['src/**/index.ts', 'node_modules/.x/*.ts', ...(argv.index || [])],
55
+ patterns: ['src/**/index.ts', 'node_modules/.x/*.ts', '!src/handlers/**/*', ...(argv.index || [])],
56
56
  replaceFile: true,
57
57
  onSuccess: filePath => {
58
58
  console.log(`✔️ 索引文件已更新: ${filePath}`);
@@ -89,7 +89,7 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
89
89
  value: 'production',
90
90
  comment: ''
91
91
  });
92
- await TemplateUtil.initHelperPackage(process.cwd());
92
+ await TemplateUtil.init(process.cwd());
93
93
  await generateManyIndex({
94
94
  cwd: process.cwd(),
95
95
  patterns: ['src/.x/*.ts'],
@@ -1,8 +1,16 @@
1
1
  export declare class TemplateUtil {
2
+ /**
3
+ * 初始化。
4
+ */
5
+ static init(cwd: string): Promise<void>;
2
6
  /**
3
7
  * 初始化辅助包。
4
8
  */
5
9
  static initHelperPackage(cwd: string): Promise<void>;
10
+ /**
11
+ * 初始化任务。
12
+ */
13
+ static initTasks(cwd: string): Promise<void>;
6
14
  /**
7
15
  * 初始化模型。
8
16
  */
@@ -3,9 +3,17 @@ import path from 'path';
3
3
  import { camelCase, dedent, snakeCase, upperFirst } from 'vtils';
4
4
  import { generateManyIndex } from 'vscode-generate-index-standalone';
5
5
  export class TemplateUtil {
6
+ /**
7
+ * 初始化。
8
+ */
9
+ static async init(cwd) {
10
+ await Promise.all([this.initHelperPackage(cwd), this.initTasks(cwd)]);
11
+ }
6
12
  /**
7
13
  * 初始化辅助包。
8
14
  */
15
+
16
+
9
17
  static async initHelperPackage(cwd) {
10
18
  const fromDir = path.join(__dirname, 'templates');
11
19
  const toDir = path.join(cwd, 'node_modules/.x');
@@ -18,6 +26,22 @@ export class TemplateUtil {
18
26
  replaceFile: true
19
27
  });
20
28
  }
29
+ /**
30
+ * 初始化任务。
31
+ */
32
+
33
+
34
+ static async initTasks(cwd) {
35
+ const tasksDir = path.join(cwd, 'tasks');
36
+ const tasksIndexFile = path.join(tasksDir, 'index.ts');
37
+
38
+ if (!(await fs.pathExists(tasksIndexFile))) {
39
+ await fs.writeFile(tasksIndexFile, dedent`
40
+ // @index(['./**/*.ts', '!**/*.test.ts', '!**/_*'], f => \`export * from '\${f.path}'\`)
41
+ // @endindex
42
+ `);
43
+ }
44
+ }
21
45
  /**
22
46
  * 初始化模型。
23
47
  */
@@ -1,2 +1 @@
1
- // @index(['../../src/tasks/**/*.ts', '!**/_*'], (f, _) => `import '${f.path}'`)
2
- // @endindex
1
+ import '../../src/tasks/index'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "1.26.7",
3
+ "version": "1.26.8",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",