#!/bin/bash # Variables et fonctions communes aux scripts du package veille-ia_ynh. # Normalise le chemin YNH pour paths.base de SvelteKit ("/" -> "" ; sinon "/veille"). veille_ia_base_path() { if [ "$path" = "/" ]; then echo "" else echo "$path" fi } # Installe les dépendances, build l'app (avec le bon sous-chemin), puis élague # les devDependencies pour ne garder que le runtime. veille_ia_build_app() { pushd "$install_dir/app" ynh_hide_warnings ynh_exec_as_app npm ci ynh_hide_warnings ynh_exec_as_app env BASE_PATH="$(veille_ia_base_path)" npm run build ynh_hide_warnings ynh_exec_as_app npm prune --omit=dev popd } # (Re)génère le fichier d'environnement applicatif et verrouille ses droits. veille_ia_write_env() { ynh_config_add --template="env" --destination="$install_dir/app/.env" chmod 400 "$install_dir/app/.env" chown "$app:$app" "$install_dir/app/.env" }