-
Notifications
You must be signed in to change notification settings - Fork 3
/
run
executable file
·79 lines (65 loc) · 2.35 KB
/
run
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
set -eu -o pipefail
# this is the entrypoint for development. It wraps up compiling and calling dev.ts
# all arguments, changes, etc. should be found in src/dev.ts
# this script checks for all the prereqs and then calls dev.ts
export REGION_A=us-east-1
export PROJECT=mfp
# check node exists
if ! which node > /dev/null ; then
echo "node not found on the system. Install version in .nvmrc based on instructions in README"
exit 1
fi
# check node version
if ! diff .nvmrc <(node -v) > /dev/null ; then
echo "Uh Oh! The current node version does not match the version required in .nvmrc"
echo "If you have installed nvm, simply running 'nvm use' in this directory should solve the problem"
echo "If you don't have nvm yet, the instructions in the README should sort you."
echo "** Don't forget to add the bit to your shell profile **"
exit 1
fi
# check yarn exists
if ! which yarn > /dev/null ; then
echo "yarn not found on the system. On macOS, you can install it with 'brew install yarn'"
exit 1
fi
# check serverless is installed globally.
if ! which serverless > /dev/null ; then
echo "installing serverless globally"
yarn global add [email protected]
fi
# have to ensure that yarn install is up to date.
# we use .yarn_install as a marker for the last time `yarn install` was run. Rerun the command when yarn.lock is updated
if [ "yarn.lock" -nt ".yarn_install" ]; then
yarn install
touch .yarn_install
fi
# Parse arguments
UPDATE_ENV=false
ARGS=()
for arg in "$@"; do
case $arg in
--update-env)
UPDATE_ENV=true
;;
*)
ARGS+=("$arg")
;;
esac
done
# Inject secrets to .env if the flag is set
if [ "$UPDATE_ENV" = true ]; then
# Check if 1Password CLI is installed
if ! which op > /dev/null; then
echo "The MDCT team uses 1Password to store and retrieve development credentials. If you do not have a 1Password account please request one."
exit 1
fi
# call 1password vault to retrieve secrets
op inject -i .env.tpl -o .env -f
op inject -i services/ui-src/.env.tpl -o services/ui-src/.env -f
sed -i "" -e "s/# pragma: allowlist secret//g" .env
sed -i "" -e "s/# pragma: allowlist secret//g" services/ui-src/.env
fi
# build and run dev.ts
# tsc is configured to build what we expect in tsconfig.json
./node_modules/.bin/tsc && node ./build_dev/run.js "${ARGS[@]-}"