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

[v0.25] Remove warning if you scaffold a model with a relation #1757

Merged
merged 3 commits into from Feb 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 1 addition & 22 deletions packages/cli/src/commands/generate/scaffold/scaffold.js
@@ -1,9 +1,7 @@
import fs from 'fs'
import path from 'path'

import boxen from 'boxen'
import camelcase from 'camelcase'
import chalk from 'chalk'
import humanize from 'humanize-string'
import Listr from 'listr'
import { paramCase } from 'param-case'
Expand Down Expand Up @@ -449,29 +447,10 @@ export const handler = async ({
javascript,
}) => {
const { model, path } = splitPathAndModel(modelArg)

const t = tasks({ model, path, force, typescript, javascript })
const schema = await getSchema(pascalcase(pluralize.singular(model)))
const line1 =
chalk.bold.yellow('WARNING') +
`: Because the data model "${pascalcase(model)}" contains a`
const line2 = 'Prisma @relation, the generated CRUD code and test must be'
const line3 =
'manually modified to work correctly. See this doc for more info:'
const line4 = chalk.underline.blue(
'https://redwoodjs.com/docs/schema-relations'
)

try {
await t.run()
if (relationsForModel(schema).length) {
console.log(
boxen(line1 + '\n' + line2 + '\n' + line3 + '\n' + line4, {
padding: 1,
margin: 1,
borderStyle: 'single',
})
)
}
} catch (e) {
console.log(c.error(e.message))
}
Expand Down