mirror of
https://github.com/taiki-e/install-action.git
synced 2026-05-09 22:30:28 +00:00
Exclude known words from "rust-dependencies" cspell dictionary
This commit is contained in:
4
.github/.cspell/rust-dependencies.txt
vendored
4
.github/.cspell/rust-dependencies.txt
vendored
@@ -1,8 +1,4 @@
|
|||||||
// This file is @generated by tidy.sh.
|
// This file is @generated by tidy.sh.
|
||||||
// It is not intended for manual editing.
|
// It is not intended for manual editing.
|
||||||
|
|
||||||
anyhow
|
|
||||||
json
|
|
||||||
semver
|
|
||||||
serde
|
|
||||||
ureq
|
ureq
|
||||||
|
|||||||
@@ -145,24 +145,36 @@ fi
|
|||||||
# Spell check (if config exists)
|
# Spell check (if config exists)
|
||||||
if [[ -f .cspell.json ]]; then
|
if [[ -f .cspell.json ]]; then
|
||||||
if type -P npm &>/dev/null; then
|
if type -P npm &>/dev/null; then
|
||||||
if [[ -f Cargo.toml ]]; then
|
if [[ -n "$(git ls-files '*Cargo.toml')" ]]; then
|
||||||
metadata=$(cargo metadata --format-version=1 --all-features --no-deps)
|
|
||||||
dependencies=''
|
dependencies=''
|
||||||
for id in $(jq <<<"${metadata}" '.workspace_members[]'); do
|
for manifest_path in $(git ls-files '*Cargo.toml'); do
|
||||||
dependencies+=$'\n'
|
if [[ "${manifest_path}" != "Cargo.toml" ]] && ! grep -Eq '\[workspace\]' "${manifest_path}"; then
|
||||||
dependencies+=$(jq <<<"${metadata}" ".packages[] | select(.id == ${id})" | jq -r '.dependencies[].name')
|
continue
|
||||||
|
fi
|
||||||
|
metadata=$(cargo metadata --format-version=1 --all-features --no-deps --manifest-path "${manifest_path}")
|
||||||
|
for id in $(jq <<<"${metadata}" '.workspace_members[]'); do
|
||||||
|
dependencies+=$'\n'
|
||||||
|
dependencies+=$(jq <<<"${metadata}" ".packages[] | select(.id == ${id})" | jq -r '.dependencies[].name')
|
||||||
|
done
|
||||||
done
|
done
|
||||||
cat >.github/.cspell/rust-dependencies.txt <<EOF
|
words=''
|
||||||
|
# shellcheck disable=SC2001
|
||||||
|
for word in $(sed <<<"${dependencies}" 's/[0-9_-]/\n/g' | LC_ALL=C sort -f -u | (grep -E '.{4,}' || true)); do
|
||||||
|
# Skip if the word is contained in other dictionaries.
|
||||||
|
if ! npx cspell trace "${word}" 2>/dev/null | (grep -v -E '/(project-dictionary|rust-dependencies)\.txt' || true) | grep -Eq "^${word} \* [0-9A-Za-z_-]+\* "; then
|
||||||
|
words+=$'\n'
|
||||||
|
words+="${word}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
cat >.github/.cspell/rust-dependencies.txt <<EOF
|
||||||
// This file is @generated by $(basename "$0").
|
// This file is @generated by $(basename "$0").
|
||||||
// It is not intended for manual editing.
|
// It is not intended for manual editing.
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
# shellcheck disable=SC2001
|
if [[ -n "${words:-}" ]]; then
|
||||||
sed <<<"${dependencies}" 's/[0-9_-]/\n/g' | LC_ALL=C sort -f -u | (grep -E '.{4,}' || true) >>.github/.cspell/rust-dependencies.txt
|
echo "${words}" >>.github/.cspell/rust-dependencies.txt
|
||||||
check_diff .github/.cspell/rust-dependencies.txt
|
|
||||||
else
|
|
||||||
touch .github/.cspell/rust-dependencies.txt
|
|
||||||
fi
|
fi
|
||||||
|
check_diff .github/.cspell/rust-dependencies.txt
|
||||||
|
|
||||||
echo "+ npx cspell --no-progress \$(git ls-files)"
|
echo "+ npx cspell --no-progress \$(git ls-files)"
|
||||||
npx cspell --no-progress $(git ls-files)
|
npx cspell --no-progress $(git ls-files)
|
||||||
|
|||||||
Reference in New Issue
Block a user