Skip to content

Commit

Permalink
refactor: install setup as dep
Browse files Browse the repository at this point in the history
  • Loading branch information
bonjourmauko committed Oct 23, 2024
1 parent a1dbfca commit d212d0a
Show file tree
Hide file tree
Showing 23 changed files with 35 additions and 1,306 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
.tox
build
dist
lib/*
lib
4 changes: 2 additions & 2 deletions bashdep.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

# Add latest bashunit release to your dependencies
readonly DEPENDENCIES=(
"https://github.com/TypedDevs/bashunit/releases/download/0.18.0/bashunit"
"https://github.com/openfisca/openfisca-setup-builder/releases/download/0.1.0/first-time-setup.sh"
)

# Load, configure and run bashdep
# shellcheck disable=SC1091
source lib/bashdep
bashdep::setup dir="lib" silent=false
bashdep::setup dir="." silent=false
bashdep::install "${DEPENDENCIES[@]}"
113 changes: 0 additions & 113 deletions build.sh

This file was deleted.

55 changes: 32 additions & 23 deletions first-time-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,28 @@ file::find_lineno() {
}

# @internal
# @arg $1 The error message.
string.error() {
echo -e "$(colour::fail "${1}")" >&2
return 1
string.decode.a() {
echo "${1}" | sed 'y/āáǎàâãäåĀÁǍÀÂÃÄÅ/aaaaaaaaAAAAAAAA/'
}

# @internal
string.unidecode.find() {
local pip poetry
pip=$(command -v unidecode 2>/dev/null)
poetry=$(poetry run which unidecode 2>/dev/null)
[[ -n ${pip} ]] && echo "${pip}" && return
[[ -n ${poetry} ]] && echo "${poetry}" && return
string.error "Unidecode not found. Install it with 'pip install unidecode'."
return 1
string.decode.e() {
echo "${1}" | sed 'y/ēéěèêëĒÉĚÈÊË/eeeeeeEEEEEE/'
}

# @internal
string.decode.i() {
echo "${1}" | sed 'y/īíǐìîïĪÍǏÌÎÏ/iiiiiiIIIIII/'
}

# @internal
string.decode.o() {
echo "${1}" | sed 'y/ōóǒòôõöŌÓǑÒÔÕÖ/oooooooOOOOOOO/'
}

# @internal
string.decode.u() {
echo "${1}" | sed 'y/ūúǔùûüǖǘǚǜŪÚǓÙÛÜǕǗǙǛ/uuuuuuuuuuUUUUUUUUUU/'
}

# @description Convert a string to lowercase.
Expand All @@ -162,9 +169,17 @@ string::lower() {
# @description Decode a string to ASCII.
# @arg $1 The string to decode.
string::decode() {
local -r unidecode=$(string.unidecode.find)
[[ -z ${unidecode} ]] && return 1
echo "${1}" | "${unidecode}"
local string="${1}"
local -r fx=(
string.decode.a
string.decode.e
string.decode.i
string.decode.o
string.decode.u
)
local fn
for fn in "${fx[@]}"; do string=$("${fn}" "${string}"); done
echo "${string}"
}

# @description Remove special characters from a string.
Expand Down Expand Up @@ -284,15 +299,9 @@ if [[ -z ${ROOT_DIR+A} ]]; then
readonly ROOT_DIR=${ROOT_PATH##*/}
fi

# @internal
msg.version() {
grep '^version =' pyproject.toml | cut -d '"' -f 2
}

# @description Define the welcome message.
msg::welcome() {
local version
version=$(msg.version)
local -r version='0.1.0'
cat <<MSG
Welcome to the OpenFisca Extension Template setup script v${version}!
Expand Down Expand Up @@ -358,7 +367,7 @@ MSG
# @arg $1 The jurisdiction name.
setup::name_label() {
local name="${1}"
local -r fx=(string::lower string::decode string::sanitise string::trim)
local -r fx=(string::decode string::lower string::sanitise string::trim)
local fn
for fn in "${fx[@]}"; do name=$("${fn}" "${name}"); done
echo "${name}"
Expand Down
35 changes: 0 additions & 35 deletions src/first_time_setup/checks.sh

This file was deleted.

46 changes: 0 additions & 46 deletions src/first_time_setup/envvars.sh

This file was deleted.

Loading

0 comments on commit d212d0a

Please sign in to comment.