forked from n4bb12/verdaccio-github-oauth-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
Β·130 lines (106 loc) Β· 2.88 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
#!/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
#
# Build server, config and client
#
build() {
# copy assets
run build mkdir -p dist/public/
run build cp -R src/client/*.css dist/public/
# build with parcel
export NODE_ENV=production
run build yarn -s parcel build src/client/verdaccio-5.ts --target browser --experimental-scope-hoisting --out-dir dist/public
run build yarn -s parcel build src/server/index.ts --target node --no-minify --out-file server.js
run build yarn -s parcel build src/cli/index.ts --target node --no-minify --out-file cli.js
# add node shebang
printf '%s\n%s\n' '#!/usr/bin/env node' "$(cat dist/cli.js)" > dist/cli.js
}
#
# Remove the plugin from node_modules
#
clean() {
run clean rm -rf dist
run clean rm -rf $pluginDir
}
#
# 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/
}
read-env() {
if [ -f .env ]; then
set -a
source .env
set +a
fi
}
typecheck() {
run typecheck yarn -s tsc --noEmit --project src/client/tsconfig.json &
run typecheck yarn -s tsc --noEmit --project src/server/tsconfig.json &
run typecheck yarn -s tsc --noEmit --project src/cli/tsconfig.json &
run typecheck yarn -s tsc --noEmit --project test/tsconfig.json &
wait
}
test-whoami() {
run whoami npm whoami --registry http://localhost:4873
}
test-publish() {
packageName="0.0.0-$(date +%Y%m%d%H%M%S)"
directory="package/$packageName"
mkdir -p "$directory"
echo "{\"name\":\"oauth-cli-test\",\"version\":\"$packageName\",\"license\":\"UNLICENSED\"}" > "$directory/package.json"
run test-publish cd "$directory"
run test-publish npm publish --registry http://localhost:4873
}
test-cli() {
# npx verdaccio-github-oauth-ui --registry http://localhost:4873
run test-cli ./dist/cli.js --registry http://localhost:4873
test-publish
}
test-docker() {
read-env
run test-docker docker rm --force verdaccio || true
run test-docker docker build --tag verdaccio .
run test-docker docker run \
--publish 4873:4873 \
--env "GITHUB_ORG=$GITHUB_ORG" \
--env "GITHUB_CLIENT_ID=$GITHUB_CLIENT_ID" \
--env "GITHUB_CLIENT_SECRET=$GITHUB_CLIENT_SECRET" \
--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