-
Notifications
You must be signed in to change notification settings - Fork 45
/
run
executable file
Β·133 lines (110 loc) Β· 2.79 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env bash
set -e
#
# Helpers
##################################################
red="\e[31m"
reset="\e[39m"
run() {
task=${1}
shift
echo -e [${task}] ${@}
${@}
}
fail() {
echo -e ${red}${@}${reset}
exit 1
}
#
# Commands
##################################################
pluginDir=plugins/verdaccio-github-oauth-ui
#
# Remove the plugin from node_modules
#
clean() {
run clean rm -rf .parcel-cache/ dist/ package/ plugins/
}
#
# Build server, config and client
#
build() {
# https://github.com/parcel-bundler/parcel/issues/8005#issuecomment-1120149358
export NODE_OPTIONS=--no-experimental-fetch
# bundle with parcel
run build yarn parcel build --target client &
run build yarn parcel build --target server &
run build yarn parcel build --target cli &
wait
# add node shebang
printf '%s\n%s\n' '#!/usr/bin/env node' "$(cat dist/cli/index.js)" > dist/cli/index.js
# make executable
chmod +x dist/cli/index.js
}
#
# Copy the built plugin to node_modules
#
copy() {
run copy mkdir -p $pluginDir/
run copy cp -R dist $pluginDir/
run copy cp package.json $pluginDir/
}
typecheck() {
run typecheck yarn tsc --noEmit --project src/client/tsconfig.json &
run typecheck yarn tsc --noEmit --project src/server/tsconfig.json &
run typecheck yarn tsc --noEmit --project src/cli/tsconfig.json &
run typecheck yarn tsc --noEmit --project test/tsconfig.json &
wait
}
read-env() {
if [ -f .env ]; then
set -a
source .env
set +a
fi
}
cli-login() {
# npx verdaccio-github-oauth-ui --registry http://localhost:4873
run cli-login ./dist/cli/index.js --registry http://localhost:4873
}
cli-whoami() {
run cli-whoami npm whoami --registry http://localhost:4873
}
cli-publish() {
packageName="0.0.0-$(date +%Y%m%d%H%M%S)"
directory="package/$packageName"
run cli-publish mkdir -p "$directory"
echo "{\"name\":\"oauth-cli-test\",\"version\":\"$packageName\",\"license\":\"UNLICENSED\"}" > "$directory/package.json"
run cli-publish cd "$directory"
run cli-publish npm publish --registry http://localhost:4873
}
cli() {
cli-login
cli-whoami
cli-publish
}
docker_() {
read-env
run docker docker rm --force verdaccio || true
run docker docker build --tag verdaccio .
run docker docker run \
--publish 4873:4873 \
--env "GITHUB_CLIENT_ID=$GITHUB_CLIENT_ID" \
--env "GITHUB_CLIENT_SECRET=$GITHUB_CLIENT_SECRET" \
--env "GITHUB_TOKEN=$GITHUB_TOKEN" \
--name verdaccio verdaccio
}
#
# CLI
##################################################
#
# Call the function specified by the first parameter, passing all remaining
# parameters to the function. If no such function exists, display usage info.
#
if [ -n "$1" ] && type $1 | grep -i function > /dev/null; then
command="$1"
shift
$command ${@}
else
fail "No such command: $1"
fi