@aamini/config 0.0.20 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +111 -20
  2. package/dist/anti-slop/index.d.mts +6 -0
  3. package/dist/anti-slop/index.mjs +2414 -0
  4. package/dist/anti-slop/index.mjs.map +1 -0
  5. package/dist/merge-BEomHgbw.d.mts +21 -0
  6. package/dist/merge-DThKwm_6.mjs +193 -0
  7. package/dist/merge-DThKwm_6.mjs.map +1 -0
  8. package/dist/playwright.d.mts +8 -3
  9. package/dist/playwright.mjs +20 -11
  10. package/dist/playwright.mjs.map +1 -1
  11. package/dist/root-U5B4x0aj.mjs +15 -0
  12. package/dist/root-U5B4x0aj.mjs.map +1 -0
  13. package/dist/tanstack/index.d.mts +45 -0
  14. package/dist/tanstack/index.mjs +189 -0
  15. package/dist/tanstack/index.mjs.map +1 -0
  16. package/dist/vite-plus/index.d.mts +101 -0
  17. package/dist/vite-plus/index.mjs +2 -0
  18. package/dist/vitest/browser.d.mts +22 -0
  19. package/dist/vitest/browser.mjs +84 -0
  20. package/dist/vitest/browser.mjs.map +1 -0
  21. package/dist/vitest/db.d.mts +28 -0
  22. package/dist/vitest/db.mjs +42 -0
  23. package/dist/vitest/db.mjs.map +1 -0
  24. package/dist/vitest/index.d.mts +29 -0
  25. package/dist/vitest/index.mjs +2 -0
  26. package/dist/vitest/react.d.mts +34 -0
  27. package/dist/vitest/react.mjs +43 -0
  28. package/dist/vitest/react.mjs.map +1 -0
  29. package/dist/vitest/server.d.mts +13 -0
  30. package/dist/vitest/server.mjs +28 -0
  31. package/dist/vitest/server.mjs.map +1 -0
  32. package/dist/vitest-CXdvqyRH.mjs +169 -0
  33. package/dist/vitest-CXdvqyRH.mjs.map +1 -0
  34. package/package.json +169 -95
  35. package/tsconfig/astro.json +9 -0
  36. package/tsconfig/{tsconfig.strict.json → base.json} +8 -0
  37. package/tsconfig/react.json +9 -0
  38. package/dist/setup/styles.d.mts +0 -1
  39. package/dist/setup/styles.mjs +0 -2
  40. package/dist/test/browser.d.mts +0 -17
  41. package/dist/test/browser.mjs +0 -35
  42. package/dist/test/browser.mjs.map +0 -1
  43. package/dist/test/db.d.mts +0 -41
  44. package/dist/test/db.mjs +0 -93
  45. package/dist/test/db.mjs.map +0 -1
  46. package/dist/test/server.d.mts +0 -16
  47. package/dist/test/server.mjs +0 -30
  48. package/dist/test/server.mjs.map +0 -1
  49. package/dist/test/visual-page.d.mts +0 -30
  50. package/dist/test/visual-page.mjs +0 -40
  51. package/dist/test/visual-page.mjs.map +0 -1
  52. package/dist/vite.d.mts +0 -73
  53. package/dist/vite.mjs +0 -211
  54. package/dist/vite.mjs.map +0 -1
  55. package/tsconfig/tsconfig.lib.json +0 -19
  56. package/tsconfig/tsconfig.tanstack.json +0 -17
package/README.md CHANGED
@@ -1,32 +1,123 @@
1
1
  # @aamini/config
2
2
 
3
- Shared configuration and test fixtures for aamini apps.
3
+ Shared Vite+ config for aria-amini apps: framework plugins, format, lint, and
4
+ TypeScript.
4
5
 
5
- ## Features
6
+ ```bash
7
+ pnpm add -D @aamini/config vite-plus oxlint-plugin-eslint
8
+ ```
9
+
10
+ ## Entry points
11
+
12
+ | Subpath | Exports |
13
+ | ---------------------- | ------------------------------------------------------ |
14
+ | `/tanstack` | `defineToolkit()`: the complete TanStack Start config |
15
+ | `/vite-plus` | `fmt`, `lint(framework)`, `mergeToolkitConfig()` |
16
+ | `/vitest` | `unitProject()`, `serverProject()`, `browserProject()` |
17
+ | `/vitest/browser` | `expectScreenshot()`, `waitForPageIdle()` |
18
+ | `/vitest/react` | `renderPage()` |
19
+ | `/vitest/server` | `createServerTest()`: MSW server fixture |
20
+ | `/vitest/db` | `createDbTest()`: Postgres testcontainer and Drizzle |
21
+ | `/playwright` | `playwrightConfig()` |
22
+ | `/anti-slop` | Oxlint JS plugin. `lint()` registers it. |
23
+ | `/tsconfig/base.json` | Strict compiler options |
24
+ | `/tsconfig/react.json` | Base plus React JSX, DOM, and Vite client types |
25
+ | `/tsconfig/astro.json` | Base plus Astro client types |
26
+
27
+ ## TanStack Start
28
+
29
+ ```ts
30
+ import { defineToolkit } from '@aamini/config/tanstack'
31
+
32
+ export default defineToolkit({
33
+ root: import.meta.dirname,
34
+ plugins: { devtools: false, nitro: { preset: 'node-server' } },
35
+ config: { server: { port: 4000 } },
36
+ })
37
+ ```
38
+
39
+ The toolkit owns the framework plugins and their order: `tanstackStart`,
40
+ `devtools`, `nitro`, `tailwindcss`, `react`, `reactCompiler`, and `varlock`.
41
+ `devtools` and `nitro` do not run under Vitest. Set a key to `false` to remove
42
+ that plugin. Set an object to merge options over the toolkit options. App
43
+ plugins go in `config.plugins` and run after the toolkit plugins.
44
+
45
+ The app installs each plugin package that it uses. If an enabled plugin's
46
+ package is missing, `defineToolkit()` throws an error with the `pnpm add -D`
47
+ command. Set `shadcn: false` to remove the `@shadcn/lint` rules.
48
+
49
+ ### Tests
50
+
51
+ `defineToolkit()` adds three Vitest projects: `unit`, `server`, and `browser`.
52
+ Set `tests.<project>` to `false` to remove a project. Set an object to merge
53
+ `test` options over the toolkit options. Arrays replace the toolkit values.
54
+
55
+ ```ts
56
+ export default defineToolkit({
57
+ root: import.meta.dirname,
58
+ tests: {
59
+ server: { include: ['src/**/*.test.ts'] },
60
+ browser: { setupFiles: ['./src/app.css'] },
61
+ },
62
+ })
63
+ ```
6
64
 
