diff --git a/.devcontainer/WELCOME.txt b/.devcontainer/WELCOME.txt new file mode 100644 index 0000000..2aed6aa --- /dev/null +++ b/.devcontainer/WELCOME.txt @@ -0,0 +1,29 @@ + +██████╗ ██████╗ ██╗ ██╗██╗ ██╗████████╗ ██╗███████╗ +██╔══██╗██╔══██╗██║ ██║╚██╗██╔╝╚══██╔══╝ ██║██╔════╝ +██║ ██║██████╔╝██║ ██║ ╚███╔╝ ██║ ██║███████╗ +██║ ██║██╔══██╗██║ ██║ ██╔██╗ ██║ ██ ██║╚════██║ +██████╔╝██║ ██║╚██████╔╝██╔╝ ██╗ ██║██╗╚█████╔╝███████║ +╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚════╝ ╚══════╝ + +Welcome to the Druxt serverless starterkit. + +Dependencies are installed, and the Drupal backend is provisioned and +running on port 8888. This site builds to full static output, so Drupal +only matters at build time - nothing needs to be running once it ships. + +Pick a task: + + npm run dev Nuxt dev server (port 3000) + npm run generate Build the full static site into nuxt/dist + npm run info What is running, and where + + npm run start Restart the backend (npm run stop halts it) + npm run login Print a one-time Drupal login link + npm run reset Wipe the database (npm run setup provisions it again) + + npm run drush -- Run Drush, e.g. npm run drush -- core:status + +Both ports above are forwarded automatically. + +Happy building. diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b6abbf8..acd4406 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -52,6 +52,11 @@ } }, "customizations": { + // Codespaces opens the welcome guide on first attach; other clients get it + // from the shell rc hook post-create.sh installs. + "codespaces": { + "openFiles": [".devcontainer/WELCOME.txt"] + }, "vscode": { "settings": { // Absolute path to where the mise feature installs the binary @@ -79,5 +84,6 @@ } }, "postCreateCommand": "bash .devcontainer/post-create.sh", + "postStartCommand": "bash .devcontainer/post-start.sh", "remoteUser": "vscode" } diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh index ffdabaf..dca8cd4 100755 --- a/.devcontainer/post-create.sh +++ b/.devcontainer/post-create.sh @@ -57,6 +57,25 @@ echo 'extension=gd' | sudo tee "$CONF_DIR/gd.ini" > /dev/null php -r "exit(extension_loaded('gd') ? 0 : 1);" || { echo "gd extension failed to load" >&2; exit 1; } +echo "==> Greeting new terminals with the welcome guide" +# postAttachCommand output goes to whatever launched the container - DevPod +# prints it to its own CLI log, outside the container - so someone opening a +# terminal never sees it. The shell's own rc file is the only place that +# reliably reaches them. +# +# Both rc files, because the base image ships bash and zsh and which one a +# terminal opens depends on the client. Every interactive shell, not once: a +# one-shot marker gets spent by whichever shell the editor opens first, which +# is rarely the one the user is looking at. +for rc in "$HOME/.bashrc" "$HOME/.zshrc"; do + cat >> "$rc" < Trusting this repo's mise.toml" mise trust @@ -66,3 +85,6 @@ echo "==> Running npm install (triggers the full setup pipeline)" # app's pinned Node 16 works fine but emits a wall of EBADENGINE # warnings that drowns the real setup output on first run. npm install --loglevel=error + +echo "==> Ready" +cat .devcontainer/WELCOME.txt diff --git a/.devcontainer/post-start.sh b/.devcontainer/post-start.sh new file mode 100755 index 0000000..40ea80a --- /dev/null +++ b/.devcontainer/post-start.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# +# Start the Drupal backend on every container start. Without this, stopping and +# resuming a container leaves the frontend pointing at a backend that is no +# longer listening, which looks like a broken install rather than a stopped +# process. +# +# Skipped, with a pointer, when the site was never provisioned (a post-create +# that failed part way), so one broken create does not also fail every start. +set -euo pipefail + +cd drupal +if [ ! -f web/sites/default/settings.local.php ]; then + echo "The Drupal backend is not provisioned. Run: npm run setup" >&2 + exit 0 +fi +.devtools/start