@icebreakers/monorepo-templates 0.1.0 → 0.1.1
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.
- package/README.md +1 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -26
- package/package.json +1 -2
- package/skeleton/.editorconfig +0 -12
- package/skeleton/LICENSE +0 -21
- package/skeleton/commitlint.config.ts +0 -3
- package/skeleton/eslint.config.js +0 -7
- package/skeleton/gitignore +0 -38
- package/skeleton/lint-staged.config.js +0 -11
- package/skeleton/package.json +0 -88
- package/skeleton/pnpm-workspace.yaml +0 -11
- package/skeleton/renovate.json +0 -28
- package/skeleton/stylelint.config.js +0 -3
- package/skeleton/tsconfig.json +0 -51
- package/skeleton/turbo.json +0 -74
- package/skeleton/vitest.config.ts +0 -123
package/README.md
CHANGED
|
@@ -4,6 +4,5 @@ Template assets and metadata used by `create-icebreaker` and `@icebreakers/monor
|
|
|
4
4
|
|
|
5
5
|
This package ships:
|
|
6
6
|
|
|
7
|
-
- `skeleton/`: minimal root workspace config files
|
|
8
7
|
- `templates/`: app and package templates
|
|
9
|
-
- `assets/`: upgrade assets for `monorepo`
|
|
8
|
+
- `assets/`: root workspace config files and upgrade assets for `monorepo`
|
package/dist/index.d.mts
CHANGED
|
@@ -7,8 +7,8 @@ import { Command, program } from "commander";
|
|
|
7
7
|
//#region src/paths.d.ts
|
|
8
8
|
declare const packageDir: string;
|
|
9
9
|
declare const templatesDir: string;
|
|
10
|
-
declare const skeletonDir: string;
|
|
11
10
|
declare const assetsDir: string;
|
|
11
|
+
declare const skeletonDir: string;
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/prepare.d.ts
|
|
14
14
|
interface PrepareAssetsOptions {
|
package/dist/index.mjs
CHANGED
|
@@ -101,8 +101,8 @@ const templateChoices$1 = [
|
|
|
101
101
|
//#region src/paths.ts
|
|
102
102
|
const packageDir = path$1.resolve(fileURLToPath(new URL("../", import.meta.url)));
|
|
103
103
|
const templatesDir = path$1.join(packageDir, "templates");
|
|
104
|
-
const skeletonDir = path$1.join(packageDir, "skeleton");
|
|
105
104
|
const assetsDir = path$1.join(packageDir, "assets");
|
|
105
|
+
const skeletonDir = assetsDir;
|
|
106
106
|
|
|
107
107
|
//#endregion
|
|
108
108
|
//#region src/utils/gitignore.ts
|
|
@@ -171,22 +171,6 @@ function createTemplateCopyFilter(rootDir) {
|
|
|
171
171
|
|
|
172
172
|
//#endregion
|
|
173
173
|
//#region src/prepare.ts
|
|
174
|
-
const skeletonFiles = [
|
|
175
|
-
".editorconfig",
|
|
176
|
-
".gitignore",
|
|
177
|
-
".npmrc",
|
|
178
|
-
"package.json",
|
|
179
|
-
"pnpm-workspace.yaml",
|
|
180
|
-
"turbo.json",
|
|
181
|
-
"tsconfig.json",
|
|
182
|
-
"eslint.config.js",
|
|
183
|
-
"stylelint.config.js",
|
|
184
|
-
"vitest.config.ts",
|
|
185
|
-
"commitlint.config.ts",
|
|
186
|
-
"lint-staged.config.js",
|
|
187
|
-
"renovate.json",
|
|
188
|
-
"LICENSE"
|
|
189
|
-
];
|
|
190
174
|
async function pathExists(targetPath) {
|
|
191
175
|
try {
|
|
192
176
|
await fs.access(targetPath);
|
|
@@ -240,13 +224,6 @@ async function copyEntry(from, to, overwriteExisting, filter) {
|
|
|
240
224
|
throw error;
|
|
241
225
|
}
|
|
242
226
|
}
|
|
243
|
-
async function copySkeleton(repoRoot, overwriteExisting) {
|
|
244
|
-
for (const file of skeletonFiles) {
|
|
245
|
-
const from = path$1.join(repoRoot, file);
|
|
246
|
-
if (!await pathExists(from)) continue;
|
|
247
|
-
await copyEntry(from, path$1.join(skeletonDir, toPublishGitignorePath(file)), overwriteExisting);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
227
|
async function copyAssets(repoRoot, overwriteExisting) {
|
|
251
228
|
for (const target of assetTargets$1) {
|
|
252
229
|
const from = path$1.join(repoRoot, target);
|
|
@@ -273,8 +250,6 @@ async function prepareAssets(options = {}) {
|
|
|
273
250
|
if (!await pathExists(path$1.join(repoRoot, "templates"))) return;
|
|
274
251
|
await resetDir(assetsDir, overwriteExisting);
|
|
275
252
|
await resetDir(templatesDir, overwriteExisting);
|
|
276
|
-
await resetDir(skeletonDir, overwriteExisting);
|
|
277
|
-
await copySkeleton(repoRoot, overwriteExisting);
|
|
278
253
|
await copyAssets(repoRoot, overwriteExisting);
|
|
279
254
|
await copyTemplates(repoRoot, overwriteExisting);
|
|
280
255
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icebreakers/monorepo-templates",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"description": "Template assets for icebreaker monorepo scaffolding",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
"assets",
|
|
33
33
|
"assets-data.mjs",
|
|
34
34
|
"dist",
|
|
35
|
-
"skeleton",
|
|
36
35
|
"template-data.mjs",
|
|
37
36
|
"templates"
|
|
38
37
|
],
|
package/skeleton/.editorconfig
DELETED
package/skeleton/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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.
|
package/skeleton/gitignore
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}
|
package/skeleton/package.json
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
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.9",
|
|
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.44.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": "^17.0.0",
|
|
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
|
-
}
|
package/skeleton/renovate.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
}
|
package/skeleton/tsconfig.json
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
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
|
-
}
|
package/skeleton/turbo.json
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
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
|
-
})
|