create-init-mtv-app 1.0.0 → 1.0.1
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 +36 -0
- 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) {
|
|
@@ -379,6 +414,7 @@ async function createProject(answers) {
|
|
|
379
414
|
await setupNextEnv(projectName, isSupabase);
|
|
380
415
|
if (isSupabase) await setupNextSupabaseClient(projectName);
|
|
381
416
|
if (dbTool === DB_TOOLS.SUPABASE_JS_SDK) await setupNextSupabaseLocal(projectName);
|
|
417
|
+
if (dbTool === DB_TOOLS.DRIZZLE_ORM) await setupDrizzle(projectName);
|
|
382
418
|
if (uiLibrary === UI_LIB.SHADCN) await setupShadcn(projectName);
|
|
383
419
|
await setupBiome(projectName, uiLibrary === UI_LIB.SHADCN);
|
|
384
420
|
await setupJest(projectName);
|