@icebreakers/monorepo-templates 0.0.0

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 (201) hide show
  1. package/README.md +9 -0
  2. package/assets/.changeset/config.json +16 -0
  3. package/assets/.changeset/create-icebreaker-interactive.md +5 -0
  4. package/assets/.changeset/monorepo-templates-package.md +5 -0
  5. package/assets/.changeset/skills-sync-resources.md +5 -0
  6. package/assets/.dockerignore +44 -0
  7. package/assets/.editorconfig +12 -0
  8. package/assets/.gitattributes +218 -0
  9. package/assets/.github/FUNDING.yml +4 -0
  10. package/assets/.github/ISSUE_TEMPLATE/bug_report.yml +71 -0
  11. package/assets/.github/ISSUE_TEMPLATE/config.yml +17 -0
  12. package/assets/.github/workflows/ci.yml +62 -0
  13. package/assets/.github/workflows/release.yml +57 -0
  14. package/assets/.husky/commit-msg +4 -0
  15. package/assets/.husky/pre-commit +4 -0
  16. package/assets/.vscode/extensions.json +6 -0
  17. package/assets/.vscode/settings.json +172 -0
  18. package/assets/CODE_OF_CONDUCT.md +128 -0
  19. package/assets/CONTRIBUTING.md +3 -0
  20. package/assets/Dockerfile +27 -0
  21. package/assets/LICENSE +21 -0
  22. package/assets/SECURITY.md +21 -0
  23. package/assets/commitlint.config.ts +3 -0
  24. package/assets/eslint.config.js +7 -0
  25. package/assets/gitignore +38 -0
  26. package/assets/lint-staged.config.js +11 -0
  27. package/assets/monorepo.config.ts +22 -0
  28. package/assets/netlify.toml +14 -0
  29. package/assets/package.json +88 -0
  30. package/assets/pnpm-workspace.yaml +11 -0
  31. package/assets/renovate.json +28 -0
  32. package/assets/stylelint.config.js +3 -0
  33. package/assets/tsconfig.json +51 -0
  34. package/assets/turbo.json +74 -0
  35. package/assets/vitest.config.ts +123 -0
  36. package/assets-data.mjs +45 -0
  37. package/dist/index.d.mts +37 -0
  38. package/dist/index.mjs +287 -0
  39. package/package.json +51 -0
  40. package/skeleton/.editorconfig +12 -0
  41. package/skeleton/LICENSE +21 -0
  42. package/skeleton/commitlint.config.ts +3 -0
  43. package/skeleton/eslint.config.js +7 -0
  44. package/skeleton/gitignore +38 -0
  45. package/skeleton/lint-staged.config.js +11 -0
  46. package/skeleton/package.json +88 -0
  47. package/skeleton/pnpm-workspace.yaml +11 -0
  48. package/skeleton/renovate.json +28 -0
  49. package/skeleton/stylelint.config.js +3 -0
  50. package/skeleton/tsconfig.json +51 -0
  51. package/skeleton/turbo.json +74 -0
  52. package/skeleton/vitest.config.ts +123 -0
  53. package/template-data.mjs +10 -0
  54. package/templates/cli/bin/index.js +2 -0
  55. package/templates/cli/dev/index.ts +2 -0
  56. package/templates/cli/gitignore +2 -0
  57. package/templates/cli/package.json +35 -0
  58. package/templates/cli/src/cli.ts +4 -0
  59. package/templates/cli/src/index.ts +15 -0
  60. package/templates/cli/tsconfig.json +7 -0
  61. package/templates/cli/tsup.config.ts +13 -0
  62. package/templates/client/eslint.config.js +12 -0
  63. package/templates/client/gitignore +28 -0
  64. package/templates/client/index.html +13 -0
  65. package/templates/client/package.json +52 -0
  66. package/templates/client/public/vite.svg +1 -0
  67. package/templates/client/src/App.vue +11 -0
  68. package/templates/client/src/main.ts +16 -0
  69. package/templates/client/src/pages/index.vue +357 -0
  70. package/templates/client/src/query-keys.ts +4 -0
  71. package/templates/client/src/router/index.ts +13 -0
  72. package/templates/client/src/stores/i18n.ts +24 -0
  73. package/templates/client/src/stores/index.ts +15 -0
  74. package/templates/client/src/style.css +1 -0
  75. package/templates/client/src/trpc/index.ts +10 -0
  76. package/templates/client/src/vite-env.d.ts +2 -0
  77. package/templates/client/tsconfig.app.json +28 -0
  78. package/templates/client/tsconfig.json +8 -0
  79. package/templates/client/tsconfig.node.json +25 -0
  80. package/templates/client/tsconfig.worker.json +11 -0
  81. package/templates/client/vite.config.ts +57 -0
  82. package/templates/client/worker/app.ts +24 -0
  83. package/templates/client/worker/config.ts +1 -0
  84. package/templates/client/worker/fetch-entry.ts +5 -0
  85. package/templates/client/worker/node-entry.ts +13 -0
  86. package/templates/client/worker/trpc-router.ts +24 -0
  87. package/templates/client/wrangler.jsonc +24 -0
  88. package/templates/server/gitignore +2 -0
  89. package/templates/server/package.json +60 -0
  90. package/templates/server/src/app.ts +191 -0
  91. package/templates/server/src/config.ts +1 -0
  92. package/templates/server/src/fetch-entry.ts +5 -0
  93. package/templates/server/src/node-entry.ts +13 -0
  94. package/templates/server/test/index.test.ts +14 -0
  95. package/templates/server/tsconfig.json +24 -0
  96. package/templates/server/tsup.config.ts +13 -0
  97. package/templates/server/vitest.config.ts +15 -0
  98. package/templates/server/wrangler.jsonc +18 -0
  99. package/templates/tsdown/package.json +47 -0
  100. package/templates/tsdown/src/index.ts +5 -0
  101. package/templates/tsdown/test/index.test.ts +11 -0
  102. package/templates/tsdown/tsconfig.json +15 -0
  103. package/templates/tsdown/tsdown.config.ts +9 -0
  104. package/templates/tsdown/vitest.config.ts +15 -0
  105. package/templates/tsup/build.config.ts +24 -0
  106. package/templates/tsup/package.json +48 -0
  107. package/templates/tsup/src/index.ts +12 -0
  108. package/templates/tsup/test/index.test.ts +18 -0
  109. package/templates/tsup/tsconfig.json +15 -0
  110. package/templates/tsup/tsup.config.ts +18 -0
  111. package/templates/tsup/vitest.config.ts +15 -0
  112. package/templates/unbuild/build.config.ts +24 -0
  113. package/templates/unbuild/package.json +48 -0
  114. package/templates/unbuild/src/index.ts +9 -0
  115. package/templates/unbuild/src/utils.ts +3 -0
  116. package/templates/unbuild/test/index.test.ts +18 -0
  117. package/templates/unbuild/tsconfig.json +15 -0
  118. package/templates/unbuild/vitest.config.ts +15 -0
  119. package/templates/vitepress/.vitepress/config.ts +93 -0
  120. package/templates/vitepress/.vitepress/theme/index.ts +4 -0
  121. package/templates/vitepress/.vitepress/theme/tailwind.css +1 -0
  122. package/templates/vitepress/gitignore +1 -0
  123. package/templates/vitepress/index.md +127 -0
  124. package/templates/vitepress/monorepo/index.md +46 -0
  125. package/templates/vitepress/monorepo/manage.md +129 -0
  126. package/templates/vitepress/monorepo/publish.md +142 -0
  127. package/templates/vitepress/package.json +39 -0
  128. package/templates/vitepress/public/logo.jpg +0 -0
  129. package/templates/vitepress/thinking.md +88 -0
  130. package/templates/vitepress/tools/changeset.md +87 -0
  131. package/templates/vitepress/tools/husky.md +108 -0
  132. package/templates/vitepress/tools/lint-staged.md +79 -0
  133. package/templates/vitepress/tools/pnpm.md +101 -0
  134. package/templates/vitepress/tools/renovate.md +91 -0
  135. package/templates/vitepress/tools/turborepo.md +149 -0
  136. package/templates/vitepress/why/assets/npm-dt.svg +15 -0
  137. package/templates/vitepress/why/assets/npm-ts.svg +19 -0
  138. package/templates/vitepress/why/examples/0.npm-basic-package/index.js +10 -0
  139. package/templates/vitepress/why/examples/0.npm-basic-package/package.json +11 -0
  140. package/templates/vitepress/why/examples/1.npm-basic-package/index.cjs +12 -0
  141. package/templates/vitepress/why/examples/1.npm-basic-package/index.d.ts +1 -0
  142. package/templates/vitepress/why/examples/1.npm-basic-package/index.js +8 -0
  143. package/templates/vitepress/why/examples/1.npm-basic-package/package.json +19 -0
  144. package/templates/vitepress/why/examples/2.npm-basic-package/README.md +1 -0
  145. package/templates/vitepress/why/examples/2.npm-basic-package/package-lock.json +30 -0
  146. package/templates/vitepress/why/examples/2.npm-basic-package/package.json +35 -0
  147. package/templates/vitepress/why/examples/2.npm-basic-package/rename-ext.js +24 -0
  148. package/templates/vitepress/why/examples/2.npm-basic-package/src/index.ts +8 -0
  149. package/templates/vitepress/why/examples/2.npm-basic-package/tsconfig.cjs.json +8 -0
  150. package/templates/vitepress/why/examples/2.npm-basic-package/tsconfig.esm.json +7 -0
  151. package/templates/vitepress/why/examples/2.npm-basic-package/tsconfig.json +18 -0
  152. package/templates/vitepress/why/examples/3.npm-basic-package/README.md +1 -0
  153. package/templates/vitepress/why/examples/3.npm-basic-package/build.config.ts +24 -0
  154. package/templates/vitepress/why/examples/3.npm-basic-package/package-lock.json +3661 -0
  155. package/templates/vitepress/why/examples/3.npm-basic-package/package.json +32 -0
  156. package/templates/vitepress/why/examples/3.npm-basic-package/src/index.ts +8 -0
  157. package/templates/vitepress/why/examples/3.npm-basic-package/tsconfig.json +16 -0
  158. package/templates/vitepress/why/examples/3.npm-basic-package/tsup.config.ts +16 -0
  159. package/templates/vitepress/why/examples/usage-cjs/cjs.cjs +4 -0
  160. package/templates/vitepress/why/examples/usage-cjs/esm.mjs +4 -0
  161. package/templates/vitepress/why/examples/usage-cjs/index.js +12 -0
  162. package/templates/vitepress/why/examples/usage-cjs/package-lock.json +42 -0
  163. package/templates/vitepress/why/examples/usage-cjs/package.json +20 -0
  164. package/templates/vitepress/why/examples/usage-esm/cjs.cjs +4 -0
  165. package/templates/vitepress/why/examples/usage-esm/createRequire.js +7 -0
  166. package/templates/vitepress/why/examples/usage-esm/esm.mjs +4 -0
  167. package/templates/vitepress/why/examples/usage-esm/index.js +8 -0
  168. package/templates/vitepress/why/examples/usage-esm/package-lock.json +42 -0
  169. package/templates/vitepress/why/examples/usage-esm/package.json +21 -0
  170. package/templates/vitepress/why/how-to-reuse-js-code.md +250 -0
  171. package/templates/vitepress/why/index.md +1 -0
  172. package/templates/vitepress/why/js-cjs-mjs.md +99 -0
  173. package/templates/vitepress/why/js-keywords.md +132 -0
  174. package/templates/vitepress/why/modern/bundlers.md +79 -0
  175. package/templates/vitepress/why/modern/dts.md +93 -0
  176. package/templates/vitepress/why/modern/esm-vs-cjs.md +84 -0
  177. package/templates/vitepress/why/modern/index.md +55 -0
  178. package/templates/vitepress/why/modern/package-entry-points.md +128 -0
  179. package/templates/vitepress/why/modern/typescript.md +155 -0
  180. package/templates/vitepress/why/publish-basic-npm-package.md +146 -0
  181. package/templates/vitepress/why/what-is-npm-package.md +162 -0
  182. package/templates/vue-lib/eslint.config.js +12 -0
  183. package/templates/vue-lib/gitignore +1 -0
  184. package/templates/vue-lib/index.html +13 -0
  185. package/templates/vue-lib/lib/HelloWorld.vue +21 -0
  186. package/templates/vue-lib/lib/index.ts +3 -0
  187. package/templates/vue-lib/package.json +61 -0
  188. package/templates/vue-lib/src/App.vue +9 -0
  189. package/templates/vue-lib/src/main.ts +8 -0
  190. package/templates/vue-lib/src/pages/index.vue +7 -0
  191. package/templates/vue-lib/src/router/index.ts +11 -0
  192. package/templates/vue-lib/src/style.css +1 -0
  193. package/templates/vue-lib/src/vite-env.d.ts +2 -0
  194. package/templates/vue-lib/test/index.test.ts +13 -0
  195. package/templates/vue-lib/tsconfig.app.json +30 -0
  196. package/templates/vue-lib/tsconfig.json +14 -0
  197. package/templates/vue-lib/tsconfig.node.json +25 -0
  198. package/templates/vue-lib/tsconfig.test.json +40 -0
  199. package/templates/vue-lib/vite.config.ts +54 -0
  200. package/templates/vue-lib/vite.shared.config.ts +13 -0
  201. package/templates/vue-lib/vitest.config.ts +13 -0
