create-velox-app 0.6.31 → 0.6.51

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 (74) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/GUIDE.md +230 -0
  3. package/dist/cli.js +1 -0
  4. package/dist/index.js +14 -4
  5. package/dist/templates/auth.js +10 -0
  6. package/dist/templates/index.js +30 -1
  7. package/dist/templates/placeholders.js +0 -3
  8. package/dist/templates/rsc-auth.d.ts +12 -0
  9. package/dist/templates/rsc-auth.js +208 -0
  10. package/dist/templates/rsc.js +40 -1
  11. package/dist/templates/shared/css-generator.d.ts +26 -0
  12. package/dist/templates/shared/css-generator.js +553 -0
  13. package/dist/templates/shared/index.d.ts +3 -0
  14. package/dist/templates/shared/index.js +3 -0
  15. package/dist/templates/shared/rsc-styles.d.ts +54 -0
  16. package/dist/templates/shared/rsc-styles.js +68 -0
  17. package/dist/templates/shared/theme.d.ts +133 -0
  18. package/dist/templates/shared/theme.js +141 -0
  19. package/dist/templates/spa.js +10 -0
  20. package/dist/templates/trpc.js +10 -0
  21. package/dist/templates/types.d.ts +2 -1
  22. package/dist/templates/types.js +6 -0
  23. package/package.json +6 -3
  24. package/src/templates/source/api/config/database.ts +13 -32
  25. package/src/templates/source/api/docker-compose.yml +21 -0
  26. package/src/templates/source/root/CLAUDE.auth.md +6 -0
  27. package/src/templates/source/root/CLAUDE.default.md +6 -0
  28. package/src/templates/source/rsc/CLAUDE.md +56 -2
  29. package/src/templates/source/rsc/app/actions/posts.ts +1 -1
  30. package/src/templates/source/rsc/app/actions/users.ts +111 -20
  31. package/src/templates/source/rsc/app/layouts/dashboard.tsx +21 -16
  32. package/src/templates/source/rsc/app/layouts/marketing.tsx +34 -0
  33. package/src/templates/source/rsc/app/layouts/minimal-content.tsx +21 -0
  34. package/src/templates/source/rsc/app/layouts/minimal.tsx +86 -5
  35. package/src/templates/source/rsc/app/layouts/root.tsx +148 -44
  36. package/src/templates/source/rsc/docker-compose.yml +21 -0
  37. package/src/templates/source/rsc/package.json +3 -3
  38. package/src/templates/source/rsc/src/api/database.ts +13 -32
  39. package/src/templates/source/rsc/src/api/handler.ts +1 -1
  40. package/src/templates/source/rsc/src/entry.client.tsx +65 -18
  41. package/src/templates/source/rsc-auth/CLAUDE.md +230 -0
  42. package/src/templates/source/rsc-auth/app/actions/auth.ts +112 -0
  43. package/src/templates/source/rsc-auth/app/actions/users.ts +289 -0
  44. package/src/templates/source/rsc-auth/app/layouts/dashboard.tsx +132 -0
  45. package/src/templates/source/rsc-auth/app/layouts/marketing.tsx +59 -0
  46. package/src/templates/source/rsc-auth/app/layouts/minimal-content.tsx +21 -0
  47. package/src/templates/source/rsc-auth/app/layouts/minimal.tsx +111 -0
  48. package/src/templates/source/rsc-auth/app/layouts/root.tsx +355 -0
  49. package/src/templates/source/rsc-auth/app/pages/_not-found.tsx +15 -0
  50. package/src/templates/source/rsc-auth/app/pages/auth/login.tsx +198 -0
  51. package/src/templates/source/rsc-auth/app/pages/auth/register.tsx +225 -0
  52. package/src/templates/source/rsc-auth/app/pages/dashboard/index.tsx +267 -0
  53. package/src/templates/source/rsc-auth/app/pages/index.tsx +83 -0
  54. package/src/templates/source/rsc-auth/app/pages/users.tsx +47 -0
  55. package/src/templates/source/rsc-auth/app.config.ts +12 -0
  56. package/src/templates/source/rsc-auth/docker-compose.yml +21 -0
  57. package/src/templates/source/rsc-auth/env.example +11 -0
  58. package/src/templates/source/rsc-auth/gitignore +34 -0
  59. package/src/templates/source/rsc-auth/package.json +44 -0
  60. package/src/templates/source/rsc-auth/prisma/schema.prisma +23 -0
  61. package/src/templates/source/rsc-auth/prisma.config.ts +22 -0
  62. package/src/templates/source/rsc-auth/public/favicon.svg +4 -0
  63. package/src/templates/source/rsc-auth/src/api/database.ts +129 -0
  64. package/src/templates/source/rsc-auth/src/api/handler.ts +85 -0
  65. package/src/templates/source/rsc-auth/src/api/procedures/auth.ts +262 -0
  66. package/src/templates/source/rsc-auth/src/api/procedures/health.ts +48 -0
  67. package/src/templates/source/rsc-auth/src/api/procedures/users.ts +87 -0
  68. package/src/templates/source/rsc-auth/src/api/schemas/auth.ts +79 -0
  69. package/src/templates/source/rsc-auth/src/api/schemas/user.ts +38 -0
  70. package/src/templates/source/rsc-auth/src/api/utils/auth.ts +157 -0
  71. package/src/templates/source/rsc-auth/src/entry.client.tsx +63 -0
  72. package/src/templates/source/rsc-auth/src/entry.server.tsx +262 -0
  73. package/src/templates/source/rsc-auth/tsconfig.json +24 -0
  74. package/src/templates/source/shared/scripts/check-client-imports.sh +75 -0
