create-prisma 0.11.5 → 0.11.6-pr.94.322.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/README.md
CHANGED
|
@@ -61,7 +61,7 @@ older cached version. Prisma Compute does not support Deno deployments yet.
|
|
|
61
61
|
- `--deploy` / `--no-deploy`
|
|
62
62
|
- `--workspace <id-or-name>`
|
|
63
63
|
- `--yes`
|
|
64
|
-
- `--force`
|
|
64
|
+
- `--force`: overwrite generated starter and Prisma files in a non-empty directory without migration history. This replaces existing Prisma config, contract, and database-client files; back up edits first. A non-empty `migrations` path is protected: use a new directory for a fresh starter, or continue working in the existing project with the Prisma CLI.
|
|
65
65
|
- `--verbose`
|
|
66
66
|
- `--json`
|
|
67
67
|
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as ApplicationLayer } from "./json-output-
|
|
2
|
+
import { a as ApplicationLayer } from "./json-output-BSxr1Zrl.mjs";
|
|
3
3
|
import { runCreatePrismaCli } from "./index.mjs";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
5
|
import { NodeRuntime } from "@effect/platform-node-shared";
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { _ as databaseProviderInputs, c as CreateCommandResultSchema, d as CreateCommandInputSchema, f as CreateTemplateSchema, g as createTemplates, h as authoringStyles, i as getErrorMessage, l as createCommandFailureResult, m as PackageManagerSchema, n as writeJsonResult, o as applicationRuntime, p as DatabaseProviderSchema, r as runCreateCommandEffect, s as CREATE_PRISMA_RESULT_SCHEMA_VERSION, t as isJsonOutputRequested, u as AuthoringStyleSchema, v as normalizeDatabaseProvider, y as packageManagers } from "./json-output-
|
|
2
|
+
import { _ as databaseProviderInputs, c as CreateCommandResultSchema, d as CreateCommandInputSchema, f as CreateTemplateSchema, g as createTemplates, h as authoringStyles, i as getErrorMessage, l as createCommandFailureResult, m as PackageManagerSchema, n as writeJsonResult, o as applicationRuntime, p as DatabaseProviderSchema, r as runCreateCommandEffect, s as CREATE_PRISMA_RESULT_SCHEMA_VERSION, t as isJsonOutputRequested, u as AuthoringStyleSchema, v as normalizeDatabaseProvider, y as packageManagers } from "./json-output-BSxr1Zrl.mjs";
|
|
3
3
|
import { Console, Effect, Option } from "effect";
|
|
4
4
|
import { Argument, CliError, Command, Flag } from "effect/unstable/cli";
|
|
5
5
|
|
|
6
6
|
//#region src/index.ts
|
|
7
|
-
const CLI_VERSION = "0.11.
|
|
7
|
+
const CLI_VERSION = "0.11.6-pr.94.322.1";
|
|
8
8
|
const optionalArgument = (name, description) => Argument.string(name).pipe(Argument.withDescription(description), Argument.optional, Argument.map(Option.getOrUndefined));
|
|
9
9
|
const optionalBoolean = (name, description) => Flag.boolean(name).pipe(Flag.withDescription(description), Flag.optional, Flag.map(Option.getOrUndefined));
|
|
10
10
|
const optionalString = (name, description) => Flag.string(name).pipe(Flag.withDescription(description), Flag.optional, Flag.map(Option.getOrUndefined));
|
|
@@ -17,7 +17,7 @@ const createPrismaCommand = Command.make("create-prisma", {
|
|
|
17
17
|
packageManager: Flag.choice("package-manager", packageManagers).pipe(Flag.withDescription("Package manager used for dependency installation"), Flag.optional, Flag.map(Option.getOrUndefined)),
|
|
18
18
|
deploy: optionalBoolean("deploy", "Deploy the generated app to Prisma immediately"),
|
|
19
19
|
workspace: optionalString("workspace", "Prisma workspace id or name to deploy into"),
|
|
20
|
-
force: optionalBoolean("force", "
|
|
20
|
+
force: optionalBoolean("force", "Overwrite generated starter and Prisma files in a directory without migration history"),
|
|
21
21
|
yes: optionalBoolean("yes", "Skip prompts and accept default choices"),
|
|
22
22
|
verbose: optionalBoolean("verbose", "Show verbose command output during setup"),
|
|
23
23
|
json: optionalBoolean("json", "Emit one quiet JSON result for agents and automation (non-interactive; deploys unless --no-deploy)")
|
|
@@ -38,6 +38,7 @@ const CreateFailureReasonSchema = Schema.Literals([
|
|
|
38
38
|
"invalid_project_name",
|
|
39
39
|
"target_path_not_directory",
|
|
40
40
|
"target_directory_not_empty",
|
|
41
|
+
"target_has_migrations",
|
|
41
42
|
"unsupported_configuration",
|
|
42
43
|
"template_scaffold_failed",
|
|
43
44
|
"prisma_init_failed",
|
|
@@ -309,20 +310,14 @@ const applicationRuntime = ManagedRuntime.make(ApplicationLayer);
|
|
|
309
310
|
|
|
310
311
|
//#endregion
|
|
311
312
|
//#region src/telemetry/client.ts
|
|
312
|
-
const TELEMETRY_API_KEY = "
|
|
313
|
+
const TELEMETRY_API_KEY = "";
|
|
313
314
|
const TELEMETRY_HOST = "https://us.i.posthog.com";
|
|
314
315
|
const TELEMETRY_CONFIG_FILE = "telemetry.json";
|
|
315
316
|
const TELEMETRY_TIMEOUT_MS = 2e3;
|
|
316
317
|
const AnonymousId = Schema.String.check(Schema.isUUID(4));
|
|
317
318
|
const decodeAnonymousId = Schema.decodeUnknownExit(AnonymousId);
|
|
318
|
-
const isTruthyEnvValue = (value) => [
|
|
319
|
-
"1",
|
|
320
|
-
"true",
|
|
321
|
-
"yes",
|
|
322
|
-
"on"
|
|
323
|
-
].includes(String(value ?? "").trim().toLowerCase());
|
|
324
319
|
function shouldDisableTelemetry() {
|
|
325
|
-
return
|
|
320
|
+
return true;
|
|
326
321
|
}
|
|
327
322
|
function getTelemetryConfigDir() {
|
|
328
323
|
if (process.platform === "darwin") return path.join(os.homedir(), "Library", "Application Support", "create-prisma");
|
|
@@ -345,7 +340,7 @@ const getAnonymousIdEffect = Effect.fn("Telemetry.getAnonymousId")(function* ()
|
|
|
345
340
|
return anonymousId;
|
|
346
341
|
});
|
|
347
342
|
const getCommonProperties = () => ({
|
|
348
|
-
"cli-version": "0.11.
|
|
343
|
+
"cli-version": "0.11.6-pr.94.322.1",
|
|
349
344
|
"node-version": process.version,
|
|
350
345
|
platform: process.platform,
|
|
351
346
|
arch: process.arch
|
|
@@ -387,6 +382,7 @@ const expectedRejectionReasons = new Set([
|
|
|
387
382
|
"invalid_project_name",
|
|
388
383
|
"target_path_not_directory",
|
|
389
384
|
"target_directory_not_empty",
|
|
385
|
+
"target_has_migrations",
|
|
390
386
|
"unsupported_configuration",
|
|
391
387
|
"not_authenticated",
|
|
392
388
|
"workspace_missing",
|
|
@@ -985,6 +981,7 @@ function redactSecrets(message) {
|
|
|
985
981
|
return message.replace(/\b((?:(?:prisma\+)?postgres(?:ql)?|mongodb(?:\+srv)?):\/\/)[^\s'"]+/gi, "$1<redacted>").replace(/\b([A-Z0-9_]*(?:MONGODB_(?:URL|URI)|DATABASE_URL|TOKEN|SECRET|PASSWORD|API_KEY|PRIVATE_KEY)[A-Z0-9_]*\s*=\s*)(?:"[^"]*"|'[^']*'|[^\s]+)/gi, "$1<redacted>").replace(/(\bAuthorization\s*:\s*Bearer\s+)[^\s'"]+/gi, "$1<redacted>");
|
|
986
982
|
}
|
|
987
983
|
function getErrorMessage(error) {
|
|
984
|
+
if (error instanceof PrismaCliCommandError) return redactSecrets(error.message);
|
|
988
985
|
if (error instanceof Error && "stderr" in error) {
|
|
989
986
|
const stderr = String(error.stderr ?? "").trim();
|
|
990
987
|
if (stderr) return redactSecrets(stderr);
|
|
@@ -1002,7 +999,7 @@ const atCreateStage = (effect, stage, reason) => effect.pipe(Effect.mapError((er
|
|
|
1002
999
|
})));
|
|
1003
1000
|
|
|
1004
1001
|
//#endregion
|
|
1005
|
-
//#region src/tasks/
|
|
1002
|
+
//#region src/tasks/prisma-cli.ts
|
|
1006
1003
|
const PrismaCliEnvelopeSchema = Schema.Struct({
|
|
1007
1004
|
ok: Schema.Boolean,
|
|
1008
1005
|
command: Schema.optionalKey(Schema.String),
|
|
@@ -1036,7 +1033,7 @@ const runPrismaJsonCommandEffect = Effect.fn("PrismaCli.runJson")(function* (opt
|
|
|
1036
1033
|
command: invocation.command,
|
|
1037
1034
|
args: invocation.args,
|
|
1038
1035
|
cwd: options.projectDir,
|
|
1039
|
-
env: process.env,
|
|
1036
|
+
env: options.env ?? process.env,
|
|
1040
1037
|
...options.onStderrLine ? { onStderrLine: options.onStderrLine } : {}
|
|
1041
1038
|
});
|
|
1042
1039
|
let envelope;
|
|
@@ -1044,16 +1041,16 @@ const runPrismaJsonCommandEffect = Effect.fn("PrismaCli.runJson")(function* (opt
|
|
|
1044
1041
|
envelope = parsePrismaCliEnvelope(result.stdout);
|
|
1045
1042
|
} catch (cause) {
|
|
1046
1043
|
return yield* new PrismaCliCommandError({
|
|
1047
|
-
message: result.stderr.trim() || getErrorMessage(cause),
|
|
1048
|
-
stderr: result.stderr,
|
|
1044
|
+
message: redactSecrets(result.stderr.trim() || result.stdout.trim()) || getErrorMessage(cause),
|
|
1045
|
+
stderr: redactSecrets(result.stderr),
|
|
1049
1046
|
exitCode: result.exitCode
|
|
1050
1047
|
});
|
|
1051
1048
|
}
|
|
1052
1049
|
if (result.exitCode !== 0 || !envelope.ok || envelope.result === void 0) return yield* new PrismaCliCommandError({
|
|
1053
|
-
message: [envelope.error?.summary ?? envelope.error?.message, envelope.error?.why].filter(Boolean).join(": ") || result.stderr.trim() || "Prisma CLI command failed.",
|
|
1050
|
+
message: redactSecrets([envelope.error?.summary ?? envelope.error?.message, envelope.error?.why].filter(Boolean).join(": ") || result.stderr.trim() || "Prisma CLI command failed."),
|
|
1054
1051
|
...envelope.commandId || envelope.command ? { command: envelope.commandId ?? envelope.command } : {},
|
|
1055
1052
|
...envelope.error?.code ? { code: envelope.error.code } : {},
|
|
1056
|
-
stderr: result.stderr,
|
|
1053
|
+
stderr: redactSecrets(result.stderr),
|
|
1057
1054
|
exitCode: result.exitCode
|
|
1058
1055
|
});
|
|
1059
1056
|
return envelope.result;
|
|
@@ -1451,24 +1448,23 @@ const runPrismaCli = Effect.fn("PrismaSetup.runCli")(function* (context, project
|
|
|
1451
1448
|
yield* Effect.sync(() => {
|
|
1452
1449
|
if (context.verbose) log.step([invocation.command, ...invocation.args].join(" "), { output: context.output });
|
|
1453
1450
|
});
|
|
1454
|
-
yield*
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1451
|
+
yield* runPrismaJsonCommandEffect({
|
|
1452
|
+
packageManager: context.packageManager,
|
|
1453
|
+
projectDir,
|
|
1454
|
+
args,
|
|
1458
1455
|
env: {
|
|
1459
1456
|
...process.env,
|
|
1460
1457
|
CI: "1"
|
|
1461
1458
|
},
|
|
1462
|
-
verbose: context.
|
|
1463
|
-
json: context.json
|
|
1459
|
+
...context.verbose ? { onStderrLine: (line) => log.message(redactSecrets(line), { output: context.output }) } : {}
|
|
1464
1460
|
});
|
|
1465
1461
|
});
|
|
1466
|
-
const runPrismaInit = Effect.fn("PrismaSetup.init")(function* (context, projectDir) {
|
|
1462
|
+
const runPrismaInit = Effect.fn("PrismaSetup.init")(function* (context, projectDir, force = false) {
|
|
1467
1463
|
yield* runPrismaCli(context, projectDir, [
|
|
1468
1464
|
"orm",
|
|
1469
1465
|
"init",
|
|
1470
1466
|
"--yes",
|
|
1471
|
-
"--
|
|
1467
|
+
...force ? ["--confirm", path.basename(projectDir).trim() || projectDir.trim()] : [],
|
|
1472
1468
|
"--target",
|
|
1473
1469
|
getInitTarget(context.databaseProvider),
|
|
1474
1470
|
"--authoring",
|
|
@@ -1481,11 +1477,7 @@ const runPrismaInit = Effect.fn("PrismaSetup.init")(function* (context, projectD
|
|
|
1481
1477
|
});
|
|
1482
1478
|
const initializeAgentSkills = Effect.fn("PrismaSetup.initializeSkills")(function* (context, projectDir) {
|
|
1483
1479
|
if (context.packageManager === "deno") return;
|
|
1484
|
-
yield* runPrismaCli(context, projectDir, [
|
|
1485
|
-
"init",
|
|
1486
|
-
"--yes",
|
|
1487
|
-
"--no-interactive"
|
|
1488
|
-
]);
|
|
1480
|
+
yield* runPrismaCli(context, projectDir, ["init", "--yes"]);
|
|
1489
1481
|
});
|
|
1490
1482
|
|
|
1491
1483
|
//#endregion
|
|
@@ -1719,7 +1711,7 @@ const executePrismaSetupContextEffect = Effect.fn("PrismaSetup.execute")(functio
|
|
|
1719
1711
|
json: context.json
|
|
1720
1712
|
}), "install_dependencies", "dependency_install_failed");
|
|
1721
1713
|
yield* Effect.sync(() => progress?.message("Preparing Prisma 8 project files..."));
|
|
1722
|
-
yield* atCreateStage(runPrismaInit(context, projectDir), "initialize_prisma", "prisma_init_failed");
|
|
1714
|
+
yield* atCreateStage(runPrismaInit(context, projectDir, options.force), "initialize_prisma", "prisma_init_failed");
|
|
1723
1715
|
yield* atCreateStage(Effect.gen(function* () {
|
|
1724
1716
|
yield* scaffoldCreateSharedTemplatesEffect({
|
|
1725
1717
|
projectDir,
|
|
@@ -1988,6 +1980,19 @@ const collectCreateContext = Effect.fn("Create.collectContext")(function* (input
|
|
|
1988
1980
|
errorReported: true
|
|
1989
1981
|
});
|
|
1990
1982
|
}
|
|
1983
|
+
if (force && targetPathState.exists) {
|
|
1984
|
+
const migrations = yield* inspectTargetPath(path.join(targetDirectory, "migrations"));
|
|
1985
|
+
if (migrations.exists && !migrations.isEmptyDirectory) {
|
|
1986
|
+
const message = `Target directory ${formatPathForDisplay(targetDirectory)} contains migration history. Create a starter in a new directory, or continue working in the existing project with the Prisma CLI. --force cannot overwrite a project with existing migrations.`;
|
|
1987
|
+
yield* Effect.sync(() => cancel(message, { output }));
|
|
1988
|
+
return yield* new CreateFailure({
|
|
1989
|
+
stage: "collect_context",
|
|
1990
|
+
reason: "target_has_migrations",
|
|
1991
|
+
message,
|
|
1992
|
+
errorReported: true
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1991
1996
|
const prismaSetupContext = yield* collectPrismaSetupContextEffect(input, {
|
|
1992
1997
|
projectDir: targetDirectory,
|
|
1993
1998
|
template
|
|
@@ -2038,6 +2043,7 @@ const executeCreateContext = Effect.fn("Create.execute")(function* (context) {
|
|
|
2038
2043
|
template: context.template,
|
|
2039
2044
|
createdProjectPath: context.targetDirectory,
|
|
2040
2045
|
includeDevNextStep: true,
|
|
2046
|
+
force: context.force,
|
|
2041
2047
|
initializeGit: !context.targetPathState.exists || context.targetPathState.isEmptyDirectory,
|
|
2042
2048
|
progressSpinner: createSpinner
|
|
2043
2049
|
});
|
package/package.json
CHANGED