Starbeamrainbowlabs
622a71962e
This was much more complicated than we expected, considering eleventy si supposed to be a "simpler static site generator".....
79 lines
2.2 KiB
Bash
Executable file
79 lines
2.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Make sure the current directory is the location of this script to simplify matters
|
|
cd "$(dirname "$(readlink -f "$0")")";
|
|
################
|
|
### Settings ###
|
|
################
|
|
|
|
# The name of this project
|
|
project_name="pepperminty.wiki";
|
|
|
|
# The path to the lantern build engine git submodule
|
|
lantern_path="./lantern-build-engine";
|
|
|
|
###
|
|
# Custom Settings
|
|
###
|
|
|
|
config="./.eleventy.js"; # relative to src/
|
|
output_dir="${PWD}/public";
|
|
|
|
###############################################################################
|
|
|
|
# Check out the lantern git submodule if needed
|
|
if [ ! -f "${lantern_path}/lantern.sh" ]; then git submodule update --init "${lantern_path}"; fi
|
|
|
|
source "${lantern_path}/lantern.sh";
|
|
|
|
if [[ "$#" -lt 1 ]]; then
|
|
echo -e "${FBLE}${project_name}${RS} build script";
|
|
echo -e " by Starbeamrainbowlabs";
|
|
echo -e "${LC}Powered by the lantern build engine, v${version}${RS}";
|
|
echo -e "";
|
|
echo -e "${CSECTION}Usage${RS}";
|
|
echo -e " ./build ${CTOKEN}{action}${RS} ${CTOKEN}{action}${RS} ${CTOKEN}{action}${RS} ...";
|
|
echo -e "";
|
|
echo -e "${CSECTION}Available actions${RS}";
|
|
echo -e " ${CACTION}setup${RS} - Perform initial setup";
|
|
echo -e " ${CACTION}build${RS} - Build the static site";
|
|
echo -e " ${CACTION}serve${RS} - Start a livereload server";
|
|
echo -e "";
|
|
|
|
exit 1;
|
|
fi
|
|
|
|
###############################################################################
|
|
|
|
task_setup() {
|
|
task_begin "Checking environment";
|
|
check_command git true;
|
|
check_command node true;
|
|
check_command npm true;
|
|
check_command npx true;
|
|
task_end 0;
|
|
|
|
task_begin "Initialising submodules";
|
|
execute git submodule update --init;
|
|
task_end $?;
|
|
|
|
task_begin "Installing dependencies";
|
|
npm install;
|
|
task_end "$?";
|
|
}
|
|
|
|
task_build() {
|
|
task_begin "Building site";
|
|
cd src || { echo "Failed to cd into src"; exit 1; };
|
|
execute npx @11ty/eleventy --config="${config}" --output="${output_dir}";
|
|
task_end "$?";
|
|
}
|
|
task_serve() {
|
|
task_begin "Building site";
|
|
cd src || { echo "Failed to cd into src"; exit 1; };
|
|
execute npx @11ty/eleventy --config="${config}" --serve --output "${output_dir}";
|
|
task_end "$?";
|
|
}
|
|
|
|
###############################################################################
|
|
|
|
tasks_run "$@";
|