@icebreakers/monorepo-templates 0.1.15 → 1.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 (80) hide show
  1. package/README.md +12 -0
  2. package/assets/.changeset/config.json +7 -2
  3. package/assets/.github/workflows/ci.yml +8 -2
  4. package/assets/.github/workflows/release.yml +2 -2
  5. package/assets/.husky/commit-msg +1 -1
  6. package/assets/.husky/pre-commit +1 -1
  7. package/assets/.husky/pre-push +5 -0
  8. package/assets/.vscode/settings.json +1 -6
  9. package/assets/AGENTS.md +8 -7
  10. package/assets/commitlint.config.ts +2 -2
  11. package/assets/eslint.config.js +2 -6
  12. package/assets/lint-staged.config.js +3 -0
  13. package/assets/package.json +39 -28
  14. package/assets/repoctl.config.ts +68 -0
  15. package/assets/stylelint.config.js +2 -2
  16. package/assets/tooling/ensure-tooling-built.mjs +24 -0
  17. package/assets/tooling/load-tooling-module.mjs +71 -0
  18. package/assets/tsconfig.json +1 -49
  19. package/assets/turbo.json +17 -6
  20. package/assets/vitest.config.ts +2 -125
  21. package/assets-data.mjs +4 -2
  22. package/dist/index.d.mts +22 -1
  23. package/dist/index.mjs +114 -30
  24. package/package.json +12 -8
  25. package/template-data.mjs +48 -8
  26. package/templates/client/eslint.config.js +6 -4
  27. package/templates/client/package.json +22 -22
  28. package/templates/client/vite.config.ts +4 -3
  29. package/templates/client/wrangler.jsonc +1 -6
  30. package/templates/server/package.json +4 -4
  31. package/templates/server/src/app.ts +4 -4
  32. package/templates/server/tsconfig.json +1 -2
  33. package/templates/server/vitest.config.ts +6 -5
  34. package/templates/server/wrangler.jsonc +1 -6
  35. package/templates/tsdown/package.json +2 -1
  36. package/templates/tsdown/test-d/index.test-d.ts +5 -0
  37. package/templates/tsdown/tsconfig.json +1 -2
  38. package/templates/tsdown/vitest.config.ts +6 -5
  39. package/templates/vitepress/.vitepress/config.ts +34 -36
  40. package/templates/vitepress/getting-started.md +243 -0
  41. package/templates/vitepress/gitignore +2 -1
  42. package/templates/vitepress/index.md +144 -79
  43. package/templates/vitepress/monorepo/commands.md +281 -0
  44. package/templates/vitepress/monorepo/index.md +103 -34
  45. package/templates/vitepress/monorepo/manage.md +181 -80
  46. package/templates/vitepress/monorepo/publish.md +128 -57
  47. package/templates/vitepress/monorepo/templates.md +67 -0
  48. package/templates/vitepress/monorepo/troubleshooting.md +207 -0
  49. package/templates/vitepress/package.json +5 -5
  50. package/templates/vitepress/thinking.md +1 -1
  51. package/templates/vitepress/tools/husky.md +7 -2
  52. package/templates/vitepress/tools/lint-staged.md +15 -1
  53. package/templates/vitepress/why/examples/usage-cjs/index.js +2 -6
  54. package/templates/vitepress/why/examples/usage-cjs/package-lock.json +7 -13
  55. package/templates/vitepress/why/examples/usage-cjs/package.json +2 -2
  56. package/templates/vitepress/why/examples/usage-esm/index.js +2 -2
  57. package/templates/vitepress/why/examples/usage-esm/package-lock.json +7 -13
  58. package/templates/vitepress/why/examples/usage-esm/package.json +2 -2
  59. package/templates/vitepress/why/modern/bundlers.md +8 -46
  60. package/templates/vue-lib/eslint.config.js +6 -4
  61. package/templates/vue-lib/package.json +17 -12
  62. package/templates/vue-lib/test-d/index.test-d.ts +6 -0
  63. package/templates/vue-lib/tsconfig.test.json +1 -1
  64. package/templates/vue-lib/vitest.config.ts +8 -5
  65. package/assets/monorepo.config.ts +0 -22
  66. package/assets/nano-staged.js +0 -18
  67. package/templates/tsup/build.config.ts +0 -24
  68. package/templates/tsup/package.json +0 -49
  69. package/templates/tsup/src/index.ts +0 -12
  70. package/templates/tsup/test/index.test.ts +0 -18
  71. package/templates/tsup/tsconfig.json +0 -15
  72. package/templates/tsup/tsup.config.ts +0 -18
  73. package/templates/tsup/vitest.config.ts +0 -15
  74. package/templates/unbuild/build.config.ts +0 -24
  75. package/templates/unbuild/package.json +0 -49
  76. package/templates/unbuild/src/index.ts +0 -9
  77. package/templates/unbuild/src/utils.ts +0 -5
  78. package/templates/unbuild/test/index.test.ts +0 -18
  79. package/templates/unbuild/tsconfig.json +0 -15
  80. package/templates/unbuild/vitest.config.ts +0 -15
