UNPKG

@godspeedsystems/godspeed

Version:

Godspeed CLI

42 lines 1.82 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const cross_spawn_1 = __importDefault(require("cross-spawn")); const commander_1 = require("commander"); const glob_1 = require("glob"); const path_1 = __importDefault(require("path")); const __1 = require("../.."); const program = new commander_1.Command(); const prepareAction = async () => { // scan the prisma files try { // find all the .prisma files const availablePrismaFiles = (0, glob_1.globSync)(path_1.default .join(process.cwd(), "src/datasources/**/*.prisma") .replace(/\\/g, "/")); if (availablePrismaFiles.length) { // generate prisma client for each file and perform db sync availablePrismaFiles.map((prismaFilePath) => { const relativeFilePath = path_1.default.relative(process.cwd(), prismaFilePath); (0, cross_spawn_1.default)("npx", ["--yes", "prisma", "generate", `--schema=${relativeFilePath}`], { stdio: "inherit" }); (0, cross_spawn_1.default)("npx", ["--yes", "prisma", "db", "push", `--schema=${relativeFilePath}`], { stdio: "inherit" }); }); } else { return; } } catch (error) { } }; const prepare = program .command("prepare") .description("prepare your prisma database for use. (It generates your prisma client for database, and sync the database with the schema)") .action(async () => { if ((0, __1.isAGodspeedProject)()) { await prepareAction(); } }); exports.default = { prepare }; //# sourceMappingURL=index.js.map