7
- - **`createAppConfig(root)`** — full Vite+ app config with React, Tailwind,
8
- SVGR, TanStack Start, Nitro
9
- - **`baseConfigFor(import.meta.url)`** — one-liner for app `vite.config.ts`
10
- - **Test fixtures** (`test/server`, `test/browser`, `test/db`) — Vitest fixtures
11
- with auto-detected MSW handlers
12
- - **`test/db`** — PostgreSQL testcontainer + drizzle + MSW integration fixture
13
- - **Playwright config** — shared Playwright configuration
14
- - **`msw.ts`** — re-exports to ensure singleton MSW instances
65
+ The `browser` project runs Chromium in two instances: `desktop` (1280×720) and
66
+ `mobile` (375×812). Visual tests compare at zero tolerance. A capture stops at
67
+ the viewport, and `fullHeight` grows the viewport to the full target. Mobile
68
+ baselines get a `-mobile` suffix.
15
69
 
16
- ## Usage
70
+ ```tsx
71
+ import { renderPage } from '@aamini/config/vitest/react'
72
+
73
+ test('home', async () => {
74
+ const page = await renderPage(HomePage, { path: '/', wrapper: AppProviders })
75
+
76
+ await page.expectScreenshot('home')
77
+ await page.expectScreenshot('home-full', { fullHeight: true })
78
+ })
79
+ ```
80
+
81
+ Playwright runs smoke tests only, against any `BASE_URL`:
17
82
 
18
83
  ```ts
19
- // vite.config.ts
20
- import { baseConfigFor } from '@aamini/config'
21
- export default baseConfigFor(import.meta.url)
84
+ import { playwrightConfig } from '@aamini/config/playwright'
85
+
86
+ export default playwrightConfig({ testDir: './e2e' })
22
87
  ```
23
88
 
89
+ ## Building blocks
90
+
24
91
  ```ts
25
- // app.test.ts
26
- import { test } from '@aamini/config/test/server'
27
- test('handles API', async ({ server }) => { ... })
92
+ import { fmt, lint, mergeToolkitConfig } from '@aamini/config/vite-plus'
93
+ import { defineConfig } from 'vite-plus'
94
+
95
+ export default defineConfig(
96
+ mergeToolkitConfig(
97
+ { fmt, lint: lint('react') },
98
+ {
99
+ fmt: {
100
+ ignorePatterns: (preset) => [...preset, 'src/generated/**'],
101
+ },
102
+ lint: { rules: { 'no-console': 'off' } },
103
+ },
104
+ ),
105
+ )
106
+ ```
107
+
108
+ ```json
109
+ {
110
+ "extends": "@aamini/config/tsconfig/react.json",
111
+ "include": ["**/*.ts", "**/*.tsx"]
112
+ }
28
113
  ```
29
114
 
30
- Handler files are auto-discovered from the consuming app's working directory:
31
- `tests/__mocks__/http.ts` → `tests/__mocks__/http.js` → `__mocks__/handlers.ts`
32
- → `__mocks__/handlers.js` → `src/mocks/handlers.ts` → `src/mocks/handlers.js`
115
+ ## Merge rules
116
+
117
+ `mergeToolkitConfig(preset, config)` merges the app config over the preset.
118
+
119
+ - A function value replaces the preset value at the same path. It receives the
120
+ preset value. This applies only where the preset sets a non-function value.
121
+ - A lint rule entry replaces the preset entry.
122
+ - Other values go to `mergeConfig` from Vite+. Objects merge deep, arrays
123
+ append, and scalars replace.
@@ -0,0 +1,6 @@
1
+ //#region src/anti-slop/index.d.ts
2
+ /** Generic Oxlint rules that reject low-evidence and low-signal implementation patterns. */
3
+ declare const antiSlopPlugin: import("vite-plus/lint/plugins").Plugin;
4
+ //#endregion
5
+ export { antiSlopPlugin as default };
6
+ //# sourceMappingURL=index.d.mts.map