feng3d-cli 0.0.1 → 0.0.3

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 (46) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +148 -148
  3. package/dist/cli.js +10 -0
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/create.d.ts.map +1 -1
  6. package/dist/commands/create.js +13 -6
  7. package/dist/commands/create.js.map +1 -1
  8. package/dist/commands/oss.d.ts.map +1 -1
  9. package/dist/commands/oss.js +26 -1
  10. package/dist/commands/oss.js.map +1 -1
  11. package/dist/commands/update.d.ts +10 -0
  12. package/dist/commands/update.d.ts.map +1 -1
  13. package/dist/commands/update.js +444 -134
  14. package/dist/commands/update.js.map +1 -1
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +1 -0
  18. package/dist/index.js.map +1 -1
  19. package/dist/templates.d.ts +79 -27
  20. package/dist/templates.d.ts.map +1 -1
  21. package/dist/templates.js +147 -140
  22. package/dist/templates.js.map +1 -1
  23. package/dist/types/config.d.ts +111 -0
  24. package/dist/types/config.d.ts.map +1 -0
  25. package/dist/types/config.js +50 -0
  26. package/dist/types/config.js.map +1 -0
  27. package/dist/versions.d.ts +2 -0
  28. package/dist/versions.d.ts.map +1 -1
  29. package/dist/versions.js +6 -0
  30. package/dist/versions.js.map +1 -1
  31. package/package.json +81 -64
  32. package/schemas/feng3d.schema.json +191 -0
  33. package/templates/.cursorrules +159 -79
  34. package/templates/.github/workflows/pages.yml +60 -0
  35. package/templates/.github/workflows/publish.yml +128 -0
  36. package/templates/.github/workflows/pull-request.yml +31 -0
  37. package/templates/.husky/pre-commit +2 -0
  38. package/templates/.vscode/settings.json +10 -0
  39. package/templates/LICENSE +15 -0
  40. package/templates/eslint.config.js +159 -0
  41. package/templates/feng3d.json +42 -0
  42. package/templates/gitignore +23 -0
  43. package/templates/test/_.test.ts +5 -0
  44. package/templates/tsconfig.json +20 -0
  45. package/templates/typedoc.json +8 -0
  46. package/templates/vitest.config.ts +8 -0
