From d5f8713882b949610d02708e02488cec31256d04 Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Wed, 14 Mar 2018 11:11:55 +0000 Subject: [PATCH] mgr/dashboard: remove node/npm system installation Node and npm are now being installed in a virtualenv, removing the need of having it installed in the system or as a node dependency. Now, if you want to use npm, you just need to activate the virtualenv created on 'build/src/pybind/mgr/dashboard/node-env', and then you can execute the same commands as you did before. Signed-off-by: Tiago Melo --- install-deps.sh | 69 ------------------- make-dist | 7 ++ src/pybind/mgr/dashboard/CMakeLists.txt | 33 +++++---- src/pybind/mgr/dashboard/HACKING.rst | 22 +++++- .../mgr/dashboard/frontend/package.json | 1 - .../mgr/dashboard/run-frontend-unittests.sh | 4 ++ 6 files changed, 51 insertions(+), 85 deletions(-) diff --git a/install-deps.sh b/install-deps.sh index c9d185b20471b..fc5dc089e792c 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -107,68 +107,6 @@ EOF fi } -function ensure_min_npm_version { - local install_npm_pkg_cmd=$1 - - if [ "$ARCH" = "aarch64" ]; then - # we don't support dashboard frontend development in arm64 architecture - return 0 - fi - - if ! type npm > /dev/null 2>&1; then - $SUDO $install_npm_pkg_cmd - fi - - NODE_VER=`node -v` - NODE_VER_MAJOR=`node -v | sed 's/v\(\w\+\).*/\1/g'` - NODE_VER_MINOR=`node -v | sed 's/v\w\+\.\(\w\+\).*/\1/g'` - - # The minimum node version required is 4.8.0 so that we can use yarn below - UPDATE_NODE=false - if [ $NODE_VER_MAJOR -lt 4 ]; then - UPDATE_NODE=true - elif [ $NODE_VER_MAJOR -eq 4 ] && [ $NODE_VER_MINOR -lt 8 ]; then - UPDATE_NODE=true - fi - if $UPDATE_NODE; then - $SUDO npm install -g n - # installs nodejs version 4.8.0 - $SUDO n 4.8.0 - $SUDO npm uninstall -g n - hash -d node > /dev/null 2>&1 || true - fi - - NPM_VER=`npm -v` - NPM_VER_MAJOR=`npm -v | sed 's/\(\w\+\).*/\1/g'` - - # The minimum npm version required is 5.0.0 so that we can install and use - # a local nodejs installation (required by the dashboard angular2 frontend) - if [ $NPM_VER_MAJOR -lt 5 ]; then - $SUDO npm install -g yarn - $SUDO yarn global add npm@^5.0.0 # install npm version 5.0.0 or later - fi - hash -d npm > /dev/null 2>&1 || true - - NEW_NODE_VER=`node -v` - NEW_NPM_VER=`npm -v` - if [ ! "$NODE_VER" = "$NEW_NODE_VER" ]; then -cat <`_ and requires the Prerequisites ~~~~~~~~~~~~~ -Run ``npm install`` in directory ``src/pybind/mgr/dashboard/frontend`` to -install the required packages locally. + * Node 6.9.0 or higher + * NPM 3 or higher + +nodeenv: + During Ceph's build we create a virtualenv with ``node`` and ``npm`` + installed, which can be used as an alternative to installing node/npm in your + system. + + If you want to use the node installed in the virtualenv you just need to + activate the virtualenv before you run any npm commands. To activate it run + ``. build/src/pybind/mgr/dashboard/node-env/bin/activate``. -.. note:: + Once you finish, you can simply run ``deactivate`` and exit the virtualenv. +Angular CLI: If you do not have the `Angular CLI `_ installed globally, then you need to execute ``ng`` commands with an additional ``npm run`` before it. +Package installation +~~~~~~~~~~~~~~~~~~~~ + +Run ``npm install`` in directory ``src/pybind/mgr/dashboard/frontend`` to +install the required packages locally. + Setting up a Development Server ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/pybind/mgr/dashboard/frontend/package.json b/src/pybind/mgr/dashboard/frontend/package.json index e173870909fbe..245d980a30593 100644 --- a/src/pybind/mgr/dashboard/frontend/package.json +++ b/src/pybind/mgr/dashboard/frontend/package.json @@ -55,7 +55,6 @@ "karma-jasmine-html-reporter": "^0.2.2", "karma-junit-reporter": "^1.2.0", "karma-phantomjs-launcher": "^1.0.4", - "node": "^8.9.4", "protractor": "~5.1.2", "ts-node": "~3.2.0", "tslint": "~5.9.1", diff --git a/src/pybind/mgr/dashboard/run-frontend-unittests.sh b/src/pybind/mgr/dashboard/run-frontend-unittests.sh index f2a50c4ac69de..20303e20edb15 100755 --- a/src/pybind/mgr/dashboard/run-frontend-unittests.sh +++ b/src/pybind/mgr/dashboard/run-frontend-unittests.sh @@ -4,6 +4,10 @@ set -e cd $CEPH_ROOT/src/pybind/mgr/dashboard/frontend +. $CEPH_ROOT/build/src/pybind/mgr/dashboard/node-env/bin/activate + npm run build -- --prod npm run test -- --browsers PhantomJS --watch=false npm run lint + +deactivate -- 2.39.5