package/README.md CHANGED
@@ -6,3 +6,15 @@ This package ships:
6
6
 
7
7
  - `templates/`: app and package templates
8
8
  - `assets/`: root workspace config files and upgrade assets for `monorepo`
9
+ - template metadata helpers such as `getTemplateChoices()`, `getTemplateChoice()`, and `getTemplateDefinition()`
10
+
11
+ ## Template Discovery
12
+
13
+ ```ts
14
+ import { getTemplateChoices, getTemplateDefinition } from '@icebreakers/monorepo-templates'
15
+
16
+ const libraries = getTemplateChoices({ category: 'library' })
17
+ const vitepress = getTemplateDefinition('vitepress')
18
+ ```
19
+
20
+ The returned metadata is a cloned snapshot, so callers can safely format it for CLI help, docs, or scaffold previews without mutating the package registry.
@@ -8,9 +8,14 @@
8
8
  ],
9
9
  "commit": false,
10
10
  "fixed": [],
11
- "linked": [],
11
+ "linked": [
12
+ [
13
+ "@icebreakers/monorepo",
14
+ "repoctl"
15
+ ]
16
+ ],
12
17
  "access": "public",
13
18
  "baseBranch": "main",
14
19
  "updateInternalDependencies": "patch",
15
20
  "ignore": []
16
- }
21
+ }
@@ -31,7 +31,7 @@ jobs:
31
31
  with:
32
32
  fetch-depth: 2
33
33
 
34
- - uses: pnpm/action-setup@v4
34
+ - uses: pnpm/action-setup@v6
35
35
 
36
36
  - name: Setup Node.js environment
37
37
  uses: actions/setup-node@v6
@@ -53,10 +53,16 @@ jobs:
53
53
  - name: Build
54
54
  run: pnpm build
55
55
 
56
+ - name: Typecheck
57
+ run: pnpm typecheck
58
+
59
+ - name: TSD
60
+ run: pnpm tsd
61
+
56
62
  - name: Test
57
63
  run: pnpm test
58
64
 
59
65
  - name: Upload coverage reports to Codecov
60
- uses: codecov/codecov-action@v5
66
+ uses: codecov/codecov-action@v6
61
67
  env:
62
68
  CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
@@ -24,7 +24,7 @@ jobs:
24
24
  - name: Checkout Repo
25
25
  uses: actions/checkout@v6
26
26
 
27
- - uses: pnpm/action-setup@v4
27
+ - uses: pnpm/action-setup@v6
28
28
 
29
29
  - name: Setup Node.js environment
30
30
  uses: actions/setup-node@v6
@@ -52,6 +52,6 @@ jobs:
52
52
  NPM_CONFIG_PROVENANCE: true
53
53
 
54
54
  - name: Upload coverage reports to Codecov
55
- uses: codecov/codecov-action@v5
55
+ uses: codecov/codecov-action@v6
56
56
  env:
57
57
  CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env sh
2
2
  set -e
3
3
 
4
- pnpm exec commitlint --edit "$1"
4
+ pnpm exec repo verify commit-msg "$1"
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env sh
2
2
  set -e
