From 62b02c442e955f912347d3b83579e373f615fd47 Mon Sep 17 00:00:00 2001 From: plastikfan Date: Sun, 11 Aug 2024 19:16:47 +0100 Subject: [PATCH] chore: auto check (#1) --- .github/workflows/ci-workflow.yml | 2 +- .github/workflows/release-workflow.yml | 2 +- .goreleaser.yaml | 2 +- README.md | 12 +- VERSION | 2 +- go.mod | 2 +- ...ive.en-GB.json => pants.active.en-GB.json} | 0 ...ive.en-US.json => pants.active.en-US.json} | 0 i18n/messages-errors.go | 2 +- i18n/messages-general.go | 2 +- ....en-US.json => pants.translate.en-US.json} | 0 i18n/translate-defs.go | 8 +- scripts/automate-checklist.sh | 243 ------------------ 13 files changed, 17 insertions(+), 260 deletions(-) rename i18n/default/{astrolib.active.en-GB.json => pants.active.en-GB.json} (100%) rename i18n/deploy/{astrolib.active.en-US.json => pants.active.en-US.json} (100%) rename i18n/out/en-US/{astrolib.translate.en-US.json => pants.translate.en-US.json} (100%) delete mode 100644 scripts/automate-checklist.sh diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index dff211c..c28f54a 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -1,4 +1,4 @@ -name: Astrolib Continuous Integration +name: Pants Continuous Integration on: push: diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index de8b14f..e88f666 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -1,4 +1,4 @@ -name: Astrolib Release +name: Pants Release on: push: diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 6edce4e..309bb92 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -5,7 +5,7 @@ before: # - go mod generate builds: - - id: "astrolib" + - id: "pants" env: - CGO_ENABLED=0 goos: diff --git a/README.md b/README.md index b66ad24..63591a5 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# 🌟 astrolib: ___Go template for library modules___ +# 🌟 pants: ___Go template for library modules___ [![A B](https://img.shields.io/badge/branching-commonflow-informational?style=flat)](https://commonflow.org) [![A B](https://img.shields.io/badge/merge-rebase-informational?style=flat)](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) [![A B](https://img.shields.io/badge/branch%20history-linear-blue?style=flat)](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule) -[![Go Reference](https://pkg.go.dev/badge/github.com/snivilised/astrolib.svg)](https://pkg.go.dev/github.com/snivilised/astrolib) -[![Go report](https://goreportcard.com/badge/github.com/snivilised/astrolib)](https://goreportcard.com/report/github.com/snivilised/astrolib) -[![Coverage Status](https://coveralls.io/repos/github/snivilised/astrolib/badge.svg?branch=main)](https://coveralls.io/github/snivilised/astrolib?branch=main&kill_cache=1) -[![Astrolib Continuous Integration](https://github.com/snivilised/astrolib/actions/workflows/ci-workflow.yml/badge.svg)](https://github.com/snivilised/astrolib/actions/workflows/ci-workflow.yml) +[![Go Reference](https://pkg.go.dev/badge/github.com/snivilised/pants.svg)](https://pkg.go.dev/github.com/snivilised/pants) +[![Go report](https://goreportcard.com/badge/github.com/snivilised/pants)](https://goreportcard.com/report/github.com/snivilised/pants) +[![Coverage Status](https://coveralls.io/repos/github/snivilised/pants/badge.svg?branch=main)](https://coveralls.io/github/snivilised/pants?branch=main&kill_cache=1) +[![Astrolib Continuous Integration](https://github.com/snivilised/pants/actions/workflows/ci-workflow.yml/badge.svg)](https://github.com/snivilised/pants/actions/workflows/ci-workflow.yml) [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) [![A B](https://img.shields.io/badge/commit-conventional-commits?style=flat)](https://www.conventionalcommits.org/) @@ -63,7 +63,7 @@ Automated via `automate-checklist.sh` script. When the user instantiates the rep ##### ✅ Rename import statements -+ `rename import paths`: global search and replace ___snivilised/astrolib___ to ___pandora/maestro___ ++ `rename import paths`: global search and replace ___snivilised/pants___ to ___pandora/maestro___ ##### ✅ Identifiers diff --git a/VERSION b/VERSION index f54b243..b82608c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.3.4 +v0.1.0 diff --git a/go.mod b/go.mod index d8536b4..cb34507 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/snivilised/astrolib +module github.com/snivilised/pants go 1.22.0 diff --git a/i18n/default/astrolib.active.en-GB.json b/i18n/default/pants.active.en-GB.json similarity index 100% rename from i18n/default/astrolib.active.en-GB.json rename to i18n/default/pants.active.en-GB.json diff --git a/i18n/deploy/astrolib.active.en-US.json b/i18n/deploy/pants.active.en-US.json similarity index 100% rename from i18n/deploy/astrolib.active.en-US.json rename to i18n/deploy/pants.active.en-US.json diff --git a/i18n/messages-errors.go b/i18n/messages-errors.go index ec2a8d0..306c00b 100644 --- a/i18n/messages-errors.go +++ b/i18n/messages-errors.go @@ -12,7 +12,7 @@ import ( // that this message has been removed from the translation files, so // it is not useable at run time. type FooBarTemplData struct { - astrolibTemplData + pantsTemplData Path string Reason error } diff --git a/i18n/messages-general.go b/i18n/messages-general.go index 96d27c0..9f8a3c3 100644 --- a/i18n/messages-general.go +++ b/i18n/messages-general.go @@ -5,7 +5,7 @@ import ( ) type UsingConfigFileTemplData struct { - astrolibTemplData + pantsTemplData ConfigFileName string } diff --git a/i18n/out/en-US/astrolib.translate.en-US.json b/i18n/out/en-US/pants.translate.en-US.json similarity index 100% rename from i18n/out/en-US/astrolib.translate.en-US.json rename to i18n/out/en-US/pants.translate.en-US.json diff --git a/i18n/translate-defs.go b/i18n/translate-defs.go index 45aaa87..3cd72fb 100644 --- a/i18n/translate-defs.go +++ b/i18n/translate-defs.go @@ -2,10 +2,10 @@ package i18n // CLIENT-TODO: Should be updated to use url of the implementing project, // so should not be left as astrolib. (this should be set by auto-check) -const AstrolibSourceID = "github.com/snivilised/astrolib" +const PantsSourceID = "github.com/snivilised/pants" -type astrolibTemplData struct{} +type pantsTemplData struct{} -func (td astrolibTemplData) SourceID() string { - return AstrolibSourceID +func (td pantsTemplData) SourceID() string { + return PantsSourceID } diff --git a/scripts/automate-checklist.sh b/scripts/automate-checklist.sh deleted file mode 100644 index c60f2c7..0000000 --- a/scripts/automate-checklist.sh +++ /dev/null @@ -1,243 +0,0 @@ -# shellcheck disable=SC2148 - -function auto-check() { - owner=$(git config --get remote.origin.url | cut -d '/' -f 4) - repo=$(git rev-parse --show-toplevel | xargs basename) - - echo "---> 😎 OWNER: $owner" - echo "---> 🧰 REPO: $repo" - echo "" - - if ! update-workflow-names "$repo" "$owner"; then - return 1 - fi - - if ! update-mod-file "$repo" "$owner"; then - return 1 - fi - - if ! update-source-id-variable-in-translate-defs "$repo" "$owner"; then - return 1 - fi - - - if ! update-astrolib-in-taskfile "$repo" "$owner"; then - return 1 - fi - - - if ! update-astrolib-in-goreleaser "$repo" "$owner"; then - return 1 - fi - - - if ! rename-templ-data-id "$repo" "$owner"; then - return 1 - fi - - - if ! update-import-statements "$repo" "$owner"; then - return 1 - fi - - - if ! update-readme "$repo" "$owner"; then - return 1 - fi - - - if ! rename-language-files "$repo" "$owner"; then - return 1 - fi - - - if ! reset-version; then - return 1 - fi - - touch ./.env - echo "✔️ done" - return 0 -} - -function update-all-generic() { - local title=$1 - local repo=$2 - local owner=$3 - local folder=$4 - local name=$5 - local target=$6 - local replacement=$7 - - echo " 🎯 ---> title: $title" - echo " ✅ ---> file pattern: $name" - echo " ✅ ---> folder: $folder" - echo " ✅ ---> target: $target" - echo " ✅ ---> replacement: $replacement" - - # !!!WARNING: sed - # does not work the same way between mac and linux - # - # find "$folder" -name "$name" -type f -print0: This part of the command uses the find utility to search for files within the specified folder ($folder) matching the given pattern ($name). Here's what each option does: - # -name "$name": Specifies the filename pattern to match. In this case, it matches the filenames with the pattern stored in the variable $name. - # -type f: Specifies that only regular files should be matched, excluding directories, symbolic links, etc. - # -print0: This option tells find to print the matched filenames separated by null characters (\0). This is essential for correctly handling filenames with spaces or special characters. - - # while IFS= read -r -d '' file; do: This initiates a while loop that reads each null-delimited filename (-d '') produced by the find command. Here's what each part does: - # IFS=: This sets the Internal Field Separator to nothing. This is to ensure that leading and trailing whitespace characters are not trimmed from each filename. - # read -r: This command reads input from the pipe (|) without interpreting backslashes (-r option). - # -d '': This option specifies the delimiter as null characters (\0), ensuring that filenames containing spaces or special characters are read correctly. - # file: This is the variable where each filename from the find command is stored during each iteration of the loop. - # - # trying to modify: - # - ci-workflow.yml - # - release-workflow.yml - find "$folder" -name "$name" -type f -print0 | while IFS= read -r -d '' file; do - echo "Processing file: $file" - uname_output=$(uname) - # sed help: - # '': no file backup needed (we modify the file in place without backing up original) - # but note that this is only required for mac. for linux, you dont need the ''. - # - # -i: The in-place edit flag, which tells sed to modify the original file inline. - # 's/search_pattern/replacement_text/g': - # - # s: Indicates that this is a substitution command. - # /search_pattern/: The pattern to search for. - # /replacement_text/: The text to replace the search pattern with. - # g: The global flag, which ensures that all occurrences of the - # search pattern are replaced, not just the first one. - if [[ "$uname_output" == *"Darwin"* ]]; then - if ! sed -i '' "s/${target}/${replacement}/g" "$file"; then - echo "!!! ⛔ Sed on mac failed for $file" - return 1 - fi - else - if ! sed -i "s/${target}/${replacement}/g" "$file"; then - echo "!!! ⛔ Sed on linux failed for $file" - return 1 - fi - fi - done - - echo " ✔️ ---> DONE" - echo "" - return 0 -} - -function update-mod-file() { - local repo=$1 - local owner=$2 - local folder=./ - local file_pattern=go.mod - local target="module github.com\/snivilised\/astrolib" - local replacement="module github.com\/$owner\/$repo" - update-all-generic "update-mod-file" "$repo" "$owner" "$folder" "$file_pattern" "$target" "$replacement" -} - -function update-source-id-variable-in-translate-defs() { - local repo=$1 - local owner=$2 - local folder=./i18n/ - local file_pattern=translate-defs.go - local target="AstrolibSourceID" - tc_repo=$(echo "${repo:0:1}" | tr '[:lower:]' '[:upper:]')${repo:1} - local replacement="${tc_repo}SourceID" - update-all-generic "update-source-id-variable-in-translate-defs" "$repo" "$owner" "$folder" "$file_pattern" "$target" "$replacement" -} - -function update-astrolib-in-taskfile() { - local repo=$1 - local owner=$2 - local folder=./ - local file_pattern=Taskfile.yml - local target=astrolib - local replacement=$repo - update-all-generic "update-astrolib-in-taskfile" "$repo" "$owner" "$folder" "$file_pattern" "$target" "$replacement" -} - -function update-workflow-names() { - local repo=$1 - local owner=$2 - local folder=.github/workflows - local file_pattern="*.yml" - local target="name: Astrolib" - tc_repo=$(echo "${repo:0:1}" | tr '[:lower:]' '[:upper:]')${repo:1} - local replacement="name: $tc_repo" - update-all-generic "💥 update-workflow-names" "$repo" "$owner" "$folder" "$file_pattern" "$target" "$replacement" -} - -function update-astrolib-in-goreleaser() { - local repo=$1 - local owner=$2 - local folder=./ - local file_pattern=.goreleaser.yaml - local target=astrolib - local replacement=$repo - update-all-generic "update-astrolib-in-goreleaser" "$repo" "$owner" "$folder" "$file_pattern" "$target" "$replacement" -} - -function rename-templ-data-id() { - local repo=$1 - local owner=$2 - local folder=./ - local file_pattern="*.go" - local target="astrolibTemplData" - local replacement="${repo}TemplData" - update-all-generic "rename-templ-data-id" "$repo" "$owner" "$folder" "$file_pattern" "$target" "$replacement" -} - -function update-readme() { - local repo=$1 - local owner=$2 - local folder=./ - local file_pattern=README.md - local target="astrolib: " - local replacement="${repo}: " - - - if ! update-all-generic "update-readme(astrolib:)" "$repo" "$owner" "$folder" "$file_pattern" "$target" "$replacement"; then - return 1 - fi - - target="snivilised\/astrolib" - replacement="$owner\/$repo" - - if ! update-all-generic "update-readme(snivilised/astrolib)" "$repo" "$owner" "$folder" "$file_pattern" "$target" "$replacement"; then - return 1 - fi - - target="astrolib Continuous Integration" - tc_repo=$(echo "${repo:0:1}" | tr '[:lower:]' '[:upper:]')${repo:1} - replacement="$tc_repo Continuous Integration" - - if ! update-all-generic "update-readme(astrolib Continuous Integration)" "$repo" "$owner" "$folder" "$file_pattern" "$target" "$replacement"; then - return 1 - fi - - return 0 -} - -function update-import-statements() { - local repo=$1 - local owner=$2 - local folder=./ - local file_pattern="*.go" - local target="snivilised\/astrolib" - local replacement="$owner\/$repo" - update-all-generic "update-import-statements" "$repo" "$owner" "$folder" "$file_pattern" "$target" "$replacement" -} - -function rename-language-files() { - local repo=$1 - find . -name 'astrolib*.json' -type f -print0 | - while IFS= read -r -d '' file; do - mv "$file" "$(dirname "$file")/$(basename "$file" | sed "s/^astrolib/$repo/")" - done - return $? -} - -function reset-version() { - echo "v0.1.0" > ./VERSION - return 0 -}