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.
Files changed (62) hide show
  1. package/README.md +54 -65
  2. package/bin/cli.js +58 -0
  3. package/dist/index.js +535 -10
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.umd.cjs +536 -0
  6. package/dist/index.umd.cjs.map +1 -0
  7. package/{dist → lib}/commands/create.d.ts.map +1 -1
  8. package/lib/commands/update.d.ts +13 -0
  9. package/lib/commands/update.d.ts.map +1 -0
  10. package/lib/index.d.ts +9 -0
  11. package/lib/index.d.ts.map +1 -0
  12. package/{dist → lib}/templates.d.ts +19 -19
  13. package/{dist → lib}/templates.d.ts.map +1 -1
  14. package/lib/versions.d.ts +17 -0
  15. package/lib/versions.d.ts.map +1 -0
  16. package/package.json +21 -27
  17. package/templates/.github/workflows/pages.yml +11 -41
  18. package/templates/.github/workflows/publish.yml +2 -8
  19. package/templates/.github/workflows/pull-request.yml +3 -3
  20. package/templates/.github/workflows/upload-oss.yml +100 -0
  21. package/templates/.husky/pre-commit +32 -1
  22. package/templates/gitignore +0 -10
  23. package/templates/package.json +71 -0
  24. package/templates/scripts/postdocs.js +46 -0
  25. package/templates/scripts/postpublish.js +19 -0
  26. package/templates/scripts/prepublish.js +19 -0
  27. package/templates/src/index.ts +6 -0
  28. package/templates/vite.config.js +50 -0
  29. package/dist/cli.d.ts +0 -7
  30. package/dist/cli.d.ts.map +0 -1
  31. package/dist/cli.js +0 -108
  32. package/dist/cli.js.map +0 -1
  33. package/dist/commands/create.js +0 -125
  34. package/dist/commands/create.js.map +0 -1
  35. package/dist/commands/oss.d.ts +0 -11
  36. package/dist/commands/oss.d.ts.map +0 -1
  37. package/dist/commands/oss.js +0 -132
  38. package/dist/commands/oss.js.map +0 -1
  39. package/dist/commands/update.d.ts +0 -30
  40. package/dist/commands/update.d.ts.map +0 -1
  41. package/dist/commands/update.js +0 -482
  42. package/dist/commands/update.js.map +0 -1
  43. package/dist/eslint.d.ts +0 -236
  44. package/dist/eslint.d.ts.map +0 -1
  45. package/dist/eslint.js +0 -119
  46. package/dist/eslint.js.map +0 -1
  47. package/dist/index.d.ts +0 -10
  48. package/dist/index.d.ts.map +0 -1
  49. package/dist/templates.js +0 -151
  50. package/dist/templates.js.map +0 -1
  51. package/dist/types/config.d.ts +0 -111
  52. package/dist/types/config.d.ts.map +0 -1
  53. package/dist/types/config.js +0 -50
  54. package/dist/types/config.js.map +0 -1
  55. package/dist/versions.d.ts +0 -31
  56. package/dist/versions.d.ts.map +0 -1
  57. package/dist/versions.js +0 -60
  58. package/dist/versions.js.map +0 -1
  59. package/schemas/feng3d.schema.json +0 -191
  60. package/templates/feng3d.json +0 -42
  61. package/templates/vitest.config.ts +0 -8
  62. /package/{dist → lib}/commands/create.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmCH;;;GAGG;AACH,wBAAsB,aAAa,CAAC,SAAS,GAAE,MAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAuM1E;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9E"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * feng3d-cli
3
+ * feng3d 命令行工具
4
+ */
5
+ export { VERSIONS, getDevDependencies } from './versions.js';
6
+ export * from './templates.js';
7
+ export { createProject } from './commands/create.js';
8
+ export { updateProject } from './commands/update.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC7D,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
@@ -18,9 +18,9 @@ export declare function getTsconfigTemplate(): object;
18
18
  */
19
19
  export declare function getTsconfigTemplateString(): string;
