@prisma/cli-init 0.4.1 → 0.5.0

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.0";
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-OCHZ4DEX.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",
@@ -3176,7 +3180,6 @@ ${previewFeatures.length > 0 ? ` previewFeatures = [${previewFeatures.map((feat
3176
3180
 
3177
3181
  datasource db {
3178
3182
  provider = "${datasourceProvider}"
3179
- url = env("DATABASE_URL")
3180
3183
  }
3181
3184
  `;
3182
3185
  if (withModel) {
@@ -3226,8 +3229,9 @@ var defaultEnv = async (url2, debug = false, comments = true) => {
3226
3229
  });
3227
3230
  url2 = server.ppg.url;
3228
3231
  }
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
3232
+ let env = comments ? `# Environment variables declared in this file are NOT automatically loaded by Prisma.
3233
+ # Please add \`import "dotenv/config";\` to your \`prisma.config.ts\` file, or use the Prisma CLI with Bun
3234
+ # to load environment variables from .env files: https://pris.ly/prisma-config-env-vars.
3231
3235
 
3232
3236
  # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
3233
3237
  # See the documentation for all the connection string options: https://pris.ly/d/connection-strings
@@ -3281,8 +3285,29 @@ var defaultGitIgnore = () => {
3281
3285
  .env
3282
3286
  `;
3283
3287
  };
3284
- var defaultGeneratorProvider = "prisma-client-js";
3288
+ var defaultGeneratorProvider = "prisma-client";
3285
3289
  var defaultPreviewFeatures = [];
3290
+ function normalizePath(configPath) {
3291
+ return JSON.stringify(configPath.replaceAll(path2.sep, "/"));
3292
+ }
3293
+ var defaultConfig = (props) => {
3294
+ const { prismaFolder } = props;
3295
+ const schemaPath = path2.relative(process.cwd(), path2.join(prismaFolder, "schema.prisma"));
3296
+ const migrationsPath = path2.relative(process.cwd(), path2.join(prismaFolder, "migrations"));
3297
+ return `import { defineConfig, env } from "prisma/config";
3298
+
3299
+ export default defineConfig({
3300
+ schema: ${normalizePath(schemaPath)},
3301
+ migrations: {
3302
+ path: ${normalizePath(migrationsPath)},
3303
+ },
3304
+ engine: "classic",
3305
+ datasource: {
3306
+ url: env("DATABASE_URL"),
3307
+ },
3308
+ });
3309
+ `;
3310
+ };
3286
3311
  var Init = class _Init {
3287
3312
  static new() {
3288
3313
  return new _Init();
@@ -3408,7 +3433,7 @@ var Init = class _Init {
3408
3433
  let generatedSchema;
3409
3434
  let generatedName;
3410
3435
  if (isPpgCommand) {
3411
- const PlatformCommands = await import("./_-2OIXXGR3.js");
3436
+ const PlatformCommands = await import("./_-YBFA2SJO.js");
3412
3437
  const credentials = await credentialsFile.load();
3413
3438
  if (internals.isError(credentials))
3414
3439
  throw credentials;
@@ -3561,6 +3586,12 @@ var Init = class _Init {
3561
3586
  );
3562
3587
  const databaseUrl = prismaPostgresDatabaseUrl || url2;
3563
3588
  const warnings = [];
3589
+ fs2.writeFileSync(
3590
+ path2.join(outputDir, "prisma.config.ts"),
3591
+ defaultConfig({
3592
+ prismaFolder
3593
+ })
3594
+ );
3564
3595
  const envPath = path2.join(outputDir, ".env");
3565
3596
  if (!fs2.existsSync(envPath)) {
3566
3597
  fs2.writeFileSync(envPath, await defaultEnv(databaseUrl, args["--debug"]));
@@ -3606,6 +3637,9 @@ var Init = class _Init {
3606
3637
  console.error("Failed to append client path to .gitignore file, reason: ", e);
3607
3638
  }
3608
3639
  const steps = [];
3640
+ if (!isBun) {
3641
+ steps.push(`Install \`dotenv\`, and add \`import "dotenv/config";\` to your \`prisma.config.ts\` file to load environment variables from \`.env\`.`);
3642
+ }
3609
3643
  const isPrismaDev = !args["--url"] && (datasourceProvider === "postgres" || datasourceProvider === "postgresql");
3610
3644
  if (isPrismaDev) {
3611
3645
  steps.push(
@@ -3641,9 +3675,14 @@ var Init = class _Init {
3641
3675
  "ORM"
3642
3676
  )} with scalable connection pooling, global caching, and a managed serverless Postgres database. Read: https://pris.ly/cli/beyond-orm`
3643
3677
  );
3678
+ if (!isBun) {
3679
+ warnings.push(`Environment variables declared in the \`.env\` file are NOT automatically loaded by Prisma.
3680
+ See: https://pris.ly/prisma-config-env-vars.`);
3681
+ }
3644
3682
  const defaultOutput = `
3645
3683
  \u2714 Your Prisma schema was created at ${green("prisma/schema.prisma")}
3646
- You can now open it in your favorite editor.
3684
+ \u2714 Your Prisma config was created at ${green("prisma.config.ts")}
3685
+ You can now open them in your favorite editor.
3647
3686
  ${warnings.length > 0 && internals.logger.should.warn() ? `
3648
3687
  ${warnings.join("\n")}
3649
3688
  ` : ""}
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.0",
4
4
  "description": "Init CLI for Prisma",
5
5
  "type": "module",
6
6
  "sideEffects": false,