feng3d-cli 0.0.3 → 0.0.5

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 (54) hide show
  1. package/README.md +0 -17
  2. package/bin/cli.js +135 -0
  3. package/dist/index.js +792 -9
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.umd.cjs +792 -0
  6. package/dist/index.umd.cjs.map +1 -0
  7. package/{dist → lib}/commands/create.d.ts.map +1 -1
  8. package/{dist → lib}/commands/update.d.ts +1 -0
  9. package/{dist → lib}/commands/update.d.ts.map +1 -1
  10. package/{dist → lib}/index.d.ts +2 -1
  11. package/lib/index.d.ts.map +1 -0
  12. package/{dist → lib}/templates.d.ts +10 -14
  13. package/lib/templates.d.ts.map +1 -0
  14. package/{dist → lib}/types/config.d.ts +2 -0
  15. package/{dist → lib}/types/config.d.ts.map +1 -1
  16. package/package.json +20 -22
  17. package/schemas/feng3d.schema.json +5 -0
  18. package/templates/.github/workflows/pages.yml +35 -2
  19. package/templates/.github/workflows/publish.yml +2 -8
  20. package/templates/.github/workflows/pull-request.yml +7 -2
  21. package/templates/feng3d.json +2 -1
  22. package/templates/gitignore +3 -0
  23. package/templates/scripts/postpublish.js +19 -0
  24. package/templates/scripts/prepublish.js +19 -0
  25. package/templates/typedoc.json +2 -2
  26. package/templates/vite.config.js +49 -0
  27. package/dist/cli.d.ts +0 -7
  28. package/dist/cli.d.ts.map +0 -1
  29. package/dist/cli.js +0 -108
  30. package/dist/cli.js.map +0 -1
  31. package/dist/commands/create.js +0 -125
  32. package/dist/commands/create.js.map +0 -1
  33. package/dist/commands/oss.js +0 -132
  34. package/dist/commands/oss.js.map +0 -1
  35. package/dist/commands/update.js +0 -482
  36. package/dist/commands/update.js.map +0 -1
  37. package/dist/eslint.d.ts +0 -236
  38. package/dist/eslint.d.ts.map +0 -1
  39. package/dist/eslint.js +0 -119
  40. package/dist/eslint.js.map +0 -1
  41. package/dist/index.d.ts.map +0 -1
  42. package/dist/templates.d.ts.map +0 -1
  43. package/dist/templates.js +0 -153
  44. package/dist/templates.js.map +0 -1
  45. package/dist/types/config.js +0 -50
  46. package/dist/types/config.js.map +0 -1
  47. package/dist/versions.js +0 -60
  48. package/dist/versions.js.map +0 -1
  49. package/templates/vitest.config.ts +0 -8
  50. /package/{dist → lib}/commands/create.d.ts +0 -0
  51. /package/{dist → lib}/commands/oss.d.ts +0 -0
  52. /package/{dist → lib}/commands/oss.d.ts.map +0 -0
  53. /package/{dist → lib}/versions.d.ts +0 -0
  54. /package/{dist → lib}/versions.d.ts.map +0 -0
package/README.md CHANGED
@@ -1,5 +1,3 @@
1
- # feng3d-cli
2
-
3
1
  feng3d 命令行工具,包含项目规范、配置模板、OSS 上传等功能。
4
2
 
5
3
  ## 功能特性
@@ -82,21 +80,6 @@ const deps = getDevDependencies({
82
80
  });
83
81
  ```
84
82
 
85
- ### 使用 ESLint 配置
86
-
87
- 在项目的 `eslint.config.js` 中:
88
-
89
- ```javascript
90
- import { eslintRules } from 'feng3d-cli/eslint';
91
-
92
- export default [
93
- // ... 其他配置
94
- {
95
- rules: eslintRules,
96
- },
97
- ];
98
- ```
99
-
100
83
  ### 使用模板
101
84
 
102
85
  ```typescript
