From 094c4861ebb78f493eb3b5660682939ca1cbb6c6 Mon Sep 17 00:00:00 2001 From: Axolotle Date: Thu, 5 Nov 2020 13:08:35 +0100 Subject: [PATCH 1/3] add use-git for yunohost-admin-vue --- ynh-dev | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/ynh-dev b/ynh-dev index a690ed4..f239518 100755 --- a/ynh-dev +++ b/ynh-dev @@ -166,6 +166,13 @@ function attach_ynhdev() ln -s /var/cache/ynh-dev/yunohost-admin/dist ./yunohost-admin/src/ fi + # Setup symlinks for future .env and nodes_modules/ for yunohost-admin-vue + if [[ ! -L ./yunohost-admin-vue/app/.env ]] + then + ln -s /var/cache/ynh-dev/yunohost-admin/.env ./yunohost-admin-vue/app + ln -s /var/cache/ynh-dev/yunohost-admin/node_modules ./yunohost-admin-vue/app/ + fi + check_lxd_setup local BOX=${1:-ynh-dev-buster} sudo lxc start $BOX 2>/dev/null || true @@ -233,7 +240,7 @@ function use_git() create_sym_link "/ynh-dev/yunohost/bin/yunoprompt" "/usr/bin/yunoprompt" create_sym_link "/ynh-dev/yunohost/bin/yunopaste" "/usr/bin/yunopaste" create_sym_link "/ynh-dev/yunohost/sbin/yunohost-reset-ldap-password" "/usr/sbin/yunohost-reset-ldap-password" - + # data create_sym_link "/ynh-dev/yunohost/data/bash-completion.d/yunohost" "/etc/bash_completion.d/yunohost" create_sym_link "/ynh-dev/yunohost/data/actionsmap/yunohost.yml" "/usr/share/moulinette/actionsmap/yunohost.yml" @@ -310,6 +317,59 @@ function use_git() warn "-------------------------------------------------------- " su ynhdev -c "./node_modules/gulp/bin/gulp.js watch --dev" + ;; + yunohost-admin-vue) + getent passwd ynhdev > /dev/null + if [ $? -eq 2 ]; then + useradd ynhdev + fi + + mkdir -p /var/cache/ynh-dev/yunohost-admin/ + # mkdir -p /var/cache/ynh-dev/yunohost-admin/dist + chown -R ynhdev /var/cache/ynh-dev/yunohost-admin/ + create_sym_link "/ynh-dev/yunohost-admin-vue/app/package.json" "/var/cache/ynh-dev/yunohost-admin/package.json" + create_sym_link "/ynh-dev/yunohost-admin-vue/app/package-lock.json" "/var/cache/ynh-dev/yunohost-admin/package-lock.json" + # create_sym_link "/ynh-dev/yunohost-admin-vue/app" "/usr/share/yunohost/admin" + + cd /var/cache/ynh-dev/yunohost-admin/ + # Create .env file with the vm ip + # Will be used by webpack-dev-server to proxy api requests. + if [[ ! -e .env ]] + then + info "Creating .env file" + IP=$(hostname -I | tr ' ' '\n' | grep "\.") + echo "VUE_APP_IP=$IP" > .env + fi + + # Allow port 8080 in config file or else the dev server will stop working after postinstall + if [[ ! -e /etc/yunohost/installed ]] + then + python2.7 - < Date: Sat, 16 Jan 2021 17:38:50 +0100 Subject: [PATCH 2/3] fix use-git vuejs --- ynh-dev | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ynh-dev b/ynh-dev index f239518..c75995f 100755 --- a/ynh-dev +++ b/ynh-dev @@ -329,6 +329,13 @@ function use_git() chown -R ynhdev /var/cache/ynh-dev/yunohost-admin/ create_sym_link "/ynh-dev/yunohost-admin-vue/app/package.json" "/var/cache/ynh-dev/yunohost-admin/package.json" create_sym_link "/ynh-dev/yunohost-admin-vue/app/package-lock.json" "/var/cache/ynh-dev/yunohost-admin/package-lock.json" + mv "/etc/nginx/conf.d/yunohost_admin.conf.inc" "/etc/nginx/conf.d/yunohost_admin.conf.inc.bkp" + trap 'on_exit' INT + on_exit() + { + mv "/etc/nginx/conf.d/yunohost_admin.conf.inc.bkp" "/etc/nginx/conf.d/yunohost_admin.conf.inc" + systemctl reload nginx + } # create_sym_link "/ynh-dev/yunohost-admin-vue/app" "/usr/share/yunohost/admin" cd /var/cache/ynh-dev/yunohost-admin/ @@ -368,6 +375,24 @@ EOF # Install dependencies npm ci --no-bin-links success "Now using Git repository for yunohost-admin" + cat < /etc/nginx/conf.d/yunohost_admin.conf.inc +location /yunohost/admin { + proxy_pass https://localhost:8080/yunohost/admin; + proxy_redirect off; + proxy_set_header Host \$host; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header X-Forwarded-Proto \$scheme; + proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host \$server_name; + proxy_set_header X-Forwarded-Port \$server_port; + + proxy_http_version 1.1; + proxy_set_header Upgrade \$http_upgrade; + proxy_set_header Connection "upgrade"; +} +EOF + + systemctl reload nginx cd /ynh-dev/yunohost-admin-vue/app/ npm run serve ;; From bfb48c25f7337b7cf15ac7ff5322892bb8c8b68f Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 19 Jan 2021 23:36:19 +0100 Subject: [PATCH 3/3] remove legacy yunohost-admin use-git --- ynh-dev | 55 ++++--------------------------------------------------- 1 file changed, 4 insertions(+), 51 deletions(-) diff --git a/ynh-dev b/ynh-dev index 8243005..f34e192 100755 --- a/ynh-dev +++ b/ynh-dev @@ -226,7 +226,7 @@ function use_git() PACKAGES=('moulinette' 'ssowat' 'yunohost' 'yunohost-admin') fi - for i in ${!PACKAGES[@]}; + for i in "${!PACKAGES[@]}"; do case ${PACKAGES[i]} in ssowat) @@ -282,54 +282,6 @@ function use_git() useradd ynhdev fi - mkdir -p /var/cache/ynh-dev/yunohost-admin/ - mkdir -p /var/cache/ynh-dev/yunohost-admin/dist - chown -R ynhdev /var/cache/ynh-dev/yunohost-admin/ - create_sym_link "/ynh-dev/yunohost-admin/src/package.json" "/var/cache/ynh-dev/yunohost-admin/package.json" - create_sym_link "/ynh-dev/yunohost-admin/src/package-lock.json" "/var/cache/ynh-dev/yunohost-admin/package-lock.json" - create_sym_link "/ynh-dev/yunohost-admin/src" "/usr/share/yunohost/admin" - - if [ ! -e /ynh-dev/yunohost-admin/src/dist ] - then - echo "If npm install fails to create the dist and node_modules folder, maybe you need to run the following *in the host!* : " - echo " " - echo "cd /your/dev/env/yunohost-admin/src/" - echo "ln -s /var/cache/ynh-dev/yunohost-admin/dist ./dist" - echo "ln -s /var/cache/ynh-dev/yunohost-admin/node_modules ./node_modules" - echo " " - fi - - # Install npm dependencies if needed - cd /var/cache/ynh-dev/yunohost-admin/ - if [ ! -e node_modules/gulp/bin/gulp.js ] - then - info "Installing dependencies to develop in yunohost-admin ..." - apt install nodejs npm -y - npm install -g npm@latest - fi - - npm ci --no-bin-links - - success "Now using Git repository for yunohost-admin" - - cd /ynh-dev/yunohost-admin/src - su ynhdev -c "./node_modules/gulp/bin/gulp.js build --dev" - warn "-------------------------------------------------------- " - warn "Launching gulp ... " - warn "NB : This command will keep running and watch for changes" - warn " in the folder /ynh-dev/yunohost-admin/src, such that you" - warn "don't need to re-run npm yourself everytime you change " - warn "something ! " - warn "-------------------------------------------------------- " - su ynhdev -c "./node_modules/gulp/bin/gulp.js watch --dev" - - ;; - yunohost-admin-vue) - getent passwd ynhdev > /dev/null - if [ $? -eq 2 ]; then - useradd ynhdev - fi - mkdir -p /var/cache/ynh-dev/yunohost-admin/ # mkdir -p /var/cache/ynh-dev/yunohost-admin/dist chown -R ynhdev /var/cache/ynh-dev/yunohost-admin/ @@ -401,6 +353,7 @@ EOF systemctl reload nginx cd /ynh-dev/yunohost-admin-vue/app/ npm run serve + ;; *) error "Invalid package '${PACKAGES[i]}': correct arguments are 'yunohost', 'ssowat', 'moulinette', 'yunohost-admin' or nothing for all" ;; @@ -412,7 +365,7 @@ function run_tests() { assert_inside_vm local PACKAGES="$@" - for PACKAGE in "$PACKAGES"; + for PACKAGE in $PACKAGES; do TEST_FUNCTION=$(echo "$PACKAGE" | tr '/:' ' ' | awk '{print $3}') TEST_MODULE=$(echo "$PACKAGE" | tr '/:' ' ' | awk '{print $2}') @@ -463,4 +416,4 @@ function run_tests() done } -main $@ +main "$@"