add use-git for yunohost-admin-vue

This commit is contained in:
Axolotle 2020-11-05 13:08:35 +01:00
parent 2105bb4b46
commit 094c4861eb

62
ynh-dev
View file

@ -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 - <<EOF
import os, yaml
setting_file = "/etc/yunohost/firewall.yml"
assert os.path.exists(setting_file), "Firewall yaml file %s does not exists ?" % setting_file
with open(setting_file) as f:
settings = yaml.load(f)
if 8080 not in settings["ipv4"]["TCP"]:
settings["ipv4"]["TCP"].append(8080)
with open(setting_file, "w") as f:
yaml.safe_dump(settings, f, default_flow_style=False)
EOF
fi
# Install npm if needed
if [[ ! -e node_modules/@vue/cli-service/bin/vue-cli-service.js ]]
then
info "Installing dependencies to develop in yunohost-admin ..."
apt install nodejs npm -y
npm install -g npm@latest
fi
# Install dependencies
npm ci --no-bin-links
success "Now using Git repository for yunohost-admin"
cd /ynh-dev/yunohost-admin-vue/app/
npm run serve
;;
esac
done