template-engine-copier skill: initial import

Copier + Jinja template-repository design skill: reference architecture,
implementation workflow, validation checklist, and a full worked example
template (questionnaire, extensions, resolvers, wrapper-first .scripts).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-12 22:30:29 +03:00
co-authored by Claude Opus 5
commit 97991021ff
29 changed files with 932 additions and 0 deletions
@@ -0,0 +1,41 @@
#!/bin/bash
export HL_V1_COPIER_TARGET_DIR=""
export HL_V1_COPIER_FORCE_COPY=false
export HL_V1_COPIER_PARAMS_FILE=""
export HL_V1_COPIER_FILE_COPIER_ANSWERS="copier-answers.yml"
export HL_V1_COPIER_FILE_COPIER_ANSWERS_NEW="copier-answers-new.yml"
ALL_ARGS=("$@")
while [ "$#" -gt 0 ]; do
case "$1" in
--copier-target-dir=*)
export HL_V1_COPIER_TARGET_DIR="${1#*=}"
shift
;;
--copier-target-dir)
export HL_V1_COPIER_TARGET_DIR="$2"
shift 2
;;
--copier-force-copy=*)
export HL_V1_COPIER_FORCE_COPY="${1#*=}"
shift
;;
--copier-force-copy)
export HL_V1_COPIER_FORCE_COPY="$2"
shift 2
;;
--copier-params-file=*)
export HL_V1_COPIER_PARAMS_FILE="${1#*=}"
shift
;;
--copier-params-file)
export HL_V1_COPIER_PARAMS_FILE="$2"
shift 2
;;
*)
shift
;;
esac
done
set -- "${ALL_ARGS[@]}"
@@ -0,0 +1,4 @@
#!/bin/bash
. ./.scripts/copier/lib/answers/--index-api.sh
. ./.scripts/copier/lib/-bootstrap-one.sh
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
. ./.scripts/copier/lib/--env-vars-reader.sh "$@"
. ./.scripts/copier/lib/--index-api.sh
@@ -0,0 +1,33 @@
#!/bin/bash
set -e
_copier_bootstrap_one() {
[ -z "${HL_V1_COPIER_TARGET_DIR}" ] && {
echo "--copier-target-dir is required"
return 1
}
_copier_answers_new_ensure_existence
_copier_answers_previous_pull_and_merge
_copier_answers_params_pull_and_merge
if [ "${HL_V1_COPIER_FORCE_COPY}" = "true" ]; then
copier copy \
--trust \
--force \
--overwrite \
--data-file "${HL_V1_COPIER_FILE_COPIER_ANSWERS_NEW}" \
. "${HL_V1_COPIER_TARGET_DIR}"
else
copier copy \
--trust \
--data-file "${HL_V1_COPIER_FILE_COPIER_ANSWERS_NEW}" \
. "${HL_V1_COPIER_TARGET_DIR}"
fi
# Keep template repo CI separate from rendered repo CI, same pattern as source repos.
if [ -f "${HL_V1_COPIER_TARGET_DIR}/.tmp-gitlab-ci.yml" ]; then
mv "${HL_V1_COPIER_TARGET_DIR}/.tmp-gitlab-ci.yml" "${HL_V1_COPIER_TARGET_DIR}/.gitlab-ci.yml"
fi
}
@@ -0,0 +1,5 @@
#!/bin/bash
. ./.scripts/copier/lib/answers/-new-ensure-existance.sh
. ./.scripts/copier/lib/answers/-previous-pull-and-merge.sh
. ./.scripts/copier/lib/answers/-params-pull-and-merge.sh
@@ -0,0 +1,5 @@
#!/bin/bash
_copier_answers_new_ensure_existence() {
[ -f "${HL_V1_COPIER_FILE_COPIER_ANSWERS_NEW}" ] || touch "${HL_V1_COPIER_FILE_COPIER_ANSWERS_NEW}"
}
@@ -0,0 +1,17 @@
#!/bin/bash
_copier_answers_params_pull_and_merge() {
[ -f "${HL_V1_COPIER_PARAMS_FILE}" ] || return 0
[ -f "${HL_V1_COPIER_FILE_COPIER_ANSWERS_NEW}" ] || return 0
if command -v yq >/dev/null 2>&1; then
local TMP_WORK_FILE="tmp-work-file.yml"
yq eval-all '. as $item ireduce ({}; . * $item)' \
"${HL_V1_COPIER_FILE_COPIER_ANSWERS_NEW}" \
"${HL_V1_COPIER_PARAMS_FILE}" >"${TMP_WORK_FILE}"
mv "${TMP_WORK_FILE}" "${HL_V1_COPIER_FILE_COPIER_ANSWERS_NEW}"
else
# Fallback: params file wins as full override when yq is unavailable.
cp "${HL_V1_COPIER_PARAMS_FILE}" "${HL_V1_COPIER_FILE_COPIER_ANSWERS_NEW}"
fi
}
@@ -0,0 +1,6 @@
#!/bin/bash
_copier_answers_previous_pull_and_merge() {
local PREVIOUS="${HL_V1_COPIER_TARGET_DIR}/${HL_V1_COPIER_FILE_COPIER_ANSWERS}"
[ -f "${PREVIOUS}" ] && cp "${PREVIOUS}" "${HL_V1_COPIER_FILE_COPIER_ANSWERS_NEW}" || true
}