fix: readd node v14 dl for bullseye and use yarn or yarnpkg depending on distro

This commit is contained in:
axolotle 2024-03-02 16:58:27 +01:00
parent c08c9a948b
commit eeb9e123a1

40
ynh-dev
View file

@ -133,17 +133,41 @@ function prepare_cache_and_deps() {
create_sym_link "$DEV_PATH/package.json" "$CACHE_PATH/package.json"
create_sym_link "$DEV_PATH/yarn.lock" "$CACHE_PATH/yarn.lock"
# Vite require node v14 to parse modern syntax
local DISTRO="$(lsb_release -s -c)"
local YARN=$([ "$DISTRO" == "bullseye" ] && echo "yarnpkg" || echo "yarn")
if [ "$DISTRO" == "bullseye" ]
then
if [[ ! $(node -v) == v14* ]]
then
info "Installing node v14..."
KEYRING=/usr/share/keyrings/nodesource.gpg
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | sudo tee "$KEYRING" >/dev/null
gpg --no-default-keyring --keyring "$KEYRING" --list-keys
VERSION=node_14.x
echo "deb [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee /etc/apt/sources.list.d/nodesource.list
apt update
apt install nodejs -y
# to return to nodejs debian version
# apt purge nodejs && rm -r /etc/apt/sources.list.d/nodesource.list && apt install nodejs
export NODE_PATH=/usr/lib/nodejs:/usr/share/nodejs
fi
fi
# install yarn if not already
if [[ $(dpkg-query -W -f='${Status}' yarn 2>/dev/null | grep -c "ok installed") -eq 0 ]];
if [[ $(dpkg-query -W -f='${Status}' "$YARN" 2>/dev/null | grep -c "ok installed") -eq 0 ]];
then
info "Installing yarn…"
apt install yarn
apt update
apt install "$YARN"
fi
pushd "$CACHE_PATH"
# Install dependencies with yarn forced to lock file versions (equivalent to `npm ci`)
info "Installing dependencies ... (this may take a while)"
yarn install --frozen-lockfile
"$YARN" install --frozen-lockfile
popd
}
@ -337,9 +361,12 @@ with open(setting_file) as f:
EOF
fi
local DISTRO="$(lsb_release -s -c)"
local YARN=$([ "$DISTRO" == "bullseye" ] && echo "yarnpkg" || echo "yarn")
cd "$DEV_PATH"
info "Now running dev server"
yarn dev --host
"$YARN" dev --host
;;
yunohost-admin-build)
if [[ ! -e "/usr/share/yunohost/admin-bkp" ]]
@ -348,8 +375,11 @@ EOF
mv /usr/share/yunohost/admin /usr/share/yunohost/admin-bkp
fi
local DISTRO="$(lsb_release -s -c)"
local YARN=$([ "$DISTRO" == "bullseye" ] && echo "yarnpkg" || echo "yarn")
cd /ynh-dev/yunohost-admin/app
yarn build
"$YARN" build
create_sym_link "/ynh-dev/yunohost-admin/app/dist" "/usr/share/yunohost/admin"