package/bin/cli.js ADDED
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * feng3d-cli
4
+ * feng3d 命令行工具,包含项目规范、OSS 上传等功能
5
+ */
6
+
7
+ import fs from 'fs';
8
+ import { Command } from 'commander';
9
+ import chalk from 'chalk';
10
+ import { createProject, updateProject, ossUploadDir } from '../dist/index.js';
11
+
12
+ const program = new Command();
13
+
14
+ program
15
+ .name('feng3d-cli')
16
+ .description('feng3d 命令行工具')
17
+ .version('0.0.1');
18
+
19
+ program
20
+ .command('create <name>')
21
+ .description('创建符合 feng3d 规范的新项目')
22
+ .option('-d, --directory <dir>', '项目目录', '.')
23
+ .option('--no-examples', '不创建示例目录')
24
+ .option('--no-vitest', '不包含 vitest 测试配置')
25
+ .action(async (name, options) =>
26
+ {
27
+ console.log(chalk.blue(`\n🚀 创建项目: ${name}\n`));
28
+ try
29
+ {
30
+ await createProject(name, options);
31
+ console.log(chalk.green(`\n✅ 项目 ${name} 创建成功!\n`));
32
+ }
33
+ catch (error)
34
+ {
35
+ console.error(chalk.red(`\n❌ 创建失败: ${error}\n`));
36
+ process.exit(1);
37
+ }
38
+ });
39
+
40
+ program
41
+ .command('update')
42
+ .description('更新当前项目的规范配置')
43
+ .option('-d, --directory <dir>', '项目目录', '.')
44
+ .option('--config', '仅更新 feng3d.json 配置')
45
+ .option('--eslint', '仅更新 ESLint 配置')
46
+ .option('--gitignore', '仅更新 .gitignore')
47
+ .option('--cursorrules', '仅更新 .cursorrules')
48
+ .option('--publish', '仅更新 npm publish workflow')
49
+ .option('--pages', '仅更新 GitHub Pages workflow')
50
+ .option('--pull-request', '仅更新 Pull Request CI workflow')
51
+ .option('--typedoc', '仅更新 typedoc.json')
52
+ .option('--test', '仅更新 test/_.test.ts')
53
+ .option('--deps', '仅更新依赖版本')
54
+ .option('--husky', '仅更新 husky pre-commit hook')
55
+ .option('--license', '仅更新 LICENSE 文件')
56
+ .option('--vscode', '仅更新 .vscode/settings.json')
57
+ .option('--tsconfig', '仅更新 tsconfig.json')
58
+ .option('--vite', '仅更新 vite.config.js')
59
+ .option('--all', '更新所有配置')
60
+ .action(async (options) =>
61
+ {
62
+ console.log(chalk.blue('\n🔄 更新项目规范配置\n'));
63
+ try
64
+ {
65
+ await updateProject(options);
66
+ console.log(chalk.green('\n✅ 规范配置更新成功!\n'));
67
+ }
68
+ catch (error)
69
+ {
70
+ console.error(chalk.red(`\n❌ 更新失败: ${error}\n`));
71
+ process.exit(1);
72
+ }
73
+ });
74
+
75
+ program
76
+ .command('check')
77
+ .description('检查当前项目是否符合 feng3d 规范')
78
+ .option('-d, --directory <dir>', '项目目录', '.')
79
+ .action(async () =>
80
+ {
81
+ console.log(chalk.blue('\n🔍 检查项目规范\n'));
82
+ // TODO: 实现规范检查
83
+ console.log(chalk.yellow('暂未实现'));
84
+ });
85
+
86
+ program
87
+ .command('oss_upload_dir')
88
+ .description('上传文件夹到阿里云 OSS')
89
+ .option('-l, --local_dir <string>', '本地目录', './public')
90
+ .option('-o, --oss_dir <string>', 'OSS 目录', '')
91
+ .action(async (options) =>
92
+ {
93
+ const localDir = options.local_dir;
94
+ let ossDir = options.oss_dir;
95
+
96
+ if (!fs.existsSync(localDir))
97
+ {
98
+ console.log(chalk.red(`\n❌ 本地目录 ${localDir} 不存在!\n`));
99
+
100
+ return;
101
+ }
102
+
103
+ if (!ossDir)
104
+ {
105
+ // 获取当前目录下 package.json 的 name 字段
106
+ try
107
+ {
108
+ const packageJson = fs.readFileSync('package.json', 'utf-8');
109
+ const packageJsonObj = JSON.parse(packageJson);
110
+
111
+ ossDir = packageJsonObj.name.split('/').pop();
112
+ }
113
+ catch
114
+ {
115
+ console.log(chalk.red('\n❌ 无法读取 package.json 获取项目名称\n'));
116
+
117
+ return;
118
+ }
119
+ }
120
+
121
+ console.log(chalk.blue(`\n📤 上传文件夹到阿里云 OSS: ${localDir} -> ${ossDir}\n`));
122
+
123
+ try
124
+ {
125
+ await ossUploadDir(localDir, ossDir);
126
+ console.log(chalk.green('\n✅ 上传完成!\n'));
127
+ }
128
+ catch (error)
129
+ {
130
+ console.error(chalk.red(`\n❌ 上传失败: ${error}\n`));
131
+ process.exit(1);
132
+ }
133
+ });
134
+
135
+ program.parse();