@@ -0,0 +1,208 @@
1
+ /**
2
+ * RSC Auth Template (React Server Components + Authentication)
3
+ *
4
+ * Full-stack application with:
5
+ * - React Server Components (RSC) with Vinxi
6
+ * - JWT Authentication via @veloxts/auth
7
+ * - Validated server actions with security features
8
+ * - File-based routing with auth pages
9
+ * - Embedded Fastify API at /api/*
10
+ */
11
+ import fs from 'node:fs';
12
+ import path from 'node:path';
13
+ import { fileURLToPath } from 'node:url';
14
+ import { compileTemplate } from './compiler.js';
15
+ import { applyDatabaseDependencies, RSC_CONFIG } from './placeholders.js';
16
+ const __filename = fileURLToPath(import.meta.url);
17
+ const __dirname = path.dirname(__filename);
18
+ /**
19
+ * Read shared script from templates/source/shared/scripts/
20
+ */
21
+ function readSharedScript(scriptName) {
22
+ // Try dist path first (production), then src path (development)
23
+ const distPath = path.join(__dirname, '..', '..', 'src', 'templates', 'source', 'shared', 'scripts', scriptName);
24
+ const srcPath = path.join(__dirname, 'source', 'shared', 'scripts', scriptName);
25
+ for (const scriptPath of [distPath, srcPath]) {
26
+ if (fs.existsSync(scriptPath)) {
27
+ return fs.readFileSync(scriptPath, 'utf-8');
28
+ }
29
+ }
30
+ throw new Error(`Shared script not found: ${scriptName}. Checked:\n - ${distPath}\n - ${srcPath}`);
31
+ }
32
+ // ============================================================================
33
+ // Template Compilation
34
+ // ============================================================================
35
+ function generatePackageJson(config) {
36
+ const content = compileTemplate('rsc-auth/package.json', config);
37
+ return applyDatabaseDependencies(content, config);
38
+ }
39
+ function generateAppConfig() {
40
+ return compileTemplate('rsc-auth/app.config.ts', RSC_CONFIG);
41
+ }
42
+ function generateTsConfig() {
43
+ return compileTemplate('rsc-auth/tsconfig.json', RSC_CONFIG);
44
+ }
45
+ function generateEnvExample(config) {
46
+ return compileTemplate('rsc-auth/env.example', config);
47
+ }
48
+ function generateGitignore() {
49
+ return compileTemplate('rsc-auth/gitignore', RSC_CONFIG);
50
+ }
51
+ function generateClaudeMd(config) {
52
+ return compileTemplate('rsc-auth/CLAUDE.md', config);
53
+ }
54
+ // Prisma
55
+ function generatePrismaSchema(config) {
56
+ return compileTemplate('rsc-auth/prisma/schema.prisma', config);
57
+ }
58
+ function generatePrismaConfig() {
59
+ return compileTemplate('rsc-auth/prisma.config.ts', RSC_CONFIG);
60
+ }
61
+ // App layer (RSC) - Pages
62
+ function generateHomePage() {
63
+ return compileTemplate('rsc-auth/app/pages/index.tsx', RSC_CONFIG);
64
+ }
65
+ function generateUsersPage() {
66
+ return compileTemplate('rsc-auth/app/pages/users.tsx', RSC_CONFIG);
67
+ }
68
+ function generateNotFoundPage() {
69
+ return compileTemplate('rsc-auth/app/pages/_not-found.tsx', RSC_CONFIG);
70
+ }
71
+ // Auth pages
72
+ function generateLoginPage() {
73
+ return compileTemplate('rsc-auth/app/pages/auth/login.tsx', RSC_CONFIG);
74
+ }
75
+ function generateRegisterPage() {
76
+ return compileTemplate('rsc-auth/app/pages/auth/register.tsx', RSC_CONFIG);
77
+ }
78
+ // Dashboard pages
79
+ function generateDashboardPage() {
80
+ return compileTemplate('rsc-auth/app/pages/dashboard/index.tsx', RSC_CONFIG);
81
+ }
82
+ // Layouts
83
+ function generateRootLayout() {
84
+ return compileTemplate('rsc-auth/app/layouts/root.tsx', RSC_CONFIG);
85
+ }
86
+ function generateMarketingLayout() {
87
+ return compileTemplate('rsc-auth/app/layouts/marketing.tsx', RSC_CONFIG);
88
+ }
89
+ function generateMinimalLayout() {
90
+ return compileTemplate('rsc-auth/app/layouts/minimal.tsx', RSC_CONFIG);
91
+ }
92
+ function generateMinimalContentLayout() {
93
+ return compileTemplate('rsc-auth/app/layouts/minimal-content.tsx', RSC_CONFIG);
94
+ }
95
+ function generateDashboardLayout() {
96
+ return compileTemplate('rsc-auth/app/layouts/dashboard.tsx', RSC_CONFIG);
97
+ }
98
+ // Actions
99
+ function generateUserActions() {
100
+ return compileTemplate('rsc-auth/app/actions/users.ts', RSC_CONFIG);
101
+ }
102
+ function generateAuthActions() {
103
+ return compileTemplate('rsc-auth/app/actions/auth.ts', RSC_CONFIG);
104
+ }
105
+ // Source layer - Entry points
106
+ function generateEntryClient() {
107
+ return compileTemplate('rsc-auth/src/entry.client.tsx', RSC_CONFIG);
108
+ }
109
+ function generateEntryServer() {
110
+ return compileTemplate('rsc-auth/src/entry.server.tsx', RSC_CONFIG);
111
+ }
112
+ // Source layer - API
113
+ function generateApiHandler() {
114
+ return compileTemplate('rsc-auth/src/api/handler.ts', RSC_CONFIG);
115
+ }
116
+ function generateDatabase(config) {
117
+ return compileTemplate('rsc-auth/src/api/database.ts', config);
118
+ }
119
+ function generateHealthProcedures() {
120
+ return compileTemplate('rsc-auth/src/api/procedures/health.ts', RSC_CONFIG);
121
+ }
122
+ function generateUserProcedures() {
123
+ return compileTemplate('rsc-auth/src/api/procedures/users.ts', RSC_CONFIG);
124
+ }
125
+ function generateAuthProcedures() {
126
+ return compileTemplate('rsc-auth/src/api/procedures/auth.ts', RSC_CONFIG);
127
+ }
128
+ // Schemas
129
+ function generateUserSchemas() {
130
+ return compileTemplate('rsc-auth/src/api/schemas/user.ts', RSC_CONFIG);
131
+ }
132
+ function generateAuthSchemas() {
133
+ return compileTemplate('rsc-auth/src/api/schemas/auth.ts', RSC_CONFIG);
134
+ }
135
+ // Utils
136
+ function generateAuthUtils() {
137
+ return compileTemplate('rsc-auth/src/api/utils/auth.ts', RSC_CONFIG);
138
+ }
139
+ // Public assets
140
+ function generateFavicon() {
141
+ return compileTemplate('rsc-auth/public/favicon.svg', RSC_CONFIG);
142
+ }
143
+ function generateDockerCompose(config) {
144
+ return compileTemplate('rsc-auth/docker-compose.yml', config);
145
+ }
146
+ // ============================================================================
147
+ // RSC Auth Template Generator
148
+ // ============================================================================
149
+ export function generateRscAuthTemplate(config) {
150
+ const files = [
151
+ // Root configuration
152
+ { path: 'package.json', content: generatePackageJson(config) },
153
+ { path: 'app.config.ts', content: generateAppConfig() },
154
+ { path: 'tsconfig.json', content: generateTsConfig() },
155
+ { path: '.env.example', content: generateEnvExample(config) },
156
+ { path: '.env', content: generateEnvExample(config) },
157
+ { path: '.gitignore', content: generateGitignore() },
158
+ { path: 'CLAUDE.md', content: generateClaudeMd(config) },
159
+ // Prisma
160
+ { path: 'prisma/schema.prisma', content: generatePrismaSchema(config) },
161
+ { path: 'prisma.config.ts', content: generatePrismaConfig() },
162
+ // App layer - Pages
163
+ { path: 'app/pages/index.tsx', content: generateHomePage() },
164
+ { path: 'app/pages/users.tsx', content: generateUsersPage() },
165
+ { path: 'app/pages/_not-found.tsx', content: generateNotFoundPage() },
166
+ // App layer - Auth pages
167
+ { path: 'app/pages/auth/login.tsx', content: generateLoginPage() },
168
+ { path: 'app/pages/auth/register.tsx', content: generateRegisterPage() },
169
+ // App layer - Dashboard
170
+ { path: 'app/pages/dashboard/index.tsx', content: generateDashboardPage() },
171
+ // App layer - Layouts
172
+ { path: 'app/layouts/root.tsx', content: generateRootLayout() },
173
+ { path: 'app/layouts/marketing.tsx', content: generateMarketingLayout() },
174
+ { path: 'app/layouts/minimal.tsx', content: generateMinimalLayout() },
175
+ { path: 'app/layouts/minimal-content.tsx', content: generateMinimalContentLayout() },
176
+ { path: 'app/layouts/dashboard.tsx', content: generateDashboardLayout() },
177
+ // App layer - Actions
178
+ { path: 'app/actions/users.ts', content: generateUserActions() },
179
+ { path: 'app/actions/auth.ts', content: generateAuthActions() },
180
+ // Source layer - Entry points
181
+ { path: 'src/entry.client.tsx', content: generateEntryClient() },
182
+ { path: 'src/entry.server.tsx', content: generateEntryServer() },
183
+ // Source layer - API
184
+ { path: 'src/api/handler.ts', content: generateApiHandler() },
185
+ { path: 'src/api/database.ts', content: generateDatabase(config) },
186
+ { path: 'src/api/procedures/health.ts', content: generateHealthProcedures() },
187
+ { path: 'src/api/procedures/users.ts', content: generateUserProcedures() },
188
+ { path: 'src/api/procedures/auth.ts', content: generateAuthProcedures() },
189
+ { path: 'src/api/schemas/user.ts', content: generateUserSchemas() },
190
+ { path: 'src/api/schemas/auth.ts', content: generateAuthSchemas() },
191
+ { path: 'src/api/utils/auth.ts', content: generateAuthUtils() },
192
+ // Public assets
193
+ { path: 'public/favicon.svg', content: generateFavicon() },
194
+ // Scripts
195
+ {
196
+ path: 'scripts/check-client-imports.sh',
197
+ content: readSharedScript('check-client-imports.sh'),
198
+ },
199
+ ];
200
+ // Add docker-compose for PostgreSQL
201
+ if (config.database === 'postgresql') {
202
+ files.push({
203
+ path: 'docker-compose.yml',
204
+ content: generateDockerCompose(config),
205
+ });
206
+ }
207
+ return files;
208
+ }
@@ -10,8 +10,27 @@
10
10
  *
