@prisma/cli-init 0.4.1 → 0.5.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.
@@ -1632,9 +1632,9 @@ Received data: ${data}`
1632
1632
  console.debug("[Query Engine] cache directory path", cacheDirectoryPath);
1633
1633
  }
1634
1634
  await mkdir2(cacheDirectoryPath, { recursive: true });
1635
- const { platform } = this.#options.platform;
1636
- const extension = platform === "windows" ? ".exe" : "";
1637
- const engineBinaryPath = join(cacheDirectoryPath, `query-engine-${platform}${extension}`);
1635
+ const { binaryTarget } = this.#options.platform;
1636
+ const extension = binaryTarget === "windows" ? ".exe" : "";
1637
+ const engineBinaryPath = join(cacheDirectoryPath, `query-engine-${binaryTarget}${extension}`);
1638
1638
  if (this.#options.debug) {
1639
1639
  console.debug("[Query Engine] binary path", engineBinaryPath);
1640
1640
  }
@@ -344,7 +344,7 @@ import internals5 from "@prisma/internals";
344
344
  import * as Checkpoint from "checkpoint-client";
345
345
 
346
346
  // package.json
347
- var version = "0.4.1";
347
+ var version = "0.5.1";
348
348
 
349
349
  // src/platform/_lib/userAgent.ts
350
350
  var debug = Debug("prisma:cli:platform:_lib:userAgent");
package/dist/index.js CHANGED
@@ -21,14 +21,14 @@ import {
21
21
  url,
22
22
  withResolvers,
23
23
  y
24
- } from "./chunk-XE2LPBET.js";
24
+ } from "./chunk-7C5I22R2.js";
25
25
  import {
26
26
  credentialsFile,
27
27
  poll,
28
28
  printPpgInitOutput,
29
29
  requestOrThrow,
30
30
  successMessage
31
- } from "./chunk-FY2W4YAF.js";
31
+ } from "./chunk-C65YHZ4S.js";
32
32
  import {
33
33
  __commonJS,
34
34
  __require,
@@ -2645,7 +2645,7 @@ async function getApp(port, dbServer, serverState) {
2645
2645
  const { debug } = serverState;
2646
2646
  const [{ Hono }, { accelerateRoute }, { utilityRoute }] = await Promise.all([
2647
2647
  import("hono/tiny"),
2648
- import("./accelerate-XNYQGU23.js"),
2648
+ import("./accelerate-YEFEYVGD.js"),
2649
2649
  import("./utility-W6LOZZIT.js")
2650
2650
  ]);
2651
2651
  const app = new Hono();
@@ -3152,6 +3152,10 @@ function printError(text) {
3152
3152
  }
3153
3153
 
3154
3154
  // src/Init.ts
3155
+ var isBun = (
3156
+ // @ts-ignore
3157
+ !!globalThis.Bun || !!globalThis.process?.versions?.bun
3158
+ );
3155
3159
  var defaultSchema = (props) => {
3156
3160
  const {
3157
3161
  datasourceProvider = "postgresql",
@@ -3226,8 +3230,9 @@ var defaultEnv = async (url2, debug = false, comments = true) => {
3226
3230
  });
3227
3231
  url2 = server.ppg.url;
3228
3232
  }
3229
- let env = comments ? `# Environment variables declared in this file are automatically made available to Prisma.
3230
- # See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
3233
+ let env = comments ? `# Environment variables declared in this file are NOT automatically loaded by Prisma.
3234
+ # Please add \`import "dotenv/config";\` to your \`prisma.config.ts\` file, or use the Prisma CLI with Bun
3235
+ # to load environment variables from .env files: https://pris.ly/prisma-config-env-vars.
3231
3236
 
3232
3237
  # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
3233
3238
  # See the documentation for all the connection string options: https://pris.ly/d/connection-strings
@@ -3281,8 +3286,29 @@ var defaultGitIgnore = () => {
3281
3286
  .env
3282
3287
  `;
3283
3288
  };
3284
- var defaultGeneratorProvider = "prisma-client-js";
3289
+ var defaultGeneratorProvider = "prisma-client";
3285
3290
  var defaultPreviewFeatures = [];
