diff --git a/app/priv/blog/engineering/2026/05-14-generate-an-init-script-to-get-your-team-up-and-running.md b/app/priv/blog/engineering/2026/05-14-generate-an-init-script-to-get-your-team-up-and-running.md new file mode 100644 index 0000000..36d4319 --- /dev/null +++ b/app/priv/blog/engineering/2026/05-14-generate-an-init-script-to-get-your-team-up-and-running.md @@ -0,0 +1,88 @@ +%{ + title: "Generate an init script to get you(r team) up and running", + author: "Willem van den Ende", + tags: ~w(pi.dev AI continuous-delivery), + description: "Checking out a repository on a fresh machine often involves some fiddling around. An init scripts costs only one prompt and gets you going now, and months later when you forgot about how you set up the project.", + published: true +} +--- + +# init script made by qwen 3.6 / Pi + +I had firehose running on another laptop already, but I added a library for syntax highlighting code + +init.sh script in the repository . The escape codes for ’the server will be on:’ are Cyan color. I removed that by hand. + + Finished in 1.9 seconds (1.7s async, 0.1s sync) + 157 tests, 0 failures + [ OK ] All tests passed. + ============================================== + 🎉 Firehose is ready to go! + ============================================== + + Useful commands: + + make test Run the full test suite + make check Static analysis (credo + format) + make compile Compile the project + make format Format all code + + Start the dev server: + + cd app && mix phx.server + + The server will be on: \033[0;36mhttp://localhost:8056\033[0m + + Demo user (created by seed): + email: demo@example.com + pass: password123! + + Database: firehose_dev (PostgreSQL on localhost) + + Port: 8056 (override with PORT=xxxx) + +It is great to have a script that gets the repo ready for work. + +This was one fairly lazy prompt: + +> I think it would be handy to have an init script for this repository that also downloads the js dependencies. the init.sh script should get the dependencies, run the mix setup so there is a working db, run the tests and download the js assets. the goal +> is for an agent or a person to be able to start working. At the end of the script, print handy instructions e.g. to run make, and what PORT the server will run on + +It only took this prompt. I aborted it after I got a my `turn-limit` extension asked if I wanted to give it more than 25 turns. The agent was done, but couldnt’ actually run the init script because the sandbox does not give it sufficient permissions to do so. + +I was using another project I hadn’t run in a months on a machine I hadn’t yet used it on. That project had an `init.sh` script, and got me going in a minute. + + + + +## Further reading + +A Full ;-), [very brief transcript](`/images/blog/2026/transcripts/make-init-script.html`). +Done. Here’s what init.sh does: + + + + +## Bonus item - what the init script does, and performance + +According to the agent: + +1. Pre-flight checks — verifies elixir, mix, node, npm, and PostgreSQL are available +2. make deps — fetches all Elixir dependencies +3. mix ecto.setup — creates the DB, runs migrations, seeds demo user +4. npm install — installs JS dependencies (highlight.js, etc.) in assets/ +5. mix assets.setup && mix assets.build — installs esbuild/tailwind and bundles the JS/CSS +6. make test — runs the full test suite + +Ends with a summary showing how to start the server (port 8056), demo credentials, and handy make commands. + +The snippet below is from my performance widget. Token generation is not super fast, but all 32 turns ran while attending Chris Parsons’ webinar. 2.5 minutes for a script that ’just works’ is good enough for me. + +📊 Performance: llama.cpp/Qwen3.6-35B-A3B-MXFP4MOE.gguf + Prefill: 28,376 tokens @ 5253.8 tok/s + Generation: 5,699 tokens @ 38.8 tok/s + Combined: 34,075 tokens @ 223.5 tok/s (2.5m total) + TTFT: 5401ms + Turns: 32 + + diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..60c31cd --- /dev/null +++ b/init.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash +# +# init.sh — One-command setup for the Firehose monorepo. +# Installs deps, sets up the DB, builds JS assets, and runs tests. +# +set -euo pipefail + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +CYAN='\033[0;36m' +NC='\033[0m' # No Color + +info() { echo -e "${CYAN}[INFO]${NC} $*"; } +ok() { echo -e "${GREEN}[ OK ]${NC} $*"; } +warn() { echo -e "${YELLOW}[ WARN ]${NC} $*"; } +fail() { echo -e "${RED}[ FAIL ]${NC} $*"; } + +# ── Pre-flight checks ────────────────────────────────────────────── + +missing=() + +for cmd in elixir mix node npm; do + command -v "$cmd" &>/dev/null || missing+=("$cmd") +done + +if [ ${#missing[@]} -gt 0 ]; then + fail "Missing required tools: ${missing[*]}" + echo "Install them via mise (mise install) or your package manager." + exit 1 +fi + +# Check for PostgreSQL +if ! pg_isready &>/dev/null; then + fail "PostgreSQL is not running or not reachable on localhost." + echo "Start it with: brew services start postgresql (or equivalent)" + exit 1 +fi + +# ── 1. Get Elixir dependencies ───────────────────────────────────── + +info "Fetching Elixir dependencies ..." +make deps +ok "Dependencies fetched." + +# ── 2. Set up the database ───────────────────────────────────────── + +info "Setting up the database (create + migrate + seed) ..." +cd app && mise exec -- mix ecto.setup +ok "Database ready." +cd .. + +# ── 3. Install npm dependencies for assets ───────────────────────── + +info "Installing npm dependencies in assets/ ..." +cd app/assets +# Use a temp cache dir to avoid root-owned-file issues in ~/.npm +npm install --cache /tmp/pi-npm-cache 2>/dev/null || npm install +cd ../.. +ok "npm dependencies installed." + +# ── 4. Build JS assets ───────────────────────────────────────────── + +info "Building JS assets ..." +cd app && mise exec -- mix assets.setup && mise exec -- mix assets.build +ok "JS assets built." +cd .. + +# ── 5. Run tests ─────────────────────────────────────────────────── + +info "Running tests ..." +make test +ok "All tests passed." + +# ── Done ─────────────────────────────────────────────────────────── + +echo "" +echo "==============================================" +echo " 🎉 Firehose is ready to go!" +echo "==============================================" +echo "" +echo " Useful commands:" +echo "" +echo " make test Run the full test suite" +echo " make check Static analysis (credo + format)" +echo " make compile Compile the project" +echo " make format Format all code" +echo "" +echo " Start the dev server:" +echo "" +echo " cd app && mix phx.server" +echo "" +echo " The server will be on: http://localhost:8056" +echo "" +echo " Demo user (created by seed):" +echo " email: demo@example.com" +echo " pass: password123!" +echo "" +echo " Database: firehose_dev (PostgreSQL on localhost)" +echo "" +echo " Port: 8056 (override with PORT=xxxx)" +echo "" +echo "=============================================="