@@ -0,0 +1,128 @@
1
+ # 当 package.json 中的版本在 npm 不存在时自动发布
2
+ name: Publish to NPM
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - master
8
+ - main
9
+ workflow_dispatch: # 支持手动触发
10
+
11
+ jobs:
12
+ check-version:
13
+ runs-on: ubuntu-latest
14
+ outputs:
15
+ should_publish: ${{ steps.check.outputs.should_publish }}
16
+ version: ${{ steps.check.outputs.version }}
17
+ steps:
18
+ - name: Checkout
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Check if version exists on npm
22
+ id: check
23
+ run: |
24
+ # 获取包名和当前版本
25
+ PACKAGE_NAME=$(node -p "require('./package.json').name")
26
+ CURRENT_VERSION=$(node -p "require('./package.json').version")
27
+ echo "Package: $PACKAGE_NAME"
28
+ echo "Current version: $CURRENT_VERSION"
29
+
30
+ # 检查该版本是否已在 npm 上存在
31
+ HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://registry.npmjs.org/$PACKAGE_NAME/$CURRENT_VERSION")
32
+
33
+ if [ "$HTTP_STATUS" = "404" ]; then
34
+ echo "Version $CURRENT_VERSION not found on npm, will publish"
35
+ echo "should_publish=true" >> $GITHUB_OUTPUT
36
+ echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
37
+ else
38
+ echo "Version $CURRENT_VERSION already exists on npm (HTTP $HTTP_STATUS)"
39
+ echo "should_publish=false" >> $GITHUB_OUTPUT
40
+ fi
41
+
42
+ publish:
43
+ needs: check-version
44
+ if: needs.check-version.outputs.should_publish == 'true'
45
+ runs-on: ubuntu-latest
46
+ steps:
47
+ - name: Checkout
48
+ uses: actions/checkout@v4
49
+ with:
50
+ fetch-depth: 0 # 获取完整历史以生成更新日志
51
+
52
+ - name: Setup Node.js
53
+ uses: actions/setup-node@v4
54
+ with:
55
+ node-version: '20'
56
+ registry-url: 'https://registry.npmjs.org'
57
+
58
+ - name: Install dependencies
59
+ run: npm install
60
+
61
+ - name: Build
62
+ run: npm run build
63
+
64
+ - name: Run lint
65
+ run: npm run lint
66
+
67
+ - name: Run tests
68
+ run: npm test
69
+
70
+ - name: Publish to NPM
71
+ run: npm publish
72
+ env:
73
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
74
+
75
+ - name: Create Git Tag
76
+ run: |
77
+ VERSION=${{ needs.check-version.outputs.version }}
78
+ git config user.name "github-actions[bot]"
79
+ git config user.email "github-actions[bot]@users.noreply.github.com"
80
+ git tag -a "v$VERSION" -m "Release v$VERSION"
81
+ git push origin "v$VERSION"
82
+ env:
83
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84
+
85
+ - name: Generate Release Notes
86
+ id: release_notes
87
+ run: |
88
+ VERSION=${{ needs.check-version.outputs.version }}
89
+
90
+ # 获取上一个版本的 tag
91
+ PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
92
+
93
+ echo "Previous tag: $PREVIOUS_TAG"
94
+
95
+ # 生成更新日志
96
+ if [ -n "$PREVIOUS_TAG" ]; then
97
+ echo "## 更新内容" > release_notes.md
98
+ echo "" >> release_notes.md
99
+ echo "与 $PREVIOUS_TAG 相比的变更:" >> release_notes.md
100
+ echo "" >> release_notes.md
101
+
102
+ # 获取提交日志
103
+ git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD >> release_notes.md
104
+ else
105
+ echo "## 更新内容" > release_notes.md
106
+ echo "" >> release_notes.md
107
+ echo "首次发布" >> release_notes.md
108
+ echo "" >> release_notes.md
109
+
110
+ # 获取所有提交日志
111
+ git log --pretty=format:"- %s (%h)" >> release_notes.md
112
+ fi
113
+
114
+ echo "" >> release_notes.md
115
+
116
+ # 输出生成的内容
117
+ echo "Generated release notes:"
118
+ cat release_notes.md
119
+
120
+ - name: Create GitHub Release
121
+ uses: softprops/action-gh-release@v1
122
+ with:
123
+ tag_name: v${{ needs.check-version.outputs.version }}
124
+ name: Release v${{ needs.check-version.outputs.version }}
125
+ body_path: release_notes.md
126
+ env:
127
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128
+
@@ -0,0 +1,31 @@
1
+ # 合并请求 CI - 运行单元测试
2
+ name: Pull Request CI
3
+
4
+ on:
5
+ pull_request:
6
+ branches:
7
+ - master
8
+ - main
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - name: Checkout
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Setup Node.js
19
+ uses: actions/setup-node@v4
20
+ with:
21
+ node-version: '20'
22
+
23
+ - name: Install dependencies
24
+ run: npm install
25
+
26
+ - name: Run lint
27
+ run: npm run lint
28
+
29
+ - name: Run unit tests
30
+ run: npm test
31
+
@@ -0,0 +1,2 @@
1
+ npx lint-staged
2
+
@@ -0,0 +1,10 @@
1
+ // 将设置放入此文件中以覆盖默认值和用户设置。
2
+ {
3
+ // 定义函数的左大括号是否放置在新的一行。
4
+ "typescript.format.placeOpenBraceOnNewLineForFunctions": true,
5
+ // 定义控制块的左括号是否放置在新的一行。
6
+ "typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
7
+ "javascript.format.placeOpenBraceOnNewLineForFunctions": true,
8
+ "javascript.format.placeOpenBraceOnNewLineForControlBlocks": true
9
+ }
10
+
@@ -0,0 +1,15 @@
1
+ MIT 许可证
2
+
3
+ 版权所有 (c) {{year}} feng
4
+
5
+ 特此授予任何获得本软件及相关文档文件("软件")副本的人免费许可,
6
+ 可以不受限制地处理本软件,包括但不限于使用、复制、修改、合并、
7
+ 发布、分发、再许可和/或销售本软件的副本,并允许向其提供本软件的
8
+ 人这样做,但须符合以下条件:
9
+
10
+ 上述版权声明和本许可声明应包含在本软件的所有副本或主要部分中。
11
+
12
+ 本软件按"原样"提供,不提供任何明示或暗示的保证,包括但不限于对
13
+ 适销性、特定用途适用性和非侵权性的保证。在任何情况下,作者或版权
14
+ 持有人均不对因本软件或本软件的使用或其他交易而产生的任何索赔、
15
+ 损害或其他责任负责,无论是在合同诉讼、侵权诉讼还是其他诉讼中。
@@ -0,0 +1,159 @@
1
+ // 导入 ESLint 核心模块
2
+ import eslint from '@eslint/js';
3
+ // 导入 TypeScript ESLint 配置
4
+ import tseslint from 'typescript-eslint';
5
+ // 导入全局变量定义
6
+ import globals from 'globals';
7
+
8
+ // 导出 ESLint 配置
9
+ export default [
10
+ // 忽略检查的文件和目录
11
+ {
12
+ ignores: [
13
+ '**/node_modules/**', // 忽略所有 node_modules 目录
14
+ '**/dist/**', // 忽略所有 dist 目录
15
+ '**/lib/**', // 忽略所有 lib 目录
16
+ '**/public/**', // 忽略所有 public 目录
17
+ '**/coverage/**', // 忽略所有 coverage 目录
18
+ '**/.git/**', // 忽略所有 .git 目录
19
+ ],
20
+ },
21
+ // 使用 ESLint 推荐配置
22
+ eslint.configs.recommended,
23
+ // 使用 TypeScript ESLint 推荐配置
24
+ ...tseslint.configs.recommended,
25
+ {
26
+ // 语言选项配置
27
+ languageOptions: {
28
+ // 全局变量配置
29
+ globals: {
30
+ ...globals.browser, // 浏览器环境全局变量
31
+ ...globals.node, // Node.js 环境全局变量
32
+ ...globals.es2021, // ES2021 全局变量
33
+ global: false, // 禁用 global 全局变量
34
+ },
35
+ // 解析器选项
36
+ parserOptions: {
37
+ ecmaVersion: 2021, // 使用 ES2021 语法
38
+ sourceType: 'module', // 使用 ES 模块
39
+ tsconfigRootDir: import.meta.dirname, // 明确指定 tsconfig 根目录
40
+ },
41
+ },
42
+ rules: {
43
+ '@typescript-eslint/no-unused-vars': 'off', // 允许未使用的变量
44
+ '@typescript-eslint/no-explicit-any': 'off', // 允许使用 any 类型
45
+ 'no-prototype-builtins': 'off', // 允许直接使用 Object.prototype 方法
46
+ '@typescript-eslint/ban-ts-comment': 'off', // 允许使用 @ts 注释
47
+ '@typescript-eslint/no-unused-expressions': 'off', // 允许未使用的表达式
48
+ '@typescript-eslint/no-empty-object-type': 'off', // 允许空对象类型
49
+ '@typescript-eslint/no-unsafe-declaration-merging': 'off', // 允许不安全的声明合并
50
+ '@typescript-eslint/no-unsafe-function-type': 'off', // 允许不安全的函数类型
51
+ '@typescript-eslint/no-this-alias': 'off', // 允许 this 别名
52
+ 'prefer-const': 'off', // 不强制使用 const
53
+ 'no-fallthrough': 'off', // 允许 fallthrough
54
+ 'no-constant-binary-expression': 'off', // 允许常量二进制表达式
55
+
56
+ // 注释格式规则
57
+ 'spaced-comment': ['warn', 'always', {
58
+ 'line': {
59
+ 'markers': ['/'], // 以 / 开头的注释需要空格
60
+ 'exceptions': ['-', '+'], // 允许以 - 和 + 开头的注释不需要空格
61
+ },
62
+ 'block': {
63
+ 'markers': ['!'], // 以 ! 开头的块级注释需要空格
64
+ 'exceptions': ['*'], // 允许以 * 开头的块级注释不需要空格
65
+ 'balanced': true, // 要求块级注释的 * 对齐
66
+ },
67
+ }],
68
+
69
+ // 空格和换行规则
70
+ 'no-trailing-spaces': ['warn', { // 禁止行尾空格
71
+ 'skipBlankLines': false, // 不跳过空行
72
+ 'ignoreComments': false, // 不忽略注释
73
+ }],
74
+ 'no-multiple-empty-lines': ['warn', { // 限制空行数量
75
+ 'max': 1, // 最多允许 1 个空行
76
+ 'maxEOF': 1, // 文件末尾最多 1 个空行
77
+ 'maxBOF': 0, // 文件开头不允许空行
78
+ }],
79
+ 'lines-between-class-members': ['warn', 'always', { // 类成员之间需要空行
80
+ 'exceptAfterSingleLine': true, // 单行成员后可以没有空行
81
+ }],
82
+ 'padding-line-between-statements': [ // 语句之间的空行规则
83
+ 'warn',
84
+ { 'blankLine': 'always', 'prev': '*', 'next': 'return' }, // return 前需要空行
85
+ { 'blankLine': 'always', 'prev': ['const', 'let', 'var'], 'next': '*' }, // 变量声明后需要空行
86
+ { 'blankLine': 'any', 'prev': ['const', 'let', 'var'], 'next': ['const', 'let', 'var'] }, // 变量声明之间可以没有空行
87
+ ],
88
+
89
+ // 缩进规则
90
+ 'indent': ['warn', 4, { // 使用 4 空格缩进
91
+ 'SwitchCase': 1, // switch case 缩进 1 级
92
+ 'VariableDeclarator': 'first', // 变量声明对齐到第一个变量
93
+ 'outerIIFEBody': 1, // 外层 IIFE 缩进 1 级
94
+ 'MemberExpression': 1, // 成员表达式缩进 1 级
95
+ 'FunctionDeclaration': { // 函数声明缩进规则
96
+ 'parameters': 1, // 参数缩进 1 级
97
+ 'body': 1, // 函数体缩进 1 级
98
+ },
99
+ 'FunctionExpression': { // 函数表达式缩进规则
100
+ 'parameters': 1, // 参数缩进 1 级
101
+ 'body': 1, // 函数体缩进 1 级
102
+ },
103
+ 'CallExpression': { // 函数调用缩进规则
104
+ 'arguments': 1, // 参数缩进 1 级
105
+ },
106
+ 'ArrayExpression': 1, // 数组表达式缩进 1 级
107
+ 'ObjectExpression': 1, // 对象表达式缩进 1 级
108
+ 'ImportDeclaration': 1, // import 声明缩进 1 级
109
+ 'flatTernaryExpressions': false, // 不扁平化三元表达式
110
+ 'ignoreComments': false, // 不忽略注释
111
+ }],
112
+
113
+ // 引号规则
114
+ 'quotes': ['warn', 'single', { // 使用单引号
115
+ 'avoidEscape': true, // 允许使用转义字符
116
+ 'allowTemplateLiterals': true, // 允许使用模板字符串
117
+ }],
118
+
119
+ // 其他格式规则
120
+ 'semi': ['off'], // 要求使用分号
121
+ 'comma-dangle': ['warn', 'always-multiline'], // 多行时要求尾随逗号
122
+ 'object-curly-spacing': ['warn', 'always'], // 对象括号内要求空格
123
+ 'array-bracket-spacing': ['warn', 'never'], // 数组括号内不允许空格
124
+ 'arrow-spacing': ['warn', { // 箭头函数空格规则
125
+ 'before': true, // 箭头前需要空格
126
+ 'after': true, // 箭头后需要空格
127
+ }],
128
+ 'block-spacing': ['warn', 'always'], // 块级代码需要空格
129
+ 'brace-style': ['warn', 'allman', { // 大括号风格
130
+ 'allowSingleLine': false, // 不允许单行大括号
131
+ }],
132
+ 'comma-spacing': ['warn', { // 逗号空格规则
133
+ 'before': false, // 逗号前不允许空格
134
+ 'after': true, // 逗号后需要空格
135
+ }],
136
+ 'comma-style': ['warn', 'last'], // 逗号放在行尾
137
+ 'key-spacing': ['warn', { // 对象键值对空格规则
138
+ 'beforeColon': false, // 冒号前不允许空格
139
+ 'afterColon': true, // 冒号后需要空格
140
+ }],
141
+ 'keyword-spacing': ['warn', { // 关键字空格规则
142
+ 'before': true, // 关键字前需要空格
143
+ 'after': true, // 关键字后需要空格
144
+ }],
145
+ 'space-before-blocks': ['warn', 'always'], // 块级代码前需要空格
146
+ 'space-before-function-paren': ['warn', { // 函数括号前空格规则
147
+ 'anonymous': 'always', // 匿名函数括号前需要空格
148
+ 'named': 'never', // 命名函数括号前不允许空格
149
+ 'asyncArrow': 'always', // 异步箭头函数括号前需要空格
150
+ }],
151
+ 'space-in-parens': ['warn', 'never'], // 括号内不允许空格
152
+ 'space-infix-ops': ['warn'], // 操作符前后需要空格
153
+ 'space-unary-ops': ['warn', { // 一元操作符空格规则
154
+ 'words': true, // 单词类操作符需要空格
155
+ 'nonwords': false, // 非单词类操作符不需要空格
156
+ }],
157
+ },
158
+ },
159
+ ];
@@ -0,0 +1,42 @@
1
+ {
2
+ "$schema": "./node_modules/feng3d-cli/schemas/feng3d.schema.json",
3
+ "name": "{{name}}",
4
+ "eslint": {
5
+ "enabled": true,
6
+ "ignores": [],
7
+ "rules": {}
8
+ },
9
+ "vitest": {
10
+ "enabled": true,
11
+ "testTimeout": 0
12
+ },
13
+ "typedoc": {
14
+ "enabled": true,
15
+ "outDir": "public"
16
+ },
17
+ "oss": {
18
+ "localDir": "./public",
19
+ "ossDir": ""
20
+ },
21
+ "templates": {
22
+ "examples": true,
23
+ "test": true
24
+ },
25
+ "update": {
26
+ "config": true,
27
+ "eslint": true,
28
+ "gitignore": true,
29
+ "cursorrules": true,
30
+ "publish": true,
31
+ "pages": true,
32
+ "pullRequest": true,
33
+ "typedoc": true,
34
+ "test": true,
35
+ "deps": true,
36
+ "husky": true,
37
+ "license": true,
38
+ "vscode": true,
39
+ "tsconfig": true
40
+ }
41
+ }
42
+
@@ -0,0 +1,23 @@
1
+ node_modules
2
+ package-lock.json
3
+ dist
4
+ lib
5
+ public
6
+ out
7
+ # 自动生成的测试配置文件
8
+ **/test-config.ts
9
+ # 测试构建输出目录
10
+ test_dist
11
+ # 测试覆盖率
12
+ coverage
13
+
14
+ # 以下文件可由 feng3d-cli 自动生成,无需提交
15
+ # 运行 `feng3d-cli update` 可重新生成
16
+ feng3d.json
17
+ .cursorrules
18
+ eslint.config.js
19
+ typedoc.json
20
+ test/_.test.ts
21
+ .husky/pre-commit
22
+ .vscode/settings.json
23
+ tsconfig.json
@@ -0,0 +1,5 @@
1
+ import { test } from 'vitest';
2
+
3
+ test('_', () =>
4
+ { });
5
+
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ESNext", "DOM", "DOM.Iterable"],
7
+ "emitDeclarationOnly": true,
8
+ "declaration": true,
9
+ "declarationMap": true,
10
+ "outDir": "lib",
11
+ "esModuleInterop": true,
12
+ "allowSyntheticDefaultImports": true,
13
+ "forceConsistentCasingInFileNames": true,
14
+ "skipLibCheck": true,
15
+ "resolveJsonModule": true,
16
+ "isolatedModules": true
17
+ },
18
+ "include": ["src/**/*.ts"],
19
+ "exclude": ["node_modules", "dist", "lib", "public"]
20
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "{{name}}",
3
+ "$schema": "https://typedoc.org/schema.json",
4
+ "entryPoints": ["src/index.ts"],
5
+ "sourceLinkTemplate": "https://github.com/feng3d-labs/{{repoName}}/tree/master/{path}#L{line}",
6
+ "out": "public"
7
+ }
8
+
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ testTimeout: 0,
6
+ },
7
+ });
8
+