From 20b02dd98cb945905a037c17c8c4e090f5ccaf0b Mon Sep 17 00:00:00 2001 From: Michael Klement Date: Thu, 21 Apr 2016 17:50:48 -0400 Subject: [PATCH 1/2] * Makefile updated to work with newer npm versions and to not push tags with `make push` --- Makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 8c364a5..36cf27c 100644 --- a/Makefile +++ b/Makefile @@ -50,16 +50,18 @@ test: ifeq ($(NOTEST),1) @echo Note: Skipping tests, as requested. >&2 else - @if [[ -n $$(json -f package.json main) ]]; then tap ./test; else urchin ./test; fi + @exists() { [ -e "$$1" ]; }; exists ./test/* || { echo "(No tests defined.)" >&2; exit 0; }; \ + if [[ -n $$(json -f package.json main) ]]; then tap ./test; else urchin ./test; fi endif -# Commits (with prompt for message) and pushes to the branch of the same name in remote repo 'origin', tags included. +# Commits (with prompt for message) and pushes to the branch of the same name in remote repo 'origin', +# but *without* tags, so as to allow quick pushing of changes without running into problems with tag redefinitions. +# (Tags are only pushed - forcefully - with `make release`.) .PHONY: push push: _need-clean-ws-or-no-untracked-files @[[ -z $$(git status --porcelain || echo no) ]] && echo "-- (Nothing to commit.)" || { git commit || exit; echo "-- Committed."; }; \ targetBranch=`git symbolic-ref --short HEAD` || exit; \ git push origin "$$targetBranch" || exit; \ - git push origin "$$targetBranch" --tags || exit; \ echo "-- Pushed." @@ -340,4 +342,4 @@ _need-origin: .PHONY: _need-npm-credentials _need-npm-credentials: @[[ `json -f package.json private` == 'true' ]] && exit 0; \ - grep -Eq '^//registry.npmjs.org/:_password' ~/.npmrc || { echo "ERROR: npm-registry credentials not found. Please log in with 'npm login' in order to enable publishing." >&2; exit 2; }; \ + grep -Eq '^//registry.npmjs.org/:(_password|_authToken)=' ~/.npmrc || { echo "ERROR: npm-registry credentials not found. Please log in with 'npm login' in order to enable publishing." >&2; exit 2; }; \ From 0729bcf8c3246ac3841dc7da813a4d1d2c64556c Mon Sep 17 00:00:00 2001 From: Michael Klement Date: Wed, 1 Jun 2016 16:15:39 -0400 Subject: [PATCH 2/2] v0.3.3 * [security] Switched to https:// URLs. --- CHANGELOG.md | 3 +++ README.md | 21 +++++++++++-------- bin/n-install | 10 +++++---- bin/n-uninstall | 10 +++++---- bin/n-update | 4 ++-- package.json | 2 +- ... Run successful and failed uninstallations | 10 +++++---- 7 files changed, 36 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d38408c..a2e6a82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ Versioning complies with [semantic versioning (semver)](http://semver.org/). +* **[v0.3.3](https://github.com/mklement0/n-install/compare/v0.3.2...v0.3.3)** (2016-06-01): + * [security] Switched to https:// URLs. + * **[v0.3.2](https://github.com/mklement0/n-install/compare/v0.3.1...v0.3.2)** (2016-02-20): * [enhancement] New option `-q` (quiet mode) skips prompts, like `-y`, and additionally suppresses all status output. diff --git a/README.md b/README.md index 2cc9777..836e748 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Additionally, installs scripts `n-update` for later on-demand updating of `n`, a The simplest case is **installation of `n` with confirmation prompt**, with subsequent **installation of the latest stable Node.js version**: ```shell -curl -L http://git.io/n-install | bash +curl -L https://git.io/n-install | bash ``` This is by far **the simplest way to get started with both `n` and Node.js** - even if you're looking to install only the latest stable Node.js version, with no (immediate) plans to install _multiple_ versions. @@ -64,33 +64,33 @@ Note: The examples use only `curl` for brevity; to run a given command with `wge * Installation with confirmation prompt to default location `$HOME/n` and installation of the latest stable Node.js version: ```shell -curl -L http://git.io/n-install | bash +curl -L https://git.io/n-install | bash ``` * Automated installation to default location `$HOME/n` and installation of the latest stable Node.js version: ```shell -curl -L http://git.io/n-install | bash -s -- -y +curl -L https://git.io/n-install | bash -s -- -y ``` * Automated, _quiet_ installation to default location `$HOME/n` and installation of the latest stable Node.js version; _no status information_ is displayed: ```shell -curl -sL http://git.io/n-install | bash -s -- -q +curl -sL https://git.io/n-install | bash -s -- -q ``` * Automated installation to the default location, with subsequent installation of the latest LTS (Long Term Support) version, and the latest 0.10.x release: ```shell -curl -L http://git.io/n-install | bash -s -- -y lts 0.10 +curl -L https://git.io/n-install | bash -s -- -y lts 0.10 ``` * Automated installation to custom location `~/util/n`, with subsequent installation of the latest stable Node.js version: ```shell -curl -L http://git.io/n-install | N_PREFIX=~/util/n bash -s -- -y +curl -L https://git.io/n-install | N_PREFIX=~/util/n bash -s -- -y ``` # Installing n @@ -114,7 +114,7 @@ For other shells, manual updating of the relevant initialization file is require ## Installation from GitHub ```shell -curl -L http://git.io/n-install | [N_PREFIX=] bash [-s -- [-y] [...]] +curl -L https://git.io/n-install | [N_PREFIX=] bash [-s -- [-y] [...]] ``` See below for an explanation of the options; `-s --` is required by Bash itself in order to pass options through to the script piped from stdin. @@ -142,7 +142,7 @@ To bypass that: ## Manual installation -* Download [this `bash` script](http://git.io/n-install) as `n-install`. +* Download [this `bash` script](https://git.io/n-install) as `n-install`. * Make it executable with `chmod +x`. * Move or symlink it to a directory in your `$PATH`. * Invoke `n-install` as detailed below. @@ -213,7 +213,7 @@ DESCRIPTION shell-initialization file; however, note that you'll then have to edit the out-sourced file *manually* - instructions will be printed. - For more information, see http://git.io/n-install-repo + For more information, see https://git.io/n-install-repo PREREQUISITES bash ... to run this script and n itself. @@ -294,6 +294,9 @@ Versioning complies with [semantic versioning (semver)](http://semver.org/). +* **[v0.3.3](https://github.com/mklement0/n-install/compare/v0.3.2...v0.3.3)** (2016-06-01): + * [security] Switched to https:// URLs. + * **[v0.3.2](https://github.com/mklement0/n-install/compare/v0.3.1...v0.3.2)** (2016-02-20): * [enhancement] New option `-q` (quiet mode) skips prompts, like `-y`, and additionally suppresses all status output. diff --git a/bin/n-install b/bin/n-install index 139f494..ecb3913 100755 --- a/bin/n-install +++ b/bin/n-install @@ -12,11 +12,13 @@ kMIN_BASH_VERSION='3.2' # due to use of =~, we require at least 3.2 ##### IMPORTANT: These names must, at least in part, be kept in sync with their counterparts in 'n-update' and 'n-uninstall'. kINSTALLER_NAME=n-install # This script's name; note that since we'll typically be running via curl directly from GitHub, using $(basename "$BASH_SOURCE") to determine the name is not an option. -kTHIS_REPO_URL='http://git.io/n-install-repo' # This script's source repository - SHORT, git.io-based form. +kTHIS_REPO_URL='https://git.io/n-install-repo' # This script's source repository - SHORT, git.io-based form. kTHIS_REPO_URL_LONG='https://github.com/mklement0/n-install' # This script's source repository in LONG form - needed for deriving raw.githubusercontent.com URLs from it. kPREFIX_DIR=${N_PREFIX:-$HOME/n} # The target prefix directory, inside which both a dir. for n itself and the active node version's dirs. will be located. -## For updating the relevant shell initialization file: -kINIT_FILE_LINE_ID=" # Added by $kINSTALLER_NAME (see $kTHIS_REPO_URL)." # The string that identifies the line added by us. +## For updating the relevant shell initialization file: The string that identifies the line added by us. +## !! Now that this project has been published, we HARD-CODE this ID string to ensure that old installations are found. +## !! For instance, we've changed from http:// to https:// URLs later, but the ID string must continue to use http:// to avoid breaking later uninstalls / reinstalls. +kINIT_FILE_LINE_ID=" # Added by n-install (see http://git.io/n-install-repo)." kREGEX_CONFLICTING_LINE='^[^#]*\bN_PREFIX=' # Regex that identifies relevant existing lines. ##### @@ -417,7 +419,7 @@ unset CDPATH # to prevent unpredictable `cd` behavior [[ -t 1 ]] || kNO_COLOR=1 # turn off colored output if stdout is not connected to a terminal # Output version number and exit, if requested. Note that the `ver='...'` statement is automatically updated by `make version VER=` - DO keep the 'v' suffix in the variable _definition_. -[[ $1 == '--version' ]] && { ver='v0.3.2'; echo "$kTHIS_NAME ${ver#v}"$'\nFor license information and more, visit https://git.io/n-install-repo'; exit 0; } +[[ $1 == '--version' ]] && { ver='v0.3.3'; echo "$kTHIS_NAME ${ver#v}"$'\n'"For license information and more, visit $kTHIS_REPO_URL"; exit 0; } # !! AS OF n 1.3.0, n ITSELF ONLY WORKS WITH curl, NOT ALSO WITH wget. # !! Once n also supports wget, mention wget as an alternative in the help text. diff --git a/bin/n-uninstall b/bin/n-uninstall index 0a43a5f..c909ad9 100755 --- a/bin/n-uninstall +++ b/bin/n-uninstall @@ -6,10 +6,12 @@ ##### IMPORTANT: These names must be kept in sync with the master copies in 'n-install'. kINSTALLER_NAME='n-install' # The name of the script that installed n. -kTHIS_REPO_URL='http://git.io/n-install-repo' # This script's source repository. +kTHIS_REPO_URL='https://git.io/n-install-repo' # This script's source repository. kPREFIX_DIR=${N_PREFIX:-$HOME/n} # The target prefix directory, inside which both a dir. for n itself and the active node version's dirs. will be located. -## For updating the relevant shell initialization file: -kINIT_FILE_LINE_ID=" # Added by $kINSTALLER_NAME (see $kTHIS_REPO_URL)." # The string that identifies the line added by us. +## For updating the relevant shell initialization file: The string that identifies the line added by us. +## !! Now that this project has been published, we HARD-CODE this ID string to ensure that old installations are found. +## !! For instance, we've changed from http:// to https:// URLs later, but the ID string must continue to use http:// to avoid breaking later uninstalls / reinstalls. +kINIT_FILE_LINE_ID=" # Added by n-install (see http://git.io/n-install-repo)." ##### kTHIS_NAME=$(basename "$0") @@ -217,7 +219,7 @@ unset CDPATH # to prevent unpredictable `cd` behavior [[ -t 1 ]] || kNO_COLOR=1 # turn off colored output if stdout is not connected to a terminal # Output version number and exit, if requested. Note that the `ver='...'` statement is automatically updated by `make version VER=` - DO keep the 'v' suffix in the variable _definition_. -[ "$1" = '--version' ] && { ver='v0.3.2'; echo "$kTHIS_NAME ${ver#v}"$'\nFor license information and more, visit https://git.io/n-install-repo'; exit 0; } +[ "$1" = '--version' ] && { ver='v0.3.3'; echo "$kTHIS_NAME ${ver#v}"$'\nFor license information and more, visit https://git.io/n-install-repo'; exit 0; } # Command-line help. if [ "$1" = '--help' ] || [ "$1" = '-h' ]; then diff --git a/bin/n-update b/bin/n-update index 453fc5b..9e713ab 100755 --- a/bin/n-update +++ b/bin/n-update @@ -8,7 +8,7 @@ kTHIS_NAME=$(basename "$0") ##### IMPORTANT: These names must be kept in sync with the master copies in 'n-install'. kINSTALLER_NAME=n-install # The installer script's name. -kTHIS_REPO_URL='http://git.io/n-install-repo' # This script's source repository. +kTHIS_REPO_URL='https://git.io/n-install-repo' # This script's source repository. ##### # @@ -124,7 +124,7 @@ unset CDPATH # to prevent unpredictable `cd` behavior [[ -t 1 ]] || kNO_COLOR=1 # turn off colored output if stdout is not connected to a terminal # Output version number and exit, if requested. Note that the `ver='...'` statement is automatically updated by `make version VER=` - DO keep the 'v' suffix in the variable _definition_. -[ "$1" = '--version' ] && { ver='v0.3.2'; echo "$kTHIS_NAME ${ver#v}"$'\nFor license information and more, visit https://git.io/n-install-repo'; exit 0; } +[ "$1" = '--version' ] && { ver='v0.3.3'; echo "$kTHIS_NAME ${ver#v}"$'\nFor license information and more, visit https://git.io/n-install-repo'; exit 0; } # Command-line help. if [ "$1" = '--help' ] || [ "$1" = '-h' ]; then diff --git a/package.json b/package.json index 0833844..1be0eaf 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "n-install", "description": "installs n, the Node.js version manager, without needing to install Node.js first", "private": true, - "version": "0.3.2", + "version": "0.3.3", "os": [ "darwin", "linux" diff --git a/test/8 Run successful and failed uninstallations b/test/8 Run successful and failed uninstallations index e70bee5..f0dd73f 100755 --- a/test/8 Run successful and failed uninstallations +++ b/test/8 Run successful and failed uninstallations @@ -36,14 +36,16 @@ tmpInitFile="$tmpDir/initFile" # Define the shell-init test files to use. # NOTE: The *1*-based indices of the arrays must match the `case` handlers below. +# 1-based indices: 1 2 3 4 5 6 initFiles=( ./.fixtures/shellInitFile-ownEntry ./.fixtures/shellInitFile-ownEntry ./.fixtures/shellInitFile-ownEntry ./.fixtures/shellInitFile-multipleOwnEntries ./.fixtures/shellInitFile-noentry ./.fixtures/shellInitFile-foreignEntry ) descriptions=( 'interactive - confirmed' 'interactive - declined' 'own entry' 'multiple own entries' 'no own entry' 'foreign entry' ) i=0 for initFile in "${initFiles[@]}"; do - descr="${descriptions[i++]}" - + (( ++i )) # start wit index 1 + descr="${descriptions[i-1]}" + # Create a dummy file and subdirs to test if they get in the way of removing $tmpPrefixDir. mkdir -p "$tmpPrefixDir/dummyDir" || die touch "$tmpPrefixDir/dummyFile" || die @@ -86,8 +88,8 @@ for initFile in "${initFiles[@]}"; do fgrep -q "$kINIT_FILE_LINE_ID" "$tmpInitFile" && die "$descr: Init file still contains '$kINIT_FILE_LINE_ID'. $epilogue" [[ ! -e "$tmpPrefixDir" ]] || die "$descr: Prefix dir still exists. $epilogue" ;; - 5|6) # init files without expected entry: should not succeed, and should keep "$tmpPrefixDir" - (( ec > 1 )) || die "$descr: Unexpectedly reported exit code $ec. $epilogue" + 5|6) # init files without expected entry: should keep "$tmpPrefixDir" and either report 6, if ~/n is present or 0 (just a warning), if it isn't. + (( ec == 0 || ec == 6 )) || die "$descr: Unexpectedly reported exit code $ec. $epilogue" [[ -e "$tmpPrefixDir" ]] || die "$descr: Prefix dir unexpectedly removed. $epilogue" ;; *)