From 19a67716252376729cff23f63818c1c797bc3b63 Mon Sep 17 00:00:00 2001 From: Benjamin Lupton Date: Sat, 14 Sep 2019 14:41:55 +1000 Subject: [PATCH] ref #4 add node-npm-install node-upgrade-npm --- README.md | 35 +++++++++++++++++++++++++---------- scripts/deploy-custom.bash | 6 +++--- scripts/deploy-git.bash | 6 +++--- scripts/deploy-now.bash | 6 +++--- scripts/node-install.bash | 4 ++-- scripts/node-latest-npm.bash | 4 ++-- scripts/node-npm-install.bash | 23 +++++++++++++++++++++++ scripts/node-publish.bash | 6 +++--- scripts/node-upgrade-npm.bash | 22 ++++++++++++++++++++++ scripts/node-verify.bash | 4 ++-- scripts/surge.bash | 6 +++--- scripts/travis-another.bash | 6 +++--- 12 files changed, 94 insertions(+), 34 deletions(-) create mode 100644 scripts/node-npm-install.bash create mode 100644 scripts/node-upgrade-npm.bash diff --git a/README.md b/README.md index 6733466..0aa1528 100644 --- a/README.md +++ b/README.md @@ -29,17 +29,12 @@ sudo: false language: node_js os: - linux -before_install: - - 'case "${TRAVIS_NODE_VERSION}" in 0.*) export NPM_CONFIG_STRICT_SSL=false ;; esac' - - 'nvm install-latest-npm' -install: - - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' node_js: - - '11' # current + - '12' # current release - '10' # active lts - - '8' # active lts - - '6' # active lts - - '4' # end of life lts + - '8' # maintenance lts + - '6' # end of life + - '4' # end of life - '0.12' # end of life - '0.10' # end of life - '0.8' # end of life @@ -47,6 +42,8 @@ node_js: matrix: fast_finish: true allow_failures: + - node_js: '6' + - node_js: '4' - node_js: '0.12' - node_js: '0.10' - node_js: '0.8' @@ -62,6 +59,8 @@ cache: We provide many premade scripts to accelerate your Travis CI usage. They are available within the [`scripts` directory](https://github.com/bevry/awesome-travis/tree/master/scripts) directory of this repository. Click on each script to see available configuration, and installation instructions. +### Listing + #### [`deploy-custom`](https://github.com/bevry/awesome-travis/blob/master/scripts/deploy-custom.bash) If the tests succeed on the specified `DEPLOY_BRANCH`, then prepare git for deployment, and then run the `DEPLOY_COMMAND`. @@ -78,13 +77,29 @@ If the tests succeed on the specified `DEPLOY_BRANCH`, then deploy with https:// Use the `DESIRED_NODE_VERSION` (defaults to the latest LTS node version) to install dependencies using `SETUP_COMMAND` (defaults to `npm install`). +This is an alternative to the `node-npm-install` script. + +#### [`node-npm-install`](https://github.com/bevry/awesome-travis/blob/master/scripts/node-npm-install.bash) + +Because the latest npm version that node 0.6 and 0.9 support, doesn't support scoped modules, so it uses node 0.8 to install npm packages and then switches back. + +This is an alternative to the `node-install` script. + #### [`node-publish`](https://github.com/bevry/awesome-travis/blob/master/scripts/node-publish.bash) Use the `DESIRED_NODE_VERSION` (defaults to the latest LTS node version) to login with npm and run `npm publish`. +#### [`node-upgrade-npm`](https://github.com/bevry/awesome-travis/blob/master/scripts/node-upgrade-npm.bash) + +Installs the latest supported version of npm for the current node version, using nvm's `install-latest-npm` command. + +This is an alternative to the `node-latest-npm` script. + #### [`node-latest-npm`](https://github.com/bevry/awesome-travis/blob/master/scripts/node-latest-npm.bash) -Ensure that the npm version is the latest npm version released. +Installs the latest npm version, using npm's `update` command. + +This is an alternative to the `node-upgrade-npm` script. #### [`node-verify`](https://github.com/bevry/awesome-travis/blob/master/scripts/node-verify.bash) diff --git a/scripts/deploy-custom.bash b/scripts/deploy-custom.bash index e33e86b..b178b03 100755 --- a/scripts/deploy-custom.bash +++ b/scripts/deploy-custom.bash @@ -3,12 +3,12 @@ set -ueE -o pipefail # If the tests succeed on the specified `DEPLOY_BRANCH`, then prepare git for deployment, and then run the `DEPLOY_COMMAND`. -# TRAVIS SCRIPT +# SCRIPT # # after_success: # - eval "$(curl -fsSL https://raw.githubusercontent.com/bevry/awesome-travis/master/scripts/deploy-custom.bash)" -# TRAVIS ENVIRONMENT VARIABLES +# CUSTOM ENVIRONMENT VARIABLES # # DEPLOY_BRANCH # The branch name that you want tested and deployed, set correctly: @@ -18,7 +18,7 @@ set -ueE -o pipefail # The command that will do the compilation and git push: # travis env set DEPLOY_COMMAND "npm run our:deploy" --public -# EXTERNAL ENVIRONMENT VARIABLES +# TRAVIS ENVIRONMENT VARIABLES # # TRAVIS_BRANCH # TRAVIS_TAG diff --git a/scripts/deploy-git.bash b/scripts/deploy-git.bash index ac62667..193be8d 100755 --- a/scripts/deploy-git.bash +++ b/scripts/deploy-git.bash @@ -4,12 +4,12 @@ set -ueE -o pipefail # If the tests succeed on the specified `DEPLOY_BRANCH`, then prepare git for deployment, and then run the `DEPLOY_COMMAND`. # The `DEPLOY_COMMAND` should be the command responsible for the compilation, git add, git commit, and git push. -# TRAVIS SCRIPT +# SCRIPT # # after_success: # - eval "$(curl -fsSL https://raw.githubusercontent.com/bevry/awesome-travis/master/scripts/deploy-git.bash)" -# TRAVIS ENVIRONMENT VARIABLES +# CUSTOM ENVIRONMENT VARIABLES # # DEPLOY_BRANCH # The branch name that you want tested and deployed, set correctly: @@ -35,7 +35,7 @@ set -ueE -o pipefail # The email that is used for the deployment commit, set to whatever: # travis env set DEPLOY_EMAIL "deployer@travis-ci.org" --public -# EXTERNAL ENVIRONMENT VARIABLES +# TRAVIS ENVIRONMENT VARIABLES # # TRAVIS_BRANCH # TRAVIS_TAG diff --git a/scripts/deploy-now.bash b/scripts/deploy-now.bash index b79569c..e2e3086 100755 --- a/scripts/deploy-now.bash +++ b/scripts/deploy-now.bash @@ -3,7 +3,7 @@ set -ueE -o pipefail # If the tests succeed on the specified `DEPLOY_BRANCH`, then deploy with https://zeit.co/now -# TRAVIS SCRIPT +# SCRIPT # # after_success: # - eval "$(curl -fsSL https://raw.githubusercontent.com/bevry/awesome-travis/master/scripts/deploy-now.bash)" @@ -13,7 +13,7 @@ set -ueE -o pipefail # You will need to make sure you have now installed as a local dependency, # using npm: npm install --save-dev now -# TRAVIS ENVIRONMENT VARIABLES +# CUSTOM ENVIRONMENT VARIABLES # # DEPLOY_BRANCH # The branch name that you want tested and deployed (defaults to `master`) @@ -27,7 +27,7 @@ set -ueE -o pipefail # Your now team, if applicable. You can fetch your teams via the `now teams list` command. # travis env set NOW_TEAM "$NOW_TEAM" --public -# EXTERNAL ENVIRONMENT VARIABLES +# TRAVIS ENVIRONMENT VARIABLES # # TRAVIS_BRANCH # TRAVIS_TAG diff --git a/scripts/node-install.bash b/scripts/node-install.bash index 78220cf..23ce1e8 100755 --- a/scripts/node-install.bash +++ b/scripts/node-install.bash @@ -3,12 +3,12 @@ set -ueE -o pipefail # Use the `DESIRED_NODE_VERSION` (defaults to the latest LTS node version) to install dependencies using `SETUP_COMMAND` (defaults to `npm install`). -# TRAVIS SCRIPT +# SCRIPT # # install: # - eval "$(curl -fsSL https://raw.githubusercontent.com/bevry/awesome-travis/master/scripts/node-install.bash)" -# TRAVIS ENVIRONMENT VARIABLES +# CUSTOM ENVIRONMENT VARIABLES # # DESIRED_NODE_VERSION # To specify a specific node version (rather tha the LTS version): diff --git a/scripts/node-latest-npm.bash b/scripts/node-latest-npm.bash index e34be1c..ab5feda 100755 --- a/scripts/node-latest-npm.bash +++ b/scripts/node-latest-npm.bash @@ -1,9 +1,9 @@ #!/bin/bash set -ueE -o pipefail -# Ensure that the npm version is the latest npm version released. +# Installs the latest npm version, using npm's `update` command. -# TRAVIS SCRIPT +# SCRIPT # # install: # - eval "$(curl -fsSL https://raw.githubusercontent.com/bevry/awesome-travis/master/scripts/node-latest-npm.bash)" diff --git a/scripts/node-npm-install.bash b/scripts/node-npm-install.bash new file mode 100644 index 0000000..ade1f29 --- /dev/null +++ b/scripts/node-npm-install.bash @@ -0,0 +1,23 @@ +#!/bin/bash +set -ueE -o pipefail + +# Because the latest npm version that node 0.6 and 0.9 support, doesn't support scoped modules, so it uses node 0.8 to install npm packages and then switches back. + +# SCRIPT +# +# install: +# - eval "$(curl -fsSL https://raw.githubusercontent.com/bevry/awesome-travis/master/scripts/node-npm-install.bash)" + +# TRAVIS ENVIRONMENT VARIABLES +# +# TRAVIS_NODE_VERSION + +if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then + set +u && nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}" && set -u +else + npm install +fi + +# while our scripts pass linting, other scripts may not +# /home/travis/.travis/job_stages: line 81: secure: unbound +set +u diff --git a/scripts/node-publish.bash b/scripts/node-publish.bash index bfcdb30..5614535 100755 --- a/scripts/node-publish.bash +++ b/scripts/node-publish.bash @@ -3,12 +3,12 @@ set -ueE -o pipefail # Use the `DESIRED_NODE_VERSION` (defaults to the latest LTS node version) to login with npm and run `npm publish`. -# TRAVIS SCRIPT +# SCRIPT # # after_success: # - eval "$(curl -fsSL https://raw.githubusercontent.com/bevry/awesome-travis/master/scripts/node-publish.bash)" -# TRAVIS ENVIRONMENT VARIABLES +# CUSTOM ENVIRONMENT VARIABLES # # DESIRED_NODE_VERSION # Specficy a specific node version (rather than the LTS version) @@ -34,7 +34,7 @@ set -ueE -o pipefail # Specify whether or not to bump the npm version # travis env set NPM_VERSION_BUMP "patch" -# EXTERNAL ENVIRONMENT VARIABLES +# TRAVIS ENVIRONMENT VARIABLES # # TRAVIS_TAG # TRAVIS_PULL_REQUEST diff --git a/scripts/node-upgrade-npm.bash b/scripts/node-upgrade-npm.bash new file mode 100644 index 0000000..1e95142 --- /dev/null +++ b/scripts/node-upgrade-npm.bash @@ -0,0 +1,22 @@ +#!/bin/bash +set -ueE -o pipefail + +# Installs the latest supported version of npm for the current node version, using nvm's `install-latest-npm` command. + +# SCRIPT +# +# before_install: +# - eval "$(curl -fsSL https://raw.githubusercontent.com/bevry/awesome-travis/master/scripts/node-upgrade-npm.bash)" + +# TRAVIS ENVIRONMENT VARIABLES +# +# TRAVIS_NODE_VERSION + +# avoid ssl errors +case "${TRAVIS_NODE_VERSION}" in 0.*) export NPM_CONFIG_STRICT_SSL=false ;; esac +# install latest npm for current node version using nvm's code to do so +set +u && nvm install-latest-npm && set -u + +# while our scripts pass linting, other scripts may not +# /home/travis/.travis/job_stages: line 81: secure: unbound +set +u diff --git a/scripts/node-verify.bash b/scripts/node-verify.bash index 11ed380..c110fc2 100755 --- a/scripts/node-verify.bash +++ b/scripts/node-verify.bash @@ -5,12 +5,12 @@ set -ueE -o pipefail # then compile and lint our project with: `npm run our:compile && npm run our:verify` # otherwise just compile our project with: `npm run our:compile` -# TRAVIS SCRIPT +# SCRIPT # # before_script: # - eval "$(curl -fsSL https://raw.githubusercontent.com/bevry/awesome-travis/master/scripts/node-verify.bash)" -# TRAVIS ENVIRONMENT VARIABLES +# CUSTOM ENVIRONMENT VARIABLES # # DESIRED_NODE_VERSION # To specify a specific node version (rather than the LTS version) diff --git a/scripts/surge.bash b/scripts/surge.bash index f5bd8c7..151efe7 100755 --- a/scripts/surge.bash +++ b/scripts/surge.bash @@ -8,7 +8,7 @@ set -ueE -o pipefail # causing a documentation recompile to always leave a dirty state - this solution avoids that, # as documentation can be git ignored. -# TRAVIS SCRIPT +# SCRIPT # # after_success: # - eval "$(curl -fsSL https://raw.githubusercontent.com/bevry/awesome-travis/master/scripts/surge.bash)" @@ -19,7 +19,7 @@ set -ueE -o pipefail # You will need to make sure you have surge installed as a local dependency, # using npm: npm install --save-dev surge -# TRAVIS ENVIRONMENT VARIABLES +# CUSTOM ENVIRONMENT VARIABLES # # DESIRED_NODE_VERSION # Specficy a specific node version (rather than the LTS version) @@ -37,7 +37,7 @@ set -ueE -o pipefail # Set the path that you want to deploy to surge # travis env set SURGE_PROJECT "." --public -# External Environment Variables +# TRAVIS ENVIRONMENT VARIABLES # # TRAVIS_REPO_SLUG # TRAVIS_BRANCH diff --git a/scripts/travis-another.bash b/scripts/travis-another.bash index e033b82..0cf3d75 100755 --- a/scripts/travis-another.bash +++ b/scripts/travis-another.bash @@ -6,7 +6,7 @@ set -ueE -o pipefail # and as such, when the content repository changes, you want to rerun the tests for the other repository, # perhaps even for deployment purposes. -# TRAVIS SCRIPT +# SCRIPT # # sudo: false # language: ruby @@ -17,7 +17,7 @@ set -ueE -o pipefail # script: # - eval "$(curl -fsSL https://raw.githubusercontent.com/bevry/awesome-travis/master/scripts/travis-another.bash)" -# TRAVIS ENVIRONMENT VARIABLES +# CUSTOM ENVIRONMENT VARIABLES # # GITHUB_TRAVIS_TOKEN # Specify your [GitHub Personal Access Token](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) with the `repo` permission. @@ -29,7 +29,7 @@ set -ueE -o pipefail # # TRAVIS_ANOTHER_BRANCH # The branch we should run this script on -# + # Run if test "${TRAVIS_BRANCH-}" = "${TRAVIS_ANOTHER_BRANCH}"; then echo "pinging $TRAVIS_ANOTHER_SLUG..."