@aamini/config 0.0.1 → 0.0.3
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 +32 -0
- package/dist/internal-Dshd0hdM.mjs +22 -0
- package/dist/internal-Dshd0hdM.mjs.map +1 -0
- package/dist/test/browser.d.mts +3 -6
- package/dist/test/browser.mjs +14 -7
- package/dist/test/browser.mjs.map +1 -1
- package/dist/test/db.d.mts +3 -8
- package/dist/test/db.mjs +18 -9
- package/dist/test/db.mjs.map +1 -1
- package/dist/test/server.d.mts +3 -6
- package/dist/test/server.mjs +15 -7
- package/dist/test/server.mjs.map +1 -1
- package/dist/vite.shared.d.mts +369 -4
- package/dist/vite.shared.mjs +87 -17
- package/dist/vite.shared.mjs.map +1 -1
- package/package.json +6 -6
- package/test/browser.ts +19 -6
- package/test/db.ts +22 -16
- package/test/internal.ts +45 -0
- package/test/server.ts +21 -9
- package/vite.shared.ts +125 -12
package/dist/vite.shared.mjs
CHANGED
|
@@ -61,7 +61,7 @@ function stylesPlugin(root) {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
const stylesSetup =
|
|
64
|
+
const stylesSetup = "@aamini/config/setup/styles";
|
|
65
65
|
function mergeProjectConfig(base, overrides = {}) {
|
|
66
66
|
return mergeConfig(base, overrides);
|
|
67
67
|
}
|
|
@@ -81,14 +81,10 @@ function createBaseConfig(root, overrides = {}, projectOverrides = {}) {
|
|
|
81
81
|
replacement: resolve(root, "src")
|
|
82
82
|
}]
|
|
83
83
|
},
|
|
84
|
-
plugins: [
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
include: "**/*.svg",
|
|
89
|
-
svgrOptions: { exportType: "default" }
|
|
90
|
-
})
|
|
91
|
-
],
|
|
84
|
+
plugins: [tailwindcss(), svgr({
|
|
85
|
+
include: "**/*.svg",
|
|
86
|
+
svgrOptions: { exportType: "default" }
|
|
87
|
+
})],
|
|
92
88
|
test: {
|
|
93
89
|
passWithNoTests: true,
|
|
94
90
|
exclude: [
|
|
@@ -173,41 +169,112 @@ function createFrameworkConfig(root) {
|
|
|
173
169
|
});
|
|
174
170
|
}
|
|
175
171
|
function createAppConfig(root, projectOverrides = {}, overrides = {}) {
|
|
176
|
-
return
|
|
172
|
+
return {
|
|
173
|
+
...workspaceConfig,
|
|
174
|
+
...mergeConfig(createFrameworkConfig(root), createBaseConfig(root, overrides, projectOverrides))
|
|
175
|
+
};
|
|
177
176
|
}
|
|
178
177
|
function baseConfigFor(configUrl) {
|
|
179
178
|
return createAppConfig(dirname(fileURLToPath(configUrl)));
|
|
180
179
|
}
|
|
181
|
-
const workspaceConfig =
|
|
180
|
+
const workspaceConfig = {
|
|
182
181
|
fmt: {
|
|
183
182
|
singleQuote: true,
|
|
184
183
|
semi: false,
|
|
185
184
|
useTabs: true,
|
|
185
|
+
experimentalTailwindcss: {},
|
|
186
186
|
printWidth: 80,
|
|
187
|
+
experimentalSortPackageJson: false,
|
|
187
188
|
proseWrap: "always",
|
|
188
189
|
ignorePatterns: [
|
|
189
190
|
"**/.vercel",
|
|
190
191
|
"**/.output",
|
|
192
|
+
"**/dist/**",
|
|
191
193
|
"**/env.d.ts",
|
|
192
194
|
"pnpm-lock.yaml",
|
|
193
|
-
"routeTree.gen.ts",
|
|
195
|
+
"**/routeTree.gen.ts",
|
|
196
|
+
"infra/manifests/gitops/flux-system/gotk-components.yaml",
|
|
197
|
+
"infra/charts/**/templates/**/*.{yml,yaml}",
|
|
194
198
|
"**/charts/**",
|
|
195
199
|
"**/*.yaml",
|
|
196
200
|
"**/*.yml"
|
|
197
|
-
]
|
|
201
|
+
],
|
|
202
|
+
overrides: [{
|
|
203
|
+
files: ["*.{yaml,yml}"],
|
|
204
|
+
options: { useTabs: false }
|
|
205
|
+
}]
|
|
198
206
|
},
|
|
199
207
|
lint: {
|
|
200
208
|
plugins: [
|
|
209
|
+
"eslint",
|
|
210
|
+
"unicorn",
|
|
201
211
|
"typescript",
|
|
212
|
+
"oxc",
|
|
202
213
|
"react",
|
|
203
|
-
"
|
|
214
|
+
"react-perf",
|
|
215
|
+
"import",
|
|
216
|
+
"jsdoc",
|
|
217
|
+
"jsx-a11y",
|
|
218
|
+
"node",
|
|
219
|
+
"promise"
|
|
204
220
|
],
|
|
221
|
+
categories: {},
|
|
205
222
|
options: {
|
|
206
223
|
typeAware: true,
|
|
207
224
|
typeCheck: true
|
|
208
225
|
},
|
|
209
|
-
rules: {
|
|
226
|
+
rules: {
|
|
227
|
+
"no-empty-pattern": "off",
|
|
228
|
+
"no-console": ["error", { allow: ["warn", "error"] }]
|
|
229
|
+
},
|
|
230
|
+
settings: {
|
|
231
|
+
"jsx-a11y": {
|
|
232
|
+
components: {},
|
|
233
|
+
attributes: {}
|
|
234
|
+
},
|
|
235
|
+
react: {
|
|
236
|
+
formComponents: [],
|
|
237
|
+
linkComponents: []
|
|
238
|
+
},
|
|
239
|
+
jsdoc: {
|
|
240
|
+
ignorePrivate: false,
|
|
241
|
+
ignoreInternal: false,
|
|
242
|
+
ignoreReplacesDocs: true,
|
|
243
|
+
overrideReplacesDocs: true,
|
|
244
|
+
augmentsExtendsReplacesDocs: false,
|
|
245
|
+
implementsReplacesDocs: false,
|
|
246
|
+
exemptDestructuredRootsFromChecks: false,
|
|
247
|
+
tagNamePreference: {}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
env: { builtin: true },
|
|
251
|
+
globals: {},
|
|
252
|
+
ignorePatterns: ["**/dist/**"],
|
|
210
253
|
overrides: [
|
|
254
|
+
{
|
|
255
|
+
files: ["**/*.test.unit.ts"],
|
|
256
|
+
rules: { "eslint/no-restricted-imports": ["error", { patterns: [{
|
|
257
|
+
group: ["@aamini/config-testing/test/*"],
|
|
258
|
+
message: "Unit tests should not import test fixtures. Use plain vitest imports instead."
|
|
259
|
+
}] }] }
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
files: ["**/*.test.tsx"],
|
|
263
|
+
rules: { "eslint/no-restricted-imports": ["error", { paths: [{
|
|
264
|
+
name: "@aamini/config-testing/test/server",
|
|
265
|
+
message: "Browser tests (*.test.tsx) should use test/browser, not test/server."
|
|
266
|
+
}, {
|
|
267
|
+
name: "@aamini/config-testing/test/db",
|
|
268
|
+
message: "Browser tests (*.test.tsx) should use test/browser, not test/db."
|
|
269
|
+
}] }] }
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
files: ["**/*.test.ts"],
|
|
273
|
+
rules: { "eslint/no-restricted-imports": ["error", { paths: [{
|
|
274
|
+
name: "@aamini/config-testing/test/browser",
|
|
275
|
+
message: "Server tests (*.test.ts) should use test/server or test/db, not test/browser."
|
|
276
|
+
}] }] }
|
|
277
|
+
},
|
|
211
278
|
{
|
|
212
279
|
files: ["apps/**"],
|
|
213
280
|
plugins: ["typescript", "react"],
|
|
@@ -216,7 +283,10 @@ const workspaceConfig = defineConfig$1({
|
|
|
216
283
|
{
|
|
217
284
|
files: ["**/*.test.ts", "**/*.test.tsx"],
|
|
218
285
|
plugins: ["typescript", "vitest"],
|
|
219
|
-
rules: {
|
|
286
|
+
rules: {
|
|
287
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
288
|
+
"vitest/no-standalone-expect": ["warn", { additionalTestBlockFunctions: ["test", "test.skip"] }]
|
|
289
|
+
}
|
|
220
290
|
},
|
|
221
291
|
{
|
|
222
292
|
files: ["**/scripts/**", "**/src/lib/imdb/**"],
|
|
@@ -225,7 +295,7 @@ const workspaceConfig = defineConfig$1({
|
|
|
225
295
|
]
|
|
226
296
|
},
|
|
227
297
|
staged: { "*.{js,ts,tsx}": "vp check --fix" }
|
|
228
|
-
}
|
|
298
|
+
};
|
|
229
299
|
//#endregion
|
|
230
300
|
export { baseConfigFor, createAppConfig, workspaceConfig };
|
|
231
301
|
|
package/dist/vite.shared.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.shared.mjs","names":["defineVitestConfig","defineConfig"],"sources":["../vite.shared.ts"],"sourcesContent":["import { nitro } from 'nitro/vite'\nimport { devtools } from '@tanstack/devtools-vite'\nimport { tanstackStart } from '@tanstack/react-start/plugin/vite'\nimport viteReact, { reactCompilerPreset } from '@vitejs/plugin-react'\nimport tailwindcss from '@tailwindcss/vite'\nimport babel from '@rolldown/plugin-babel'\nimport svgr from 'vite-plugin-svgr'\nimport { existsSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type { Plugin } from 'vite'\nimport {\n\tdefineConfig as defineVitestConfig,\n\tmergeConfig,\n\ttype TestProjectConfiguration,\n\ttype TestProjectInlineConfiguration,\n} from 'vitest/config'\nimport { defineConfig } from 'vite'\nimport { playwright } from 'vite-plus/test/browser-playwright'\n\nconst HANDLER_LOCATIONS = [\n\t'__mocks__/handlers.ts',\n\t'__mocks__/handlers.js',\n\t'src/mocks/handlers.ts',\n\t'src/mocks/handlers.js',\n]\n\nconst STYLES_LOCATIONS = ['src/styles.css', 'src/index.css', 'src/app.css']\n\nfunction mswHandlersPlugin(root: string): Plugin {\n\tconst virtualModuleId = '@test/handlers'\n\tconst resolvedVirtualModuleId = '\\0' + virtualModuleId\n\n\treturn {\n\t\tname: 'msw-handlers-resolver',\n\t\tresolveId(id) {\n\t\t\tif (id === virtualModuleId) {\n\t\t\t\treturn resolvedVirtualModuleId\n\t\t\t}\n\t\t\treturn undefined\n\t\t},\n\t\tload(id) {\n\t\t\tif (id === resolvedVirtualModuleId) {\n\t\t\t\tfor (const location of HANDLER_LOCATIONS) {\n\t\t\t\t\tconst fullPath = resolve(root, location)\n\t\t\t\t\tif (existsSync(fullPath)) {\n\t\t\t\t\t\treturn `export { default } from '${fullPath}'`\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`No MSW handlers found. Expected one of:\\n${HANDLER_LOCATIONS.map((l) => ` - ${resolve(root, l)}`).join('\\n')}`,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn undefined\n\t\t},\n\t}\n}\n\nfunction stylesPlugin(root: string): Plugin {\n\tconst virtualModuleId = '@test/styles'\n\tconst resolvedVirtualModuleId = '\\0' + virtualModuleId\n\n\treturn {\n\t\tname: 'styles-resolver',\n\t\tresolveId(id) {\n\t\t\tif (id === virtualModuleId) {\n\t\t\t\treturn resolvedVirtualModuleId\n\t\t\t}\n\t\t\treturn undefined\n\t\t},\n\t\tload(id) {\n\t\t\tif (id === resolvedVirtualModuleId) {\n\t\t\t\tfor (const location of STYLES_LOCATIONS) {\n\t\t\t\t\tconst fullPath = resolve(root, location)\n\t\t\t\t\tif (existsSync(fullPath)) {\n\t\t\t\t\t\treturn `import '${fullPath}'`\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`No styles file found. Expected one of:\\n${STYLES_LOCATIONS.map((l) => ` - ${resolve(root, l)}`).join('\\n')}`,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn undefined\n\t\t},\n\t}\n}\n\nconst stylesSetup = new URL('setup/styles.ts', import.meta.url).pathname\n\nfunction mergeProjectConfig(\n\tbase: TestProjectConfiguration,\n\toverrides: TestProjectConfiguration = {},\n): TestProjectConfiguration {\n\treturn mergeConfig(\n\t\tbase as Record<string, any>,\n\t\toverrides as Record<string, any>,\n\t) as TestProjectConfiguration\n}\n\ninterface ProjectOverrides {\n\tserver?: TestProjectConfiguration\n\tbrowser?: TestProjectConfiguration\n}\n\nfunction createBaseConfig(\n\troot: string,\n\toverrides: TestProjectInlineConfiguration = {},\n\tprojectOverrides: ProjectOverrides = {},\n) {\n\tconst localSetup = resolve(root, 'vitest.setup.ts')\n\tconst hasLocalSetup = existsSync(localSetup)\n\n\treturn mergeConfig(\n\t\tdefineVitestConfig({\n\t\t\troot,\n\t\t\tresolve: {\n\t\t\t\ttsconfigPaths: true,\n\t\t\t\tdedupe: ['react', 'react-dom'],\n\t\t\t\talias: [\n\t\t\t\t\t{ find: '@/mocks', replacement: resolve(root, '__mocks__') },\n\t\t\t\t\t{ find: '@', replacement: resolve(root, 'src') },\n\t\t\t\t],\n\t\t\t},\n\t\t\tplugins: [\n\t\t\t\ttailwindcss(),\n\t\t\t\tviteReact(),\n\t\t\t\tsvgr({\n\t\t\t\t\tinclude: '**/*.svg',\n\t\t\t\t\tsvgrOptions: { exportType: 'default' },\n\t\t\t\t}),\n\t\t\t],\n\t\t\ttest: {\n\t\t\t\tpassWithNoTests: true,\n\t\t\t\texclude: [\n\t\t\t\t\t'**/node_modules/**',\n\t\t\t\t\t'**/dist/**',\n\t\t\t\t\t'**/.output/**',\n\t\t\t\t\t'**/.vercel/**',\n\t\t\t\t\t'**/cypress/**',\n\t\t\t\t\t'**/.{idea,git,cache,output,temp}/**',\n\t\t\t\t\t'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',\n\t\t\t\t\t'**/e2e/**',\n\t\t\t\t],\n\t\t\t\tprojects: [\n\t\t\t\t\t{\n\t\t\t\t\t\textends: true,\n\t\t\t\t\t\ttest: {\n\t\t\t\t\t\t\tname: 'unit',\n\t\t\t\t\t\t\tinclude: ['src/**/*.test.unit.ts'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tmergeProjectConfig(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\textends: true,\n\t\t\t\t\t\t\tplugins: [mswHandlersPlugin(root)],\n\t\t\t\t\t\t\ttest: {\n\t\t\t\t\t\t\t\tname: 'server',\n\t\t\t\t\t\t\t\tinclude: ['src/**/*.test.ts'],\n\t\t\t\t\t\t\t\texclude: ['src/**/*.test.unit.ts', 'src/**/*.test.tsx'],\n\t\t\t\t\t\t\t\ttestTimeout: 30_000,\n\t\t\t\t\t\t\t\tfileParallelism: false,\n\t\t\t\t\t\t\t\tsetupFiles: hasLocalSetup ? [localSetup] : [],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} satisfies TestProjectConfiguration,\n\t\t\t\t\t\tprojectOverrides.server ?? {},\n\t\t\t\t\t),\n\t\t\t\t\tmergeProjectConfig(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\textends: true,\n\t\t\t\t\t\t\tplugins: [mswHandlersPlugin(root), stylesPlugin(root)],\n\t\t\t\t\t\t\ttest: {\n\t\t\t\t\t\t\t\tname: 'browser',\n\t\t\t\t\t\t\t\tinclude: ['src/**/*.test.tsx', 'tests/**/*.test.tsx'],\n\t\t\t\t\t\t\t\tsetupFiles: [stylesSetup],\n\t\t\t\t\t\t\t\tbrowser: {\n\t\t\t\t\t\t\t\t\tinstances: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tbrowser: 'chromium',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\tprovider: playwright(),\n\t\t\t\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\t\t\t\theadless: true,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} satisfies TestProjectConfiguration,\n\t\t\t\t\t\tprojectOverrides.browser ?? {},\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t},\n\t\t}),\n\t\toverrides,\n\t)\n}\n\nconst isVitest = process.env.VITEST === 'true'\n\nfunction createFrameworkConfig(root: string) {\n\treturn defineConfig({\n\t\troot,\n\t\tresolve: {\n\t\t\ttsconfigPaths: true,\n\t\t\tdedupe: ['react', 'react-dom'],\n\t\t\talias: [\n\t\t\t\t{ find: '@/mocks', replacement: resolve(root, '__mocks__') },\n\t\t\t\t{ find: '@', replacement: resolve(root, 'src') },\n\t\t\t],\n\t\t},\n\t\tssr: {\n\t\t\tnoExternal: ['recharts'],\n\t\t},\n\t\tplugins: [\n\t\t\t...(isVitest ? [] : [devtools(), nitro(), tanstackStart()]),\n\t\t\ttailwindcss(),\n\t\t\tviteReact(),\n\t\t\tbabel({ presets: [reactCompilerPreset()] }),\n\t\t\tsvgr({\n\t\t\t\tinclude: '**/*.svg',\n\t\t\t\tsvgrOptions: { exportType: 'default' },\n\t\t\t}),\n\t\t],\n\t})\n}\n\n// Creates a full app config with customized test project overrides\nexport function createAppConfig(\n\troot: string,\n\tprojectOverrides: ProjectOverrides = {},\n\toverrides: TestProjectInlineConfiguration = {},\n) {\n\treturn mergeConfig(\n\t\tcreateFrameworkConfig(root),\n\t\tcreateBaseConfig(root, overrides, projectOverrides),\n\t)\n}\n\n// Helper to create config from import.meta.url\nexport function baseConfigFor(configUrl: string | URL) {\n\tconst root = dirname(fileURLToPath(configUrl))\n\treturn createAppConfig(root)\n}\n\n// Workspace-level shared config (lint, fmt, staged)\n// Cast to any because Vite+ extensions (fmt, lint, staged) aren't in standard Vite types\nexport const workspaceConfig = defineConfig({\n\tfmt: {\n\t\tsingleQuote: true,\n\t\tsemi: false,\n\t\tuseTabs: true,\n\t\tprintWidth: 80,\n\t\tproseWrap: 'always',\n\t\tignorePatterns: [\n\t\t\t'**/.vercel',\n\t\t\t'**/.output',\n\t\t\t'**/env.d.ts',\n\t\t\t'pnpm-lock.yaml',\n\t\t\t'routeTree.gen.ts',\n\t\t\t'**/charts/**',\n\t\t\t'**/*.yaml',\n\t\t\t'**/*.yml',\n\t\t],\n\t},\n\tlint: {\n\t\tplugins: ['typescript', 'react', 'unicorn'],\n\t\toptions: {\n\t\t\ttypeAware: true,\n\t\t\ttypeCheck: true,\n\t\t},\n\t\trules: {\n\t\t\t'no-console': ['error', { allow: ['warn', 'error'] }],\n\t\t},\n\t\toverrides: [\n\t\t\t{\n\t\t\t\tfiles: ['apps/**'],\n\t\t\t\tplugins: ['typescript', 'react'],\n\t\t\t\trules: {\n\t\t\t\t\t'react/self-closing-comp': 'error',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tfiles: ['**/*.test.ts', '**/*.test.tsx'],\n\t\t\t\tplugins: ['typescript', 'vitest'],\n\t\t\t\trules: {\n\t\t\t\t\t'@typescript-eslint/no-explicit-any': 'off',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tfiles: ['**/scripts/**', '**/src/lib/imdb/**'],\n\t\t\t\trules: {\n\t\t\t\t\t'no-console': 'off',\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\tstaged: {\n\t\t'*.{js,ts,tsx}': 'vp check --fix',\n\t},\n} as any)\n"],"mappings":";;;;;;;;;;;;;;AAoBA,MAAM,oBAAoB;CACzB;CACA;CACA;CACA;CACA;AAED,MAAM,mBAAmB;CAAC;CAAkB;CAAiB;CAAc;AAE3E,SAAS,kBAAkB,MAAsB;CAChD,MAAM,kBAAkB;CACxB,MAAM,0BAA0B,OAAO;CAEvC,OAAO;EACN,MAAM;EACN,UAAU,IAAI;GACb,IAAI,OAAO,iBACV,OAAO;;EAIT,KAAK,IAAI;GACR,IAAI,OAAO,yBAAyB;IACnC,KAAK,MAAM,YAAY,mBAAmB;KACzC,MAAM,WAAW,QAAQ,MAAM,SAAS;KACxC,IAAI,WAAW,SAAS,EACvB,OAAO,4BAA4B,SAAS;;IAG9C,MAAM,IAAI,MACT,4CAA4C,kBAAkB,KAAK,MAAM,OAAO,QAAQ,MAAM,EAAE,GAAG,CAAC,KAAK,KAAK,GAC9G;;;EAIH;;AAGF,SAAS,aAAa,MAAsB;CAC3C,MAAM,kBAAkB;CACxB,MAAM,0BAA0B,OAAO;CAEvC,OAAO;EACN,MAAM;EACN,UAAU,IAAI;GACb,IAAI,OAAO,iBACV,OAAO;;EAIT,KAAK,IAAI;GACR,IAAI,OAAO,yBAAyB;IACnC,KAAK,MAAM,YAAY,kBAAkB;KACxC,MAAM,WAAW,QAAQ,MAAM,SAAS;KACxC,IAAI,WAAW,SAAS,EACvB,OAAO,WAAW,SAAS;;IAG7B,MAAM,IAAI,MACT,2CAA2C,iBAAiB,KAAK,MAAM,OAAO,QAAQ,MAAM,EAAE,GAAG,CAAC,KAAK,KAAK,GAC5G;;;EAIH;;AAGF,MAAM,cAAc,IAA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SAAS,CAAC,cAAc,QAAQ;IAChC,OAAO,EACN,2BAA2B,SAC3B;IACD;GACD;IACC,OAAO,CAAC,gBAAgB,gBAAgB;IACxC,SAAS,CAAC,cAAc,SAAS;IACjC,OAAO,EACN,sCAAsC,OACtC;IACD;GACD;IACC,OAAO,CAAC,iBAAiB,qBAAqB;IAC9C,OAAO,EACN,cAAc,OACd;IACD;GACD;EACD;CACD,QAAQ,EACP,iBAAiB,kBACjB;CACD,CAAQ"}
|
|
1
|
+
{"version":3,"file":"vite.shared.mjs","names":["defineVitestConfig","defineConfig"],"sources":["../vite.shared.ts"],"sourcesContent":["import { nitro } from 'nitro/vite'\nimport { devtools } from '@tanstack/devtools-vite'\nimport { tanstackStart } from '@tanstack/react-start/plugin/vite'\nimport viteReact, { reactCompilerPreset } from '@vitejs/plugin-react'\nimport tailwindcss from '@tailwindcss/vite'\nimport babel from '@rolldown/plugin-babel'\nimport svgr from 'vite-plugin-svgr'\nimport { existsSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type { Plugin } from 'vite'\nimport {\n\tdefineConfig as defineVitestConfig,\n\tmergeConfig,\n\ttype TestProjectConfiguration,\n\ttype TestProjectInlineConfiguration,\n} from 'vitest/config'\nimport { defineConfig } from 'vite'\nimport { playwright } from 'vite-plus/test/browser-playwright'\n\nconst HANDLER_LOCATIONS = [\n\t'__mocks__/handlers.ts',\n\t'__mocks__/handlers.js',\n\t'src/mocks/handlers.ts',\n\t'src/mocks/handlers.js',\n]\n\nconst STYLES_LOCATIONS = ['src/styles.css', 'src/index.css', 'src/app.css']\n\nfunction mswHandlersPlugin(root: string): Plugin {\n\tconst virtualModuleId = '@test/handlers'\n\tconst resolvedVirtualModuleId = '\\0' + virtualModuleId\n\n\treturn {\n\t\tname: 'msw-handlers-resolver',\n\t\tresolveId(id) {\n\t\t\tif (id === virtualModuleId) {\n\t\t\t\treturn resolvedVirtualModuleId\n\t\t\t}\n\t\t\treturn undefined\n\t\t},\n\t\tload(id) {\n\t\t\tif (id === resolvedVirtualModuleId) {\n\t\t\t\tfor (const location of HANDLER_LOCATIONS) {\n\t\t\t\t\tconst fullPath = resolve(root, location)\n\t\t\t\t\tif (existsSync(fullPath)) {\n\t\t\t\t\t\treturn `export { default } from '${fullPath}'`\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`No MSW handlers found. Expected one of:\\n${HANDLER_LOCATIONS.map((l) => ` - ${resolve(root, l)}`).join('\\n')}`,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn undefined\n\t\t},\n\t}\n}\n\nfunction stylesPlugin(root: string): Plugin {\n\tconst virtualModuleId = '@test/styles'\n\tconst resolvedVirtualModuleId = '\\0' + virtualModuleId\n\n\treturn {\n\t\tname: 'styles-resolver',\n\t\tresolveId(id) {\n\t\t\tif (id === virtualModuleId) {\n\t\t\t\treturn resolvedVirtualModuleId\n\t\t\t}\n\t\t\treturn undefined\n\t\t},\n\t\tload(id) {\n\t\t\tif (id === resolvedVirtualModuleId) {\n\t\t\t\tfor (const location of STYLES_LOCATIONS) {\n\t\t\t\t\tconst fullPath = resolve(root, location)\n\t\t\t\t\tif (existsSync(fullPath)) {\n\t\t\t\t\t\treturn `import '${fullPath}'`\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`No styles file found. Expected one of:\\n${STYLES_LOCATIONS.map((l) => ` - ${resolve(root, l)}`).join('\\n')}`,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn undefined\n\t\t},\n\t}\n}\n\nconst stylesSetup = '@aamini/config/setup/styles'\n\nfunction mergeProjectConfig(\n\tbase: TestProjectConfiguration,\n\toverrides: TestProjectConfiguration = {},\n): TestProjectConfiguration {\n\treturn mergeConfig(\n\t\tbase as Record<string, any>,\n\t\toverrides as Record<string, any>,\n\t) as TestProjectConfiguration\n}\n\ninterface ProjectOverrides {\n\tserver?: TestProjectConfiguration\n\tbrowser?: TestProjectConfiguration\n}\n\nfunction createBaseConfig(\n\troot: string,\n\toverrides: TestProjectInlineConfiguration = {},\n\tprojectOverrides: ProjectOverrides = {},\n) {\n\tconst localSetup = resolve(root, 'vitest.setup.ts')\n\tconst hasLocalSetup = existsSync(localSetup)\n\n\treturn mergeConfig(\n\t\tdefineVitestConfig({\n\t\t\troot,\n\t\t\tresolve: {\n\t\t\t\ttsconfigPaths: true,\n\t\t\t\tdedupe: ['react', 'react-dom'],\n\t\t\t\talias: [\n\t\t\t\t\t{ find: '@/mocks', replacement: resolve(root, '__mocks__') },\n\t\t\t\t\t{ find: '@', replacement: resolve(root, 'src') },\n\t\t\t\t],\n\t\t\t},\n\t\t\tplugins: [\n\t\t\t\ttailwindcss(),\n\t\t\t\tsvgr({\n\t\t\t\t\tinclude: '**/*.svg',\n\t\t\t\t\tsvgrOptions: { exportType: 'default' },\n\t\t\t\t}),\n\t\t\t],\n\t\t\ttest: {\n\t\t\t\tpassWithNoTests: true,\n\t\t\t\texclude: [\n\t\t\t\t\t'**/node_modules/**',\n\t\t\t\t\t'**/dist/**',\n\t\t\t\t\t'**/.output/**',\n\t\t\t\t\t'**/.vercel/**',\n\t\t\t\t\t'**/cypress/**',\n\t\t\t\t\t'**/.{idea,git,cache,output,temp}/**',\n\t\t\t\t\t'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',\n\t\t\t\t\t'**/e2e/**',\n\t\t\t\t],\n\t\t\t\tprojects: [\n\t\t\t\t\t{\n\t\t\t\t\t\textends: true,\n\t\t\t\t\t\ttest: {\n\t\t\t\t\t\t\tname: 'unit',\n\t\t\t\t\t\t\tinclude: ['src/**/*.test.unit.ts'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tmergeProjectConfig(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\textends: true,\n\t\t\t\t\t\t\tplugins: [mswHandlersPlugin(root)],\n\t\t\t\t\t\t\ttest: {\n\t\t\t\t\t\t\t\tname: 'server',\n\t\t\t\t\t\t\t\tinclude: ['src/**/*.test.ts'],\n\t\t\t\t\t\t\t\texclude: ['src/**/*.test.unit.ts', 'src/**/*.test.tsx'],\n\t\t\t\t\t\t\t\ttestTimeout: 30_000,\n\t\t\t\t\t\t\t\tfileParallelism: false,\n\t\t\t\t\t\t\t\tsetupFiles: hasLocalSetup ? [localSetup] : [],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} satisfies TestProjectConfiguration,\n\t\t\t\t\t\tprojectOverrides.server ?? {},\n\t\t\t\t\t),\n\t\t\t\t\tmergeProjectConfig(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\textends: true,\n\t\t\t\t\t\t\tplugins: [mswHandlersPlugin(root), stylesPlugin(root)],\n\t\t\t\t\t\t\ttest: {\n\t\t\t\t\t\t\t\tname: 'browser',\n\t\t\t\t\t\t\t\tinclude: ['src/**/*.test.tsx', 'tests/**/*.test.tsx'],\n\t\t\t\t\t\t\t\tsetupFiles: [stylesSetup],\n\t\t\t\t\t\t\t\tbrowser: {\n\t\t\t\t\t\t\t\t\tinstances: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tbrowser: 'chromium',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\tprovider: playwright(),\n\t\t\t\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\t\t\t\theadless: true,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} satisfies TestProjectConfiguration,\n\t\t\t\t\t\tprojectOverrides.browser ?? {},\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t},\n\t\t}),\n\t\toverrides,\n\t)\n}\n\nconst isVitest = process.env.VITEST === 'true'\n\nfunction createFrameworkConfig(root: string) {\n\treturn defineConfig({\n\t\troot,\n\t\tresolve: {\n\t\t\ttsconfigPaths: true,\n\t\t\tdedupe: ['react', 'react-dom'],\n\t\t\talias: [\n\t\t\t\t{ find: '@/mocks', replacement: resolve(root, '__mocks__') },\n\t\t\t\t{ find: '@', replacement: resolve(root, 'src') },\n\t\t\t],\n\t\t},\n\t\tssr: {\n\t\t\tnoExternal: ['recharts'],\n\t\t},\n\t\tplugins: [\n\t\t\t...(isVitest ? [] : [devtools(), nitro(), tanstackStart()]),\n\t\t\ttailwindcss(),\n\t\t\tviteReact(),\n\t\t\tbabel({ presets: [reactCompilerPreset()] }),\n\t\t\tsvgr({\n\t\t\t\tinclude: '**/*.svg',\n\t\t\t\tsvgrOptions: { exportType: 'default' },\n\t\t\t}),\n\t\t],\n\t})\n}\n\n// Creates a full app config with customized test project overrides\nexport function createAppConfig(\n\troot: string,\n\tprojectOverrides: ProjectOverrides = {},\n\toverrides: TestProjectInlineConfiguration = {},\n) {\n\treturn {\n\t\t...workspaceConfig,\n\t\t...mergeConfig(\n\t\t\tcreateFrameworkConfig(root),\n\t\t\tcreateBaseConfig(root, overrides, projectOverrides),\n\t\t),\n\t}\n}\n\n// Helper to create config from import.meta.url\nexport function baseConfigFor(configUrl: string | URL) {\n\tconst root = dirname(fileURLToPath(configUrl))\n\treturn createAppConfig(root)\n}\n\n// Workspace-level Vite+ config shared by monorepo roots.\nexport const workspaceConfig = {\n\tfmt: {\n\t\tsingleQuote: true,\n\t\tsemi: false,\n\t\tuseTabs: true,\n\t\texperimentalTailwindcss: {},\n\t\tprintWidth: 80,\n\t\texperimentalSortPackageJson: false,\n\t\tproseWrap: 'always',\n\t\tignorePatterns: [\n\t\t\t'**/.vercel',\n\t\t\t'**/.output',\n\t\t\t'**/dist/**',\n\t\t\t'**/env.d.ts',\n\t\t\t'pnpm-lock.yaml',\n\t\t\t'**/routeTree.gen.ts',\n\t\t\t'infra/manifests/gitops/flux-system/gotk-components.yaml',\n\t\t\t'infra/charts/**/templates/**/*.{yml,yaml}',\n\t\t\t'**/charts/**',\n\t\t\t'**/*.yaml',\n\t\t\t'**/*.yml',\n\t\t],\n\t\toverrides: [\n\t\t\t{\n\t\t\t\tfiles: ['*.{yaml,yml}'],\n\t\t\t\toptions: {\n\t\t\t\t\tuseTabs: false,\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\tlint: {\n\t\tplugins: [\n\t\t\t'eslint',\n\t\t\t'unicorn',\n\t\t\t'typescript',\n\t\t\t'oxc',\n\t\t\t'react',\n\t\t\t'react-perf',\n\t\t\t'import',\n\t\t\t'jsdoc',\n\t\t\t'jsx-a11y',\n\t\t\t'node',\n\t\t\t'promise',\n\t\t],\n\t\tcategories: {},\n\t\toptions: {\n\t\t\ttypeAware: true,\n\t\t\ttypeCheck: true,\n\t\t},\n\t\trules: {\n\t\t\t'no-empty-pattern': 'off',\n\t\t\t'no-console': ['error', { allow: ['warn', 'error'] }],\n\t\t},\n\t\tsettings: {\n\t\t\t'jsx-a11y': {\n\t\t\t\tcomponents: {},\n\t\t\t\tattributes: {},\n\t\t\t},\n\t\t\treact: {\n\t\t\t\tformComponents: [],\n\t\t\t\tlinkComponents: [],\n\t\t\t},\n\t\t\tjsdoc: {\n\t\t\t\tignorePrivate: false,\n\t\t\t\tignoreInternal: false,\n\t\t\t\tignoreReplacesDocs: true,\n\t\t\t\toverrideReplacesDocs: true,\n\t\t\t\taugmentsExtendsReplacesDocs: false,\n\t\t\t\timplementsReplacesDocs: false,\n\t\t\t\texemptDestructuredRootsFromChecks: false,\n\t\t\t\ttagNamePreference: {},\n\t\t\t},\n\t\t},\n\t\tenv: {\n\t\t\tbuiltin: true,\n\t\t},\n\t\tglobals: {},\n\t\tignorePatterns: ['**/dist/**'],\n\t\toverrides: [\n\t\t\t{\n\t\t\t\tfiles: ['**/*.test.unit.ts'],\n\t\t\t\trules: {\n\t\t\t\t\t'eslint/no-restricted-imports': [\n\t\t\t\t\t\t'error',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpatterns: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tgroup: ['@aamini/config-testing/test/*'],\n\t\t\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\t\t'Unit tests should not import test fixtures. Use plain vitest imports instead.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tfiles: ['**/*.test.tsx'],\n\t\t\t\trules: {\n\t\t\t\t\t'eslint/no-restricted-imports': [\n\t\t\t\t\t\t'error',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpaths: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: '@aamini/config-testing/test/server',\n\t\t\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\t\t'Browser tests (*.test.tsx) should use test/browser, not test/server.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: '@aamini/config-testing/test/db',\n\t\t\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\t\t'Browser tests (*.test.tsx) should use test/browser, not test/db.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tfiles: ['**/*.test.ts'],\n\t\t\t\trules: {\n\t\t\t\t\t'eslint/no-restricted-imports': [\n\t\t\t\t\t\t'error',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpaths: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: '@aamini/config-testing/test/browser',\n\t\t\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\t\t'Server tests (*.test.ts) should use test/server or test/db, not test/browser.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tfiles: ['apps/**'],\n\t\t\t\tplugins: ['typescript', 'react'],\n\t\t\t\trules: {\n\t\t\t\t\t'react/self-closing-comp': 'error',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tfiles: ['**/*.test.ts', '**/*.test.tsx'],\n\t\t\t\tplugins: ['typescript', 'vitest'],\n\t\t\t\trules: {\n\t\t\t\t\t'@typescript-eslint/no-explicit-any': 'off',\n\t\t\t\t\t'vitest/no-standalone-expect': [\n\t\t\t\t\t\t'warn',\n\t\t\t\t\t\t{ additionalTestBlockFunctions: ['test', 'test.skip'] },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tfiles: ['**/scripts/**', '**/src/lib/imdb/**'],\n\t\t\t\trules: {\n\t\t\t\t\t'no-console': 'off',\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\tstaged: {\n\t\t'*.{js,ts,tsx}': 'vp check --fix',\n\t},\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,MAAM,oBAAoB;CACzB;CACA;CACA;CACA;CACA;AAED,MAAM,mBAAmB;CAAC;CAAkB;CAAiB;CAAc;AAE3E,SAAS,kBAAkB,MAAsB;CAChD,MAAM,kBAAkB;CACxB,MAAM,0BAA0B,OAAO;CAEvC,OAAO;EACN,MAAM;EACN,UAAU,IAAI;GACb,IAAI,OAAO,iBACV,OAAO;;EAIT,KAAK,IAAI;GACR,IAAI,OAAO,yBAAyB;IACnC,KAAK,MAAM,YAAY,mBAAmB;KACzC,MAAM,WAAW,QAAQ,MAAM,SAAS;KACxC,IAAI,WAAW,SAAS,EACvB,OAAO,4BAA4B,SAAS;;IAG9C,MAAM,IAAI,MACT,4CAA4C,kBAAkB,KAAK,MAAM,OAAO,QAAQ,MAAM,EAAE,GAAG,CAAC,KAAK,KAAK,GAC9G;;;EAIH;;AAGF,SAAS,aAAa,MAAsB;CAC3C,MAAM,kBAAkB;CACxB,MAAM,0BAA0B,OAAO;CAEv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;EACJ,aAAa;EACb,MAAM;EACN,SAAS;EACT,yBAAyB,EAAE;EAC3B,YAAY;EACZ,6BAA6B;EAC7B,WAAW;EACX,gBAAgB;GACf;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACD,WAAW,CACV;GACC,OAAO,CAAC,eAAe;GACvB,SAAS,EACR,SAAS,OACT;GACD,CACD;EACD;CACD,MAAM;EACL,SAAS;GACR;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACD,YAAY,EAAE;EACd,SAAS;GACR,WAAW;GACX,WAAW;GACX;EACD,OAAO;GACN,oBAAoB;GACpB,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,QAAQ,EAAE,CAAC;GACrD;EACD,UAAU;GACT,YAAY;IACX,YAAY,EAAE;IACd,YAAY,EAAE;IACd;GACD,OAAO;IACN,gBAAgB,EAAE;IAClB,gBAAgB,EAAE;IAClB;GACD,OAAO;IACN,eAAe;IACf,gBAAgB;IAChB,oBAAoB;IACpB,sBAAsB;IACtB,6BAA6B;IAC7B,wBAAwB;IACxB,mCAAmC;IACnC,mBAAmB,EAAE;IACrB;GACD;EACD,KAAK,EACJ,SAAS,MACT;EACD,SAAS,EAAE;EACX,gBAAgB,CAAC,aAAa;EAC9B,WAAW;GACV;IACC,OAAO,CAAC,oBAAoB;IAC5B,OAAO,EACN,gCAAgC,CAC/B,SACA,EACC,UAAU,CACT;KACC,OAAO,CAAC,gCAAgC;KACxC,SACC;KACD,CACD,EACD,CACD,EACD;IACD;GACD;IACC,OAAO,CAAC,gBAAgB;IACxB,OAAO,EACN,gCAAgC,CAC/B,SACA,EACC,OAAO,CACN;KACC,MAAM;KACN,SACC;KACD,EACD;KACC,MAAM;KACN,SACC;KACD,CACD,EACD,CACD,EACD;IACD;GACD;IACC,OAAO,CAAC,eAAe;IACvB,OAAO,EACN,gCAAgC,CAC/B,SACA,EACC,OAAO,CACN;KACC,MAAM;KACN,SACC;KACD,CACD,EACD,CACD,EACD;IACD;GACD;IACC,OAAO,CAAC,UAAU;IAClB,SAAS,CAAC,cAAc,QAAQ;IAChC,OAAO,EACN,2BAA2B,SAC3B;IACD;GACD;IACC,OAAO,CAAC,gBAAgB,gBAAgB;IACxC,SAAS,CAAC,cAAc,SAAS;IACjC,OAAO;KACN,sCAAsC;KACtC,+BAA+B,CAC9B,QACA,EAAE,8BAA8B,CAAC,QAAQ,YAAY,EAAE,CACvD;KACD;IACD;GACD;IACC,OAAO,CAAC,iBAAiB,qBAAqB;IAC9C,OAAO,EACN,cAAc,OACd;IACD;GACD;EACD;CACD,QAAQ,EACP,iBAAiB,kBACjB;CACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aamini/config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -57,11 +57,14 @@
|
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
|
+
"build": "vp pack",
|
|
60
61
|
"pack": "vp pack",
|
|
61
62
|
"prepublishOnly": "vp pack"
|
|
62
63
|
},
|
|
63
64
|
"dependencies": {
|
|
65
|
+
"@babel/core": "^7.29.0",
|
|
64
66
|
"@playwright/test": "^1.59.1",
|
|
67
|
+
"@rolldown/plugin-babel": "^0.2.3",
|
|
65
68
|
"@tailwindcss/vite": "^4.2.1",
|
|
66
69
|
"@tanstack/devtools-vite": "^0.6.0",
|
|
67
70
|
"@tanstack/react-start": "^1.166.7",
|
|
@@ -83,17 +86,14 @@
|
|
|
83
86
|
"testcontainers": "^11.12.0",
|
|
84
87
|
"typescript": "^5.8.3",
|
|
85
88
|
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
|
|
89
|
+
"vite-plus": "latest",
|
|
86
90
|
"vite-plugin-svgr": "^5.2.0",
|
|
87
91
|
"vitest": "npm:@voidzero-dev/vite-plus-test@latest",
|
|
88
92
|
"vitest-browser-react": "^2.0.5"
|
|
89
93
|
},
|
|
90
94
|
"devDependencies": {
|
|
91
|
-
"@babel/core": "^7.29.0",
|
|
92
|
-
"@rolldown/plugin-babel": "^0.2.3",
|
|
93
95
|
"@types/babel__core": "^7.20.5",
|
|
94
96
|
"@vitest/ui": "4.1.5",
|
|
95
|
-
"
|
|
96
|
-
"playwright": "*",
|
|
97
|
-
"vite-plus": "latest"
|
|
97
|
+
"playwright": "*"
|
|
98
98
|
}
|
|
99
99
|
}
|
package/test/browser.ts
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
// oxlint-disable typescript-eslint/triple-slash-reference
|
|
2
2
|
/// <reference path="../virtual-modules.d.ts" />
|
|
3
3
|
// oxlint-disable no-empty-pattern
|
|
4
|
-
import handlers from '@test/handlers'
|
|
5
4
|
import { setupWorker, type SetupWorker } from 'msw/browser'
|
|
6
5
|
import { test as baseTest } from 'vitest'
|
|
6
|
+
import type { TestAPI } from 'vitest'
|
|
7
7
|
|
|
8
8
|
export interface MswBrowserFixture {
|
|
9
9
|
worker: SetupWorker
|
|
10
10
|
_cleanup: void
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
let workerSingleton: SetupWorker | undefined
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
async function ensureWorker(): Promise<SetupWorker> {
|
|
16
|
+
if (!workerSingleton) {
|
|
17
|
+
const { default: handlers } = await import('@test/handlers')
|
|
18
|
+
workerSingleton = setupWorker(...handlers)
|
|
19
|
+
}
|
|
20
|
+
return workerSingleton
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const extended = baseTest.extend<MswBrowserFixture>({
|
|
16
24
|
worker: [
|
|
17
25
|
async ({}, use) => {
|
|
18
|
-
|
|
19
|
-
await
|
|
20
|
-
|
|
26
|
+
const worker = await ensureWorker()
|
|
27
|
+
await worker.start({ quiet: true, onUnhandledRequest: 'bypass' })
|
|
28
|
+
await use(worker)
|
|
29
|
+
worker.stop()
|
|
21
30
|
},
|
|
22
31
|
{ auto: true, scope: 'worker' },
|
|
23
32
|
],
|
|
@@ -29,3 +38,7 @@ export const test = baseTest.extend<MswBrowserFixture>({
|
|
|
29
38
|
{ auto: true },
|
|
30
39
|
],
|
|
31
40
|
})
|
|
41
|
+
|
|
42
|
+
export { afterEach, beforeEach, describe, expect, vi } from 'vitest'
|
|
43
|
+
|
|
44
|
+
export const test = extended as TestAPI<MswBrowserFixture>
|
package/test/db.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
// oxlint-disable typescript-eslint/triple-slash-reference
|
|
2
|
-
/// <reference path="../virtual-modules.d.ts" />
|
|
3
1
|
// oxlint-disable no-empty-pattern
|
|
4
|
-
import handlers from '@test/handlers'
|
|
5
2
|
import { setupServer, SetupServer } from 'msw/node'
|
|
6
3
|
import { resolve } from 'node:path'
|
|
7
4
|
import { test as baseTest } from 'vitest'
|
|
5
|
+
import type { TestAPI } from 'vitest'
|
|
8
6
|
import type { Database } from './database'
|
|
9
7
|
import { seedDatabase } from './database'
|
|
8
|
+
import { findHandlerPath } from './internal'
|
|
10
9
|
|
|
11
10
|
const DEFAULT_SCHEMA_PATH = 'src/db/tables.ts'
|
|
12
11
|
const DEFAULT_MIGRATIONS_PATH = 'src/db/migrations'
|
|
@@ -19,15 +18,23 @@ export interface DbFixture {
|
|
|
19
18
|
seedFunction: (db: Database) => Promise<void>
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
let mswServer: SetupServer | undefined
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
async function ensureMswServer(): Promise<SetupServer> {
|
|
24
|
+
if (!mswServer) {
|
|
25
|
+
const { default: handlers } = await import(findHandlerPath())
|
|
26
|
+
mswServer = setupServer(...handlers)
|
|
27
|
+
}
|
|
28
|
+
return mswServer
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let extended = baseTest.extend<DbFixture>({
|
|
26
32
|
server: [
|
|
27
33
|
async ({}, use) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
const server = await ensureMswServer()
|
|
35
|
+
server.listen({ onUnhandledRequest: 'bypass' })
|
|
36
|
+
await use(server)
|
|
37
|
+
server.close()
|
|
31
38
|
},
|
|
32
39
|
{ auto: true, scope: 'worker' },
|
|
33
40
|
],
|
|
@@ -38,8 +45,6 @@ export const test = baseTest.extend<DbFixture>({
|
|
|
38
45
|
},
|
|
39
46
|
{ auto: true },
|
|
40
47
|
],
|
|
41
|
-
|
|
42
|
-
// Database fixtures
|
|
43
48
|
seedFunction: [async ({}, use) => use(async () => {}), { scope: 'file' }],
|
|
44
49
|
db: [
|
|
45
50
|
async ({ seedFunction }: Pick<DbFixture, 'seedFunction'>, use) => {
|
|
@@ -48,10 +53,7 @@ export const test = baseTest.extend<DbFixture>({
|
|
|
48
53
|
const { Wait } = await import('testcontainers')
|
|
49
54
|
const { Pool } = await import('pg')
|
|
50
55
|
|
|
51
|
-
// Auto-discover schema
|
|
52
56
|
const schemaPath = resolve(process.cwd(), DEFAULT_SCHEMA_PATH)
|
|
53
|
-
|
|
54
|
-
// Resolve migrations folder relative to cwd (app root)
|
|
55
57
|
const migrationsFolder = resolve(process.cwd(), DEFAULT_MIGRATIONS_PATH)
|
|
56
58
|
|
|
57
59
|
const container = await new PostgreSqlContainer(DEFAULT_IMAGE)
|
|
@@ -73,8 +75,12 @@ export const test = baseTest.extend<DbFixture>({
|
|
|
73
75
|
],
|
|
74
76
|
})
|
|
75
77
|
|
|
78
|
+
export { afterEach, beforeEach, describe, expect, vi } from 'vitest'
|
|
79
|
+
|
|
80
|
+
export const test = extended as TestAPI<DbFixture>
|
|
81
|
+
|
|
76
82
|
export function initDb(seedFunction: (db: Database) => Promise<void>) {
|
|
77
|
-
|
|
83
|
+
extended = extended.override({
|
|
78
84
|
seedFunction: [async ({}, use) => use(seedFunction), { scope: 'file' }],
|
|
79
|
-
})
|
|
85
|
+
}) as typeof extended
|
|
80
86
|
}
|
package/test/internal.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs'
|
|
2
|
+
import { resolve } from 'node:path'
|
|
3
|
+
|
|
4
|
+
export const HANDLER_LOCATIONS = [
|
|
5
|
+
'__mocks__/handlers.ts',
|
|
6
|
+
'__mocks__/handlers.js',
|
|
7
|
+
'src/mocks/handlers.ts',
|
|
8
|
+
'src/mocks/handlers.js',
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
export function findHandlerPath(): string {
|
|
12
|
+
if (typeof process === 'undefined') {
|
|
13
|
+
return ''
|
|
14
|
+
}
|
|
15
|
+
const cwd = process.cwd()
|
|
16
|
+
for (const location of HANDLER_LOCATIONS) {
|
|
17
|
+
const fullPath = resolve(cwd, location)
|
|
18
|
+
if (existsSync(fullPath)) return fullPath
|
|
19
|
+
}
|
|
20
|
+
throw new Error(
|
|
21
|
+
`No MSW handlers found. Expected one of:\n${HANDLER_LOCATIONS.map((l) => ` - ${resolve(cwd, l)}`).join('\n')}`,
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function createProxy<T extends object>(getTarget: () => T): T {
|
|
26
|
+
const handlers: ProxyHandler<object> = {
|
|
27
|
+
get(_, prop) {
|
|
28
|
+
return Reflect.get(getTarget(), prop, getTarget())
|
|
29
|
+
},
|
|
30
|
+
apply(target, thisArg, args) {
|
|
31
|
+
return Reflect.apply(getTarget() as any, thisArg, args)
|
|
32
|
+
},
|
|
33
|
+
has(_, prop) {
|
|
34
|
+
return prop in getTarget()
|
|
35
|
+
},
|
|
36
|
+
ownKeys() {
|
|
37
|
+
return Reflect.ownKeys(getTarget())
|
|
38
|
+
},
|
|
39
|
+
getOwnPropertyDescriptor(_, prop) {
|
|
40
|
+
return Reflect.getOwnPropertyDescriptor(getTarget(), prop)
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
const proxyTarget = () => {}
|
|
44
|
+
return new Proxy(proxyTarget, handlers) as T
|
|
45
|
+
}
|
package/test/server.ts
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
// oxlint-disable typescript-eslint/triple-slash-reference
|
|
2
|
-
/// <reference path="../virtual-modules.d.ts" />
|
|
3
1
|
// oxlint-disable no-empty-pattern
|
|
4
|
-
import
|
|
5
|
-
import { SetupServer, setupServer } from 'msw/node'
|
|
2
|
+
import { setupServer, type SetupServer } from 'msw/node'
|
|
6
3
|
import { test as baseTest } from 'vitest'
|
|
4
|
+
import type { TestAPI } from 'vitest'
|
|
5
|
+
import { findHandlerPath } from './internal'
|
|
7
6
|
|
|
8
7
|
export interface MswServerFixture {
|
|
9
8
|
server: SetupServer
|
|
10
9
|
_cleanup: void
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
let mswServer: SetupServer | undefined
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
async function ensureMswServer(): Promise<SetupServer> {
|
|
15
|
+
if (!mswServer) {
|
|
16
|
+
const { default: handlers } = await import(findHandlerPath())
|
|
17
|
+
mswServer = setupServer(...handlers)
|
|
18
|
+
}
|
|
19
|
+
return mswServer
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const extended = baseTest.extend<MswServerFixture>({
|
|
16
23
|
server: [
|
|
17
24
|
async ({}, use) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
const server = await ensureMswServer()
|
|
26
|
+
server.listen({ onUnhandledRequest: 'bypass' })
|
|
27
|
+
await use(server)
|
|
28
|
+
server.close()
|
|
21
29
|
},
|
|
22
30
|
{ auto: true, scope: 'worker' },
|
|
23
31
|
],
|
|
@@ -29,3 +37,7 @@ export const test = baseTest.extend<MswServerFixture>({
|
|
|
29
37
|
{ auto: true },
|
|
30
38
|
],
|
|
31
39
|
})
|
|
40
|
+
|
|
41
|
+
export { afterEach, beforeEach, describe, expect, vi } from 'vitest'
|
|
42
|
+
|
|
43
|
+
export const test = extended as TestAPI<MswServerFixture>
|