20
20
  /**
21
- * 获取 vitest.config.ts 模板内容
21
+ * 获取 vite.config.js 模板内容
22
22
  */
23
- export declare function getVitestConfigTemplate(): string;
23
+ export declare function getViteConfigTemplate(): string;
24
24
  /**
25
25
  * 获取 eslint.config.js 模板内容
26
26
  */
@@ -55,6 +55,10 @@ export declare function getPagesWorkflowTemplate(): string;
55
55
  * 获取 GitHub Actions pull-request workflow 模板内容
56
56
  */
57
57
  export declare function getPullRequestWorkflowTemplate(): string;
58
+ /**
59
+ * 获取 GitHub Actions upload-oss workflow 模板内容
60
+ */
61
+ export declare function getUploadOssWorkflowTemplate(): string;
58
62
  /**
59
63
  * 获取 .husky/pre-commit 模板内容
60
64
  */
@@ -70,25 +74,21 @@ export declare function getLicenseTemplate(ctx?: {
70
74
  */
71
75
  export declare function getVscodeSettingsTemplate(): string;
72
76
  /**
73
- * 检测可用的 schema 路径
74
- * 优先级:当前项目 -> 依赖目录
77
+ * 获取 scripts/prepublish.js 模板内容
78
+ */
79
+ export declare function getPrepublishScriptTemplate(): string;
80
+ /**
81
+ * 获取 scripts/postpublish.js 模板内容
75
82
  */
76
- export declare function detectSchemaPath(projectDir: string): string;
83
+ export declare function getPostpublishScriptTemplate(): string;
77
84
  /**
78
- * 获取 feng3d.json 模板内容
85
+ * 获取 scripts/postdocs.js 模板内容
79
86
  */
80
- export declare function getFeng3dConfigTemplate(options: {
87
+ export declare function getPostdocsScriptTemplate(): string;
88
+ /**
89
+ * 获取 src/index.ts 模板内容
90
+ */
91
+ export declare function getSrcIndexTemplate(options: {
81
92
  name: string;
82
- schemaPath?: string;
83
- }): object;
84
- /** @deprecated 请使用 getGitignoreTemplate() 函数 */
85
- export declare const gitignoreTemplate: string;
86
- /** @deprecated 请使用 getCursorrrulesTemplate() 函数 */
87
- export declare const cursorrrulesTemplate: string;
88
- /** @deprecated 请使用 getTsconfigTemplate() 函数 */
89
- export declare const tsconfigTemplate: object;
90
- /** @deprecated 请使用 getVitestConfigTemplate() 函数 */
91
- export declare const vitestConfigTemplate: string;
92
- /** @deprecated 请使用 getTypedocConfig() 函数 */
93
- export declare const createTypedocConfig: typeof getTypedocConfig;
93
+ }): string;
94
94
  //# sourceMappingURL=templates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAI7C;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAGhD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAG5C;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAGlD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAGhD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAGhD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACtC,QAAQ,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAGT;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAC9C,QAAQ,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAKT;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAGvE;AAED;;GAEG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAGnD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAGjD;AAED;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,MAAM,CAGvD;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAGlD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CAMtE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAGlD;AAUD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAc3D;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAa9F;AAGD,gDAAgD;AAChD,eAAO,MAAM,iBAAiB,QAAyB,CAAC;AACxD,mDAAmD;AACnD,eAAO,MAAM,oBAAoB,QAA4B,CAAC;AAC9D,+CAA+C;AAC/C,eAAO,MAAM,gBAAgB,QAAwB,CAAC;AACtD,mDAAmD;AACnD,eAAO,MAAM,oBAAoB,QAA4B,CAAC;AAC9D,4CAA4C;AAC5C,eAAO,MAAM,mBAAmB,yBAAmB,CAAC"}
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAI7C;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAGhD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAG5C;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAGlD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAG9C;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAGhD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACtC,QAAQ,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAGT;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAC9C,QAAQ,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAKT;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAGvE;AAED;;GAEG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAGnD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAGjD;AAED;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,MAAM,CAGvD;AAED;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,MAAM,CAGrD;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAGlD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CAMtE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAGlD;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAGpD;AAED;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,MAAM,CAGrD;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAGlD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAKrE"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * feng3d 项目统一依赖版本
3
+ * 从 templates/package.json 中读取
4
+ */
5
+ /**
6
+ * 统一依赖版本(从 templates/package.json 读取)
7
+ */
8
+ export declare const VERSIONS: Record<string, string>;
9
+ /**
10
+ * 获取 devDependencies 配置
11
+ */
12
+ export declare function getDevDependencies(options?: {
13
+ includeVitest?: boolean;
14
+ includeTypedoc?: boolean;
15
+ includeCoverage?: boolean;
16
+ }): Record<string, string>;
17
+ //# sourceMappingURL=versions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuBH;;GAEG;AACH,eAAO,MAAM,QAAQ,wBAA6B,CAAC;AAEnD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE;IACxC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;CACxB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAuB9B"}
package/package.json CHANGED
@@ -1,44 +1,37 @@
1
1
  {
2
2
  "name": "feng3d-cli",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "feng3d 项目通用标准,包含代码规范、配置模板和 CLI 工具",
5
5
  "homepage": "https://feng3d.com/feng3d-cli/",
6
6
  "author": "feng",
7
7
  "license": "MIT",
8
8
  "type": "module",
9
- "main": "./dist/index.js",
10
- "types": "./dist/index.d.ts",
9
+ "main": "./dist/index.umd.cjs",
10
+ "types": "./lib/index.d.ts",
11
+ "module": "./dist/index.js",
11
12
  "bin": {
12
- "feng3d-cli": "./dist/cli.js"
13
+ "feng3d-cli": "./bin/cli.js"
13
14
  },
14
15
  "exports": {
15
16
  ".": {
16
- "types": "./dist/index.d.ts",
17
- "import": "./dist/index.js"
18
- },
19
- "./eslint": {
20
- "types": "./dist/eslint.d.ts",
21
- "import": "./dist/eslint.js"
17
+ "types": "./src/index.ts",
18
+ "import": "./dist/index.js",
19
+ "require": "./dist/index.umd.cjs"
22
20
  }
23
21
  },
24
22
  "scripts": {
25
- "clean": "rimraf \"{lib,dist,public}\"",
26
- "build": "tsc",
27
- "dev": "tsc -w",
23
+ "clean": "rimraf lib dist public",
24
+ "build": "vite build && tsc",
25
+ "watch": "concurrently \"vite build --watch\" \"tsc -w\" \"vitest\"",
28
26
  "test": "vitest run",
29
- "test:watch": "vitest",
30
- "types": "tsc",
31
- "watch": "tsc -w",
32
27
  "lint": "eslint . --ext .js,.ts --max-warnings 0",
33
28
  "lintfix": "npm run lint -- --fix",
34
29
  "docs": "typedoc",
35
- "upload_oss": "npm run build && npm run docs && node dist/cli.js oss_upload_dir",
36
- "update": "npm run build && node dist/cli.js update && npm install",
37
- "release": "npm run clean && npm run lint && npm run build && npm run docs && npm publish",
38
- "prepublishOnly": "npm run lint && npm test && npm run build",
39
- "publish:manual": "npm publish",
40
- "prepare": "husky",
41
- "postinstall": "npm run build && node dist/cli.js update || exit 0"
30
+ "update": "npm run build && node bin/cli.js update && npm install",
31
+ "prepublishOnly": "node scripts/prepublish.js",
32
+ "release": "npm run clean && npm run lint && npm test && npm run build && npm run docs && npm publish",
33
+ "postpublish": "node scripts/postpublish.js",
34
+ "prepare": "husky"
42
35
  },
43
36
  "publishConfig": {
44
37
  "access": "public"
@@ -48,12 +41,12 @@
48
41
  "url": "https://github.com/feng3d-labs/feng3d-cli.git"
49
42
  },
50
43
  "files": [
44
+ "bin",
51
45
  "dist",
52
- "templates",
53
- "schemas"
46
+ "lib",
47
+ "templates"
54
48
  ],
55
49
  "dependencies": {
56
- "ali-oss": "^6.22.0",
57
50
  "chalk": "^5.3.0",
58
51
  "commander": "^12.1.0",
59
52
  "fs-extra": "^11.2.0"
@@ -75,7 +68,8 @@
75
68
  "typescript-eslint": "^8.32.1",
76
69
  "vite": "^6.3.5",
77
70
  "vitest": "^3.1.3",
78
- "cross-env": "7.0.3"
71
+ "cross-env": "7.0.3",
72
+ "concurrently": "^9.1.2"
79
73
  },
80
74
  "lint-staged": {
81
75
  "*.{js,ts}": [
@@ -1,15 +1,16 @@
1
1
  # 将文档发布到 GitHub Pages
2
- # 仅在主分支版本号发生变化时触发部署
2
+ # 在 npm 发布成功后自动执行,也可手动触发
3
3
  name: Deploy to GitHub Pages
4
4
 
5
5
  on:
6
- push:
7
- branches:
8
- - master
9
- - main
10
- paths:
11
- - 'package.json' # 仅在 package.json 变化时触发
12
- workflow_dispatch: # 支持手动触发
6
+ # npm 发布成功后自动触发
7
+ workflow_run:
8
+ workflows: ["Publish to NPM"]
9
+ types:
10
+ - completed
11
+
12
+ # 支持手动触发
13
+ workflow_dispatch:
13
14
 
14
15
  # 设置 GITHUB_TOKEN 的权限
15
16
  permissions:
@@ -23,40 +24,10 @@ concurrency:
23
24
  cancel-in-progress: true
24
25
 
25
26
  jobs:
26
- # 检查版本号是否变化
27
- check-version:
28
- runs-on: ubuntu-latest
29
- outputs:
30
- version_changed: ${{ steps.check.outputs.changed }}
31
- steps:
32
- - name: Checkout
33
- uses: actions/checkout@v4
34
- with:
35
- fetch-depth: 2 # 获取最近两次提交以比较版本
36
-
37
- - name: Check if version changed
38
- id: check
39
- run: |
40
- # 获取当前版本
41
- CURRENT_VERSION=$(node -p "require('./package.json').version")
42
- # 获取上一次提交的版本
43
- git checkout HEAD~1 -- package.json 2>/dev/null || echo "First commit"
44
- PREVIOUS_VERSION=$(node -p "require('./package.json').version" 2>/dev/null || echo "0.0.0")
45
- git checkout HEAD -- package.json
46
-
47
- if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
48
- echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION"
49
- echo "changed=true" >> $GITHUB_OUTPUT
50
- else
51
- echo "Version unchanged: $CURRENT_VERSION"
52
- echo "changed=false" >> $GITHUB_OUTPUT
53
- fi
54
-
55
27
  build:
56
28
  runs-on: ubuntu-latest
57
- needs: check-version
58
- # 仅在版本号变化或手动触发时构建
59
- if: needs.check-version.outputs.version_changed == 'true' || github.event_name == 'workflow_dispatch'
29
+ # 仅在 publish 成功后执行,或手动触发时执行
30
+ if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
60
31
  steps:
61
32
  - name: Checkout
62
33
  uses: actions/checkout@v4
@@ -90,4 +61,3 @@ jobs:
90
61
  - name: Deploy to GitHub Pages
91
62
  id: deployment
92
63
  uses: actions/deploy-pages@v4
93
-
@@ -58,17 +58,11 @@ jobs:
58
58
  - name: Install dependencies
59
59
  run: npm install
60
60
 
61
- - name: Build
62
- run: npm run build
63
-
64
- - name: Run lint
65
- run: npm run lint
66
-
67
61
  - name: Run tests
68
62
  run: npm test
69
63
 
70
- - name: Publish to NPM
71
- run: npm publish
64
+ - name: Release to NPM
65
+ run: npm run release
72
66
  env:
73
67
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
74
68
 
@@ -1,6 +1,6 @@
1
- # CI - 运行单元测试
2
- # 在合并到主分支或在主分支提交代码时执行
3
- name: CI
1
+ # 代码检查和测试
2
+ # 在 PR 或推送到主分支时执行
3
+ name: Lint and Test
4
4
 
5
5
  on:
6
6
  push:
@@ -0,0 +1,100 @@
1
+ # 上传文档到 OSS
2
+ # 在 npm 发布成功后自动执行,也可手动触发
3
+ name: Upload to OSS
4
+
5
+ on:
6
+ # npm 发布成功后自动触发
7
+ workflow_run:
8
+ workflows: ["Publish to NPM"]
9
+ types:
10
+ - completed
11
+
12
+ # 支持手动触发
13
+ workflow_dispatch:
14
+
15
+ jobs:
16
+ upload:
17
+ runs-on: ubuntu-latest
18
+ # 仅在 publish 成功后执行,或手动触发时执行
19
+ if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
20
+ steps:
21
+ - name: Checkout
22
+ uses: actions/checkout@v4
23
+
24
+ - name: Setup Node.js
25
+ uses: actions/setup-node@v4
26
+ with:
27
+ node-version: '20'
28
+
29
+ - name: Install dependencies
30
+ run: npm install
31
+
32
+ - name: Build docs
33
+ run: npm run docs
34
+
35
+ - name: Check OSS config
36
+ id: check_oss
37
+ run: |
38
+ if [ -z "${{ secrets.OSS_ACCESS_KEY_ID }}" ]; then
39
+ echo "OSS 未配置,跳过上传"
40
+ echo "skip=true" >> $GITHUB_OUTPUT
41
+ else
42
+ echo "skip=false" >> $GITHUB_OUTPUT
43
+ fi
44
+
45
+ - name: Upload to OSS
46
+ if: steps.check_oss.outputs.skip != 'true'
47
+ env:
48
+ OSS_REGION: ${{ secrets.OSS_REGION }}
49
+ OSS_ACCESS_KEY_ID: ${{ secrets.OSS_ACCESS_KEY_ID }}
50
+ OSS_ACCESS_KEY_SECRET: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
51
+ OSS_BUCKET: ${{ secrets.OSS_BUCKET }}
52
+ run: |
53
+ # 检查 public 目录是否存在
54
+ if [ ! -d "public" ]; then
55
+ echo "public 目录不存在,跳过 OSS 上传"
56
+ exit 0
57
+ fi
58
+
59
+ # 获取仓库名作为 OSS 目录
60
+ REPO_NAME=$(node -p "require('./package.json').name.replace(/^@[^/]+\//, '')")
61
+ echo "上传目录: $REPO_NAME"
62
+
63
+ # 安装 ali-oss
64
+ npm install ali-oss --no-save
65
+
66
+ # 执行上传
67
+ node -e "
68
+ const OSS = require('ali-oss');
69
+ const fs = require('fs');
70
+ const path = require('path');
71
+
72
+ const client = new OSS({
73
+ region: process.env.OSS_REGION,
74
+ accessKeyId: process.env.OSS_ACCESS_KEY_ID,
75
+ accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET,
76
+ bucket: process.env.OSS_BUCKET,
77
+ });
78
+
79
+ const localDir = 'public';
80
+ const ossDir = '$REPO_NAME';
81
+
82
+ async function uploadDir(dir, ossPath) {
83
+ const items = fs.readdirSync(dir);
84
+ for (const item of items) {
85
+ const localPath = path.join(dir, item);
86
+ const remotePath = ossPath + '/' + item;
87
+ if (fs.statSync(localPath).isDirectory()) {
88
+ await uploadDir(localPath, remotePath);
89
+ } else {
90
+ await client.put(remotePath, localPath);
91
+ console.log('上传: ' + remotePath);
92
+ }
93
+ }
94
+ }
95
+
96
+ uploadDir(localDir, ossDir)
97
+ .then(() => console.log('OSS 上传完成'))
98
+ .catch(err => { console.error('OSS 上传失败:', err); process.exit(1); });
99
+ "
100
+
@@ -1,2 +1,33 @@
1
- npx lint-staged
1
+ #!/bin/sh
2
2
 
3
+ echo ""
4
+ echo "🔍 [1/2] 检查代码规范..."
5
+ echo ""
6
+
7
+ if ! npx lint-staged --allow-empty; then
8
+ echo ""
9
+ echo "❌ 代码规范检查失败!"
10
+ echo ""
11
+ echo "请修复以上 ESLint 错误后再提交。"
12
+ echo "提示: 运行 'npm run lintfix' 可自动修复部分问题。"
13
+ echo ""
14
+ exit 1
15
+ fi
16
+
17
+ echo ""
18
+ echo "🧪 [2/2] 运行单元测试..."
19
+ echo ""
20
+
21
+ if ! npm test; then
22
+ echo ""
23
+ echo "❌ 单元测试失败!"
24
+ echo ""
25
+ echo "请修复测试错误后再提交。"
26
+ echo "提示: 运行 'npm test' 查看详细错误信息。"
27
+ echo ""
28
+ exit 1
29
+ fi
30
+
31
+ echo ""
32
+ echo "✅ 所有检查通过,准备提交!"
33
+ echo ""
@@ -11,13 +11,3 @@ test_dist
11
11
  # 测试覆盖率
12
12
  coverage
13
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,71 @@
1
+ {
2
+ "name": "{{name}}",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "homepage": "https://feng3d.com/{{repoName}}/",
6
+ "author": "feng",
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "main": "./src/index.ts",
10
+ "types": "./src/index.ts",
11
+ "module": "./src/index.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./src/index.ts",
15
+ "import": "./src/index.ts",
16
+ "require": "./src/index.ts"
17
+ }
18
+ },
19
+ "scripts": {
20
+ "examples:dev": "cd examples && npm run dev",
21
+ "postdocs": "node scripts/postdocs.js && cd examples && vite build --outDir ../public",
22
+ "clean": "rimraf lib dist public",
23
+ "build": "vite build && tsc",
24
+ "watch": "concurrently \"vite build --watch\" \"tsc -w\" \"vitest\"",
25
+ "test": "vitest run",
26
+ "lint": "eslint . --ext .js,.ts --max-warnings 0",
27
+ "lintfix": "npm run lint -- --fix",
28
+ "docs": "typedoc",
29
+ "prepublishOnly": "node scripts/prepublish.js",
30
+ "release": "npm run clean && npm run lint && npm test && npm run build && npm run docs && npm publish",
31
+ "postpublish": "node scripts/postpublish.js",
32
+ "prepare": "husky"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/feng3d-labs/{{repoName}}.git"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "files": [
42
+ "dist/",
43
+ "lib",
44
+ "src"
45
+ ],
46
+ "devDependencies": {
47
+ "@eslint/js": "^9.0.0",
48
+ "@typescript-eslint/eslint-plugin": "8.32.1",
49
+ "@typescript-eslint/parser": "8.32.1",
50
+ "concurrently": "^9.1.2",
51
+ "cross-env": "7.0.3",
52
+ "eslint": "9.26.0",
53
+ "globals": "^14.0.0",
54
+ "husky": "^9.1.7",
55
+ "lint-staged": "^15.2.10",
56
+ "rimraf": "6.0.1",
57
+ "tslib": "^2.8.1",
58
+ "typedoc": "^0.28.4",
59
+ "typescript": "5.8.3",
60
+ "typescript-eslint": "^8.32.1",
61
+ "vite": "^6.3.5",
62
+ "vitest": "^3.1.3"
63
+ },
64
+ "dependencies": {},
65
+ "lint-staged": {
66
+ "*.{js,ts}": [
67
+ "eslint --fix --max-warnings 0"
68
+ ]
69
+ }
70
+ }
71
+
@@ -0,0 +1,46 @@
1
+ /**
2
+ * postdocs 脚本
3
+ *
4
+ * 将 typedoc 生成的文档从 public 移动到 public/doc 目录
5
+ */
6
+
7
+ import { existsSync, mkdirSync, cpSync, rmSync } from 'fs';
8
+ import { resolve, dirname } from 'path';
9
+ import { fileURLToPath } from 'url';
10
+
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = dirname(__filename);
13
+ const rootDir = resolve(__dirname, '..');
14
+
15
+ const publicDir = resolve(rootDir, 'public');
16
+ const tempDir = resolve(rootDir, 'public_temp');
17
+ const docDir = resolve(rootDir, 'public/doc');
18
+
19
+ // 1. 复制 public 到 public_temp
20
+ if (existsSync(publicDir))
21
+ {
22
+ // 先删除临时目录(如果存在)
23
+ if (existsSync(tempDir))
24
+ {
25
+ rmSync(tempDir, { recursive: true, force: true });
26
+ }
27
+ // 复制 public 到 public_temp
28
+ cpSync(publicDir, tempDir, { recursive: true });
29
+ // 删除原 public 目录
30
+ rmSync(publicDir, { recursive: true, force: true });
31
+ }
32
+
33
+ // 2. 创建新的 public 目录
34
+ mkdirSync(publicDir, { recursive: true });
35
+
36
+ // 3. 将 public_temp 移动到 public/doc
37
+ if (existsSync(tempDir))
38
+ {
39
+ // 复制 public_temp 到 public/doc
40
+ cpSync(tempDir, docDir, { recursive: true });
41
+ // 删除 public_temp
42
+ rmSync(tempDir, { recursive: true, force: true });
43
+ }
44
+
45
+ console.log('文档已移动到 public/doc 目录');
46
+
@@ -0,0 +1,19 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+
4
+ const pkgpath = path.resolve('package.json');
5
+
6
+ let pkg = fs.readFileSync(pkgpath, 'utf8');
7
+
8
+ pkg = pkg
9
+ .replace(`"types": "./lib/index.d.ts"`, `"types": "./src/index.ts"`)
10
+ //
11
+ .replace(`"module": "./dist/index.js"`, `"module": "./src/index.ts"`)
12
+ .replace(`"main": "./dist/index.umd.cjs"`, `"main": "./src/index.ts"`)
13
+ //
14
+ .replace(`"import": "./dist/index.js"`, `"import": "./src/index.ts"`)
15
+ .replace(`"require": "./dist/index.umd.cjs"`, `"require": "./src/index.ts"`)
16
+ ;
17
+
18
+ fs.writeFileSync(pkgpath, pkg, 'utf8');
19
+
@@ -0,0 +1,19 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+
4
+ const pkgpath = path.resolve('package.json');
5
+
6
+ let pkg = fs.readFileSync(pkgpath, 'utf8');
7
+
8
+ pkg = pkg
9
+ .replace(`"types": "./src/index.ts"`, `"types": "./lib/index.d.ts"`)
10
+ //
11
+ .replace(`"module": "./src/index.ts"`, `"module": "./dist/index.js"`)
12
+ .replace(`"main": "./src/index.ts"`, `"main": "./dist/index.umd.cjs"`)
13
+ //
14
+ .replace(`"import": "./src/index.ts"`, `"import": "./dist/index.js"`)
15
+ .replace(`"require": "./src/index.ts"`, `"require": "./dist/index.umd.cjs"`)
16
+ ;
17
+
18
+ fs.writeFileSync(pkgpath, pkg, 'utf8');
19
+
@@ -0,0 +1,6 @@
1
+ /**
2
+ * {{name}}
3
+ */
4
+
5
+ export { };
6
+