From 6e57b2584a8ede848e717a9c11d7a8ea4e5ea071 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Mon, 11 Sep 2023 00:09:21 -0400 Subject: [PATCH] [FIX] npm installation - install npm locally instead of globaly --- .gitignore | 2 + conf/pycharm_exclude_folder.txt | 1 + package-lock.json | 66 +++++++++++++++ package.json | 11 +++ script/install/install_OSX_dependency.sh | 3 +- script/install/install_debian_dependency.sh | 92 +++++++-------------- script/install/install_locally.sh | 1 + script/install/install_locally_dev.sh | 2 + script/maintenance/prettier.sh | 2 +- script/maintenance/prettier_xml.sh | 6 +- 10 files changed, 120 insertions(+), 66 deletions(-) create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.gitignore b/.gitignore index c484315..5ea8a44 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ get-poetry.py artifacts wkhtmltox* cache + +node_modules diff --git a/conf/pycharm_exclude_folder.txt b/conf/pycharm_exclude_folder.txt index b0e4414..bd0fe12 100644 --- a/conf/pycharm_exclude_folder.txt +++ b/conf/pycharm_exclude_folder.txt @@ -10,3 +10,4 @@ doc/odoo_documentation-user artifacts cache htmlcov +node_modules diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..c3e6e97 --- /dev/null +++ b/package-lock.json @@ -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 + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..fef8ce6 --- /dev/null +++ b/package.json @@ -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" + } +} diff --git a/script/install/install_OSX_dependency.sh b/script/install/install_OSX_dependency.sh index f82bed9..1728a08 100755 --- a/script/install/install_OSX_dependency.sh +++ b/script/install/install_OSX_dependency.sh @@ -35,8 +35,7 @@ echo "\n---- Installing nodeJS NPM and rtlcss for LTR support ----" brew install nodejs npm openssl sudo npm install -g rtlcss sudo npm install -g less -sudo npm install -g prettier -sudo npm install -g prettier @prettier/plugin-xml +npm install echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc diff --git a/script/install/install_debian_dependency.sh b/script/install/install_debian_dependency.sh index d297c5a..aaac1f0 100755 --- a/script/install/install_debian_dependency.sh +++ b/script/install/install_debian_dependency.sh @@ -89,74 +89,46 @@ if [[ $retVal -ne 0 ]]; then fi 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 sudo apt remove nodeJS npm - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash - 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 + NODE_MAJOR=16 else - curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash - - sudo apt-get install -y nodejs - retVal=$? - if [[ $retVal -ne 0 ]]; then - echo "apt-get nodejs installation error." - exit 1 - fi - sudo npm install npm@latest -g - retVal=$? - if [[ $retVal -ne 0 ]]; then - echo "npm install npm lastest installation error." - exit 1 - fi - sudo npm install -g rtlcss - retVal=$? - if [[ $retVal -ne 0 ]]; then - echo "npm install rtlcss installation error." - exit 1 - fi - sudo npm install -g less - retVal=$? - if [[ $retVal -ne 0 ]]; then - echo "npm install less installation error." - exit 1 - fi + NODE_MAJOR=20 +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 +retVal=$? +if [[ $retVal -ne 0 ]]; then + echo "npm install npm lastest installation error." + exit 1 +fi +sudo npm install -g rtlcss +retVal=$? +if [[ $retVal -ne 0 ]]; then + echo "npm install rtlcss installation error." + exit 1 +fi +sudo npm install -g less +retVal=$? +if [[ $retVal -ne 0 ]]; then + echo "npm install less installation error." + exit 1 fi echo -e "\n---- Test tool ----" -sudo npm install -g prettier +npm install retVal=$? if [[ $retVal -ne 0 ]]; then - echo "npm install prettier 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." + echo "npm install prettier + plugin-xml installation error." exit 1 fi diff --git a/script/install/install_locally.sh b/script/install/install_locally.sh index 0e415d0..79275fb 100755 --- a/script/install/install_locally.sh +++ b/script/install/install_locally.sh @@ -75,6 +75,7 @@ if [[ ! -d ${VENV_PATH} ]]; then exit 1 fi fi +source ./.venv/bin/activate #if [[ ! -d "${POETRY_PATH}" ]]; then # # Delete directory ~/.poetry and .venv to force update to new version diff --git a/script/install/install_locally_dev.sh b/script/install/install_locally_dev.sh index 98dfbcb..f7deef6 100755 --- a/script/install/install_locally_dev.sh +++ b/script/install/install_locally_dev.sh @@ -17,6 +17,8 @@ if [[ $retVal -ne 0 ]]; then exit 1 fi +npm install + ## Install maintainer-tools #cd script/OCA_maintainer-tools || exit ## virtualenv is not installed by default diff --git a/script/maintenance/prettier.sh b/script/maintenance/prettier.sh index b7f22c3..4494ecc 100755 --- a/script/maintenance/prettier.sh +++ b/script/maintenance/prettier.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # This will format all js,css,html # argument 1: directory or file to format -prettier --write $@ +./node_modules/.bin/prettier --tab-width 4 --print-width 120 --no-bracket-spacing --write "$@" retVal=$? if [[ $retVal -ne 0 ]]; then echo "Error prettier format" diff --git a/script/maintenance/prettier_xml.sh b/script/maintenance/prettier_xml.sh index 2b0890f..853484e 100755 --- a/script/maintenance/prettier_xml.sh +++ b/script/maintenance/prettier_xml.sh @@ -4,14 +4,14 @@ STR_ARG="'$*'" if [[ "${STR_ARG}" = *"/data/"* ]]; then # 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 - 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 #prettier --xml-whitespace-sensitivity "strict" --prose-wrap always --tab-width 4 --no-bracket-spacing --print-width 120 --write $@ fi retVal=$? if [[ $retVal -ne 0 ]]; then - echo "Error prettier format" + echo "Error prettier-xml format" exit 1 fi