@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,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,45 @@
1
+ const coreAssetTargets = [
2
+ '.changeset',
3
+ '.husky',
4
+ '.vscode',
5
+ '.editorconfig',
6
+ '.gitattributes',
7
+ '.gitignore',
8
+ '.npmrc',
9
+ 'commitlint.config.ts',
10
+ 'eslint.config.js',
11
+ 'lint-staged.config.js',
12
+ 'stylelint.config.js',
13
+ 'monorepo.config.ts',
14
+ 'package.json',
15
+ // pnpm
16
+ 'pnpm-workspace.yaml',
17
+ // base tsconfig
18
+ 'tsconfig.json',
19
+ // turbo
20
+ 'turbo.json',
21
+ // vitest
22
+ 'vitest.config.ts',
23
+ // 'vitest.workspace.ts',
24
+ // #region docker
25
+ 'Dockerfile',
26
+ '.dockerignore',
27
+ // #endregion
28
+ ]
29
+
30
+ const extraAssetTargets = [
31
+ // renovate
32
+ '.github',
33
+ 'LICENSE',
34
+ 'renovate.json',
35
+ 'SECURITY.md',
36
+ 'CODE_OF_CONDUCT.md',
37
+ 'CONTRIBUTING.md',
38
+ 'netlify.toml',
39
+ ]
40
+
41
+ export const assetTargets = [...coreAssetTargets, ...extraAssetTargets]
42
+
43
+ export function getAssetTargets(core = false) {
44
+ return core ? [...coreAssetTargets] : [...assetTargets]
45
+ }
@@ -0,0 +1,37 @@
1
+ //#region src/paths.d.ts
2
+ declare const packageDir: string;
3
+ declare const templatesDir: string;
4
+ declare const skeletonDir: string;
5
+ declare const assetsDir: string;
6
+ //#endregion
7
+ //#region src/prepare.d.ts
8
+ interface PrepareAssetsOptions {
9
+ overwriteExisting?: boolean;
10
+ silent?: boolean;
11
+ }
12
+ declare function prepareAssets(options?: PrepareAssetsOptions): Promise<void>;
13
+ //#endregion
14
+ //#region src/utils/gitignore.d.ts
15
+ declare function toPublishGitignorePath(input: string): string;
16
+ declare function toWorkspaceGitignorePath(input: string): string;
17
+ declare function isGitignoreFile(name: string): boolean;
18
+ //#endregion
19
+ //#region src/utils/template-filter.d.ts
20
+ declare function shouldSkipTemplatePath(rootDir: string, targetPath: string): boolean;
21
+ declare function createTemplateCopyFilter(rootDir: string): (src: string) => boolean;
22
+ //#endregion
23
+ //#region src/index.d.ts
24
+ interface TemplateChoice {
25
+ key: string;
26
+ label: string;
27
+ source: string;
28
+ target: string;
29
+ }
30
+ declare const templateChoices: TemplateChoice[];
31
+ declare const assetTargets: string[];
32
+ declare const getAssetTargets: (core?: boolean) => string[];
33
+ declare const templateSourceMap: Record<string, string>;
34
+ declare const templateTargetMap: Record<string, string>;
35
+ declare const templateMap: Record<string, string>;
36
+ //#endregion
37
+ export { TemplateChoice, assetTargets, assetsDir, createTemplateCopyFilter, getAssetTargets, isGitignoreFile, packageDir, prepareAssets, shouldSkipTemplatePath, skeletonDir, templateChoices, templateMap, templateSourceMap, templateTargetMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath };
package/dist/index.mjs ADDED
@@ -0,0 +1,287 @@
1
+ import * as path$1 from "node:path";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import fs from "node:fs/promises";
5
+
6
+ //#region assets-data.mjs
7
+ const coreAssetTargets = [
8
+ ".changeset",
9
+ ".husky",
10
+ ".vscode",
11
+ ".editorconfig",
12
+ ".gitattributes",
13
+ ".gitignore",
14
+ ".npmrc",
15
+ "commitlint.config.ts",
16
+ "eslint.config.js",
17
+ "lint-staged.config.js",
18
+ "stylelint.config.js",
19
+ "monorepo.config.ts",
20
+ "package.json",
21
+ "pnpm-workspace.yaml",
22
+ "tsconfig.json",
23
+ "turbo.json",
24
+ "vitest.config.ts",
25
+ "Dockerfile",
26
+ ".dockerignore"
27
+ ];
28
+ const extraAssetTargets = [
29
+ ".github",
30
+ "LICENSE",
31
+ "renovate.json",
32
+ "SECURITY.md",
33
+ "CODE_OF_CONDUCT.md",
34
+ "CONTRIBUTING.md",
35
+ "netlify.toml"
36
+ ];
37
+ const assetTargets$1 = [...coreAssetTargets, ...extraAssetTargets];
38
+ function getAssetTargets$1(core = false) {
39
+ return core ? [...coreAssetTargets] : [...assetTargets$1];
40
+ }
41
+
42
+ //#endregion
43
+ //#region template-data.mjs
44
+ const templateChoices$1 = [
45
+ {
46
+ key: "unbuild",
47
+ label: "unbuild 打包",
48
+ source: "unbuild",
49
+ target: "packages/unbuild"
50
+ },
51
+ {
52
+ key: "tsup",
53
+ label: "tsup 打包",
54
+ source: "tsup",
55
+ target: "packages/tsup"
56
+ },
57
+ {
58
+ key: "tsdown",
59
+ label: "tsdown 打包",
60
+ source: "tsdown",
61
+ target: "packages/tsdown"
62
+ },
63
+ {
64
+ key: "vue-lib",
65
+ label: "vue 组件",
66
+ source: "vue-lib",
67
+ target: "packages/vue-lib"
68
+ },
69
+ {
70
+ key: "vue-hono",
71
+ label: "vue hono 全栈",
72
+ source: "client",
73
+ target: "apps/client"
74
+ },
75
+ {
76
+ key: "hono-server",
77
+ label: "hono 模板",
78
+ source: "server",
79
+ target: "apps/server"
80
+ },
81
+ {
82
+ key: "vitepress",
83
+ label: "vitepress 文档",
84
+ source: "vitepress",
85
+ target: "apps/website"
86
+ },
87
+ {
88
+ key: "cli",
89
+ label: "cli 模板",
90
+ source: "cli",
91
+ target: "apps/cli"
92
+ }
93
+ ];
94
+
95
+ //#endregion
96
+ //#region src/paths.ts
97
+ const packageDir = path$1.resolve(fileURLToPath(new URL("../", import.meta.url)));
98
+ const templatesDir = path$1.join(packageDir, "templates");
99
+ const skeletonDir = path$1.join(packageDir, "skeleton");
100
+ const assetsDir = path$1.join(packageDir, "assets");
101
+
102
+ //#endregion
103
+ //#region src/utils/gitignore.ts
104
+ const publishBasename = "gitignore";
105
+ const workspaceBasename = ".gitignore";
106
+ function detectSeparator(input) {
107
+ if (input.includes("\\") && !input.includes("/")) return "\\";
108
+ return "/";
109
+ }
110
+ function replaceBasename(input, from, to) {
111
+ if (!input) return input;
112
+ const separator = detectSeparator(input);
113
+ const normalized = input.replace(/[\\/]/g, separator);
114
+ const hasTrailingSeparator = normalized.endsWith(separator);
115
+ const segments = normalized.split(separator);
116
+ if (hasTrailingSeparator && segments[segments.length - 1] === "") segments.pop();
117
+ const lastIndex = segments.length - 1;
118
+ if (lastIndex >= 0 && segments[lastIndex] === from) {
119
+ segments[lastIndex] = to;
120
+ const rebuilt = segments.join(separator);
121
+ return hasTrailingSeparator ? `${rebuilt}${separator}` : rebuilt;
122
+ }
123
+ return input;
124
+ }
125
+ function toPublishGitignorePath(input) {
126
+ return replaceBasename(input, workspaceBasename, publishBasename);
127
+ }
128
+ function toWorkspaceGitignorePath(input) {
129
+ return replaceBasename(input, publishBasename, workspaceBasename);
130
+ }
131
+ function isGitignoreFile(name) {
132
+ return toPublishGitignorePath(name) !== name || toWorkspaceGitignorePath(name) !== name;
133
+ }
134
+
135
+ //#endregion
136
+ //#region src/utils/template-filter.ts
137
+ const skipDirs = new Set([
138
+ "node_modules",
139
+ "dist",
140
+ ".turbo",
141
+ ".cache",
142
+ ".vite",
143
+ ".tmp",
144
+ ".vue-global-types",
145
+ ".wrangler"
146
+ ]);
147
+ const skipFiles = new Set([
148
+ ".DS_Store",
149
+ "typed-router.d.ts",
150
+ "worker-configuration.d.ts"
151
+ ]);
152
+ function shouldSkipTemplatePath(rootDir, targetPath) {
153
+ const basename = path.basename(targetPath);
154
+ if (skipFiles.has(basename)) return true;
155
+ if (basename.endsWith(".tsbuildinfo")) return true;
156
+ const relative = path.relative(rootDir, targetPath);
157
+ if (!relative || relative.startsWith("..")) return false;
158
+ const segments = relative.split(path.sep);
159
+ if (segments.some((segment) => skipDirs.has(segment))) return true;
160
+ for (let i = 0; i < segments.length - 1; i += 1) if (segments[i] === ".vitepress" && segments[i + 1] === "cache") return true;
161
+ return false;
162
+ }
163
+ function createTemplateCopyFilter(rootDir) {
164
+ return (src) => !shouldSkipTemplatePath(rootDir, src);
165
+ }
166
+
167
+ //#endregion
168
+ //#region src/prepare.ts
169
+ const skeletonFiles = [
170
+ ".editorconfig",
171
+ ".gitignore",
172
+ ".npmrc",
173
+ "package.json",
174
+ "pnpm-workspace.yaml",
175
+ "turbo.json",
176
+ "tsconfig.json",
177
+ "eslint.config.js",
178
+ "stylelint.config.js",
179
+ "vitest.config.ts",
180
+ "commitlint.config.ts",
181
+ "lint-staged.config.js",
182
+ "renovate.json",
183
+ "LICENSE"
184
+ ];
185
+ async function pathExists(targetPath) {
186
+ try {
187
+ await fs.access(targetPath);
188
+ return true;
189
+ } catch {
190
+ return false;
191
+ }
192
+ }
193
+ async function renameGitignoreFiles(targetDir) {
194
+ let entries;
195
+ try {
196
+ entries = await fs.readdir(targetDir, { withFileTypes: true });
197
+ } catch (error) {
198
+ if (error.code === "ENOENT") return;
199
+ throw error;
200
+ }
201
+ await Promise.all(entries.map(async (entry) => {
202
+ const current = path$1.join(targetDir, entry.name);
203
+ if (entry.isDirectory()) {
204
+ await renameGitignoreFiles(current);
205
+ return;
206
+ }
207
+ const renamed = toPublishGitignorePath(entry.name);
208
+ if (renamed !== entry.name) await fs.rename(current, path$1.join(targetDir, renamed));
209
+ }));
210
+ }
211
+ async function resetDir(targetDir, overwriteExisting) {
212
+ if (!overwriteExisting && await pathExists(targetDir)) return;
213
+ try {
214
+ await fs.rm(targetDir, {
215
+ recursive: true,
216
+ force: true
217
+ });
218
+ } catch (error) {
219
+ const err = error;
220
+ if (err?.code !== "ENOTEMPTY" && err?.code !== "EBUSY" && err?.code !== "EPERM") throw error;
221
+ }
222
+ await fs.mkdir(targetDir, { recursive: true });
223
+ }
224
+ async function copyEntry(from, to, overwriteExisting, filter) {
225
+ if (!overwriteExisting && await pathExists(to)) return;
226
+ try {
227
+ await fs.cp(from, to, {
228
+ recursive: true,
229
+ force: overwriteExisting,
230
+ filter
231
+ });
232
+ } catch (error) {
233
+ const err = error;
234
+ if (!overwriteExisting && (err?.code === "EEXIST" || err?.code === "ENOTEMPTY")) return;
235
+ throw error;
236
+ }
237
+ }
238
+ async function copySkeleton(repoRoot, overwriteExisting) {
239
+ for (const file of skeletonFiles) {
240
+ const from = path$1.join(repoRoot, file);
241
+ if (!await pathExists(from)) continue;
242
+ await copyEntry(from, path$1.join(skeletonDir, toPublishGitignorePath(file)), overwriteExisting);
243
+ }
244
+ }
245
+ async function copyAssets(repoRoot, overwriteExisting) {
246
+ for (const target of assetTargets$1) {
247
+ const from = path$1.join(repoRoot, target);
248
+ if (!await pathExists(from)) continue;
249
+ const to = path$1.join(assetsDir, toPublishGitignorePath(target));
250
+ const stats = await fs.stat(from);
251
+ await copyEntry(from, to, overwriteExisting, target === ".husky" ? (src) => !/[\\/]_$/.test(src) : void 0);
252
+ if (stats.isDirectory()) await renameGitignoreFiles(to);
253
+ }
254
+ }
255
+ async function copyTemplates(repoRoot, overwriteExisting) {
256
+ for (const template of templateChoices$1) {
257
+ const from = path$1.join(repoRoot, "templates", template.source);
258
+ if (!await pathExists(from)) continue;
259
+ const to = path$1.join(templatesDir, template.source);
260
+ const filter = (src) => !shouldSkipTemplatePath(from, src);
261
+ await copyEntry(from, to, overwriteExisting, filter);
262
+ await renameGitignoreFiles(to);
263
+ }
264
+ }
265
+ async function prepareAssets(options = {}) {
266
+ const overwriteExisting = options.overwriteExisting ?? true;
267
+ const repoRoot = path$1.resolve(packageDir, "..", "..");
268
+ if (!await pathExists(path$1.join(repoRoot, "templates"))) return;
269
+ await resetDir(assetsDir, overwriteExisting);
270
+ await resetDir(templatesDir, overwriteExisting);
271
+ await resetDir(skeletonDir, overwriteExisting);
272
+ await copySkeleton(repoRoot, overwriteExisting);
273
+ await copyAssets(repoRoot, overwriteExisting);
274
+ await copyTemplates(repoRoot, overwriteExisting);
275
+ }
276
+
277
+ //#endregion
278
+ //#region src/index.ts
279
+ const templateChoices = templateChoices$1;
280
+ const assetTargets = assetTargets$1;
281
+ const getAssetTargets = getAssetTargets$1;
282
+ const templateSourceMap = Object.fromEntries(templateChoices.map((item) => [item.key, item.source]));
283
+ const templateTargetMap = Object.fromEntries(templateChoices.map((item) => [item.key, item.target]));
284
+ const templateMap = templateSourceMap;
285
+
286
+ //#endregion
287
+ export { assetTargets, assetsDir, createTemplateCopyFilter, getAssetTargets, isGitignoreFile, packageDir, prepareAssets, shouldSkipTemplatePath, skeletonDir, templateChoices, templateMap, templateSourceMap, templateTargetMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath };
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@icebreakers/monorepo-templates",
3
+ "type": "module",
4
+ "version": "0.0.0",
5
+ "description": "Template assets for icebreaker monorepo scaffolding",
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": "packages/monorepo-templates"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/sonofmagic/monorepo-template/issues"
15
+ },
16
+ "keywords": [
17
+ "monorepo",
18
+ "template",
19
+ "scaffold"
20
+ ],
21
+ "sideEffects": false,
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "import": "./dist/index.mjs"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "main": "./dist/index.mjs",
30
+ "types": "./dist/index.d.ts",
31
+ "files": [
32
+ "assets",
33
+ "assets-data.mjs",
34
+ "dist",
35
+ "skeleton",
36
+ "template-data.mjs",
37
+ "templates"
38
+ ],
39
+ "engines": {
40
+ "node": ">=18.0.0"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "scripts": {
46
+ "dev": "tsdown --watch --sourcemap",
47
+ "build": "tsdown",
48
+ "sync:assets": "node scripts/sync-assets.mjs",
49
+ "lint": "eslint ."
50
+ }
51
+ }
@@ -0,0 +1,12 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ [*]
7
+ indent_style = space
8
+ indent_size = 2
9
+ end_of_line = lf
10
+ charset = utf-8
11
+ trim_trailing_whitespace = false
12
+ insert_final_newline = false
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ice breaker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ import { icebreaker } from '@icebreakers/commitlint-config'
2
+
3
+ export default icebreaker()
@@ -0,0 +1,7 @@
1
+ import { icebreaker } from '@icebreakers/eslint-config'
2
+
3
+ export default icebreaker(
4
+ {
5
+ ignores: ['**/fixtures/**'],
6
+ },
7
+ )