@@ -4,6 +4,7 @@ set -euo pipefail
44SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
55REPO_ROOT=" $( cd " ${SCRIPT_DIR} /.." && pwd) "
66TEMPLATE_DIR=" ${REPO_ROOT} /templates/project"
7+ REPO_RAW_BASE=" ${REPO_RAW_BASE:- https:// raw.githubusercontent.com/ psfs/ core/ master} "
78
89PROJECT_NAME=" "
910TARGET_PATH=" "
@@ -51,6 +52,37 @@ require_template() {
5152 [[ -f " ${TEMPLATE_DIR} /${file} " ]] || die " Template not found: ${TEMPLATE_DIR} /${file} "
5253}
5354
55+ download_file () {
56+ local source=" $1 "
57+ local destination=" $2 "
58+ mkdir -p " $( dirname " ${destination} " ) "
59+
60+ if command_exists curl; then
61+ curl -fsSL " ${source} " -o " ${destination} "
62+ return
63+ fi
64+ if command_exists wget; then
65+ wget -qO " ${destination} " " ${source} "
66+ return
67+ fi
68+
69+ die " Unable to download templates: neither curl nor wget is available."
70+ }
71+
72+ ensure_templates_available () {
73+ if [[ -f " ${TEMPLATE_DIR} /composer.json.tpl" ]]; then
74+ return
75+ fi
76+
77+ # Fallback for standalone execution (e.g., script piped/downloaded without repo layout).
78+ local fallback_dir=" ${SCRIPT_DIR} /.psfs-templates/project"
79+ download_file " ${REPO_RAW_BASE} /templates/project/composer.json.tpl" " ${fallback_dir} /composer.json.tpl"
80+ download_file " ${REPO_RAW_BASE} /templates/project/docker-compose.yml.tpl" " ${fallback_dir} /docker-compose.yml.tpl"
81+ download_file " ${REPO_RAW_BASE} /templates/project/.env.example.tpl" " ${fallback_dir} /.env.example.tpl"
82+ download_file " ${REPO_RAW_BASE} /templates/project/docker/php.ini.tpl" " ${fallback_dir} /docker/php.ini.tpl"
83+ TEMPLATE_DIR=" ${fallback_dir} "
84+ }
85+
5486escape_sed () {
5587 printf ' %s' " $1 " | sed -e ' s/[\/&]/\\&/g'
5688}
@@ -239,7 +271,7 @@ validate_inputs() {
239271}
240272
241273init_project_tree () {
242- mkdir -p " ${TARGET_PATH} " /{config,html,modules ,cache,logs,locale}
274+ mkdir -p " ${TARGET_PATH} " /{config,html,src ,cache,logs,locale}
243275 if [[ " ${RUNTIME} " == " docker" ]]; then
244276 mkdir -p " ${TARGET_PATH} /docker"
245277 fi
@@ -340,6 +372,7 @@ main() {
340372 derive_defaults
341373 prompt_project_meta
342374 validate_inputs
375+ ensure_templates_available
343376 init_project_tree
344377 render_composer_json
345378 render_docker_bundle
0 commit comments