From 11863903b68254698f02d2e85f76c56faec1e244 Mon Sep 17 00:00:00 2001 From: Steven Nance Date: Thu, 12 Sep 2024 13:51:45 +0200 Subject: [PATCH 1/2] switch to nx-release for publishing (#33) * chore: switch to nx-release for publishing * chore: revert unnecessary eslint changes added by migration --- .eslintrc.json | 10 ++------- .github/CONTRIBUTING.md | 33 +++++++++++++++++++++++++++++ libs/nx-react-workshop/package.json | 2 +- libs/nx-react-workshop/project.json | 10 ++------- nx.json | 15 +++++++++++++ package.json | 3 +-- scripts/local-release.ts | 15 ------------- scripts/tsconfig.release.json | 9 -------- 8 files changed, 54 insertions(+), 43 deletions(-) create mode 100644 .github/CONTRIBUTING.md delete mode 100644 scripts/local-release.ts delete mode 100644 scripts/tsconfig.release.json diff --git a/.eslintrc.json b/.eslintrc.json index e41eaa8..9ca2e83 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -24,18 +24,12 @@ { "files": ["*.ts", "*.tsx"], "extends": ["plugin:@nx/typescript"], - "rules": { - "@typescript-eslint/no-extra-semi": "error", - "no-extra-semi": "off" - } + "rules": {} }, { "files": ["*.js", "*.jsx"], "extends": ["plugin:@nx/javascript"], - "rules": { - "@typescript-eslint/no-extra-semi": "error", - "no-extra-semi": "off" - } + "rules": {} } ] } diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..39851ee --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,33 @@ +# Contributing + +`TODO` + +## Local Package Publishing + +When iterating on the `@nrwl/nx-workshop-e2e` package, it's often helpful to test out a published +version of the package locally. This can be done by starting the local registry, `verdaccio`, and using the `nx release` command. + +To start the local registry, run the `local-registry` target for the root workspace project: + +```bash +nx local-registry +``` + +In another terminal, you can then trigger deployment to that registry by running the `release` target for the `nx-workshop-e2e` project: + +```bash +nx release version prerelease && nx release publish + +# alternatively +nx release-dev nx-react-workshop +``` + +Once your dev version has been published, you can then update the `nx-workshop-e2e` package in your consuming project to the version you just published. + +Since verdaccio configures itself in the `~/.npmrc` file, you can simply install using your standard package manager commands: + +```bash +npm add --save-dev @nrwl/nx-react-workshop@latest +# or alternatively with yarn +yarn add -D @nrwl/nx-react-workshop@latest +``` diff --git a/libs/nx-react-workshop/package.json b/libs/nx-react-workshop/package.json index 1efa574..26d1d1b 100644 --- a/libs/nx-react-workshop/package.json +++ b/libs/nx-react-workshop/package.json @@ -1,6 +1,6 @@ { "name": "@nrwl/nx-react-workshop", - "version": "0.2.1", + "version": "0.0.0", "main": "src/index.js", "generators": "./generators.json", "executors": "./executors.json", diff --git a/libs/nx-react-workshop/project.json b/libs/nx-react-workshop/project.json index d7e5d99..8cf0b6c 100644 --- a/libs/nx-react-workshop/project.json +++ b/libs/nx-react-workshop/project.json @@ -54,14 +54,8 @@ "updateBuildableProjectDepsInPackageJson": true } }, - "publish": { - "executor": "nx:run-commands", - "options": { - "commands": [ - "yarn nx build nx-react-workshop", - "yarn publish dist/libs/nx-react-workshop" - ] - } + "release-dev": { + "command": "nx release version prerelease && nx release publish" } } } diff --git a/nx.json b/nx.json index 4451a95..244f105 100644 --- a/nx.json +++ b/nx.json @@ -21,6 +21,11 @@ "@nx/eslint:lint": { "inputs": ["default", "{workspaceRoot}/.eslintrc.json"], "cache": true + }, + "nx-release-publish": { + "options": { + "packageRoot": "dist/libs/{projectName}" + } } }, "namedInputs": { @@ -38,6 +43,16 @@ "!{projectRoot}/tsconfig.storybook.json" ] }, + "release": { + "projects": ["nx-react-workshop"], + "version": { + "preVersionCommand": "nx build nx-react-workshop", + "generatorOptions": { + "packageRoot": "dist/libs/{projectName}", + "currentVersionResolver": "registry" + } + } + }, "nxCloudAccessToken": "NzdhYTRjNmQtNGYwMC00MGE0LTk2YzEtNWFlNGU1MDk3OTczfHJlYWQtd3JpdGU=", "nxCloudUrl": "https://staging.nx.app", "useInferencePlugins": false, diff --git a/package.json b/package.json index 7111ac3..0e0cb76 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,7 @@ "version": "0.0.0", "license": "MIT", "scripts": { - "nx": "nx", - "local-release": "ts-node -P ./scripts/tsconfig.release.json ./scripts/local-release" + "nx": "nx" }, "private": true, "dependencies": { diff --git a/scripts/local-release.ts b/scripts/local-release.ts deleted file mode 100644 index 799e6e5..0000000 --- a/scripts/local-release.ts +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env node -import { execSync } from 'child_process'; - -const LARGE_BUFFER = 1024 * 1000000; - -(async () => { - execSync(`yarn nx build nx-react-workshop`, { - stdio: [0, 1, 2], - maxBuffer: LARGE_BUFFER, - }); -})(); - -function getRegistry() { - return new URL(execSync('npm config get registry').toString().trim()); -} diff --git a/scripts/tsconfig.release.json b/scripts/tsconfig.release.json deleted file mode 100644 index 522adc8..0000000 --- a/scripts/tsconfig.release.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "../scripts/tools-out", - "module": "commonjs", - "types": ["node"] - }, - "include": ["**/*.ts"] -} From 00811dcae0d152cc714bd6d2af7e844dda5efcf7 Mon Sep 17 00:00:00 2001 From: Steven Nance Date: Thu, 12 Sep 2024 13:53:29 +0200 Subject: [PATCH 2/2] feat(ci): add initial ci config (#34) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ci: add initial ci config * Update ci.yml --------- Co-authored-by: Miroslav Jonaš --- .github/workflows/ci.yml | 38 ++++++++++++++++++++++++++++++++++++++ nx.json | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e486573 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +permissions: + actions: read + contents: read + +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # This enables task distribution via Nx Cloud + # Run this command as early as possible, before dependencies are installed + # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun + - run: yarn dlx nx-cloud start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="e2e" + + # Cache node_modules + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'yarn' + + - run: yarn install --immutable + - uses: nrwl/nx-set-shas@v4 + + # Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud + # - run: yarn nx-cloud record -- echo Hello World + # Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected + - run: yarn nx affected -t lint test build e2e diff --git a/nx.json b/nx.json index 244f105..a5f9bf2 100644 --- a/nx.json +++ b/nx.json @@ -30,7 +30,7 @@ }, "namedInputs": { "default": ["{projectRoot}/**/*", "sharedGlobals"], - "sharedGlobals": [], + "sharedGlobals": ["{workspaceRoot}/.github/workflows/ci.yml"], "production": [ "default", "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",