From c00f996beaf64da0375e5cffe1107e6a1773a099 Mon Sep 17 00:00:00 2001 From: Adam L Barrett Date: Sat, 9 May 2020 11:36:19 -0600 Subject: [PATCH] fix(testing): add a guard to not accidently publish to the registry (#2978) --- e2e/local-registry/setup.ts | 9 ++++++++- scripts/create-playground.sh | 4 ++-- scripts/e2e-ci1.sh | 4 ++-- scripts/e2e-ci2.sh | 4 ++-- scripts/e2e-ci3.sh | 4 ++-- scripts/e2e-ci4.sh | 4 ++-- scripts/e2e-rerun.sh | 6 +++--- scripts/e2e.sh | 8 ++++---- 8 files changed, 25 insertions(+), 18 deletions(-) diff --git a/e2e/local-registry/setup.ts b/e2e/local-registry/setup.ts index cdee2b11ff..d6c0acae33 100644 --- a/e2e/local-registry/setup.ts +++ b/e2e/local-registry/setup.ts @@ -4,7 +4,7 @@ import { getDirectories } from '../utils'; const asyncExec = promisify(exec); -process.env.PUBLISHED_VERSION = `9999.0.0`; +process.env.PUBLISHED_VERSION = `9999.0.1`; async function spawnLocalRegistry() { const localRegistryProcess = spawn('npx', [ @@ -40,6 +40,13 @@ async function updateVersion(packagePath) { } async function publishPackage(packagePath) { + if (process.env.npm_config_registry.indexOf('http://localhost') === -1) { + throw Error(` + ------------------ + 💣 ERROR 💣 => $NPM_REGISTRY does not look like a local registry' + ------------------ + `); + } await asyncExec(`npm publish`, { cwd: packagePath, env: process.env, diff --git a/scripts/create-playground.sh b/scripts/create-playground.sh index 649f4f4881..9d4f775cf6 100755 --- a/scripts/create-playground.sh +++ b/scripts/create-playground.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash -./scripts/link.sh 9999.0.0 +./scripts/link.sh 9999.0.1 rm -rf tmp mkdir -p tmp/angular mkdir -p tmp/nx -PUBLISHED_VERSION=9999.0.0 NPM_CONFIG_REGISTRY=http://localhost:4872/ jest --maxWorkers=1 -c "./build/e2e/jest-config.js" ./build/e2e/commands/create-playground.test.js +PUBLISHED_VERSION=9999.0.1 npm_config_registry=http://localhost:4872/ jest --maxWorkers=1 -c "./build/e2e/jest-config.js" ./build/e2e/commands/create-playground.test.js diff --git a/scripts/e2e-ci1.sh b/scripts/e2e-ci1.sh index ea61035cd6..8b981dd3f0 100755 --- a/scripts/e2e-ci1.sh +++ b/scripts/e2e-ci1.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash -./scripts/link.sh 9999.0.0 +./scripts/link.sh 9999.0.1 rm -rf tmp mkdir -p tmp/angular mkdir -p tmp/nx export SELECTED_CLI=$1 -PUBLISHED_VERSION=9999.0.0 npm_config_registry=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 "./build/e2e/(angular|cli|workspace|workspace-aux-commands|cypress).test.js" +PUBLISHED_VERSION=9999.0.1 npm_config_registry=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 "./build/e2e/(angular|cli|workspace|workspace-aux-commands|cypress).test.js" diff --git a/scripts/e2e-ci2.sh b/scripts/e2e-ci2.sh index 39cdcf56cd..a72ab3d052 100755 --- a/scripts/e2e-ci2.sh +++ b/scripts/e2e-ci2.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash -./scripts/link.sh 9999.0.0 +./scripts/link.sh 9999.0.1 rm -rf tmp mkdir -p tmp/angular mkdir -p tmp/nx export SELECTED_CLI=$1 -PUBLISHED_VERSION=9999.0.0 npm_config_registry=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 "./build/e2e/(jest|karma|next|nx-plugin|downgrade-module).test.js" +PUBLISHED_VERSION=9999.0.1 npm_config_registry=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 "./build/e2e/(jest|karma|next|nx-plugin|downgrade-module).test.js" diff --git a/scripts/e2e-ci3.sh b/scripts/e2e-ci3.sh index 96ba4d2ab9..cb6a453ddd 100755 --- a/scripts/e2e-ci3.sh +++ b/scripts/e2e-ci3.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash -./scripts/link.sh 9999.0.0 +./scripts/link.sh 9999.0.1 rm -rf tmp mkdir -p tmp/angular mkdir -p tmp/nx export SELECTED_CLI=$1 -PUBLISHED_VERSION=9999.0.0 npm_config_registry=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 "./build/e2e/(storybook|upgrade-module|web|angular-package|react-package|ngrx).test.js" +PUBLISHED_VERSION=9999.0.1 npm_config_registry=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 "./build/e2e/(storybook|upgrade-module|web|angular-package|react-package|ngrx).test.js" diff --git a/scripts/e2e-ci4.sh b/scripts/e2e-ci4.sh index cdbf5ae27a..872e98474a 100755 --- a/scripts/e2e-ci4.sh +++ b/scripts/e2e-ci4.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash -./scripts/link.sh 9999.0.0 +./scripts/link.sh 9999.0.1 rm -rf tmp mkdir -p tmp/angular mkdir -p tmp/nx export SELECTED_CLI=$1 -PUBLISHED_VERSION=9999.0.0 npm_config_registry=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 "./build/e2e/(ng-add|node|react).test.js" +PUBLISHED_VERSION=9999.0.1 npm_config_registry=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 "./build/e2e/(ng-add|node|react).test.js" diff --git a/scripts/e2e-rerun.sh b/scripts/e2e-rerun.sh index cba8535a1e..6cfc2a93f4 100755 --- a/scripts/e2e-rerun.sh +++ b/scripts/e2e-rerun.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -./scripts/link.sh 9999.0.0 +./scripts/link.sh 9999.0.1 rm -rf tmp/nx/proj/node_modules/@nrwl rm -rf tmp/angular/proj/node_modules/@nrwl @@ -8,9 +8,9 @@ cp -r node_modules/@nrwl tmp/nx/proj/node_modules/@nrwl cp -r node_modules/@nrwl tmp/angular/proj/node_modules/@nrwl if [ -n "$1" ]; then - PUBLISHED_VERSION=9999.0.0 NPM_CONFIG_REGISTRY=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 ./build/e2e/$1.test.js + PUBLISHED_VERSION=9999.0.1 npm_config_registry=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 ./build/e2e/$1.test.js else - PUBLISHED_VERSION=9999.0.0 NPM_CONFIG_REGISTRY=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 ./build/e2e + PUBLISHED_VERSION=9999.0.1 npm_config_registry=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 ./build/e2e fi diff --git a/scripts/e2e.sh b/scripts/e2e.sh index b048e2839c..0a62a6c8c2 100755 --- a/scripts/e2e.sh +++ b/scripts/e2e.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -./scripts/link.sh 9999.0.0 +./scripts/link.sh 9999.0.1 rm -rf tmp mkdir -p tmp/angular @@ -10,10 +10,10 @@ if [ -n "$1" ]; then COMMAND_FILE="./build/e2e/commands/$1.test.js" if [ -f "$TEST_FILE" ]; then - PUBLISHED_VERSION=9999.0.0 NPM_CONFIG_REGISTRY=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 $TEST_FILE + PUBLISHED_VERSION=9999.0.1 npm_config_registry=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 $TEST_FILE else - PUBLISHED_VERSION=9999.0.0 NPM_CONFIG_REGISTRY=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 $COMMAND_FILE + PUBLISHED_VERSION=9999.0.1 npm_config_registry=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 $COMMAND_FILE fi else - PUBLISHED_VERSION=9999.0.0 NPM_CONFIG_REGISTRY=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 ./build/e2e/*.test.js + PUBLISHED_VERSION=9999.0.1 npm_config_registry=http://localhost:4872/ jest -c "./build/e2e/jest-config.js" --maxWorkers=1 ./build/e2e/*.test.js fi