create-velox-app 0.6.27 → 0.6.31
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/CHANGELOG.md +24 -0
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +74 -7
- package/dist/index.d.ts +2 -3
- package/dist/index.js +7 -8
- package/dist/templates/auth.d.ts +0 -1
- package/dist/templates/auth.js +9 -9
- package/dist/templates/compiler.d.ts +0 -1
- package/dist/templates/compiler.js +1 -2
- package/dist/templates/index.d.ts +0 -1
- package/dist/templates/index.js +0 -1
- package/dist/templates/placeholders.d.ts +31 -3
- package/dist/templates/placeholders.js +167 -4
- package/dist/templates/rsc.d.ts +0 -1
- package/dist/templates/rsc.js +9 -9
- package/dist/templates/shared/index.d.ts +0 -1
- package/dist/templates/shared/index.js +0 -1
- package/dist/templates/shared/root.d.ts +0 -1
- package/dist/templates/shared/root.js +11 -2
- package/dist/templates/shared/web-base.d.ts +0 -1
- package/dist/templates/shared/web-base.js +0 -1
- package/dist/templates/shared/web-styles.d.ts +0 -1
- package/dist/templates/shared/web-styles.js +0 -1
- package/dist/templates/shared.d.ts +0 -1
- package/dist/templates/shared.js +0 -1
- package/dist/templates/spa.d.ts +0 -1
- package/dist/templates/spa.js +9 -9
- package/dist/templates/trpc.d.ts +0 -1
- package/dist/templates/trpc.js +9 -9
- package/dist/templates/types.d.ts +0 -1
- package/dist/templates/types.js +1 -3
- package/package.json +5 -2
- package/src/templates/source/api/config/database.ts +76 -0
- package/src/templates/source/api/env.auth +1 -4
- package/src/templates/source/api/env.default +1 -4
- package/src/templates/source/api/prisma/schema.auth.prisma +1 -2
- package/src/templates/source/api/prisma/schema.default.prisma +1 -2
- package/src/templates/source/api/procedures/auth.ts +2 -2
- package/src/templates/source/api/procedures/health.ts +2 -2
- package/src/templates/source/api/procedures/users.auth.ts +2 -2
- package/src/templates/source/api/procedures/users.default.ts +2 -8
- package/src/templates/source/root/.cursorrules +3 -3
- package/src/templates/source/root/CLAUDE.auth.md +2 -2
- package/src/templates/source/root/CLAUDE.default.md +2 -2
- package/src/templates/source/root/package.json +6 -6
- package/src/templates/source/rsc/env.example +1 -1
- package/src/templates/source/rsc/prisma/schema.prisma +1 -1
- package/src/templates/source/rsc/src/api/database.ts +76 -0
- package/src/templates/source/rsc/src/api/procedures/health.ts +2 -2
- package/src/templates/source/rsc/src/api/procedures/posts.ts +2 -2
- package/src/templates/source/rsc/src/api/procedures/users.ts +2 -2
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/templates/auth.d.ts.map +0 -1
- package/dist/templates/auth.js.map +0 -1
- package/dist/templates/compiler.d.ts.map +0 -1
- package/dist/templates/compiler.js.map +0 -1
- package/dist/templates/default.d.ts +0 -12
- package/dist/templates/default.d.ts.map +0 -1
- package/dist/templates/default.js +0 -85
- package/dist/templates/default.js.map +0 -1
- package/dist/templates/fullstack.d.ts +0 -15
- package/dist/templates/fullstack.d.ts.map +0 -1
- package/dist/templates/fullstack.js +0 -110
- package/dist/templates/fullstack.js.map +0 -1
- package/dist/templates/index.d.ts.map +0 -1
- package/dist/templates/index.js.map +0 -1
- package/dist/templates/placeholders.d.ts.map +0 -1
- package/dist/templates/placeholders.js.map +0 -1
- package/dist/templates/rsc.d.ts.map +0 -1
- package/dist/templates/rsc.js.map +0 -1
- package/dist/templates/shared/index.d.ts.map +0 -1
- package/dist/templates/shared/index.js.map +0 -1
- package/dist/templates/shared/root.d.ts.map +0 -1
- package/dist/templates/shared/root.js.map +0 -1
- package/dist/templates/shared/web-base.d.ts.map +0 -1
- package/dist/templates/shared/web-base.js.map +0 -1
- package/dist/templates/shared/web-styles.d.ts.map +0 -1
- package/dist/templates/shared/web-styles.js.map +0 -1
- package/dist/templates/shared.d.ts.map +0 -1
- package/dist/templates/shared.js.map +0 -1
- package/dist/templates/source/api/config/app.d.ts +0 -13
- package/dist/templates/source/api/config/app.d.ts.map +0 -1
- package/dist/templates/source/api/config/app.js +0 -14
- package/dist/templates/source/api/config/app.js.map +0 -1
- package/dist/templates/source/api/config/auth.d.ts +0 -34
- package/dist/templates/source/api/config/auth.d.ts.map +0 -1
- package/dist/templates/source/api/config/auth.js +0 -165
- package/dist/templates/source/api/config/auth.js.map +0 -1
- package/dist/templates/source/api/config/index.auth.d.ts +0 -6
- package/dist/templates/source/api/config/index.auth.d.ts.map +0 -1
- package/dist/templates/source/api/config/index.auth.js +0 -6
- package/dist/templates/source/api/config/index.auth.js.map +0 -1
- package/dist/templates/source/api/config/index.default.d.ts +0 -5
- package/dist/templates/source/api/config/index.default.d.ts.map +0 -1
- package/dist/templates/source/api/config/index.default.js +0 -5
- package/dist/templates/source/api/config/index.default.js.map +0 -1
- package/dist/templates/source/api/database/index.d.ts +0 -9
- package/dist/templates/source/api/database/index.d.ts.map +0 -1
- package/dist/templates/source/api/database/index.js +0 -18
- package/dist/templates/source/api/database/index.js.map +0 -1
- package/dist/templates/source/api/index.auth.d.ts +0 -5
- package/dist/templates/source/api/index.auth.d.ts.map +0 -1
- package/dist/templates/source/api/index.auth.js +0 -59
- package/dist/templates/source/api/index.auth.js.map +0 -1
- package/dist/templates/source/api/index.default.d.ts +0 -5
- package/dist/templates/source/api/index.default.d.ts.map +0 -1
- package/dist/templates/source/api/index.default.js +0 -56
- package/dist/templates/source/api/index.default.js.map +0 -1
- package/dist/templates/source/api/prisma.config.d.ts +0 -9
- package/dist/templates/source/api/prisma.config.d.ts.map +0 -1
- package/dist/templates/source/api/prisma.config.js +0 -15
- package/dist/templates/source/api/prisma.config.js.map +0 -1
- package/dist/templates/source/api/procedures/auth.d.ts +0 -14
- package/dist/templates/source/api/procedures/auth.d.ts.map +0 -1
- package/dist/templates/source/api/procedures/auth.js +0 -221
- package/dist/templates/source/api/procedures/auth.js.map +0 -1
- package/dist/templates/source/api/procedures/health.d.ts +0 -5
- package/dist/templates/source/api/procedures/health.d.ts.map +0 -1
- package/dist/templates/source/api/procedures/health.js +0 -21
- package/dist/templates/source/api/procedures/health.js.map +0 -1
- package/dist/templates/source/api/procedures/index.auth.d.ts +0 -7
- package/dist/templates/source/api/procedures/index.auth.d.ts.map +0 -1
- package/dist/templates/source/api/procedures/index.auth.js +0 -7
- package/dist/templates/source/api/procedures/index.auth.js.map +0 -1
- package/dist/templates/source/api/procedures/index.default.d.ts +0 -6
- package/dist/templates/source/api/procedures/index.default.d.ts.map +0 -1
- package/dist/templates/source/api/procedures/index.default.js +0 -6
- package/dist/templates/source/api/procedures/index.default.js.map +0 -1
- package/dist/templates/source/api/procedures/users.auth.d.ts +0 -7
- package/dist/templates/source/api/procedures/users.auth.d.ts.map +0 -1
- package/dist/templates/source/api/procedures/users.auth.js +0 -111
- package/dist/templates/source/api/procedures/users.auth.js.map +0 -1
- package/dist/templates/source/api/procedures/users.default.d.ts +0 -5
- package/dist/templates/source/api/procedures/users.default.d.ts.map +0 -1
- package/dist/templates/source/api/procedures/users.default.js +0 -86
- package/dist/templates/source/api/procedures/users.default.js.map +0 -1
- package/dist/templates/source/api/schemas/index.d.ts +0 -5
- package/dist/templates/source/api/schemas/index.d.ts.map +0 -1
- package/dist/templates/source/api/schemas/index.js +0 -5
- package/dist/templates/source/api/schemas/index.js.map +0 -1
- package/dist/templates/source/api/schemas/user.d.ts +0 -11
- package/dist/templates/source/api/schemas/user.d.ts.map +0 -1
- package/dist/templates/source/api/schemas/user.js +0 -20
- package/dist/templates/source/api/schemas/user.js.map +0 -1
- package/dist/templates/source/api/tsup.config.d.ts +0 -3
- package/dist/templates/source/api/tsup.config.d.ts.map +0 -1
- package/dist/templates/source/api/tsup.config.js +0 -10
- package/dist/templates/source/api/tsup.config.js.map +0 -1
- package/dist/templates/source/web/main.d.ts +0 -9
- package/dist/templates/source/web/main.d.ts.map +0 -1
- package/dist/templates/source/web/main.js +0 -27
- package/dist/templates/source/web/main.js.map +0 -1
- package/dist/templates/source/web/routes/__root.d.ts +0 -2
- package/dist/templates/source/web/routes/__root.d.ts.map +0 -1
- package/dist/templates/source/web/routes/__root.js +0 -28
- package/dist/templates/source/web/routes/__root.js.map +0 -1
- package/dist/templates/source/web/routes/about.d.ts +0 -2
- package/dist/templates/source/web/routes/about.d.ts.map +0 -1
- package/dist/templates/source/web/routes/about.js +0 -33
- package/dist/templates/source/web/routes/about.js.map +0 -1
- package/dist/templates/source/web/routes/index.auth.d.ts +0 -2
- package/dist/templates/source/web/routes/index.auth.d.ts.map +0 -1
- package/dist/templates/source/web/routes/index.auth.js +0 -159
- package/dist/templates/source/web/routes/index.auth.js.map +0 -1
- package/dist/templates/source/web/routes/index.default.d.ts +0 -2
- package/dist/templates/source/web/routes/index.default.d.ts.map +0 -1
- package/dist/templates/source/web/routes/index.default.js +0 -60
- package/dist/templates/source/web/routes/index.default.js.map +0 -1
- package/dist/templates/source/web/vite.config.d.ts +0 -3
- package/dist/templates/source/web/vite.config.d.ts.map +0 -1
- package/dist/templates/source/web/vite.config.js +0 -22
- package/dist/templates/source/web/vite.config.js.map +0 -1
- package/dist/templates/spa.d.ts.map +0 -1
- package/dist/templates/spa.js.map +0 -1
- package/dist/templates/trpc.d.ts.map +0 -1
- package/dist/templates/trpc.js.map +0 -1
- package/dist/templates/types.d.ts.map +0 -1
- package/dist/templates/types.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# create-velox-app
|
|
2
2
|
|
|
3
|
+
## 0.6.31
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- npm must use concurrently for run dev script
|
|
8
|
+
|
|
9
|
+
## 0.6.30
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- disable source maps for published packages
|
|
14
|
+
|
|
15
|
+
## 0.6.29
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- add multi-tenancy and PostgreSQL support - test and lint fix
|
|
20
|
+
|
|
21
|
+
## 0.6.28
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- add multi-tenancy support and postgresql database
|
|
26
|
+
|
|
3
27
|
## 0.6.27
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Handles command-line arguments and initiates the scaffolding process.
|
|
7
7
|
*/
|
|
8
8
|
import { CREATE_VERSION, createVeloxApp } from './index.js';
|
|
9
|
-
import { getAvailableTemplates, TEMPLATE_METADATA } from './templates/index.js';
|
|
9
|
+
import { DATABASE_METADATA, getAvailableDatabases, getAvailableTemplates, isDatabaseAvailable, isValidDatabase, TEMPLATE_METADATA, } from './templates/index.js';
|
|
10
10
|
import { resolveTemplateAlias, TEMPLATE_ALIASES } from './templates/types.js';
|
|
11
11
|
// ============================================================================
|
|
12
12
|
// Constants
|
|
@@ -17,6 +17,13 @@ function getTemplateNames() {
|
|
|
17
17
|
const aliases = Object.keys(TEMPLATE_ALIASES);
|
|
18
18
|
return [...templates, ...aliases].join(', ');
|
|
19
19
|
}
|
|
20
|
+
/** Get list of available database names for error messages */
|
|
21
|
+
function getDatabaseNames() {
|
|
22
|
+
return getAvailableDatabases()
|
|
23
|
+
.filter((db) => !db.disabled)
|
|
24
|
+
.map((db) => db.type)
|
|
25
|
+
.join(', ');
|
|
26
|
+
}
|
|
20
27
|
// ============================================================================
|
|
21
28
|
// Help & Version
|
|
22
29
|
// ============================================================================
|
|
@@ -30,6 +37,8 @@ Usage:
|
|
|
30
37
|
Options:
|
|
31
38
|
-t, --template <name> Template to use (default: "spa")
|
|
32
39
|
Available: ${getTemplateNames()}
|
|
40
|
+
-d, --database <name> Database to use (default: "sqlite")
|
|
41
|
+
Available: ${getDatabaseNames()}
|
|
33
42
|
-h, --help Show this help message
|
|
34
43
|
-v, --version Show version number
|
|
35
44
|
|
|
@@ -39,15 +48,20 @@ Templates:
|
|
|
39
48
|
trpc ${TEMPLATE_METADATA.trpc.description}
|
|
40
49
|
rsc ${TEMPLATE_METADATA.rsc.description}
|
|
41
50
|
|
|
51
|
+
Databases:
|
|
52
|
+
sqlite ${DATABASE_METADATA.sqlite.hint}
|
|
53
|
+
postgresql ${DATABASE_METADATA.postgresql.hint}
|
|
54
|
+
|
|
42
55
|
Aliases:
|
|
43
56
|
default → spa (backward compatible)
|
|
44
57
|
fullstack → rsc (backward compatible)
|
|
45
58
|
|
|
46
59
|
Examples:
|
|
47
|
-
npx create-velox-app my-app
|
|
48
|
-
npx create-velox-app my-app --template=spa
|
|
49
|
-
npx create-velox-app my-app --
|
|
50
|
-
npx create-velox-app
|
|
60
|
+
npx create-velox-app my-app # Interactive mode
|
|
61
|
+
npx create-velox-app my-app --template=spa # SPA + API template
|
|
62
|
+
npx create-velox-app my-app --database=postgresql # Use PostgreSQL
|
|
63
|
+
npx create-velox-app my-app -t rsc -d postgresql # RSC with PostgreSQL
|
|
64
|
+
npx create-velox-app # Prompt for name
|
|
51
65
|
`;
|
|
52
66
|
function parseArgs(args) {
|
|
53
67
|
const result = {
|
|
@@ -56,6 +70,7 @@ function parseArgs(args) {
|
|
|
56
70
|
};
|
|
57
71
|
const unexpectedArgs = [];
|
|
58
72
|
let templateFlagSeen = false;
|
|
73
|
+
let databaseFlagSeen = false;
|
|
59
74
|
for (let i = 0; i < args.length; i++) {
|
|
60
75
|
const arg = args[i];
|
|
61
76
|
// Handle --help / -h
|
|
@@ -115,6 +130,59 @@ function parseArgs(args) {
|
|
|
115
130
|
}
|
|
116
131
|
continue;
|
|
117
132
|
}
|
|
133
|
+
// Handle --database=<value> or -d=<value>
|
|
134
|
+
if (arg.startsWith('--database=') || arg.startsWith('-d=')) {
|
|
135
|
+
// Check for duplicate flag
|
|
136
|
+
if (databaseFlagSeen) {
|
|
137
|
+
console.error('Error: --database flag specified multiple times');
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
databaseFlagSeen = true;
|
|
141
|
+
const value = arg.split('=')[1];
|
|
142
|
+
if (!value) {
|
|
143
|
+
console.error(`Error: --database requires a value. Available: ${getDatabaseNames()}`);
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
if (isValidDatabase(value)) {
|
|
147
|
+
if (!isDatabaseAvailable(value)) {
|
|
148
|
+
console.error(`Database "${value}" is not yet available. Available: ${getDatabaseNames()}`);
|
|
149
|
+
process.exit(1);
|
|
150
|
+
}
|
|
151
|
+
result.database = value;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
console.error(`Invalid database: ${value}. Available: ${getDatabaseNames()}`);
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
// Handle --database <value> or -d <value>
|
|
160
|
+
if (arg === '--database' || arg === '-d') {
|
|
161
|
+
// Check for duplicate flag
|
|
162
|
+
if (databaseFlagSeen) {
|
|
163
|
+
console.error('Error: --database flag specified multiple times');
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
databaseFlagSeen = true;
|
|
167
|
+
const value = args[i + 1];
|
|
168
|
+
if (!value || value.startsWith('-')) {
|
|
169
|
+
console.error(`Error: --database requires a value. Available: ${getDatabaseNames()}`);
|
|
170
|
+
process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
if (isValidDatabase(value)) {
|
|
173
|
+
if (!isDatabaseAvailable(value)) {
|
|
174
|
+
console.error(`Database "${value}" is not yet available. Available: ${getDatabaseNames()}`);
|
|
175
|
+
process.exit(1);
|
|
176
|
+
}
|
|
177
|
+
result.database = value;
|
|
178
|
+
i++; // Skip next arg
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
console.error(`Invalid database: ${value}. Available: ${getDatabaseNames()}`);
|
|
182
|
+
process.exit(1);
|
|
183
|
+
}
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
118
186
|
// Non-flag argument
|
|
119
187
|
if (!arg.startsWith('-')) {
|
|
120
188
|
if (!result.projectName) {
|
|
@@ -153,7 +221,7 @@ async function main() {
|
|
|
153
221
|
process.exit(0);
|
|
154
222
|
}
|
|
155
223
|
// Run scaffolder
|
|
156
|
-
await createVeloxApp(parsed.projectName, parsed.template);
|
|
224
|
+
await createVeloxApp(parsed.projectName, parsed.template, parsed.database);
|
|
157
225
|
}
|
|
158
226
|
catch (error) {
|
|
159
227
|
// Handle unexpected errors with actionable guidance
|
|
@@ -185,4 +253,3 @@ async function main() {
|
|
|
185
253
|
}
|
|
186
254
|
// Run the CLI
|
|
187
255
|
main();
|
|
188
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
* CLI tool for bootstrapping new VeloxTS applications with multiple templates.
|
|
5
5
|
* Provides an interactive setup experience similar to create-next-app.
|
|
6
6
|
*/
|
|
7
|
-
import type { TemplateType } from './templates/index.js';
|
|
7
|
+
import type { DatabaseType, TemplateType } from './templates/index.js';
|
|
8
8
|
/** Create-velox-app package version */
|
|
9
9
|
export declare const CREATE_VERSION: string;
|
|
10
10
|
/**
|
|
11
11
|
* Main scaffolding function that creates a new VeloxTS project
|
|
12
12
|
*/
|
|
13
|
-
export declare function createVeloxApp(initialProjectName?: string, initialTemplate?: TemplateType): Promise<void>;
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
|
13
|
+
export declare function createVeloxApp(initialProjectName?: string, initialTemplate?: TemplateType, initialDatabase?: DatabaseType): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -56,7 +56,7 @@ function isPathSafe(baseDir, targetPath) {
|
|
|
56
56
|
/**
|
|
57
57
|
* Main scaffolding function that creates a new VeloxTS project
|
|
58
58
|
*/
|
|
59
|
-
export async function createVeloxApp(initialProjectName, initialTemplate) {
|
|
59
|
+
export async function createVeloxApp(initialProjectName, initialTemplate, initialDatabase) {
|
|
60
60
|
// Print welcome banner
|
|
61
61
|
console.log('');
|
|
62
62
|
p.intro(pc.cyan(pc.bold('create-velox-app')));
|
|
@@ -64,7 +64,7 @@ export async function createVeloxApp(initialProjectName, initialTemplate) {
|
|
|
64
64
|
let projectCreated = false;
|
|
65
65
|
try {
|
|
66
66
|
// Collect project configuration
|
|
67
|
-
const config = await promptProjectConfig(initialProjectName, initialTemplate);
|
|
67
|
+
const config = await promptProjectConfig(initialProjectName, initialTemplate, initialDatabase);
|
|
68
68
|
projectDirectory = config.directory;
|
|
69
69
|
// Show configuration summary
|
|
70
70
|
p.log.info(pc.dim('Configuration:'));
|
|
@@ -124,7 +124,7 @@ export async function createVeloxApp(initialProjectName, initialTemplate) {
|
|
|
124
124
|
/**
|
|
125
125
|
* Prompt user for project configuration
|
|
126
126
|
*/
|
|
127
|
-
async function promptProjectConfig(initialName, initialTemplate) {
|
|
127
|
+
async function promptProjectConfig(initialName, initialTemplate, initialDatabase) {
|
|
128
128
|
// Project name
|
|
129
129
|
const name = initialName
|
|
130
130
|
? initialName
|
|
@@ -172,10 +172,10 @@ async function promptProjectConfig(initialName, initialTemplate) {
|
|
|
172
172
|
}
|
|
173
173
|
template = selectedTemplate;
|
|
174
174
|
}
|
|
175
|
-
// Database selection
|
|
176
|
-
let database = 'sqlite';
|
|
177
|
-
// Only show database prompt in interactive mode (when
|
|
178
|
-
if (!initialTemplate) {
|
|
175
|
+
// Database selection
|
|
176
|
+
let database = initialDatabase ?? 'sqlite';
|
|
177
|
+
// Only show database prompt in interactive mode (when not provided via CLI)
|
|
178
|
+
if (!initialDatabase && !initialTemplate) {
|
|
179
179
|
const databases = getAvailableDatabases();
|
|
180
180
|
const selectedDatabase = await p.select({
|
|
181
181
|
message: 'Choose a database',
|
|
@@ -462,4 +462,3 @@ function printSuccessMessage(config) {
|
|
|
462
462
|
}
|
|
463
463
|
console.log('');
|
|
464
464
|
}
|
|
465
|
-
//# sourceMappingURL=index.js.map
|
package/dist/templates/auth.d.ts
CHANGED
package/dist/templates/auth.js
CHANGED
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
* Complete authentication system ready for production.
|
|
9
9
|
*/
|
|
10
10
|
import { compileTemplate } from './compiler.js';
|
|
11
|
-
import { AUTH_CONFIG } from './placeholders.js';
|
|
11
|
+
import { AUTH_CONFIG, applyDatabaseDependencies } from './placeholders.js';
|
|
12
12
|
import { generateRootFiles, generateWebBaseFiles, generateWebStyleFiles } from './shared/index.js';
|
|
13
13
|
// ============================================================================
|
|
14
14
|
// API Template Compilation
|
|
15
15
|
// ============================================================================
|
|
16
16
|
function generateApiPackageJson(config) {
|
|
17
|
-
|
|
17
|
+
const content = compileTemplate('api/package.auth.json', config);
|
|
18
|
+
return applyDatabaseDependencies(content, config);
|
|
18
19
|
}
|
|
19
20
|
function generateApiTsConfig() {
|
|
20
21
|
return compileTemplate('api/tsconfig.json', AUTH_CONFIG);
|
|
@@ -25,8 +26,8 @@ function generateApiTsupConfig() {
|
|
|
25
26
|
function generateEnvExample(config) {
|
|
26
27
|
return compileTemplate('api/env.auth', config);
|
|
27
28
|
}
|
|
28
|
-
function generatePrismaSchema() {
|
|
29
|
-
return compileTemplate('api/prisma/schema.auth.prisma',
|
|
29
|
+
function generatePrismaSchema(config) {
|
|
30
|
+
return compileTemplate('api/prisma/schema.auth.prisma', config);
|
|
30
31
|
}
|
|
31
32
|
function generatePrismaConfig() {
|
|
32
33
|
return compileTemplate('api/prisma.config.ts', AUTH_CONFIG);
|
|
@@ -52,8 +53,8 @@ function generateRouterTs() {
|
|
|
52
53
|
function generateRouterTypesTs() {
|
|
53
54
|
return compileTemplate('api/router.types.auth.ts', AUTH_CONFIG);
|
|
54
55
|
}
|
|
55
|
-
function generateConfigDatabase() {
|
|
56
|
-
return compileTemplate('api/config/database.ts',
|
|
56
|
+
function generateConfigDatabase(config) {
|
|
57
|
+
return compileTemplate('api/config/database.ts', config);
|
|
57
58
|
}
|
|
58
59
|
function generateHealthProcedures() {
|
|
59
60
|
return compileTemplate('api/procedures/health.ts', AUTH_CONFIG);
|
|
@@ -89,14 +90,14 @@ export function generateAuthTemplate(config) {
|
|
|
89
90
|
{ path: 'apps/api/.env.example', content: generateEnvExample(config) },
|
|
90
91
|
{ path: 'apps/api/.env', content: generateEnvExample(config) },
|
|
91
92
|
// Prisma
|
|
92
|
-
{ path: 'apps/api/prisma/schema.prisma', content: generatePrismaSchema() },
|
|
93
|
+
{ path: 'apps/api/prisma/schema.prisma', content: generatePrismaSchema(config) },
|
|
93
94
|
// API Source files
|
|
94
95
|
{ path: 'apps/api/src/router.ts', content: generateRouterTs() },
|
|
95
96
|
{ path: 'apps/api/src/router.types.ts', content: generateRouterTypesTs() },
|
|
96
97
|
{ path: 'apps/api/src/index.ts', content: generateIndexTs() },
|
|
97
98
|
{ path: 'apps/api/src/config/app.ts', content: generateConfigApp(config) },
|
|
98
99
|
{ path: 'apps/api/src/config/auth.ts', content: generateAuthConfig() },
|
|
99
|
-
{ path: 'apps/api/src/config/database.ts', content: generateConfigDatabase() },
|
|
100
|
+
{ path: 'apps/api/src/config/database.ts', content: generateConfigDatabase(config) },
|
|
100
101
|
{ path: 'apps/api/src/procedures/health.ts', content: generateHealthProcedures() },
|
|
101
102
|
{ path: 'apps/api/src/procedures/auth.ts', content: generateAuthProcedures() },
|
|
102
103
|
{ path: 'apps/api/src/procedures/users.ts', content: generateUserProceduresWithAuth() },
|
|
@@ -114,4 +115,3 @@ export function generateAuthTemplate(config) {
|
|
|
114
115
|
const webStyleFiles = generateWebStyleFiles();
|
|
115
116
|
return [...files, ...rootFiles, ...webBaseFiles, ...webStyleFiles];
|
|
116
117
|
}
|
|
117
|
-
//# sourceMappingURL=auth.js.map
|
|
@@ -78,7 +78,7 @@ export function readTemplateSource(relativePath) {
|
|
|
78
78
|
*/
|
|
79
79
|
export function compileTemplate(relativePath, config) {
|
|
80
80
|
const content = readTemplateSource(relativePath);
|
|
81
|
-
const withConditionals = processConditionals(content, config
|
|
81
|
+
const withConditionals = processConditionals(content, config);
|
|
82
82
|
return applyPlaceholders(withConditionals, config);
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
@@ -146,4 +146,3 @@ export function listSourceFiles(relativeDir) {
|
|
|
146
146
|
walkDir(dirPath, relativeDir);
|
|
147
147
|
return files;
|
|
148
148
|
}
|
|
149
|
-
//# sourceMappingURL=compiler.js.map
|
|
@@ -17,4 +17,3 @@ export declare function generateTemplateFiles(config: TemplateConfig): TemplateF
|
|
|
17
17
|
* Get directories that need to be created for the template
|
|
18
18
|
*/
|
|
19
19
|
export declare function getTemplateDirectories(template: TemplateType): string[];
|
|
20
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/templates/index.js
CHANGED
|
@@ -18,10 +18,20 @@ export declare const PLACEHOLDERS: {
|
|
|
18
18
|
readonly VELOXTS_VERSION: "__VELOXTS_VERSION__";
|
|
19
19
|
/** Package manager run command (npm run, pnpm, yarn) */
|
|
20
20
|
readonly RUN_CMD: "__RUN_CMD__";
|
|
21
|
+
/** Workspace command prefix for api package (e.g., "pnpm -F api", "npm run -w api") */
|
|
22
|
+
readonly WS_API: "__WS_API__";
|
|
23
|
+
/** Complete dev command for running api and web in parallel */
|
|
24
|
+
readonly DEV_CMD: "__DEV_CMD__";
|
|
25
|
+
/** Recursive run command (e.g., "pnpm -r", "npm run -ws") */
|
|
26
|
+
readonly WS_ALL: "__WS_ALL__";
|
|
21
27
|
/** API server port (default: 3030) */
|
|
22
28
|
readonly API_PORT: "__API_PORT__";
|
|
23
29
|
/** Web dev server port (default: 8080) */
|
|
24
30
|
readonly WEB_PORT: "__WEB_PORT__";
|
|
31
|
+
/** Database provider for Prisma schema (sqlite, postgresql) */
|
|
32
|
+
readonly DATABASE_PROVIDER: "__DATABASE_PROVIDER__";
|
|
33
|
+
/** Database URL for .env files */
|
|
34
|
+
readonly DATABASE_URL: "__DATABASE_URL__";
|
|
25
35
|
};
|
|
26
36
|
/**
|
|
27
37
|
* Default template configuration for templates that don't need real values.
|
|
@@ -59,6 +69,17 @@ export declare function applyPlaceholders(content: string, config: TemplateConfi
|
|
|
59
69
|
* Apply placeholders to JSON content (handles proper escaping).
|
|
60
70
|
*/
|
|
61
71
|
export declare function applyPlaceholdersToJson(content: Record<string, unknown>, config: TemplateConfig): string;
|
|
72
|
+
/**
|
|
73
|
+
* Apply database-specific dependency modifications to package.json content.
|
|
74
|
+
*
|
|
75
|
+
* - SQLite: Uses @prisma/adapter-better-sqlite3, better-sqlite3
|
|
76
|
+
* - PostgreSQL: Uses @prisma/adapter-pg, pg, @types/pg
|
|
77
|
+
*
|
|
78
|
+
* @param content - Raw package.json content string
|
|
79
|
+
* @param config - Template configuration with database choice
|
|
80
|
+
* @returns Modified package.json string with correct database dependencies
|
|
81
|
+
*/
|
|
82
|
+
export declare function applyDatabaseDependencies(content: string, config: TemplateConfig): string;
|
|
62
83
|
/**
|
|
63
84
|
* Conditional block markers for template-specific content.
|
|
64
85
|
* Use these in source files to mark sections that should only appear in certain templates.
|
|
@@ -72,13 +93,20 @@ export declare const CONDITIONALS: {
|
|
|
72
93
|
readonly JSX_AUTH_END: "{/* @endif auth */}";
|
|
73
94
|
readonly JSX_DEFAULT_START: "{/* @if default */}";
|
|
74
95
|
readonly JSX_DEFAULT_END: "{/* @endif default */}";
|
|
96
|
+
readonly SQLITE_START: "/* @if sqlite */";
|
|
97
|
+
readonly SQLITE_END: "/* @endif sqlite */";
|
|
98
|
+
readonly POSTGRESQL_START: "/* @if postgresql */";
|
|
99
|
+
readonly POSTGRESQL_END: "/* @endif postgresql */";
|
|
100
|
+
readonly JSX_SQLITE_START: "{/* @if sqlite */}";
|
|
101
|
+
readonly JSX_SQLITE_END: "{/* @endif sqlite */}";
|
|
102
|
+
readonly JSX_POSTGRESQL_START: "{/* @if postgresql */}";
|
|
103
|
+
readonly JSX_POSTGRESQL_END: "{/* @endif postgresql */}";
|
|
75
104
|
};
|
|
76
105
|
/**
|
|
77
106
|
* Process conditional blocks in template content.
|
|
78
107
|
*
|
|
79
108
|
* @param content - Template content with conditional blocks
|
|
80
|
-
* @param
|
|
109
|
+
* @param config - Template configuration (template type and database)
|
|
81
110
|
* @returns Content with appropriate blocks included/removed
|
|
82
111
|
*/
|
|
83
|
-
export declare function processConditionals(content: string,
|
|
84
|
-
//# sourceMappingURL=placeholders.d.ts.map
|
|
112
|
+
export declare function processConditionals(content: string, config: TemplateConfig): string;
|
|
@@ -21,10 +21,20 @@ export const PLACEHOLDERS = {
|
|
|
21
21
|
VELOXTS_VERSION: '__VELOXTS_VERSION__',
|
|
22
22
|
/** Package manager run command (npm run, pnpm, yarn) */
|
|
23
23
|
RUN_CMD: '__RUN_CMD__',
|
|
24
|
+
/** Workspace command prefix for api package (e.g., "pnpm -F api", "npm run -w api") */
|
|
25
|
+
WS_API: '__WS_API__',
|
|
26
|
+
/** Complete dev command for running api and web in parallel */
|
|
27
|
+
DEV_CMD: '__DEV_CMD__',
|
|
28
|
+
/** Recursive run command (e.g., "pnpm -r", "npm run -ws") */
|
|
29
|
+
WS_ALL: '__WS_ALL__',
|
|
24
30
|
/** API server port (default: 3030) */
|
|
25
31
|
API_PORT: '__API_PORT__',
|
|
26
32
|
/** Web dev server port (default: 8080) */
|
|
27
33
|
WEB_PORT: '__WEB_PORT__',
|
|
34
|
+
/** Database provider for Prisma schema (sqlite, postgresql) */
|
|
35
|
+
DATABASE_PROVIDER: '__DATABASE_PROVIDER__',
|
|
36
|
+
/** Database URL for .env files */
|
|
37
|
+
DATABASE_URL: '__DATABASE_URL__',
|
|
28
38
|
};
|
|
29
39
|
/**
|
|
30
40
|
* Default template configuration for templates that don't need real values.
|
|
@@ -76,6 +86,64 @@ export const RSC_CONFIG = {
|
|
|
76
86
|
function getRunCommand(packageManager) {
|
|
77
87
|
return packageManager === 'npm' ? 'npm run' : packageManager;
|
|
78
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Get the workspace command prefix for the api package.
|
|
91
|
+
* Used for commands like db:push, db:generate that target the api workspace.
|
|
92
|
+
*/
|
|
93
|
+
function getWsApiCommand(packageManager) {
|
|
94
|
+
switch (packageManager) {
|
|
95
|
+
case 'npm':
|
|
96
|
+
return 'npm run -w api';
|
|
97
|
+
case 'yarn':
|
|
98
|
+
return 'yarn workspace api';
|
|
99
|
+
case 'pnpm':
|
|
100
|
+
default:
|
|
101
|
+
return 'pnpm -F api';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get the complete dev command for running api and web in parallel.
|
|
106
|
+
* Note: npm doesn't support parallel workspace execution natively,
|
|
107
|
+
* so we use concurrently for npm users.
|
|
108
|
+
*/
|
|
109
|
+
function getDevCommand(packageManager) {
|
|
110
|
+
switch (packageManager) {
|
|
111
|
+
case 'npm':
|
|
112
|
+
// npm doesn't have built-in parallel execution for workspaces
|
|
113
|
+
// Use concurrently to run api and web dev servers in parallel
|
|
114
|
+
// Quotes are escaped for JSON compatibility
|
|
115
|
+
return 'concurrently \\"npm run -w api dev\\" \\"npm run -w web dev\\"';
|
|
116
|
+
case 'yarn':
|
|
117
|
+
return 'yarn workspaces foreach -A --parallel run dev';
|
|
118
|
+
case 'pnpm':
|
|
119
|
+
default:
|
|
120
|
+
return 'pnpm --parallel -r dev';
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get the recursive workspace run command.
|
|
125
|
+
* Used for running build across all workspaces.
|
|
126
|
+
*/
|
|
127
|
+
function getWsAllCommand(packageManager) {
|
|
128
|
+
switch (packageManager) {
|
|
129
|
+
case 'npm':
|
|
130
|
+
return 'npm run -ws --if-present';
|
|
131
|
+
case 'yarn':
|
|
132
|
+
return 'yarn workspaces foreach -A run';
|
|
133
|
+
case 'pnpm':
|
|
134
|
+
default:
|
|
135
|
+
return 'pnpm -r';
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get the default DATABASE_URL for the selected database.
|
|
140
|
+
*/
|
|
141
|
+
function getDatabaseUrl(database) {
|
|
142
|
+
if (database === 'postgresql') {
|
|
143
|
+
return 'postgresql://user:password@localhost:5432/myapp';
|
|
144
|
+
}
|
|
145
|
+
return 'file:./dev.db';
|
|
146
|
+
}
|
|
79
147
|
/**
|
|
80
148
|
* Apply placeholder replacements to template content.
|
|
81
149
|
*
|
|
@@ -92,8 +160,13 @@ export function applyPlaceholders(content, config) {
|
|
|
92
160
|
[PLACEHOLDERS.PACKAGE_MANAGER]: config.packageManager,
|
|
93
161
|
[PLACEHOLDERS.VELOXTS_VERSION]: VELOXTS_VERSION,
|
|
94
162
|
[PLACEHOLDERS.RUN_CMD]: getRunCommand(config.packageManager),
|
|
163
|
+
[PLACEHOLDERS.WS_API]: getWsApiCommand(config.packageManager),
|
|
164
|
+
[PLACEHOLDERS.DEV_CMD]: getDevCommand(config.packageManager),
|
|
165
|
+
[PLACEHOLDERS.WS_ALL]: getWsAllCommand(config.packageManager),
|
|
95
166
|
[PLACEHOLDERS.API_PORT]: '3030',
|
|
96
167
|
[PLACEHOLDERS.WEB_PORT]: '8080',
|
|
168
|
+
[PLACEHOLDERS.DATABASE_PROVIDER]: config.database,
|
|
169
|
+
[PLACEHOLDERS.DATABASE_URL]: getDatabaseUrl(config.database),
|
|
97
170
|
};
|
|
98
171
|
let result = content;
|
|
99
172
|
for (const [placeholder, value] of Object.entries(replacements)) {
|
|
@@ -108,6 +181,45 @@ export function applyPlaceholdersToJson(content, config) {
|
|
|
108
181
|
const jsonString = JSON.stringify(content, null, 2);
|
|
109
182
|
return applyPlaceholders(jsonString, config);
|
|
110
183
|
}
|
|
184
|
+
// Database adapter versions
|
|
185
|
+
const PRISMA_VERSION = '7.2.0';
|
|
186
|
+
const PG_VERSION = '8.16.0';
|
|
187
|
+
/**
|
|
188
|
+
* Apply database-specific dependency modifications to package.json content.
|
|
189
|
+
*
|
|
190
|
+
* - SQLite: Uses @prisma/adapter-better-sqlite3, better-sqlite3
|
|
191
|
+
* - PostgreSQL: Uses @prisma/adapter-pg, pg, @types/pg
|
|
192
|
+
*
|
|
193
|
+
* @param content - Raw package.json content string
|
|
194
|
+
* @param config - Template configuration with database choice
|
|
195
|
+
* @returns Modified package.json string with correct database dependencies
|
|
196
|
+
*/
|
|
197
|
+
export function applyDatabaseDependencies(content, config) {
|
|
198
|
+
const pkg = JSON.parse(content);
|
|
199
|
+
if (config.database === 'postgresql') {
|
|
200
|
+
// Remove SQLite dependencies
|
|
201
|
+
if (pkg.dependencies) {
|
|
202
|
+
delete pkg.dependencies['@prisma/adapter-better-sqlite3'];
|
|
203
|
+
delete pkg.dependencies['better-sqlite3'];
|
|
204
|
+
}
|
|
205
|
+
// Add PostgreSQL dependencies
|
|
206
|
+
pkg.dependencies = pkg.dependencies ?? {};
|
|
207
|
+
pkg.dependencies['@prisma/adapter-pg'] = PRISMA_VERSION;
|
|
208
|
+
pkg.dependencies.pg = PG_VERSION;
|
|
209
|
+
// Add @types/pg to devDependencies
|
|
210
|
+
pkg.devDependencies = pkg.devDependencies ?? {};
|
|
211
|
+
pkg.devDependencies['@types/pg'] = PG_VERSION;
|
|
212
|
+
// Sort dependencies alphabetically
|
|
213
|
+
if (pkg.dependencies) {
|
|
214
|
+
pkg.dependencies = Object.fromEntries(Object.entries(pkg.dependencies).sort(([a], [b]) => a.localeCompare(b)));
|
|
215
|
+
}
|
|
216
|
+
if (pkg.devDependencies) {
|
|
217
|
+
pkg.devDependencies = Object.fromEntries(Object.entries(pkg.devDependencies).sort(([a], [b]) => a.localeCompare(b)));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// SQLite is already the default in the source files, no changes needed
|
|
221
|
+
return JSON.stringify(pkg, null, 2);
|
|
222
|
+
}
|
|
111
223
|
// ============================================================================
|
|
112
224
|
// Conditional Content
|
|
113
225
|
// ============================================================================
|
|
@@ -122,15 +234,26 @@ function escapeRegex(str) {
|
|
|
122
234
|
* Use these in source files to mark sections that should only appear in certain templates.
|
|
123
235
|
*/
|
|
124
236
|
export const CONDITIONALS = {
|
|
237
|
+
// Template conditionals
|
|
125
238
|
AUTH_START: '/* @if auth */',
|
|
126
239
|
AUTH_END: '/* @endif auth */',
|
|
127
240
|
DEFAULT_START: '/* @if default */',
|
|
128
241
|
DEFAULT_END: '/* @endif default */',
|
|
129
|
-
// JSX-style conditionals (wrapped in braces)
|
|
242
|
+
// JSX-style template conditionals (wrapped in braces)
|
|
130
243
|
JSX_AUTH_START: '{/* @if auth */}',
|
|
131
244
|
JSX_AUTH_END: '{/* @endif auth */}',
|
|
132
245
|
JSX_DEFAULT_START: '{/* @if default */}',
|
|
133
246
|
JSX_DEFAULT_END: '{/* @endif default */}',
|
|
247
|
+
// Database conditionals
|
|
248
|
+
SQLITE_START: '/* @if sqlite */',
|
|
249
|
+
SQLITE_END: '/* @endif sqlite */',
|
|
250
|
+
POSTGRESQL_START: '/* @if postgresql */',
|
|
251
|
+
POSTGRESQL_END: '/* @endif postgresql */',
|
|
252
|
+
// JSX-style database conditionals
|
|
253
|
+
JSX_SQLITE_START: '{/* @if sqlite */}',
|
|
254
|
+
JSX_SQLITE_END: '{/* @endif sqlite */}',
|
|
255
|
+
JSX_POSTGRESQL_START: '{/* @if postgresql */}',
|
|
256
|
+
JSX_POSTGRESQL_END: '{/* @endif postgresql */}',
|
|
134
257
|
};
|
|
135
258
|
/** Pre-compiled regex for auth conditional blocks (performance optimization) */
|
|
136
259
|
const AUTH_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.AUTH_START)}[\\s\\S]*?${escapeRegex(CONDITIONALS.AUTH_END)}`, 'g');
|
|
@@ -140,15 +263,27 @@ const DEFAULT_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.DEFAULT_STA
|
|
|
140
263
|
const JSX_AUTH_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.JSX_AUTH_START)}[\\s\\S]*?${escapeRegex(CONDITIONALS.JSX_AUTH_END)}`, 'g');
|
|
141
264
|
/** Pre-compiled regex for JSX default conditional blocks */
|
|
142
265
|
const JSX_DEFAULT_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.JSX_DEFAULT_START)}[\\s\\S]*?${escapeRegex(CONDITIONALS.JSX_DEFAULT_END)}`, 'g');
|
|
266
|
+
/** Pre-compiled regex for sqlite conditional blocks */
|
|
267
|
+
const SQLITE_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.SQLITE_START)}[\\s\\S]*?${escapeRegex(CONDITIONALS.SQLITE_END)}`, 'g');
|
|
268
|
+
/** Pre-compiled regex for postgresql conditional blocks */
|
|
269
|
+
const POSTGRESQL_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.POSTGRESQL_START)}[\\s\\S]*?${escapeRegex(CONDITIONALS.POSTGRESQL_END)}`, 'g');
|
|
270
|
+
/** Pre-compiled regex for JSX sqlite conditional blocks */
|
|
271
|
+
const JSX_SQLITE_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.JSX_SQLITE_START)}[\\s\\S]*?${escapeRegex(CONDITIONALS.JSX_SQLITE_END)}`, 'g');
|
|
272
|
+
/** Pre-compiled regex for JSX postgresql conditional blocks */
|
|
273
|
+
const JSX_POSTGRESQL_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.JSX_POSTGRESQL_START)}[\\s\\S]*?${escapeRegex(CONDITIONALS.JSX_POSTGRESQL_END)}`, 'g');
|
|
143
274
|
/**
|
|
144
275
|
* Process conditional blocks in template content.
|
|
145
276
|
*
|
|
146
277
|
* @param content - Template content with conditional blocks
|
|
147
|
-
* @param
|
|
278
|
+
* @param config - Template configuration (template type and database)
|
|
148
279
|
* @returns Content with appropriate blocks included/removed
|
|
149
280
|
*/
|
|
150
|
-
export function processConditionals(content,
|
|
281
|
+
export function processConditionals(content, config) {
|
|
151
282
|
let result = content;
|
|
283
|
+
const { template, database } = config;
|
|
284
|
+
// =========================================================================
|
|
285
|
+
// Template conditionals
|
|
286
|
+
// =========================================================================
|
|
152
287
|
// Process auth conditionals (both JS and JSX style)
|
|
153
288
|
if (template === 'auth') {
|
|
154
289
|
// Keep auth content but remove markers
|
|
@@ -176,6 +311,34 @@ export function processConditionals(content, template) {
|
|
|
176
311
|
result = result.replace(DEFAULT_BLOCK_PATTERN, '');
|
|
177
312
|
result = result.replace(JSX_DEFAULT_BLOCK_PATTERN, '');
|
|
178
313
|
}
|
|
314
|
+
// =========================================================================
|
|
315
|
+
// Database conditionals
|
|
316
|
+
// =========================================================================
|
|
317
|
+
// Process sqlite conditionals
|
|
318
|
+
if (database === 'sqlite') {
|
|
319
|
+
// Keep sqlite content but remove markers
|
|
320
|
+
result = result.replaceAll(CONDITIONALS.SQLITE_START, '');
|
|
321
|
+
result = result.replaceAll(CONDITIONALS.SQLITE_END, '');
|
|
322
|
+
result = result.replaceAll(CONDITIONALS.JSX_SQLITE_START, '');
|
|
323
|
+
result = result.replaceAll(CONDITIONALS.JSX_SQLITE_END, '');
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
// Remove entire sqlite blocks
|
|
327
|
+
result = result.replace(SQLITE_BLOCK_PATTERN, '');
|
|
328
|
+
result = result.replace(JSX_SQLITE_BLOCK_PATTERN, '');
|
|
329
|
+
}
|
|
330
|
+
// Process postgresql conditionals
|
|
331
|
+
if (database === 'postgresql') {
|
|
332
|
+
// Keep postgresql content but remove markers
|
|
333
|
+
result = result.replaceAll(CONDITIONALS.POSTGRESQL_START, '');
|
|
334
|
+
result = result.replaceAll(CONDITIONALS.POSTGRESQL_END, '');
|
|
335
|
+
result = result.replaceAll(CONDITIONALS.JSX_POSTGRESQL_START, '');
|
|
336
|
+
result = result.replaceAll(CONDITIONALS.JSX_POSTGRESQL_END, '');
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
// Remove entire postgresql blocks
|
|
340
|
+
result = result.replace(POSTGRESQL_BLOCK_PATTERN, '');
|
|
341
|
+
result = result.replace(JSX_POSTGRESQL_BLOCK_PATTERN, '');
|
|
342
|
+
}
|
|
179
343
|
return result;
|
|
180
344
|
}
|
|
181
|
-
//# sourceMappingURL=placeholders.js.map
|
package/dist/templates/rsc.d.ts
CHANGED