create-prisma 0.4.2-next.37.94.1 → 0.4.2-next.37.98.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/cli.mjs +1 -1
- package/dist/{create-DgTPw_xS.mjs → create-C5pPk2G0.mjs} +289 -98
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/templates/create/astro/README.md.hbs +3 -2
- package/templates/create/elysia/README.md.hbs +3 -2
- package/templates/create/hono/README.md.hbs +3 -2
- package/templates/create/minimal/README.md.hbs +3 -2
- package/templates/create/nest/README.md.hbs +3 -2
- package/templates/create/next/README.md.hbs +3 -2
- package/templates/create/nuxt/README.md.hbs +3 -2
- package/templates/create/svelte/README.md.hbs +3 -2
- package/templates/create/tanstack-start/README.md.hbs +3 -2
package/dist/cli.mjs
CHANGED
|
@@ -49,7 +49,7 @@ async function getAnonymousId() {
|
|
|
49
49
|
}
|
|
50
50
|
function getCommonProperties() {
|
|
51
51
|
return {
|
|
52
|
-
"cli-version": "0.4.2-next.37.
|
|
52
|
+
"cli-version": "0.4.2-next.37.98.1",
|
|
53
53
|
"node-version": process.version,
|
|
54
54
|
platform: process.platform,
|
|
55
55
|
arch: process.arch
|
|
@@ -137,60 +137,6 @@ async function trackCreateFailed(params) {
|
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
//#endregion
|
|
141
|
-
//#region src/utils/runtime.ts
|
|
142
|
-
function usesNodeStyleRuntime(packageManager) {
|
|
143
|
-
return packageManager !== void 0 && packageManager !== "bun" && packageManager !== "deno";
|
|
144
|
-
}
|
|
145
|
-
function requiresDotenvConfigImport(packageManager) {
|
|
146
|
-
return usesNodeStyleRuntime(packageManager);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
//#endregion
|
|
150
|
-
//#region src/constants/dependencies.ts
|
|
151
|
-
const dependencyVersionMap = {
|
|
152
|
-
"@elysiajs/node": "^1.4.5",
|
|
153
|
-
"@types/node": "^25.6.2",
|
|
154
|
-
dotenv: "^17.4.2",
|
|
155
|
-
tsx: "^4.21.0"
|
|
156
|
-
};
|
|
157
|
-
const PRISMA_NEXT_PACKAGE_VERSION = "latest";
|
|
158
|
-
function isPrismaNextPackage(packageName) {
|
|
159
|
-
return packageName === "prisma-next" || packageName.startsWith("@prisma-next/");
|
|
160
|
-
}
|
|
161
|
-
function getPrismaNextPackageSpecifier(packageName) {
|
|
162
|
-
return `${packageName}@${PRISMA_NEXT_PACKAGE_VERSION}`;
|
|
163
|
-
}
|
|
164
|
-
function getDependencyVersion(packageName) {
|
|
165
|
-
if (isPrismaNextPackage(packageName)) return PRISMA_NEXT_PACKAGE_VERSION;
|
|
166
|
-
return dependencyVersionMap[packageName];
|
|
167
|
-
}
|
|
168
|
-
function usesViteDevServer(template) {
|
|
169
|
-
return template === "astro" || template === "nuxt" || template === "svelte" || template === "tanstack-start";
|
|
170
|
-
}
|
|
171
|
-
function getCreateTemplateDependencies(template, packageManager) {
|
|
172
|
-
const targets = [];
|
|
173
|
-
if (usesViteDevServer(template)) targets.push({
|
|
174
|
-
packageJsonPath: "package.json",
|
|
175
|
-
dependencies: [],
|
|
176
|
-
devDependencies: ["@prisma-next/vite-plugin-contract-emit"]
|
|
177
|
-
});
|
|
178
|
-
if (template === "minimal" || template === "hono" || template === "elysia" || template === "nest") {
|
|
179
|
-
const runtimeDevDependencies = usesNodeStyleRuntime(packageManager) ? ["tsx"] : [];
|
|
180
|
-
if (template === "elysia" && packageManager !== "deno") targets.push({
|
|
181
|
-
packageJsonPath: "package.json",
|
|
182
|
-
dependencies: ["@elysiajs/node"],
|
|
183
|
-
devDependencies: ["@types/node", ...runtimeDevDependencies]
|
|
184
|
-
});
|
|
185
|
-
else if (runtimeDevDependencies.length > 0) targets.push({
|
|
186
|
-
packageJsonPath: "package.json",
|
|
187
|
-
dependencies: [],
|
|
188
|
-
devDependencies: runtimeDevDependencies
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
return targets;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
140
|
//#endregion
|
|
195
141
|
//#region src/types.ts
|
|
196
142
|
const databaseProviderInputs = [
|
|
@@ -328,11 +274,18 @@ function getPackageManagerManifestValue(packageManager) {
|
|
|
328
274
|
if (!packageManager || packageManager === "deno") return;
|
|
329
275
|
return packageManagerManifestValues[packageManager];
|
|
330
276
|
}
|
|
277
|
+
function getDenoPrismaSpecifier() {
|
|
278
|
+
return "npm:prisma-next";
|
|
279
|
+
}
|
|
280
|
+
function getDenoNpmSpecifier(packageSpecifier) {
|
|
281
|
+
return `npm:${packageSpecifier.replace(/@latest$/, "")}`;
|
|
282
|
+
}
|
|
331
283
|
function getDenoAllowedScriptSpecifiers() {
|
|
332
284
|
return [
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
285
|
+
"npm:prisma-next",
|
|
286
|
+
"npm:@prisma-next/postgres",
|
|
287
|
+
"npm:@prisma-next/mongo",
|
|
288
|
+
"npm:mongodb-memory-server"
|
|
336
289
|
].join(",");
|
|
337
290
|
}
|
|
338
291
|
function getInstallCommand(packageManager) {
|
|
@@ -416,7 +369,7 @@ function getPackageExecutionArgs(packageManager, commandArgs) {
|
|
|
416
369
|
args: [
|
|
417
370
|
"run",
|
|
418
371
|
"-A",
|
|
419
|
-
|
|
372
|
+
getDenoNpmSpecifier(packageName),
|
|
420
373
|
...args
|
|
421
374
|
]
|
|
422
375
|
};
|
|
@@ -474,6 +427,15 @@ function getLocalPackageBinaryCommand(packageManager, binaryName, binaryArgs) {
|
|
|
474
427
|
return [execution.command, ...execution.args].join(" ");
|
|
475
428
|
}
|
|
476
429
|
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/utils/runtime.ts
|
|
432
|
+
function usesNodeStyleRuntime(packageManager) {
|
|
433
|
+
return packageManager !== void 0 && packageManager !== "bun" && packageManager !== "deno";
|
|
434
|
+
}
|
|
435
|
+
function requiresDotenvConfigImport(packageManager) {
|
|
436
|
+
return usesNodeStyleRuntime(packageManager);
|
|
437
|
+
}
|
|
438
|
+
|
|
477
439
|
//#endregion
|
|
478
440
|
//#region src/templates/shared.ts
|
|
479
441
|
function getOptionalHashString(hash, key) {
|
|
@@ -585,6 +547,52 @@ async function scaffoldCreateTemplate(opts) {
|
|
|
585
547
|
});
|
|
586
548
|
}
|
|
587
549
|
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region src/constants/dependencies.ts
|
|
552
|
+
const dependencyVersionMap = {
|
|
553
|
+
"@elysiajs/node": "^1.4.5",
|
|
554
|
+
"@types/node": "^25.6.2",
|
|
555
|
+
dotenv: "^17.4.2",
|
|
556
|
+
"mongodb-memory-server": "^11.1.0",
|
|
557
|
+
tsx: "^4.21.0"
|
|
558
|
+
};
|
|
559
|
+
const PRISMA_NEXT_PACKAGE_VERSION = "latest";
|
|
560
|
+
function isPrismaNextPackage(packageName) {
|
|
561
|
+
return packageName === "prisma-next" || packageName.startsWith("@prisma-next/");
|
|
562
|
+
}
|
|
563
|
+
function getPrismaNextPackageSpecifier(packageName) {
|
|
564
|
+
return `${packageName}@${PRISMA_NEXT_PACKAGE_VERSION}`;
|
|
565
|
+
}
|
|
566
|
+
function getDependencyVersion(packageName) {
|
|
567
|
+
if (isPrismaNextPackage(packageName)) return PRISMA_NEXT_PACKAGE_VERSION;
|
|
568
|
+
return dependencyVersionMap[packageName];
|
|
569
|
+
}
|
|
570
|
+
function usesViteDevServer(template) {
|
|
571
|
+
return template === "astro" || template === "nuxt" || template === "svelte" || template === "tanstack-start";
|
|
572
|
+
}
|
|
573
|
+
function getCreateTemplateDependencies(template, packageManager) {
|
|
574
|
+
const targets = [];
|
|
575
|
+
if (usesViteDevServer(template)) targets.push({
|
|
576
|
+
packageJsonPath: "package.json",
|
|
577
|
+
dependencies: [],
|
|
578
|
+
devDependencies: ["@prisma-next/vite-plugin-contract-emit"]
|
|
579
|
+
});
|
|
580
|
+
if (template === "minimal" || template === "hono" || template === "elysia" || template === "nest") {
|
|
581
|
+
const runtimeDevDependencies = usesNodeStyleRuntime(packageManager) ? ["tsx"] : [];
|
|
582
|
+
if (template === "elysia" && packageManager !== "deno") targets.push({
|
|
583
|
+
packageJsonPath: "package.json",
|
|
584
|
+
dependencies: ["@elysiajs/node"],
|
|
585
|
+
devDependencies: ["@types/node", ...runtimeDevDependencies]
|
|
586
|
+
});
|
|
587
|
+
else if (runtimeDevDependencies.length > 0) targets.push({
|
|
588
|
+
packageJsonPath: "package.json",
|
|
589
|
+
dependencies: [],
|
|
590
|
+
devDependencies: runtimeDevDependencies
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
return targets;
|
|
594
|
+
}
|
|
595
|
+
|
|
588
596
|
//#endregion
|
|
589
597
|
//#region src/constants/db-packages.ts
|
|
590
598
|
function getDbPackages(provider, _packageManager) {
|
|
@@ -602,7 +610,7 @@ function getDbPackages(provider, _packageManager) {
|
|
|
602
610
|
//#region src/tasks/install.ts
|
|
603
611
|
function getPrismaNextScriptMap(packageManager) {
|
|
604
612
|
if (packageManager === "deno") {
|
|
605
|
-
const prismaNextCli = `deno run -A --env-file=.env
|
|
613
|
+
const prismaNextCli = `deno run -A --env-file=.env ${getDenoPrismaSpecifier()}`;
|
|
606
614
|
return {
|
|
607
615
|
"contract:emit": `${prismaNextCli} contract emit`,
|
|
608
616
|
"db:init": `${prismaNextCli} db init`,
|
|
@@ -816,32 +824,201 @@ const DEFAULT_INSTALL = true;
|
|
|
816
824
|
const DEFAULT_EMIT = true;
|
|
817
825
|
const DEFAULT_INTERACTIVE_PRISMA_POSTGRES = true;
|
|
818
826
|
const DEFAULT_AUTOMATED_PRISMA_POSTGRES = false;
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
start_period: 5s
|
|
827
|
+
const MONGO_MEMORY_SERVER_SCRIPT = `import { spawn } from "node:child_process";
|
|
828
|
+
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
829
|
+
import path from "node:path";
|
|
830
|
+
|
|
831
|
+
const defaultDatabaseUrl = "mongodb://localhost:27017/mydb?replicaSet=rs0&directConnection=true";
|
|
832
|
+
const dataRoot = path.resolve(process.env.MONGO_DB_PATH ?? ".mongo-data");
|
|
833
|
+
const dbPath = path.join(dataRoot, "db");
|
|
834
|
+
const pidFile = path.join(dataRoot, "mongo.pid");
|
|
835
|
+
const logFile = path.join(dataRoot, "mongo.log");
|
|
836
|
+
const readyTimeoutMs = Number(process.env.MONGO_READY_TIMEOUT_MS ?? 60_000);
|
|
837
|
+
|
|
838
|
+
function getMongoConfig() {
|
|
839
|
+
const databaseUrl = process.env.DATABASE_URL ?? defaultDatabaseUrl;
|
|
840
|
+
const url = new URL(databaseUrl);
|
|
841
|
+
if (url.protocol !== "mongodb:") {
|
|
842
|
+
throw new Error("DATABASE_URL must use the mongodb:// protocol.");
|
|
843
|
+
}
|
|
837
844
|
|
|
838
|
-
|
|
839
|
-
|
|
845
|
+
const port = Number(url.port || "27017");
|
|
846
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
847
|
+
throw new Error(\`DATABASE_URL has an invalid MongoDB port: \${url.port}\`);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
return {
|
|
851
|
+
databaseUrl,
|
|
852
|
+
port,
|
|
853
|
+
replSetName: url.searchParams.get("replicaSet") || "rs0",
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
function readPid() {
|
|
858
|
+
if (!existsSync(pidFile)) return null;
|
|
859
|
+
const raw = readFileSync(pidFile, "utf8").trim();
|
|
860
|
+
const pid = Number(raw);
|
|
861
|
+
return Number.isFinite(pid) && pid > 0 ? pid : null;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
function isAlive(pid) {
|
|
865
|
+
try {
|
|
866
|
+
process.kill(pid, 0);
|
|
867
|
+
return true;
|
|
868
|
+
} catch {
|
|
869
|
+
return false;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
function getChildCommand() {
|
|
874
|
+
const scriptPath = path.resolve(process.argv[1] ?? "");
|
|
875
|
+
const versions = process.versions;
|
|
876
|
+
if (versions.deno) return { command: process.execPath, args: ["run", "-A", scriptPath, "_run"] };
|
|
877
|
+
return { command: process.execPath, args: [scriptPath, "_run"] };
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
async function runServer() {
|
|
881
|
+
mkdirSync(dbPath, { recursive: true });
|
|
882
|
+
const config = getMongoConfig();
|
|
883
|
+
const memoryServer = await import("mongodb-memory-server");
|
|
884
|
+
const { MongoMemoryReplSet } = memoryServer.default ?? memoryServer;
|
|
885
|
+
const replSet = await MongoMemoryReplSet.create({
|
|
886
|
+
replSet: { name: config.replSetName, count: 1 },
|
|
887
|
+
instanceOpts: [{ port: config.port, storageEngine: "wiredTiger", dbPath }],
|
|
888
|
+
});
|
|
889
|
+
console.log(\`MongoDB server ready for \${config.databaseUrl}\`);
|
|
890
|
+
console.log(\`Data directory: \${dbPath}\`);
|
|
891
|
+
const shutdown = async () => {
|
|
892
|
+
await replSet.stop();
|
|
893
|
+
process.exit(0);
|
|
894
|
+
};
|
|
895
|
+
process.on("SIGINT", shutdown);
|
|
896
|
+
process.on("SIGTERM", shutdown);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
async function up() {
|
|
900
|
+
mkdirSync(dataRoot, { recursive: true });
|
|
901
|
+
const existing = readPid();
|
|
902
|
+
if (existing !== null && isAlive(existing)) {
|
|
903
|
+
console.log(\`MongoDB is already running (PID \${existing}). Use \\\`db:down\\\` to stop.\`);
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
if (existing !== null) rmSync(pidFile, { force: true });
|
|
907
|
+
|
|
908
|
+
writeFileSync(logFile, "");
|
|
909
|
+
const logFd = openSync(logFile, "a");
|
|
910
|
+
const { command, args } = getChildCommand();
|
|
911
|
+
const child = spawn(
|
|
912
|
+
command,
|
|
913
|
+
args,
|
|
914
|
+
{
|
|
915
|
+
detached: true,
|
|
916
|
+
stdio: ["ignore", logFd, logFd],
|
|
917
|
+
env: process.env,
|
|
918
|
+
},
|
|
919
|
+
);
|
|
920
|
+
closeSync(logFd);
|
|
921
|
+
if (typeof child.pid !== "number") throw new Error("Failed to spawn MongoDB child process.");
|
|
922
|
+
writeFileSync(pidFile, String(child.pid));
|
|
923
|
+
child.unref();
|
|
924
|
+
|
|
925
|
+
const start = Date.now();
|
|
926
|
+
while (Date.now() - start < readyTimeoutMs) {
|
|
927
|
+
if (!isAlive(child.pid)) {
|
|
928
|
+
console.error("MongoDB failed to start:");
|
|
929
|
+
console.error(readFileSync(logFile, "utf8"));
|
|
930
|
+
rmSync(pidFile, { force: true });
|
|
931
|
+
process.exit(1);
|
|
932
|
+
}
|
|
933
|
+
const log = readFileSync(logFile, "utf8");
|
|
934
|
+
if (log.includes("MongoDB server ready")) {
|
|
935
|
+
for (const line of log.split("\\n")) {
|
|
936
|
+
if (line.trim().length > 0) console.log(line);
|
|
937
|
+
}
|
|
938
|
+
console.log(\`Detached (PID \${child.pid}). Logs: \${logFile}\`);
|
|
939
|
+
console.log("Stop with \`db:down\` or wipe with \`db:reset\`.");
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
943
|
+
}
|
|
944
|
+
console.error(\`Timed out waiting for MongoDB after \${readyTimeoutMs}ms.\`);
|
|
945
|
+
console.error(readFileSync(logFile, "utf8"));
|
|
946
|
+
try {
|
|
947
|
+
process.kill(child.pid, "SIGTERM");
|
|
948
|
+
} catch {
|
|
949
|
+
// ignore
|
|
950
|
+
}
|
|
951
|
+
rmSync(pidFile, { force: true });
|
|
952
|
+
process.exit(1);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
async function down(wipe) {
|
|
956
|
+
const pid = readPid();
|
|
957
|
+
if (pid !== null && isAlive(pid)) {
|
|
958
|
+
process.kill(pid, "SIGTERM");
|
|
959
|
+
const deadline = Date.now() + 10_000;
|
|
960
|
+
while (Date.now() < deadline && isAlive(pid)) {
|
|
961
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
962
|
+
}
|
|
963
|
+
if (isAlive(pid)) {
|
|
964
|
+
console.warn(\`MongoDB (PID \${pid}) did not exit within 10s; sending SIGKILL.\`);
|
|
965
|
+
try {
|
|
966
|
+
process.kill(pid, "SIGKILL");
|
|
967
|
+
} catch {
|
|
968
|
+
// ignore
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
console.log(\`Stopped MongoDB (PID \${pid}).\`);
|
|
972
|
+
} else if (pid !== null) {
|
|
973
|
+
console.log("MongoDB was not running (stale PID file).");
|
|
974
|
+
} else {
|
|
975
|
+
console.log("MongoDB is not running.");
|
|
976
|
+
}
|
|
977
|
+
rmSync(pidFile, { force: true });
|
|
978
|
+
if (wipe) {
|
|
979
|
+
rmSync(dataRoot, { recursive: true, force: true });
|
|
980
|
+
console.log(\`Removed \${dataRoot}.\`);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
const cmd = process.argv[2] ?? "up";
|
|
985
|
+
switch (cmd) {
|
|
986
|
+
case "up":
|
|
987
|
+
await up();
|
|
988
|
+
break;
|
|
989
|
+
case "down":
|
|
990
|
+
await down(false);
|
|
991
|
+
break;
|
|
992
|
+
case "reset":
|
|
993
|
+
await down(true);
|
|
994
|
+
break;
|
|
995
|
+
case "_run":
|
|
996
|
+
await runServer();
|
|
997
|
+
break;
|
|
998
|
+
default:
|
|
999
|
+
console.error(\`Unknown command: \${cmd}. Use: up | down | reset\`);
|
|
1000
|
+
process.exit(2);
|
|
1001
|
+
}
|
|
840
1002
|
`;
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
1003
|
+
function getMongoMemoryScripts(packageManager) {
|
|
1004
|
+
switch (packageManager) {
|
|
1005
|
+
case "bun": return {
|
|
1006
|
+
"db:up": "bun --env-file=.env scripts/mongo.mjs up",
|
|
1007
|
+
"db:down": "bun --env-file=.env scripts/mongo.mjs down",
|
|
1008
|
+
"db:reset": "bun --env-file=.env scripts/mongo.mjs reset"
|
|
1009
|
+
};
|
|
1010
|
+
case "deno": return {
|
|
1011
|
+
"db:up": "deno run -A --env-file=.env scripts/mongo.mjs up",
|
|
1012
|
+
"db:down": "deno run -A --env-file=.env scripts/mongo.mjs down",
|
|
1013
|
+
"db:reset": "deno run -A --env-file=.env scripts/mongo.mjs reset"
|
|
1014
|
+
};
|
|
1015
|
+
default: return {
|
|
1016
|
+
"db:up": "node --env-file=.env scripts/mongo.mjs up",
|
|
1017
|
+
"db:down": "node --env-file=.env scripts/mongo.mjs down",
|
|
1018
|
+
"db:reset": "node --env-file=.env scripts/mongo.mjs reset"
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
845
1022
|
const requiredPrismaFileGroups = [
|
|
846
1023
|
["prisma/contract.prisma", "prisma/contract.ts"],
|
|
847
1024
|
["prisma-next.config.ts"],
|
|
@@ -1101,16 +1278,30 @@ async function ensurePackageScripts(projectDir, scripts) {
|
|
|
1101
1278
|
}
|
|
1102
1279
|
if (didChange) await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
|
|
1103
1280
|
}
|
|
1104
|
-
async function
|
|
1105
|
-
const
|
|
1106
|
-
if (await fs.pathExists(
|
|
1107
|
-
await fs.
|
|
1281
|
+
async function ensureMongoMemoryServerScript(projectDir) {
|
|
1282
|
+
const scriptPath = path.join(projectDir, "scripts", "mongo.mjs");
|
|
1283
|
+
if (await fs.pathExists(scriptPath)) return;
|
|
1284
|
+
await fs.ensureDir(path.dirname(scriptPath));
|
|
1285
|
+
await fs.writeFile(scriptPath, MONGO_MEMORY_SERVER_SCRIPT, "utf8");
|
|
1108
1286
|
}
|
|
1109
|
-
async function
|
|
1287
|
+
async function ensureMongoMemoryServerDevDependency(projectDir) {
|
|
1288
|
+
const packageJsonPath = path.join(projectDir, "package.json");
|
|
1289
|
+
if (!await fs.pathExists(packageJsonPath)) return;
|
|
1290
|
+
const packageJson = await fs.readJson(packageJsonPath);
|
|
1291
|
+
if (!packageJson.devDependencies) packageJson.devDependencies = {};
|
|
1292
|
+
const memoryServerVersion = getDependencyVersion("mongodb-memory-server");
|
|
1293
|
+
if (packageJson.devDependencies["mongodb-memory-server"] === memoryServerVersion) return;
|
|
1294
|
+
packageJson.devDependencies["mongodb-memory-server"] = memoryServerVersion;
|
|
1295
|
+
packageJson.devDependencies = Object.fromEntries(Object.entries(packageJson.devDependencies).sort(([a], [b]) => a.localeCompare(b)));
|
|
1296
|
+
await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
|
|
1297
|
+
}
|
|
1298
|
+
async function writeMongoLocalHelpersForContext(context, projectDir) {
|
|
1110
1299
|
if (context.databaseProvider !== "mongo" || context.databaseUrl) return true;
|
|
1111
1300
|
try {
|
|
1112
|
-
await
|
|
1113
|
-
await
|
|
1301
|
+
await ensureMongoMemoryServerScript(projectDir);
|
|
1302
|
+
await ensureMongoMemoryServerDevDependency(projectDir);
|
|
1303
|
+
await ensurePackageScripts(projectDir, getMongoMemoryScripts(context.packageManager));
|
|
1304
|
+
await ensureGitignoreEntry(projectDir, ".mongo-data");
|
|
1114
1305
|
return true;
|
|
1115
1306
|
} catch (error) {
|
|
1116
1307
|
cancel(getCommandErrorMessage(error));
|
|
@@ -1263,7 +1454,7 @@ async function finalizePrismaFilesForContext(context, projectDir, provisionResul
|
|
|
1263
1454
|
}
|
|
1264
1455
|
}
|
|
1265
1456
|
function getPrismaNextCliCommand(packageManager, prismaNextArgs) {
|
|
1266
|
-
if (packageManager === "deno") return `deno run -A --env-file=.env
|
|
1457
|
+
if (packageManager === "deno") return `deno run -A --env-file=.env ${getDenoPrismaSpecifier()} ${prismaNextArgs.join(" ")}`;
|
|
1267
1458
|
return getLocalPackageBinaryCommand(packageManager, "prisma-next", prismaNextArgs);
|
|
1268
1459
|
}
|
|
1269
1460
|
function getPrismaNextCliArgs(packageManager, prismaNextArgs) {
|
|
@@ -1273,7 +1464,7 @@ function getPrismaNextCliArgs(packageManager, prismaNextArgs) {
|
|
|
1273
1464
|
"run",
|
|
1274
1465
|
"-A",
|
|
1275
1466
|
"--env-file=.env",
|
|
1276
|
-
|
|
1467
|
+
getDenoPrismaSpecifier(),
|
|
1277
1468
|
...prismaNextArgs
|
|
1278
1469
|
]
|
|
1279
1470
|
};
|
|
@@ -1326,7 +1517,7 @@ function buildNextStepsForContext(opts) {
|
|
|
1326
1517
|
});
|
|
1327
1518
|
if (context.databaseProvider === "mongo" && !context.databaseUrl) nextSteps.push({
|
|
1328
1519
|
command: getRunScriptCommand(context.packageManager, "db:up"),
|
|
1329
|
-
description: "Start the local MongoDB replica set with
|
|
1520
|
+
description: "Start the local MongoDB replica set with mongodb-memory-server. Stop with `db:down`, wipe with `db:reset`."
|
|
1330
1521
|
});
|
|
1331
1522
|
nextSteps.push({
|
|
1332
1523
|
command: getRunScriptCommand(context.packageManager, "migration:plan"),
|
|
@@ -1381,6 +1572,10 @@ async function executePrismaSetupContext(context, options = {}) {
|
|
|
1381
1572
|
stopProgressOnFailure();
|
|
1382
1573
|
return false;
|
|
1383
1574
|
}
|
|
1575
|
+
if (!await writeMongoLocalHelpersForContext(context, projectDir)) {
|
|
1576
|
+
stopProgressOnFailure();
|
|
1577
|
+
return false;
|
|
1578
|
+
}
|
|
1384
1579
|
if (context.shouldInstall) progressSpinner?.message("Installing dependencies...");
|
|
1385
1580
|
if (!await installDependenciesForContext(context, projectDir)) {
|
|
1386
1581
|
stopProgressOnFailure();
|
|
@@ -1391,10 +1586,6 @@ async function executePrismaSetupContext(context, options = {}) {
|
|
|
1391
1586
|
stopProgressOnFailure();
|
|
1392
1587
|
return false;
|
|
1393
1588
|
}
|
|
1394
|
-
if (!await writeMongoDockerHelpersForContext(context, projectDir)) {
|
|
1395
|
-
stopProgressOnFailure();
|
|
1396
|
-
return false;
|
|
1397
|
-
}
|
|
1398
1589
|
if (context.shouldEmit && context.shouldInstall) progressSpinner?.message("Emitting Prisma Next contract artifacts...");
|
|
1399
1590
|
const emitResult = await emitPrismaNextContractForContext(context, projectDir);
|
|
1400
1591
|
const warningLines = buildWarningLines(provisionResult.warning, emitResult.warning);
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as DatabaseUrlSchema, r as CreateCommandInputSchema, s as PackageManagerSchema, t as runCreateCommand } from "./create-
|
|
2
|
+
import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as DatabaseUrlSchema, r as CreateCommandInputSchema, s as PackageManagerSchema, t as runCreateCommand } from "./create-C5pPk2G0.mjs";
|
|
3
3
|
import { os } from "@orpc/server";
|
|
4
4
|
import { createCli } from "trpc-cli";
|
|
5
5
|
|
|
6
6
|
//#region src/index.ts
|
|
7
|
-
const CLI_VERSION = "0.4.2-next.37.
|
|
7
|
+
const CLI_VERSION = "0.4.2-next.37.98.1";
|
|
8
8
|
const router = os.router({ create: os.meta({
|
|
9
9
|
description: "Create a new project with Prisma setup",
|
|
10
10
|
default: true,
|
package/package.json
CHANGED
|
@@ -22,8 +22,9 @@ Database helper scripts are added to `package.json`:
|
|
|
22
22
|
|
|
23
23
|
- `{{runScriptCommand packageManager "contract:emit"}}` - emit contract artifacts after contract changes
|
|
24
24
|
{{#if (eq provider "mongo")}}
|
|
25
|
-
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set
|
|
26
|
-
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB
|
|
25
|
+
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set with `mongodb-memory-server`. Data persists in `.mongo-data/` across restarts.
|
|
26
|
+
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB process (data preserved)
|
|
27
|
+
- `{{runScriptCommand packageManager "db:reset"}}` - stop and wipe `.mongo-data/` for a clean slate
|
|
27
28
|
- `{{runScriptCommand packageManager "migration:plan"}}` - create a MongoDB migration plan
|
|
28
29
|
- `{{runScriptCommand packageManager "migrate"}}` - apply the planned MongoDB migration
|
|
29
30
|
{{else}}
|
|
@@ -20,8 +20,9 @@ Database helper scripts are added to `package.json`:
|
|
|
20
20
|
|
|
21
21
|
- `{{runScriptCommand packageManager "contract:emit"}}` - emit contract artifacts after contract changes
|
|
22
22
|
{{#if (eq provider "mongo")}}
|
|
23
|
-
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set
|
|
24
|
-
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB
|
|
23
|
+
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set with `mongodb-memory-server`. Data persists in `.mongo-data/` across restarts.
|
|
24
|
+
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB process (data preserved)
|
|
25
|
+
- `{{runScriptCommand packageManager "db:reset"}}` - stop and wipe `.mongo-data/` for a clean slate
|
|
25
26
|
- `{{runScriptCommand packageManager "migration:plan"}}` - create a MongoDB migration plan
|
|
26
27
|
- `{{runScriptCommand packageManager "migrate"}}` - apply the planned MongoDB migration
|
|
27
28
|
{{else}}
|
|
@@ -20,8 +20,9 @@ Database helper scripts are added to `package.json`:
|
|
|
20
20
|
|
|
21
21
|
- `{{runScriptCommand packageManager "contract:emit"}}` - emit contract artifacts after contract changes
|
|
22
22
|
{{#if (eq provider "mongo")}}
|
|
23
|
-
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set
|
|
24
|
-
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB
|
|
23
|
+
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set with `mongodb-memory-server`. Data persists in `.mongo-data/` across restarts.
|
|
24
|
+
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB process (data preserved)
|
|
25
|
+
- `{{runScriptCommand packageManager "db:reset"}}` - stop and wipe `.mongo-data/` for a clean slate
|
|
25
26
|
- `{{runScriptCommand packageManager "migration:plan"}}` - create a MongoDB migration plan
|
|
26
27
|
- `{{runScriptCommand packageManager "migrate"}}` - apply the planned MongoDB migration
|
|
27
28
|
{{else}}
|
|
@@ -19,8 +19,9 @@ Database helper scripts are added to `package.json`:
|
|
|
19
19
|
|
|
20
20
|
- `{{runScriptCommand packageManager "contract:emit"}}` - emit contract artifacts after contract changes
|
|
21
21
|
{{#if (eq provider "mongo")}}
|
|
22
|
-
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set
|
|
23
|
-
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB
|
|
22
|
+
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set with `mongodb-memory-server`. Data persists in `.mongo-data/` across restarts.
|
|
23
|
+
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB process (data preserved)
|
|
24
|
+
- `{{runScriptCommand packageManager "db:reset"}}` - stop and wipe `.mongo-data/` for a clean slate
|
|
24
25
|
- `{{runScriptCommand packageManager "migration:plan"}}` - create a MongoDB migration plan
|
|
25
26
|
- `{{runScriptCommand packageManager "migrate"}}` - apply the planned MongoDB migration
|
|
26
27
|
{{else}}
|
|
@@ -21,8 +21,9 @@ Database helper scripts are added to `package.json`:
|
|
|
21
21
|
|
|
22
22
|
- `{{runScriptCommand packageManager "contract:emit"}}` - emit contract artifacts after contract changes
|
|
23
23
|
{{#if (eq provider "mongo")}}
|
|
24
|
-
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set
|
|
25
|
-
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB
|
|
24
|
+
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set with `mongodb-memory-server`. Data persists in `.mongo-data/` across restarts.
|
|
25
|
+
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB process (data preserved)
|
|
26
|
+
- `{{runScriptCommand packageManager "db:reset"}}` - stop and wipe `.mongo-data/` for a clean slate
|
|
26
27
|
- `{{runScriptCommand packageManager "migration:plan"}}` - create a MongoDB migration plan
|
|
27
28
|
- `{{runScriptCommand packageManager "migrate"}}` - apply the planned MongoDB migration
|
|
28
29
|
{{else}}
|
|
@@ -20,8 +20,9 @@ Database helper scripts are added to `package.json`:
|
|
|
20
20
|
|
|
21
21
|
- `{{runScriptCommand packageManager "contract:emit"}}` - emit contract artifacts after contract changes
|
|
22
22
|
{{#if (eq provider "mongo")}}
|
|
23
|
-
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set
|
|
24
|
-
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB
|
|
23
|
+
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set with `mongodb-memory-server`. Data persists in `.mongo-data/` across restarts.
|
|
24
|
+
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB process (data preserved)
|
|
25
|
+
- `{{runScriptCommand packageManager "db:reset"}}` - stop and wipe `.mongo-data/` for a clean slate
|
|
25
26
|
- `{{runScriptCommand packageManager "migration:plan"}}` - create a MongoDB migration plan
|
|
26
27
|
- `{{runScriptCommand packageManager "migrate"}}` - apply the planned MongoDB migration
|
|
27
28
|
{{else}}
|
|
@@ -22,8 +22,9 @@ Database helper scripts are added to `package.json`:
|
|
|
22
22
|
|
|
23
23
|
- `{{runScriptCommand packageManager "contract:emit"}}` - emit contract artifacts after contract changes
|
|
24
24
|
{{#if (eq provider "mongo")}}
|
|
25
|
-
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set
|
|
26
|
-
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB
|
|
25
|
+
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set with `mongodb-memory-server`. Data persists in `.mongo-data/` across restarts.
|
|
26
|
+
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB process (data preserved)
|
|
27
|
+
- `{{runScriptCommand packageManager "db:reset"}}` - stop and wipe `.mongo-data/` for a clean slate
|
|
27
28
|
- `{{runScriptCommand packageManager "migration:plan"}}` - create a MongoDB migration plan
|
|
28
29
|
- `{{runScriptCommand packageManager "migrate"}}` - apply the planned MongoDB migration
|
|
29
30
|
{{else}}
|
|
@@ -21,8 +21,9 @@ Database helper scripts are added to `package.json`:
|
|
|
21
21
|
|
|
22
22
|
- `{{runScriptCommand packageManager "contract:emit"}}` - emit contract artifacts after contract changes
|
|
23
23
|
{{#if (eq provider "mongo")}}
|
|
24
|
-
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set
|
|
25
|
-
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB
|
|
24
|
+
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set with `mongodb-memory-server`. Data persists in `.mongo-data/` across restarts.
|
|
25
|
+
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB process (data preserved)
|
|
26
|
+
- `{{runScriptCommand packageManager "db:reset"}}` - stop and wipe `.mongo-data/` for a clean slate
|
|
26
27
|
- `{{runScriptCommand packageManager "migration:plan"}}` - create a MongoDB migration plan
|
|
27
28
|
- `{{runScriptCommand packageManager "migrate"}}` - apply the planned MongoDB migration
|
|
28
29
|
{{else}}
|
|
@@ -21,8 +21,9 @@ Database helper scripts are added to `package.json`:
|
|
|
21
21
|
|
|
22
22
|
- `{{runScriptCommand packageManager "contract:emit"}}` - emit contract artifacts after contract changes
|
|
23
23
|
{{#if (eq provider "mongo")}}
|
|
24
|
-
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set
|
|
25
|
-
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB
|
|
24
|
+
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set with `mongodb-memory-server`. Data persists in `.mongo-data/` across restarts.
|
|
25
|
+
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB process (data preserved)
|
|
26
|
+
- `{{runScriptCommand packageManager "db:reset"}}` - stop and wipe `.mongo-data/` for a clean slate
|
|
26
27
|
- `{{runScriptCommand packageManager "migration:plan"}}` - create a MongoDB migration plan
|
|
27
28
|
- `{{runScriptCommand packageManager "migrate"}}` - apply the planned MongoDB migration
|
|
28
29
|
{{else}}
|