create-raredays-app 0.1.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 (158) hide show
  1. package/README.md +89 -0
  2. package/bin/index.js +1024 -0
  3. package/package.json +43 -0
  4. package/scaffold-fragments/billing/files/app/api/billing/webhook/route.ts +5 -0
  5. package/scaffold-fragments/billing/module.json +31 -0
  6. package/scaffold-fragments/billing/runtime/config.ts +8 -0
  7. package/scaffold-fragments/billing/runtime/exports.ts +6 -0
  8. package/scaffold-fragments/billing/runtime/imports.ts +6 -0
  9. package/scaffold-fragments/billing/runtime/ports.ts +3 -0
  10. package/scaffold-fragments/cms/module.json +29 -0
  11. package/scaffold-fragments/cms/runtime/config.ts +4 -0
  12. package/scaffold-fragments/cms/runtime/exports.ts +1 -0
  13. package/scaffold-fragments/cms/runtime/imports.ts +1 -0
  14. package/scaffold-fragments/email/module.json +30 -0
  15. package/scaffold-fragments/email/runtime/config.ts +1 -0
  16. package/scaffold-fragments/email/runtime/imports.ts +1 -0
  17. package/scaffold-fragments/email/runtime/ports.ts +1 -0
  18. package/scaffold-fragments/feature-flags/files/app/lib/flags.ts +48 -0
  19. package/scaffold-fragments/feature-flags/module.json +66 -0
  20. package/scaffold-fragments/i18n/files/messages/en-US.json +15 -0
  21. package/scaffold-fragments/i18n/module.json +9 -0
  22. package/scaffold-fragments/i18n/runtime/config.ts +7 -0
  23. package/scaffold-fragments/i18n/runtime/exports.ts +1 -0
  24. package/scaffold-fragments/i18n/runtime/imports.ts +2 -0
  25. package/scaffold-fragments/i18n/runtime/ports.ts +1 -0
  26. package/scaffold-fragments/identity/module.json +30 -0
  27. package/scaffold-fragments/identity/vendors/better-auth/files/app/api/auth/[...all]/route.ts +15 -0
  28. package/scaffold-fragments/identity/vendors/better-auth/files/app/lib/auth.ts +20 -0
  29. package/scaffold-fragments/jobs/module.json +12 -0
  30. package/scaffold-fragments/jobs/runtime/config.ts +4 -0
  31. package/scaffold-fragments/jobs/runtime/imports.ts +1 -0
  32. package/scaffold-fragments/jobs/runtime/ports.ts +1 -0
  33. package/scaffold-fragments/notifications/module.json +12 -0
  34. package/scaffold-fragments/notifications/runtime/config.ts +8 -0
  35. package/scaffold-fragments/notifications/runtime/imports.ts +5 -0
  36. package/scaffold-fragments/notifications/runtime/ports.ts +1 -0
  37. package/scaffold-fragments/organizations/module.json +12 -0
  38. package/scaffold-fragments/telemetry/module.json +43 -0
  39. package/scaffold-fragments/telemetry/runtime/config.ts +7 -0
  40. package/scaffold-fragments/telemetry/runtime/imports.ts +7 -0
  41. package/scaffold-fragments/telemetry/runtime/ports.ts +1 -0
  42. package/skillex/private/contribute.md +193 -0
  43. package/skillex/public/consumer.md +157 -0
  44. package/templates/client/.storybook/main.ts +77 -0
  45. package/templates/client/.storybook/preview.ts +12 -0
  46. package/templates/client/CLAUDE.md +50 -0
  47. package/templates/client/_claude/settings.json +107 -0
  48. package/templates/client/_github/PULL_REQUEST_TEMPLATE.md +19 -0
  49. package/templates/client/_github/dependabot.yml +48 -0
  50. package/templates/client/_github/workflows/ci.yml +104 -0
  51. package/templates/client/_gitignore +15 -0
  52. package/templates/client/_npmrc +1 -0
  53. package/templates/client/app/(app)/layout.tsx +49 -0
  54. package/templates/client/app/(marketing)/layout.tsx +21 -0
  55. package/templates/client/app/(marketing)/page.tsx +34 -0
  56. package/templates/client/app/api/backend/[...path]/route.ts +37 -0
  57. package/templates/client/app/api/dev/login/route.ts +14 -0
  58. package/templates/client/app/api/dev/logout/route.ts +18 -0
  59. package/templates/client/app/globals.css +22 -0
  60. package/templates/client/app/home-auth-controls.tsx +28 -0
  61. package/templates/client/app/layout.tsx +38 -0
  62. package/templates/client/app/lib/backend-client.ts +55 -0
  63. package/templates/client/app/lib/runtime.test.ts +38 -0
  64. package/templates/client/app/lib/runtime.ts +54 -0
  65. package/templates/client/app/protected/page.tsx +31 -0
  66. package/templates/client/app/theme.override.css +9 -0
  67. package/templates/client/instrumentation.ts +10 -0
  68. package/templates/client/mocks/browser.tsx +28 -0
  69. package/templates/client/mocks/handlers.ts +20 -0
  70. package/templates/client/mocks/node.ts +7 -0
  71. package/templates/client/next.config.ts +8 -0
  72. package/templates/client/oxfmt.config.ts +8 -0
  73. package/templates/client/oxlint.config.ts +8 -0
  74. package/templates/client/package.json +61 -0
  75. package/templates/client/postcss.config.mjs +1 -0
  76. package/templates/client/public/mockServiceWorker.js +349 -0
  77. package/templates/client/scripts/build-theme.mjs +18 -0
  78. package/templates/client/site.spec.ts +58 -0
  79. package/templates/client/skillex.json +12 -0
  80. package/templates/client/skills/repo.md +56 -0
  81. package/templates/client/stylelint.config.mjs +4 -0
  82. package/templates/client/tsconfig.json +11 -0
  83. package/templates/client/vitest.config.ts +27 -0
  84. package/templates/client/vitest.setup.ts +18 -0
  85. package/templates/full-stack/.storybook/main.ts +77 -0
  86. package/templates/full-stack/.storybook/preview.ts +12 -0
  87. package/templates/full-stack/CLAUDE.md +50 -0
  88. package/templates/full-stack/_claude/settings.json +107 -0
  89. package/templates/full-stack/_github/PULL_REQUEST_TEMPLATE.md +19 -0
  90. package/templates/full-stack/_github/dependabot.yml +57 -0
  91. package/templates/full-stack/_github/workflows/ci.yml +109 -0
  92. package/templates/full-stack/_github/workflows/db-check.yml +36 -0
  93. package/templates/full-stack/_github/workflows/db-migrate.yml +39 -0
  94. package/templates/full-stack/_gitignore +15 -0
  95. package/templates/full-stack/_npmrc +1 -0
  96. package/templates/full-stack/app/(app)/layout.tsx +53 -0
  97. package/templates/full-stack/app/(marketing)/layout.tsx +21 -0
  98. package/templates/full-stack/app/(marketing)/page.tsx +38 -0
  99. package/templates/full-stack/app/api/dev/login/route.ts +14 -0
  100. package/templates/full-stack/app/api/dev/logout/route.ts +18 -0
  101. package/templates/full-stack/app/api/widgets/route.ts +10 -0
  102. package/templates/full-stack/app/demo/widgets/page.tsx +86 -0
  103. package/templates/full-stack/app/globals.css +22 -0
  104. package/templates/full-stack/app/home-auth-controls.tsx +28 -0
  105. package/templates/full-stack/app/layout.tsx +38 -0
  106. package/templates/full-stack/app/lib/runtime.test.ts +38 -0
  107. package/templates/full-stack/app/lib/runtime.ts +54 -0
  108. package/templates/full-stack/app/protected/page.tsx +31 -0
  109. package/templates/full-stack/app/theme.override.css +9 -0
  110. package/templates/full-stack/db/check.ts +46 -0
  111. package/templates/full-stack/db/index.ts +109 -0
  112. package/templates/full-stack/db/migrate.ts +66 -0
  113. package/templates/full-stack/db/migrations/.gitkeep +0 -0
  114. package/templates/full-stack/db/schema.ts +20 -0
  115. package/templates/full-stack/drizzle.config.ts +16 -0
  116. package/templates/full-stack/instrumentation.ts +10 -0
  117. package/templates/full-stack/mocks/browser.tsx +28 -0
  118. package/templates/full-stack/mocks/handlers.ts +34 -0
  119. package/templates/full-stack/mocks/node.ts +7 -0
  120. package/templates/full-stack/next.config.ts +8 -0
  121. package/templates/full-stack/oxfmt.config.ts +8 -0
  122. package/templates/full-stack/oxlint.config.ts +8 -0
  123. package/templates/full-stack/package.json +72 -0
  124. package/templates/full-stack/postcss.config.mjs +1 -0
  125. package/templates/full-stack/public/mockServiceWorker.js +349 -0
  126. package/templates/full-stack/scripts/build-theme.mjs +18 -0
  127. package/templates/full-stack/site.spec.ts +58 -0
  128. package/templates/full-stack/skillex.json +12 -0
  129. package/templates/full-stack/skills/repo.md +56 -0
  130. package/templates/full-stack/stylelint.config.mjs +4 -0
  131. package/templates/full-stack/tsconfig.json +11 -0
  132. package/templates/full-stack/vitest.config.ts +42 -0
  133. package/templates/full-stack/vitest.setup.ts +18 -0
  134. package/templates/static/.storybook/main.ts +77 -0
  135. package/templates/static/.storybook/preview.ts +12 -0
  136. package/templates/static/CLAUDE.md +50 -0
  137. package/templates/static/_claude/settings.json +107 -0
  138. package/templates/static/_github/PULL_REQUEST_TEMPLATE.md +18 -0
  139. package/templates/static/_github/dependabot.yml +43 -0
  140. package/templates/static/_github/workflows/ci.yml +91 -0
  141. package/templates/static/_gitignore +15 -0
  142. package/templates/static/_npmrc +1 -0
  143. package/templates/static/app/(marketing)/layout.tsx +21 -0
  144. package/templates/static/app/(marketing)/page.tsx +17 -0
  145. package/templates/static/app/globals.css +22 -0
  146. package/templates/static/app/layout.tsx +24 -0
  147. package/templates/static/app/theme.override.css +9 -0
  148. package/templates/static/next.config.ts +19 -0
  149. package/templates/static/oxfmt.config.ts +8 -0
  150. package/templates/static/oxlint.config.ts +8 -0
  151. package/templates/static/package.json +53 -0
  152. package/templates/static/postcss.config.mjs +1 -0
  153. package/templates/static/scripts/build-theme.mjs +18 -0
  154. package/templates/static/site.spec.ts +58 -0
  155. package/templates/static/skillex.json +12 -0
  156. package/templates/static/skills/repo.md +56 -0
  157. package/templates/static/stylelint.config.mjs +4 -0
  158. package/templates/static/tsconfig.json +11 -0
