Skip to content

Commit

Permalink
Add seeding script
Browse files Browse the repository at this point in the history
The app will no longer work unless the seed script is run.
We don't always want to seed this data as we hit the prod GH API.
For now the seeding can be run by passing a flag to the script/bootstrap
command.
  • Loading branch information
rich committed Sep 11, 2024
1 parent 108b6d0 commit 44cc80c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,9 @@ In order for Towtruck to communicate with the GitHub API, it needs several piece
- `CLIENT_ID`: A unique alphanumeric ID assigned to the GitHub App.
- `CLIENT_SECRET`: A token used to authenticate API requests. These are generated by GitHub in the app settings.
- `WEBHOOK_SECRET`: A user-defined secret used to authenticate GitHub to Towtruck for receiving webhooks. This must be exactly the same as it is entered in the app settings on GitHub.


### Seedings

Once all the other setup steps have been completed run `script/seed` or `script/bootstrap --seed` to seed the data.
This will call the Github API which is rate limit so take care not to to run the script too often.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"test": "node --test",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"format": "prettier --write ."
"format": "prettier --write .",
"seed": "node --env-file=.env ./dataScripts/fetchAllRepos.js"
},
"author": "dxw",
"license": "MIT",
Expand Down
7 changes: 7 additions & 0 deletions script/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ nvm install

echo "==> Installing node modules..."
npm install

if [ -n "$1" ]; then
echo "==> Seeding data..."
npm run seed
else
echo "==> Skipping seeding data..."
fi
10 changes: 10 additions & 0 deletions script/seed
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# script/seed: Seeds the necessary data

set -e

cd "$(dirname "$0")/.."

echo "==> Seeding data..."
npm run seed

0 comments on commit 44cc80c

Please sign in to comment.