@webpresso/agent-config 0.3.3 → 0.3.6
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.
|
@@ -55,11 +55,8 @@ export declare const baseConfig: {
|
|
|
55
55
|
* export default { ...typescriptBaseConfig, vitest: { configFile: 'vitest.stryker.config.ts' } }
|
|
56
56
|
*/
|
|
57
57
|
export declare const typescriptBaseConfig: {
|
|
58
|
-
checkers: string[];
|
|
59
|
-
tsconfigFile: string;
|
|
60
58
|
packageManager: string;
|
|
61
59
|
testRunner: string;
|
|
62
|
-
plugins: string[];
|
|
63
60
|
ignorePatterns: string[];
|
|
64
61
|
mutate: string[];
|
|
65
62
|
concurrency: number;
|
|
@@ -86,6 +83,9 @@ export declare const typescriptBaseConfig: {
|
|
|
86
83
|
};
|
|
87
84
|
incremental: boolean;
|
|
88
85
|
incrementalFile: string;
|
|
86
|
+
plugins: string[];
|
|
87
|
+
checkers: string[];
|
|
88
|
+
tsconfigFile: string;
|
|
89
89
|
};
|
|
90
90
|
/**
|
|
91
91
|
* Extends typescriptBaseConfig for Cloudflare Workers packages whose vitest config
|
|
@@ -99,14 +99,8 @@ export declare const typescriptBaseConfig: {
|
|
|
99
99
|
* export default { ...typescriptWorkersBaseConfig }
|
|
100
100
|
*/
|
|
101
101
|
export declare const typescriptWorkersBaseConfig: {
|
|
102
|
-
vitest: {
|
|
103
|
-
configFile: string;
|
|
104
|
-
};
|
|
105
|
-
checkers: string[];
|
|
106
|
-
tsconfigFile: string;
|
|
107
102
|
packageManager: string;
|
|
108
103
|
testRunner: string;
|
|
109
|
-
plugins: string[];
|
|
110
104
|
ignorePatterns: string[];
|
|
111
105
|
mutate: string[];
|
|
112
106
|
concurrency: number;
|
|
@@ -130,5 +124,11 @@ export declare const typescriptWorkersBaseConfig: {
|
|
|
130
124
|
};
|
|
131
125
|
incremental: boolean;
|
|
132
126
|
incrementalFile: string;
|
|
127
|
+
plugins: string[];
|
|
128
|
+
checkers: string[];
|
|
129
|
+
tsconfigFile: string;
|
|
130
|
+
vitest: {
|
|
131
|
+
configFile: string;
|
|
132
|
+
};
|
|
133
133
|
};
|
|
134
134
|
export default baseConfig;
|
|
@@ -26,7 +26,6 @@ export const baseConfig = {
|
|
|
26
26
|
"**/.codex/**",
|
|
27
27
|
"**/.cursor/**",
|
|
28
28
|
"**/.opencode/**",
|
|
29
|
-
"**/.omx/**",
|
|
30
29
|
"**/dist/**",
|
|
31
30
|
"**/coverage/**",
|
|
32
31
|
"**/*.d.ts",
|
|
@@ -106,6 +105,7 @@ export const baseConfig = {
|
|
|
106
105
|
*/
|
|
107
106
|
export const typescriptBaseConfig = {
|
|
108
107
|
...baseConfig,
|
|
108
|
+
plugins: [...baseConfig.plugins, "@stryker-mutator/typescript-checker"],
|
|
109
109
|
checkers: ["typescript"],
|
|
110
110
|
tsconfigFile: "tsconfig.json",
|
|
111
111
|
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composed Vitest configuration: `nodeConfig` + the `@webpresso/source`
|
|
3
|
+
* resolve-condition contract.
|
|
4
|
+
*
|
|
5
|
+
* Consumers previously hand-rolled this composition themselves — a
|
|
6
|
+
* `mergeConfig(nodeConfig, createWebpressoSourceResolveConfig())` call plus a
|
|
7
|
+
* manual `resolve`/`ssr` spread, copy-pasted across every package that needs
|
|
8
|
+
* to run tests against source instead of `dist/`. This module is the single
|
|
9
|
+
* canonical, tested implementation those copies converge on.
|
|
10
|
+
*
|
|
11
|
+
* Usage in vitest.config.ts (single-config shape):
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { createNodeSourceVitestConfig } from '@webpresso/agent-config/vitest/node-source'
|
|
14
|
+
*
|
|
15
|
+
* export default createNodeSourceVitestConfig({ extraConditions: ['source'] })
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Usage (unit/integration projects shape):
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { createNodeSourceProjects } from '@webpresso/agent-config/vitest/node-source'
|
|
21
|
+
* import { nodeConfig } from '@webpresso/agent-config/vitest/node'
|
|
22
|
+
* import { mergeConfig } from 'vite-plus/test/config'
|
|
23
|
+
*
|
|
24
|
+
* export default mergeConfig(nodeConfig, {
|
|
25
|
+
* test: { projects: createNodeSourceProjects('my-package', { extraConditions: ['source'] }) },
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import type { UserWorkspaceConfig, ViteUserConfigExport } from "vite-plus/test/config";
|
|
30
|
+
import type { CreateNodeProjectsOptions, ResolveAliasEntry } from "./node.js";
|
|
31
|
+
export interface CreateNodeSourceVitestConfigOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Extra resolve conditions appended AFTER the full base
|
|
34
|
+
* `@webpresso/source` condition set — applied identically to both
|
|
35
|
+
* top-level `resolve.conditions` and `ssr.resolve.conditions`. Framework
|
|
36
|
+
* packages pass `['source']`.
|
|
37
|
+
*/
|
|
38
|
+
extraConditions?: readonly string[];
|
|
39
|
+
/**
|
|
40
|
+
* Extra resolve aliases appended after `nodeConfig`'s built-in alias array
|
|
41
|
+
* (generated runtime aliases + the bun:sqlite shim).
|
|
42
|
+
*/
|
|
43
|
+
alias?: readonly ResolveAliasEntry[];
|
|
44
|
+
tsconfigPaths?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Shallow-merged into the base `test` block (`{ ...nodeConfig.test,
|
|
47
|
+
* ...test }`) — NOT deep-merged. A deep merge (e.g. via `mergeConfig`)
|
|
48
|
+
* would concatenate array fields such as `setupFiles`/`execArgv`/coverage
|
|
49
|
+
* `include`/`exclude` with `nodeConfig`'s own copies of those same arrays,
|
|
50
|
+
* which previously crashed forks-pool worker startup when a consumer
|
|
51
|
+
* config spread `nodeConfig.test` and then merged the result again.
|
|
52
|
+
* Provide a full replacement value for any array field you want to change.
|
|
53
|
+
*/
|
|
54
|
+
test?: UserWorkspaceConfig["test"];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Compose `nodeConfig` with the `@webpresso/source` resolve-condition
|
|
58
|
+
* contract into a single flat Vitest config.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createNodeSourceVitestConfig(options?: CreateNodeSourceVitestConfigOptions): ViteUserConfigExport;
|
|
61
|
+
export interface CreateNodeSourceProjectsOptions extends CreateNodeProjectsOptions {
|
|
62
|
+
/**
|
|
63
|
+
* Extra resolve conditions appended AFTER the full base
|
|
64
|
+
* `@webpresso/source` condition set on BOTH the unit and integration
|
|
65
|
+
* projects (top-level `resolve.conditions` and `ssr.resolve.conditions`).
|
|
66
|
+
*/
|
|
67
|
+
extraConditions?: readonly string[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create unit/integration Vitest projects (via `createNodeProjects`) with the
|
|
71
|
+
* `@webpresso/source` resolve-condition contract layered onto each project,
|
|
72
|
+
* without disturbing `createNodeProjects`'s own `extraAlias` /
|
|
73
|
+
* `extraInline` / `extraSetupFiles` seam.
|
|
74
|
+
*/
|
|
75
|
+
export declare function createNodeSourceProjects(name: string, options?: CreateNodeSourceProjectsOptions): UserWorkspaceConfig[];
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composed Vitest configuration: `nodeConfig` + the `@webpresso/source`
|
|
3
|
+
* resolve-condition contract.
|
|
4
|
+
*
|
|
5
|
+
* Consumers previously hand-rolled this composition themselves — a
|
|
6
|
+
* `mergeConfig(nodeConfig, createWebpressoSourceResolveConfig())` call plus a
|
|
7
|
+
* manual `resolve`/`ssr` spread, copy-pasted across every package that needs
|
|
8
|
+
* to run tests against source instead of `dist/`. This module is the single
|
|
9
|
+
* canonical, tested implementation those copies converge on.
|
|
10
|
+
*
|
|
11
|
+
* Usage in vitest.config.ts (single-config shape):
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { createNodeSourceVitestConfig } from '@webpresso/agent-config/vitest/node-source'
|
|
14
|
+
*
|
|
15
|
+
* export default createNodeSourceVitestConfig({ extraConditions: ['source'] })
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Usage (unit/integration projects shape):
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { createNodeSourceProjects } from '@webpresso/agent-config/vitest/node-source'
|
|
21
|
+
* import { nodeConfig } from '@webpresso/agent-config/vitest/node'
|
|
22
|
+
* import { mergeConfig } from 'vite-plus/test/config'
|
|
23
|
+
*
|
|
24
|
+
* export default mergeConfig(nodeConfig, {
|
|
25
|
+
* test: { projects: createNodeSourceProjects('my-package', { extraConditions: ['source'] }) },
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import { createNodeProjects, nodeConfig } from "./node.js";
|
|
30
|
+
import { createWebpressoSourceResolveConfig } from "./source-conditions.js";
|
|
31
|
+
const baseConfig = nodeConfig;
|
|
32
|
+
const baseNodeAlias = Array.isArray(baseConfig.resolve?.alias)
|
|
33
|
+
? baseConfig.resolve.alias
|
|
34
|
+
: [];
|
|
35
|
+
function appendConditions(sourceResolve, extraConditions) {
|
|
36
|
+
return {
|
|
37
|
+
resolve: [...sourceResolve.resolve.conditions, ...extraConditions],
|
|
38
|
+
ssr: [...sourceResolve.ssr.resolve.conditions, ...extraConditions],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Compose `nodeConfig` with the `@webpresso/source` resolve-condition
|
|
43
|
+
* contract into a single flat Vitest config.
|
|
44
|
+
*/
|
|
45
|
+
export function createNodeSourceVitestConfig(options = {}) {
|
|
46
|
+
const { extraConditions = [], alias = [], tsconfigPaths, test } = options;
|
|
47
|
+
const sourceResolve = createWebpressoSourceResolveConfig(tsconfigPaths === undefined ? {} : { tsconfigPaths });
|
|
48
|
+
const conditions = appendConditions(sourceResolve, extraConditions);
|
|
49
|
+
return {
|
|
50
|
+
...nodeConfig,
|
|
51
|
+
resolve: {
|
|
52
|
+
...baseConfig.resolve,
|
|
53
|
+
...sourceResolve.resolve,
|
|
54
|
+
alias: [...baseNodeAlias, ...alias],
|
|
55
|
+
conditions: conditions.resolve,
|
|
56
|
+
},
|
|
57
|
+
ssr: {
|
|
58
|
+
...baseConfig.ssr,
|
|
59
|
+
resolve: {
|
|
60
|
+
...baseConfig.ssr?.resolve,
|
|
61
|
+
conditions: conditions.ssr,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
test: {
|
|
65
|
+
...baseConfig.test,
|
|
66
|
+
...test,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create unit/integration Vitest projects (via `createNodeProjects`) with the
|
|
72
|
+
* `@webpresso/source` resolve-condition contract layered onto each project,
|
|
73
|
+
* without disturbing `createNodeProjects`'s own `extraAlias` /
|
|
74
|
+
* `extraInline` / `extraSetupFiles` seam.
|
|
75
|
+
*/
|
|
76
|
+
export function createNodeSourceProjects(name, options = {}) {
|
|
77
|
+
const { extraConditions = [], ...projectOptions } = options;
|
|
78
|
+
const conditions = appendConditions(createWebpressoSourceResolveConfig(), extraConditions);
|
|
79
|
+
return createNodeProjects(name, projectOptions).map((project) => {
|
|
80
|
+
const composableProject = project;
|
|
81
|
+
return {
|
|
82
|
+
...project,
|
|
83
|
+
resolve: {
|
|
84
|
+
...composableProject.resolve,
|
|
85
|
+
conditions: conditions.resolve,
|
|
86
|
+
},
|
|
87
|
+
ssr: {
|
|
88
|
+
...composableProject.ssr,
|
|
89
|
+
resolve: {
|
|
90
|
+
...composableProject.ssr?.resolve,
|
|
91
|
+
conditions: conditions.ssr,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpresso/agent-config",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Shared vitest, tsconfig, stryker, and workers-test config for webpresso consumers. Binary-free — pure test/config tooling.",
|
|
6
6
|
"homepage": "https://github.com/webpresso/agent-kit#readme",
|
|
@@ -106,6 +106,12 @@
|
|
|
106
106
|
"default": "./dist/esm/vitest/node.js"
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
|
+
"./vitest/node-source": {
|
|
110
|
+
"import": {
|
|
111
|
+
"types": "./dist/esm/vitest/node-source.d.ts",
|
|
112
|
+
"default": "./dist/esm/vitest/node-source.js"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
109
115
|
"./vitest/react": {
|
|
110
116
|
"import": {
|
|
111
117
|
"types": "./dist/esm/vitest/react.d.ts",
|
|
@@ -161,10 +167,10 @@
|
|
|
161
167
|
},
|
|
162
168
|
"dependencies": {
|
|
163
169
|
"@vitejs/plugin-react": "^6.0.3",
|
|
164
|
-
"@webpresso/agent-core": "0.1.
|
|
165
|
-
"vite": "^8.1.
|
|
166
|
-
"vite-plus": "^0.2.
|
|
167
|
-
"vitest": "^4.1.
|
|
170
|
+
"@webpresso/agent-core": "0.1.3",
|
|
171
|
+
"vite": "^8.1.4",
|
|
172
|
+
"vite-plus": "^0.2.4",
|
|
173
|
+
"vitest": "^4.1.10"
|
|
168
174
|
},
|
|
169
175
|
"peerDependencies": {
|
|
170
176
|
"@cloudflare/vitest-pool-workers": "*",
|
|
@@ -221,6 +227,7 @@
|
|
|
221
227
|
"./tsconfig/react-router.json": "./src/tsconfig/react-router.json",
|
|
222
228
|
"./vitest/flakiness-reporter": "./src/vitest/flakiness-reporter.ts",
|
|
223
229
|
"./vitest/node": "./src/vitest/node.ts",
|
|
230
|
+
"./vitest/node-source": "./src/vitest/node-source.ts",
|
|
224
231
|
"./vitest/react": "./src/vitest/react.ts",
|
|
225
232
|
"./vitest/react-router": "./src/vitest/react-router.ts",
|
|
226
233
|
"./vitest/react-setup": "./src/vitest/react-setup.ts",
|