11
11
  * This is a single-package structure (not a monorepo workspace).
12
12
  */
13
+ import fs from 'node:fs';
14
+ import path from 'node:path';
15
+ import { fileURLToPath } from 'node:url';
13
16
  import { compileTemplate } from './compiler.js';
14
17
  import { applyDatabaseDependencies, RSC_CONFIG } from './placeholders.js';
18
+ const __filename = fileURLToPath(import.meta.url);
19
+ const __dirname = path.dirname(__filename);
20
+ /**
21
+ * Read shared script from templates/source/shared/scripts/
22
+ */
23
+ function readSharedScript(scriptName) {
24
+ // Try dist path first (production), then src path (development)
25
+ const distPath = path.join(__dirname, '..', '..', 'src', 'templates', 'source', 'shared', 'scripts', scriptName);
26
+ const srcPath = path.join(__dirname, 'source', 'shared', 'scripts', scriptName);
27
+ for (const scriptPath of [distPath, srcPath]) {
28
+ if (fs.existsSync(scriptPath)) {
29
+ return fs.readFileSync(scriptPath, 'utf-8');
30
+ }
31
+ }
32
+ throw new Error(`Shared script not found: ${scriptName}. Checked:\n - ${distPath}\n - ${srcPath}`);
33
+ }
15
34
  // ============================================================================
