From 89e8379f8d4697f3607fe223a8632f31bd5cec8b Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Mon, 11 May 2020 01:22:17 -0400 Subject: [PATCH] feat(repo): improve local-registry publishing (#2979) --- .verdaccio/config.yml | 39 +++++++++++++++++++++++++++++++++++++++ .verdaccio/htpasswd | 1 + package.json | 4 ++-- scripts/local-registry.sh | 17 +++++++++++------ scripts/publish.sh | 7 ++++--- 5 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 .verdaccio/config.yml create mode 100644 .verdaccio/htpasswd diff --git a/.verdaccio/config.yml b/.verdaccio/config.yml new file mode 100644 index 0000000000..e698e91ec5 --- /dev/null +++ b/.verdaccio/config.yml @@ -0,0 +1,39 @@ +# path to a directory with all packages +storage: ./build/local-registry/storage + +auth: + htpasswd: + file: ./htpasswd + +# a list of other known repositories we can talk to +uplinks: + npmjs: + url: https://registry.npmjs.org/ + cache: true + yarn: + url: https://registry.yarnpkg.com + cache: true + +packages: + '@*/*': + # scoped packages + access: $all + publish: $all + unpublish: $all + proxy: npmjs + + '**': + # allow all users (including non-authenticated users) to read and + # publish all packages + access: $all + + # allow all users (including non-authenticated users) to publish/publish packages + publish: $all + unpublish: $all + + # if package is not available locally, proxy requests to 'yarn' registry + proxy: npmjs + +# log settings +logs: + - { type: stdout, format: pretty, level: http } diff --git a/.verdaccio/htpasswd b/.verdaccio/htpasswd new file mode 100644 index 0000000000..8391cd4b0a --- /dev/null +++ b/.verdaccio/htpasswd @@ -0,0 +1 @@ +test:$6FrCaT/v0dwE:autocreated 2020-03-25T19:10:50.254Z diff --git a/package.json b/package.json index 0d927914ab..e6215c35cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nrwl/nx-source", - "version": "9.2.3", + "version": "9.4.0", "description": "Extensible Dev Tools for Monorepos", "homepage": "https://nx.dev", "main": "index.js", @@ -272,4 +272,4 @@ "pre-push": "yarn checkcommit && yarn documentation && yarn checkformat" } } -} +} \ No newline at end of file diff --git a/scripts/local-registry.sh b/scripts/local-registry.sh index dc4750ed26..6852a49f7f 100755 --- a/scripts/local-registry.sh +++ b/scripts/local-registry.sh @@ -1,15 +1,15 @@ #!/usr/bin/env bash -ENABLE=$1 +COMMAND=$1 -if [[ $ENABLE == "enable" ]]; then +if [[ $COMMAND == "enable" ]]; then echo "Setting registry to local registry" echo "To Disable: yarn local-registry disable" npm config set registry http://localhost:4873/ yarn config set registry http://localhost:4873/ fi -if [[ $ENABLE == "disable" ]]; then +if [[ $COMMAND == "disable" ]]; then npm config delete registry yarn config delete registry CURRENT_NPM_REGISTRY=`npm config get registry` @@ -20,7 +20,12 @@ if [[ $ENABLE == "disable" ]]; then echo " > YARN: $CURRENT_YARN_REIGSTRY" fi -if [[ $ENABLE == "start" ]]; then - echo "Starting Local Registry" - npx verdaccio +if [[ $COMMAND == "clear" ]]; then + echo "Clearing Local Registry" + rm -rf ./build/local-registry/storage +fi + +if [[ $COMMAND == "start" ]]; then + echo "Starting Local Registry" + npx verdaccio --config ./.verdaccio/config.yml fi diff --git a/scripts/publish.sh b/scripts/publish.sh index 67505c029e..b0fa6339c7 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -9,9 +9,7 @@ LOCALBUILD=$3 PACKAGE_SOURCE=build/packages NPM_DEST=build/npm ORIG_DIRECTORY=`pwd` - -# We are running inside of a child_process, so we need to reauth -npm adduser +NPM_REGISTRY=`npm config get registry` # for local releases if [ "$LOCALBUILD" = "--local" ]; then echo @@ -31,6 +29,9 @@ if [ "$LOCALBUILD" = "--local" ]; then fi else echo "Publishing to public npm" + + # We are running inside of a child_process, so we need to reauth + npm adduser fi for package in $NPM_DEST/*/