@kcconfigs/vitest 0.0.1 → 0.1.0-beta.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.
- package/CHANGELOG.md +35 -0
- package/dist/index.cjs +141 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +93 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +135 -0
- package/dist/index.js.map +1 -0
- package/dist/mockHelpers/index.cjs +10 -0
- package/dist/mockHelpers/index.d.cts +4 -0
- package/dist/mockHelpers/index.d.ts +4 -0
- package/dist/mockHelpers/index.js +5 -0
- package/package.json +69 -1
- package/src/constants.ts +48 -0
- package/src/index.test.ts +47 -0
- package/src/index.ts +8 -0
- package/src/mockHelpers/fs.ts +1 -0
- package/src/mockHelpers/index.test.ts +24 -0
- package/src/mockHelpers/index.ts +1 -0
- package/src/models.test.ts +39 -0
- package/src/models.ts +27 -0
- package/src/utils/defineEmptyProject.test.ts +70 -0
- package/src/utils/defineEmptyProject.ts +9 -0
- package/src/utils/defineEmptyRoot.test.ts +97 -0
- package/src/utils/defineEmptyRoot.ts +9 -0
- package/src/utils/defineProject.test.ts +87 -0
- package/src/utils/defineProject.ts +18 -0
- package/src/utils/defineProjectOrRoot.test.ts +88 -0
- package/src/utils/defineProjectOrRoot.ts +18 -0
- package/src/utils/defineRoot.example.ts +16 -0
- package/src/utils/defineRoot.test.ts +114 -0
- package/src/utils/defineRoot.ts +16 -0
- package/src/utils/mergeConfig.test.ts +126 -0
- package/src/utils/mergeConfig.ts +29 -0
- package/src/utils/setupMocks.test.ts +81 -0
- package/src/utils/setupMocks.ts +22 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0-beta.0 (2025-12-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **core:** move all packages into packages/* directory ([58230cd](https://github.com/kc-workspace/kcws/commit/58230cd286d0dea953d232806c91508ebfc57701))
|
|
9
|
+
* **kcconfigs/vitest:** add @kcconfigs/vitest/mocks for mocking data and add setupMocks() ([e81927a](https://github.com/kc-workspace/kcws/commit/e81927afa84e33bc280319d1b1e8ced1ca3bc569))
|
|
10
|
+
* **kcconfigs/vitest:** add source and typedoc conditions in exports ([2c9e1c3](https://github.com/kc-workspace/kcws/commit/2c9e1c3c046ab5798c51dead219bac2953233f07))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Performance Improvements
|
|
14
|
+
|
|
15
|
+
* **kcconfigs/vitest:** automatically include all ts files in coverage report ([5e2cd8f](https://github.com/kc-workspace/kcws/commit/5e2cd8fd2dad10fc4fc8d5715e3da9b7cf7c8225))
|
|
16
|
+
* **kcconfigs/vitest:** only enabled junit and html for test and text, lcov, and html for coverage ([bf2ef9e](https://github.com/kc-workspace/kcws/commit/bf2ef9e16f6b9792b3a531a92b467c5120fa35d7))
|
|
17
|
+
* **kcconfigs/vitest:** use __mocks__ instead of mocks to ignore from coverage automatically ([9767ff2](https://github.com/kc-workspace/kcws/commit/9767ff20a6dd6dce68fd3bf54bccf502a709b2a1))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bugfixes
|
|
21
|
+
|
|
22
|
+
* homepage contains invalid url ([0ee37d6](https://github.com/kc-workspace/kcws/commit/0ee37d641fe5b04fb019099915c8aa3ddfed3be7))
|
|
23
|
+
* **kcconfigs/vitest:** remove unused dependencies from package.json file ([9c237d1](https://github.com/kc-workspace/kcws/commit/9c237d151240e466f3c43f3f03f6f013e0426bd5))
|
|
24
|
+
* **kcconfigs/vitest:** temporary ignore biome useLiteralKeys as it conflict with ts(4111) ([d186810](https://github.com/kc-workspace/kcws/commit/d1868101d2cdb1d865747a24be9d1fc08322b706))
|
|
25
|
+
* trigger re-release please ([65447a7](https://github.com/kc-workspace/kcws/commit/65447a776ed2f8638f6f35a4d00277d407143114))
|
|
26
|
+
* update all [@kcconfigs](https://github.com/kcconfigs) description so it trigger new deployment with new tag separator ([cf5be8c](https://github.com/kc-workspace/kcws/commit/cf5be8cc02fba8becb7e8f31fd6f3a741c0f0b95))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Dependencies
|
|
30
|
+
|
|
31
|
+
* The following workspace dependencies were updated
|
|
32
|
+
* devDependencies
|
|
33
|
+
* @kcconfigs/tsconfig bumped to 0.1.0-beta.1
|
|
34
|
+
* @kcconfigs/tsdown bumped to 0.1.0-beta.1
|
|
35
|
+
* @kcconfigs/biome bumped to 0.1.1
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
let vitest_config = require("vitest/config");
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
|
|
5
|
+
//#region src/utils/mergeConfig.ts
|
|
6
|
+
/**
|
|
7
|
+
* Merges multiple configuration objects into a single configuration.
|
|
8
|
+
* later addons taking precedence over earlier ones.
|
|
9
|
+
*
|
|
10
|
+
* No object will be mutated during this process.
|
|
11
|
+
*
|
|
12
|
+
* @template C - The configuration object type that extends a Record with string keys
|
|
13
|
+
* @param defaults - The default configuration object
|
|
14
|
+
* @param addons - One or more configuration objects to merge into the defaults
|
|
15
|
+
* @returns The merged configuration object
|
|
16
|
+
*/
|
|
17
|
+
const mergeConfig = (defaults, ...addons) => {
|
|
18
|
+
return addons.filter((addon) => addon !== void 0 && addon !== null).reduce((merged, addon) => (0, vitest_config.mergeConfig)(merged, addon), defaults);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/utils/defineEmptyProject.ts
|
|
23
|
+
const defineEmptyProject = (...configs) => {
|
|
24
|
+
return (0, vitest_config.defineProject)(mergeConfig({}, ...configs));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/utils/defineEmptyRoot.ts
|
|
29
|
+
const defineEmptyRoot = (...configs) => {
|
|
30
|
+
return (0, vitest_config.defineConfig)(mergeConfig({}, ...configs));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/constants.ts
|
|
35
|
+
/** @internal */
|
|
36
|
+
const baseRootConfig = { test: {
|
|
37
|
+
restoreMocks: true,
|
|
38
|
+
mockReset: true,
|
|
39
|
+
clearMocks: true,
|
|
40
|
+
unstubGlobals: true,
|
|
41
|
+
unstubEnvs: true,
|
|
42
|
+
environment: "node",
|
|
43
|
+
reporters: [
|
|
44
|
+
"default",
|
|
45
|
+
"html",
|
|
46
|
+
"junit"
|
|
47
|
+
],
|
|
48
|
+
outputFile: {
|
|
49
|
+
html: "reports/test-results/index.html",
|
|
50
|
+
junit: "reports/test-results/junit.xml"
|
|
51
|
+
},
|
|
52
|
+
coverage: {
|
|
53
|
+
enabled: true,
|
|
54
|
+
provider: "v8",
|
|
55
|
+
reporter: [
|
|
56
|
+
["text"],
|
|
57
|
+
["lcovonly"],
|
|
58
|
+
["html", { subdir: "html" }]
|
|
59
|
+
],
|
|
60
|
+
reportsDirectory: "reports/coverage",
|
|
61
|
+
thresholds: { perFile: true },
|
|
62
|
+
include: ["**/*.{ts,tsx}"],
|
|
63
|
+
exclude: [
|
|
64
|
+
"**/[.]**",
|
|
65
|
+
"**/*{.,-}{test,spec}?(-d).?(c|m)[jt]s?(x)",
|
|
66
|
+
"**/__mocks__/**",
|
|
67
|
+
"**/dist/**",
|
|
68
|
+
"**/*.d.{ts,cts,mts}",
|
|
69
|
+
"**/*.example.?(c|m)[jt]s?(x)",
|
|
70
|
+
"**/*.config.?(c|m)[jt]s?(x)",
|
|
71
|
+
"**/*.schema.?(c|m)[jt]s?(x)"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
} };
|
|
75
|
+
/** @internal */
|
|
76
|
+
const baseProjectConfig = {};
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/utils/defineProject.ts
|
|
80
|
+
/**
|
|
81
|
+
* Defines the root Vitest configuration for the workspace.
|
|
82
|
+
* Merges the base root configuration with any provided user configuration.
|
|
83
|
+
*
|
|
84
|
+
* @param config - Optional user-provided Vitest configuration overrides
|
|
85
|
+
* @returns The merged root Vitest configuration
|
|
86
|
+
*
|
|
87
|
+
* @includeExample
|
|
88
|
+
*/
|
|
89
|
+
const defineProject = (...config) => {
|
|
90
|
+
return defineEmptyProject(baseRootConfig, baseProjectConfig, ...config);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/utils/defineProjectOrRoot.ts
|
|
95
|
+
/**
|
|
96
|
+
* Defines the root Vitest configuration for the workspace.
|
|
97
|
+
* Merges the base root configuration with any provided user configuration.
|
|
98
|
+
*
|
|
99
|
+
* @param config - Optional user-provided Vitest configuration overrides
|
|
100
|
+
* @returns The merged root Vitest configuration
|
|
101
|
+
*
|
|
102
|
+
* @includeExample
|
|
103
|
+
*/
|
|
104
|
+
const defineProjectOrRoot = (...config) => {
|
|
105
|
+
return defineEmptyRoot(baseRootConfig, baseProjectConfig, ...config);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/utils/defineRoot.ts
|
|
110
|
+
/**
|
|
111
|
+
* Defines the root Vitest configuration for the workspace.
|
|
112
|
+
* Merges the base root configuration with any provided user configuration.
|
|
113
|
+
*
|
|
114
|
+
* @param config - Optional user-provided Vitest configuration overrides
|
|
115
|
+
* @returns The merged root Vitest configuration
|
|
116
|
+
*
|
|
117
|
+
* @includeExample
|
|
118
|
+
*/
|
|
119
|
+
const defineRoot = (...config) => {
|
|
120
|
+
return defineEmptyRoot(baseRootConfig, ...config);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/utils/setupMocks.ts
|
|
125
|
+
const resolvePath = (name) => {
|
|
126
|
+
return (0, node_path.join)(__dirname, "..", "__mocks__", `${name}.ts`);
|
|
127
|
+
};
|
|
128
|
+
const setupMocks = (flag) => {
|
|
129
|
+
return Object.keys(flag).map((key) => flag[key] === true ? resolvePath(key) : void 0).filter((path) => path !== void 0);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
exports.defineEmptyProject = defineEmptyProject;
|
|
134
|
+
exports.defineEmptyRoot = defineEmptyRoot;
|
|
135
|
+
exports.defineProject = defineProject;
|
|
136
|
+
exports.defineProjectOrRoot = defineProjectOrRoot;
|
|
137
|
+
exports.defineRoot = defineRoot;
|
|
138
|
+
exports.mergeConfig = mergeConfig;
|
|
139
|
+
exports.setupMocks = setupMocks;
|
|
140
|
+
// Generated by @kcconfigs/tsdown
|
|
141
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["baseRootConfig: UserConfig","baseProjectConfig: UserConfig"],"sources":["../src/utils/mergeConfig.ts","../src/utils/defineEmptyProject.ts","../src/utils/defineEmptyRoot.ts","../src/constants.ts","../src/utils/defineProject.ts","../src/utils/defineProjectOrRoot.ts","../src/utils/defineRoot.ts","../src/utils/setupMocks.ts"],"sourcesContent":["import { mergeConfig as _mergeConfig } from \"vitest/config\";\nimport type { AnyConfig } from \"../models\";\n\n/**\n * Merges multiple configuration objects into a single configuration.\n * later addons taking precedence over earlier ones.\n *\n * No object will be mutated during this process.\n *\n * @template C - The configuration object type that extends a Record with string keys\n * @param defaults - The default configuration object\n * @param addons - One or more configuration objects to merge into the defaults\n * @returns The merged configuration object\n */\nexport const mergeConfig = <C extends AnyConfig>(\n\tdefaults: C,\n\t...addons: Optional<C>[]\n): C => {\n\treturn addons\n\t\t.filter((addon) => addon !== undefined && addon !== null)\n\t\t.reduce(\n\t\t\t(merged, addon) =>\n\t\t\t\t_mergeConfig(\n\t\t\t\t\tmerged as Record<string, unknown>,\n\t\t\t\t\taddon as Record<string, unknown>,\n\t\t\t\t) as C,\n\t\t\tdefaults,\n\t\t);\n};\n","import { defineProject } from \"vitest/config\";\nimport type { ProjectConfig } from \"../models\";\nimport { mergeConfig } from \"./mergeConfig\";\n\nexport const defineEmptyProject = (\n\t...configs: Optional<ProjectConfig>[]\n): ProjectConfig => {\n\treturn defineProject(mergeConfig({}, ...configs));\n};\n","import { defineConfig } from \"vitest/config\";\nimport type { UserConfig } from \"../models\";\nimport { mergeConfig } from \"./mergeConfig\";\n\nexport const defineEmptyRoot = (\n\t...configs: Optional<UserConfig>[]\n): UserConfig => {\n\treturn defineConfig(mergeConfig({}, ...configs));\n};\n","import type { UserConfig } from \"./models\";\n\n/** @internal */\nexport const baseRootConfig: UserConfig = {\n\ttest: {\n\t\trestoreMocks: true,\n\t\tmockReset: true,\n\t\tclearMocks: true,\n\t\tunstubGlobals: true,\n\t\tunstubEnvs: true,\n\t\tenvironment: \"node\",\n\t\treporters: [\"default\", \"html\", \"junit\"],\n\t\toutputFile: {\n\t\t\thtml: \"reports/test-results/index.html\",\n\t\t\tjunit: \"reports/test-results/junit.xml\",\n\t\t},\n\t\tcoverage: {\n\t\t\tenabled: true,\n\t\t\tprovider: \"v8\",\n\t\t\treporter: [[\"text\"], [\"lcovonly\"], [\"html\", { subdir: \"html\" }]],\n\t\t\treportsDirectory: \"reports/coverage\",\n\t\t\tthresholds: {\n\t\t\t\tperFile: true,\n\t\t\t},\n\t\t\tinclude: [\"**/*.{ts,tsx}\"],\n\t\t\texclude: [\n\t\t\t\t// Ignored hidden files\n\t\t\t\t\"**/[.]**\",\n\t\t\t\t// Ignored test files\n\t\t\t\t\"**/*{.,-}{test,spec}?(-d).?(c|m)[jt]s?(x)\",\n\t\t\t\t\"**/__mocks__/**\",\n\t\t\t\t// Ignored dist files\n\t\t\t\t\"**/dist/**\",\n\t\t\t\t// Ignored typescript definition files\n\t\t\t\t\"**/*.d.{ts,cts,mts}\",\n\t\t\t\t// Ignored example files\n\t\t\t\t\"**/*.example.?(c|m)[jt]s?(x)\",\n\t\t\t\t// Ignored configuration files\n\t\t\t\t\"**/*.config.?(c|m)[jt]s?(x)\",\n\t\t\t\t// Ignored schema files\n\t\t\t\t\"**/*.schema.?(c|m)[jt]s?(x)\",\n\t\t\t],\n\t\t},\n\t},\n};\n\n/** @internal */\nexport const baseProjectConfig: UserConfig = {};\n","import { baseProjectConfig, baseRootConfig } from \"../constants\";\nimport type { ProjectConfig } from \"../models\";\nimport { defineEmptyProject } from \"./defineEmptyProject\";\n\n/**\n * Defines the root Vitest configuration for the workspace.\n * Merges the base root configuration with any provided user configuration.\n *\n * @param config - Optional user-provided Vitest configuration overrides\n * @returns The merged root Vitest configuration\n *\n * @includeExample\n */\nexport const defineProject = (\n\t...config: Optional<ProjectConfig>[]\n): ProjectConfig => {\n\treturn defineEmptyProject(baseRootConfig, baseProjectConfig, ...config);\n};\n","import { baseProjectConfig, baseRootConfig } from \"../constants\";\nimport type { ProjectConfig, UserConfig } from \"../models\";\nimport { defineEmptyRoot } from \"./defineEmptyRoot\";\n\n/**\n * Defines the root Vitest configuration for the workspace.\n * Merges the base root configuration with any provided user configuration.\n *\n * @param config - Optional user-provided Vitest configuration overrides\n * @returns The merged root Vitest configuration\n *\n * @includeExample\n */\nexport const defineProjectOrRoot = (\n\t...config: Optional<UserConfig>[]\n): ProjectConfig => {\n\treturn defineEmptyRoot(baseRootConfig, baseProjectConfig, ...config);\n};\n","import { baseRootConfig } from \"../constants\";\nimport type { UserConfig } from \"../models\";\nimport { defineEmptyRoot } from \"./defineEmptyRoot\";\n\n/**\n * Defines the root Vitest configuration for the workspace.\n * Merges the base root configuration with any provided user configuration.\n *\n * @param config - Optional user-provided Vitest configuration overrides\n * @returns The merged root Vitest configuration\n *\n * @includeExample\n */\nexport const defineRoot = (...config: Optional<UserConfig>[]): UserConfig => {\n\treturn defineEmptyRoot(baseRootConfig, ...config);\n};\n","import { join } from \"node:path\";\n\nexport interface MockFlag {\n\tfs?: true;\n\tfsPromises?: true;\n\tprocess?: true;\n\tos?: true;\n}\n\nexport type MockFlagKey = keyof MockFlag;\n\nconst resolvePath = (name: string) => {\n\t// import.meta.dirname is resolved to `dist` directory\n\treturn join(import.meta.dirname, \"..\", \"__mocks__\", `${name}.ts`);\n};\n\nexport const setupMocks = (flag: MockFlag): string[] => {\n\tconst keys = Object.keys(flag) as MockFlagKey[];\n\treturn keys\n\t\t.map((key) => (flag[key] === true ? resolvePath(key) : undefined))\n\t\t.filter((path) => path !== undefined);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,MAAa,eACZ,UACA,GAAG,WACI;AACP,QAAO,OACL,QAAQ,UAAU,UAAU,UAAa,UAAU,KAAK,CACxD,QACC,QAAQ,yCAEP,QACA,MACA,EACF,SACA;;;;;ACvBH,MAAa,sBACZ,GAAG,YACgB;AACnB,yCAAqB,YAAY,EAAE,EAAE,GAAG,QAAQ,CAAC;;;;;ACHlD,MAAa,mBACZ,GAAG,YACa;AAChB,wCAAoB,YAAY,EAAE,EAAE,GAAG,QAAQ,CAAC;;;;;;ACJjD,MAAaA,iBAA6B,EACzC,MAAM;CACL,cAAc;CACd,WAAW;CACX,YAAY;CACZ,eAAe;CACf,YAAY;CACZ,aAAa;CACb,WAAW;EAAC;EAAW;EAAQ;EAAQ;CACvC,YAAY;EACX,MAAM;EACN,OAAO;EACP;CACD,UAAU;EACT,SAAS;EACT,UAAU;EACV,UAAU;GAAC,CAAC,OAAO;GAAE,CAAC,WAAW;GAAE,CAAC,QAAQ,EAAE,QAAQ,QAAQ,CAAC;GAAC;EAChE,kBAAkB;EAClB,YAAY,EACX,SAAS,MACT;EACD,SAAS,CAAC,gBAAgB;EAC1B,SAAS;GAER;GAEA;GACA;GAEA;GAEA;GAEA;GAEA;GAEA;GACA;EACD;CACD,EACD;;AAGD,MAAaC,oBAAgC,EAAE;;;;;;;;;;;;;AClC/C,MAAa,iBACZ,GAAG,WACgB;AACnB,QAAO,mBAAmB,gBAAgB,mBAAmB,GAAG,OAAO;;;;;;;;;;;;;;ACHxE,MAAa,uBACZ,GAAG,WACgB;AACnB,QAAO,gBAAgB,gBAAgB,mBAAmB,GAAG,OAAO;;;;;;;;;;;;;;ACHrE,MAAa,cAAc,GAAG,WAA+C;AAC5E,QAAO,gBAAgB,gBAAgB,GAAG,OAAO;;;;;ACHlD,MAAM,eAAe,SAAiB;AAErC,uCAAiC,MAAM,aAAa,GAAG,KAAK,KAAK;;AAGlE,MAAa,cAAc,SAA6B;AAEvD,QADa,OAAO,KAAK,KAAK,CAE5B,KAAK,QAAS,KAAK,SAAS,OAAO,YAAY,IAAI,GAAG,OAAW,CACjE,QAAQ,SAAS,SAAS,OAAU"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
import { UserWorkspaceConfig, ViteUserConfig } from "vitest/config";
|
|
3
|
+
|
|
4
|
+
//#region src/models.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generic configuration type allowing any string keys and values.
|
|
8
|
+
* Used as a flexible type for configuration merging operations.
|
|
9
|
+
*/
|
|
10
|
+
type AnyConfig = Record<string, any>;
|
|
11
|
+
/**
|
|
12
|
+
* Vitest user configuration type for root workspace setup.
|
|
13
|
+
* Extends Vite's user configuration with Vitest-specific test settings.
|
|
14
|
+
*
|
|
15
|
+
* @see https://vitest.dev/config/
|
|
16
|
+
*/
|
|
17
|
+
type UserConfig = ViteUserConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Vitest project configuration type for workspace projects.
|
|
20
|
+
* Extends Vite's workspace config with project-specific test settings.
|
|
21
|
+
*
|
|
22
|
+
* @see https://vitest.dev/config/
|
|
23
|
+
*/
|
|
24
|
+
type ProjectConfig = UserWorkspaceConfig;
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/utils/defineEmptyProject.d.ts
|
|
27
|
+
declare const defineEmptyProject: (...configs: Optional<ProjectConfig>[]) => ProjectConfig;
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/utils/defineEmptyRoot.d.ts
|
|
30
|
+
declare const defineEmptyRoot: (...configs: Optional<UserConfig>[]) => UserConfig;
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/utils/defineProject.d.ts
|
|
33
|
+
/**
|
|
34
|
+
* Defines the root Vitest configuration for the workspace.
|
|
35
|
+
* Merges the base root configuration with any provided user configuration.
|
|
36
|
+
*
|
|
37
|
+
* @param config - Optional user-provided Vitest configuration overrides
|
|
38
|
+
* @returns The merged root Vitest configuration
|
|
39
|
+
*
|
|
40
|
+
* @includeExample
|
|
41
|
+
*/
|
|
42
|
+
declare const defineProject: (...config: Optional<ProjectConfig>[]) => ProjectConfig;
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/utils/defineProjectOrRoot.d.ts
|
|
45
|
+
/**
|
|
46
|
+
* Defines the root Vitest configuration for the workspace.
|
|
47
|
+
* Merges the base root configuration with any provided user configuration.
|
|
48
|
+
*
|
|
49
|
+
* @param config - Optional user-provided Vitest configuration overrides
|
|
50
|
+
* @returns The merged root Vitest configuration
|
|
51
|
+
*
|
|
52
|
+
* @includeExample
|
|
53
|
+
*/
|
|
54
|
+
declare const defineProjectOrRoot: (...config: Optional<UserConfig>[]) => ProjectConfig;
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/utils/defineRoot.d.ts
|
|
57
|
+
/**
|
|
58
|
+
* Defines the root Vitest configuration for the workspace.
|
|
59
|
+
* Merges the base root configuration with any provided user configuration.
|
|
60
|
+
*
|
|
61
|
+
* @param config - Optional user-provided Vitest configuration overrides
|
|
62
|
+
* @returns The merged root Vitest configuration
|
|
63
|
+
*
|
|
64
|
+
* @includeExample
|
|
65
|
+
*/
|
|
66
|
+
declare const defineRoot: (...config: Optional<UserConfig>[]) => UserConfig;
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/utils/mergeConfig.d.ts
|
|
69
|
+
/**
|
|
70
|
+
* Merges multiple configuration objects into a single configuration.
|
|
71
|
+
* later addons taking precedence over earlier ones.
|
|
72
|
+
*
|
|
73
|
+
* No object will be mutated during this process.
|
|
74
|
+
*
|
|
75
|
+
* @template C - The configuration object type that extends a Record with string keys
|
|
76
|
+
* @param defaults - The default configuration object
|
|
77
|
+
* @param addons - One or more configuration objects to merge into the defaults
|
|
78
|
+
* @returns The merged configuration object
|
|
79
|
+
*/
|
|
80
|
+
declare const mergeConfig: <C extends AnyConfig>(defaults: C, ...addons: Optional<C>[]) => C;
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/utils/setupMocks.d.ts
|
|
83
|
+
interface MockFlag {
|
|
84
|
+
fs?: true;
|
|
85
|
+
fsPromises?: true;
|
|
86
|
+
process?: true;
|
|
87
|
+
os?: true;
|
|
88
|
+
}
|
|
89
|
+
declare const setupMocks: (flag: MockFlag) => string[];
|
|
90
|
+
//#endregion
|
|
91
|
+
export { type AnyConfig, type ProjectConfig, type UserConfig, defineEmptyProject, defineEmptyRoot, defineProject, defineProjectOrRoot, defineRoot, mergeConfig, setupMocks };
|
|
92
|
+
// Generated by @kcconfigs/tsdown
|
|
93
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/models.ts","../src/utils/defineEmptyProject.ts","../src/utils/defineEmptyRoot.ts","../src/utils/defineProject.ts","../src/utils/defineProjectOrRoot.ts","../src/utils/defineRoot.ts","../src/utils/mergeConfig.ts","../src/utils/setupMocks.ts"],"sourcesContent":[],"mappings":";;;;;;;AAUA;AAQA;AAQY,KAhBA,SAAA,GAAY,MAgBZ,CAAgB,MAAA,EAAA,GAAA,CAAA;;;;ACtB5B;;;AAEG,KDYS,UAAA,GAAa,cCZtB;;;;;ACFH;;AACa,KFqBD,aAAA,GAAgB,mBErBf;;;cDDA,iCACA,SAAS,qBACnB;;;cCFU,8BACA,SAAS,kBACnB;;;;;AFIH;AAQA;AAQA;;;;ACtBA;AACsB,cEQT,aFRS,EAAA,CAAA,GAAA,MAAA,EESV,QFTU,CESD,aFTC,CAAA,EAAA,EAAA,GEUnB,aFVmB;;;;;ADKtB;AAQA;AAQA;;;;ACtBA;AACsB,cGQT,mBHRS,EAAA,CAAA,GAAA,MAAA,EGSV,QHTU,CGSD,UHTC,CAAA,EAAA,EAAA,GGUnB,aHVmB;;;;;ADKtB;AAQA;AAQA;;;;ACtBA;AACsB,cIQT,UJRS,EAAA,CAAA,GAAA,MAAA,EIQgB,QJRhB,CIQyB,UJRzB,CAAA,EAAA,EAAA,GIQyC,UJRzC;;;;;ADKtB;AAQA;AAQA;;;;ACtBA;;;AAEG,cKQU,WLRV,EAAA,CAAA,UKQmC,SLRnC,CAAA,CAAA,QAAA,EKSQ,CLTR,EAAA,GAAA,MAAA,EKUS,QLVT,CKUkB,CLVlB,CAAA,EAAA,EAAA,GKWA,CLXA;;;UMJc,QAAA;;;EPQjB,OAAY,CAAA,EAAA,IAAA;EAQZ,EAAA,CAAY,EAAA,IAAA;AAQZ;cOVa,mBAAoB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
import { UserWorkspaceConfig, ViteUserConfig } from "vitest/config";
|
|
3
|
+
|
|
4
|
+
//#region src/models.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generic configuration type allowing any string keys and values.
|
|
8
|
+
* Used as a flexible type for configuration merging operations.
|
|
9
|
+
*/
|
|
10
|
+
type AnyConfig = Record<string, any>;
|
|
11
|
+
/**
|
|
12
|
+
* Vitest user configuration type for root workspace setup.
|
|
13
|
+
* Extends Vite's user configuration with Vitest-specific test settings.
|
|
14
|
+
*
|
|
15
|
+
* @see https://vitest.dev/config/
|
|
16
|
+
*/
|
|
17
|
+
type UserConfig = ViteUserConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Vitest project configuration type for workspace projects.
|
|
20
|
+
* Extends Vite's workspace config with project-specific test settings.
|
|
21
|
+
*
|
|
22
|
+
* @see https://vitest.dev/config/
|
|
23
|
+
*/
|
|
24
|
+
type ProjectConfig = UserWorkspaceConfig;
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/utils/defineEmptyProject.d.ts
|
|
27
|
+
declare const defineEmptyProject: (...configs: Optional<ProjectConfig>[]) => ProjectConfig;
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/utils/defineEmptyRoot.d.ts
|
|
30
|
+
declare const defineEmptyRoot: (...configs: Optional<UserConfig>[]) => UserConfig;
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/utils/defineProject.d.ts
|
|
33
|
+
/**
|
|
34
|
+
* Defines the root Vitest configuration for the workspace.
|
|
35
|
+
* Merges the base root configuration with any provided user configuration.
|
|
36
|
+
*
|
|
37
|
+
* @param config - Optional user-provided Vitest configuration overrides
|
|
38
|
+
* @returns The merged root Vitest configuration
|
|
39
|
+
*
|
|
40
|
+
* @includeExample
|
|
41
|
+
*/
|
|
42
|
+
declare const defineProject: (...config: Optional<ProjectConfig>[]) => ProjectConfig;
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/utils/defineProjectOrRoot.d.ts
|
|
45
|
+
/**
|
|
46
|
+
* Defines the root Vitest configuration for the workspace.
|
|
47
|
+
* Merges the base root configuration with any provided user configuration.
|
|
48
|
+
*
|
|
49
|
+
* @param config - Optional user-provided Vitest configuration overrides
|
|
50
|
+
* @returns The merged root Vitest configuration
|
|
51
|
+
*
|
|
52
|
+
* @includeExample
|
|
53
|
+
*/
|
|
54
|
+
declare const defineProjectOrRoot: (...config: Optional<UserConfig>[]) => ProjectConfig;
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/utils/defineRoot.d.ts
|
|
57
|
+
/**
|
|
58
|
+
* Defines the root Vitest configuration for the workspace.
|
|
59
|
+
* Merges the base root configuration with any provided user configuration.
|
|
60
|
+
*
|
|
61
|
+
* @param config - Optional user-provided Vitest configuration overrides
|
|
62
|
+
* @returns The merged root Vitest configuration
|
|
63
|
+
*
|
|
64
|
+
* @includeExample
|
|
65
|
+
*/
|
|
66
|
+
declare const defineRoot: (...config: Optional<UserConfig>[]) => UserConfig;
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/utils/mergeConfig.d.ts
|
|
69
|
+
/**
|
|
70
|
+
* Merges multiple configuration objects into a single configuration.
|
|
71
|
+
* later addons taking precedence over earlier ones.
|
|
72
|
+
*
|
|
73
|
+
* No object will be mutated during this process.
|
|
74
|
+
*
|
|
75
|
+
* @template C - The configuration object type that extends a Record with string keys
|
|
76
|
+
* @param defaults - The default configuration object
|
|
77
|
+
* @param addons - One or more configuration objects to merge into the defaults
|
|
78
|
+
* @returns The merged configuration object
|
|
79
|
+
*/
|
|
80
|
+
declare const mergeConfig: <C extends AnyConfig>(defaults: C, ...addons: Optional<C>[]) => C;
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/utils/setupMocks.d.ts
|
|
83
|
+
interface MockFlag {
|
|
84
|
+
fs?: true;
|
|
85
|
+
fsPromises?: true;
|
|
86
|
+
process?: true;
|
|
87
|
+
os?: true;
|
|
88
|
+
}
|
|
89
|
+
declare const setupMocks: (flag: MockFlag) => string[];
|
|
90
|
+
//#endregion
|
|
91
|
+
export { type AnyConfig, type ProjectConfig, type UserConfig, defineEmptyProject, defineEmptyRoot, defineProject, defineProjectOrRoot, defineRoot, mergeConfig, setupMocks };
|
|
92
|
+
// Generated by @kcconfigs/tsdown
|
|
93
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/models.ts","../src/utils/defineEmptyProject.ts","../src/utils/defineEmptyRoot.ts","../src/utils/defineProject.ts","../src/utils/defineProjectOrRoot.ts","../src/utils/defineRoot.ts","../src/utils/mergeConfig.ts","../src/utils/setupMocks.ts"],"sourcesContent":[],"mappings":";;;;;;;AAUA;AAQA;AAQY,KAhBA,SAAA,GAAY,MAgBZ,CAAgB,MAAA,EAAA,GAAA,CAAA;;;;ACtB5B;;;AAEG,KDYS,UAAA,GAAa,cCZtB;;;;;ACFH;;AACa,KFqBD,aAAA,GAAgB,mBErBf;;;cDDA,iCACA,SAAS,qBACnB;;;cCFU,8BACA,SAAS,kBACnB;;;;;AFIH;AAQA;AAQA;;;;ACtBA;AACsB,cEQT,aFRS,EAAA,CAAA,GAAA,MAAA,EESV,QFTU,CESD,aFTC,CAAA,EAAA,EAAA,GEUnB,aFVmB;;;;;ADKtB;AAQA;AAQA;;;;ACtBA;AACsB,cGQT,mBHRS,EAAA,CAAA,GAAA,MAAA,EGSV,QHTU,CGSD,UHTC,CAAA,EAAA,EAAA,GGUnB,aHVmB;;;;;ADKtB;AAQA;AAQA;;;;ACtBA;AACsB,cIQT,UJRS,EAAA,CAAA,GAAA,MAAA,EIQgB,QJRhB,CIQyB,UJRzB,CAAA,EAAA,EAAA,GIQyC,UJRzC;;;;;ADKtB;AAQA;AAQA;;;;ACtBA;;;AAEG,cKQU,WLRV,EAAA,CAAA,UKQmC,SLRnC,CAAA,CAAA,QAAA,EKSQ,CLTR,EAAA,GAAA,MAAA,EKUS,QLVT,CKUkB,CLVlB,CAAA,EAAA,EAAA,GKWA,CLXA;;;UMJc,QAAA;;;EPQjB,OAAY,CAAA,EAAA,IAAA;EAQZ,EAAA,CAAY,EAAA,IAAA;AAQZ;cOVa,mBAAoB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// @generated by tsdown, DO NOT edit it manually
|
|
2
|
+
import { defineConfig, defineProject as defineProject$1, mergeConfig as mergeConfig$1 } from "vitest/config";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/utils/mergeConfig.ts
|
|
6
|
+
/**
|
|
7
|
+
* Merges multiple configuration objects into a single configuration.
|
|
8
|
+
* later addons taking precedence over earlier ones.
|
|
9
|
+
*
|
|
10
|
+
* No object will be mutated during this process.
|
|
11
|
+
*
|
|
12
|
+
* @template C - The configuration object type that extends a Record with string keys
|
|
13
|
+
* @param defaults - The default configuration object
|
|
14
|
+
* @param addons - One or more configuration objects to merge into the defaults
|
|
15
|
+
* @returns The merged configuration object
|
|
16
|
+
*/
|
|
17
|
+
const mergeConfig = (defaults, ...addons) => {
|
|
18
|
+
return addons.filter((addon) => addon !== void 0 && addon !== null).reduce((merged, addon) => mergeConfig$1(merged, addon), defaults);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/utils/defineEmptyProject.ts
|
|
23
|
+
const defineEmptyProject = (...configs) => {
|
|
24
|
+
return defineProject$1(mergeConfig({}, ...configs));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/utils/defineEmptyRoot.ts
|
|
29
|
+
const defineEmptyRoot = (...configs) => {
|
|
30
|
+
return defineConfig(mergeConfig({}, ...configs));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/constants.ts
|
|
35
|
+
/** @internal */
|
|
36
|
+
const baseRootConfig = { test: {
|
|
37
|
+
restoreMocks: true,
|
|
38
|
+
mockReset: true,
|
|
39
|
+
clearMocks: true,
|
|
40
|
+
unstubGlobals: true,
|
|
41
|
+
unstubEnvs: true,
|
|
42
|
+
environment: "node",
|
|
43
|
+
reporters: [
|
|
44
|
+
"default",
|
|
45
|
+
"html",
|
|
46
|
+
"junit"
|
|
47
|
+
],
|
|
48
|
+
outputFile: {
|
|
49
|
+
html: "reports/test-results/index.html",
|
|
50
|
+
junit: "reports/test-results/junit.xml"
|
|
51
|
+
},
|
|
52
|
+
coverage: {
|
|
53
|
+
enabled: true,
|
|
54
|
+
provider: "v8",
|
|
55
|
+
reporter: [
|
|
56
|
+
["text"],
|
|
57
|
+
["lcovonly"],
|
|
58
|
+
["html", { subdir: "html" }]
|
|
59
|
+
],
|
|
60
|
+
reportsDirectory: "reports/coverage",
|
|
61
|
+
thresholds: { perFile: true },
|
|
62
|
+
include: ["**/*.{ts,tsx}"],
|
|
63
|
+
exclude: [
|
|
64
|
+
"**/[.]**",
|
|
65
|
+
"**/*{.,-}{test,spec}?(-d).?(c|m)[jt]s?(x)",
|
|
66
|
+
"**/__mocks__/**",
|
|
67
|
+
"**/dist/**",
|
|
68
|
+
"**/*.d.{ts,cts,mts}",
|
|
69
|
+
"**/*.example.?(c|m)[jt]s?(x)",
|
|
70
|
+
"**/*.config.?(c|m)[jt]s?(x)",
|
|
71
|
+
"**/*.schema.?(c|m)[jt]s?(x)"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
} };
|
|
75
|
+
/** @internal */
|
|
76
|
+
const baseProjectConfig = {};
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/utils/defineProject.ts
|
|
80
|
+
/**
|
|
81
|
+
* Defines the root Vitest configuration for the workspace.
|
|
82
|
+
* Merges the base root configuration with any provided user configuration.
|
|
83
|
+
*
|
|
84
|
+
* @param config - Optional user-provided Vitest configuration overrides
|
|
85
|
+
* @returns The merged root Vitest configuration
|
|
86
|
+
*
|
|
87
|
+
* @includeExample
|
|
88
|
+
*/
|
|
89
|
+
const defineProject = (...config) => {
|
|
90
|
+
return defineEmptyProject(baseRootConfig, baseProjectConfig, ...config);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/utils/defineProjectOrRoot.ts
|
|
95
|
+
/**
|
|
96
|
+
* Defines the root Vitest configuration for the workspace.
|
|
97
|
+
* Merges the base root configuration with any provided user configuration.
|
|
98
|
+
*
|
|
99
|
+
* @param config - Optional user-provided Vitest configuration overrides
|
|
100
|
+
* @returns The merged root Vitest configuration
|
|
101
|
+
*
|
|
102
|
+
* @includeExample
|
|
103
|
+
*/
|
|
104
|
+
const defineProjectOrRoot = (...config) => {
|
|
105
|
+
return defineEmptyRoot(baseRootConfig, baseProjectConfig, ...config);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/utils/defineRoot.ts
|
|
110
|
+
/**
|
|
111
|
+
* Defines the root Vitest configuration for the workspace.
|
|
112
|
+
* Merges the base root configuration with any provided user configuration.
|
|
113
|
+
*
|
|
114
|
+
* @param config - Optional user-provided Vitest configuration overrides
|
|
115
|
+
* @returns The merged root Vitest configuration
|
|
116
|
+
*
|
|
117
|
+
* @includeExample
|
|
118
|
+
*/
|
|
119
|
+
const defineRoot = (...config) => {
|
|
120
|
+
return defineEmptyRoot(baseRootConfig, ...config);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/utils/setupMocks.ts
|
|
125
|
+
const resolvePath = (name) => {
|
|
126
|
+
return join(import.meta.dirname, "..", "__mocks__", `${name}.ts`);
|
|
127
|
+
};
|
|
128
|
+
const setupMocks = (flag) => {
|
|
129
|
+
return Object.keys(flag).map((key) => flag[key] === true ? resolvePath(key) : void 0).filter((path) => path !== void 0);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
export { defineEmptyProject, defineEmptyRoot, defineProject, defineProjectOrRoot, defineRoot, mergeConfig, setupMocks };
|
|
134
|
+
// Generated by @kcconfigs/tsdown
|
|
135
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_mergeConfig","defineProject","baseRootConfig: UserConfig","baseProjectConfig: UserConfig"],"sources":["../src/utils/mergeConfig.ts","../src/utils/defineEmptyProject.ts","../src/utils/defineEmptyRoot.ts","../src/constants.ts","../src/utils/defineProject.ts","../src/utils/defineProjectOrRoot.ts","../src/utils/defineRoot.ts","../src/utils/setupMocks.ts"],"sourcesContent":["import { mergeConfig as _mergeConfig } from \"vitest/config\";\nimport type { AnyConfig } from \"../models\";\n\n/**\n * Merges multiple configuration objects into a single configuration.\n * later addons taking precedence over earlier ones.\n *\n * No object will be mutated during this process.\n *\n * @template C - The configuration object type that extends a Record with string keys\n * @param defaults - The default configuration object\n * @param addons - One or more configuration objects to merge into the defaults\n * @returns The merged configuration object\n */\nexport const mergeConfig = <C extends AnyConfig>(\n\tdefaults: C,\n\t...addons: Optional<C>[]\n): C => {\n\treturn addons\n\t\t.filter((addon) => addon !== undefined && addon !== null)\n\t\t.reduce(\n\t\t\t(merged, addon) =>\n\t\t\t\t_mergeConfig(\n\t\t\t\t\tmerged as Record<string, unknown>,\n\t\t\t\t\taddon as Record<string, unknown>,\n\t\t\t\t) as C,\n\t\t\tdefaults,\n\t\t);\n};\n","import { defineProject } from \"vitest/config\";\nimport type { ProjectConfig } from \"../models\";\nimport { mergeConfig } from \"./mergeConfig\";\n\nexport const defineEmptyProject = (\n\t...configs: Optional<ProjectConfig>[]\n): ProjectConfig => {\n\treturn defineProject(mergeConfig({}, ...configs));\n};\n","import { defineConfig } from \"vitest/config\";\nimport type { UserConfig } from \"../models\";\nimport { mergeConfig } from \"./mergeConfig\";\n\nexport const defineEmptyRoot = (\n\t...configs: Optional<UserConfig>[]\n): UserConfig => {\n\treturn defineConfig(mergeConfig({}, ...configs));\n};\n","import type { UserConfig } from \"./models\";\n\n/** @internal */\nexport const baseRootConfig: UserConfig = {\n\ttest: {\n\t\trestoreMocks: true,\n\t\tmockReset: true,\n\t\tclearMocks: true,\n\t\tunstubGlobals: true,\n\t\tunstubEnvs: true,\n\t\tenvironment: \"node\",\n\t\treporters: [\"default\", \"html\", \"junit\"],\n\t\toutputFile: {\n\t\t\thtml: \"reports/test-results/index.html\",\n\t\t\tjunit: \"reports/test-results/junit.xml\",\n\t\t},\n\t\tcoverage: {\n\t\t\tenabled: true,\n\t\t\tprovider: \"v8\",\n\t\t\treporter: [[\"text\"], [\"lcovonly\"], [\"html\", { subdir: \"html\" }]],\n\t\t\treportsDirectory: \"reports/coverage\",\n\t\t\tthresholds: {\n\t\t\t\tperFile: true,\n\t\t\t},\n\t\t\tinclude: [\"**/*.{ts,tsx}\"],\n\t\t\texclude: [\n\t\t\t\t// Ignored hidden files\n\t\t\t\t\"**/[.]**\",\n\t\t\t\t// Ignored test files\n\t\t\t\t\"**/*{.,-}{test,spec}?(-d).?(c|m)[jt]s?(x)\",\n\t\t\t\t\"**/__mocks__/**\",\n\t\t\t\t// Ignored dist files\n\t\t\t\t\"**/dist/**\",\n\t\t\t\t// Ignored typescript definition files\n\t\t\t\t\"**/*.d.{ts,cts,mts}\",\n\t\t\t\t// Ignored example files\n\t\t\t\t\"**/*.example.?(c|m)[jt]s?(x)\",\n\t\t\t\t// Ignored configuration files\n\t\t\t\t\"**/*.config.?(c|m)[jt]s?(x)\",\n\t\t\t\t// Ignored schema files\n\t\t\t\t\"**/*.schema.?(c|m)[jt]s?(x)\",\n\t\t\t],\n\t\t},\n\t},\n};\n\n/** @internal */\nexport const baseProjectConfig: UserConfig = {};\n","import { baseProjectConfig, baseRootConfig } from \"../constants\";\nimport type { ProjectConfig } from \"../models\";\nimport { defineEmptyProject } from \"./defineEmptyProject\";\n\n/**\n * Defines the root Vitest configuration for the workspace.\n * Merges the base root configuration with any provided user configuration.\n *\n * @param config - Optional user-provided Vitest configuration overrides\n * @returns The merged root Vitest configuration\n *\n * @includeExample\n */\nexport const defineProject = (\n\t...config: Optional<ProjectConfig>[]\n): ProjectConfig => {\n\treturn defineEmptyProject(baseRootConfig, baseProjectConfig, ...config);\n};\n","import { baseProjectConfig, baseRootConfig } from \"../constants\";\nimport type { ProjectConfig, UserConfig } from \"../models\";\nimport { defineEmptyRoot } from \"./defineEmptyRoot\";\n\n/**\n * Defines the root Vitest configuration for the workspace.\n * Merges the base root configuration with any provided user configuration.\n *\n * @param config - Optional user-provided Vitest configuration overrides\n * @returns The merged root Vitest configuration\n *\n * @includeExample\n */\nexport const defineProjectOrRoot = (\n\t...config: Optional<UserConfig>[]\n): ProjectConfig => {\n\treturn defineEmptyRoot(baseRootConfig, baseProjectConfig, ...config);\n};\n","import { baseRootConfig } from \"../constants\";\nimport type { UserConfig } from \"../models\";\nimport { defineEmptyRoot } from \"./defineEmptyRoot\";\n\n/**\n * Defines the root Vitest configuration for the workspace.\n * Merges the base root configuration with any provided user configuration.\n *\n * @param config - Optional user-provided Vitest configuration overrides\n * @returns The merged root Vitest configuration\n *\n * @includeExample\n */\nexport const defineRoot = (...config: Optional<UserConfig>[]): UserConfig => {\n\treturn defineEmptyRoot(baseRootConfig, ...config);\n};\n","import { join } from \"node:path\";\n\nexport interface MockFlag {\n\tfs?: true;\n\tfsPromises?: true;\n\tprocess?: true;\n\tos?: true;\n}\n\nexport type MockFlagKey = keyof MockFlag;\n\nconst resolvePath = (name: string) => {\n\t// import.meta.dirname is resolved to `dist` directory\n\treturn join(import.meta.dirname, \"..\", \"__mocks__\", `${name}.ts`);\n};\n\nexport const setupMocks = (flag: MockFlag): string[] => {\n\tconst keys = Object.keys(flag) as MockFlagKey[];\n\treturn keys\n\t\t.map((key) => (flag[key] === true ? resolvePath(key) : undefined))\n\t\t.filter((path) => path !== undefined);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,MAAa,eACZ,UACA,GAAG,WACI;AACP,QAAO,OACL,QAAQ,UAAU,UAAU,UAAa,UAAU,KAAK,CACxD,QACC,QAAQ,UACRA,cACC,QACA,MACA,EACF,SACA;;;;;ACvBH,MAAa,sBACZ,GAAG,YACgB;AACnB,QAAOC,gBAAc,YAAY,EAAE,EAAE,GAAG,QAAQ,CAAC;;;;;ACHlD,MAAa,mBACZ,GAAG,YACa;AAChB,QAAO,aAAa,YAAY,EAAE,EAAE,GAAG,QAAQ,CAAC;;;;;;ACJjD,MAAaC,iBAA6B,EACzC,MAAM;CACL,cAAc;CACd,WAAW;CACX,YAAY;CACZ,eAAe;CACf,YAAY;CACZ,aAAa;CACb,WAAW;EAAC;EAAW;EAAQ;EAAQ;CACvC,YAAY;EACX,MAAM;EACN,OAAO;EACP;CACD,UAAU;EACT,SAAS;EACT,UAAU;EACV,UAAU;GAAC,CAAC,OAAO;GAAE,CAAC,WAAW;GAAE,CAAC,QAAQ,EAAE,QAAQ,QAAQ,CAAC;GAAC;EAChE,kBAAkB;EAClB,YAAY,EACX,SAAS,MACT;EACD,SAAS,CAAC,gBAAgB;EAC1B,SAAS;GAER;GAEA;GACA;GAEA;GAEA;GAEA;GAEA;GAEA;GACA;EACD;CACD,EACD;;AAGD,MAAaC,oBAAgC,EAAE;;;;;;;;;;;;;AClC/C,MAAa,iBACZ,GAAG,WACgB;AACnB,QAAO,mBAAmB,gBAAgB,mBAAmB,GAAG,OAAO;;;;;;;;;;;;;;ACHxE,MAAa,uBACZ,GAAG,WACgB;AACnB,QAAO,gBAAgB,gBAAgB,mBAAmB,GAAG,OAAO;;;;;;;;;;;;;;ACHrE,MAAa,cAAc,GAAG,WAA+C;AAC5E,QAAO,gBAAgB,gBAAgB,GAAG,OAAO;;;;;ACHlD,MAAM,eAAe,SAAiB;AAErC,QAAO,KAAK,OAAO,KAAK,SAAS,MAAM,aAAa,GAAG,KAAK,KAAK;;AAGlE,MAAa,cAAc,SAA6B;AAEvD,QADa,OAAO,KAAK,KAAK,CAE5B,KAAK,QAAS,KAAK,SAAS,OAAO,YAAY,IAAI,GAAG,OAAW,CACjE,QAAQ,SAAS,SAAS,OAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kcconfigs/vitest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
|
+
"description": "Shared vitest configuration",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"vitest": "4.0.15",
|
|
8
|
+
"memfs": "4.51.1"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@biomejs/biome": "2.3.10",
|
|
12
|
+
"tsdown": "0.18.1",
|
|
13
|
+
"@kcconfigs/tsdown": "0.1.0-beta.1",
|
|
14
|
+
"@kcconfigs/tsconfig": "0.1.0-beta.1",
|
|
15
|
+
"@kcconfigs/biome": "0.1.1"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"vitest": "^4.0.0"
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.cts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"source": "./src/index.ts",
|
|
25
|
+
"typedoc": "./src/index.ts",
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/index.d.cts",
|
|
28
|
+
"default": "./dist/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"default": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"./mocks": {
|
|
36
|
+
"source": "./src/mockHelpers/index.ts",
|
|
37
|
+
"typedoc": "./src/mockHelpers/index.ts",
|
|
38
|
+
"require": {
|
|
39
|
+
"types": "./dist/mockHelpers/index.d.cts",
|
|
40
|
+
"default": "./dist/mockHelpers/index.cjs"
|
|
41
|
+
},
|
|
42
|
+
"default": {
|
|
43
|
+
"types": "./dist/mockHelpers/index.d.ts",
|
|
44
|
+
"default": "./dist/mockHelpers/index.js"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
4
48
|
"license": "AGPL-3.0-only",
|
|
5
49
|
"homepage": "https://github.com/kc-workspace/kcws/tree/main/packages/@kcconfigs/vitest",
|
|
6
50
|
"repository": {
|
|
@@ -13,10 +57,34 @@
|
|
|
13
57
|
"email": "kcws@kc.in.th",
|
|
14
58
|
"url": "https://github.com/kamontat"
|
|
15
59
|
},
|
|
60
|
+
"keywords": [
|
|
61
|
+
"config",
|
|
62
|
+
"typescript",
|
|
63
|
+
"vitest",
|
|
64
|
+
"test"
|
|
65
|
+
],
|
|
66
|
+
"files": [
|
|
67
|
+
"CHANGELOG.json",
|
|
68
|
+
"CHANGELOG.md",
|
|
69
|
+
"dist",
|
|
70
|
+
"src",
|
|
71
|
+
"mocks"
|
|
72
|
+
],
|
|
16
73
|
"engines": {
|
|
17
74
|
"node": ">=14"
|
|
18
75
|
},
|
|
19
76
|
"publishConfig": {
|
|
20
77
|
"access": "public"
|
|
78
|
+
},
|
|
79
|
+
"scripts": {
|
|
80
|
+
"test": "vitest run",
|
|
81
|
+
"build": "tsdown",
|
|
82
|
+
"fix": "biome check --fix --unsafe",
|
|
83
|
+
"check": "pnpm run lint:check && pnpm run format:check && pnpm run type:check",
|
|
84
|
+
"format": "biome format --fix",
|
|
85
|
+
"format:check": "biome format",
|
|
86
|
+
"lint": "biome lint --fix --unsafe",
|
|
87
|
+
"lint:check": "biome lint",
|
|
88
|
+
"type:check": "tsc --build"
|
|
21
89
|
}
|
|
22
90
|
}
|