Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Split `justfile` to make it modular

Dhruv Bhanushali8629cac6f9ef
diff --git a/frontend/justfile b/frontend/justfile
index 1a32a2ef4..40403ecde 100644
--- a/frontend/justfile
+++ b/frontend/justfile
@@ -1,8 +1,19 @@
set dotenv-load := false
# Show all available recipes
-default:
- pnpm run
+@_default:
+ echo "############"
+ echo "# Frontend #"
+ echo "############"
+ just --list --unsorted
+
+# Install dependencies
+install *args: && core-locales
+ pnpm install {{ args }}
+
+# Ensure that some core locales are present
+core-locales:
+ cp -r test/locales/* src/locales
# Run a package.json script via pnpm
run *args:
diff --git a/justfile b/justfile
new file mode 100644
index 000000000..d029434f4
--- /dev/null
+++ b/justfile
@@ -0,0 +1,50 @@
+set dotenv-load := false
+
+# Meaning of Just prefixes:
+# @ - Quiet recipes (https://github.com/casey/just#quiet-recipes)
+# _ - Private recipes (https://github.com/casey/just#private-recipes)
+
+# Show all available recipes, also recurses inside nested justfiles
+@_default:
+ just --list --unsorted
+ cd frontend && just
+
+#######
+# Dev #
+#######
+
+# Install all dependencies
+@install:
+ just frontend/install --ignore-workspace
+
+# Setup pre-commit as a Git hook
+precommit:
+ #!/usr/bin/env bash
+ set -eo pipefail
+ if [ -z "$SKIP_PRE_COMMIT" ] && [ ! -f ./pre-commit.pyz ]; then
+ echo "Downloading pre-commit"
+ URL=$(
+ curl \
+ --fail \
+ --silent `# silence error raised by grep closing the pipe early` \
+ ${GITHUB_TOKEN:+ --header "Authorization: Bearer ${GITHUB_TOKEN}"} \
+ https://api.github.com/repos/pre-commit/pre-commit/releases/latest |
+ grep -o 'https://.*\.pyz' -m 1
+ )
+ echo "Download URL: $URL"
+ curl \
+ --fail \
+ --location `# follow redirects, else cURL outputs a blank file` \
+ --output pre-commit.pyz \
+ ${GITHUB_TOKEN:+ --header "Authorization: Bearer ${GITHUB_TOKEN}"} \
+ "$URL"
+ echo "Installing pre-commit"
+ python3 pre-commit.pyz install -t pre-push -t pre-commit
+ echo "Done"
+ else
+ echo "Skipping pre-commit installation"
+ fi
+
+# Run pre-commit to lint and reformat all files
+lint:
+ python3 pre-commit.pyz run --all-files