feat: Develop core scaffolding engine and Git configuration templates
This commit is contained in:
parent
d1eb191aaf
commit
b23efea14e
3 changed files with 104 additions and 0 deletions
67
lib/scaffold.sh
Normal file
67
lib/scaffold.sh
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# =============================================================================
|
||||||
|
# lib/scaffold.sh
|
||||||
|
# Directory structure creation and template rendering engine.
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
render_template() {
|
||||||
|
local template_file="$1"
|
||||||
|
local output_file="$2"
|
||||||
|
|
||||||
|
[[ ! -f "$template_file" ]] && { error "Template not found: ${template_file}"; exit 1; }
|
||||||
|
|
||||||
|
local content
|
||||||
|
content=$(cat "$template_file")
|
||||||
|
|
||||||
|
# Placeholder replacement
|
||||||
|
content="${content//\{\{GENOME_NAME\}\}/${GENOME_NAME}}"
|
||||||
|
content="${content//\{\{GENOME_NAME_UPPER\}\}/${GENOME_NAME^^}}"
|
||||||
|
content="${content//\{\{GENOME_DESC\}\}/${GENOME_DESC}}"
|
||||||
|
content="${content//\{\{FORGEJO_URL\}\}/${FORGEJO_URL}}"
|
||||||
|
content="${content//\{\{FORGEJO_USER\}\}/${FORGEJO_USER}}"
|
||||||
|
content="${content//\{\{VAULTWARDEN_URL\}\}/${VAULTWARDEN_URL}}"
|
||||||
|
content="${content//\{\{MASTER_REPO\}\}/${MASTER_REPO}}"
|
||||||
|
content="${content//\{\{DATE\}\}/$(date +%Y-%m-%d)}"
|
||||||
|
|
||||||
|
mkdir -p "$(dirname "$output_file")"
|
||||||
|
printf '%s\n' "$content" > "$output_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
scaffold_genome() {
|
||||||
|
local base="$1"
|
||||||
|
local dirs=(
|
||||||
|
"raw/articles" "raw/transcripts" "raw/code-packs" "raw/assets" "raw/private"
|
||||||
|
"wiki/sources" "wiki/entities" "wiki/concepts" "wiki/queries" "wiki/private"
|
||||||
|
)
|
||||||
|
|
||||||
|
info "Building directory structure in ${base}..."
|
||||||
|
for dir in "${dirs[@]}"; do
|
||||||
|
mkdir -p "${base}/${dir}"
|
||||||
|
touch "${base}/${dir}/.gitkeep"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Core templates
|
||||||
|
render_template "${TEMPLATES_DIR}/gitattributes" "${base}/.gitattributes"
|
||||||
|
render_template "${TEMPLATES_DIR}/gitignore" "${base}/.gitignore"
|
||||||
|
render_template "${TEMPLATES_DIR}/agents-genome.md" "${base}/AGENTS.md"
|
||||||
|
render_template "${TEMPLATES_DIR}/wiki-index.md" "${base}/wiki/index.md"
|
||||||
|
render_template "${TEMPLATES_DIR}/wiki-log.md" "${base}/wiki/log.md"
|
||||||
|
|
||||||
|
success "Scaffold completed for genome: ${GENOME_NAME}"
|
||||||
|
}
|
||||||
|
|
||||||
|
install_precommit_hook() {
|
||||||
|
local repo_path="$1"
|
||||||
|
local hook_path="${repo_path}/.git/hooks/pre-commit"
|
||||||
|
|
||||||
|
cp "${TEMPLATES_DIR}/pre-commit.sh" "$hook_path"
|
||||||
|
chmod +x "$hook_path"
|
||||||
|
success "Pre-commit security hook installed at: $hook_path"
|
||||||
|
}
|
||||||
|
|
||||||
|
scaffold_master() {
|
||||||
|
local base="$1"
|
||||||
|
render_template "${TEMPLATES_DIR}/agents-master.md" "${base}/AGENTS.md"
|
||||||
|
render_template "${TEMPLATES_DIR}/readme-master.md" "${base}/README.md"
|
||||||
|
success "Master repository scaffold completed."
|
||||||
|
}
|
||||||
17
templates/gitattributes
Normal file
17
templates/gitattributes
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
# --- Encryption Rules for Genomes ---
|
||||||
|
# These directories are stored as encrypted AES-256 blobs on the remote server.
|
||||||
|
# They require git-crypt and the specific genome key to be readable.
|
||||||
|
|
||||||
|
raw/private/** filter=git-crypt diff=git-crypt
|
||||||
|
wiki/private/** filter=git-crypt diff=git-crypt
|
||||||
|
|
||||||
|
# --- Binary Integrity ---
|
||||||
|
# Prevent line-ending conversion for encrypted files to avoid corruption.
|
||||||
|
raw/private/** -text
|
||||||
|
wiki/private/** -text
|
||||||
|
|
||||||
|
# --- Standard Text Configuration ---
|
||||||
|
*.md text eol=lf
|
||||||
|
*.sh text eol=lf
|
||||||
|
*.env text eol=lf
|
||||||
|
Makefile text eol=lf
|
||||||
20
templates/gitignore
Normal file
20
templates/gitignore
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
# --- Security Keys ---
|
||||||
|
# NEVER commit .key files to the repository
|
||||||
|
*.key
|
||||||
|
.resource_key
|
||||||
|
|
||||||
|
# --- Operating System Files ---
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
.directory
|
||||||
|
*.swp
|
||||||
|
|
||||||
|
# --- Obsidian & Editor Configs ---
|
||||||
|
.obsidian/
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# --- Temporary Files & Local Logs ---
|
||||||
|
*.log
|
||||||
|
.tmp/
|
||||||
|
node_modules/
|
||||||
Loading…
Add table
Reference in a new issue