-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathjustfile
More file actions
164 lines (140 loc) · 5.02 KB
/
Copy pathjustfile
File metadata and controls
164 lines (140 loc) · 5.02 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# To run these commands, read CONTRIBUTING.md
# Affects authoring this Justfile:
# https://github.com/casey/just?tab=readme-ov-file#positional-arguments
set positional-arguments := true
# List all available commands when running `just` without arguments
_default:
@just --list
rm-lockfiles:
#!/usr/bin/env sh
for dir in template-*; do
if [ -d "$dir" ] && [ -f "$dir/package-lock.json" ]; then
rm -f "$dir/package-lock.json"
rm -f "$dir/bun.lockb"
fi
done
# Since the lockfiles are deleted by the CLI tool when the project is downloaded
# (in order to allow dependencies to be installed through any package manager),
# it’s a good idea to regenerate them from time to time to ensure that
# templates still work.
regenerate-lockfiles:
just rm-lockfiles
just install-all
# Install npm dependencies in all template folders
install-all:
#!/usr/bin/env sh
set -e
total=0
for dir in template-*; do
if [ -d "$dir" ] && [ -f "$dir/package.json" ]; then
total=$((total+1))
fi
done
counter=0
install_deps() {
dir="$1"
counter=$((counter+1))
printf "\n\033[35m[%s/%s] Installing dependencies in \033[36m%s\033[35m\033[0m\n" "$counter" "$total" "$dir"
if [ "$dir" = "template-astro" ]; then
(cd "$dir" && bun install)
else
(cd "$dir" && npm install)
fi
}
for dir in template-*; do
if [ -d "$dir" ] && [ -f "$dir/package.json" ]; then
install_deps "$(basename $dir)"
fi
done
# Clean install of npm dependencies in all template folders.
# Unlike `install-all`, this uses `npm ci` / `bun install --frozen-lockfile`,
# which never rewrite lockfiles. Used by `update-ai-files` so the resulting
# diff contains only AI files and no lockfile churn.
_install-all-clean:
#!/usr/bin/env sh
set -e
total=0
for dir in template-*; do
if [ -d "$dir" ] && [ -f "$dir/package.json" ]; then
total=$((total+1))
fi
done
counter=0
install_deps() {
dir="$1"
counter=$((counter+1))
printf "\n\033[35m[%s/%s] Installing dependencies in \033[36m%s\033[35m\033[0m\n" "$counter" "$total" "$dir"
if [ "$dir" = "template-astro" ]; then
(cd "$dir" && bun install --frozen-lockfile)
else
(cd "$dir" && npm ci)
fi
}
for dir in template-*; do
if [ -d "$dir" ] && [ -f "$dir/package.json" ]; then
install_deps "$(basename $dir)"
fi
done
regenerate-codegen: install-all
#!/usr/bin/env sh
set -e
total=0
for dir in template-*; do
if [ -d "$dir" ] && [ -f "$dir/package.json" ]; then
total=$((total+1))
fi
done
# Set up environment variables in a new dev deployment
printf "\n\033[35mSetting up environment variables in a dev deployment\033[0m\n"
cd template-bare
npx convex dev --once --configure existing --team convex-playground --project templates-regenerate-codegen --dev-deployment cloud
npx convex env set CLERK_JWT_ISSUER_DOMAIN "https://placeholder.authkit.dev/"
npx convex env set WORKOS_CLIENT_ID client_placeholder
npx convex env set WORKOS_CLIENT_SECRET placeholder
npx convex env set WORKOS_ENVIRONMENT_ID environment_placeholder
npx convex env set WORKOS_ENVIRONMENT_API_KEY sk_test_placeholder
cd ..
counter=0
regenerate() {
dir="$1"
counter=$((counter+1))
printf "\n\033[35m[%s/%s] Updating codegen in \033[36m%s\033[35m\033[0m\n" "$counter" "$total" "$dir"
# convex-playground/templates-regenerate-codegen is an empty project that has
# mock values for all environment variables used in templates
(cd "$dir" && test -f ".env.local" || npx convex dev --once --configure existing --team convex-playground --project templates-regenerate-codegen --dev-deployment cloud --skip-push)
if [ "$dir" = "template-component" ]; then
# The component codegen uses a separate command
(cd "$dir" && npm run build:codegen)
fi
(cd "$dir" && npx convex codegen --init)
}
for dir in template-*; do
if [ -d "$dir" ] && [ -f "$dir/package.json" ]; then
regenerate "$(basename $dir)"
fi
done
update-ai-files: _install-all-clean
#!/usr/bin/env sh
set -e
total=0
for dir in template-*; do
if [ -d "$dir" ] && [ -f "$dir/package.json" ]; then
total=$((total+1))
fi
done
counter=0
update_ai_files() {
dir="$1"
counter=$((counter+1))
printf "\n\033[35m[%s/%s] Updating AI files in \033[36m%s\033[35m\033[0m\n" "$counter" "$total" "$dir"
(cd "$dir" && npx convex ai-files update)
}
for dir in template-*; do
if [ -d "$dir" ] && [ -f "$dir/package.json" ]; then
update_ai_files "$(basename $dir)"
fi
done
# Commit a template change in the `templates` repo
commit message:
git add template-*
git commit -m "$1"