feng3d-cli 0.0.4 → 0.0.6
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/README.md +54 -65
- package/bin/cli.js +58 -0
- package/dist/index.js +535 -10
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +536 -0
- package/dist/index.umd.cjs.map +1 -0
- package/{dist → lib}/commands/create.d.ts.map +1 -1
- package/lib/commands/update.d.ts +13 -0
- package/lib/commands/update.d.ts.map +1 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.d.ts.map +1 -0
- package/{dist → lib}/templates.d.ts +19 -19
- package/{dist → lib}/templates.d.ts.map +1 -1
- package/lib/versions.d.ts +17 -0
- package/lib/versions.d.ts.map +1 -0
- package/package.json +21 -27
- package/templates/.github/workflows/pages.yml +11 -41
- package/templates/.github/workflows/publish.yml +2 -8
- package/templates/.github/workflows/pull-request.yml +3 -3
- package/templates/.github/workflows/upload-oss.yml +100 -0
- package/templates/.husky/pre-commit +32 -1
- package/templates/gitignore +0 -10
- package/templates/package.json +71 -0
- package/templates/scripts/postdocs.js +46 -0
- package/templates/scripts/postpublish.js +19 -0
- package/templates/scripts/prepublish.js +19 -0
- package/templates/src/index.ts +6 -0
- package/templates/vite.config.js +50 -0
- package/dist/cli.d.ts +0 -7
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -108
- package/dist/cli.js.map +0 -1
- package/dist/commands/create.js +0 -125
- package/dist/commands/create.js.map +0 -1
- package/dist/commands/oss.d.ts +0 -11
- package/dist/commands/oss.d.ts.map +0 -1
- package/dist/commands/oss.js +0 -132
- package/dist/commands/oss.js.map +0 -1
- package/dist/commands/update.d.ts +0 -30
- package/dist/commands/update.d.ts.map +0 -1
- package/dist/commands/update.js +0 -482
- package/dist/commands/update.js.map +0 -1
- package/dist/eslint.d.ts +0 -236
- package/dist/eslint.d.ts.map +0 -1
- package/dist/eslint.js +0 -119
- package/dist/eslint.js.map +0 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.d.ts.map +0 -1
- package/dist/templates.js +0 -151
- package/dist/templates.js.map +0 -1
- package/dist/types/config.d.ts +0 -111
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js +0 -50
- package/dist/types/config.js.map +0 -1
- package/dist/versions.d.ts +0 -31
- package/dist/versions.d.ts.map +0 -1
- package/dist/versions.js +0 -60
- package/dist/versions.js.map +0 -1
- package/schemas/feng3d.schema.json +0 -191
- package/templates/feng3d.json +0 -42
- package/templates/vitest.config.ts +0 -8
- /package/{dist → lib}/commands/create.d.ts +0 -0
package/README.md
CHANGED
|
@@ -5,27 +5,24 @@ feng3d 命令行工具,包含项目规范、配置模板、OSS 上传等功能
|
|
|
5
5
|
- 📋 统一的代码规范(ESLint 配置)
|
|
6
6
|
- 📦 统一的依赖版本管理
|
|
7
7
|
- 🛠️ CLI 工具支持创建和更新项目
|
|
8
|
-
- 📝
|
|
8
|
+
- 📝 项目模板(LICENSE, .gitignore, .cursorrules, tsconfig.json, vite.config.js 等)
|
|
9
|
+
- 🔄 GitHub Actions 工作流模板
|
|
9
10
|
- 📤 阿里云 OSS 文件上传
|
|
10
11
|
|
|
11
|
-
##
|
|
12
|
+
## 使用方式
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
npm install -g feng3d-cli
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
或作为开发依赖:
|
|
14
|
+
推荐使用 `npx` 直接运行,无需安装:
|
|
18
15
|
|
|
19
16
|
```bash
|
|
20
|
-
|
|
17
|
+
npx feng3d-cli <command>
|
|
21
18
|
```
|
|
22
19
|
|
|
23
|
-
## CLI
|
|
20
|
+
## CLI 命令
|
|
24
21
|
|
|
25
22
|
### 创建新项目
|
|
26
23
|
|
|
27
24
|
```bash
|
|
28
|
-
feng3d-cli create my-project
|
|
25
|
+
npx feng3d-cli create my-project
|
|
29
26
|
```
|
|
30
27
|
|
|
31
28
|
选项:
|
|
@@ -36,82 +33,75 @@ feng3d-cli create my-project
|
|
|
36
33
|
### 更新现有项目
|
|
37
34
|
|
|
38
35
|
```bash
|
|
39
|
-
feng3d-cli update
|
|
36
|
+
npx feng3d-cli update
|
|
37
|
+
npx feng3d-cli update -d ./my-project # 指定项目目录
|
|
40
38
|
```
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
- `-d, --directory <dir>` - 项目目录(默认:当前目录)
|
|
44
|
-
- `--eslint` - 仅更新 ESLint 配置
|
|
45
|
-
- `--gitignore` - 仅更新 .gitignore
|
|
46
|
-
- `--cursorrules` - 仅更新 .cursorrules
|
|
47
|
-
- `--deps` - 仅更新依赖版本
|
|
48
|
-
- `--all` - 更新所有配置
|
|
40
|
+
更新项目的所有规范配置文件,包括 ESLint、TypeScript、Vite、GitHub Actions 等。
|
|
49
41
|
|
|
50
42
|
### 上传到阿里云 OSS
|
|
51
43
|
|
|
52
44
|
```bash
|
|
53
|
-
feng3d-cli oss_upload_dir # 上传 ./public 目录
|
|
54
|
-
feng3d-cli oss_upload_dir -l ./dist # 指定本地目录
|
|
55
|
-
feng3d-cli oss_upload_dir -l ./public -o my-project # 指定 OSS 目录
|
|
45
|
+
npx feng3d-cli oss_upload_dir # 上传 ./public 目录
|
|
46
|
+
npx feng3d-cli oss_upload_dir -l ./dist # 指定本地目录
|
|
47
|
+
npx feng3d-cli oss_upload_dir -l ./public -o my-project # 指定 OSS 目录
|
|
56
48
|
```
|
|
57
49
|
|
|
58
50
|
选项:
|
|
59
51
|
- `-l, --local_dir <dir>` - 本地目录(默认:./public)
|
|
60
52
|
- `-o, --oss_dir <dir>` - OSS 目录(默认:从 package.json 的 name 获取)
|
|
61
53
|
|
|
62
|
-
>
|
|
54
|
+
> 注意:需要在用户目录下创建 `oss_config.json` 配置 OSS 访问密钥(如 `~/oss_config.json`)
|
|
55
|
+
>
|
|
56
|
+
> 配置文件格式:
|
|
57
|
+
> ```json
|
|
58
|
+
> {
|
|
59
|
+
> "region": "oss-cn-hangzhou",
|
|
60
|
+
> "accessKeyId": "your-access-key-id",
|
|
61
|
+
> "accessKeySecret": "your-access-key-secret",
|
|
62
|
+
> "bucket": "your-bucket-name"
|
|
63
|
+
> }
|
|
64
|
+
> ```
|
|
63
65
|
|
|
64
66
|
## 编程使用
|
|
65
67
|
|
|
66
|
-
### 获取统一版本
|
|
67
|
-
|
|
68
|
-
```typescript
|
|
69
|
-
import { VERSIONS, getDevDependencies } from 'feng3d-cli';
|
|
70
|
-
|
|
71
|
-
// 获取特定依赖版本
|
|
72
|
-
console.log(VERSIONS.typescript); // '5.8.3'
|
|
73
|
-
console.log(VERSIONS.vitest); // '^3.1.3'
|
|
74
|
-
|
|
75
|
-
// 获取完整的 devDependencies
|
|
76
|
-
const deps = getDevDependencies({
|
|
77
|
-
includeVitest: true,
|
|
78
|
-
includeCoverage: true,
|
|
79
|
-
includeTypedoc: true,
|
|
80
|
-
});
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### 使用 ESLint 配置
|
|
84
|
-
|
|
85
|
-
在项目的 `eslint.config.js` 中:
|
|
86
|
-
|
|
87
|
-
```javascript
|
|
88
|
-
import { eslintRules } from 'feng3d-cli/eslint';
|
|
89
|
-
|
|
90
|
-
export default [
|
|
91
|
-
// ... 其他配置
|
|
92
|
-
{
|
|
93
|
-
rules: eslintRules,
|
|
94
|
-
},
|
|
95
|
-
];
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### 使用模板
|
|
99
|
-
|
|
100
68
|
```typescript
|
|
101
69
|
import {
|
|
70
|
+
// 版本管理
|
|
71
|
+
VERSIONS,
|
|
72
|
+
getDevDependencies,
|
|
73
|
+
// 模板
|
|
102
74
|
gitignoreTemplate,
|
|
103
75
|
cursorrrulesTemplate,
|
|
104
|
-
|
|
105
|
-
|
|
76
|
+
getTypedocConfig,
|
|
77
|
+
getLicenseTemplate,
|
|
78
|
+
getVscodeSettingsTemplate,
|
|
79
|
+
getTsconfigTemplate,
|
|
80
|
+
getViteConfigTemplate,
|
|
81
|
+
// 项目操作
|
|
82
|
+
createProject,
|
|
83
|
+
updateProject,
|
|
84
|
+
ossUploadDir,
|
|
106
85
|
} from 'feng3d-cli';
|
|
107
|
-
|
|
108
|
-
// 创建 typedoc 配置
|
|
109
|
-
const config = createTypedocConfig({
|
|
110
|
-
name: '@feng3d/my-package',
|
|
111
|
-
repoName: 'my-package',
|
|
112
|
-
});
|
|
113
86
|
```
|
|
114
87
|
|
|
88
|
+
## 模板文件
|
|
89
|
+
|
|
90
|
+
| 文件 | 说明 |
|
|
91
|
+
|------|------|
|
|
92
|
+
| LICENSE | MIT 许可证(中文) |
|
|
93
|
+
| .gitignore | Git 忽略规则 |
|
|
94
|
+
| .cursorrules | Cursor AI 规则 |
|
|
95
|
+
| tsconfig.json | TypeScript 配置 |
|
|
96
|
+
| vite.config.js | Vite 构建配置 |
|
|
97
|
+
| eslint.config.js | ESLint 配置 |
|
|
98
|
+
| typedoc.json | TypeDoc 配置 |
|
|
99
|
+
| .vscode/settings.json | VS Code 设置 |
|
|
100
|
+
| .husky/pre-commit | Git pre-commit hook |
|
|
101
|
+
| .github/workflows/*.yml | GitHub Actions 工作流 |
|
|
102
|
+
| scripts/prepublish.js | 发布前脚本 |
|
|
103
|
+
| scripts/postpublish.js | 发布后脚本 |
|
|
104
|
+
|
|
115
105
|
## 统一版本
|
|
116
106
|
|
|
117
107
|
| 依赖 | 版本 |
|
|
@@ -143,4 +133,3 @@ const config = createTypedocConfig({
|
|
|
143
133
|
## 许可证
|
|
144
134
|
|
|
145
135
|
MIT
|
|
146
|
-
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* feng3d-cli
|
|
4
|
+
* feng3d 命令行工具,包含项目规范、OSS 上传等功能
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import { createProject, updateProject } from '../dist/index.js';
|
|
10
|
+
|
|
11
|
+
const program = new Command();
|
|
12
|
+
|
|
13
|
+
program
|
|
14
|
+
.name('feng3d-cli')
|
|
15
|
+
.description('feng3d 命令行工具')
|
|
16
|
+
.version('0.0.1');
|
|
17
|
+
|
|
18
|
+
program
|
|
19
|
+
.command('create <name>')
|
|
20
|
+
.description('创建符合 feng3d 规范的新项目')
|
|
21
|
+
.option('-d, --directory <dir>', '项目目录', '.')
|
|
22
|
+
.option('--no-examples', '不创建示例目录')
|
|
23
|
+
.option('--no-vitest', '不包含 vitest 测试配置')
|
|
24
|
+
.action(async (name, options) =>
|
|
25
|
+
{
|
|
26
|
+
console.log(chalk.blue(`\n🚀 创建项目: ${name}\n`));
|
|
27
|
+
try
|
|
28
|
+
{
|
|
29
|
+
await createProject(name, options);
|
|
30
|
+
console.log(chalk.green(`\n✅ 项目 ${name} 创建成功!\n`));
|
|
31
|
+
}
|
|
32
|
+
catch (error)
|
|
33
|
+
{
|
|
34
|
+
console.error(chalk.red(`\n❌ 创建失败: ${error}\n`));
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
program
|
|
40
|
+
.command('update')
|
|
41
|
+
.description('更新当前项目的规范配置')
|
|
42
|
+
.option('-d, --directory <dir>', '项目目录', '.')
|
|
43
|
+
.action(async (options) =>
|
|
44
|
+
{
|
|
45
|
+
console.log(chalk.blue('\n🔄 更新项目规范配置\n'));
|
|
46
|
+
try
|
|
47
|
+
{
|
|
48
|
+
await updateProject(options.directory);
|
|
49
|
+
console.log(chalk.green('\n✅ 规范配置更新成功!\n'));
|
|
50
|
+
}
|
|
51
|
+
catch (error)
|
|
52
|
+
{
|
|
53
|
+
console.error(chalk.red(`\n❌ 更新失败: ${error}\n`));
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
program.parse();
|