Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
Merge branch 'alpha' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
mavilein committed Apr 3, 2019
2 parents 4059b4b + 20019ff commit 57b818b
Show file tree
Hide file tree
Showing 293 changed files with 19,909 additions and 1,898 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "prisma-query"]
path = server/prisma-rs/libs/prisma-query
url = https://github.com/prisma/prisma-query.git
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Command, flags, Flags } from 'prisma-cli-engine'
import { Command } from 'prisma-cli-engine'
import chalk from 'chalk'

export default class Account extends Command {
Expand Down
64 changes: 53 additions & 11 deletions cli/packages/prisma-cli-core/src/commands/deploy/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import { Command, flags, Flags, DeployPayload, Config } from 'prisma-cli-engine'
import { Cluster } from 'prisma-yml'
import chalk from 'chalk'
import * as inquirer from 'inquirer'
import * as path from 'path'
import * as fs from 'fs-extra'
import { Seeder } from '../seed/Seeder'
const debug = require('debug')('deploy')
import {
prettyTime,
concatName,
defaultDockerCompose,
printAdminLink,
} from '../../utils/util'
import * as sillyname from 'sillyname'
import { prettyTime, concatName, printAdminLink } from '../../utils/util'
import { EndpointDialog } from '../../utils/EndpointDialog'
import { spawnSync } from 'npm-run'
import { spawnSync as nativeSpawnSync } from 'child_process'
import * as figures from 'figures'
import { satisfiesVersion } from '../../utils/satisfiesVersion'
import GenerateCommand from '../generate/generate'

export default class Deploy extends Command {
static topic = 'deploy'
Expand Down Expand Up @@ -68,6 +62,9 @@ ${chalk.gray(
description: 'Path to Prisma definition file',
char: 'p',
}),
'no-generate': flags.boolean({
description: 'Disable implicit client generation',
}),
}
private showedHooks: boolean = false
async run() {
Expand All @@ -79,6 +76,7 @@ ${chalk.gray(
const envFile = this.flags['env-file']
const dryRun = this.flags['dry-run']
const noMigrate = this.flags['no-migrate']
const noGenerate = this.flags['no-generate']

if (envFile && !fs.pathExistsSync(path.join(this.config.cwd, envFile))) {
await this.out.error(`--env-file path '${envFile}' does not exist`)
Expand Down Expand Up @@ -185,6 +183,7 @@ ${chalk.gray(
projectNew,
workspace!,
noMigrate,
noGenerate,
)
}

Expand Down Expand Up @@ -231,6 +230,7 @@ ${chalk.gray(
projectNew: boolean,
workspace: string | null,
noMigrate: boolean,
noGenerate: boolean,
): Promise<void> {
let before = Date.now()

Expand Down Expand Up @@ -269,7 +269,6 @@ ${chalk.gray(
)
let done = false
while (!done) {
const revision = migrationResult.migration.revision
const migration = await this.client.getMigration(
concatName(cluster, serviceName, workspace),
stageName,
Expand Down Expand Up @@ -334,6 +333,49 @@ ${chalk.gray(
}
}

if (
migrationResult &&
migrationResult.migration &&
migrationResult.migration.revision > 0 &&
!dryRun &&
!noGenerate
) {
let done = false
while (!done) {
const migration = await this.client.getMigration(
concatName(cluster, serviceName, workspace),
stageName,
)
if (
(migration.errors &&
migration.errors.length === 0 &&
migration.applied === migrationResult.migration.steps.length) ||
['SUCCESS'].includes(migration.status)
) {
done = true
const isGenerateHookPresent = hooks.some(
hook => hook.includes('prisma') && hook.includes('generate'),
)
if (isGenerateHookPresent) {
this.out.log(
chalk.yellow(
`Warning: The \`prisma generate\` command was executed twice. Since Prisma 1.31, the Prisma client is generated automatically after running \`prisma deploy\`. It is not necessary to generate it via a \`post-deploy\` hook any more, you can therefore remove the hook if you do not need it otherwise.`,
),
)
}
const generateCommand = new GenerateCommand({
config: this.config
})
generateCommand.run()
} else {
debug('skipping implicit generate at migration polling')
}
await new Promise(r => setTimeout(r, 500))
}
} else {
debug('skipping implicit generate at migrationResult')
}

if (migrationResult.migration) {
if (
this.definition.definition!.seed &&
Expand Down Expand Up @@ -450,7 +492,7 @@ ${chalk.gray(

if (steps.length > 0) {
this.out.log(
'\n' + chalk.bold(dryRun ? 'Potential changees:' : 'Changes:'),
'\n' + chalk.bold(dryRun ? 'Potential changes:' : 'Changes:'),
)
this.out.migration.printMessages(steps)
this.out.log('')
Expand Down Expand Up @@ -485,4 +527,4 @@ ${chalk.gray(

export function isValidProjectName(projectName: string): boolean {
return /^[A-Z](.*)/.test(projectName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { DatabaseType, IGQLType } from 'prisma-datamodel'
import { fetchAndPrintSchema } from '../deploy/printSchema'

const debug = require('debug')('generate')
export default class GenereateCommand extends Command {
export default class GenerateCommand extends Command {
static topic = 'generate'
static description = 'Generate a schema or Prisma Bindings'
static flags: Flags = {
Expand All @@ -39,6 +39,7 @@ export default class GenereateCommand extends Command {
}),
}
async run() {
this.flags = this.flags || {}
const envFile = this.flags['env-file']
await this.definition.load(this.flags, envFile)

Expand Down
3 changes: 2 additions & 1 deletion cli/packages/prisma-client-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"http-link-dataloader": "^0.1.6",
"jsonwebtoken": "^8.3.0",
"lodash.flatten": "^4.4.0",
"prettier": "1.14.3",
"prettier": "1.16.4",
"prisma-datamodel": "1.23.0-alpha.1",
"prisma-generate-schema": "1.20.4",
"subscriptions-transport-ws": "^0.9.15",
Expand All @@ -39,6 +39,7 @@
},
"devDependencies": {
"@types/graphql": "14.0.3",
"@types/prettier": "1.16.1",
"ava": "^0.25.0",
"graphql": "^14.0.2",
"semantic-release": "^15.10.4",
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions cli/packages/prisma-client-lib/src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class Client {
},
inactivityTimeout: 60000,
lazy: true,
reconnect: true,
},
WS,
)
Expand Down
Loading

0 comments on commit 57b818b

Please sign in to comment.