chore(repo): change workspace to use verdaccio executor (#17280)

This commit is contained in:
Emily Xiong 2023-05-30 12:34:19 -04:00 committed by GitHub
parent a7c6d5aadb
commit b7410e61bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 39 deletions

View File

@ -73,18 +73,15 @@ it can be useful to publish to a local registry.
Check out [this video for a live walkthrough](https://youtu.be/Tx257WpNsxc) or follow the instructions below:
- Run `pnpm local-registry start` in Terminal 1 (keep it running)
- Run `pnpm local-registry` in Terminal 1 (keep it running)
- Run `npm adduser --registry http://localhost:4873` in Terminal 2 (real credentials are not required, you just need to
be logged in. You can use test/test/test@test.io.)
- Run `pnpm local-registry enable` in Terminal 2
- Run `pnpm nx-release 16.0.0 --local` in Terminal 2 - you can choose any nonexistent version number here, but it's recommended to use the next major
- Run `cd ./tmp` in Terminal 2
- Run `npx create-nx-workspace@16.0.0` in Terminal 2
- Run `npx create-nx-workspace@17.0.0` in Terminal 2
If you have problems publishing, make sure you use Node 18 and NPM 8.
**NOTE:** After you finish with local testing don't forget to stop the local registry (e.g. closing the Terminal 1) and disabling the local registy using `pnpm local-registry disable`. Keeping local registry enabled will change your lock file resolutions to `localhost:4873` on the next `pnpm i`. You can also run `pnpm local-registry clear` to clean all packages in that local registry.
**NOTE:** To use this newly published local version, you need to make a new workspace or change all of your target packages to this new version, eg: `"nx": "^16.0.0",` and re-run `pnpm i` in your testing project.
### Publishing for Yarn 2+ (Berry)
@ -101,7 +98,7 @@ Yarn Berry operates slightly differently than Yarn Classic. In order to publish
- localhost
```
- Run `pnpm local-registry start` in Terminal 1 (keep it running)
- Run `pnpm local-registry` in Terminal 1 (keep it running)
- If you are creating nx workspace outside of your nx repo, make sure to add npm registry info to your root yarnrc (
usually in ~/.yarnrc.yml). The file should look something like this:

View File

@ -18,7 +18,7 @@
"prepublishOnly": "node ./scripts/update-package-group.js",
"version": "pnpm prettier lerna.json --write",
"depcheck": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/depcheck",
"local-registry": "./scripts/local-registry.sh",
"local-registry": "nx local-registry @nx/nx-source",
"documentation": "ts-node -P scripts/tsconfig.scripts.json ./scripts/documentation/generators/main.ts && pnpm check-documentation-map",
"submit-plugin": "node ./scripts/submit-plugin.js",
"prepare": "is-ci || husky install",

14
project.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "@nx/nx-source",
"$schema": "node_modules/nx/schemas/project-schema.json",
"targets": {
"local-registry": {
"executor": "@nx/js:verdaccio",
"options": {
"port": 4873,
"config": ".verdaccio/config.yml",
"storage": "build/local-registry/storage"
}
}
}
}

View File

@ -1,32 +0,0 @@
#!/usr/bin/env bash
COMMAND=$1
if [[ $COMMAND == "enable" ]]; then
echo "Setting registry to local registry"
echo "To Disable: pnpm local-registry disable"
npm config set registry http://localhost:4873/ --location user
yarn config set registry http://localhost:4873/
fi
if [[ $COMMAND == "disable" ]]; then
npm config delete registry --location user
yarn config delete registry
CURRENT_NPM_REGISTRY=$(npm config get registry --location user)
CURRENT_YARN_REGISTRY=$(yarn config get registry)
echo "Reverting registries"
echo " > NPM: $CURRENT_NPM_REGISTRY"
echo " > YARN: $CURRENT_YARN_REIGSTRY"
fi
if [[ $COMMAND == "clear" ]]; then
echo "Clearing Local Registry"
rm -rf ./build/local-registry/storage
fi
if [[ $COMMAND == "start" ]]; then
echo "Starting Local Registry"
VERDACCIO_HANDLE_KILL_SIGNALS=true
pnpm verdaccio --config ./.verdaccio/config.yml
fi