@@ -0,0 +1,7 @@
1
+ // Node-side mock server. Activated by `instrumentation.ts` when
2
+ // `MOCKS=on`, and by `vitest.setup.ts` during tests.
3
+
4
+ import { setupMockServer } from "@raredays/mocks/node";
5
+ import { handlers } from "./handlers";
6
+
7
+ export const mockServer = setupMockServer(handlers);
@@ -0,0 +1,8 @@
1
+ import { withRaredays } from "@raredays/core";
2
+ import type { NextConfig } from "next";
3
+
4
+ const config: NextConfig = withRaredays({
5
+ // Project-specific Next.js config goes here.
6
+ });
7
+
8
+ export default config;
@@ -0,0 +1,8 @@
1
+ import { defineConfig, mergeConfig, base } from "@raredays/lint/oxfmt";
2
+
3
+ // Explicit return-type annotation avoids TS2742 ("inferred type cannot be
4
+ // named without a reference to ..."). `defineConfig` is re-exported from the
5
+ // upstream `oxfmt` package, so the inferred default-export type would
6
+ // otherwise reference a non-portable path.
7
+ const config: ReturnType<typeof defineConfig> = defineConfig(mergeConfig(base));
8
+ export default config;
@@ -0,0 +1,8 @@
1
+ import { defineConfig, mergeConfig, base } from "@raredays/lint/oxlint";
2
+
3
+ // Explicit return-type annotation avoids TS2742 ("inferred type cannot be
4
+ // named without a reference to ..."). `defineConfig` is re-exported from the
5
+ // upstream `oxlint` package, so the inferred default-export type would
6
+ // otherwise reference a non-portable path.
7
+ const config: ReturnType<typeof defineConfig> = defineConfig(mergeConfig(base));
8
+ export default config;
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "raredays-app",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "postinstall": "skillex refresh -q || true",
8
+ "dev": "pnpm theme:build && next dev -p ${PORT:-3000}",
9
+ "dev:mocks": "MOCKS=on NEXT_PUBLIC_MOCKS=on pnpm dev",
10
+ "build": "pnpm theme:build && next build",
11
+ "start": "next start -p ${PORT:-3000}",
12
+ "theme:build": "node ./scripts/build-theme.mjs",
13
+ "test": "vitest run",
14
+ "test:watch": "vitest",
15
+ "storybook": "storybook dev -p 6006",
16
+ "storybook:build": "storybook build -o storybook-static",
17
+ "db:generate": "drizzle-kit generate",
18
+ "db:migrate": "node db/migrate.ts",
19
+ "db:check": "node db/check.ts",
20
+ "db:push": "drizzle-kit push",
21
+ "db:studio": "drizzle-kit studio",
22
+ "db:drop": "drizzle-kit drop",
23
+ "lint": "raredays lint",
24
+ "lint:fix": "raredays lint:fix",
25
+ "format": "raredays format",
26
+ "format:check": "raredays format:check",
27
+ "style": "raredays style",
28
+ "style:fix": "raredays style:fix",
29
+ "fix": "raredays fix",
30
+ "typecheck": "tsc --noEmit",
31
+ "check": "raredays check && tsc --noEmit"
32
+ },
33
+ "dependencies": {
34
+ "@raredays/components": "0.0.1",
35
+ "@raredays/core": "0.0.1",
36
+ "@raredays/identity": "0.0.1",
37
+ "@raredays/mocks": "0.0.1",
38
+ "@raredays/postgres": "0.0.1",
39
+ "@raredays/postgres-neon": "0.0.1",
40
+ "@raredays/postgres-pglite": "0.0.1",
41
+ "@raredays/style": "0.0.1",
42
+ "drizzle-orm": "0.45.2",
43
+ "lucide-react": "1.14.0",
44
+ "msw": "2.11.5",
45
+ "next": "16.2.4",
46
+ "react": "19.2.5",
47
+ "react-dom": "19.2.5"
48
+ },
49
+ "devDependencies": {
50
+ "@raredays/lint": "0.0.1",
51
+ "@raredays/site-config": "0.0.1",
52
+ "@raredays/theme-build": "0.0.1",
53
+ "@raredays/typescript": "0.0.1",
54
+ "@tailwindcss/postcss": "4.2.4",
55
+ "@types/node": "22.19.17",
56
+ "@types/react": "19.2.14",
57
+ "@types/react-dom": "19.2.3",
58
+ "@storybook/react-vite": "10.3.6",
59
+ "@tailwindcss/vite": "4.2.4",
60
+ "@vitejs/plugin-react": "6.0.1",
61
+ "drizzle-kit": "0.31.10",
62
+ "happy-dom": "15.11.7",
63
+ "storybook": "10.3.6",
64
+ "tailwindcss": "4.2.4",
65
+ "typescript": "5.9.3",
66
+ "vite": "8.0.10",
67
+ "vitest": "4.1.5"
68
+ },
69
+ "engines": {
70
+ "node": ">=24"
71
+ }
72
+ }
@@ -0,0 +1 @@
1
+ export { default } from "@raredays/style/postcss";
@@ -0,0 +1,349 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+
4
+ /**
5
+ * Mock Service Worker.
6
+ * @see https://github.com/mswjs/msw
7
+ * - Please do NOT modify this file.
8
+ */
9
+
10
+ const PACKAGE_VERSION = '2.11.5'
11
+ const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
12
+ const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
13
+ const activeClientIds = new Set()
14
+
15
+ addEventListener('install', function () {
16
+ self.skipWaiting()
17
+ })
18
+
19
+ addEventListener('activate', function (event) {
20
+ event.waitUntil(self.clients.claim())
21
+ })
22
+
23
+ addEventListener('message', async function (event) {
24
+ const clientId = Reflect.get(event.source || {}, 'id')
25
+
26
+ if (!clientId || !self.clients) {
27
+ return
28
+ }
29
+
30
+ const client = await self.clients.get(clientId)
31
+
32
+ if (!client) {
33
+ return
34
+ }
35
+
36
+ const allClients = await self.clients.matchAll({
37
+ type: 'window',
38
+ })
39
+
40
+ switch (event.data) {
41
+ case 'KEEPALIVE_REQUEST': {
42
+ sendToClient(client, {
43
+ type: 'KEEPALIVE_RESPONSE',
44
+ })
45
+ break
46
+ }
47
+
48
+ case 'INTEGRITY_CHECK_REQUEST': {
49
+ sendToClient(client, {
50
+ type: 'INTEGRITY_CHECK_RESPONSE',
51
+ payload: {
52
+ packageVersion: PACKAGE_VERSION,
53
+ checksum: INTEGRITY_CHECKSUM,
54
+ },
55
+ })
56
+ break
57
+ }
58
+
59
+ case 'MOCK_ACTIVATE': {
60
+ activeClientIds.add(clientId)
61
+
62
+ sendToClient(client, {
63
+ type: 'MOCKING_ENABLED',
64
+ payload: {
65
+ client: {
66
+ id: client.id,
67
+ frameType: client.frameType,
68
+ },
69
+ },
70
+ })
71
+ break
72
+ }
73
+
74
+ case 'CLIENT_CLOSED': {
75
+ activeClientIds.delete(clientId)
76
+
77
+ const remainingClients = allClients.filter((client) => {
78
+ return client.id !== clientId
79
+ })
80
+
81
+ // Unregister itself when there are no more clients
82
+ if (remainingClients.length === 0) {
83
+ self.registration.unregister()
84
+ }
85
+
86
+ break
87
+ }
88
+ }
89
+ })
90
+
91
+ addEventListener('fetch', function (event) {
92
+ const requestInterceptedAt = Date.now()
93
+
94
+ // Bypass navigation requests.
95
+ if (event.request.mode === 'navigate') {
96
+ return
97
+ }
98
+
99
+ // Opening the DevTools triggers the "only-if-cached" request
100
+ // that cannot be handled by the worker. Bypass such requests.
101
+ if (
102
+ event.request.cache === 'only-if-cached' &&
103
+ event.request.mode !== 'same-origin'
104
+ ) {
105
+ return
106
+ }
107
+
108
+ // Bypass all requests when there are no active clients.
109
+ // Prevents the self-unregistered worked from handling requests
110
+ // after it's been terminated (still remains active until the next reload).
111
+ if (activeClientIds.size === 0) {
112
+ return
113
+ }
114
+
115
+ const requestId = crypto.randomUUID()
116
+ event.respondWith(handleRequest(event, requestId, requestInterceptedAt))
117
+ })
118
+
119
+ /**
120
+ * @param {FetchEvent} event
121
+ * @param {string} requestId
122
+ * @param {number} requestInterceptedAt
123
+ */
124
+ async function handleRequest(event, requestId, requestInterceptedAt) {
125
+ const client = await resolveMainClient(event)
126
+ const requestCloneForEvents = event.request.clone()
127
+ const response = await getResponse(
128
+ event,
129
+ client,
130
+ requestId,
131
+ requestInterceptedAt,
132
+ )
133
+
134
+ // Send back the response clone for the "response:*" life-cycle events.
135
+ // Ensure MSW is active and ready to handle the message, otherwise
136
+ // this message will pend indefinitely.
137
+ if (client && activeClientIds.has(client.id)) {
138
+ const serializedRequest = await serializeRequest(requestCloneForEvents)
139
+
140
+ // Clone the response so both the client and the library could consume it.
141
+ const responseClone = response.clone()
142
+
143
+ sendToClient(
144
+ client,
145
+ {
146
+ type: 'RESPONSE',
147
+ payload: {
148
+ isMockedResponse: IS_MOCKED_RESPONSE in response,
149
+ request: {
150
+ id: requestId,
151
+ ...serializedRequest,
152
+ },
153
+ response: {
154
+ type: responseClone.type,
155
+ status: responseClone.status,
156
+ statusText: responseClone.statusText,
157
+ headers: Object.fromEntries(responseClone.headers.entries()),
158
+ body: responseClone.body,
159
+ },
160
+ },
161
+ },
162
+ responseClone.body ? [serializedRequest.body, responseClone.body] : [],
163
+ )
164
+ }
165
+
166
+ return response
167
+ }
168
+
169
+ /**
170
+ * Resolve the main client for the given event.
171
+ * Client that issues a request doesn't necessarily equal the client
172
+ * that registered the worker. It's with the latter the worker should
173
+ * communicate with during the response resolving phase.
174
+ * @param {FetchEvent} event
175
+ * @returns {Promise<Client | undefined>}
176
+ */
177
+ async function resolveMainClient(event) {
178
+ const client = await self.clients.get(event.clientId)
179
+
180
+ if (activeClientIds.has(event.clientId)) {
181
+ return client
182
+ }
183
+
184
+ if (client?.frameType === 'top-level') {
185
+ return client
186
+ }
187
+
188
+ const allClients = await self.clients.matchAll({
189
+ type: 'window',
190
+ })
191
+
192
+ return allClients
193
+ .filter((client) => {
194
+ // Get only those clients that are currently visible.
195
+ return client.visibilityState === 'visible'
196
+ })
197
+ .find((client) => {
198
+ // Find the client ID that's recorded in the
199
+ // set of clients that have registered the worker.
200
+ return activeClientIds.has(client.id)
201
+ })
202
+ }
203
+
204
+ /**
205
+ * @param {FetchEvent} event
206
+ * @param {Client | undefined} client
207
+ * @param {string} requestId
208
+ * @param {number} requestInterceptedAt
209
+ * @returns {Promise<Response>}
210
+ */
211
+ async function getResponse(event, client, requestId, requestInterceptedAt) {
212
+ // Clone the request because it might've been already used
213
+ // (i.e. its body has been read and sent to the client).
214
+ const requestClone = event.request.clone()
215
+
216
+ function passthrough() {
217
+ // Cast the request headers to a new Headers instance
218
+ // so the headers can be manipulated with.
219
+ const headers = new Headers(requestClone.headers)
220
+
221
+ // Remove the "accept" header value that marked this request as passthrough.
222
+ // This prevents request alteration and also keeps it compliant with the
223
+ // user-defined CORS policies.
224
+ const acceptHeader = headers.get('accept')
225
+ if (acceptHeader) {
226
+ const values = acceptHeader.split(',').map((value) => value.trim())
227
+ const filteredValues = values.filter(
228
+ (value) => value !== 'msw/passthrough',
229
+ )
230
+
231
+ if (filteredValues.length > 0) {
232
+ headers.set('accept', filteredValues.join(', '))
233
+ } else {
234
+ headers.delete('accept')
235
+ }
236
+ }
237
+
238
+ return fetch(requestClone, { headers })
239
+ }
240
+
241
+ // Bypass mocking when the client is not active.
242
+ if (!client) {
243
+ return passthrough()
244
+ }
245
+
246
+ // Bypass initial page load requests (i.e. static assets).
247
+ // The absence of the immediate/parent client in the map of the active clients
248
+ // means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet
249
+ // and is not ready to handle requests.
250
+ if (!activeClientIds.has(client.id)) {
251
+ return passthrough()
252
+ }
253
+
254
+ // Notify the client that a request has been intercepted.
255
+ const serializedRequest = await serializeRequest(event.request)
256
+ const clientMessage = await sendToClient(
257
+ client,
258
+ {
259
+ type: 'REQUEST',
260
+ payload: {
261
+ id: requestId,
262
+ interceptedAt: requestInterceptedAt,
263
+ ...serializedRequest,
264
+ },
265
+ },
266
+ [serializedRequest.body],
267
+ )
268
+
269
+ switch (clientMessage.type) {
270
+ case 'MOCK_RESPONSE': {
271
+ return respondWithMock(clientMessage.data)
272
+ }
273
+
274
+ case 'PASSTHROUGH': {
275
+ return passthrough()
276
+ }
277
+ }
278
+
279
+ return passthrough()
280
+ }
281
+
282
+ /**
283
+ * @param {Client} client
284
+ * @param {any} message
285
+ * @param {Array<Transferable>} transferrables
286
+ * @returns {Promise<any>}
287
+ */
288
+ function sendToClient(client, message, transferrables = []) {
289
+ return new Promise((resolve, reject) => {
290
+ const channel = new MessageChannel()
291
+
292
+ channel.port1.onmessage = (event) => {
293
+ if (event.data && event.data.error) {
294
+ return reject(event.data.error)
295
+ }
296
+
297
+ resolve(event.data)
298
+ }
299
+
300
+ client.postMessage(message, [
301
+ channel.port2,
302
+ ...transferrables.filter(Boolean),
303
+ ])
304
+ })
305
+ }
306
+
307
+ /**
308
+ * @param {Response} response
309
+ * @returns {Response}
310
+ */
311
+ function respondWithMock(response) {
312
+ // Setting response status code to 0 is a no-op.
313
+ // However, when responding with a "Response.error()", the produced Response
314
+ // instance will have status code set to 0. Since it's not possible to create
315
+ // a Response instance with status code 0, handle that use-case separately.
316
+ if (response.status === 0) {
317
+ return Response.error()
318
+ }
319
+
320
+ const mockedResponse = new Response(response.body, response)
321
+
322
+ Reflect.defineProperty(mockedResponse, IS_MOCKED_RESPONSE, {
323
+ value: true,
324
+ enumerable: true,
325
+ })
326
+
327
+ return mockedResponse
328
+ }
329
+
330
+ /**
331
+ * @param {Request} request
332
+ */
333
+ async function serializeRequest(request) {
334
+ return {
335
+ url: request.url,
336
+ mode: request.mode,
337
+ method: request.method,
338
+ headers: Object.fromEntries(request.headers.entries()),
339
+ cache: request.cache,
340
+ credentials: request.credentials,
341
+ destination: request.destination,
342
+ integrity: request.integrity,
343
+ redirect: request.redirect,
344
+ referrer: request.referrer,
345
+ referrerPolicy: request.referrerPolicy,
346
+ body: await request.arrayBuffer(),
347
+ keepalive: request.keepalive,
348
+ }
349
+ }
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ import { dirname, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { loadSiteSpec } from "@raredays/site-config";
5
+ import { writeThemeOverride } from "@raredays/theme-build";
6
+
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ const projectRoot = resolve(__dirname, "..");
9
+
10
+ const spec = await loadSiteSpec(resolve(projectRoot, "site.spec.ts"));
11
+ const outPath = resolve(projectRoot, "app/theme.override.css");
12
+
13
+ await writeThemeOverride(spec, outPath, {
14
+ regenCommand: "pnpm theme:build",
15
+ source: "site.spec.ts",
16
+ });
17
+
18
+ console.log(`✓ wrote ${outPath}`);
@@ -0,0 +1,58 @@
1
+ import { defineSiteSpec } from "@raredays/site-config";
2
+
3
+ /**
4
+ * The site specification for this app.
5
+ *
6
+ * Edit this file to brand your site, configure navigation, declare integrations,
7
+ * and enable modules. The Tailwind theme override stylesheet at
8
+ * `app/theme.override.css` is regenerated from this file by `pnpm theme:build`
9
+ * (which is chained into `pnpm dev` and `pnpm build`).
10
+ */
11
+ export default defineSiteSpec({
12
+ framework: "0.x",
13
+ runtime: "full-stack",
14
+ identity: {
15
+ name: "__SLUG__",
16
+ slug: "__SLUG__",
17
+ canonicalDomain: "example.com",
18
+ locales: ["en-US"],
19
+ },
20
+ branding: {
21
+ // Token overrides flow into Tailwind's @theme layer at build time.
22
+ // Anything in @raredays/tokens can be overridden here; unset keys keep
23
+ // the framework defaults. Examples:
24
+ //
25
+ // tokens: {
26
+ // color: { brand: { primary: "#0070f3", secondary: "#111111" } },
27
+ // font: { sans: "'Inter Variable', ui-sans-serif, system-ui, sans-serif" },
28
+ // radius: { md: "0.5rem" },
29
+ // },
30
+ assets: {
31
+ logo: "/logo.svg",
32
+ favicon: "/favicon.ico",
33
+ },
34
+ },
35
+ navigation: {
36
+ primary: [{ label: "Home", href: "/" }],
37
+ footer: [{ label: "About", href: "/about" }],
38
+ },
39
+ // Module configurations live here, keyed by module id. Each enabled module
40
+ // package validates its own slice. Example:
41
+ //
42
+ // modules: {
43
+ // billing: { plans: [...] },
44
+ // },
45
+ integrations: {
46
+ // Each integration's credential slots reference SHOUTING_SNAKE_CASE env
47
+ // var names — never literal secret values. Example:
48
+ //
49
+ // stripe: {
50
+ // secretKey: "STRIPE_SECRET_KEY",
51
+ // webhookSecret: "STRIPE_WEBHOOK_SECRET",
52
+ // },
53
+ },
54
+ deploy: {
55
+ vercel: { projectId: "prj_replace_me" },
56
+ database: { provider: "neon", urlRef: "DATABASE_URL" },
57
+ },
58
+ });
@@ -0,0 +1,12 @@
1
+ {
2
+ "Version": 4,
3
+ "Rules": [
4
+ {
5
+ "Scope": "**",
6
+ "Skills": [
7
+ "skills/repo.md"
8
+ ],
9
+ "DependencyBoundary": "."
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,56 @@
1
+ ---
2
+ title: Repository conventions
3
+ topic: repo-conventions
4
+ tags: [getting-started]
5
+ ---
6
+
7
+ # Repository conventions
8
+
9
+ This app was scaffolded with `create-raredays-app`. The framework's
10
+ `@raredays/*` packages are workspace deps and ship their own skills, all
11
+ auto-discovered via the `DependencyBoundary` in `skillex.json`.
12
+
13
+ ## Layout
14
+
15
+ ```
16
+ app/
17
+ ├── (auth)/ # Sign-in / sign-up routes (when identity:better-auth is wired)
18
+ ├── (subscribed)/ # Routes gated behind an active subscription
19
+ ├── api/ # API route handlers
20
+ ├── demo/ # Sample pages (delete or replace)
21
+ ├── lib/
22
+ │ └── runtime.ts # Provider composition root — edit here to swap providers
23
+ ├── globals.css # Tailwind v4 entry; scans @raredays/* dists for utilities
24
+ ├── layout.tsx # Root layout — wraps app in RaredaysProvider
25
+ └── theme.override.css # Generated by `pnpm theme:build` from site.spec.ts
26
+ db/ # Drizzle schema + migrations
27
+ mocks/ # MSW handlers (node + browser setups)
28
+ public/ # Static assets + mockServiceWorker.js
29
+ site.spec.ts # Single source of truth for site config — feeds theme:build
30
+ ```
31
+
32
+ ## Always-on workflow
33
+
34
+ ```sh
35
+ pnpm install # auto-runs skillex refresh via postinstall
36
+ pnpm dev # Next dev server
37
+ pnpm dev:mocks # Dev with MSW intercepting fetch
38
+ pnpm test # vitest run (node-mode tests)
39
+ pnpm check # lint + format:check + style + typecheck (gate before commit)
40
+ ```
41
+
42
+ ## Where things live in the framework
43
+
44
+ - `@raredays/core` — provider/port pattern, `RaredaysProvider`, env-config, ports
45
+ - `@raredays/components` — design system components (Tailwind v4, shadcn-flavored)
46
+ - `@raredays/identity` (+ `identity-better-auth`) — auth, sessions, organizations
47
+ - `@raredays/billing` (+ `billing-stripe`) — subscriptions, webhooks → events
48
+ - `@raredays/notifications` — in-app + email notification port
49
+ - `@raredays/cms` (+ `cms-hygraph`, `cms-bridge`) — headless CMS port + canonical-id bridge
50
+ - `@raredays/engagement` — declarative engagement tables (bookmarks, history, tags)
51
+ - `@raredays/state-machine` — typed state machine primitive
52
+ - `@raredays/i18n` — locale-aware translations + formatters
53
+ - `@raredays/mocks` — MSW setup for node + browser
54
+
55
+ Run `pnpm exec skillex query --package "@raredays/<name>"` for any of them
56
+ to see canonical usage patterns.
@@ -0,0 +1,4 @@
1
+ /** @type {import("stylelint").Config} */
2
+ export default {
3
+ extends: ["@raredays/lint/stylelint"],
4
+ };
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "@raredays/typescript/tsconfig.next.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "paths": {
6
+ "@/*": ["./app/*"]
7
+ }
8
+ },
9
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
10
+ "exclude": ["node_modules"]
11
+ }
@@ -0,0 +1,42 @@
1
+ import path from "node:path";
2
+ import react from "@vitejs/plugin-react";
3
+ import { defineConfig } from "vitest/config";
4
+
5
+ export default defineConfig({
6
+ plugins: [react()],
7
+ resolve: {
8
+ // Mirror tsconfig.json `paths` so tests can import via `@/*`.
9
+ alias: {
10
+ "@": path.resolve(__dirname, "./app"),
11
+ },
12
+ },
13
+ test: {
14
+ // happy-dom is required for any test that mounts a React tree —
15
+ // node leaves `document`/`window` undefined. Server-only tests still
16
+ // pass because happy-dom is a superset of node's globals.
17
+ environment: "happy-dom",
18
+ // Inline @raredays/* sources so vitest doesn't choke on ESM-internal
19
+ // package paths when components import from sibling subpath exports.
20
+ server: {
21
+ deps: {
22
+ inline: [/@raredays\//],
23
+ },
24
+ },
25
+ include: ["app/**/*.test.ts", "app/**/*.test.tsx", "lib/**/*.test.ts"],
26
+ setupFiles: ["./vitest.setup.ts"],
27
+ // Env stubs for module-load-time provider construction.
28
+ //
29
+ // Some `@raredays/*` providers eagerly read env at import time
30
+ // (e.g. `cms.ts` reading `HYGRAPH_ENDPOINT`). Without stubs here,
31
+ // any test that transitively imports such a module fails to LOAD.
32
+ // Real values via `.env.local` override these in real dev runs.
33
+ //
34
+ // Add stubs for any integration declared in `site.spec.ts` whose
35
+ // provider constructs at import time. Defect D11 (T010 turn 0229).
36
+ env: {
37
+ MOCKS: "on",
38
+ HYGRAPH_ENDPOINT: "http://localhost:test",
39
+ HYGRAPH_TOKEN: "test",
40
+ },
41
+ },
42
+ });
@@ -0,0 +1,18 @@
1
+ // Boot the MSW Node server for the duration of the test run. Tests can
2
+ // override handlers per-suite via `mockServer.use(...)` and the after-each
3
+ // reset cleans them up.
4
+
5
+ import { afterAll, afterEach, beforeAll } from "vitest";
6
+ import { mockServer } from "./mocks/node";
7
+
8
+ beforeAll(() => {
9
+ mockServer.start();
10
+ });
11
+
12
+ afterEach(() => {
13
+ mockServer.resetHandlers();
14
+ });
15
+
16
+ afterAll(() => {
17
+ mockServer.stop();
18
+ });