create-prisma 0.9.2-pr.63.234.1 → 0.9.2
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-D_6j6lE8.mjs → create-DPrHKEg5.mjs} +25 -138
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { cancel, confirm, intro, isCancel, log, note, outro, select, spinner,
|
|
3
|
+
import { cancel, confirm, intro, isCancel, log, note, outro, select, spinner, text } from "@clack/prompts";
|
|
4
4
|
import fs from "fs-extra";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
@@ -10,16 +10,24 @@ import Handlebars from "handlebars";
|
|
|
10
10
|
import { existsSync } from "node:fs";
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
import { execa } from "execa";
|
|
13
|
-
import { createInterface } from "node:readline";
|
|
14
13
|
import { styleText } from "node:util";
|
|
15
14
|
|
|
16
15
|
//#region src/telemetry/client.ts
|
|
17
|
-
const TELEMETRY_API_KEY = "";
|
|
16
|
+
const TELEMETRY_API_KEY = "phc_cmc85avbWyuJ2JyKdGPdv7dxXli8xLdWDBPbvIXWJfs";
|
|
18
17
|
const TELEMETRY_HOST = "https://us.i.posthog.com";
|
|
19
18
|
const TELEMETRY_CONFIG_FILE = "telemetry.json";
|
|
20
19
|
const UUID_V4_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
20
|
+
function isTruthyEnvValue(value) {
|
|
21
|
+
return [
|
|
22
|
+
"1",
|
|
23
|
+
"true",
|
|
24
|
+
"yes",
|
|
25
|
+
"on"
|
|
26
|
+
].includes(String(value ?? "").trim().toLowerCase());
|
|
27
|
+
}
|
|
21
28
|
function shouldDisableTelemetry() {
|
|
22
|
-
return true;
|
|
29
|
+
if (isTruthyEnvValue(process.env.CI) || isTruthyEnvValue(process.env.GITHUB_ACTIONS)) return true;
|
|
30
|
+
return process.env.CREATE_PRISMA_DISABLE_TELEMETRY !== void 0 || process.env.CREATE_PRISMA_TELEMETRY_DISABLED !== void 0 || process.env.DO_NOT_TRACK !== void 0;
|
|
23
31
|
}
|
|
24
32
|
function getTelemetryConfigDir() {
|
|
25
33
|
if (process.platform === "darwin") return path.join(os.homedir(), "Library", "Application Support", "create-prisma");
|
|
@@ -41,7 +49,7 @@ async function getAnonymousId() {
|
|
|
41
49
|
}
|
|
42
50
|
function getCommonProperties() {
|
|
43
51
|
return {
|
|
44
|
-
"cli-version": "0.9.2
|
|
52
|
+
"cli-version": "0.9.2",
|
|
45
53
|
"node-version": process.version,
|
|
46
54
|
platform: process.platform,
|
|
47
55
|
arch: process.arch
|
|
@@ -660,7 +668,7 @@ async function installProjectDependencies(packageManager, projectDir = process.c
|
|
|
660
668
|
//#endregion
|
|
661
669
|
//#region src/tasks/deploy-with-composer.ts
|
|
662
670
|
function redactSecrets(message) {
|
|
663
|
-
return message.replace(/\b((?:
|
|
671
|
+
return message.replace(/\b((?:prisma\+)?postgres(?:ql)?:\/\/)[^\s'"]+/gi, "$1<redacted>").replace(/\b([A-Z0-9_]*(?:DATABASE_URL|TOKEN|SECRET|PASSWORD|API_KEY|PRIVATE_KEY)[A-Z0-9_]*=)[^\s]+/g, "$1<redacted>");
|
|
664
672
|
}
|
|
665
673
|
function getErrorMessage(error) {
|
|
666
674
|
if (error instanceof Error) return redactSecrets(error.message);
|
|
@@ -695,16 +703,12 @@ async function runPrismaJsonCommand(options) {
|
|
|
695
703
|
"--json",
|
|
696
704
|
"--no-interactive"
|
|
697
705
|
]);
|
|
698
|
-
const
|
|
706
|
+
const result = await execa(invocation.command, invocation.args, {
|
|
699
707
|
cwd: options.projectDir,
|
|
700
708
|
env: process.env,
|
|
701
709
|
reject: false
|
|
702
710
|
});
|
|
703
|
-
|
|
704
|
-
const lines = createInterface({ input: subprocess.stderr });
|
|
705
|
-
for await (const line of lines) if (line.trim()) options.onStderrLine?.(line);
|
|
706
|
-
})() : Promise.resolve();
|
|
707
|
-
const [result] = await Promise.all([subprocess, stderrLines]);
|
|
711
|
+
if (options.forwardStderr && result.stderr) process.stderr.write(result.stderr.endsWith("\n") ? result.stderr : `${result.stderr}\n`);
|
|
708
712
|
let envelope;
|
|
709
713
|
try {
|
|
710
714
|
envelope = parsePrismaCliEnvelope(result.stdout);
|
|
@@ -718,19 +722,6 @@ async function runPrismaJsonCommand(options) {
|
|
|
718
722
|
}
|
|
719
723
|
return envelope.result;
|
|
720
724
|
}
|
|
721
|
-
function findProjectNameCollisions(projects, appName) {
|
|
722
|
-
return projects.filter((project) => project.name === appName);
|
|
723
|
-
}
|
|
724
|
-
async function ensureProjectNameAvailable(options) {
|
|
725
|
-
const collisions = findProjectNameCollisions((await runPrismaJsonCommand({
|
|
726
|
-
packageManager: options.packageManager,
|
|
727
|
-
projectDir: options.projectDir,
|
|
728
|
-
args: ["project", "list"]
|
|
729
|
-
})).items, options.appName);
|
|
730
|
-
if (collisions.length === 0) return;
|
|
731
|
-
const projectIds = collisions.map((project) => project.id).join(", ");
|
|
732
|
-
throw new Error(`A Prisma project named "${options.appName}" already exists in workspace ${workspaceLabel(options.workspace)} (${options.workspace.id}). Choose a different project name or delete the existing project (${projectIds}) in Prisma Console, then retry.`);
|
|
733
|
-
}
|
|
734
725
|
async function ensureAuthentication(packageManager, projectDir, beforeInteractiveLogin) {
|
|
735
726
|
const whoami = () => runPrismaJsonCommand({
|
|
736
727
|
packageManager,
|
|
@@ -852,13 +843,8 @@ async function getProjectDetails(options) {
|
|
|
852
843
|
return;
|
|
853
844
|
}
|
|
854
845
|
}
|
|
855
|
-
|
|
856
|
-
* Performs the optional one-shot deployment at the end of a create-prisma scaffold.
|
|
857
|
-
* Generated projects use their own `deploy` script for every subsequent deployment.
|
|
858
|
-
*/
|
|
859
|
-
async function deployNewProjectWithComposer(options) {
|
|
846
|
+
async function deployWithComposer(options) {
|
|
860
847
|
const progress = options.verbose ? void 0 : spinner();
|
|
861
|
-
let deploymentLog;
|
|
862
848
|
let progressRunning = false;
|
|
863
849
|
const showProgress = (message) => {
|
|
864
850
|
if (!progress) return;
|
|
@@ -889,14 +875,6 @@ async function deployNewProjectWithComposer(options) {
|
|
|
889
875
|
...options.workspace ? { workspace: options.workspace } : {}
|
|
890
876
|
});
|
|
891
877
|
if (!selectedWorkspace) return;
|
|
892
|
-
showProgress("Checking Prisma project name...");
|
|
893
|
-
if (options.verbose) log.step("Checking Prisma project name.");
|
|
894
|
-
await ensureProjectNameAvailable({
|
|
895
|
-
appName: options.appName,
|
|
896
|
-
packageManager: options.packageManager,
|
|
897
|
-
projectDir: options.projectDir,
|
|
898
|
-
workspace: selectedWorkspace
|
|
899
|
-
});
|
|
900
878
|
showProgress("Building for deployment...");
|
|
901
879
|
if (options.verbose) log.step("Building for deployment.");
|
|
902
880
|
const build = getRunScriptArgs(options.packageManager, "build");
|
|
@@ -905,40 +883,22 @@ async function deployNewProjectWithComposer(options) {
|
|
|
905
883
|
env: process.env,
|
|
906
884
|
stdio: options.verbose ? "inherit" : "pipe"
|
|
907
885
|
});
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
PRISMA_PLATFORM_CLI_PACKAGE,
|
|
911
|
-
"deploy",
|
|
912
|
-
"module.ts"
|
|
913
|
-
]);
|
|
914
|
-
if (options.verbose) log.step(`Deploying to Prisma with ${deployCommand}.`);
|
|
915
|
-
else {
|
|
916
|
-
deploymentLog = taskLog({
|
|
917
|
-
title: "Deploying to Prisma...",
|
|
918
|
-
limit: 10
|
|
919
|
-
});
|
|
920
|
-
deploymentLog.message(`$ ${deployCommand}`);
|
|
921
|
-
}
|
|
886
|
+
showProgress("Deploying to Prisma...");
|
|
887
|
+
if (options.verbose) log.step("Deploying to Prisma.");
|
|
922
888
|
const deployment = parseComposerDeployResult(await runPrismaJsonCommand({
|
|
923
889
|
packageManager: options.packageManager,
|
|
924
890
|
projectDir: options.projectDir,
|
|
925
891
|
args: ["deploy", "module.ts"],
|
|
926
|
-
|
|
927
|
-
const redactedLine = redactSecrets(line);
|
|
928
|
-
if (options.verbose) process.stderr.write(`${redactedLine}\n`);
|
|
929
|
-
else deploymentLog?.message(redactedLine);
|
|
930
|
-
}
|
|
892
|
+
forwardStderr: options.verbose
|
|
931
893
|
}));
|
|
932
894
|
const appName = deployment?.appName ?? options.appName;
|
|
933
|
-
|
|
934
|
-
else deploymentLog?.message("Loading deployment details...");
|
|
895
|
+
showProgress("Loading deployment details...");
|
|
935
896
|
const details = await getProjectDetails({
|
|
936
897
|
packageManager: options.packageManager,
|
|
937
898
|
projectDir: options.projectDir,
|
|
938
899
|
appName
|
|
939
900
|
});
|
|
940
|
-
|
|
941
|
-
deploymentLog = void 0;
|
|
901
|
+
progress?.stop("Deployed to Prisma.");
|
|
942
902
|
progressRunning = false;
|
|
943
903
|
if (options.verbose) log.success("Deployed to Prisma.");
|
|
944
904
|
const workspace = details?.workspace ?? selectedWorkspace;
|
|
@@ -949,73 +909,13 @@ async function deployNewProjectWithComposer(options) {
|
|
|
949
909
|
project: details?.project ?? { name: appName }
|
|
950
910
|
};
|
|
951
911
|
} catch (error) {
|
|
952
|
-
|
|
953
|
-
deploymentLog.error("Deployment failed.");
|
|
954
|
-
deploymentLog = void 0;
|
|
955
|
-
} else progress?.error("Deployment failed.");
|
|
912
|
+
progress?.error("Deployment failed.");
|
|
956
913
|
progressRunning = false;
|
|
957
914
|
log.error(`Deploy failed: ${getErrorMessage(error)}`);
|
|
958
915
|
return;
|
|
959
916
|
}
|
|
960
917
|
}
|
|
961
918
|
|
|
962
|
-
//#endregion
|
|
963
|
-
//#region src/tasks/initialize-git.ts
|
|
964
|
-
function errorMessage(error) {
|
|
965
|
-
if (error instanceof Error && "stderr" in error) {
|
|
966
|
-
const stderr = String(error.stderr ?? "").trim();
|
|
967
|
-
if (stderr) return stderr;
|
|
968
|
-
}
|
|
969
|
-
return error instanceof Error ? error.message : String(error);
|
|
970
|
-
}
|
|
971
|
-
/**
|
|
972
|
-
* Initializes a standalone scaffold as a Git repository and records its generated files.
|
|
973
|
-
* Projects created inside an existing repository remain part of that repository.
|
|
974
|
-
*/
|
|
975
|
-
async function initializeGitRepository(projectDir, env = process.env) {
|
|
976
|
-
try {
|
|
977
|
-
const existing = await execa("git", ["rev-parse", "--is-inside-work-tree"], {
|
|
978
|
-
cwd: projectDir,
|
|
979
|
-
env,
|
|
980
|
-
reject: false
|
|
981
|
-
});
|
|
982
|
-
if (existing.exitCode === 0 && existing.stdout.trim() === "true") return { status: "already-in-repository" };
|
|
983
|
-
} catch (error) {
|
|
984
|
-
return {
|
|
985
|
-
status: "skipped",
|
|
986
|
-
reason: errorMessage(error)
|
|
987
|
-
};
|
|
988
|
-
}
|
|
989
|
-
let initialized = false;
|
|
990
|
-
try {
|
|
991
|
-
await execa("git", ["init"], {
|
|
992
|
-
cwd: projectDir,
|
|
993
|
-
env
|
|
994
|
-
});
|
|
995
|
-
initialized = true;
|
|
996
|
-
await execa("git", ["add", "--all"], {
|
|
997
|
-
cwd: projectDir,
|
|
998
|
-
env
|
|
999
|
-
});
|
|
1000
|
-
await execa("git", [
|
|
1001
|
-
"commit",
|
|
1002
|
-
"--no-verify",
|
|
1003
|
-
"-m",
|
|
1004
|
-
"Initial commit from create-prisma"
|
|
1005
|
-
], {
|
|
1006
|
-
cwd: projectDir,
|
|
1007
|
-
env
|
|
1008
|
-
});
|
|
1009
|
-
return { status: "initialized" };
|
|
1010
|
-
} catch (error) {
|
|
1011
|
-
if (initialized) await fs.remove(path.join(projectDir, ".git"));
|
|
1012
|
-
return {
|
|
1013
|
-
status: "skipped",
|
|
1014
|
-
reason: errorMessage(error)
|
|
1015
|
-
};
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
919
|
//#endregion
|
|
1020
920
|
//#region src/tasks/setup-prisma.ts
|
|
1021
921
|
const DEFAULT_DATABASE_PROVIDER = "postgres";
|
|
@@ -1266,9 +1166,7 @@ async function executePrismaSetupContext(context, options = {}) {
|
|
|
1266
1166
|
const projectName = options.projectName ?? path.basename(projectDir);
|
|
1267
1167
|
const template = options.template ?? "minimal";
|
|
1268
1168
|
const progress = context.verbose ? void 0 : options.progressSpinner ?? spinner();
|
|
1269
|
-
|
|
1270
|
-
let gitInitialization;
|
|
1271
|
-
if (ownsProgress) progress.start("Creating Prisma 8 project...");
|
|
1169
|
+
if (progress !== void 0 && !options.progressSpinner) progress.start("Creating Prisma 8 project...");
|
|
1272
1170
|
try {
|
|
1273
1171
|
progress?.message("Preparing Prisma 8 project files...");
|
|
1274
1172
|
await runPrismaInit(context, projectDir);
|
|
@@ -1283,23 +1181,13 @@ async function executePrismaSetupContext(context, options = {}) {
|
|
|
1283
1181
|
await writePrismaDependencies(context.databaseProvider, context.packageManager, context.authoring, projectDir);
|
|
1284
1182
|
await ensureComposerTypeScriptOptions(projectDir);
|
|
1285
1183
|
if (context.databaseProvider === "mongo") await ensureMongoEnvironment(projectDir);
|
|
1286
|
-
if (context.packageManager !== "deno") {
|
|
1287
|
-
await ensureGitignoreEntry(projectDir, "/.alchemy");
|
|
1288
|
-
await ensureGitignoreEntry(projectDir, "/.prisma-composer");
|
|
1289
|
-
}
|
|
1290
1184
|
progress?.message(`Installing dependencies with ${getInstallCommand(context.packageManager)}...`);
|
|
1291
1185
|
await installProjectDependencies(context.packageManager, projectDir, { verbose: context.verbose });
|
|
1292
1186
|
progress?.message("Installing Prisma agent skills...");
|
|
1293
1187
|
await initializeAgentSkills(context, projectDir);
|
|
1294
1188
|
progress?.message("Generating Prisma 8 contract artifacts...");
|
|
1295
1189
|
await emitContract(context, projectDir);
|
|
1296
|
-
if (options.initializeGit) {
|
|
1297
|
-
progress?.message("Initializing Git repository...");
|
|
1298
|
-
gitInitialization = await initializeGitRepository(projectDir);
|
|
1299
|
-
}
|
|
1300
1190
|
progress?.stop("Prisma 8 project ready.");
|
|
1301
|
-
if (gitInitialization?.status === "initialized" && context.verbose) log.success("Initialized Git repository with an initial commit.");
|
|
1302
|
-
else if (gitInitialization?.status === "skipped") log.warn(`Could not initialize Git repository: ${gitInitialization.reason}`);
|
|
1303
1191
|
} catch (error) {
|
|
1304
1192
|
progress?.error("Could not create Prisma 8 project.");
|
|
1305
1193
|
cancel(getCommandErrorMessage(error));
|
|
@@ -1307,7 +1195,7 @@ async function executePrismaSetupContext(context, options = {}) {
|
|
|
1307
1195
|
}
|
|
1308
1196
|
let deployment;
|
|
1309
1197
|
if (context.shouldDeploy) {
|
|
1310
|
-
deployment = await
|
|
1198
|
+
deployment = await deployWithComposer({
|
|
1311
1199
|
appName: projectName,
|
|
1312
1200
|
packageManager: context.packageManager,
|
|
1313
1201
|
projectDir,
|
|
@@ -1602,7 +1490,6 @@ async function executeCreateContext(context) {
|
|
|
1602
1490
|
template: context.template,
|
|
1603
1491
|
createdProjectPath: context.targetDirectory,
|
|
1604
1492
|
includeDevNextStep: true,
|
|
1605
|
-
initializeGit: !context.targetPathState.exists || context.targetPathState.isEmptyDirectory,
|
|
1606
1493
|
progressSpinner: createSpinner
|
|
1607
1494
|
})) return {
|
|
1608
1495
|
ok: false,
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as PackageManagerSchema, r as CreateCommandInputSchema, t as runCreateCommand } from "./create-
|
|
2
|
+
import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as PackageManagerSchema, r as CreateCommandInputSchema, t as runCreateCommand } from "./create-DPrHKEg5.mjs";
|
|
3
3
|
import { os } from "@orpc/server";
|
|
4
4
|
import { createCli } from "trpc-cli";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
|
|
7
7
|
//#region src/index.ts
|
|
8
|
-
const CLI_VERSION = "0.9.2
|
|
8
|
+
const CLI_VERSION = "0.9.2";
|
|
9
9
|
const CreateCliInputSchema = z.tuple([z.string().trim().min(1, "Please enter a valid project name").optional().describe("Project name / directory"), CreateCommandInputSchema]);
|
|
10
10
|
function normalizeCreateCliInput(input) {
|
|
11
11
|
const [projectName, options] = input;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-prisma",
|
|
3
|
-
"version": "0.9.2
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Create Prisma 8 projects with first-party templates and great DX.",
|
|
6
6
|
"homepage": "https://github.com/prisma/create-prisma",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dev": "tsdown --watch",
|
|
38
38
|
"start": "bun run ./dist/cli.mjs",
|
|
39
39
|
"test": "bun run test:unit && bun run test:e2e",
|
|
40
|
-
"test:unit": "bun test ./tests/dependencies.test.ts ./tests/deploy-with-composer.test.ts ./tests/
|
|
40
|
+
"test:unit": "bun test ./tests/dependencies.test.ts ./tests/deploy-with-composer.test.ts ./tests/install.test.ts ./tests/node-version.test.ts ./tests/setup-prisma.test.ts ./tests/telemetry.test.ts",
|
|
41
41
|
"test:e2e": "bun test --timeout 180000 ./tests/e2e/create-prisma.e2e.test.ts",
|
|
42
42
|
"check": "bun run format:check && bun run lint",
|
|
43
43
|
"lint": "oxlint . --deny-warnings",
|