Manage configuration files with Build Configs
https://www.oliverdavies.dev/build-configs
This commit is contained in:
parent
3174c501bc
commit
89d441106a
14
.gitignore
vendored
14
.gitignore
vendored
|
@ -1,5 +1,9 @@
|
||||||
.direnv/
|
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||||
node_modules/
|
|
||||||
output_*/
|
/output_*/
|
||||||
source/build/
|
/vendor/
|
||||||
vendor/
|
|
||||||
|
/.direnv/
|
||||||
|
|
||||||
|
/node_modules/
|
||||||
|
/source/build/
|
||||||
|
|
2
.tmux
2
.tmux
|
@ -16,7 +16,7 @@ tmux new-session -d -s "${session_name}" -n vim -c "${session_path}"
|
||||||
# 1. Main window: Vim
|
# 1. Main window: Vim
|
||||||
tmux send-keys -t "${session_name}:vim" "nvim" Enter
|
tmux send-keys -t "${session_name}:vim" "nvim" Enter
|
||||||
tmux split-pane -t "${session_name}:vim" -h -c "${session_path}" -p 40
|
tmux split-pane -t "${session_name}:vim" -h -c "${session_path}" -p 40
|
||||||
tmux send-keys -t "${session_name}:vim.right" "vendor/bin/sculpin generate --server --watch" Enter
|
tmux send-keys -t "${session_name}:vim.right" "./run start" Enter
|
||||||
|
|
||||||
# 2. General shell use.
|
# 2. General shell use.
|
||||||
tmux new-window -t "${session_name}" -c "${session_path}"
|
tmux new-window -t "${session_name}" -c "${session_path}"
|
||||||
|
|
16
build.yaml
Normal file
16
build.yaml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
name: oliverdavies-uk
|
||||||
|
type: sculpin
|
||||||
|
language: php
|
||||||
|
|
||||||
|
flake:
|
||||||
|
devshell:
|
||||||
|
packages:
|
||||||
|
- nodePackages.pnpm
|
||||||
|
- nodejs
|
||||||
|
- php81
|
||||||
|
- php81Packages.composer
|
||||||
|
|
||||||
|
git:
|
||||||
|
ignore:
|
||||||
|
- /node_modules/
|
||||||
|
- /source/build/
|
|
@ -72,16 +72,16 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1703200384,
|
"lastModified": 1705856552,
|
||||||
"narHash": "sha256-q5j06XOsy0qHOarsYPfZYJPWbTbc8sryRxianlEPJN0=",
|
"narHash": "sha256-JXfnuEf5Yd6bhMs/uvM67/joxYKoysyE3M2k6T3eWbg=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "0b3d618173114c64ab666f557504d6982665d328",
|
"rev": "612f97239e2cc474c13c9dafa0df378058c5ad8d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"ref": "nixos-23.11",
|
"ref": "nixos-unstable",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||||
description = "oliverdavies.uk-sculpin";
|
|
||||||
|
|
||||||
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
devshell.url = "github:numtide/devshell";
|
devshell.url = "github:numtide/devshell";
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs@{ flake-parts, ... }:
|
outputs = inputs@{ flake-parts, ... }:
|
||||||
|
@ -15,8 +15,8 @@
|
||||||
perSystem = { config, self', inputs', pkgs, system, ... }: {
|
perSystem = { config, self', inputs', pkgs, system, ... }: {
|
||||||
devshells.default = {
|
devshells.default = {
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
"nodejs"
|
|
||||||
"nodePackages.pnpm"
|
"nodePackages.pnpm"
|
||||||
|
"nodejs"
|
||||||
"php81"
|
"php81"
|
||||||
"php81Packages.composer"
|
"php81Packages.composer"
|
||||||
];
|
];
|
||||||
|
|
84
run
84
run
|
@ -1,56 +1,12 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
function clean {
|
PATH="${PATH}:./vendor/bin"
|
||||||
rm -fr output_*/ source/build/
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create a new daily email.
|
# Generate the site.
|
||||||
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}"
|
|
||||||
sed -i "s#{{ permalink }}#archive/${year}/${month}/${day}/${slug}#" "${filepath}"
|
|
||||||
|
|
||||||
# Create a commit with the appropriate date in the message
|
|
||||||
git add "${filepath}"
|
|
||||||
git commit --quiet -m "Add daily email for ${date}
|
|
||||||
|
|
||||||
${title}"
|
|
||||||
|
|
||||||
echo "${filepath}"
|
|
||||||
}
|
|
||||||
function generate {
|
function generate {
|
||||||
local args=()
|
local args=()
|
||||||
|
|
||||||
|
@ -71,35 +27,15 @@ function help {
|
||||||
printf "\nExtended help:\n Each task has comments for general usage\n"
|
printf "\nExtended help:\n Each task has comments for general usage\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
function npm:build:css {
|
# Start the project.
|
||||||
local args=()
|
function start {
|
||||||
|
sculpin generate --server --watch "${@}"
|
||||||
if [[ "${NODE_ENV:-}" == "production" ]]; then
|
|
||||||
args=(--minify)
|
|
||||||
else
|
|
||||||
args=(--watch)
|
|
||||||
fi
|
|
||||||
|
|
||||||
npx tailwindcss \
|
|
||||||
--config assets/tailwind.config.ts \
|
|
||||||
--output source/build/tailwind.css "${args[@]}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function publish {
|
# Include any local tasks.
|
||||||
export NODE_ENV=production
|
[[ -e run.local ]] && source run.local
|
||||||
export APP_ENV=production
|
|
||||||
|
|
||||||
git stash
|
|
||||||
|
|
||||||
clean
|
|
||||||
npm:build:css
|
|
||||||
generate
|
|
||||||
|
|
||||||
rsync --archive --verbose --compress --update --delete \
|
|
||||||
output_prod/ ssh.oliverdavies.uk:/srv/oliverdavies.uk-sculpin
|
|
||||||
|
|
||||||
git stash pop
|
|
||||||
}
|
|
||||||
|
|
||||||
TIMEFORMAT="Task completed in %3lR"
|
TIMEFORMAT="Task completed in %3lR"
|
||||||
time "${@:-help}"
|
time "${@:-help}"
|
||||||
|
|
||||||
|
# vim: ft=bash
|
||||||
|
|
82
run.local
Executable file
82
run.local
Executable file
|
@ -0,0 +1,82 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function clean {
|
||||||
|
rm -fr output_*/ source/build/
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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}"
|
||||||
|
sed -i "s#{{ permalink }}#archive/${year}/${month}/${day}/${slug}#" "${filepath}"
|
||||||
|
|
||||||
|
# Create a commit with the appropriate date in the message
|
||||||
|
git add "${filepath}"
|
||||||
|
git commit --quiet -m "Add daily email for ${date}
|
||||||
|
|
||||||
|
${title}"
|
||||||
|
|
||||||
|
echo "${filepath}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function npm:build:css {
|
||||||
|
local args=()
|
||||||
|
|
||||||
|
if [[ "${NODE_ENV:-}" == "production" ]]; then
|
||||||
|
args=(--minify)
|
||||||
|
else
|
||||||
|
args=(--watch)
|
||||||
|
fi
|
||||||
|
|
||||||
|
npx tailwindcss \
|
||||||
|
--config assets/tailwind.config.ts \
|
||||||
|
--output source/build/tailwind.css "${args[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function publish {
|
||||||
|
export NODE_ENV=production
|
||||||
|
export APP_ENV=production
|
||||||
|
|
||||||
|
git stash
|
||||||
|
|
||||||
|
clean
|
||||||
|
npm:build:css
|
||||||
|
generate
|
||||||
|
|
||||||
|
rsync --archive --verbose --compress --update --delete \
|
||||||
|
output_prod/ ssh.oliverdavies.uk:/srv/oliverdavies.uk-sculpin
|
||||||
|
|
||||||
|
git stash pop
|
||||||
|
}
|
||||||
|
|
||||||
|
# vim: ft=bash
|
Loading…
Reference in a new issue