-
Notifications
You must be signed in to change notification settings - Fork 321
/
index.js
45 lines (37 loc) · 1.1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const fs = require('fs')
const {
replaceInFiles,
deploy,
writeEnv,
getInfo,
makeSandboxEndpoint,
} = require('graphql-boilerplate-install')
module.exports = async ({ project, projectDir }) => {
const templateName = 'graphql-boilerplate'
const endpoint = await makeSandboxEndpoint(project)
process.chdir('server/')
replaceInFiles(
['src/index.js', 'package.json', 'prisma/prisma.yml'],
templateName,
project,
)
replaceInFiles(['src/index.js'], '__PRISMA_ENDPOINT__', endpoint)
replaceInFiles(['prisma/prisma.yml'], '__PRISMA_ENDPOINT__', endpoint)
console.log('Running $ prisma deploy...')
await deploy(false)
const info = await getInfo()
process.chdir('../')
replaceInFiles(
['server/src/generated/prisma-client/index.js'],
'__PRISMA_ENDPOINT__',
info.httpEndpoint,
)
console.log(`\
Next steps:
1. Change directory: \`cd ${projectDir}/server\`
2. Start local server: \`yarn start\` (you can now open a Playground at http://localhost:4000)
3. Change directory: \`cd ..\`
4. Start React app: \`yarn start\`
5. Open browser: http://localhost:3000
`)
}