日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

日常開發經常要簡化很多操作可以用make 工具封裝很多命令干活,但是在Docker 容器內有時候為了簡化鏡像的大小和避免風險都沒有安裝make ,但是又需要用很多已命令的命令執行任務,索性就用shell封裝好一個類似make 的模板,如下所示

#!/usr/bin/env bash

#/ PATH=./node_modules/.bin:$PATH

#/ https://www.tldp.org/LDP/abs/html/options.html

# Similar to -v (Print each command to stdout before executing it), but expands commands

# set -o xtrace

# set -o verbose

# Abort script at first error, when a command exits with non-zero status (except in until or while loops, if-tests, list constructs)

set -o errexit

# Apply to subprocesses too

shopt -s inherit_errexit 2>/dev/null || true

# Causes a pipeline to return the exit status of the last command in the pipe that returned a non-zero return value.

set -o pipefail

# Attempt to use undefined variable outputs error message, and forces an exit

set -o nounset

# makes iterations and splitting less surprising

IFS=$'nt'

# full path current folder

__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# full path of the script.sh (including the name)

__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"

# name of the script

__base="$(basename ${__file} .sh)"

# full path of the parent folder

__root="$(cd "$(dirname "${__dir}")" && pwd)" # <-- change this as it depends on your app

# Log function

# This disables and re-enables debug trace mode (only if it was already set)

# Sources: https://superuser.com/a/1338887/922762 -- https://github.com/Kurento/adm-scripts/blob/master/bash.conf.sh

shopt -s expand_aliases # This trick requires enabling aliases in Bash

BASENAME="$(basename "$0")" # Complete file name

echo_and_restore() {

echo "[${BASENAME}] $(cat -)"

# shellcheck disable=SC2154

case "$flags" in (*x*) set -x; esac

}

alias log='({ flags="$-"; set +x; } 2>/dev/null; echo_and_restore) <<<'

# Exit trap

# This runs at the end or, thanks to 'errexit', upon any error

on_exit() {

{ _RC="$?"; set +x; } 2>/dev/null

if ((_RC)); then log "ERROR ($_RC)"; else log "SUCCESS"; fi

log "#################### END ####################"

}

trap on_exit EXIT

log "==================== BEGIN ===================="

export appdir="$__dir"/

export SOURCE_FILES="$appdir tests"

function assert_env () {

source "$__dir"/".venv/bin/activate" || exit 1

echo "Pip location:"

pip_cmd=$(command -v pip)

echo "$pip_cmd"

current=$(pwd)

pip_path="$current/.venv/bin/pip"

echo "$pip_path"

if [[ "$pip_cmd" -ef "$pip_path" ]]; then

echo "paths match"

else

exit 1

fi

}

function clean () {

log "cleaning files"

find . -name '__pycache__' -exec rm -fr {} +;

find . -name '.ipynb_checkpoints' -exec rm -fr {} +;

find . -name '*.pyo' -exec rm -f {} +;

find . -name '*.pyc' -exec rm -f {} +;

find . -name '*.egg-info' -exec rm -fr {} +;

find . -name '*~' -exec rm -f {} +;

find . -name '*.egg' -exec rm -f {} +

}

function deps () {

assert_env

pip install pip-tools pip setuptools

pip-compile -v --allow-unsafe --output-file requirements/main.txt requirements/main.in &&

pip-compile -v --allow-unsafe --output-file requirements/dev.txt requirements/dev.in

}

function update () {

assert_env

# --build-isolation --generate-hashes

pip install --upgrade pip-tools pip setuptools

pip-compile -v --upgrade --allow-unsafe --output-file requirements/main.txt requirements/main.in &&

pip-compile -v --upgrade --allow-unsafe --output-file requirements/dev.txt requirements/dev.in

wait

pip-sync requirements/*.txt

}

function install {

assert_env

if ! command -v pip-sync; then echo "pip-tools not installed" && exit; fi

pip-sync requirements/*.txt

}

function lint () {

assert_env

autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place "$appdir" --exclude=__init__.py

isort --profile black "$appdir"

black "$appdir"

}

function report () {

echo "Flake8 report:" > "$__dir"/code_report.txt

flake8 "$appdir" >> code_report.txt

echo "Bandit report:" >> code_report.txt

bandit -r "$appdir" >> "$__dir"/code_report.txt

}

function publish () {

assert_env

if ! command -v twine &>/dev/null ; then

echo "Unable to find the 'twine' command."

echo "Install from PyPI, using 'pip install twine'."

exit 1

fi

if ! pip show wheel &>/dev/null ; then

echo "Unable to find the 'wheel' command."

echo "Install from PyPI, using 'pip install wheel'."

exit 1

fi

clean

log "building package"

Python/ target=_blank class=infotextkey>Python3 setup.py sdist bdist_wheel

log "uploading to PyPi"

python3 -m twine upload dist/*

log "cleaning..."

clean

echo "You probably want to also tag the version now:"

echo "git tag -a ${VERSION} -m 'version ${VERSION}'"

echo "git push --tags"

}

function build () {

echo "build task not implemented"

}

function tester () {

echo "not implemented"

assert_env

# pytest ...

}

function buildprod {

echo "build task not implemented"

assert_env

# this runs in parallel

format & deps & tester &

wait

echo "not implemented"

# shiv ...

}

function run {

echo "running app with uvicorn"

assert_env

uvicorn --workers 2 app.main:app --reload --reload-dir "$appdir"

}

function default {

# start

clean

}

function tasks {

echo "$0 <task> <args>"

echo "Tasks:"

compgen -A function | cat -n

}

# Help message (extracted from script headers)

usage() { grep '^#/' "$0" | cut --characters=4-; exit 0; }

REGEX='(^|W)(-h|--help)($|W)'

[[ "$*" =~ $REGEX ]] && usage || true

TIMEFORMAT="Task completed in %3lR"

time ${@:-default}

 

?

分享到:
標簽:shell
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定