Skip to content

Commit

Permalink
FIX
Browse files Browse the repository at this point in the history
  • Loading branch information
kayman-mk committed Jan 8, 2025
1 parent 64dea62 commit a10b647
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions .config/cspell.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"version": "0.2",
"language": "en",
"ignorePaths": [".idea"],
"dictionaries": [
"workflow",
"maven",
Expand Down
47 changes: 45 additions & 2 deletions .github/update_workflows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Done by the workflows in this feature branch, except for the release workflow.
EOF
)

gh pr create --title "ci: update workflows to latest version" --body "$body" --base main
gh pr create --title "ci(deps): update workflows to latest version" --body "$body" --base main
gh pr view --web
}

Expand Down Expand Up @@ -116,6 +116,47 @@ function ensure_and_set_parameters_or_exit() {
fi
}

function ensure_cspell_dictionary() {
dictionary=$1
if [ ! -f "$destination_path/.config/dictionaries/$dictionary.txt" ]; then
cp -p ".config/dictionaries/$dictionary.txt" "$destination_path/.config/dictionaries/"
fi
}

function setup_cspell() {
# init the dictionaries
if [ ! -d "$destination_path/.config/dictionaries" ]; then
cp -pr .config/dictionaries "$destination_path/.config/"
fi
# this repository, the workflow templates
ensure_cspell_dictionary "workflow"
# the dictionaries for the specific repository types
ensure_cspell_dictionary "maven"
ensure_cspell_dictionary "terraform-module"
ensure_cspell_dictionary "docker"
ensure_cspell_dictionary "simple"
ensure_cspell_dictionary "python"
# the dictionary for the project
ensure_cspell_dictionary "project"
# fix the "addWords" setting needed for some IDEs
jq 'del(.dictionaryDefinitions[] | select(.addWords) | .addWords)' "$destination_path/.config/cspell.json" > "$destination_path/.config/cspell.json.tmp"
repository_name=$(basename "$destination_path")
if [ "$repository_name" == "Repository-Template-Docker" ]; then
jq '(.dictionaryDefinitions[] | select(.name == "docker")).addWords |= true' "$destination_path/.config/cspell.json.tmp" > "$destination_path/.config/cspell.json"
elif [ "$repository_name" == "Repository-Template-Maven" ]; then
jq '(.dictionaryDefinitions[] | select(.name == "maven")).addWords |= true' "$destination_path/.config/cspell.json.tmp" > "$destination_path/.config/cspell.json"
elif [ "$repository_name" == "Repository-Template-Terraform-Module" ]; then
jq '(.dictionaryDefinitions[] | select(.name == "terraform-module")).addWords |= true' "$destination_path/.config/cspell.json.tmp" > "$destination_path/.config/cspell.json"
elif [ "$repository_name" == "Repository-Template-Simple" ]; then
jq '(.dictionaryDefinitions[] | select(.name == "simple")).addWords |= true' "$destination_path/.config/cspell.json.tmp" > "$destination_path/.config/cspell.json"
elif [ "$repository_name" == "Repository-Template-Python" ]; then
jq '(.dictionaryDefinitions[] | select(.name == "python")).addWords |= true' "$destination_path/.config/cspell.json.tmp" > "$destination_path/.config/cspell.json"
else
jq '(.dictionaryDefinitions[] | select(.name == "project")).addWords |= true' "$destination_path/.config/cspell.json.tmp" > "$destination_path/.config/cspell.json"
fi
rm "$destination_path/.config/cspell.json.tmp"
}

ensure_prerequisites_or_exit
ensure_repo_preconditions_or_exit
ensure_and_set_parameters_or_exit "$@"
Expand All @@ -134,7 +175,9 @@ if [ -f "$destination_path/update-workflows.sh" ]; then
git mv -f "$destination_path/update-workflows.sh" "$destination_path/.github/update_workflows.sh"
fi

cp -p .config "$destination_path/"
mkdir -p "$destination_path/.config"
# copy fails if a directory is hit. dictionaries/ is handled in the setup_cspell function
cp -p .config/*.* "$destination_path/.config/"

setup_cspell

Expand Down

0 comments on commit a10b647

Please sign in to comment.