Skip to content

Commit 1ad632a

Browse files
committed
refactor(install): protect project scaffolding and update core framework separately
1 parent c54129b commit 1ad632a

File tree

2 files changed

+59
-26
lines changed

2 files changed

+59
-26
lines changed

docs/install.sh

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,44 +60,39 @@ trap 'rm -rf "$TEMP_DIR"' EXIT
6060
git clone --depth 1 -q "$REPO_URL" "$TEMP_DIR" || error "Failed to clone template repository."
6161

6262
# --- Discovery ---
63-
FILES_TO_EXTRACT=(
64-
"GEMINI.md"
65-
"makefile"
66-
"TASKS.md"
67-
"CHANGELOG.md"
68-
"README.md"
69-
)
70-
71-
CONTENT_DIRS=(
72-
"journal"
73-
"plans"
74-
"research"
75-
"drafts"
76-
)
63+
CORE_FILES=("GEMINI.md")
64+
SCAFFOLD_FILES=("README.md" "TASKS.md" "CHANGELOG.md" "makefile")
65+
CONTENT_DIRS=("journal" "plans" "research" "drafts")
7766

7867
WILL_CREATE=()
7968
WILL_UPDATE=()
8069

81-
# Check .gemini directory
70+
# 1. Core Framework Check
8271
if [[ -d ".gemini" ]]; then
8372
WILL_UPDATE+=(".gemini/ (core framework)")
8473
else
8574
WILL_CREATE+=(".gemini/ (core framework)")
8675
fi
8776

88-
# Check top-level files
89-
for f in "${FILES_TO_EXTRACT[@]}"; do
77+
for f in "${CORE_FILES[@]}"; do
9078
if [[ -e "$f" ]]; then
91-
WILL_UPDATE+=("$f")
79+
WILL_UPDATE+=("$f (core framework)")
9280
else
93-
WILL_CREATE+=("$f")
81+
WILL_CREATE+=("$f (core framework)")
9482
fi
9583
done
9684

97-
# Check content directories
85+
# 2. Project Scaffolding Check
86+
for f in "${SCAFFOLD_FILES[@]}"; do
87+
if [[ ! -e "$f" ]]; then
88+
WILL_CREATE+=("$f (new scaffolding)")
89+
fi
90+
done
91+
92+
# 3. Content Directories Check
9893
for d in "${CONTENT_DIRS[@]}"; do
9994
if [[ ! -d "$d" ]]; then
100-
WILL_CREATE+=("$d/")
95+
WILL_CREATE+=("$d/ (new content directory)")
10196
fi
10297
done
10398

@@ -109,7 +104,7 @@ if [[ ${#WILL_CREATE[@]} -gt 0 ]]; then
109104
fi
110105

111106
if [[ ${#WILL_UPDATE[@]} -gt 0 ]]; then
112-
echo -e "\033[1;34mExisting files/folders to update (framework only):\033[0m"
107+
echo -e "\033[1;34mExisting files/folders to update (core framework):\033[0m"
113108
for f in "${WILL_UPDATE[@]}"; do echo " ~ $f"; done
114109
fi
115110

@@ -128,20 +123,27 @@ echo "🛠️ Applying changes..."
128123
mkdir -p .gemini
129124
cp -r "$TEMP_DIR/.gemini/." .gemini/
130125

131-
# 2. Update Top-Level Files
132-
for f in "${FILES_TO_EXTRACT[@]}"; do
126+
# 2. Update Core Files (Always)
127+
for f in "${CORE_FILES[@]}"; do
133128
cp "$TEMP_DIR/$f" .
134129
done
135130

136-
# 3. Ensure Content Directories & .gitkeep
131+
# 3. Create Scaffolding Files (Only if missing)
132+
for f in "${SCAFFOLD_FILES[@]}"; do
133+
if [[ ! -f "$f" ]]; then
134+
cp "$TEMP_DIR/$f" .
135+
fi
136+
done
137+
138+
# 4. Ensure Content Directories & .gitkeep
137139
for d in "${CONTENT_DIRS[@]}"; do
138140
mkdir -p "$d"
139141
if [[ -f "$TEMP_DIR/$d/.gitkeep" ]]; then
140142
cp "$TEMP_DIR/$d/.gitkeep" "$d/"
141143
fi
142144
done
143145

144-
# 4. Journal Entry
146+
# 5. Journal Entry
145147
TODAY=$(date +%Y-%m-%d)
146148
mkdir -p journal
147149
JOURNAL_FILE="journal/$TODAY.md"

plans/refine-install-script.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Plan: Refine `install.sh` File Handling
2+
3+
## Objective
4+
Update `docs/install.sh` to distinguish between core framework files (which should be extracted/updated) and project scaffolding files (which should only be created if they don't exist).
5+
6+
## Requirements
7+
- **Core Framework (Always Extract):** `.gemini/`, `GEMINI.md`.
8+
- **Project Scaffolding (Create If Missing):** `README.md`, `TASKS.md`, `CHANGELOG.md`, `makefile`.
9+
- **Content Directories:** `journal/`, `plans/`, `research/`, `drafts/` (Ensure existence).
10+
11+
## Proposed Changes
12+
13+
### 1. Update `docs/install.sh`
14+
- **Re-categorize variables:**
15+
- `CORE_FILES=("GEMINI.md")`
16+
- `SCAFFOLD_FILES=("README.md" "TASKS.md" "CHANGELOG.md" "makefile")`
17+
- `CONTENT_DIRS=("journal" "plans" "research" "drafts")`
18+
- **Refine Summary Logic:**
19+
- Loop through `CORE_FILES` and `.gemini/` to mark as "Update" if they exist, or "Create" if they don't.
20+
- Loop through `SCAFFOLD_FILES` and mark as "Create" ONLY if they don't exist. If they exist, they should be ignored by the update process.
21+
- **Refine Execution Logic:**
22+
- **Core:** `cp -r "$TEMP_DIR/.gemini/." .gemini/` and `cp "$TEMP_DIR/GEMINI.md" .` (Always overwrite).
23+
- **Scaffold:** Use `cp -n` (no-clobber) or `if [[ ! -f "$f" ]]; then cp ...; fi` for each file in `SCAFFOLD_FILES`.
24+
- **Directories:** Keep existing logic to ensure directories exist.
25+
26+
## Verification Strategy
27+
- **Code Review:** Ensure the shell logic correctly uses `[[ ! -f "$f" ]]` or `cp -n` to prevent overwriting existing user project files.
28+
- **Manual Test:** Run the script in a test environment to verify:
29+
- `GEMINI.md` is updated.
30+
- Existing `README.md` is preserved.
31+
- Missing `makefile` is created.

0 commit comments

Comments
 (0)