create-prisma 0.9.2-pr.63.231.1 → 0.9.2-pr.63.233.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "./create-B4dcx9oX.mjs";
2
+ import "./create-Dc8jbxT6.mjs";
3
3
  import { createCreatePrismaCli } from "./index.mjs";
4
4
 
5
5
  //#region src/cli.ts
@@ -41,7 +41,7 @@ async function getAnonymousId() {
41
41
  }
42
42
  function getCommonProperties() {
43
43
  return {
44
- "cli-version": "0.9.2-pr.63.231.1",
44
+ "cli-version": "0.9.2-pr.63.233.1",
45
45
  "node-version": process.version,
46
46
  platform: process.platform,
47
47
  arch: process.arch
@@ -852,7 +852,11 @@ async function getProjectDetails(options) {
852
852
  return;
853
853
  }
854
854
  }
855
- async function deployWithComposer(options) {
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) {
856
860
  const progress = options.verbose ? void 0 : spinner();
857
861
  let deploymentLog;
858
862
  let progressRunning = false;
@@ -955,6 +959,63 @@ async function deployWithComposer(options) {
955
959
  }
956
960
  }
957
961
 
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
+
958
1019
  //#endregion
959
1020
  //#region src/tasks/setup-prisma.ts
960
1021
  const DEFAULT_DATABASE_PROVIDER = "postgres";
@@ -1205,7 +1266,9 @@ async function executePrismaSetupContext(context, options = {}) {
1205
1266
  const projectName = options.projectName ?? path.basename(projectDir);
1206
1267
  const template = options.template ?? "minimal";
1207
1268
  const progress = context.verbose ? void 0 : options.progressSpinner ?? spinner();
1208
- if (progress !== void 0 && !options.progressSpinner) progress.start("Creating Prisma 8 project...");
1269
+ const ownsProgress = progress !== void 0 && !options.progressSpinner;
1270
+ let gitInitialization;
1271
+ if (ownsProgress) progress.start("Creating Prisma 8 project...");
1209
1272
  try {
1210
1273
  progress?.message("Preparing Prisma 8 project files...");
1211
1274
  await runPrismaInit(context, projectDir);
@@ -1220,13 +1283,23 @@ async function executePrismaSetupContext(context, options = {}) {
1220
1283
  await writePrismaDependencies(context.databaseProvider, context.packageManager, context.authoring, projectDir);
1221
1284
  await ensureComposerTypeScriptOptions(projectDir);
1222
1285
  if (context.databaseProvider === "mongo") await ensureMongoEnvironment(projectDir);
1286
+ if (context.packageManager !== "deno") {
1287
+ await ensureGitignoreEntry(projectDir, "/.alchemy");
1288
+ await ensureGitignoreEntry(projectDir, "/.prisma-composer");
1289
+ }
1223
1290
  progress?.message(`Installing dependencies with ${getInstallCommand(context.packageManager)}...`);
1224
1291
  await installProjectDependencies(context.packageManager, projectDir, { verbose: context.verbose });
1225
1292
  progress?.message("Installing Prisma agent skills...");
1226
1293
  await initializeAgentSkills(context, projectDir);
1227
1294
  progress?.message("Generating Prisma 8 contract artifacts...");
1228
1295
  await emitContract(context, projectDir);
1296
+ if (options.initializeGit) {
1297
+ progress?.message("Initializing Git repository...");
1298
+ gitInitialization = await initializeGitRepository(projectDir);
1299
+ }
1229
1300
  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}`);
1230
1303
  } catch (error) {
1231
1304
  progress?.error("Could not create Prisma 8 project.");
1232
1305
  cancel(getCommandErrorMessage(error));
@@ -1234,7 +1307,7 @@ async function executePrismaSetupContext(context, options = {}) {
1234
1307
  }
1235
1308
  let deployment;
1236
1309
  if (context.shouldDeploy) {
1237
- deployment = await deployWithComposer({
1310
+ deployment = await deployNewProjectWithComposer({
1238
1311
  appName: projectName,
1239
1312
  packageManager: context.packageManager,
1240
1313
  projectDir,
@@ -1529,6 +1602,7 @@ async function executeCreateContext(context) {
1529
1602
  template: context.template,
1530
1603
  createdProjectPath: context.targetDirectory,
1531
1604
  includeDevNextStep: true,
1605
+ initializeGit: !context.targetPathState.exists || context.targetPathState.isEmptyDirectory,
1532
1606
  progressSpinner: createSpinner
1533
1607
  })) return {
1534
1608
  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-B4dcx9oX.mjs";
2
+ import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as PackageManagerSchema, r as CreateCommandInputSchema, t as runCreateCommand } from "./create-Dc8jbxT6.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-pr.63.231.1";
8
+ const CLI_VERSION = "0.9.2-pr.63.233.1";
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-pr.63.231.1",
3
+ "version": "0.9.2-pr.63.233.1",
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/install.test.ts ./tests/node-version.test.ts ./tests/setup-prisma.test.ts ./tests/telemetry.test.ts",
40
+ "test:unit": "bun test ./tests/dependencies.test.ts ./tests/deploy-with-composer.test.ts ./tests/initialize-git.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",