Skip to content

Commit 379fa6e

Browse files
refactor: consolidate doctor and troubleshooting into single command
- Merge troubleshooting.sh checks into doctor.sh (placeholder detection, script permission auto-fix) - Add create-container.sh as postCreateCommand orchestrator - Sync devcontainer extensions between root and template - Update e2e workflow and README references
1 parent 1f88722 commit 379fa6e

11 files changed

Lines changed: 113 additions & 210 deletions

File tree

β€Ž.devcontainer/devcontainer.jsonβ€Ž

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,24 @@
1313
"ghcr.io/devcontainers/features/node:1": {},
1414
"ghcr.io/devcontainers/features/github-cli:1": {}
1515
},
16-
"postCreateCommand": "bash ./scripts/setup-ai-tools.sh",
16+
"postCreateCommand": "bash ./scripts/create-container.sh",
1717
"customizations": {
1818
"vscode": {
1919
"extensions": [
2020
"esbenp.prettier-vscode",
21-
"GitHub.github-vscode-theme",
21+
"bierner.markdown-mermaid",
22+
"mechatroner.rainbow-csv",
23+
"esbenp.prettier-vscode",
2224
"bierner.markdown-mermaid",
2325
"mechatroner.rainbow-csv",
2426
"ms-vscode.makefile-tools",
2527
"ms-azuretools.vscode-containers",
2628
"ms-azuretools.vscode-docker",
2729
"github.vscode-github-actions",
2830
"github.vscode-pull-request-github",
31+
"streetsidesoftware.code-spell-checker-cspell-bundled-dictionaries",
32+
"streetsidesoftware.code-spell-checker",
33+
"anthropic.claude-code",
2934
"DavidAnson.vscode-markdownlint"
3035
],
3136
"settings": {

β€Ž.github/workflows/e2e-install.ymlβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ jobs:
3636
test -f AGENTS.md
3737
test -d scripts
3838
test -f scripts/setup-env.sh
39-
test -f scripts/troubleshooting.sh
39+
test -f scripts/doctor.sh
4040
4141
echo "Verifying execute permissions..."
4242
test -x scripts/setup-env.sh
4343
test -x scripts/start-container.sh
44-
test -x scripts/troubleshooting.sh
44+
test -x scripts/doctor.sh
4545
4646
echo "Verifying no root-only files leaked..."
4747
if [ -f "install.sh" ]; then

β€Ž.vscode/extensions.jsonβ€Ž

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"ms-azuretools.vscode-docker",
99
"github.vscode-github-actions",
1010
"github.vscode-pull-request-github",
11-
"streetsidesoftware.code-spell-checker-cspell-bundled-dictionaries"
11+
"streetsidesoftware.code-spell-checker-cspell-bundled-dictionaries",
12+
"streetsidesoftware.code-spell-checker",
13+
"anthropic.claude-code",
14+
"DavidAnson.vscode-markdownlint"
1215
]
1316
}

β€Žscripts/create-container.shβ€Ž

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Orchestrator for postCreateCommand β€” runs once when the container is first created.
5+
# Calls individual setup scripts in the correct order.
6+
7+
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
8+
# shellcheck source=scripts/utils.sh
9+
source "$SCRIPT_DIR/utils.sh"
10+
11+
ensure_root
12+
13+
log_info "Running first-time container setup..."
14+
15+
# 1. Install AI CLI tools (Gemini, Claude, extensions)
16+
bash ./scripts/setup-ai-tools.sh
17+
18+
log_success "Container creation setup complete."

β€Žscripts/doctor.shβ€Ž

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/bin/bash
22
set -uo pipefail
33

4-
# Non-interactive health check β€” runs on every container start.
5-
# Never prompts for input. Reports status and directs to 'make setup' if needed.
4+
# Unified environment health check and troubleshooting.
5+
# Runs non-interactively on every container start and can be invoked manually.
6+
# Never prompts for input. Reports status, auto-fixes what it can,
7+
# and directs to 'make setup' for the rest.
68

79
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
810
# shellcheck source=scripts/utils.sh
@@ -18,7 +20,12 @@ echo "────────────────────────
1820

1921
# --- Load .env and apply git config ---
2022
if [ -f .env ]; then
21-
log_success ".env file found."
23+
if grep -q "YOUR_GIT_NAME_HERE" .env || grep -q "YOUR_GIT_EMAIL_HERE" .env; then
24+
log_warn ".env file contains placeholder values. Run 'make setup' to configure."
25+
ISSUES=$((ISSUES + 1))
26+
else
27+
log_success ".env file found."
28+
fi
2229
safe_export_env
2330

2431
# Apply git config from .env
@@ -37,7 +44,7 @@ if [ -f .env ]; then
3744
gh auth setup-git 2>/dev/null || true
3845
fi
3946
else
40-
log_warn ".env file not found."
47+
log_warn ".env file not found. Run 'make setup' to configure."
4148
ISSUES=$((ISSUES + 1))
4249
fi
4350

@@ -64,7 +71,7 @@ if command -v gh &> /dev/null; then
6471
if gh auth status &> /dev/null; then
6572
log_success "GitHub CLI authenticated."
6673
else
67-
log_warn "GitHub CLI installed but not authenticated."
74+
log_warn "GitHub CLI installed but not authenticated. Run 'gh auth login'."
6875
ISSUES=$((ISSUES + 1))
6976
fi
7077
else
@@ -100,6 +107,23 @@ for var in GEMINI_API_KEY ANTHROPIC_API_KEY GITHUB_TOKEN; do
100107
fi
101108
done
102109

110+
# --- Script permissions ---
111+
echo ""
112+
echo "πŸ” Script Permissions"
113+
echo "──────────────────────────────────────"
114+
PERM_ISSUE=0
115+
for script in scripts/*.sh templates/scripts/*.sh; do
116+
if [ -f "$script" ] && [ ! -x "$script" ]; then
117+
PERM_ISSUE=1
118+
fi
119+
done
120+
if [ $PERM_ISSUE -eq 1 ]; then
121+
chmod +x scripts/*.sh templates/scripts/*.sh 2>/dev/null || true
122+
log_success "Fixed missing execute permissions on scripts."
123+
else
124+
log_success "All scripts have correct permissions."
125+
fi
126+
103127
# --- Git hooks ---
104128
echo ""
105129
echo "πŸ”§ Git Hooks"

β€Žscripts/troubleshooting.shβ€Ž

Lines changed: 0 additions & 108 deletions
This file was deleted.

β€Žtemplates/.devcontainer/devcontainer.jsonβ€Ž

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"ghcr.io/devcontainers/features/node:1": {},
1414
"ghcr.io/devcontainers/features/github-cli:1": {}
1515
},
16-
"postCreateCommand": "bash ./scripts/setup-ai-tools.sh",
16+
"postCreateCommand": "bash ./scripts/create-container.sh",
1717
"customizations": {
1818
"vscode": {
1919
"extensions": [
@@ -24,7 +24,8 @@
2424
"ms-azuretools.vscode-containers",
2525
"ms-azuretools.vscode-docker",
2626
"github.vscode-github-actions",
27-
"github.vscode-pull-request-github"
27+
"github.vscode-pull-request-github",
28+
"DavidAnson.vscode-markdownlint"
2829
],
2930
"settings": {
3031
"workbench.startupEditor": "none",

β€Žtemplates/README.mdβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ Here's what was installed and why:
3535
β”œβ”€β”€ scripts/ # βš™οΈ Setup & automation scripts
3636
β”‚ β”œβ”€β”€ start-container.sh # [postStartCommand] Fast, idempotent checks
3737
β”‚ β”œβ”€β”€ setup-env.sh # [Manual] Interactive setup for credentials
38-
β”‚ β”œβ”€β”€ troubleshooting.sh # [Manual] Diagnose common environment issues
39-
β”‚ β”œβ”€β”€ setup-gemini.sh # [postCreateCommand] Global tool installations
38+
β”‚ β”œβ”€β”€ doctor.sh # [Manual/Auto] Environment health check & troubleshooting
39+
β”‚ β”œβ”€β”€ setup-ai-tools.sh # [postCreateCommand] Global tool installations
4040
β”‚ β”œβ”€β”€ ai-context.sh # [Manual] Bundle metadata for AI assistants
4141
β”‚ └── new-adr.sh # [Manual] Scaffold a new ADR file
4242
β”‚
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Orchestrator for postCreateCommand β€” runs once when the container is first created.
5+
# Calls individual setup scripts in the correct order.
6+
7+
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
8+
# shellcheck source=scripts/utils.sh
9+
source "$SCRIPT_DIR/utils.sh"
10+
11+
ensure_root
12+
ensure_container
13+
14+
log_info "Running first-time container setup..."
15+
16+
# 1. Install AI CLI tools (Gemini, Claude, extensions)
17+
bash ./scripts/setup-ai-tools.sh
18+
19+
log_success "Container creation setup complete."

β€Žtemplates/scripts/doctor.shβ€Ž

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/bin/bash
22
set -uo pipefail
33

4-
# Non-interactive health check β€” runs on every container start.
5-
# Never prompts for input. Reports status and directs to 'make setup' if needed.
4+
# Unified environment health check and troubleshooting.
5+
# Runs non-interactively on every container start and can be invoked manually.
6+
# Never prompts for input. Reports status, auto-fixes what it can,
7+
# and directs to 'make setup' for the rest.
68

79
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
810
# shellcheck source=scripts/utils.sh
@@ -18,7 +20,12 @@ echo "────────────────────────
1820

1921
# --- Load .env and apply git config ---
2022
if [ -f .env ]; then
21-
log_success ".env file found."
23+
if grep -q "YOUR_GIT_NAME_HERE" .env || grep -q "YOUR_GIT_EMAIL_HERE" .env; then
24+
log_warn ".env file contains placeholder values. Run 'make setup' to configure."
25+
ISSUES=$((ISSUES + 1))
26+
else
27+
log_success ".env file found."
28+
fi
2229
safe_export_env
2330

2431
# Apply git config from .env
@@ -37,7 +44,7 @@ if [ -f .env ]; then
3744
gh auth setup-git 2>/dev/null || true
3845
fi
3946
else
40-
log_warn ".env file not found."
47+
log_warn ".env file not found. Run 'make setup' to configure."
4148
ISSUES=$((ISSUES + 1))
4249
fi
4350

@@ -64,7 +71,7 @@ if command -v gh &> /dev/null; then
6471
if gh auth status &> /dev/null; then
6572
log_success "GitHub CLI authenticated."
6673
else
67-
log_warn "GitHub CLI installed but not authenticated."
74+
log_warn "GitHub CLI installed but not authenticated. Run 'gh auth login'."
6875
ISSUES=$((ISSUES + 1))
6976
fi
7077
else
@@ -100,6 +107,23 @@ for var in GEMINI_API_KEY ANTHROPIC_API_KEY GITHUB_TOKEN; do
100107
fi
101108
done
102109

110+
# --- Script permissions ---
111+
echo ""
112+
echo "πŸ” Script Permissions"
113+
echo "──────────────────────────────────────"
114+
PERM_ISSUE=0
115+
for script in scripts/*.sh; do
116+
if [ -f "$script" ] && [ ! -x "$script" ]; then
117+
PERM_ISSUE=1
118+
fi
119+
done
120+
if [ $PERM_ISSUE -eq 1 ]; then
121+
chmod +x scripts/*.sh 2>/dev/null || true
122+
log_success "Fixed missing execute permissions on scripts."
123+
else
124+
log_success "All scripts have correct permissions."
125+
fi
126+
103127
# --- Git hooks ---
104128
echo ""
105129
echo "πŸ”§ Git Hooks"

0 commit comments

Comments
Β (0)