Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cli): add deprecation message for introspect command #8763

Merged
merged 16 commits into from Aug 18, 2021
Merged
15 changes: 11 additions & 4 deletions packages/cli/src/__tests__/__helpers__/snapshotSerializer.ts
Expand Up @@ -39,6 +39,11 @@ function normalizeRustError(str) {
function normalizeTmpDir(str) {
return str.replace(/\/tmp\/([a-z0-9]+)\//g, '/tmp/dir/')
}

function normalizeMs(str) {
return str.replace(/\d{1,3}ms/g, 'XXms')
}

const serializer = {
test(value) {
return typeof value === 'string' || value instanceof Error
Expand All @@ -53,10 +58,12 @@ const serializer = {
return prepareSchemaForSnapshot(
normalizeGithubLinks(
normalizeRustError(
normalizeTmpDir(
normalizeGithubLinks(
normalizeToUnixPaths(
removePlatforms(trimErrorPaths(stripAnsi(message))),
normalizeMs(
normalizeTmpDir(
normalizeGithubLinks(
normalizeToUnixPaths(
removePlatforms(trimErrorPaths(stripAnsi(message))),
),
),
),
),
Expand Down
60 changes: 29 additions & 31 deletions packages/cli/src/__tests__/commands/Generate.test.ts
Expand Up @@ -33,9 +33,7 @@ describe('using cli', () => {
throw new Error(data.stderr + data.stdout)
}

expect(cleanSnapshot(data.stdout)).toContain(
`✔ Generated I am a minimal generator to`,
)
expect(cleanSnapshot(data.stdout)).toContain(`I am a minimal generator`)
}, 30000) // timeout
})

Expand All @@ -45,13 +43,13 @@ describe('--schema from project directory', () => {
const result = Generate.new().parse(['--schema=./schema.prisma'])
await expect(result).resolves.toMatchInlineSnapshot(`

✔ Generated Prisma Client (0.0.0) to ./@prisma/client in 133ms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
\`\`\`
import { PrismaClient } from './@prisma/client'
const prisma = new PrismaClient()
\`\`\`
`)
✔ Generated Prisma Client (0.0.0) to ./@prisma/client in XXms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
\`\`\`
import { PrismaClient } from './@prisma/client'
const prisma = new PrismaClient()
\`\`\`
`)
})

it('--schema relative path: should fail - invalid path', async () => {
Expand All @@ -68,13 +66,13 @@ describe('--schema from project directory', () => {
const result = Generate.new().parse([`--schema=${absoluteSchemaPath}`])
await expect(result).resolves.toMatchInlineSnapshot(`

✔ Generated Prisma Client (0.0.0) to ./@prisma/client in 144ms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
\`\`\`
import { PrismaClient } from './@prisma/client'
const prisma = new PrismaClient()
\`\`\`
`)
✔ Generated Prisma Client (0.0.0) to ./@prisma/client in XXms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
\`\`\`
import { PrismaClient } from './@prisma/client'
const prisma = new PrismaClient()
\`\`\`
`)
})

it('--schema absolute path: should fail - invalid path', async () => {
Expand All @@ -95,13 +93,13 @@ describe('--schema from parent directory', () => {
])
await expect(result).resolves.toMatchInlineSnapshot(`

✔ Generated Prisma Client (0.0.0) to ./subdirectory/@prisma/client in 147ms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
\`\`\`
import { PrismaClient } from './subdirectory/@prisma/client'
const prisma = new PrismaClient()
\`\`\`
`)
✔ Generated Prisma Client (0.0.0) to ./subdirectory/@prisma/client in XXms
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why the the indentation changed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One mysterious thing for me with Jest ...

You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
\`\`\`
import { PrismaClient } from './subdirectory/@prisma/client'
const prisma = new PrismaClient()
\`\`\`
`)
})

it('--schema relative path: should fail - invalid path', async () => {
Expand All @@ -122,13 +120,13 @@ describe('--schema from parent directory', () => {
const result = Generate.new().parse([`--schema=${absoluteSchemaPath}`])
await expect(result).resolves.toMatchInlineSnapshot(`

✔ Generated Prisma Client (0.0.0) to ./subdirectory/@prisma/client in 131ms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
\`\`\`
import { PrismaClient } from './subdirectory/@prisma/client'
const prisma = new PrismaClient()
\`\`\`
`)
✔ Generated Prisma Client (0.0.0) to ./subdirectory/@prisma/client in XXms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
\`\`\`
import { PrismaClient } from './subdirectory/@prisma/client'
const prisma = new PrismaClient()
\`\`\`
`)
})

it('--schema absolute path: should fail - invalid path', async () => {
Expand Down