-
Notifications
You must be signed in to change notification settings - Fork 102
/
justfile
185 lines (143 loc) · 5.48 KB
/
justfile
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
set shell := ["bash", "-uc"]
export PATH := "./node_modules/.bin" + ":" + join(justfile_directory(), "node_modules/.bin") + ":" + env_var('PATH')
# just setup -- default when running just with no command
default:
just install
# run biome
biome *args:
cd {{ invocation_directory() }} && biome {{ args }}
# build all packages
build: _build-streams _build-player _build-overlay
# list changed files since branched off from origin/main
@changed:
git diff --diff-filter=d --name-only $(git merge-base --fork-point origin/main)
# create a changelog
changelog:
#!/usr/bin/env bash
set -euo pipefail
new_version="$(jq -r .version package.json)"
old_version="$(git show HEAD:package.json | jq -r .version)"
url="$(jq -r .repository.url package.json)"
range=$(just sha v$old_version)..$(just sha HEAD)
changelog $new_version $range --url $url --outfile=CHANGELOG.md
# check if there are uncommitted changes in the workspace
@check-dirty:
git diff --quiet || (echo "workspace dirty!"; git diff; exit 1)
# report coverage information after running tests
coverage workspace *args='-r text --all':
c8 report --src={{ workspace }}/src {{ args }}
# run esbuild, WORKSPACE=(overlay|player|streams)
esbuild workspace *args:
cd {{ workspace }} && node esbuild.mjs {{ args }}
# autofix and format changed files
format +FILES="`just changed`":
just biome check --apply {{ FILES }}
# install dependencies
install:
CYPRESS_INSTALL_BINARY=0 && yarn install --immutable
# check lint rules and formatting for changed files
lint workspace:
just biome check {{ workspace }}
# check for updates
ncu *args:
ncu --root --workspaces {{ args }}
# create a prerelease commit, KIND=(new|nightly)
release $level='patch':
just version $level
just changelog
git add -u
git commit -m "release: $(jq -r .version package.json)"
# start an example RTSP over WebSocket server
rtsp-ws:
#!/usr/bin/env bash
set -euo pipefail
trap "kill 0" EXIT SIGINT
scripts/rtsp-server.sh &
scripts/tcp-ws-proxy.cjs >& tcp-ws-proxy.log &
wait
# statically serve a directory
serve path *args='--bind 0.0.0.0':
http-server {{ path }} {{ args }}
# get the complete SHA ID for a commit
@sha $commitish='HEAD':
git rev-parse $commitish
# generate tools
tools:
cd tools && esbuild --platform=node --outfile=src/__generated__/changelog.mjs --format=esm --out-extension:.js=.mjs --bundle --external:cmd-ts src/changelog/cli.ts
just biome format --write 'tools/src/__generated__/*'
# update a specific dependency to latest
update *packages:
just ncu -u {{ packages }}
npm install
npm update --include-workspace-root --workspaces {{ packages }}
# CI verification
verify:
just build
just lint .
just test
just tools
just check-dirty
# update the package version of all workspaces
version $level='prerelease':
#!/usr/bin/env bash
current=$(jq -r '.version' package.json)
next=$(semver -i $level --preid alpha $current)
echo "update: $current => $next"
npm version $next --git-tag-version=false --workspace=streams --workspace=player --workspace=overlay --include-workspace-root
# run vite development server, WORKSPACE=(player)
vite WORKSPACE *ARGS:
cd {{ WORKSPACE }} && node vite.mjs {{ ARGS }}
# run the default app for a particular workspace
run workspace:
just _run-{{ workspace }}
# tag a commit with annotated tag (e.g. just tag v1.2.3 main)
tag tagname commit:
git tag -a -m {{ tagname }} {{ tagname }} {{ commit }}
# run all unit tests
test:
just uvu streams
just coverage streams
# run tsc in workspace(s) (default current, or all if in project root)
tsc workspace:
cd {{ workspace }} && tsc
# run uvu to test files matching pattern (path = path to tsconfig.json + tests, e.g. "admx/web", or "iam")
uvu path pattern='.*\.test\.tsx?':
c8 -r none --clean=false --src={{ path }} -- tsx --tsconfig {{ path }}/tsconfig.json node_modules/uvu/bin.js {{ path }}/tests/ {{ pattern }}
#
# hidden commands (these can be run but they are not shown with just --list)
#
_build-streams: (tsc "streams")
just esbuild streams
_build-player: _build-streams (tsc "player")
just esbuild player
_build-overlay: (tsc "overlay")
just esbuild overlay
_copy-player-bundle dst:
cp player/dist/media-stream-player.min.js {{ dst }}
cp player/dist/media-stream-player.min.js.map {{ dst }}
_copy-streams-bundle dst:
cp streams/dist/media-stream-library.min.js {{ dst }}
cp streams/dist/media-stream-library.min.js.map {{ dst }}
_run-example-overlay-react: _build-overlay
cd example-overlay-react && node vite.mjs
_run-example-player-react: _build-player
cd example-player-react && node vite.mjs
_run-example-player-webcomponent: _build-player (_copy-player-bundle "example-player-webcomponent")
just serve example-player-webcomponent
_run-example-streams-node: _build-streams
cd example-streams-node && node player.cjs
_run-example-streams-web: _build-streams (_copy-streams-bundle "example-streams-web")
#!/usr/bin/env bash
set -euo pipefail
trap "kill 0" EXIT SIGINT
just rtsp-ws &
just serve example-streams-web &&
wait
_run-overlay: _build-overlay
echo "no direct playground for overlay yet, running example-overlay-react instead"
just _run-example-overlay-react
_run-player: (esbuild 'streams')
just vite player
_run-streams: _build-streams
echo "no direct playground for streams yet, running example-streams-web instead"
just _run-example-streams-web