Lines 307-373javascript
307 walk(full, join7(base, name));
309 const content = readFileSync5(full, "utf-8");
310 const rendered = render(content, config);
311 const targetRel = join7(TARGET_MAGIC_PATH3, relative4(ADAPTER_DIR3, full));
312 files.set(targetRel, rendered);
316 walk(ADAPTER_DIR3, "");
318 console.log(`[dry-run] VS Code adapter: ${files.size} files`);
323// src/cli/prisma-injector.ts
324import { resolve as resolve2, dirname as dirname6 } from "path";
325import { fileURLToPath as fileURLToPath5 } from "url";
327// src/caijuehub/strategies/prisma.strategy.ts
328import { spawnSync } from "child_process";
329import { copyFileSync, existsSync as existsSync4, readFileSync as readFileSync6, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
330import { resolve } from "path";
333 onExistingAddPrisma: "ask",
334 onMigrateFail: "rollback",
336 migrationName: "add_workflow_init",
337 schemaArg: "--schema=prisma/",
338 requiresUserModel: true
340async function injectPrisma(projectRoot, addPrismaTemplate, options = {}) {
341 const C = PRISMA_CONFIG;
342 const prismaDir = resolve(projectRoot, "prisma");
343 const schemaPath = resolve(prismaDir, "schema.prisma");
344 const destPath = resolve(prismaDir, "add.prisma");
345 if (!existsSync4(prismaDir) || !existsSync4(schemaPath)) {
346 if (C.onMissing === "skip") {
347 console.log("\u8DF3\u8FC7\uFF1A\u7F3A\u5C11 Prisma");
350 if (C.onMissing === "ask" && !options.force && !options.yes) {
351 const a = await ask("\u9879\u76EE\u7F3A\u5C11 Prisma\uFF0C\u662F\u5426\u6267\u884C prisma init\uFF1F[Y/n] ");
352 if (a !== "n" && a !== "no") {
353 console.log("\u6267\u884C npx prisma init ...");
354 spawnSync("npx", ["prisma", "init", "--datasource-provider", "postgresql"], { cwd: projectRoot, stdio: "inherit", shell: false });
355 const envPath = resolve(projectRoot, ".env");
HighRuntime Package Install
Package source invokes a package manager install command at runtime.
dist/index.jsView on unpkg · L353 356 const devEnvPath = resolve(projectRoot, ".env.development");
357 if (existsSync4(envPath)) {
358 const envContent = readFileSync6(envPath, "utf-8");
359 const dbUrl = envContent.match(/DATABASE_URL=.*/);
361 const existing = existsSync4(devEnvPath) ? readFileSync6(devEnvPath, "utf-8") : "";
362 if (!existing.includes("DATABASE_URL=")) {
363 writeFileSync2(devEnvPath, `${existing}${existing ? "\n" : ""}${dbUrl[0]}
366 if (existsSync4(envPath)) unlinkSync(envPath);
367 console.log("\u5DF2\u5C06 DATABASE_URL \u8FC1\u79FB\u5230 .env.development");
370 console.log("\u8BF7\u7F16\u8F91 .env.development \u914D\u7F6E DATABASE_URL\uFF0C\u7136\u540E\u91CD\u65B0\u8FD0\u884C add-coder init \u5B8C\u6210\u8FC1\u79FB");
371 console.log(" \u53EF\u9009\u6587\u4EF6\u4F18\u5148\u7EA7: .env.development.local > .env.development > .env.local > .env");
372 const schemaContent = readFileSync6(schemaPath, "utf-8");
373 if (!/model\s+User\s*\{/.test(schemaContent)) {