[FIX] npm installation

- install npm locally instead of globaly
This commit is contained in:
Mathieu Benoit 2023-09-11 00:09:21 -04:00
parent 91ab1e1a8e
commit 6e57b2584a
10 changed files with 120 additions and 66 deletions

2
.gitignore vendored
View file

@ -24,3 +24,5 @@ get-poetry.py
artifacts artifacts
wkhtmltox* wkhtmltox*
cache cache
node_modules

View file

@ -10,3 +10,4 @@ doc/odoo_documentation-user
artifacts artifacts
cache cache
htmlcov htmlcov
node_modules

66
package-lock.json generated Normal file
View file

@ -0,0 +1,66 @@
{
"name": "erplibre",
"version": "1.5.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "erplibre",
"version": "1.5.0",
"license": "AGPLv3",
"devDependencies": {
"@prettier/plugin-xml": "==2.2.0",
"prettier": "==2.8.8"
}
},
"node_modules/@prettier/plugin-xml": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/@prettier/plugin-xml/-/plugin-xml-2.2.0.tgz",
"integrity": "sha512-UWRmygBsyj4bVXvDiqSccwT1kmsorcwQwaIy30yVh8T+Gspx4OlC0shX1y+ZuwXZvgnafmpRYKks0bAu9urJew==",
"dev": true,
"dependencies": {
"@xml-tools/parser": "^1.0.11",
"prettier": ">=2.4.0"
}
},
"node_modules/@xml-tools/parser": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@xml-tools/parser/-/parser-1.0.11.tgz",
"integrity": "sha512-aKqQ077XnR+oQtHJlrAflaZaL7qZsulWc/i/ZEooar5JiWj1eLt0+Wg28cpa+XLney107wXqneC+oG1IZvxkTA==",
"dev": true,
"dependencies": {
"chevrotain": "7.1.1"
}
},
"node_modules/chevrotain": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/chevrotain/-/chevrotain-7.1.1.tgz",
"integrity": "sha512-wy3mC1x4ye+O+QkEinVJkPf5u2vsrDIYW9G7ZuwFl6v/Yu0LwUuT2POsb+NUWApebyxfkQq6+yDfRExbnI5rcw==",
"dev": true,
"dependencies": {
"regexp-to-ast": "0.5.0"
}
},
"node_modules/prettier": {
"version": "2.8.8",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
},
"engines": {
"node": ">=10.13.0"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/regexp-to-ast": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/regexp-to-ast/-/regexp-to-ast-0.5.0.tgz",
"integrity": "sha512-tlbJqcMHnPKI9zSrystikWKwHkBqu2a/Sgw01h3zFjvYrMxEDYHzzoMZnUrbIfpTFEsoRnnviOXNCzFiSc54Qw==",
"dev": true
}
}
}

11
package.json Normal file
View file

@ -0,0 +1,11 @@
{
"name": "erplibre",
"description": "Easy installation of Odoo",
"version": "1.5.0",
"license": "AGPLv3",
"homepage": "https://erplibre.ca",
"devDependencies": {
"@prettier/plugin-xml": "==2.2.0",
"prettier": "==2.8.8"
}
}

View file

@ -35,8 +35,7 @@ echo "\n---- Installing nodeJS NPM and rtlcss for LTR support ----"
brew install nodejs npm openssl brew install nodejs npm openssl
sudo npm install -g rtlcss sudo npm install -g rtlcss
sudo npm install -g less sudo npm install -g less
sudo npm install -g prettier npm install
sudo npm install -g prettier @prettier/plugin-xml
echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

View file

