2024-01-26 08:15:06 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
function clean {
|
2024-07-30 19:33:11 +00:00
|
|
|
rm -fr assets/node_modules/ output_*/ source/build/ vendor/
|
2024-01-26 08:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Create a new daily email.
|
|
|
|
function create-daily {
|
|
|
|
local date="${1}"
|
|
|
|
local title="${2}"
|
|
|
|
|
|
|
|
if [ "${date}" == "next" ]; then
|
|
|
|
next_date=$(ls -1 source/_daily_emails | tail -n 1 | tr -d '.md' | xargs -I {} date +%Y-%m-%d -d '{} +1 day')
|
|
|
|
else
|
|
|
|
next_date="${date}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
filepath="source/_daily_emails/${next_date}.md"
|
|
|
|
|
|
|
|
shift 1
|
|
|
|
|
|
|
|
# Generate the title and slug.
|
|
|
|
title="${*}"
|
|
|
|
slug=$(echo "${title}" | \
|
|
|
|
tr '[:upper:]' '[:lower:]' | \
|
|
|
|
sed 's/[^a-z0-9]/-/g' | \
|
|
|
|
sed 's/\-\-+/-/g' | \
|
|
|
|
sed 's/^\-//;s/\-$//')
|
|
|
|
|
|
|
|
# Create the file.
|
|
|
|
cp -f --no-clobber stub.md "${filepath}"
|
|
|
|
|
|
|
|
date=$(date -d "${next_date}" +%Y-%m-%d)
|
|
|
|
day=$(date -d "${next_date}" +%d)
|
|
|
|
month=$(date -d "${next_date}" +%m)
|
|
|
|
year=$(date -d "${next_date}" +%Y)
|
|
|
|
|
|
|
|
# Replace the placeholders.
|
|
|
|
sed -i "s/{{ date }}/${date}/" "${filepath}"
|
|
|
|
sed -i "s/{{ title }}/${title}/" "${filepath}"
|
2024-05-21 21:40:37 +00:00
|
|
|
sed -i "s#{{ permalink }}#daily/${year}/${month}/${day}/${slug}#" "${filepath}"
|
2024-01-26 08:15:06 +00:00
|
|
|
|
|
|
|
# Create a commit with the appropriate date in the message
|
|
|
|
git add "${filepath}"
|
|
|
|
git commit --quiet -m "Add daily email for ${date}
|
|
|
|
|
|
|
|
${title}"
|
|
|
|
|
2024-04-24 21:47:40 +00:00
|
|
|
echo "${filepath}"
|
2024-01-26 08:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function npm:build:css {
|
|
|
|
local args=()
|
|
|
|
|
|
|
|
if [[ "${NODE_ENV:-}" == "production" ]]; then
|
|
|
|
args=(--minify)
|
|
|
|
else
|
|
|
|
args=(--watch)
|
|
|
|
fi
|
|
|
|
|
2024-07-30 19:19:27 +00:00
|
|
|
cd assets || exit
|
|
|
|
|
|
|
|
tailwindcss \
|
|
|
|
--config tailwind.config.ts \
|
|
|
|
--output ../source/build/tailwind.css "${args[@]}"
|
2024-01-26 08:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function publish {
|
|
|
|
export NODE_ENV=production
|
|
|
|
export APP_ENV=production
|
|
|
|
|
2024-02-17 08:56:50 +00:00
|
|
|
tag-release
|
2024-03-22 15:17:09 +00:00
|
|
|
git push
|
2024-02-17 08:56:50 +00:00
|
|
|
|
2024-01-26 08:15:06 +00:00
|
|
|
git stash
|
|
|
|
|
|
|
|
clean
|
|
|
|
npm:build:css
|
|
|
|
generate
|
|
|
|
|
2024-06-16 23:33:38 +00:00
|
|
|
rsync --archive --verbose --compress --update --delete \
|
2024-06-18 22:29:59 +00:00
|
|
|
output_prod/ ssh.oliverdavies.uk:/srv/www.oliverdavies.uk
|
2024-01-26 08:15:06 +00:00
|
|
|
|
|
|
|
git stash pop
|
|
|
|
}
|
|
|
|
|
2024-05-03 14:21:56 +00:00
|
|
|
function test {
|
2024-07-30 19:26:39 +00:00
|
|
|
phpunit "${@}"
|
2024-05-03 14:21:56 +00:00
|
|
|
}
|
|
|
|
|
2024-01-26 08:15:06 +00:00
|
|
|
# vim: ft=bash
|