Skip to content

Commit

Permalink
chore: printWidth from 80 to 120 (#9458)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolg42 committed Oct 18, 2021
1 parent 14cdd28 commit bbdf1c2
Show file tree
Hide file tree
Showing 253 changed files with 1,597 additions and 5,084 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.yml
Expand Up @@ -2,4 +2,4 @@ tabWidth: 2
trailingComma: all
singleQuote: true
semi: false
printWidth: 80
printWidth: 120
2 changes: 1 addition & 1 deletion packages/cli/.prettierrc.yml
Expand Up @@ -2,4 +2,4 @@ tabWidth: 2
trailingComma: all
singleQuote: true
semi: false
printWidth: 80
printWidth: 120
22 changes: 6 additions & 16 deletions packages/cli/helpers/build.ts
Expand Up @@ -47,29 +47,19 @@ const cliLifecyclePlugin: esbuild.Plugin = {

build.onEnd(async () => {
// we copy the contents from @prisma/studio to build
copySync(
path.join(require.resolve('@prisma/studio/package.json'), '../dist'),
'./build/public',
{
recursive: true,
overwrite: true,
},
)
copySync(path.join(require.resolve('@prisma/studio/package.json'), '../dist'), './build/public', {
recursive: true,
overwrite: true,
})

// we copy the contents from checkpoint-client to build
await copyFile(
path.join(
require.resolve('checkpoint-client/package.json'),
'../dist/child.js',
),
path.join(require.resolve('checkpoint-client/package.json'), '../dist/child.js'),
'./build/child.js',
)

// we copy the contents from xdg-open to build
await copyFile(
path.join(require.resolve('open/package.json'), '../xdg-open'),
'./build/xdg-open',
)
await copyFile(path.join(require.resolve('open/package.json'), '../xdg-open'), './build/xdg-open')

await replaceFirstLine('./build/index.js', '#!/usr/bin/env node\n')

Expand Down
4 changes: 1 addition & 3 deletions packages/cli/helpers/copy-prisma-client.ts
Expand Up @@ -9,9 +9,7 @@ const clientPath = path.dirname(require.resolve('@prisma/client'))
const clientPkg = require('@prisma/client/package.json')

// we compute the paths of the files that would get npm published
const clientFiles = (clientPkg.files ?? []).map((file: string) =>
path.join(clientPath, file),
)
const clientFiles = (clientPkg.files ?? []).map((file: string) => path.join(clientPath, file))

// we copy each file that we found in pkg to a new destination
for (const file of clientFiles) {
Expand Down
43 changes: 8 additions & 35 deletions packages/cli/src/CLI.ts
@@ -1,13 +1,6 @@
import chalk from 'chalk'
import type { Command, Commands } from '@prisma/sdk'
import {
arg,
isError,
format,
HelpError,
unknownCommand,
logger,
} from '@prisma/sdk'
import { arg, isError, format, HelpError, unknownCommand, logger } from '@prisma/sdk'
import { Version } from './Version'
import { link } from '@prisma/sdk'
import { ensureBinariesExist } from '@prisma/engines'
Expand All @@ -19,10 +12,7 @@ export class CLI implements Command {
static new(cmds: Commands, ensureBinaries: string[]): CLI {
return new CLI(cmds, ensureBinaries)
}
private constructor(
private readonly cmds: Commands,
private readonly ensureBinaries: string[],
) {}
private constructor(private readonly cmds: Commands, private readonly ensureBinaries: string[]) {}

async parse(argv: string[]): Promise<string | Error> {
const args = arg(argv, {
Expand Down Expand Up @@ -55,20 +45,14 @@ export class CLI implements Command {
const cmdName = args._[0]
// Throw if "lift"
if (cmdName === 'lift') {
throw new Error(
`${chalk.red('prisma lift')} has been renamed to ${chalk.green(
'prisma migrate',
)}`,
)
throw new Error(`${chalk.red('prisma lift')} has been renamed to ${chalk.green('prisma migrate')}`)
}
// warn if "introspect"
else if (cmdName === 'introspect') {
logger.warn('')
logger.warn(
`${chalk.bold(
`The ${chalk.underline(
'prisma introspect',
)} command is deprecated. Please use ${chalk.green(
`The ${chalk.underline('prisma introspect')} command is deprecated. Please use ${chalk.green(
'prisma db pull',
)} instead.`,
)}`,
Expand All @@ -85,20 +69,11 @@ export class CLI implements Command {

let argsForCmd: string[]
if (args['--experimental']) {
argsForCmd = [
...args._.slice(1),
`--experimental=${args['--experimental']}`,
]
argsForCmd = [...args._.slice(1), `--experimental=${args['--experimental']}`]
} else if (args['--preview-feature']) {
argsForCmd = argsForCmd = [
...args._.slice(1),
`--preview-feature=${args['--preview-feature']}`,
]
argsForCmd = argsForCmd = [...args._.slice(1), `--preview-feature=${args['--preview-feature']}`]
} else if (args['--early-access-feature']) {
argsForCmd = argsForCmd = [
...args._.slice(1),
`--early-access-feature=${args['--early-access-feature']}`,
]
argsForCmd = argsForCmd = [...args._.slice(1), `--early-access-feature=${args['--early-access-feature']}`]
} else {
argsForCmd = args._.slice(1)
}
Expand All @@ -119,9 +94,7 @@ export class CLI implements Command {
private static help = format(`
${
process.platform === 'win32' ? '' : chalk.bold.green('◭ ')
}Prisma is a modern DB toolkit to query, migrate and model your database (${link(
'https://prisma.io',
)})
}Prisma is a modern DB toolkit to query, migrate and model your database (${link('https://prisma.io')})
${chalk.bold('Usage')}
Expand Down
14 changes: 5 additions & 9 deletions packages/cli/src/Dev.ts
Expand Up @@ -10,18 +10,14 @@ export class Dev implements Command {
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-unused-vars
async parse(argv: string[]): Promise<string> {
return format(`
${chalk.redBright(
'Prisma CLI does not include a `dev` command any more right now.',
)}
${chalk.redBright('Prisma CLI does not include a `dev` command any more right now.')}
If you want to run Prisma Studio, use ${chalk.green('prisma studio')}.
If you want to generate the Prisma Client, use ${chalk.green(
'prisma generate',
)} (or ${chalk.green('prisma generate --watch')})
If you want to generate the Prisma Client, use ${chalk.green('prisma generate')} (or ${chalk.green(
'prisma generate --watch',
)})
If you want to update your schema, use ${chalk.green('prisma db pull')}.
If you want to migrate your database, use ${chalk.green(
'prisma migrate',
)}.
If you want to migrate your database, use ${chalk.green('prisma migrate')}.
`)
}
}
32 changes: 6 additions & 26 deletions packages/cli/src/Doctor.ts
Expand Up @@ -81,11 +81,7 @@ ${chalk.bold('Examples')}
)
}

console.log(
chalk.dim(
`Prisma schema loaded from ${path.relative(process.cwd(), schemaPath)}`,
),
)
console.log(chalk.dim(`Prisma schema loaded from ${path.relative(process.cwd(), schemaPath)}`))

const schema = await readFile(schemaPath, 'utf-8')
const localDmmf = await getDMMF({ datamodel: schema })
Expand All @@ -94,10 +90,7 @@ ${chalk.bold('Examples')}
console.error(`👩‍⚕️🏥 Prisma Doctor checking the database...`)

const connectionString = config.datasources[0].url
const canConnect = await canConnectToDatabase(
connectionString.value,
path.dirname(schemaPath),
)
const canConnect = await canConnectToDatabase(connectionString.value, path.dirname(schemaPath))
if (typeof canConnect !== 'boolean') {
throw new Error(`${canConnect.code}: ${canConnect.message}`)
}
Expand All @@ -116,18 +109,14 @@ ${chalk.bold('Examples')}

const remoteDmmf = await getDMMF({ datamodel })

const remoteModels = keyBy(
remoteDmmf.datamodel.models,
(m) => m.dbName ?? m.name,
)
const remoteModels = keyBy(remoteDmmf.datamodel.models, (m) => m.dbName ?? m.name)

const modelPairs = localDmmf.datamodel.models.map((localModel) => ({
localModel,
remoteModel: remoteModels[localModel.dbName ?? localModel.name],
}))

const getFieldName = (f: DMMF.Field) =>
f.dbNames && f.dbNames.length > 0 ? f.dbNames[0] : f.name
const getFieldName = (f: DMMF.Field) => (f.dbNames && f.dbNames.length > 0 ? f.dbNames[0] : f.name)

const messages: string[] = []

Expand All @@ -145,12 +134,7 @@ ${chalk.bold('Examples')}
const remoteField = remoteFields[getFieldName(localField)]
if (!remoteField) {
missingFields.push(localField)
} else if (
!equal(
pick(localField, ['type', 'isList']),
pick(remoteField, ['type', 'isList']),
)
) {
} else if (!equal(pick(localField, ['type', 'isList']), pick(remoteField, ['type', 'isList']))) {
incorrectFieldType.push({ localField, remoteField })
}
}
Expand Down Expand Up @@ -194,11 +178,7 @@ function printModelMessage({
missingFields: DMMF.Field[]
incorrectFieldType: IncorrectFieldTypes
}) {
if (
!missingModel &&
missingFields.length === 0 &&
incorrectFieldType.length === 0
) {
if (!missingModel && missingFields.length === 0 && incorrectFieldType.length === 0) {
return null
}
let msg = `${chalk.bold.underline(model.name)}\n`
Expand Down
19 changes: 3 additions & 16 deletions packages/cli/src/Format.ts
@@ -1,12 +1,5 @@
import type { Command } from '@prisma/sdk'
import {
arg,
format,
formatSchema,
getDMMF,
getSchemaPath,
HelpError,
} from '@prisma/sdk'
import { arg, format, formatSchema, getDMMF, getSchemaPath, HelpError } from '@prisma/sdk'
import chalk from 'chalk'
import fs from 'fs'
import os from 'os'
Expand Down Expand Up @@ -74,11 +67,7 @@ Or specify a Prisma schema path
)
}

console.log(
chalk.dim(
`Prisma schema loaded from ${path.relative(process.cwd(), schemaPath)}`,
),
)
console.log(chalk.dim(`Prisma schema loaded from ${path.relative(process.cwd(), schemaPath)}`))

let output = await formatSchema({
schemaPath,
Expand All @@ -93,9 +82,7 @@ Or specify a Prisma schema path
fs.writeFileSync(schemaPath, output)
const after = Date.now()

return `Formatted ${chalk.underline(schemaPath)} in ${formatms(
after - before,
)} 🚀`
return `Formatted ${chalk.underline(schemaPath)} in ${formatms(after - before)} 🚀`
}

public help(error?: string): string | HelpError {
Expand Down

0 comments on commit bbdf1c2

Please sign in to comment.