create-init-mtv-app 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +64 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -251,6 +251,41 @@ if (!parsed.success) {
|
|
|
251
251
|
export const sharedEnv = parsed.data;
|
|
252
252
|
`.trimStart();
|
|
253
253
|
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/setups/drizzle.ts
|
|
256
|
+
async function setupDrizzle(projectName) {
|
|
257
|
+
const schemasDir = path.join(projectName, "src", "backend", "db", "schemas");
|
|
258
|
+
const migrationsDir = path.join(projectName, "src", "backend", "db", "migrations");
|
|
259
|
+
const drizzleConfigPath = path.join(projectName, "src", "backend", "db", "drizzle.config.ts");
|
|
260
|
+
await Promise.all([
|
|
261
|
+
fs.ensureDir(schemasDir),
|
|
262
|
+
fs.ensureDir(migrationsDir),
|
|
263
|
+
fs.ensureFile(drizzleConfigPath)
|
|
264
|
+
]);
|
|
265
|
+
await fs.writeFile(drizzleConfigPath, drizzleConfigTemplate);
|
|
266
|
+
const packageJsonPath = path.join(projectName, "package.json");
|
|
267
|
+
const packageJson = await fs.readJson(packageJsonPath);
|
|
268
|
+
packageJson.scripts["db:generate"] = "npx drizzle-kit generate --config=./src/backend/db/drizzle.config.ts";
|
|
269
|
+
packageJson.scripts["db:migrate"] = "npx drizzle-kit push --config=./src/backend/db/drizzle.config.ts";
|
|
270
|
+
packageJson.scripts["db:studio"] = "npx drizzle-kit studio --verbose --config=./src/backend/db/drizzle.config.ts";
|
|
271
|
+
packageJson.scripts["db:pull"] = "npx drizzle-kit pull --config=./src/backend/db/drizzle.config.ts";
|
|
272
|
+
packageJson.scripts["db:check"] = "npx drizzle-kit check --config=./src/backend/db/drizzle.config.ts";
|
|
273
|
+
await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
|
|
274
|
+
}
|
|
275
|
+
const drizzleConfigTemplate = `import "server-only";
|
|
276
|
+
import { defineConfig } from "drizzle-kit";
|
|
277
|
+
import { serverEnv } from "../env.server";
|
|
278
|
+
|
|
279
|
+
export default defineConfig({
|
|
280
|
+
dialect: "postgresql",
|
|
281
|
+
schema: "./src/backend/db/schemas/*",
|
|
282
|
+
out: "./src/backend/db/migrations",
|
|
283
|
+
dbCredentials: {
|
|
284
|
+
url: serverEnv.DATABASE_URL,
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
`.trimStart();
|
|
288
|
+
|
|
254
289
|
//#endregion
|
|
255
290
|
//#region src/setups/shadcn.ts
|
|
256
291
|
async function setupShadcn(projectName) {
|
|
@@ -347,6 +382,30 @@ const config: Config = {
|
|
|
347
382
|
export default config;
|
|
348
383
|
`.trimStart();
|
|
349
384
|
|
|
385
|
+
//#endregion
|
|
386
|
+
//#region src/setups/docker_postges.ts
|
|
387
|
+
async function setupDockerPostgres(projectName) {
|
|
388
|
+
const dockerComposePath = path.join(projectName, "docker-compose.yml");
|
|
389
|
+
await fs.ensureFile(dockerComposePath);
|
|
390
|
+
await fs.writeFile(dockerComposePath, dockerComposeTemplate);
|
|
391
|
+
}
|
|
392
|
+
const dockerComposeTemplate = `
|
|
393
|
+
version: '3'
|
|
394
|
+
services:
|
|
395
|
+
postgres:
|
|
396
|
+
image: postgres:17
|
|
397
|
+
ports:
|
|
398
|
+
- 5432:5432
|
|
399
|
+
environment:
|
|
400
|
+
- POSTGRES_USER=postgres
|
|
401
|
+
- POSTGRES_PASSWORD=postgres
|
|
402
|
+
- POSTGRES_DB=postgres
|
|
403
|
+
volumes:
|
|
404
|
+
- postgres_data:/var/lib/postgresql/data
|
|
405
|
+
volumes:
|
|
406
|
+
postgres_data:
|
|
407
|
+
`;
|
|
408
|
+
|
|
350
409
|
//#endregion
|
|
351
410
|
//#region src/create.ts
|
|
352
411
|
async function createProject(answers) {
|
|
@@ -354,7 +413,6 @@ async function createProject(answers) {
|
|
|
354
413
|
switch (framework) {
|
|
355
414
|
case FRAMEWORKS.NEXT: {
|
|
356
415
|
await createNextApp(projectName);
|
|
357
|
-
const isSupabase = dbProvider === DB_PROVIDERS.SUPABASE;
|
|
358
416
|
const dependencies = [
|
|
359
417
|
"react-hook-form",
|
|
360
418
|
"@hookform/resolvers",
|
|
@@ -368,7 +426,7 @@ async function createProject(answers) {
|
|
|
368
426
|
"@types/jest",
|
|
369
427
|
"ts-jest"
|
|
370
428
|
];
|
|
371
|
-
if (
|
|
429
|
+
if (dbProvider === DB_PROVIDERS.SUPABASE) dependencies.push("@supabase/ssr", "@supabase/supabase-js");
|
|
372
430
|
if (dbTool === DB_TOOLS.DRIZZLE_ORM) {
|
|
373
431
|
dependencies.push("drizzle-orm", "postgres");
|
|
374
432
|
devDependencies.push("drizzle-kit");
|
|
@@ -376,9 +434,11 @@ async function createProject(answers) {
|
|
|
376
434
|
await installDependencies(projectName, dependencies);
|
|
377
435
|
await installDevDependencies(projectName, devDependencies);
|
|
378
436
|
await setupHuskyLintStaged(projectName);
|
|
379
|
-
await setupNextEnv(projectName,
|
|
380
|
-
if (
|
|
437
|
+
await setupNextEnv(projectName, dbProvider === DB_PROVIDERS.SUPABASE);
|
|
438
|
+
if (dbProvider === DB_PROVIDERS.SUPABASE) await setupNextSupabaseClient(projectName);
|
|
439
|
+
if (dbProvider === DB_PROVIDERS.DOCKER) await setupDockerPostgres(projectName);
|
|
381
440
|
if (dbTool === DB_TOOLS.SUPABASE_JS_SDK) await setupNextSupabaseLocal(projectName);
|
|
441
|
+
if (dbTool === DB_TOOLS.DRIZZLE_ORM) await setupDrizzle(projectName);
|
|
382
442
|
if (uiLibrary === UI_LIB.SHADCN) await setupShadcn(projectName);
|
|
383
443
|
await setupBiome(projectName, uiLibrary === UI_LIB.SHADCN);
|
|
384
444
|
await setupJest(projectName);
|