@aamini/config 0.0.12 → 0.0.14
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/dist/{playwright.shared.config.d.mts → playwright.d.mts} +2 -3
- package/dist/{playwright.shared.config.mjs → playwright.mjs} +2 -3
- package/dist/playwright.mjs.map +1 -0
- package/dist/setup/styles.mjs +0 -1
- package/dist/test/browser.d.mts +7 -2
- package/dist/test/browser.mjs +5 -3
- package/dist/test/browser.mjs.map +1 -1
- package/dist/test/db.d.mts +34 -7
- package/dist/test/db.mjs +29 -15
- package/dist/test/db.mjs.map +1 -1
- package/dist/test/server.d.mts +7 -3
- package/dist/test/server.mjs +3 -4
- package/dist/test/server.mjs.map +1 -1
- package/dist/vite.d.mts +81 -0
- package/dist/vite.mjs +211 -0
- package/dist/vite.mjs.map +1 -0
- package/package.json +43 -47
- package/tsconfig/tsconfig.tanstack.json +1 -1
- package/dist/internal-Dshd0hdM.mjs +0 -22
- package/dist/internal-Dshd0hdM.mjs.map +0 -1
- package/dist/playwright.shared.config.mjs.map +0 -1
- package/dist/test/database.d.mts +0 -22
- package/dist/test/database.mjs +0 -18
- package/dist/test/database.mjs.map +0 -1
- package/dist/test/playwright.d.mts +0 -7
- package/dist/test/playwright.mjs +0 -15
- package/dist/test/playwright.mjs.map +0 -1
- package/dist/test/postgres.d.mts +0 -14
- package/dist/test/postgres.mjs +0 -25
- package/dist/test/postgres.mjs.map +0 -1
- package/dist/test/visual-page.d.mts +0 -36
- package/dist/test/visual-page.mjs +0 -30
- package/dist/test/visual-page.mjs.map +0 -1
- package/dist/vite.shared.d.mts +0 -379
- package/dist/vite.shared.mjs +0 -302
- package/dist/vite.shared.mjs.map +0 -1
- package/dist/vitest.shared.d.mts +0 -12
- package/dist/vitest.shared.mjs +0 -122
- package/dist/vitest.shared.mjs.map +0 -1
- package/msw.ts +0 -5
- package/playwright.shared.config.ts +0 -71
- package/setup/styles.ts +0 -4
- package/test/browser.ts +0 -44
- package/test/database.ts +0 -38
- package/test/db.ts +0 -86
- package/test/internal.ts +0 -45
- package/test/playwright.ts +0 -17
- package/test/postgres.ts +0 -43
- package/test/server.ts +0 -43
- package/test/visual-page.ts +0 -57
- package/tsconfig/tsconfig.astro.json +0 -34
- package/tsconfig/tsconfig.react.json +0 -16
- package/virtual-modules.d.ts +0 -6
- package/vite.config.ts +0 -53
- package/vite.shared.ts +0 -411
- package/vitest.shared.ts +0 -183
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { PlaywrightTestConfig } from "@playwright/test";
|
|
2
2
|
|
|
3
|
-
//#region playwright.
|
|
4
|
-
/** See https://playwright.dev/docs/test-configuration. */
|
|
3
|
+
//#region src/playwright.d.ts
|
|
5
4
|
declare const baseConfig: (overrides?: PlaywrightTestConfig) => Promise<PlaywrightTestConfig<{}, {}>>;
|
|
6
5
|
//#endregion
|
|
7
6
|
export { baseConfig };
|
|
8
|
-
//# sourceMappingURL=playwright.
|
|
7
|
+
//# sourceMappingURL=playwright.d.mts.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { defineConfig, devices } from "@playwright/test";
|
|
2
|
-
//#region playwright.
|
|
3
|
-
/** See https://playwright.dev/docs/test-configuration. */
|
|
2
|
+
//#region src/playwright.ts
|
|
4
3
|
const baseConfig = async (overrides) => {
|
|
5
4
|
return defineConfig({
|
|
6
5
|
testDir: "./e2e",
|
|
@@ -44,4 +43,4 @@ const baseConfig = async (overrides) => {
|
|
|
44
43
|
//#endregion
|
|
45
44
|
export { baseConfig };
|
|
46
45
|
|
|
47
|
-
//# sourceMappingURL=playwright.
|
|
46
|
+
//# sourceMappingURL=playwright.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwright.mjs","names":[],"sources":["../src/playwright.ts"],"sourcesContent":["import {\n\tdefineConfig,\n\tdevices,\n\ttype PlaywrightTestConfig,\n} from '@playwright/test'\n\nexport const baseConfig = async (overrides?: PlaywrightTestConfig) => {\n\treturn defineConfig(\n\t\t{\n\t\t\ttestDir: './e2e',\n\t\t\toutputDir: '.playwright/test-results',\n\t\t\tfullyParallel: true,\n\t\t\tworkers: process.env.CI ? 1 : '50%',\n\t\t\tforbidOnly: !!process.env.CI,\n\t\t\tretries: process.env.CI ? 3 : 0,\n\t\t\treporter: [\n\t\t\t\t['html', { open: 'never', outputFolder: '.playwright/report' }],\n\t\t\t],\n\t\t\tuse: {\n\t\t\t\tcolorScheme: 'dark',\n\t\t\t\tbaseURL: process.env.BASE_URL,\n\t\t\t\ttrace: 'retain-on-first-failure',\n\t\t\t\tscreenshot: 'on',\n\t\t\t\tvideo: 'retain-on-failure',\n\t\t\t},\n\t\t\ttimeout: 15_000,\n\t\t\texpect: { timeout: 5_000 },\n\t\t\tprojects: [\n\t\t\t\t{\n\t\t\t\t\tname: 'chromium',\n\t\t\t\t\tuse: {\n\t\t\t\t\t\t...devices['Desktop Chrome'],\n\t\t\t\t\t\tlaunchOptions: { args: ['--disable-lcd-text'] },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'mobile',\n\t\t\t\t\tuse: {\n\t\t\t\t\t\t...devices['Desktop Chrome'],\n\t\t\t\t\t\tviewport: { width: 320, height: 800 },\n\t\t\t\t\t\tlaunchOptions: { args: ['--disable-lcd-text'] },\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"],"mappings":";;AAMA,MAAa,aAAa,OAAO,cAAqC;CACrE,OAAO,aACN;EACC,SAAS;EACT,WAAW;EACX,eAAe;EACf,SAAS,QAAQ,IAAI,KAAK,IAAI;EAC9B,YAAY,CAAC,CAAC,QAAQ,IAAI;EAC1B,SAAS,QAAQ,IAAI,KAAK,IAAI;EAC9B,UAAU,CACT,CAAC,QAAQ;GAAE,MAAM;GAAS,cAAc;GAAsB,CAAC,CAC/D;EACD,KAAK;GACJ,aAAa;GACb,SAAS,QAAQ,IAAI;GACrB,OAAO;GACP,YAAY;GACZ,OAAO;GACP;EACD,SAAS;EACT,QAAQ,EAAE,SAAS,KAAO;EAC1B,UAAU,CACT;GACC,MAAM;GACN,KAAK;IACJ,GAAG,QAAQ;IACX,eAAe,EAAE,MAAM,CAAC,qBAAqB,EAAE;IAC/C;GACD,EACD;GACC,MAAM;GACN,KAAK;IACJ,GAAG,QAAQ;IACX,UAAU;KAAE,OAAO;KAAK,QAAQ;KAAK;IACrC,eAAe,EAAE,MAAM,CAAC,qBAAqB,EAAE;IAC/C;GACD,CACD;EACD,EACD,aAAa,EAAE,CACf"}
|
package/dist/setup/styles.mjs
CHANGED
package/dist/test/browser.d.mts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { SetupWorker } from "msw/browser";
|
|
2
|
-
import { TestAPI, afterEach, beforeEach, describe, expect, vi } from "
|
|
2
|
+
import { ExpectPollOptions, TestAPI, afterEach, beforeEach, describe, expect as expect$1, vi } from "vite-plus/test";
|
|
3
|
+
import { Locator } from "vite-plus/test/browser";
|
|
3
4
|
|
|
4
|
-
//#region test/browser.d.ts
|
|
5
|
+
//#region src/test/browser.d.ts
|
|
5
6
|
interface MswBrowserFixture {
|
|
6
7
|
worker: SetupWorker;
|
|
7
8
|
_cleanup: void;
|
|
8
9
|
}
|
|
10
|
+
type BrowserElementExpectation = {
|
|
11
|
+
element: <T extends HTMLElement | SVGElement | null | Locator>(element: T, options?: ExpectPollOptions) => any;
|
|
12
|
+
};
|
|
13
|
+
declare const expect: typeof expect$1 & BrowserElementExpectation;
|
|
9
14
|
declare const test: TestAPI<MswBrowserFixture>;
|
|
10
15
|
//#endregion
|
|
11
16
|
export { MswBrowserFixture, afterEach, beforeEach, describe, expect, test, vi };
|
package/dist/test/browser.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { setupWorker } from "msw/browser";
|
|
2
|
-
import { afterEach, beforeEach, describe, expect, test as test$1, vi } from "
|
|
3
|
-
//#region test/browser.ts
|
|
2
|
+
import { afterEach, beforeEach, describe, expect as expect$1, test as test$1, vi } from "vite-plus/test";
|
|
3
|
+
//#region src/test/browser.ts
|
|
4
4
|
let workerSingleton;
|
|
5
5
|
async function ensureWorker() {
|
|
6
6
|
if (!workerSingleton) {
|
|
@@ -9,7 +9,7 @@ async function ensureWorker() {
|
|
|
9
9
|
}
|
|
10
10
|
return workerSingleton;
|
|
11
11
|
}
|
|
12
|
-
const
|
|
12
|
+
const extended = test$1.extend({
|
|
13
13
|
worker: [async ({}, use) => {
|
|
14
14
|
const worker = await ensureWorker();
|
|
15
15
|
await worker.start({
|
|
@@ -27,6 +27,8 @@ const test = test$1.extend({
|
|
|
27
27
|
worker.resetHandlers();
|
|
28
28
|
}, { auto: true }]
|
|
29
29
|
});
|
|
30
|
+
const expect = expect$1;
|
|
31
|
+
const test = extended;
|
|
30
32
|
//#endregion
|
|
31
33
|
export { afterEach, beforeEach, describe, expect, test, vi };
|
|
32
34
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.mjs","names":["baseTest"],"sources":["../../test/browser.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"browser.mjs","names":["baseTest","baseExpect"],"sources":["../../src/test/browser.ts"],"sourcesContent":["import { setupWorker, type SetupWorker } from 'msw/browser'\nimport { expect as baseExpect, test as baseTest } from 'vite-plus/test'\nimport type { ExpectPollOptions, TestAPI } from 'vite-plus/test'\nimport type { Locator } from 'vite-plus/test/browser'\n\nexport interface MswBrowserFixture {\n\tworker: SetupWorker\n\t_cleanup: void\n}\n\ntype BrowserElementExpectation = {\n\telement: <T extends HTMLElement | SVGElement | null | Locator>(\n\t\telement: T,\n\t\toptions?: ExpectPollOptions,\n\t) => any\n}\n\nlet workerSingleton: SetupWorker | undefined\n\nasync function ensureWorker(): Promise<SetupWorker> {\n\tif (!workerSingleton) {\n\t\tconst { default: handlers } = await import('@test/handlers')\n\t\tworkerSingleton = setupWorker(...handlers)\n\t}\n\treturn workerSingleton\n}\n\nconst extended = baseTest.extend<MswBrowserFixture>({\n\tworker: [\n\t\tasync ({}, use) => {\n\t\t\tconst worker = await ensureWorker()\n\t\t\tawait worker.start({ quiet: true, onUnhandledRequest: 'bypass' })\n\t\t\tawait use(worker)\n\t\t\tworker.stop()\n\t\t},\n\t\t{ auto: true, scope: 'worker' },\n\t],\n\t_cleanup: [\n\t\tasync ({ worker }, use) => {\n\t\t\tawait use()\n\t\t\tworker.resetHandlers()\n\t\t},\n\t\t{ auto: true },\n\t],\n})\n\nexport { afterEach, beforeEach, describe, vi } from 'vite-plus/test'\nexport const expect = baseExpect as typeof baseExpect &\n\tBrowserElementExpectation\nexport const test = extended as TestAPI<MswBrowserFixture>\n"],"mappings":";;;AAiBA,IAAI;AAEJ,eAAe,eAAqC;CACnD,IAAI,CAAC,iBAAiB;EACrB,MAAM,EAAE,SAAS,aAAa,MAAM,OAAO;EAC3C,kBAAkB,YAAY,GAAG,SAAS;;CAE3C,OAAO;;AAGR,MAAM,WAAWA,OAAS,OAA0B;CACnD,QAAQ,CACP,OAAO,IAAI,QAAQ;EAClB,MAAM,SAAS,MAAM,cAAc;EACnC,MAAM,OAAO,MAAM;GAAE,OAAO;GAAM,oBAAoB;GAAU,CAAC;EACjE,MAAM,IAAI,OAAO;EACjB,OAAO,MAAM;IAEd;EAAE,MAAM;EAAM,OAAO;EAAU,CAC/B;CACD,UAAU,CACT,OAAO,EAAE,UAAU,QAAQ;EAC1B,MAAM,KAAK;EACX,OAAO,eAAe;IAEvB,EAAE,MAAM,MAAM,CACd;CACD,CAAC;AAGF,MAAa,SAASC;AAEtB,MAAa,OAAO"}
|
package/dist/test/db.d.mts
CHANGED
|
@@ -1,16 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as _$vite_plus_test0 from "vite-plus/test";
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, vi } from "vite-plus/test";
|
|
3
3
|
import { SetupServer } from "msw/node";
|
|
4
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
5
|
+
import { Pool } from "pg";
|
|
4
6
|
|
|
5
|
-
//#region test/db.d.ts
|
|
7
|
+
//#region src/test/db.d.ts
|
|
8
|
+
interface DbConfig {
|
|
9
|
+
schemaPath?: string;
|
|
10
|
+
migrationsPath?: string;
|
|
11
|
+
postgresImage?: string;
|
|
12
|
+
}
|
|
13
|
+
type Database = NodePgDatabase & {
|
|
14
|
+
$client: Pool;
|
|
15
|
+
};
|
|
6
16
|
interface DbFixture {
|
|
7
17
|
server: SetupServer;
|
|
8
18
|
_cleanup: void;
|
|
9
19
|
db: Database;
|
|
10
|
-
seedFunction: (db: Database) => Promise<void
|
|
20
|
+
seedFunction: (db: Database) => Promise<void> | void;
|
|
21
|
+
}
|
|
22
|
+
declare const test: _$vite_plus_test0.TestAPI<{
|
|
23
|
+
server: SetupServer;
|
|
24
|
+
_cleanup: void;
|
|
25
|
+
db: Database;
|
|
26
|
+
seedFunction: (db: Database) => Promise<void> | void;
|
|
27
|
+
}>;
|
|
28
|
+
declare function initDb(seed: (db: Database) => Promise<void> | void, config?: DbConfig): void;
|
|
29
|
+
interface SeedDatabaseOptions {
|
|
30
|
+
schemaPath: string;
|
|
31
|
+
migrationsFolder: string;
|
|
32
|
+
seedFunction?: (db: Database) => Promise<void> | void;
|
|
33
|
+
extensions?: string[];
|
|
11
34
|
}
|
|
12
|
-
declare
|
|
13
|
-
|
|
35
|
+
declare function seedDatabase(db: Database, {
|
|
36
|
+
schemaPath,
|
|
37
|
+
migrationsFolder,
|
|
38
|
+
seedFunction,
|
|
39
|
+
extensions
|
|
40
|
+
}: SeedDatabaseOptions): Promise<void>;
|
|
14
41
|
//#endregion
|
|
15
|
-
export { DbFixture, afterEach, beforeEach, describe, expect, initDb, test, vi };
|
|
42
|
+
export { Database, DbConfig, DbFixture, SeedDatabaseOptions, afterEach, beforeEach, describe, expect, initDb, seedDatabase, test, vi };
|
|
16
43
|
//# sourceMappingURL=db.d.mts.map
|
package/dist/test/db.mjs
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { seedDatabase } from "./database.mjs";
|
|
2
|
-
import { t as findHandlerPath } from "../internal-Dshd0hdM.mjs";
|
|
3
1
|
import { resolve } from "node:path";
|
|
4
|
-
import { afterEach, beforeEach, describe, expect, test as test$1, vi } from "
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, test as test$1, vi } from "vite-plus/test";
|
|
5
3
|
import { setupServer } from "msw/node";
|
|
6
|
-
//#region test/db.ts
|
|
4
|
+
//#region src/test/db.ts
|
|
7
5
|
const DEFAULT_SCHEMA_PATH = "src/db/tables.ts";
|
|
8
6
|
const DEFAULT_MIGRATIONS_PATH = "src/db/migrations";
|
|
9
7
|
const DEFAULT_IMAGE = "postgres:17";
|
|
8
|
+
const DEFAULT_EXTENSIONS = ["pg_trgm"];
|
|
9
|
+
let dbConfig = {};
|
|
10
10
|
let mswServer;
|
|
11
|
+
let seedFunction = async () => {};
|
|
11
12
|
async function ensureMswServer() {
|
|
12
13
|
if (!mswServer) {
|
|
13
|
-
const { default: handlers } = await import(
|
|
14
|
+
const { default: handlers } = await import("@test/handlers");
|
|
14
15
|
mswServer = setupServer(...handlers);
|
|
15
16
|
}
|
|
16
17
|
return mswServer;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
const test = test$1.extend({
|
|
19
20
|
server: [async ({}, use) => {
|
|
20
21
|
const server = await ensureMswServer();
|
|
21
22
|
server.listen({ onUnhandledRequest: "bypass" });
|
|
@@ -29,16 +30,17 @@ let extended = test$1.extend({
|
|
|
29
30
|
await use();
|
|
30
31
|
server.resetHandlers();
|
|
31
32
|
}, { auto: true }],
|
|
32
|
-
seedFunction: [async ({}, use) => use(
|
|
33
|
+
seedFunction: [async ({}, use) => use(seedFunction), { scope: "file" }],
|
|
33
34
|
db: [async ({ seedFunction }, use) => {
|
|
34
35
|
const { PostgreSqlContainer } = await import("@testcontainers/postgresql");
|
|
35
36
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
36
37
|
const { Wait } = await import("testcontainers");
|
|
37
38
|
const { Pool } = await import("pg");
|
|
38
|
-
const schemaPath = resolve(process.cwd(), DEFAULT_SCHEMA_PATH);
|
|
39
|
-
const migrationsFolder = resolve(process.cwd(), DEFAULT_MIGRATIONS_PATH);
|
|
40
|
-
const container = await new PostgreSqlContainer(DEFAULT_IMAGE).withWaitStrategy(Wait.forHealthCheck()).start();
|
|
41
|
-
const
|
|
39
|
+
const schemaPath = resolve(process.cwd(), dbConfig.schemaPath ?? DEFAULT_SCHEMA_PATH);
|
|
40
|
+
const migrationsFolder = resolve(process.cwd(), dbConfig.migrationsPath ?? DEFAULT_MIGRATIONS_PATH);
|
|
41
|
+
const container = await new PostgreSqlContainer(dbConfig.postgresImage ?? DEFAULT_IMAGE).withWaitStrategy(Wait.forHealthCheck()).start();
|
|
42
|
+
const client = new Pool({ connectionString: container.getConnectionUri() });
|
|
43
|
+
const db = Object.assign(drizzle({ client }), { $client: client });
|
|
42
44
|
try {
|
|
43
45
|
await seedDatabase(db, {
|
|
44
46
|
schemaPath,
|
|
@@ -52,11 +54,23 @@ let extended = test$1.extend({
|
|
|
52
54
|
}
|
|
53
55
|
}, { scope: "file" }]
|
|
54
56
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
function initDb(seed, config = {}) {
|
|
58
|
+
dbConfig = config;
|
|
59
|
+
seedFunction = seed;
|
|
60
|
+
}
|
|
61
|
+
async function seedDatabase(db, { schemaPath, migrationsFolder, seedFunction, extensions = DEFAULT_EXTENSIONS }) {
|
|
62
|
+
const { migrate } = await import("drizzle-orm/node-postgres/migrator");
|
|
63
|
+
const { reset } = await import("drizzle-seed");
|
|
64
|
+
const schema = await import(
|
|
65
|
+
/* @vite-ignore */
|
|
66
|
+
schemaPath
|
|
67
|
+
);
|
|
68
|
+
for (const ext of extensions) await db.execute(`CREATE EXTENSION IF NOT EXISTS "${ext}"`);
|
|
69
|
+
await migrate(db, { migrationsFolder });
|
|
70
|
+
await reset(db, schema);
|
|
71
|
+
if (seedFunction) await seedFunction(db);
|
|
58
72
|
}
|
|
59
73
|
//#endregion
|
|
60
|
-
export { afterEach, beforeEach, describe, expect, initDb, test, vi };
|
|
74
|
+
export { afterEach, beforeEach, describe, expect, initDb, seedDatabase, test, vi };
|
|
61
75
|
|
|
62
76
|
//# sourceMappingURL=db.mjs.map
|
package/dist/test/db.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.mjs","names":["baseTest"],"sources":["../../test/db.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"db.mjs","names":["baseTest"],"sources":["../../src/test/db.ts"],"sourcesContent":["import { setupServer, type SetupServer } from 'msw/node'\nimport { resolve } from 'node:path'\nimport { test as baseTest } from 'vite-plus/test'\nimport type { NodePgDatabase } from 'drizzle-orm/node-postgres'\nimport type { Pool } from 'pg'\n\nconst DEFAULT_SCHEMA_PATH = 'src/db/tables.ts'\nconst DEFAULT_MIGRATIONS_PATH = 'src/db/migrations'\nconst DEFAULT_IMAGE = 'postgres:17'\nconst DEFAULT_EXTENSIONS = ['pg_trgm']\n\nexport interface DbConfig {\n\tschemaPath?: string\n\tmigrationsPath?: string\n\tpostgresImage?: string\n}\n\nexport type Database = NodePgDatabase & {\n\t$client: Pool\n}\n\nexport interface DbFixture {\n\tserver: SetupServer\n\t_cleanup: void\n\tdb: Database\n\tseedFunction: (db: Database) => Promise<void> | void\n}\n\nlet dbConfig: DbConfig = {}\nlet mswServer: SetupServer | undefined\nlet seedFunction: (db: Database) => Promise<void> | void = async () => {}\n\nasync function ensureMswServer(): Promise<SetupServer> {\n\tif (!mswServer) {\n\t\tconst { default: handlers } = await import('@test/handlers')\n\t\tmswServer = setupServer(...handlers)\n\t}\n\treturn mswServer\n}\n\nexport const test = baseTest.extend<DbFixture>({\n\tserver: [\n\t\tasync ({}, use) => {\n\t\t\tconst server = await ensureMswServer()\n\t\t\tserver.listen({ onUnhandledRequest: 'bypass' })\n\t\t\tawait use(server)\n\t\t\tserver.close()\n\t\t},\n\t\t{ auto: true, scope: 'worker' },\n\t],\n\t_cleanup: [\n\t\tasync ({ server }, use) => {\n\t\t\tawait use()\n\t\t\tserver.resetHandlers()\n\t\t},\n\t\t{ auto: true },\n\t],\n\tseedFunction: [async ({}, use) => use(seedFunction), { scope: 'file' }],\n\tdb: [\n\t\tasync ({ seedFunction }, use) => {\n\t\t\tconst { PostgreSqlContainer } = await import('@testcontainers/postgresql')\n\t\t\tconst { drizzle } = await import('drizzle-orm/node-postgres')\n\t\t\tconst { Wait } = await import('testcontainers')\n\t\t\tconst { Pool } = await import('pg')\n\t\t\tconst schemaPath = resolve(\n\t\t\t\tprocess.cwd(),\n\t\t\t\tdbConfig.schemaPath ?? DEFAULT_SCHEMA_PATH,\n\t\t\t)\n\t\t\tconst migrationsFolder = resolve(\n\t\t\t\tprocess.cwd(),\n\t\t\t\tdbConfig.migrationsPath ?? DEFAULT_MIGRATIONS_PATH,\n\t\t\t)\n\t\t\tconst container = await new PostgreSqlContainer(\n\t\t\t\tdbConfig.postgresImage ?? DEFAULT_IMAGE,\n\t\t\t)\n\t\t\t\t.withWaitStrategy(Wait.forHealthCheck())\n\t\t\t\t.start()\n\t\t\tconst client = new Pool({\n\t\t\t\tconnectionString: container.getConnectionUri(),\n\t\t\t})\n\t\t\tconst db = Object.assign(drizzle({ client }), { $client: client })\n\n\t\t\ttry {\n\t\t\t\tawait seedDatabase(db, { schemaPath, migrationsFolder, seedFunction })\n\t\t\t\tawait use(db)\n\t\t\t} finally {\n\t\t\t\tawait db.$client.end()\n\t\t\t\tawait container.stop()\n\t\t\t}\n\t\t},\n\t\t{ scope: 'file' },\n\t],\n})\n\nexport { afterEach, beforeEach, describe, expect, vi } from 'vite-plus/test'\n\nexport function initDb(\n\tseed: (db: Database) => Promise<void> | void,\n\tconfig: DbConfig = {},\n) {\n\tdbConfig = config\n\tseedFunction = seed\n}\n\nexport interface SeedDatabaseOptions {\n\tschemaPath: string\n\tmigrationsFolder: string\n\tseedFunction?: (db: Database) => Promise<void> | void\n\textensions?: string[]\n}\n\nexport async function seedDatabase(\n\tdb: Database,\n\t{\n\t\tschemaPath,\n\t\tmigrationsFolder,\n\t\tseedFunction,\n\t\textensions = DEFAULT_EXTENSIONS,\n\t}: SeedDatabaseOptions,\n) {\n\tconst { migrate } = await import('drizzle-orm/node-postgres/migrator')\n\tconst { reset } = await import('drizzle-seed')\n\tconst schema = await import(/* @vite-ignore */ schemaPath)\n\n\tfor (const ext of extensions) {\n\t\tawait db.execute(`CREATE EXTENSION IF NOT EXISTS \"${ext}\"`)\n\t}\n\tawait migrate(db, { migrationsFolder })\n\tawait reset(db, schema)\n\tif (seedFunction) await seedFunction(db)\n}\n"],"mappings":";;;;AAMA,MAAM,sBAAsB;AAC5B,MAAM,0BAA0B;AAChC,MAAM,gBAAgB;AACtB,MAAM,qBAAqB,CAAC,UAAU;AAmBtC,IAAI,WAAqB,EAAE;AAC3B,IAAI;AACJ,IAAI,eAAuD,YAAY;AAEvE,eAAe,kBAAwC;CACtD,IAAI,CAAC,WAAW;EACf,MAAM,EAAE,SAAS,aAAa,MAAM,OAAO;EAC3C,YAAY,YAAY,GAAG,SAAS;;CAErC,OAAO;;AAGR,MAAa,OAAOA,OAAS,OAAkB;CAC9C,QAAQ,CACP,OAAO,IAAI,QAAQ;EAClB,MAAM,SAAS,MAAM,iBAAiB;EACtC,OAAO,OAAO,EAAE,oBAAoB,UAAU,CAAC;EAC/C,MAAM,IAAI,OAAO;EACjB,OAAO,OAAO;IAEf;EAAE,MAAM;EAAM,OAAO;EAAU,CAC/B;CACD,UAAU,CACT,OAAO,EAAE,UAAU,QAAQ;EAC1B,MAAM,KAAK;EACX,OAAO,eAAe;IAEvB,EAAE,MAAM,MAAM,CACd;CACD,cAAc,CAAC,OAAO,IAAI,QAAQ,IAAI,aAAa,EAAE,EAAE,OAAO,QAAQ,CAAC;CACvE,IAAI,CACH,OA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1
|
-
import
|
|
1
|
+
import * as _$vite_plus_test0 from "vite-plus/test";
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, vi } from "vite-plus/test";
|
|
2
3
|
import { SetupServer } from "msw/node";
|
|
3
4
|
|
|
4
|
-
//#region test/server.d.ts
|
|
5
|
+
//#region src/test/server.d.ts
|
|
5
6
|
interface MswServerFixture {
|
|
6
7
|
server: SetupServer;
|
|
7
8
|
_cleanup: void;
|
|
8
9
|
}
|
|
9
|
-
declare const test: TestAPI<
|
|
10
|
+
declare const test: _$vite_plus_test0.TestAPI<{
|
|
11
|
+
server: SetupServer;
|
|
12
|
+
_cleanup: void;
|
|
13
|
+
}>;
|
|
10
14
|
//#endregion
|
|
11
15
|
export { MswServerFixture, afterEach, beforeEach, describe, expect, test, vi };
|
|
12
16
|
//# sourceMappingURL=server.d.mts.map
|
package/dist/test/server.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { afterEach, beforeEach, describe, expect, test as test$1, vi } from "vitest";
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test as test$1, vi } from "vite-plus/test";
|
|
3
2
|
import { setupServer } from "msw/node";
|
|
4
|
-
//#region test/server.ts
|
|
3
|
+
//#region src/test/server.ts
|
|
5
4
|
let mswServer;
|
|
6
5
|
async function ensureMswServer() {
|
|
7
6
|
if (!mswServer) {
|
|
8
|
-
const { default: handlers } = await import(
|
|
7
|
+
const { default: handlers } = await import("@test/handlers");
|
|
9
8
|
mswServer = setupServer(...handlers);
|
|
10
9
|
}
|
|
11
10
|
return mswServer;
|
package/dist/test/server.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.mjs","names":["baseTest"],"sources":["../../test/server.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"server.mjs","names":["baseTest"],"sources":["../../src/test/server.ts"],"sourcesContent":["import { setupServer, type SetupServer } from 'msw/node'\nimport { test as baseTest } from 'vite-plus/test'\n\nexport interface MswServerFixture {\n\tserver: SetupServer\n\t_cleanup: void\n}\n\nlet mswServer: SetupServer | undefined\n\nasync function ensureMswServer(): Promise<SetupServer> {\n\tif (!mswServer) {\n\t\tconst { default: handlers } = await import('@test/handlers')\n\t\tmswServer = setupServer(...handlers)\n\t}\n\treturn mswServer\n}\n\nconst extended = baseTest.extend<MswServerFixture>({\n\tserver: [\n\t\tasync ({}, use) => {\n\t\t\tconst server = await ensureMswServer()\n\t\t\tserver.listen({ onUnhandledRequest: 'bypass' })\n\t\t\tawait use(server)\n\t\t\tserver.close()\n\t\t},\n\t\t{ auto: true, scope: 'worker' },\n\t],\n\t_cleanup: [\n\t\tasync ({ server }, use) => {\n\t\t\tawait use()\n\t\t\tserver.resetHandlers()\n\t\t},\n\t\t{ auto: true },\n\t],\n})\n\nexport { afterEach, beforeEach, describe, expect, vi } from 'vite-plus/test'\nexport const test = extended\n"],"mappings":";;;AAQA,IAAI;AAEJ,eAAe,kBAAwC;CACtD,IAAI,CAAC,WAAW;EACf,MAAM,EAAE,SAAS,aAAa,MAAM,OAAO;EAC3C,YAAY,YAAY,GAAG,SAAS;;CAErC,OAAO;;AAuBR,MAAa,OApBIA,OAAS,OAAyB;CAClD,QAAQ,CACP,OAAO,IAAI,QAAQ;EAClB,MAAM,SAAS,MAAM,iBAAiB;EACtC,OAAO,OAAO,EAAE,oBAAoB,UAAU,CAAC;EAC/C,MAAM,IAAI,OAAO;EACjB,OAAO,OAAO;IAEf;EAAE,MAAM;EAAM,OAAO;EAAU,CAC/B;CACD,UAAU,CACT,OAAO,EAAE,UAAU,QAAQ;EAC1B,MAAM,KAAK;EACX,OAAO,eAAe;IAEvB,EAAE,MAAM,MAAM,CACd;CACD,CAGmB"}
|
package/dist/vite.d.mts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { TestProjectConfiguration } from "vite-plus";
|
|
2
|
+
|
|
3
|
+
//#region src/workspace.d.ts
|
|
4
|
+
declare const workspaceConfig: {
|
|
5
|
+
fmt: {
|
|
6
|
+
singleQuote: boolean;
|
|
7
|
+
semi: boolean;
|
|
8
|
+
useTabs: boolean;
|
|
9
|
+
experimentalTailwindcss: {};
|
|
10
|
+
printWidth: number;
|
|
11
|
+
experimentalSortPackageJson: boolean;
|
|
12
|
+
proseWrap: string;
|
|
13
|
+
ignorePatterns: string[];
|
|
14
|
+
overrides: {
|
|
15
|
+
files: string[];
|
|
16
|
+
options: {
|
|
17
|
+
useTabs: boolean;
|
|
18
|
+
};
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
lint: {
|
|
22
|
+
plugins: string[];
|
|
23
|
+
categories: {};
|
|
24
|
+
options: {
|
|
25
|
+
typeAware: boolean;
|
|
26
|
+
typeCheck: boolean;
|
|
27
|
+
};
|
|
28
|
+
rules: {
|
|
29
|
+
'no-empty-pattern': string;
|
|
30
|
+
'no-console': (string | {
|
|
31
|
+
allow: string[];
|
|
32
|
+
})[];
|
|
33
|
+
};
|
|
34
|
+
settings: {
|
|
35
|
+
'jsx-a11y': {
|
|
36
|
+
components: {};
|
|
37
|
+
attributes: {};
|
|
38
|
+
};
|
|
39
|
+
react: {
|
|
40
|
+
formComponents: any[];
|
|
41
|
+
linkComponents: any[];
|
|
42
|
+
};
|
|
43
|
+
jsdoc: {
|
|
44
|
+
ignorePrivate: boolean;
|
|
45
|
+
ignoreInternal: boolean;
|
|
46
|
+
ignoreReplacesDocs: boolean;
|
|
47
|
+
overrideReplacesDocs: boolean;
|
|
48
|
+
augmentsExtendsReplacesDocs: boolean;
|
|
49
|
+
implementsReplacesDocs: boolean;
|
|
50
|
+
exemptDestructuredRootsFromChecks: boolean;
|
|
51
|
+
tagNamePreference: {};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
env: {
|
|
55
|
+
builtin: boolean;
|
|
56
|
+
};
|
|
57
|
+
globals: {};
|
|
58
|
+
ignorePatterns: string[];
|
|
59
|
+
};
|
|
60
|
+
staged: {
|
|
61
|
+
'*.{js,ts,tsx}': string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/vite.d.ts
|
|
66
|
+
interface ProjectOverrides {
|
|
67
|
+
server?: TestProjectConfiguration;
|
|
68
|
+
browser?: TestProjectConfiguration;
|
|
69
|
+
}
|
|
70
|
+
interface AppConfigOptions {
|
|
71
|
+
root?: string;
|
|
72
|
+
projectOverrides?: ProjectOverrides;
|
|
73
|
+
}
|
|
74
|
+
declare const createAppConfig: ({
|
|
75
|
+
root,
|
|
76
|
+
projectOverrides
|
|
77
|
+
}?: AppConfigOptions) => Record<string, unknown>;
|
|
78
|
+
declare const viteConfig: typeof createAppConfig;
|
|
79
|
+
//#endregion
|
|
80
|
+
export { AppConfigOptions, createAppConfig, viteConfig, workspaceConfig };
|
|
81
|
+
//# sourceMappingURL=vite.d.mts.map
|
package/dist/vite.mjs
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { nitro } from "nitro/vite";
|
|
2
|
+
import { devtools } from "@tanstack/devtools-vite";
|
|
3
|
+
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
|
|
4
|
+
import viteReact, { reactCompilerPreset } from "@vitejs/plugin-react";
|
|
5
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
6
|
+
import babel from "@rolldown/plugin-babel";
|
|
7
|
+
import svgr from "vite-plugin-svgr";
|
|
8
|
+
import { resolve } from "node:path";
|
|
9
|
+
import { mergeConfig } from "vite-plus";
|
|
10
|
+
import { playwright } from "vite-plus/test/browser-playwright";
|
|
11
|
+
import { existsSync } from "node:fs";
|
|
12
|
+
//#region src/plugins/virtual-modules.ts
|
|
13
|
+
const HANDLER_LOCATIONS = [
|
|
14
|
+
"__mocks__/handlers.ts",
|
|
15
|
+
"__mocks__/handlers.js",
|
|
16
|
+
"src/mocks/handlers.ts",
|
|
17
|
+
"src/mocks/handlers.js"
|
|
18
|
+
];
|
|
19
|
+
const STYLES_LOCATIONS = [
|
|
20
|
+
"src/styles.css",
|
|
21
|
+
"src/index.css",
|
|
22
|
+
"src/app.css"
|
|
23
|
+
];
|
|
24
|
+
function createVirtualFilePlugin({ locations, moduleId, name, sideEffectOnly = false }) {
|
|
25
|
+
const resolvedModuleId = `\0${moduleId}`;
|
|
26
|
+
let root = process.cwd();
|
|
27
|
+
return {
|
|
28
|
+
name,
|
|
29
|
+
configResolved(config) {
|
|
30
|
+
root = config.root;
|
|
31
|
+
},
|
|
32
|
+
resolveId(id) {
|
|
33
|
+
if (id === moduleId) return resolvedModuleId;
|
|
34
|
+
},
|
|
35
|
+
load(id) {
|
|
36
|
+
if (id !== resolvedModuleId) return void 0;
|
|
37
|
+
for (const location of locations) {
|
|
38
|
+
const fullPath = resolve(root, location);
|
|
39
|
+
if (existsSync(fullPath)) {
|
|
40
|
+
if (sideEffectOnly) return `import ${JSON.stringify(fullPath)}`;
|
|
41
|
+
return `export { default } from ${JSON.stringify(fullPath)}`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`No file found for ${moduleId}. Expected one of:\n${locations.map((location) => ` - ${resolve(root, location)}`).join("\n")}`);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function createMswHandlersPlugin() {
|
|
49
|
+
return createVirtualFilePlugin({
|
|
50
|
+
locations: HANDLER_LOCATIONS,
|
|
51
|
+
moduleId: "@test/handlers",
|
|
52
|
+
name: "aamini-msw-handlers"
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function createStylesPlugin() {
|
|
56
|
+
return createVirtualFilePlugin({
|
|
57
|
+
locations: STYLES_LOCATIONS,
|
|
58
|
+
moduleId: "@test/styles",
|
|
59
|
+
name: "aamini-test-styles",
|
|
60
|
+
sideEffectOnly: true
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const workspaceConfig = {
|
|
64
|
+
fmt: {
|
|
65
|
+
singleQuote: true,
|
|
66
|
+
semi: false,
|
|
67
|
+
useTabs: true,
|
|
68
|
+
experimentalTailwindcss: {},
|
|
69
|
+
printWidth: 80,
|
|
70
|
+
experimentalSortPackageJson: false,
|
|
71
|
+
proseWrap: "always",
|
|
72
|
+
ignorePatterns: [
|
|
73
|
+
"**/.output",
|
|
74
|
+
"**/dist/**",
|
|
75
|
+
"pnpm-lock.yaml",
|
|
76
|
+
"**/routeTree.gen.ts"
|
|
77
|
+
],
|
|
78
|
+
overrides: [{
|
|
79
|
+
files: ["*.{yaml,yml}"],
|
|
80
|
+
options: { useTabs: false }
|
|
81
|
+
}]
|
|
82
|
+
},
|
|
83
|
+
lint: {
|
|
84
|
+
plugins: [
|
|
85
|
+
"eslint",
|
|
86
|
+
"unicorn",
|
|
87
|
+
"typescript",
|
|
88
|
+
"oxc",
|
|
89
|
+
"react",
|
|
90
|
+
"react-perf",
|
|
91
|
+
"import",
|
|
92
|
+
"jsdoc",
|
|
93
|
+
"jsx-a11y",
|
|
94
|
+
"node",
|
|
95
|
+
"promise"
|
|
96
|
+
],
|
|
97
|
+
categories: {},
|
|
98
|
+
options: {
|
|
99
|
+
typeAware: true,
|
|
100
|
+
typeCheck: true
|
|
101
|
+
},
|
|
102
|
+
rules: {
|
|
103
|
+
"no-empty-pattern": "off",
|
|
104
|
+
"no-console": ["error", { allow: ["warn", "error"] }]
|
|
105
|
+
},
|
|
106
|
+
settings: {
|
|
107
|
+
"jsx-a11y": {
|
|
108
|
+
components: {},
|
|
109
|
+
attributes: {}
|
|
110
|
+
},
|
|
111
|
+
react: {
|
|
112
|
+
formComponents: [],
|
|
113
|
+
linkComponents: []
|
|
114
|
+
},
|
|
115
|
+
jsdoc: {
|
|
116
|
+
ignorePrivate: false,
|
|
117
|
+
ignoreInternal: false,
|
|
118
|
+
ignoreReplacesDocs: true,
|
|
119
|
+
overrideReplacesDocs: true,
|
|
120
|
+
augmentsExtendsReplacesDocs: false,
|
|
121
|
+
implementsReplacesDocs: false,
|
|
122
|
+
exemptDestructuredRootsFromChecks: false,
|
|
123
|
+
tagNamePreference: {}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
env: { builtin: true },
|
|
127
|
+
globals: {},
|
|
128
|
+
ignorePatterns: ["**/dist/**"]
|
|
129
|
+
},
|
|
130
|
+
staged: { "*.{js,ts,tsx}": "vp check --fix" }
|
|
131
|
+
};
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/vite.ts
|
|
134
|
+
const stylesSetup = "@aamini/config/setup/styles";
|
|
135
|
+
const createAppConfig = ({ root = process.cwd(), projectOverrides } = {}) => ({
|
|
136
|
+
root,
|
|
137
|
+
resolve: {
|
|
138
|
+
tsconfigPaths: true,
|
|
139
|
+
dedupe: ["react", "react-dom"],
|
|
140
|
+
alias: [
|
|
141
|
+
{
|
|
142
|
+
find: "@/mocks",
|
|
143
|
+
replacement: resolve(root, "__mocks__")
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
find: "@",
|
|
147
|
+
replacement: resolve(root, "src")
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
find: "@tests",
|
|
151
|
+
replacement: resolve(root, "tests")
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
plugins: [
|
|
156
|
+
tanstackStart(),
|
|
157
|
+
...process.env.VITEST === "true" ? [] : [devtools({ injectSource: { enabled: false } }), nitro()],
|
|
158
|
+
tailwindcss(),
|
|
159
|
+
viteReact(),
|
|
160
|
+
babel({ presets: [reactCompilerPreset()] }),
|
|
161
|
+
svgr({
|
|
162
|
+
include: "**/*.svg",
|
|
163
|
+
svgrOptions: { exportType: "default" }
|
|
164
|
+
})
|
|
165
|
+
],
|
|
166
|
+
fmt: workspaceConfig.fmt,
|
|
167
|
+
lint: workspaceConfig.lint,
|
|
168
|
+
staged: workspaceConfig.staged,
|
|
169
|
+
test: {
|
|
170
|
+
passWithNoTests: true,
|
|
171
|
+
projects: [
|
|
172
|
+
{
|
|
173
|
+
extends: true,
|
|
174
|
+
test: {
|
|
175
|
+
name: "unit",
|
|
176
|
+
include: ["src/**/*.test.unit.ts"]
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
mergeConfig({
|
|
180
|
+
extends: true,
|
|
181
|
+
plugins: [createMswHandlersPlugin()],
|
|
182
|
+
test: {
|
|
183
|
+
name: "server",
|
|
184
|
+
include: ["src/**/*.test.ts"],
|
|
185
|
+
testTimeout: 3e4,
|
|
186
|
+
fileParallelism: false
|
|
187
|
+
}
|
|
188
|
+
}, projectOverrides?.server ?? {}),
|
|
189
|
+
mergeConfig({
|
|
190
|
+
extends: true,
|
|
191
|
+
plugins: [createMswHandlersPlugin(), createStylesPlugin()],
|
|
192
|
+
test: {
|
|
193
|
+
name: "browser",
|
|
194
|
+
include: ["src/**/*.test.tsx", "tests/**/*.test.tsx"],
|
|
195
|
+
setupFiles: [stylesSetup],
|
|
196
|
+
browser: {
|
|
197
|
+
instances: [{ browser: "chromium" }],
|
|
198
|
+
provider: playwright(),
|
|
199
|
+
enabled: true,
|
|
200
|
+
headless: true
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}, projectOverrides?.browser ?? {})
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
const viteConfig = createAppConfig;
|
|
208
|
+
//#endregion
|
|
209
|
+
export { createAppConfig, viteConfig, workspaceConfig };
|
|
210
|
+
|
|
211
|
+
//# sourceMappingURL=vite.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.mjs","names":[],"sources":["../src/plugins/virtual-modules.ts","../src/workspace.ts","../src/vite.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport type { Plugin } from 'vite'\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 createVirtualFilePlugin({\n\tlocations,\n\tmoduleId,\n\tname,\n\tsideEffectOnly = false,\n}: {\n\tlocations: string[]\n\tmoduleId: string\n\tname: string\n\tsideEffectOnly?: boolean\n}): Plugin {\n\tconst resolvedModuleId = `\\0${moduleId}`\n\tlet root = process.cwd()\n\n\treturn {\n\t\tname,\n\t\tconfigResolved(config) {\n\t\t\troot = config.root\n\t\t},\n\t\tresolveId(id) {\n\t\t\tif (id === moduleId) return resolvedModuleId\n\t\t\treturn undefined\n\t\t},\n\t\tload(id) {\n\t\t\tif (id !== resolvedModuleId) return undefined\n\n\t\t\tfor (const location of locations) {\n\t\t\t\tconst fullPath = resolve(root, location)\n\t\t\t\tif (existsSync(fullPath)) {\n\t\t\t\t\tif (sideEffectOnly) return `import ${JSON.stringify(fullPath)}`\n\t\t\t\t\treturn `export { default } from ${JSON.stringify(fullPath)}`\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrow new Error(\n\t\t\t\t`No file found for ${moduleId}. Expected one of:\\n${locations\n\t\t\t\t\t.map((location) => ` - ${resolve(root, location)}`)\n\t\t\t\t\t.join('\\n')}`,\n\t\t\t)\n\t\t},\n\t}\n}\n\nexport function createMswHandlersPlugin() {\n\treturn createVirtualFilePlugin({\n\t\tlocations: HANDLER_LOCATIONS,\n\t\tmoduleId: '@test/handlers',\n\t\tname: 'aamini-msw-handlers',\n\t})\n}\n\nexport function createStylesPlugin() {\n\treturn createVirtualFilePlugin({\n\t\tlocations: STYLES_LOCATIONS,\n\t\tmoduleId: '@test/styles',\n\t\tname: 'aamini-test-styles',\n\t\tsideEffectOnly: true,\n\t})\n}\n","const fmt = {\n\tsingleQuote: true,\n\tsemi: false,\n\tuseTabs: true,\n\texperimentalTailwindcss: {},\n\tprintWidth: 80,\n\texperimentalSortPackageJson: false,\n\tproseWrap: 'always',\n\tignorePatterns: [\n\t\t'**/.output',\n\t\t'**/dist/**',\n\t\t'pnpm-lock.yaml',\n\t\t'**/routeTree.gen.ts',\n\t],\n\toverrides: [\n\t\t{\n\t\t\tfiles: ['*.{yaml,yml}'],\n\t\t\toptions: { useTabs: false },\n\t\t},\n\t],\n}\n\nconst lint = {\n\tplugins: [\n\t\t'eslint',\n\t\t'unicorn',\n\t\t'typescript',\n\t\t'oxc',\n\t\t'react',\n\t\t'react-perf',\n\t\t'import',\n\t\t'jsdoc',\n\t\t'jsx-a11y',\n\t\t'node',\n\t\t'promise',\n\t],\n\tcategories: {},\n\toptions: {\n\t\ttypeAware: true,\n\t\ttypeCheck: true,\n\t},\n\trules: {\n\t\t'no-empty-pattern': 'off',\n\t\t'no-console': ['error', { allow: ['warn', 'error'] }],\n\t},\n\tsettings: {\n\t\t'jsx-a11y': { components: {}, attributes: {} },\n\t\treact: { formComponents: [], linkComponents: [] },\n\t\tjsdoc: {\n\t\t\tignorePrivate: false,\n\t\t\tignoreInternal: false,\n\t\t\tignoreReplacesDocs: true,\n\t\t\toverrideReplacesDocs: true,\n\t\t\taugmentsExtendsReplacesDocs: false,\n\t\t\timplementsReplacesDocs: false,\n\t\t\texemptDestructuredRootsFromChecks: false,\n\t\t\ttagNamePreference: {},\n\t\t},\n\t},\n\tenv: { builtin: true },\n\tglobals: {},\n\tignorePatterns: ['**/dist/**'],\n}\n\nexport const workspaceConfig = {\n\tfmt,\n\tlint,\n\tstaged: {\n\t\t'*.{js,ts,tsx}': 'vp check --fix',\n\t},\n}\n","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 { resolve } from 'node:path'\nimport { mergeConfig, type TestProjectConfiguration } from 'vite-plus'\nimport { playwright } from 'vite-plus/test/browser-playwright'\nimport {\n\tcreateMswHandlersPlugin,\n\tcreateStylesPlugin,\n} from './plugins/virtual-modules.ts'\nimport { workspaceConfig } from './workspace.ts'\n\nconst stylesSetup = '@aamini/config/setup/styles'\n\ninterface ProjectOverrides {\n\tserver?: TestProjectConfiguration\n\tbrowser?: TestProjectConfiguration\n}\n\nexport interface AppConfigOptions {\n\troot?: string\n\tprojectOverrides?: ProjectOverrides\n}\n\nexport const createAppConfig = ({\n\troot = process.cwd(),\n\tprojectOverrides,\n}: AppConfigOptions = {}): Record<string, unknown> => ({\n\troot,\n\tresolve: {\n\t\ttsconfigPaths: true,\n\t\tdedupe: ['react', 'react-dom'],\n\t\talias: [\n\t\t\t{ find: '@/mocks', replacement: resolve(root, '__mocks__') },\n\t\t\t{ find: '@', replacement: resolve(root, 'src') },\n\t\t\t{ find: '@tests', replacement: resolve(root, 'tests') },\n\t\t],\n\t},\n\tplugins: [\n\t\ttanstackStart(),\n\t\t...(process.env.VITEST === 'true'\n\t\t\t? []\n\t\t\t: [devtools({ injectSource: { enabled: false } }), nitro()]),\n\t\ttailwindcss(),\n\t\tviteReact(),\n\t\tbabel({ presets: [reactCompilerPreset()] }),\n\t\tsvgr({\n\t\t\tinclude: '**/*.svg',\n\t\t\tsvgrOptions: { exportType: 'default' },\n\t\t}),\n\t],\n\tfmt: workspaceConfig.fmt,\n\tlint: workspaceConfig.lint,\n\tstaged: workspaceConfig.staged,\n\ttest: {\n\t\tpassWithNoTests: true,\n\t\tprojects: [\n\t\t\t{\n\t\t\t\textends: true,\n\t\t\t\ttest: {\n\t\t\t\t\tname: 'unit',\n\t\t\t\t\tinclude: ['src/**/*.test.unit.ts'],\n\t\t\t\t},\n\t\t\t},\n\t\t\tmergeConfig(\n\t\t\t\t{\n\t\t\t\t\textends: true,\n\t\t\t\t\tplugins: [createMswHandlersPlugin()],\n\t\t\t\t\ttest: {\n\t\t\t\t\t\tname: 'server',\n\t\t\t\t\t\tinclude: ['src/**/*.test.ts'],\n\t\t\t\t\t\ttestTimeout: 30_000,\n\t\t\t\t\t\tfileParallelism: false,\n\t\t\t\t\t},\n\t\t\t\t} satisfies TestProjectConfiguration as Record<string, unknown>,\n\t\t\t\t(projectOverrides?.server ?? {}) as Record<string, unknown>,\n\t\t\t),\n\t\t\tmergeConfig(\n\t\t\t\t{\n\t\t\t\t\textends: true,\n\t\t\t\t\tplugins: [createMswHandlersPlugin(), createStylesPlugin()],\n\t\t\t\t\ttest: {\n\t\t\t\t\t\tname: 'browser',\n\t\t\t\t\t\tinclude: ['src/**/*.test.tsx', 'tests/**/*.test.tsx'],\n\t\t\t\t\t\tsetupFiles: [stylesSetup],\n\t\t\t\t\t\tbrowser: {\n\t\t\t\t\t\t\tinstances: [{ browser: 'chromium' }],\n\t\t\t\t\t\t\tprovider: playwright(),\n\t\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\t\theadless: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t} satisfies TestProjectConfiguration as Record<string, unknown>,\n\t\t\t\t(projectOverrides?.browser ?? {}) as Record<string, unknown>,\n\t\t\t),\n\t\t],\n\t},\n})\n\nexport const viteConfig: typeof createAppConfig = createAppConfig\nexport { workspaceConfig } from './workspace.ts'\n"],"mappings":";;;;;;;;;;;;AAIA,MAAM,oBAAoB;CACzB;CACA;CACA;CACA;CACA;AAED,MAAM,mBAAmB;CAAC;CAAkB;CAAiB;CAAc;AAE3E,SAAS,wBAAwB,EAChC,WACA,UACA,MACA,iBAAiB,SAMP;CACV,MAAM,mBAAmB,KAAK;CAC9B,IAAI,OAAO,QAAQ,KAAK;CAExB,OAAO;EACN;EACA,eAAe,QAAQ;GACtB,OAAO,OAAO;;EAEf,UAAU,IAAI;GACb,IAAI,OAAO,UAAU,OAAO;;EAG7B,KAAK,IAAI;GACR,IAAI,OAAO,kBAAkB,OAAO,KAAA;GAEpC,KAAK,MAAM,YAAY,WAAW;IACjC,MAAM,WAAW,QAAQ,MAAM,SAAS;IACxC,IAAI,WAAW,SAAS,EAAE;KACzB,IAAI,gBAAgB,OAAO,UAAU,KAAK,UAAU,SAAS;KAC7D,OAAO,2BAA2B,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