Add AIO build script.
This commit is contained in:
16
balloon.py
16
balloon.py
@@ -13,7 +13,7 @@ from typing import TYPE_CHECKING
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from _typeshed import StrPath
|
from _typeshed import StrPath
|
||||||
|
|
||||||
WORK_DIR: StrPath = os.getcwd()
|
WORK_DIR: StrPath = os.getcwd() + '/'
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Tag:
|
class Tag:
|
||||||
@@ -104,16 +104,24 @@ def main() -> None:
|
|||||||
# Incorrect number of arguments
|
# Incorrect number of arguments
|
||||||
# Long help flag
|
# Long help flag
|
||||||
# Short help flag
|
# Short help flag
|
||||||
if len(sys.argv) != 1 or (
|
if len(sys.argv) != 2 or (
|
||||||
sys.argv[0] == '--help'
|
sys.argv[0] == '--help'
|
||||||
or sys.argv[0] == '-h'
|
or sys.argv[0] == '-h'
|
||||||
):
|
):
|
||||||
help()
|
help()
|
||||||
return
|
return
|
||||||
|
|
||||||
with open(str(WORK_DIR) + 'src' + sys.argv[0], 'rt') as f:
|
file_name = sys.argv[1].removeprefix('src/')
|
||||||
|
|
||||||
|
with open(str(WORK_DIR) + 'src/' + file_name, 'rt') as f:
|
||||||
html_src = HTML(f.read())
|
html_src = HTML(f.read())
|
||||||
with open(str(WORK_DIR) + 'target' + sys.argv[0], 'w') as f:
|
|
||||||
|
try:
|
||||||
|
os.makedirs(str(WORK_DIR) + 'target/' + os.path.dirname(file_name))
|
||||||
|
except FileExistsError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
with open(str(WORK_DIR) + 'target/' + file_name, 'w') as f:
|
||||||
f.write(html_src.write())
|
f.write(html_src.write())
|
||||||
|
|
||||||
def help() -> None:
|
def help() -> None:
|
||||||
|
|||||||
73
build.sh
Executable file
73
build.sh
Executable file
@@ -0,0 +1,73 @@
|
|||||||
|
#! /usr/bin/bash
|
||||||
|
#
|
||||||
|
# I'm new to bash scripting, so give me a break.
|
||||||
|
# I know that this is probably crap, but it's cheap, dirty, and does the job.
|
||||||
|
|
||||||
|
python=~/.pyenv/versions/3.12.9/bin/python
|
||||||
|
green='\e[32m'
|
||||||
|
cyan='\e[36m'
|
||||||
|
|
||||||
|
# The "a" is just to make this work if no characters are present in $@
|
||||||
|
args=$@
|
||||||
|
args+=('a')
|
||||||
|
|
||||||
|
if [ $(expr length "$args") -gt 1 ]
|
||||||
|
then
|
||||||
|
args=$@
|
||||||
|
else
|
||||||
|
args='inflate style copy'
|
||||||
|
fi
|
||||||
|
|
||||||
|
for x in $args
|
||||||
|
do
|
||||||
|
if [ "$x" == 'inflate' ]
|
||||||
|
then
|
||||||
|
echo -e "$green"Inflating...
|
||||||
|
|
||||||
|
files=(`ls src/*.html`)
|
||||||
|
files+=(`ls src/errors/*.html`)
|
||||||
|
|
||||||
|
for html in "${files[@]}"
|
||||||
|
do
|
||||||
|
echo -e " $cyan$html -> target/"
|
||||||
|
|
||||||
|
eval $python 'balloon.py' $html
|
||||||
|
done
|
||||||
|
|
||||||
|
elif [ "$x" == 'style' ]
|
||||||
|
then
|
||||||
|
echo -e "$green"Styling...
|
||||||
|
|
||||||
|
sass src/style.scss target/style.css
|
||||||
|
|
||||||
|
echo -e "$cyan"' src/style.scss -> target/style.css'
|
||||||
|
|
||||||
|
elif [ "$x" == 'copy' ]
|
||||||
|
then
|
||||||
|
echo -e "$green"Copying...
|
||||||
|
|
||||||
|
files=(
|
||||||
|
'.well-known/security.txt'
|
||||||
|
'img'
|
||||||
|
'robots.txt'
|
||||||
|
)
|
||||||
|
|
||||||
|
for item in "${files[@]}"
|
||||||
|
do
|
||||||
|
echo -e "$cyan src/$item -> target/$item"
|
||||||
|
|
||||||
|
cp -R src/$item target/$item
|
||||||
|
done
|
||||||
|
elif [ "$x" == '-h' -o "$x" == '--help' ]
|
||||||
|
then
|
||||||
|
echo -e "$green"Usage:"$cyan" build.sh [OPTIONS] [COMMAND]
|
||||||
|
echo
|
||||||
|
echo -e "$green"Options:"$cyan"
|
||||||
|
echo ' -h, --help Print help'
|
||||||
|
echo
|
||||||
|
echo -e "$green"Commands:"$cyan"
|
||||||
|
echo ' inflate Inflate the HTML source'
|
||||||
|
echo ' style Compile SCSS to CSS'
|
||||||
|
echo ' copy Copy assets to target'
|
||||||
|
fi
|
||||||
|
done
|
||||||
Reference in New Issue
Block a user