Skip to content

Commit

Permalink
fix: use prisma-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
schickling committed Jan 14, 2018
1 parent 6da8fc3 commit a130d7c
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 2,700 deletions.
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
"version": "0.0.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"repository": "[email protected]:graphql-boilerplates/graphql-boilerplate-install.git",
"repository":
"[email protected]:graphql-boilerplates/graphql-boilerplate-install.git",
"author": "Johannes Schickling <[email protected]>",
"contributors": [
"Kim Brandwijk <[email protected]>"
],
"contributors": ["Kim Brandwijk <[email protected]>"],
"license": "MIT",
"scripts": {
"prepublishOnly": "npm run build",
"build": "rimraf dist && tsc -d",
"test": "echo No tests..."
},
"peerDependencies": {
"graphcool": "1.0.0-beta4.1.1"
"prisma-cli": "beta"
},
"dependencies": {
"cross-spawn": "5.1.0",
Expand Down
33 changes: 0 additions & 33 deletions src/graphcool.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { replaceInFile, replaceInFiles } from './utils'
export { deploy, writeEnv, getInfo } from './graphcool'
export { deploy, writeEnv, getInfo } from './prisma'
36 changes: 36 additions & 0 deletions src/prisma.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as fs from 'fs'
import { spawn } from './utils'

export async function deploy(silent: boolean) {
const options = { stdio: silent ? 'pipe' : 'inherit' }

return spawn('prisma', ['deploy'], options)
.then(res => {
if (!silent) {
console.log(res)
}
})
.catch(err => console.error(err))
}

export async function getInfo(): Promise<any> {
return spawn('prisma', ['info', '--current', '--json'], { stdio: 'pipe' })
.then(res => JSON.parse(res))
.catch(err => console.error(err))
}

export async function writeEnv() {
return spawn('prisma', ['info', '--current', '--json'], { stdio: 'pipe' })
.then(res => {
const endpointInfo = JSON.parse(res)
fs.writeFileSync(
'.env',
`\
PRISMA_SECRET=${endpointInfo.secret}
PRISMA_STAGE=${endpointInfo.stage}
PRISMA_CLUSTER=${endpointInfo.cluster}
PRISMA_ENDPOINT=${endpointInfo.httpEndpoint}`,
)
})
.catch(err => console.error(err))
}
Loading

0 comments on commit a130d7c

Please sign in to comment.