Skip to content

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

1.8 KB
Raw Blame
COLOR := "\\033[0;34m"
NO_COLOR := "\\033[0m"

# Show all available recipes
@_default:
    printf "\n{{ COLOR }}# Vale (path: \`.vale/\`)\n"
    printf "===================={{ NO_COLOR }}\n"
    just --list --unsorted

IGNORE_FILES_PATTERN := ".pnpm|changelogs|projects/proposals|node_modules|.?venv"

# This recipe generates a list of Markdown and MDX files to be processed, excluding those
# matched by the IGNORE_FILES_PATTERN. Files are listed relative to the parent directory
# of the current working directory. If a custom separator is specified, newlines are
# replaced with this separator before outputting the file list.
_files separator="\n":
    #! /usr/bin/env bash
    files=$(
        find "$PWD/.." -type f \( -name "*.md" -o -name "*.mdx" \) \
            | grep -vE "{{ IGNORE_FILES_PATTERN }}"
    )
    if [ '{{ separator }}' != '\n' ]; then
        echo "$files" | tr '\n' '{{ separator }}'
        exit 0
    fi
    echo "$files"

VALE_BIN_NAME := "vale_" + os() + "_" + arch()
VALE_STYLES_PATH := "/opt/.local/share/vale/styles"

@_link_openverse_styles:
    mkdir -p {{ VALE_STYLES_PATH }}
    [ ! -L {{ VALE_STYLES_PATH }}/config ] && ln -s "$(pwd)"/styles/config {{ VALE_STYLES_PATH }}/config || true
    [ ! -L {{ VALE_STYLES_PATH }}/Openverse ] && ln -s "$(pwd)"/styles/Openverse {{ VALE_STYLES_PATH }}/Openverse || true

# Run Vale configured for Openverse.
@run: _link_openverse_styles
    #!/usr/bin/env bash
    # Download vale if not not found by which
    if [ ! -f ./{{ VALE_BIN_NAME }} ]; then
        echo "Downloading Vale"
        ./download.sh {{ VALE_BIN_NAME }}
    fi

    export VALE_STYLES_PATH={{ VALE_STYLES_PATH }}
    # Sync to make sure styles are up to date (this is fast if they are already synced)
    ./{{ VALE_BIN_NAME }} sync
    # Run vale :)
    ./{{ VALE_BIN_NAME }} {{ "`just _files`" }}