3291
+ function normalizePath(configPath) {
3292
+ return JSON.stringify(configPath.replaceAll(path2.sep, "/"));
3293
+ }
3294
+ var defaultConfig = (props) => {
3295
+ const { prismaFolder } = props;
3296
+ const schemaPath = path2.relative(process.cwd(), path2.join(prismaFolder, "schema.prisma"));
3297
+ const migrationsPath = path2.relative(process.cwd(), path2.join(prismaFolder, "migrations"));
3298
+ return `import { defineConfig, env } from "prisma/config";
3299
+
3300
+ export default defineConfig({
3301
+ schema: ${normalizePath(schemaPath)},
3302
+ migrations: {
3303
+ path: ${normalizePath(migrationsPath)},
3304
+ },
3305
+ engine: "classic",
3306
+ datasource: {
3307
+ url: env("DATABASE_URL"),
3308
+ },
3309
+ });
3310
+ `;
3311
+ };
3286
3312
  var Init = class _Init {
3287
3313
  static new() {
3288
3314
  return new _Init();
@@ -3399,6 +3425,9 @@ var Init = class _Init {
3399
3425
  const previewFeatures = args["--preview-feature"];
3400
3426
  const output = args["--output"];
3401
3427
  const isPpgCommand = args["--db"] || datasourceProvider === internals.PRISMA_POSTGRES_PROVIDER || args["--prompt"] || args["--vibe"];
3428
+ if (args["--debug"]) {
3429
+ console.log(`[isBun]`, isBun);
3430
+ }
3402
3431
  let prismaPostgresDatabaseUrl;
3403
3432
  let workspaceId = ``;
3404
3433
  let projectId = ``;
@@ -3408,7 +3437,7 @@ var Init = class _Init {
3408
3437
  let generatedSchema;
3409
3438
  let generatedName;
3410
3439
  if (isPpgCommand) {
3411
- const PlatformCommands = await import("./_-2OIXXGR3.js");
3440
+ const PlatformCommands = await import("./_-2XY5LH7K.js");
3412
3441
  const credentials = await credentialsFile.load();
3413
3442
  if (internals.isError(credentials))
3414
3443
  throw credentials;
@@ -3561,6 +3590,12 @@ var Init = class _Init {
3561
3590
  );
3562
3591
  const databaseUrl = prismaPostgresDatabaseUrl || url2;
3563
3592
  const warnings = [];
3593
+ fs2.writeFileSync(
3594
+ path2.join(outputDir, "prisma.config.ts"),
3595
+ defaultConfig({
3596
+ prismaFolder
3597
+ })
3598
+ );
3564
3599
  const envPath = path2.join(outputDir, ".env");
3565
3600
  if (!fs2.existsSync(envPath)) {
3566
3601
  fs2.writeFileSync(envPath, await defaultEnv(databaseUrl, args["--debug"]));
@@ -3606,6 +3641,9 @@ var Init = class _Init {
3606
3641
  console.error("Failed to append client path to .gitignore file, reason: ", e);
3607
3642
  }
3608
3643
  const steps = [];
3644
+ if (!isBun) {
3645
+ steps.push(`Install \`dotenv\`, and add \`import "dotenv/config";\` to your \`prisma.config.ts\` file to load environment variables from \`.env\`.`);
3646
+ }
3609
3647
  const isPrismaDev = !args["--url"] && (datasourceProvider === "postgres" || datasourceProvider === "postgresql");
3610
3648
  if (isPrismaDev) {
3611
3649
  steps.push(
@@ -3641,9 +3679,14 @@ var Init = class _Init {
3641
3679
  "ORM"
3642
3680
  )} with scalable connection pooling, global caching, and a managed serverless Postgres database. Read: https://pris.ly/cli/beyond-orm`
3643
3681
  );
3682
+ if (!isBun) {
3683
+ warnings.push(`Environment variables declared in the \`.env\` file are NOT automatically loaded by Prisma.
3684
+ See: https://pris.ly/prisma-config-env-vars.`);
3685
+ }
3644
3686
  const defaultOutput = `
3645
3687
  \u2714 Your Prisma schema was created at ${green("prisma/schema.prisma")}
3646
- You can now open it in your favorite editor.
3688
+ \u2714 Your Prisma config was created at ${green("prisma.config.ts")}
3689
+ You can now open them in your favorite editor.
3647
3690
  ${warnings.length > 0 && internals.logger.should.warn() ? `
3648
3691
  ${warnings.join("\n")}
3649
3692
  ` : ""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/cli-init",
3
- "version": "0.4.1",
3
+ "version": "0.5.1",
4
4
  "description": "Init CLI for Prisma",
5
5
  "type": "module",
6
6
  "sideEffects": false,