3
3
 
4
- pnpm exec nano-staged
4
+ pnpm exec repo verify pre-commit
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env sh
2
+ set -e
3
+
4
+ pnpm lint
5
+ pnpm typecheck
@@ -67,12 +67,7 @@
67
67
  "xml",
68
68
  "gql",
69
69
  "graphql",
70
- "astro",
71
- "css",
72
- "less",
73
- "scss",
74
- "pcss",
75
- "postcss"
70
+ "astro"
76
71
  ],
77
72
  "css.validate": false,
78
73
  "less.validate": false,
package/assets/AGENTS.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Project Structure & Module Organization
4
4
 
5
- This pnpm + Turbo monorepo keeps template sources under `templates/` (`cli`, `client`, `server`, `vitepress`, `tsup`, `tsdown`, `unbuild`, `vue-lib`) and reusable tooling under `packages/` (e.g., `monorepo`, `create-icebreaker`). Shared TypeScript and build settings live in root configs such as `turbo.json`, `tsconfig.json`, and `eslint.config.js`. Tests sit alongside their targets in `test/*.test.ts`, and each app owns its public assets (`public/`, `worker/`) to keep deployments self-contained.
5
+ This pnpm + Turbo monorepo keeps template sources under `templates/` (`cli`, `client`, `server`, `vitepress`, `tsdown`, `vue-lib`) and reusable tooling under `packages/` (e.g., `monorepo`, `create-icebreaker`). Shared TypeScript and build settings live in root configs such as `turbo.json`, `tsconfig.json`, and `eslint.config.js`. Tests sit alongside their targets in `test/*.test.ts`, and each app owns its public assets (`public/`, `worker/`) to keep deployments self-contained.
6
6
 
7
7
  ## Build, Test, and Development Commands
8
8
 