@@ -0,0 +1,38 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ node_modules
5
+ .pnp
6
+ .pnp.js
7
+
8
+ # testing
9
+ coverage
10
+
11
+ # next.js
12
+ .next/
13
+ out/
14
+ build
15
+
16
+ # misc
17
+ .DS_Store
18
+ *.pem
19
+
20
+ # debug
21
+ npm-debug.log*
22
+ yarn-debug.log*
23
+ yarn-error.log*
24
+ .pnpm-debug.log*
25
+
26
+ # local env files
27
+ .env.local
28
+ .env.development.local
29
+ .env.test.local
30
+ .env.production.local
31
+
32
+ # turbo
33
+ .turbo
34
+
35
+ dist
36
+ vite.config.ts.timestamp-*.mjs
37
+ config.ts.timestamp-*.mjs
38
+ .vite-inspect
@@ -0,0 +1,11 @@
1
+ export default {
2
+ '*.{js,jsx,mjs,ts,tsx,mts,vue}': [
3
+ 'eslint --fix',
4
+ ],
5
+ '*.{json,md,mdx,css,html,yml,yaml,scss}': [
6
+ // 'prettier --with-node-modules --ignore-path .prettierignore --write',
7
+ 'eslint --fix',
8
+ ],
9
+ // for rust
10
+ // '*.rs': ['cargo fmt --'],
11
+ }
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "monorepo-template",
3
+ "type": "module",
4
+ "version": "0.0.0",
5
+ "private": true,
6
+ "packageManager": "pnpm@10.28.0",
7
+ "author": "ice breaker <1324318532@qq.com>",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/sonofmagic/monorepo-template.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/sonofmagic/monorepo-template/issues"
14
+ },
15
+ "engines": {
16
+ "node": ">=20.0.0"
17
+ },
18
+ "scripts": {
19
+ "build": "turbo run build",
20
+ "dev": "turbo run dev --parallel",
21
+ "test": "vitest run",
22
+ "test:dev": "vitest",
23
+ "lint": "turbo run lint",
24
+ "audit": "pnpm audit --audit-level=moderate",
25
+ "audit:fix": "pnpm audit --fix",
26
+ "typecheck": "turbo run typecheck",
27
+ "format": "eslint . --fix",
28
+ "validate": "pnpm run typecheck && pnpm run lint && pnpm run test",
29
+ "release": "changeset",
30
+ "publish-packages": "turbo run build lint test && changeset version && changeset publish",
31
+ "------": "--------------",
32
+ "preinstall": "npx only-allow pnpm",
33
+ "prepare": "husky",
34
+ "commit": "commit",
35
+ "commitlint": "commitlint --edit",
36
+ "-------": "---------------",
37
+ "pr:alpha": "changeset pre enter alpha",
38
+ "pr:beta": "changeset pre enter beta",
39
+ "pr:rc": "changeset pre enter rc",
40
+ "pr:exit": "changeset pre exit",
41
+ "--------": "----------------",
42
+ "script:init": "monorepo init",
43
+ "script:sync": "monorepo sync",
44
+ "script:clean": "monorepo clean",
45
+ "script:mirror": "monorepo mirror"
46
+ },
47
+ "devDependencies": {
48
+ "@changesets/cli": "^2.29.8",
49
+ "@commitlint/cli": "^20.3.1",
50
+ "@icebreakers/changelog-github": "^0.1.0",
51
+ "@icebreakers/commitlint-config": "^1.2.5",
52
+ "@icebreakers/eslint-config": "^1.6.13",
53
+ "@icebreakers/monorepo": "workspace:*",
54
+ "@icebreakers/stylelint-config": "^1.2.5",
55
+ "@types/fs-extra": "^11.0.4",
56
+ "@types/node": "^25.0.8",
57
+ "@types/semver": "^7.7.1",
58
+ "@vitest/coverage-v8": "~4.0.17",
59
+ "ci-info": "^4.3.1",
60
+ "cross-env": "^10.1.0",
61
+ "defu": "^6.1.4",
62
+ "es-toolkit": "^1.43.0",
63
+ "eslint": "^9.39.2",
64
+ "execa": "^9.6.1",
65
+ "fs-extra": "^11.3.3",
66
+ "husky": "^9.1.7",
67
+ "lint-staged": "^16.2.7",
68
+ "only-allow": "^1.2.2",
69
+ "pathe": "^2.0.3",
70
+ "pkg-types": "^2.3.0",
71
+ "rimraf": "^6.1.2",
72
+ "stylelint": "^16.26.1",
73
+ "tsdown": "0.19.0",
74
+ "tslib": "^2.8.1",
75
+ "tsup": "^8.5.1",
76
+ "tsx": "^4.21.0",
77
+ "turbo": "^2.7.4",
78
+ "type-fest": "^5.4.1",
79
+ "typescript": "^5.9.3",
80
+ "unbuild": "^3.6.1",
81
+ "vitest": "~4.0.17",
82
+ "yaml": "^2.8.2"
83
+ },
84
+ "publishConfig": {
85
+ "access": "public",
86
+ "registry": "https://registry.npmjs.org"
87
+ }
88
+ }
@@ -0,0 +1,11 @@
1
+ packages:
2
+ - apps/*
3
+ - packages/*
4
+ - templates/*
5
+ - '!**/test/**'
6
+
7
+ onlyBuiltDependencies:
8
+ - '@tailwindcss/oxide'
9
+ - esbuild
10
+ - sharp
11
+ - workerd
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "config:recommended",
5
+ "group:allNonMajor",
6
+ ":semanticCommitTypeAll(chore)"
7
+ ],
8
+ "commitBody": "[skip netlify]",
9
+ "rangeStrategy": "bump",
10
+ "npm": {
11
+ "commitMessageTopic": "{{prettyDepType}} {{depName}}"
12
+ },
13
+ "ignoreDeps": [
14
+ "node"
15
+ ],
16
+ "automerge": true,
17
+ "automergeType": "pr",
18
+ "packageRules": [
19
+ {
20
+ "matchUpdateTypes": [
21
+ "minor",
22
+ "patch",
23
+ "pin",
24
+ "digest"
25
+ ]
26
+ }
27
+ ]
28
+ }
@@ -0,0 +1,3 @@
1
+ import { icebreaker } from '@icebreakers/stylelint-config'
2
+
3
+ export default icebreaker()
@@ -0,0 +1,51 @@
1
+ {
2
+ "compilerOptions": {
3
+ // 指定 ECMAScript 目标版本,ESNext 表示支持最新的 ES 特性
4
+ "target": "ESNext",
5
+
6
+ // 指定模块系统,ESNext 使用原生 ES 模块 (import/export)
7
+ "module": "ESNext",
8
+
9
+ // 模块解析策略,Bundler 模式适用于打包工具(如 Vite、Webpack),支持更宽松的解析规则
10
+ "moduleResolution": "Bundler",
11
+
12
+ // 允许导入 .json 文件,并自动生成类型声明
13
+ "resolveJsonModule": true,
14
+
15
+ // 指定要包含的类型声明文件,node 提供 Node.js API 类型,vitest/globals 提供测试全局变量类型
16
+ "types": [
17
+ "node",
18
+ "vitest/globals"
19
+ ],
20
+
21
+ // 允许编译 JavaScript 文件,使其可以被导入和进行类型检查
22
+ "allowJs": true,
23
+
24
+ // 启用所有严格类型检查选项,包括 noImplicitAny、strictNullChecks 等
25
+ "strict": true,
26
+
27
+ // 严格检查可选属性类型,区分 undefined 和缺失的属性
28
+ "exactOptionalPropertyTypes": true,
29
+
30
+ // 要求子类重写父类方法时必须使用 override 关键字
31
+ "noImplicitOverride": true,
32
+
33
+ // 禁止通过索引签名(如 obj['key'])访问未在索引签名中定义的属性
34
+ "noPropertyAccessFromIndexSignature": true,
35
+
36
+ // 访问索引签名时返回 undefined | T,而不是 T(防止未定义访问错误)
37
+ "noUncheckedIndexedAccess": true,
38
+
39
+ // 不生成输出文件(仅用于类型检查,实际由打包工具处理编译)
40
+ "noEmit": true,
41
+
42
+ // 允许从没有默认导出的模块中默认导入(如 import React from 'react')
43
+ "allowSyntheticDefaultImports": true,
44
+
45
+ // 启用 ES 模块互操作性,为 CommonJS 模块提供 synthetic default imports
46
+ "esModuleInterop": true,
47
+
48
+ // 跳过库文件的类型检查,提高编译速度(库文件通常已经有类型声明)
49
+ "skipLibCheck": true
50
+ }
51
+ }
@@ -0,0 +1,74 @@
1
+ {
2
+ "$schema": "https://turborepo.com/schema.json",
3
+ "tasks": {
4
+ "build": {
5
+ "dependsOn": [
6
+ "^build"
7
+ ],
8
+ "inputs": [
9
+ "src/**",
10
+ "lib/**",
11
+ "package.json",
12
+ "tsconfig*.json",
13
+ "*.config.{js,ts,mjs,mts}"
14
+ ],
15
+ "outputs": [
16
+ "dist/**",
17
+ "bin/**"
18
+ ]
19
+ },
20
+ "lint": {
21
+ "dependsOn": [
22
+ "^lint"
23
+ ],
24
+ "inputs": [
25
+ "src/**",
26
+ "lib/**",
27
+ "test/**",
28
+ "*.config.{js,ts}",
29
+ ".eslintrc*",
30
+ ".stylelintrc*"
31
+ ],
32
+ "outputs": []
33
+ },
34
+ "dev": {
35
+ "cache": false,
36
+ "persistent": true
37
+ },
38
+ "test": {
39
+ "dependsOn": [
40
+ "^test"
41
+ ],
42
+ "inputs": [
43
+ "src/**",
44
+ "lib/**",
45
+ "test/**",
46
+ "package.json",
47
+ "vitest.config.{js,ts}",
48
+ "tsconfig*.json"
49
+ ],
50
+ "outputs": [
51
+ "coverage/**"
52
+ ]
53
+ },
54
+ "typecheck": {
55
+ "dependsOn": [
56
+ "^typecheck"
57
+ ],
58
+ "inputs": [
59
+ "src/**",
60
+ "lib/**",
61
+ "test/**",
62
+ "package.json",
63
+ "tsconfig*.json"
64
+ ],
65
+ "outputs": []
66
+ },
67
+ "release": {
68
+ "cache": false
69
+ },
70
+ "sync": {
71
+ "cache": false
72
+ }
73
+ }
74
+ }
@@ -0,0 +1,123 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+ import { defineConfig } from 'vitest/config'
5
+ import YAML from 'yaml'
6
+
7
+ const ROOT_DIR = path.dirname(fileURLToPath(new URL(import.meta.url)))
8
+ const WORKSPACE_FILE = path.resolve(ROOT_DIR, 'pnpm-workspace.yaml')
9
+ const CONFIG_FILENAMES = [
10
+ 'vitest.config.ts',
11
+ 'vitest.config.mts',
12
+ 'vitest.config.cts',
13
+ 'vitest.config.js',
14
+ 'vitest.config.cjs',
15
+ 'vitest.config.mjs',
16
+ ] as const
17
+
18
+ function extractBaseDirFromGlob(pattern: string): string | null {
19
+ if (!pattern) {
20
+ return null
21
+ }
22
+
23
+ const normalized = pattern
24
+ .replace(/\\/g, '/')
25
+ .replace(/^\.\//, '')
26
+ const globIndex = normalized.search(/[*?[{]/)
27
+ const base = globIndex === -1
28
+ ? normalized
29
+ : normalized.slice(0, globIndex)
30
+
31
+ const cleaned = base.replace(/\/+$/, '')
32
+ return cleaned || null
33
+ }
34
+
35
+ function loadProjectRootsFromWorkspace(): string[] {
36
+ if (!fs.existsSync(WORKSPACE_FILE)) {
37
+ return []
38
+ }
39
+
40
+ try {
41
+ const workspaceContent = fs.readFileSync(WORKSPACE_FILE, 'utf8')
42
+ const workspace = YAML.parse(workspaceContent) ?? {}
43
+ const packages: unknown[] = Array.isArray(workspace.packages) ? workspace.packages : []
44
+ const roots = packages
45
+ .map(entry => typeof entry === 'string' ? entry.trim() : '')
46
+ .filter(entry => entry && !entry.startsWith('!'))
47
+ .map(extractBaseDirFromGlob)
48
+ .filter((entry): entry is string => Boolean(entry))
49
+
50
+ return roots.length ? Array.from(new Set(roots)) : []
51
+ }
52
+ catch (error) {
53
+ console.warn('[vitest] Failed to parse pnpm-workspace.yaml, no project roots will be used.', error)
54
+ return []
55
+ }
56
+ }
57
+
58
+ const PROJECT_ROOTS = loadProjectRootsFromWorkspace()
59
+
60
+ if (!PROJECT_ROOTS.length) {
61
+ console.warn('[vitest] No project roots detected. Check pnpm-workspace.yaml to define workspace packages.')
62
+ }
63
+
64
+ function findConfig(basePath: string): string | null {
65
+ for (const filename of CONFIG_FILENAMES) {
66
+ const candidate = path.join(basePath, filename)
67
+ if (fs.existsSync(candidate)) {
68
+ return candidate
69
+ }
70
+ }
71
+ return null
72
+ }
73
+
74
+ function resolveProjects(): string[] {
75
+ const projects: string[] = []
76
+
77
+ for (const folder of PROJECT_ROOTS) {
78
+ const rootPath = path.resolve(ROOT_DIR, folder)
79
+ if (!fs.existsSync(rootPath)) {
80
+ continue
81
+ }
82
+
83
+ const rootConfig = findConfig(rootPath)
84
+ if (rootConfig) {
85
+ projects.push(rootConfig)
86
+ }
87
+
88
+ const entries = fs.readdirSync(rootPath, { withFileTypes: true })
89
+ for (const entry of entries) {
90
+ if (!entry.isDirectory()) {
91
+ continue
92
+ }
93
+
94
+ const projectDir = path.join(rootPath, entry.name)
95
+ const configPath = findConfig(projectDir)
96
+ if (configPath) {
97
+ projects.push(configPath)
98
+ }
99
+ }
100
+ }
101
+
102
+ return projects
103
+ }
104
+
105
+ const projects = resolveProjects()
106
+
107
+ export default defineConfig(() => {
108
+ return {
109
+ test: {
110
+ projects,
111
+ coverage: {
112
+ enabled: true,
113
+ skipFull: true,
114
+ exclude: [
115
+ '**/dist/**',
116
+ ],
117
+ },
118
+ forceRerunTriggers: [
119
+ '**/{vitest,vite}.config.*/**',
120
+ ],
121
+ },
122
+ }
123
+ })
@@ -0,0 +1,10 @@
1
+ export const templateChoices = [
2
+ { key: 'unbuild', label: 'unbuild 打包', source: 'unbuild', target: 'packages/unbuild' },
3
+ { key: 'tsup', label: 'tsup 打包', source: 'tsup', target: 'packages/tsup' },
4
+ { key: 'tsdown', label: 'tsdown 打包', source: 'tsdown', target: 'packages/tsdown' },
5
+ { key: 'vue-lib', label: 'vue 组件', source: 'vue-lib', target: 'packages/vue-lib' },
6
+ { key: 'vue-hono', label: 'vue hono 全栈', source: 'client', target: 'apps/client' },
7
+ { key: 'hono-server', label: 'hono 模板', source: 'server', target: 'apps/server' },
8
+ { key: 'vitepress', label: 'vitepress 文档', source: 'vitepress', target: 'apps/website' },
9
+ { key: 'cli', label: 'cli 模板', source: 'cli', target: 'apps/cli' },
10
+ ]
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/cli.js'
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env -S npx tsx
2
+ import '../src/cli.ts'
@@ -0,0 +1,2 @@
1
+ bar
2
+ t
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@icebreakers/cli",
3
+ "type": "module",
4
+ "version": "0.0.0",
5
+ "description": "icebreaker's cli template",
6
+ "author": "ice breaker <1324318532@qq.com>",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/sonofmagic/monorepo-template.git",
11
+ "directory": "templates/cli"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/sonofmagic/monorepo-template/issues"
15
+ },
16
+ "keywords": [],
17
+ "bin": {
18
+ "ice": "./dev/index.ts"
19
+ },
20
+ "scripts": {
21
+ "start": "tsx src/index.ts",
22
+ "dev": "tsup --watch --sourcemap",
23
+ "build": "tsup",
24
+ "lint": "eslint .",
25
+ "lint:fix": "eslint . --fix"
26
+ },
27
+ "dependencies": {
28
+ "consola": "^3.4.2"
29
+ },
30
+ "publishConfig": {
31
+ "bin": {
32
+ "ice": "./bin/index.js"
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,4 @@
1
+ import process from 'node:process'
2
+ import { runCli } from './index'
3
+
4
+ runCli(process.argv)
@@ -0,0 +1,15 @@
1
+ import process from 'node:process'
2
+ import { pathToFileURL } from 'node:url'
3
+ import { consola } from 'consola'
4
+
5
+ export function runCli(argv: string[] = process.argv) {
6
+ consola.info('[@icebreakers/cli]:', argv)
7
+ }
8
+
9
+ const executedFile = process.argv[1]
10
+ if (executedFile) {
11
+ const entryUrl = pathToFileURL(executedFile).href
12
+ if (entryUrl === import.meta.url) {
13
+ runCli()
14
+ }
15
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "include": [
4
+ "src",
5
+ "test"
6
+ ]
7
+ }
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from 'tsup'
2
+
3
+ export default defineConfig({
4
+ entry: ['src/index.ts', 'src/cli.ts'], // ,],
5
+ shims: true,
6
+ format: ['cjs', 'esm'],
7
+ clean: true,
8
+ dts: true,
9
+ // https://github.com/egoist/tsup/pull/1056
10
+ // https://github.com/egoist/tsup/issues?q=cjsInterop
11
+ // cjsInterop: true,
12
+ // splitting: true,
13
+ })
@@ -0,0 +1,12 @@
1
+ import { icebreaker } from '@icebreakers/eslint-config'
2
+
3
+ export default icebreaker(
4
+ {
5
+ vue: true,
6
+ typescript: true,
7
+ tailwindcss: {
8
+ entryPoint: './src/style.css',
9
+ },
10
+ ignores: ['**/fixtures/**'],
11
+ },
12
+ )
@@ -0,0 +1,28 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ dist
12
+ dist-ssr
13
+ *.local
14
+
15
+ # Editor directories and files
16
+ .vscode/*
17
+ !.vscode/extensions.json
18
+ .idea
19
+ .DS_Store
20
+ *.suo
21
+ *.ntvs*
22
+ *.njsproj
23
+ *.sln
24
+ *.sw?
25
+ src/types/typed-router.d.ts
26
+ .wrangler
27
+ .dev.vars*
28
+ worker-configuration.d.ts
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Vite + Vue + TS</title>
8
+ </head>
9
+ <body>
10
+ <div id="app"></div>
11
+ <script type="module" src="/src/main.ts"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@icebreakers/client",
3
+ "type": "module",
4
+ "version": "0.0.0",
5
+ "private": true,
6
+ "scripts": {
7
+ "dev": "vite --host",
8
+ "build": "vue-tsc -b && vite build",
9
+ "lint": "eslint .",
10
+ "lint:fix": "eslint . --fix",
11
+ "preview": "vite preview",
12
+ "deploy": "wrangler deploy",
13
+ "cf-typegen": "wrangler types",
14
+ "postinstall": "pnpm cf-typegen"
15
+ },
16
+ "dependencies": {
17
+ "@faker-js/faker": "^10.2.0",
18
+ "@tanstack/vue-query": "^5.92.6",
19
+ "@tanstack/vue-query-devtools": "^6.1.3",
20
+ "@tanstack/vue-table": "^8.21.3",
21
+ "@tanstack/vue-virtual": "^3.13.18",
22
+ "@trpc/client": "^11.8.1",
23
+ "clsx": "^2.1.1",
24
+ "pinia": "^3.0.4",
25
+ "tailwind-merge": "^3.4.0",
26
+ "tailwind-variants": "^3.2.2",
27
+ "vue": "^3.5.26",
28
+ "vue-i18n": "^11.2.8",
29
+ "vue-router": "^4.6.4"
30
+ },
31
+ "devDependencies": {
32
+ "@cloudflare/vite-plugin": "^1.20.3",
33
+ "@hono/node-server": "^1.19.9",
34
+ "@hono/trpc-server": "^0.4.2",
35
+ "@tailwindcss/vite": "^4.1.18",
36
+ "@trpc/server": "^11.8.1",
37
+ "@vitejs/plugin-vue": "^6.0.3",
38
+ "@vitejs/plugin-vue-jsx": "^5.1.3",
39
+ "@vue/tsconfig": "^0.8.1",
40
+ "consola": "^3.4.2",
41
+ "hono": "^4.11.4",
42
+ "tailwindcss": "^4.1.18",
43
+ "typescript": "~5.9.3",
44
+ "unplugin-vue-router": "^0.19.2",
45
+ "vite": "^7.3.1",
46
+ "vite-plugin-vue-devtools": "^8.0.5",
47
+ "vite-tsconfig-paths": "^6.0.4",
48
+ "vue-tsc": "3.2.2",
49
+ "wrangler": "^4.59.1",
50
+ "zod": "^4.3.5"
51
+ }
52
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,11 @@
1
+ <script setup lang="ts">
2
+ import { VueQueryDevtools } from '@tanstack/vue-query-devtools'
3
+ import { RouterView } from 'vue-router'
4
+ </script>
5
+
6
+ <template>
7
+ <div>
8
+ <RouterView />
9
+ </div>
10
+ <VueQueryDevtools />
11
+ </template>