Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/cli/src/Init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const defaultEnv = async (

let env = comments
? `# Environment variables declared in this file are NOT automatically loaded by Prisma.
# Please add \`import "dotenv/config";\` to your \`prisma.config.ts\` file, or use the Prisma CLI with Bun
# Please add \`import "dotenv/config";\` to your \`prisma7.config.ts\` file, or use the Prisma CLI with Bun
# to load environment variables from .env files: https://pris.ly/prisma-config-env-vars.

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
Expand Down Expand Up @@ -609,7 +609,7 @@ export class Init implements Command {
const warnings: string[] = []

writer.write(
path.join(outputDir, 'prisma.config.ts'),
path.join(outputDir, 'prisma7.config.ts'),
defaultConfig({
prismaFolder,
runtime: isBun ? 'bun' : 'other',
Expand Down Expand Up @@ -682,7 +682,7 @@ export class Init implements Command {

const cliCommand = this.identity
const connectExistingDatabaseSteps = `\
1. Configure your DATABASE_URL in ${green('prisma.config.ts')}
1. Configure your DATABASE_URL in ${green('prisma7.config.ts')}
2. Run ${green(getCommandWithExecutor(`${cliCommand} db pull`))} to introspect your database.`

const postgresProviders: ConnectorType[] = ['postgres', 'postgresql', 'prisma+postgres']
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/Studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ ${bold('Examples')}
${dim('$')} BROWSER=none ${identity} studio --port 5555

Specify a custom prisma config file
${dim('$')} ${identity} studio --config=./prisma.config.ts
${dim('$')} ${identity} studio --config=./prisma7.config.ts

Specify a direct database connection string
${dim('$')} ${identity} studio --url="postgresql://user:password@localhost:5432/dbname"
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/Validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ ${bold('Examples')}
${dim('$')} ${identity} validate

With a Prisma config file
${dim('$')} ${identity} validate --config=./prisma.config.ts
${dim('$')} ${identity} validate --config=./prisma7.config.ts

Or specify a Prisma schema path
${dim('$')} ${identity} validate --schema=./schema.prisma
Expand Down
63 changes: 33 additions & 30 deletions packages/cli/src/__tests__/Init.vitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ test('is schema and env written on disk replace', async () => {
const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatch(await defaultEnv(undefined, false, true, 'prisma'))

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(fs.existsSync(join(ctx.tmpDir, 'prisma.config.ts'))).toBe(false)
expect(config).toContain('prisma/schema.prisma')
expect(config).toMatchInlineSnapshot(`
"// This file was generated by Prisma, and assumes you have installed the following:
Expand Down Expand Up @@ -85,7 +86,9 @@ test('prisma7 init writes scoped config package and keeps prisma7 commands', asy
).toString(),
)

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(fs.existsSync(join(ctx.tmpDir, 'prisma.config.ts'))).toBe(false)
expect(recordedStdout).toContain('prisma7.config.ts')
expect(config).toMatchInlineSnapshot(`
"// This file was generated by Prisma, and assumes you have installed the following:
// npm install --save-dev @prisma/prisma7 dotenv
Expand Down Expand Up @@ -123,7 +126,7 @@ test('works with url param', async () => {
const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatchInlineSnapshot(`
"# Environment variables declared in this file are NOT automatically loaded by Prisma.
# Please add \`import "dotenv/config";\` to your \`prisma.config.ts\` file, or use the Prisma CLI with Bun
# Please add \`import "dotenv/config";\` to your \`prisma7.config.ts\` file, or use the Prisma CLI with Bun
# to load environment variables from .env files: https://pris.ly/prisma-config-env-vars.

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
Expand All @@ -132,7 +135,7 @@ test('works with url param', async () => {
DATABASE_URL="file:dev.db""
`)

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('url: process.env["DATABASE_URL"]')
expect(config).toMatchInlineSnapshot(`
"// This file was generated by Prisma, and assumes you have installed the following:
Expand Down Expand Up @@ -171,7 +174,7 @@ test('works with provider param - postgresql', async () => {
const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatchInlineSnapshot(`
"# Environment variables declared in this file are NOT automatically loaded by Prisma.
# Please add \`import "dotenv/config";\` to your \`prisma.config.ts\` file, or use the Prisma CLI with Bun
# Please add \`import "dotenv/config";\` to your \`prisma7.config.ts\` file, or use the Prisma CLI with Bun
# to load environment variables from .env files: https://pris.ly/prisma-config-env-vars.

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
Expand All @@ -180,7 +183,7 @@ test('works with provider param - postgresql', async () => {
DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public""
`)

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('url: process.env["DATABASE_URL"]')
expect(config).toMatchInlineSnapshot(`
"// This file was generated by Prisma, and assumes you have installed the following:
Expand Down Expand Up @@ -219,7 +222,7 @@ test('works with provider param - cockroachdb', async () => {
const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatchInlineSnapshot(`
"# Environment variables declared in this file are NOT automatically loaded by Prisma.
# Please add \`import "dotenv/config";\` to your \`prisma.config.ts\` file, or use the Prisma CLI with Bun
# Please add \`import "dotenv/config";\` to your \`prisma7.config.ts\` file, or use the Prisma CLI with Bun
# to load environment variables from .env files: https://pris.ly/prisma-config-env-vars.

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
Expand All @@ -228,7 +231,7 @@ test('works with provider param - cockroachdb', async () => {
DATABASE_URL="postgresql://johndoe:randompassword@localhost:26257/mydb?schema=public""
`)

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -254,7 +257,7 @@ test('works with provider and url params - cockroachdb', async () => {
const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatchInlineSnapshot(`
"# Environment variables declared in this file are NOT automatically loaded by Prisma.
# Please add \`import "dotenv/config";\` to your \`prisma.config.ts\` file, or use the Prisma CLI with Bun
# Please add \`import "dotenv/config";\` to your \`prisma7.config.ts\` file, or use the Prisma CLI with Bun
# to load environment variables from .env files: https://pris.ly/prisma-config-env-vars.

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
Expand All @@ -263,7 +266,7 @@ test('works with provider and url params - cockroachdb', async () => {
DATABASE_URL="postgresql://johndoe:randompassword@localhost:26257/mydb?schema=public""
`)

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('url: process.env["DATABASE_URL"]')
expect(config).toMatchSnapshot()
})
Expand All @@ -286,7 +289,7 @@ test('works with provider param - mysql', async () => {
const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatchInlineSnapshot(`
"# Environment variables declared in this file are NOT automatically loaded by Prisma.
# Please add \`import "dotenv/config";\` to your \`prisma.config.ts\` file, or use the Prisma CLI with Bun
# Please add \`import "dotenv/config";\` to your \`prisma7.config.ts\` file, or use the Prisma CLI with Bun
# to load environment variables from .env files: https://pris.ly/prisma-config-env-vars.

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
Expand All @@ -295,7 +298,7 @@ test('works with provider param - mysql', async () => {
DATABASE_URL="mysql://johndoe:randompassword@localhost:3306/mydb""
`)

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -318,7 +321,7 @@ test('works with provider param - SQLITE', async () => {
const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatchInlineSnapshot(`
"# Environment variables declared in this file are NOT automatically loaded by Prisma.
# Please add \`import "dotenv/config";\` to your \`prisma.config.ts\` file, or use the Prisma CLI with Bun
# Please add \`import "dotenv/config";\` to your \`prisma7.config.ts\` file, or use the Prisma CLI with Bun
# to load environment variables from .env files: https://pris.ly/prisma-config-env-vars.

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
Expand All @@ -327,7 +330,7 @@ test('works with provider param - SQLITE', async () => {
DATABASE_URL="file:./dev.db""
`)

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -350,7 +353,7 @@ test('works with provider param - SqlServer', async () => {
const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatchInlineSnapshot(`
"# Environment variables declared in this file are NOT automatically loaded by Prisma.
# Please add \`import "dotenv/config";\` to your \`prisma.config.ts\` file, or use the Prisma CLI with Bun
# Please add \`import "dotenv/config";\` to your \`prisma7.config.ts\` file, or use the Prisma CLI with Bun
# to load environment variables from .env files: https://pris.ly/prisma-config-env-vars.

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
Expand All @@ -359,7 +362,7 @@ test('works with provider param - SqlServer', async () => {
DATABASE_URL="sqlserver://localhost:1433;database=mydb;user=SA;password=randompassword;""
`)

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -382,7 +385,7 @@ test('works with provider param - MongoDB', async () => {
const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatchInlineSnapshot(`
"# Environment variables declared in this file are NOT automatically loaded by Prisma.
# Please add \`import "dotenv/config";\` to your \`prisma.config.ts\` file, or use the Prisma CLI with Bun
# Please add \`import "dotenv/config";\` to your \`prisma7.config.ts\` file, or use the Prisma CLI with Bun
# to load environment variables from .env files: https://pris.ly/prisma-config-env-vars.

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
Expand All @@ -391,7 +394,7 @@ test('works with provider param - MongoDB', async () => {
DATABASE_URL="mongodb+srv://root:randompassword@cluster0.ab1cd.mongodb.net/mydb?retryWrites=true&w=majority""
`)

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -410,7 +413,7 @@ test('works with --with-model param postgresql', async () => {
expect(schema).toMatch(defaultSchema({ withModel: true, datasourceProvider: 'postgresql' }))
expect(schema).toMatchSnapshot()

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -426,7 +429,7 @@ test('works with --with-model param mongodb', async () => {
expect(schema).toMatch(defaultSchema({ withModel: true, datasourceProvider: 'mongodb' }))
expect(schema).toMatchSnapshot()

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -442,7 +445,7 @@ test('works with --with-model param cockroachdb', async () => {
expect(schema).toMatch(defaultSchema({ withModel: true, datasourceProvider: 'cockroachdb' }))
expect(schema).toMatchSnapshot()

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -465,7 +468,7 @@ test('works with generator param - `go run github.com/steebchen/prisma-client-go
)
expect(schema).toMatchSnapshot()

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -485,7 +488,7 @@ test('works with preview features - mock test', async () => {
)
expect(schema).toMatchSnapshot()

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -508,7 +511,7 @@ test('works with preview features - multiple', async () => {
)
expect(schema).toMatchSnapshot()

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -526,7 +529,7 @@ test('works with custom output', async () => {
)
expect(schema).toMatchSnapshot()

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -543,7 +546,7 @@ test('warns when DATABASE_URL present in .env ', async () => {
const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatch(`DATABASE_URL="postgres://dont:overwrite@me:5432/tests"`)

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -561,7 +564,7 @@ test('appends when .env present', async () => {
expect(env).toMatch(/SOMETHING="is here"/)
expect(env).toMatch(/DATABASE_URL="prisma\+postgres:\/\/localhost:(\d+)\/\?api_key=eyJk.*TAifQ"/)

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -572,7 +575,7 @@ test('writes a minimal .gitignore file', async () => {
const gitignore = fs.readFileSync(join(ctx.tmpDir, '.gitignore'), 'utf-8')
expect(gitignore).toMatchSnapshot()

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -586,7 +589,7 @@ test('do not replace .gitignore file if already present', async () => {
const gitignoreAfter = fs.readFileSync(gitignorePath, 'utf-8')
expect(gitignoreAfter).toMatchSnapshot()

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand All @@ -597,7 +600,7 @@ test('uses determineClientOutputPath when no output is specified', async () => {
const schema = fs.readFileSync(join(ctx.tmpDir, 'prisma', 'schema.prisma'), 'utf-8')
expect(schema).toContain('output = "../lib/generated/prisma"')

const config = fs.readFileSync(join(ctx.tmpDir, 'prisma.config.ts'), 'utf-8')
const config = fs.readFileSync(join(ctx.tmpDir, 'prisma7.config.ts'), 'utf-8')
expect(config).toContain('defineConfig')
expect(config).toMatchSnapshot()
})
Expand Down
9 changes: 9 additions & 0 deletions packages/cli/src/__tests__/Studio.vitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ beforeEach(() => {
getPortMock.mockResolvedValue(55_555)
})

test('uses the Prisma 7 config filename in help examples', async () => {
const { Studio } = await import('../Studio')
const help = Studio.new('prisma').help()

expect(help).toEqual(expect.any(String))
expect(help).toContain('studio --config=./prisma7.config.ts')
expect(help).not.toContain('studio --config=./prisma.config.ts')
})

describe('Studio URL validation', () => {
beforeEach(() => {
vi.resetModules()
Expand Down
Loading
Loading