16
35
  // Template Compilation
17
36
  // ============================================================================
@@ -60,6 +79,9 @@ function generateMarketingLayout() {
60
79
  function generateMinimalLayout() {
61
80
  return compileTemplate('rsc/app/layouts/minimal.tsx', RSC_CONFIG);
62
81
  }
82
+ function generateMinimalContentLayout() {
83
+ return compileTemplate('rsc/app/layouts/minimal-content.tsx', RSC_CONFIG);
84
+ }
63
85
  function generateAboutPage() {
64
86
  return compileTemplate('rsc/app/pages/(marketing)/about.tsx', RSC_CONFIG);
65
87
  }
@@ -134,11 +156,14 @@ function generatePostSchemas() {
134
156
  function generateFavicon() {
135
157
  return compileTemplate('rsc/public/favicon.svg', RSC_CONFIG);
136
158
  }
159
+ function generateDockerCompose(config) {
160
+ return compileTemplate('rsc/docker-compose.yml', config);
161
+ }
137
162
  // ============================================================================
138
163
  // RSC Template Generator
139
164
  // ============================================================================
140
165
  export function generateRscTemplate(config) {
141
- return [
166
+ const files = [
142
167
  // Root configuration files
143
168
  { path: 'package.json', content: generatePackageJson(config) },
144
169
  { path: 'app.config.ts', content: generateAppConfig() },
@@ -170,6 +195,7 @@ export function generateRscTemplate(config) {
170
195
  { path: 'app/layouts/root.tsx', content: generateRootLayout() },
171
196
  { path: 'app/layouts/marketing.tsx', content: generateMarketingLayout() },
172
197
  { path: 'app/layouts/minimal.tsx', content: generateMinimalLayout() },
198
+ { path: 'app/layouts/minimal-content.tsx', content: generateMinimalContentLayout() },
173
199
  { path: 'app/layouts/dashboard.tsx', content: generateDashboardLayout() },
174
200
  { path: 'app/pages/users/_layout.tsx', content: generateUsersLayout() },
175
201
  // App layer (RSC) - Server actions
@@ -188,5 +214,18 @@ export function generateRscTemplate(config) {
188
214
  { path: 'src/api/schemas/post.ts', content: generatePostSchemas() },
189
215
  // Public assets
190
216
  { path: 'public/favicon.svg', content: generateFavicon() },
217
+ // Scripts
218
+ {
219
+ path: 'scripts/check-client-imports.sh',
220
+ content: readSharedScript('check-client-imports.sh'),
221
+ },
191
222
  ];
223
+ // Add docker-compose for PostgreSQL
224
+ if (config.database === 'postgresql') {
225
+ files.push({
226
+ path: 'docker-compose.yml',
227
+ content: generateDockerCompose(config),
228
+ });
229
+ }
230
+ return files;
192
231
  }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * CSS Generator Functions
3
+ *
4
+ * Generates CSS strings from the theme design system.
5
+ * These functions provide consistent dark mode styling across all RSC templates.
6
+ */
7
+ /**
8
+ * Global CSS reset and base styles for dark mode
9
+ */
10
+ export declare function generateGlobalReset(): string;
11
+ /**
12
+ * Root layout styles - Navigation, footer, and main content area
13
+ */
14
+ export declare function generateRscRootStyles(): string;
15
+ /**
16
+ * Dashboard layout styles - Sidebar navigation
17
+ */
18
+ export declare function generateRscDashboardStyles(): string;
19
+ /**
20
+ * Minimal layout styles - For auth pages, centered content
21
+ */
22
+ export declare function generateRscMinimalStyles(): string;
23
+ /**
24
+ * Marketing layout styles - Banner/badge
25
+ */
26
+ export declare function generateRscMarketingStyles(): string;