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

Commit

Permalink
(update/docs) - seedDb script/docs to run in api (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
ed42311 authored Aug 12, 2020
1 parent dbde304 commit fb9b9ac
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://grandstack.io/deploy-starter-netlify) [![Deploy to Vercel](https://vercel.com/button)](https://grandstack.io/deploy-starter-vercel) [![Provision Neo4j](https://grandstack.io/img/provision-neo4j.png)](https://sandbox.neo4j.com/?usecase=blank-sandbox)


# GRANDstack Starter

```
Expand Down Expand Up @@ -43,7 +42,7 @@ This will create a new directory `myNewApp`, download the latest release of the

### 3. Seed the database (optional)

Once the application is running, in another terminal run
Make sure your application is running locally with `npm start` or `yarn start`, open another terminal and run

```
npm run seedDb
Expand Down Expand Up @@ -170,7 +169,6 @@ If you want to load the example DB after the services have been started:
docker-compose run api npm run seedDb
```


You can find instructions for other ways to use Neo4j (Neo4j Desktop, Neo4j Aura, and other cloud services) in the [Neo4j directory README.](./neo4j)

This project is licensed under the Apache License v2.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"prettier-eslint-cli": "^5.0.0"
},
"scripts": {
"seedDb": "node scripts/seed.js",
"start": "node scripts/start-dev.js",
"build": "node scripts/build.js",
"format": "find . -name \"*.js\" | grep -v node_modules | grep -v build | xargs prettier --write",
Expand Down
1 change: 1 addition & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ npm run start
- `start-dev.js` - starts the GraphQL API and web-react servers
- `build.js` - builds the api and web-react projects
- `inferSchema.js` - connect to Neo4j and generate inferred GraphQL type definitions, written to `./api/src/schema.graphql`
- `seed.js` - seeds the database locally from the api directory
19 changes: 19 additions & 0 deletions scripts/seed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const utils = require('./utils')
const { API_DIR, runner } = utils
const concurrently = require('concurrently')

const jobs = [
{
name: 'api:seedDB',
command: `cd ${API_DIR} && ${runner} run seedDb`,
prefixColor: 'yellow',
},
]

concurrently(jobs, {
restartTries: 3,
prefix: '{time} {name} |',
timestampFormat: 'HH:mm:ss',
}).catch((e) => {
console.error(e.message)
})
20 changes: 20 additions & 0 deletions scripts/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const path = require('path')
const execa = require('execa')

const API_DIR = path.join(__dirname, '../api')

const shouldUseYarn = () => {
try {
execa.sync('yarnpkg', ['--version'])
return true
} catch (e) {
return false
}
}

const runner = shouldUseYarn() ? 'yarn' : 'npm'

module.exports = {
runner,
API_DIR,
}

0 comments on commit fb9b9ac

Please sign in to comment.