@@ -15,11 +15,11 @@ This pnpm + Turbo monorepo keeps template sources under `templates/` (`cli`, `cl
15
15
 
16
16
  ## Coding Style & Naming Conventions
17
17
 
18
- Follow the root `.editorconfig`: two-space indentation, LF line endings, UTF-8. Prefer TypeScript (`.ts`/`.tsx`) and Vue SFCs; name files with kebab-case (`user-table.vue`) and exported symbols with PascalCase for components or camelCase for utilities. ESLint (`@icebreakers/eslint-config`) and Stylelint enforce formatting; run `pnpm lint` before committing, and rely on Husky + lint-staged to auto-fix staged files. Any style-related code changes (CSS, SCSS, Less, Vue style blocks, and similar files) must pass Stylelint checks before commit. All changed code must pass ESLint checks before commit.
18
+ Follow the root `.editorconfig`: two-space indentation, LF line endings, UTF-8. Prefer TypeScript (`.ts`/`.tsx`) and Vue SFCs; name files with kebab-case (`user-table.vue`) and exported symbols with PascalCase for components or camelCase for utilities. ESLint (`@icebreakers/eslint-config`) and Stylelint enforce formatting; run `pnpm lint` before committing, and rely on Husky + lint-staged to auto-fix staged files. Any style-related code changes (CSS, SCSS, Less, Vue style blocks, and similar files) must pass Stylelint checks before commit. All changed JavaScript, TypeScript, and Vue code must pass ESLint checks before commit.
19
19
 
20
- `nano-staged.js` must include Stylelint checks for staged style files so style validation also runs during pre-commit.
20
+ `lint-staged.config.js` must include Stylelint checks for staged style files so style validation also runs during pre-commit. It must also route staged TypeScript and Vue files into workspace `typecheck` scripts so Vue workspaces run `vue-tsc` and non-Vue TypeScript workspaces run `tsc`.
21
21
 
22
- When a single code file exceeds 300 lines, treat it as a refactor signal and split it into smaller modules.
22
+ When a single code file exceeds 300 lines, treat it as a refactor signal and split it into smaller modules before commit whenever the change touches that area. Do not keep appending responsibilities to an already large file when a folder-based split would make the design clearer.
23
23
 
24
24
  When splitting code, do not create suffix-based sibling files such as `xxx.config.ts` or `xxx.filter.ts` just to move logic around. Create a dedicated folder (for example `xxx/`) and place the split modules inside it with clear responsibilities.
25
25
 
@@ -34,7 +34,7 @@ Before running tests, build the packages first and run tests against build artif
34
34
 
35
35
  TypeScript issues must be fixed before commit. Do not commit with unresolved TypeScript compile or type-check errors.
36
36
 
37
- TypeScript code must be validated with `tsc` (`pnpm typecheck` or the relevant workspace `typecheck` script) and must not contain type errors.
37
+ TypeScript code must be validated with the relevant workspace `typecheck` script and must not contain type errors. Pure TypeScript workspaces are expected to validate with `tsc` (`pnpm typecheck` or `tsc -p tsconfig.json`). Vue workspaces are expected to validate with `vue-tsc` (typically `vue-tsc -b`).
38
38
 
39
39
  When building TypeScript libraries (type-focused APIs or public type definitions), add and maintain `tsd` type tests to verify exported type behavior.
40
40
 
@@ -45,7 +45,8 @@ Commits must conform to Conventional Commit syntax; recent history uses prefixes
45
45
  For AI-generated or AI-assisted changes, use this verification order before commit or PR:
46
46
 
47
47
  1. Run build first (`pnpm build` or the relevant workspace build command).
48
- 2. Run lint checks, ensuring all changed code passes ESLint and style-related code passes Stylelint.
49
- 3. Run TypeScript checks and fix all type errors before proceeding.
48
+ 2. Run lint checks, ensuring all changed JavaScript, TypeScript, and Vue code passes ESLint and all style-related code passes Stylelint.
49
+ 3. Run TypeScript checks and fix all type errors before proceeding. Vue workspaces must pass `vue-tsc`; TypeScript workspaces must pass `tsc`.
50
50
  4. For TypeScript libraries, run `tsd` type tests and fix all failures before proceeding.
51
51
  5. Run tests against built artifacts, including unit, integration, and E2E suites (when available in the affected workspace).
52
+ 6. Before commit, review whether the touched files need splitting or refactoring; do not commit avoidable large-file growth when a clearer module boundary is apparent.
@@ -1,3 +1,3 @@
1
- import { icebreaker } from '@icebreakers/commitlint-config'
1
+ import { defineCommitlintConfig } from 'repoctl/tooling'
2
2
 
3
- export default icebreaker()
3
+ export default await defineCommitlintConfig()
@@ -1,7 +1,3 @@
1
- import { icebreaker } from '@icebreakers/eslint-config'
1
+ import { defineEslintConfig } from 'repoctl/tooling'
2
2
 
3
- export default icebreaker(
4
- {
5
- ignores: ['**/fixtures/**'],
6
- },
7
- )
3
+ export default await defineEslintConfig()
@@ -0,0 +1,3 @@
1
+ import { defineLintStagedConfig } from 'repoctl/tooling'
2
+
3
+ export default await defineLintStagedConfig()
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "version": "0.0.0",
5
5
  "private": true,
6
- "packageManager": "pnpm@10.32.1",
6
+ "packageManager": "pnpm@10.33.2",
7
7
  "author": "ice breaker <hi@sonofmagic.top>",
8
8
  "repository": {
9
9
  "type": "git",
@@ -17,15 +17,17 @@
17
17
  },
18
18
  "scripts": {
19
19
  "build": "turbo run build",
20
+ "tooling:build": "turbo run build --filter=@icebreakers/monorepo --filter=repoctl",
20
21
  "dev": "turbo run dev --parallel",
21
22
  "test": "vitest run",
22
23
  "test:dev": "vitest",
23
24
  "lint": "turbo run lint",
25
+ "tsd": "turbo run tsd",
24
26
  "audit": "pnpm audit --audit-level=moderate",
25
27
  "audit:fix": "pnpm audit --fix",
26
28
  "typecheck": "turbo run typecheck",
27
29
  "format": "eslint . --fix",
28
- "validate": "pnpm run typecheck && pnpm run lint && pnpm run test",
30
+ "validate": "pnpm run build && pnpm run lint && pnpm run typecheck && pnpm run tsd && pnpm run test",
29
31
  "release": "changeset",
30
32
  "publish-packages": "turbo run build lint test && changeset version && changeset publish",
31
33
  "------": "--------------",
@@ -34,49 +36,58 @@
34
36
  "commit": "commit",
35
37
  "commitlint": "commitlint --edit",
36
38
  "-------": "---------------",
39
+ "setup": "repo setup",
40
+ "new": "repo new",
41
+ "check": "repo check",
42
+ "doctor": "repo doctor",
43
+ "sync": "repo sync",
44
+ "clean:repo": "repo clean",
45
+ "mirror": "repo mirror",
46
+ "------simple": "--------------",
37
47
  "pr:alpha": "changeset pre enter alpha",
38
48
  "pr:beta": "changeset pre enter beta",
39
49
  "pr:rc": "changeset pre enter rc",
40
50
  "pr:exit": "changeset pre exit",
41
51
  "--------": "----------------",
42
- "script:init": "monorepo init",
43
- "script:sync": "monorepo sync",
44
- "script:clean": "monorepo clean",
45
- "script:mirror": "monorepo mirror"
52
+ "script:init": "repo init",
53
+ "script:sync": "repo sync",
54
+ "script:clean": "repo clean",
55
+ "script:mirror": "repo mirror"
46
56
  },
47
57
  "devDependencies": {
48
- "@changesets/cli": "^2.30.0",
49
- "@commitlint/cli": "^20.4.4",
50
- "@icebreakers/changelog-github": "^0.2.1",
51
- "@icebreakers/commitlint-config": "^1.2.11",
52
- "@icebreakers/eslint-config": "^1.6.29",
58
+ "@changesets/cli": "^2.31.0",
59
+ "@commitlint/cli": "^20.5.3",
60
+ "@icebreakers/changelog-github": "^1.0.2",
61
+ "@icebreakers/commitlint-config": "^2.0.0",
62
+ "@icebreakers/eslint-config": "^4.0.10",
53
63
  "@icebreakers/monorepo": "workspace:*",
54
- "@icebreakers/stylelint-config": "^2.0.4",
55
- "@types/node": "^25.5.0",
64
+ "@icebreakers/stylelint-config": "^3.0.6",
65
+ "@types/node": "^25.6.0",
56
66
  "@types/semver": "^7.7.1",
57
- "@vitest/coverage-v8": "~4.1.0",
67
+ "@vitest/coverage-v8": "~4.1.5",
58
68
  "ci-info": "^4.4.0",
59
69
  "cross-env": "^10.1.0",
60
- "defu": "^6.1.4",
61
- "es-toolkit": "^1.45.1",
62
- "eslint": "^10.0.3",
70
+ "defu": "^6.1.7",
71
+ "es-toolkit": "^1.46.1",
72
+ "eslint": "^10.3.0",
63
73
  "husky": "^9.1.7",
64
- "nano-staged": "^0.9.0",
74
+ "lint-staged": "^16.4.0",
65
75
  "only-allow": "^1.2.2",
66
76
  "pathe": "^2.0.3",
67
- "pkg-types": "^2.3.0",
68
- "stylelint": "^17.4.0",
69
- "tailwindcss": "^4.2.1",
70
- "tsdown": "0.21.2",
77
+ "pkg-types": "^2.3.1",
78
+ "repoctl": "workspace:*",
79
+ "stylelint": "^17.9.1",
80
+ "tailwindcss": "^4.2.4",
81
+ "tsd": "^0.33.0",
82
+ "tsdown": "0.21.10",
71
83
  "tslib": "^2.8.1",
72
84
  "tsup": "^8.5.1",
73
85
  "tsx": "^4.21.0",
74
- "turbo": "^2.8.17",
75
- "type-fest": "^5.4.4",
76
- "typescript": "^5.9.3",
77
- "unbuild": "^3.6.1",
78
- "vitest": "~4.1.0",
79
- "yaml": "^2.8.2"
86
+ "turbo": "^2.9.7",
87
+ "type-fest": "^5.6.0",
88
+ "typescript": "^6.0.3",
89
+ "vitest": "~4.1.5",
90
+ "yaml": "^2.8.4"
80
91
  },
81
92
  "publishConfig": {
82
93
  "access": "public",
@@ -0,0 +1,68 @@
1
+ import type { MonorepoConfig } from 'repoctl'
2
+
3
+ function createLintStagedConfig(monorepoCommand: string) {
4
+ return {
5
+ '*.{js,jsx,mjs,ts,tsx,mts,cts}': [
6
+ 'eslint --fix',
7
+ ],
8
+ '*.vue': [
9
+ 'eslint --fix',
10
+ 'stylelint --fix --allow-empty-input',
11
+ ],
12
+ '*.{ts,tsx,mts,cts,vue}': (files: string[]) => {
13
+ const uniqueFiles = [...new Set(files)]
14
+ if (uniqueFiles.length === 0) {
15
+ return []
16
+ }
17
+ return `${monorepoCommand} verify staged-typecheck ${uniqueFiles.map(file => `'${file.replaceAll('\'', '\'\\\'\'')}'`).join(' ')}`
18
+ },
19
+ '*.{json,md,mdx,html,yml,yaml}': [
20
+ 'eslint --fix',
21
+ ],
22
+ '*.{css,scss,sass,less}': [
23
+ 'stylelint --fix --allow-empty-input',
24
+ ],
25
+ }
26
+ }
27
+
28
+ export default {
29
+ commands: {
30
+ create: {
31
+ defaultTemplate: 'tsdown',
32
+ renameJson: false,
33
+ },
34
+ clean: {
35
+ autoConfirm: false,
36
+ ignorePackages: ['@icebreakers/website'],
37
+ },
38
+ upgrade: {
39
+ skipOverwrite: false,
40
+ mergeTargets: true,
41
+ },
42
+ },
43
+ tooling: {
44
+ commitlint: {
45
+ extends: ['@commitlint/config-conventional'],
46
+ },
47
+ eslint: {
48
+ ignores: ['**/fixtures/**'],
49
+ },
50
+ stylelint: {
51
+ rules: {},
52
+ },
53
+ lintStaged: {
54
+ config: createLintStagedConfig('pnpm exec repoctl'),
55
+ },
56
+ tsconfig: {
57
+ compilerOptions: {},
58
+ },
59
+ vitest: {
60
+ includeWorkspaceRootConfig: false,
61
+ coverageSkipFull: true,
62
+ },
63
+ vitestProject: {
64
+ globals: true,
65
+ testTimeout: 60_000,
66
+ },
67
+ },
68
+ } satisfies MonorepoConfig
@@ -1,3 +1,3 @@
1
- import { icebreaker } from '@icebreakers/stylelint-config'
1
+ import { defineStylelintConfig } from 'repoctl/tooling'
2
2
 
3
- export default icebreaker()
3
+ export default await defineStylelintConfig()
@@ -0,0 +1,24 @@
1
+ import { execSync } from 'node:child_process'
2
+ import { existsSync } from 'node:fs'
3
+ import path from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
5
+
6
+ const toolingMarkerPaths = [
7
+ ['packages', 'monorepo', 'dist', 'tooling-entry.mjs'],
8
+ ['packages', 'repoctl', 'dist', 'tooling-entry.mjs'],
9
+ ]
10
+
11
+ const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
12
+
13
+ export async function ensureToolingBuilt() {
14
+ const missingBuildOutput = toolingMarkerPaths.some(segments => !existsSync(path.join(rootDir, ...segments)))
15
+
16
+ if (!missingBuildOutput) {
17
+ return
18
+ }
19
+
20
+ execSync('pnpm tooling:build', {
21
+ cwd: rootDir,
22
+ stdio: 'inherit',
23
+ })
24
+ }
@@ -0,0 +1,71 @@
1
+ import path from 'node:path'
2
+ import { fileURLToPath, pathToFileURL } from 'node:url'
3
+ import { ensureToolingBuilt } from './ensure-tooling-built.mjs'
4
+
5
+ const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
6
+
7
+ const toolingEntryPaths = {
8
+ monorepo: path.join(rootDir, 'packages', 'monorepo', 'dist', 'tooling-entry.mjs'),
9
+ repoctl: path.join(rootDir, 'packages', 'repoctl', 'dist', 'tooling-entry.mjs'),
10
+ }
11
+
12
+ function getToolingImportSpecifier(entryPath, cacheBust = false) {
13
+ const fileUrl = pathToFileURL(entryPath)
14
+ return cacheBust ? `${fileUrl.href}?t=${Date.now()}` : fileUrl.href
15
+ }
16
+
17
+ export function isRecoverableToolingLoadError(error) {
18
+ if (!(error instanceof Error)) {
19
+ return false
20
+ }
21
+
22
+ const nodeError = /** @type {NodeJS.ErrnoException} */ (error)
23
+ return nodeError.code === 'ERR_MODULE_NOT_FOUND'
24
+ || nodeError.code === 'ENOENT'
25
+ || error.message.includes('Cannot find module')
26
+ || error.message.includes('No such file or directory')
27
+ }
28
+
29
+ async function importToolingEntry(entryPath, cacheBust = false) {
30
+ const specifier = getToolingImportSpecifier(entryPath, cacheBust)
31
+ return import(specifier)
32
+ }
33
+
34
+ export function createToolingModuleLoader({
35
+ ensureBuilt = ensureToolingBuilt,
36
+ importModule = importToolingEntry,
37
+ } = {}) {
38
+ return async function loadToolingModule(entryPath) {
39
+ await ensureBuilt()
40
+
41
+ try {
42
+ return await importModule(entryPath)
43
+ }
44
+ catch (error) {
45
+ if (!isRecoverableToolingLoadError(error)) {
46
+ throw error
47
+ }
48
+
49
+ await ensureBuilt()
50
+ return importModule(entryPath, true)
51
+ }
52
+ }
53
+ }
54
+
55
+ const loadToolingModule = createToolingModuleLoader()
56
+
57
+ export function loadMonorepoToolingModule() {
58
+ return loadToolingModule(toolingEntryPaths.monorepo)
59
+ }
60
+
61
+ export async function loadRepoctlToolingModule() {
62
+ try {
63
+ return await loadToolingModule(toolingEntryPaths.repoctl)
64
+ }
65
+ catch (error) {
66
+ if (!isRecoverableToolingLoadError(error)) {
67
+ throw error
68
+ }
69
+ return loadToolingModule(toolingEntryPaths.monorepo)
70
+ }
71
+ }
@@ -1,51 +1,3 @@
1
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
- }
2
+ "extends": "repoctl/tsconfig"
51
3
  }
package/assets/turbo.json CHANGED
@@ -14,7 +14,8 @@
14
14
  ],
15
15
  "outputs": [
16
16
  "dist/**",
17
- "bin/**"
17
+ "bin/**",
18
+ ".vitepress/dist/**"
18
19
  ]
19
20
  },
20
21
  "lint": {
@@ -22,12 +23,12 @@
22
23
  "^lint"
23
24
  ],
24
25
  "inputs": [
25
- "src/**",
26
- "lib/**",
27
- "test/**",
28
- "*.config.{js,ts}",
26
+ "**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts,vue}",
27
+ "**/*.{json,html,md,mdx,yml,yaml}",
28
+ "*.config.{js,ts,mjs,mts}",
29
29
  ".eslintrc*",
30
- ".stylelintrc*"
30
+ ".stylelintrc*",
31
+ "package.json"
31
32
  ],
32
33
  "outputs": []
33
34
  },
@@ -64,6 +65,16 @@
64
65
  ],
65
66
  "outputs": []
66
67
  },
68
+ "tsd": {
69
+ "inputs": [
70
+ "src/**",
71
+ "lib/**",
72
+ "test-d/**",
73
+ "package.json",
74
+ "tsconfig*.json"
75
+ ],
76
+ "outputs": []
77
+ },
67
78
  "release": {
68
79
  "cache": false
69
80
  },