create-prisma 0.9.2-pr.63.232.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-DLnU4PH_.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.232.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
@@ -959,6 +959,63 @@ async function deployNewProjectWithComposer(options) {
959
959
  }
960
960
  }
961
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
+
962
1019
  //#endregion
963
1020
  //#region src/tasks/setup-prisma.ts
964
1021
  const DEFAULT_DATABASE_PROVIDER = "postgres";
@@ -1209,7 +1266,9 @@ async function executePrismaSetupContext(context, options = {}) {
1209
1266
  const projectName = options.projectName ?? path.basename(projectDir);
1210
1267
  const template = options.template ?? "minimal";
1211
1268
  const progress = context.verbose ? void 0 : options.progressSpinner ?? spinner();
1212
- 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...");
1213
1272
  try {
1214
1273
  progress?.message("Preparing Prisma 8 project files...");
1215
1274
  await runPrismaInit(context, projectDir);
@@ -1224,13 +1283,23 @@ async function executePrismaSetupContext(context, options = {}) {
1224
1283
  await writePrismaDependencies(context.databaseProvider, context.packageManager, context.authoring, projectDir);
1225
1284
  await ensureComposerTypeScriptOptions(projectDir);
1226
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
+ }
1227
1290
  progress?.message(`Installing dependencies with ${getInstallCommand(context.packageManager)}...`);
1228
1291
  await installProjectDependencies(context.packageManager, projectDir, { verbose: context.verbose });
1229
1292
  progress?.message("Installing Prisma agent skills...");
1230
1293
  await initializeAgentSkills(context, projectDir);
1231
1294
  progress?.message("Generating Prisma 8 contract artifacts...");
1232
1295
  await emitContract(context, projectDir);
1296
+ if (options.initializeGit) {
1297
+ progress?.message("Initializing Git repository...");
1298
+ gitInitialization = await initializeGitRepository(projectDir);
1299
+ }
1233
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}`);
1234
1303
  } catch (error) {
1235
1304
  progress?.error("Could not create Prisma 8 project.");
1236
1305
  cancel(getCommandErrorMessage(error));
@@ -1533,6 +1602,7 @@ async function executeCreateContext(context) {
1533
1602
  template: context.template,
1534
1603
  createdProjectPath: context.targetDirectory,
1535
1604
  includeDevNextStep: true,
1605
+ initializeGit: !context.targetPathState.exists || context.targetPathState.isEmptyDirectory,
1536
1606
  progressSpinner: createSpinner
1537
1607
  })) return {
1538
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-DLnU4PH_.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.232.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.232.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",