@ -89,43 +89,22 @@ if [[ $retVal -ne 0 ]]; then
fi fi
echo -e "\n---- Installing nodeJS NPM and rtlcss for LTR support ----" echo -e "\n---- Installing nodeJS NPM and rtlcss for LTR support ----"
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
if [ "18.04" == "${UBUNTU_VERSION}" ]; then if [ "18.04" == "${UBUNTU_VERSION}" ]; then
sudo apt remove nodeJS npm sudo apt remove nodeJS npm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash NODE_MAJOR=16
chmod +x ~/.nvm/nvm.sh
. $NVM_DIR/nvm.sh && nvm install 16.15.1
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "nvm installation error."
exit 1
fi
source ~/.bashrc
npm install npm@latest -g
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "npm install npm lastest installation error."
exit 1
fi
npm install -g rtlcss
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "npm install rtlcss installation error."
exit 1
fi
npm install -g less
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "npm install less installation error."
exit 1
fi
else else
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash - NODE_MAJOR=20
sudo apt-get install -y nodejs
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "apt-get nodejs installation error."
exit 1
fi fi
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt-get update
sudo apt-get install nodejs -y
sudo npm install npm@latest -g sudo npm install npm@latest -g
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
@ -144,19 +123,12 @@ else
echo "npm install less installation error." echo "npm install less installation error."
exit 1 exit 1
fi fi
fi
echo -e "\n---- Test tool ----" echo -e "\n---- Test tool ----"
sudo npm install -g prettier npm install
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "npm install prettier installation error." echo "npm install prettier + plugin-xml installation error."
exit 1
fi
sudo npm install -g prettier @prettier/plugin-xml
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "npm install prettier plugin-xml installation error."
exit 1 exit 1
fi fi

View file

@ -75,6 +75,7 @@ if [[ ! -d ${VENV_PATH} ]]; then
exit 1 exit 1
fi fi
fi fi
source ./.venv/bin/activate
#if [[ ! -d "${POETRY_PATH}" ]]; then #if [[ ! -d "${POETRY_PATH}" ]]; then
# # Delete directory ~/.poetry and .venv to force update to new version # # Delete directory ~/.poetry and .venv to force update to new version

View file

@ -17,6 +17,8 @@ if [[ $retVal -ne 0 ]]; then
exit 1 exit 1
fi fi
npm install
## Install maintainer-tools ## Install maintainer-tools
#cd script/OCA_maintainer-tools || exit #cd script/OCA_maintainer-tools || exit
## virtualenv is not installed by default ## virtualenv is not installed by default

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This will format all js,css,html # This will format all js,css,html
# argument 1: directory or file to format # argument 1: directory or file to format
prettier --write $@ ./node_modules/.bin/prettier --tab-width 4 --print-width 120 --no-bracket-spacing --write "$@"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error prettier format" echo "Error prettier format"

View file

@ -4,14 +4,14 @@
STR_ARG="'$*'" STR_ARG="'$*'"
if [[ "${STR_ARG}" = *"/data/"* ]]; then if [[ "${STR_ARG}" = *"/data/"* ]]; then
# Need to keep width with data, else add corrupted string data # Need to keep width with data, else add corrupted string data
prettier --xml-whitespace-sensitivity "ignore" --prose-wrap always --tab-width 4 --no-bracket-spacing --print-width 999999999 --write $@ ./node_modules/.bin/prettier --plugin=@prettier/plugin-xml --xml-whitespace-sensitivity "ignore" --prose-wrap always --tab-width 4 --no-bracket-spacing --print-width 999999999 --write "$@"
else else
prettier --xml-whitespace-sensitivity "ignore" --prose-wrap always --tab-width 4 --no-bracket-spacing --print-width 120 --write $@ ./node_modules/.bin/prettier --plugin=@prettier/plugin-xml --xml-whitespace-sensitivity "ignore" --prose-wrap always --tab-width 4 --no-bracket-spacing --print-width 120 --write "$@"
# strict xml-whitespace-sensitivity will keep space alignement # strict xml-whitespace-sensitivity will keep space alignement
#prettier --xml-whitespace-sensitivity "strict" --prose-wrap always --tab-width 4 --no-bracket-spacing --print-width 120 --write $@ #prettier --xml-whitespace-sensitivity "strict" --prose-wrap always --tab-width 4 --no-bracket-spacing --print-width 120 --write $@
fi fi
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error prettier format" echo "Error prettier-xml format"
exit 1 exit 1
fi fi