Skip to content

Commit 139828d

Browse files
authored
refactor: 'create_initial_user.sh' helper script (#59)
I've been running this `curl` command a bunch of times every day (whenever I restart my dev server) - so moving it to a more convenient place.
1 parent 5d7112f commit 139828d

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

develop.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,25 @@
22

33
set -euo pipefail
44

5+
EMAIL="${EMAIL:-admin@coder.com}"
6+
USERNAME="${USERNAME:-admin}"
7+
ORGANIZATION="${ORGANIZATION:-ACME-Corp}"
8+
PASSWORD="${PASSWORD:-password}"
59
PROJECT_ROOT="$(git rev-parse --show-toplevel)"
610
cd "${PROJECT_ROOT}"
711

12+
# Helper to create an initial user
13+
function create_initial_user() {
14+
# TODO: We need to wait for `coderd` to spin up -
15+
# need to replace with a deterministic strategy
16+
sleep 5s
17+
18+
curl -X POST \
19+
-d "{\"email\": \"$EMAIL\", \"username\": \"$USERNAME\", \"organization\": \"$ORGANIZATION\", \"password\": \"$PASSWORD\"}" \
20+
-H 'Content-Type:application/json' \
21+
http://localhost:3000/api/v2/users
22+
}
23+
824
# Do initial build - a dev build for coderd.
925
# It's OK that we don't build the front-end before - because the front-end
1026
# assets are handled by the `yarn dev` devserver.
@@ -13,4 +29,4 @@ make bin/coderd
1329
# This is a way to run multiple processes in parallel, and have Ctrl-C work correctly
1430
# to kill both at the same time. For more details, see:
1531
# https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script
16-
(trap 'kill 0' SIGINT; CODERV2_HOST=http://127.0.0.1:3000 yarn dev & ./bin/coderd)
32+
(trap 'kill 0' SIGINT; create_initial_user & CODERV2_HOST=http://127.0.0.1:3000 yarn dev & ./bin/coderd)

0 commit comments

Comments
 (0)