Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(js): replace publish script with nx release config #21474

Merged
merged 71 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
1de8a84
feat(js): replace publish script with nx release config
fahslaj Feb 1, 2024
fa703a3
docs(js): update docs
fahslaj Feb 1, 2024
e9bfd18
chore(js): add more unit tests
fahslaj Feb 1, 2024
75e7172
fix(js): pr tweaks
fahslaj Feb 1, 2024
26eec09
fix(js): do not add build dependency for publish target
fahslaj Feb 1, 2024
799814b
chore(js): disable nx-plugin e2e tests
fahslaj Feb 1, 2024
9e63fd5
chore(js): workaround for pnpm lockfile issue
fahslaj Feb 1, 2024
1f027ea
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 1, 2024
a7a3a70
chore(js): update e2e tests
fahslaj Feb 2, 2024
528d359
chore(js): fix js-generator e2e
fahslaj Feb 2, 2024
ca20163
chore(js): update docs and test description
fahslaj Feb 2, 2024
2ca6995
Merge remote-tracking branch 'upstream/master' into feat/nx-release-i…
fahslaj Feb 2, 2024
e38ff75
fix(js): add additional info messages
fahslaj Feb 2, 2024
1f5122d
feat(release): add generator options overrides api
fahslaj Feb 3, 2024
8e7038b
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 3, 2024
6af84aa
chore(release): update docs
fahslaj Feb 3, 2024
5045d0e
chore(release): update project-schema to include release prop
fahslaj Feb 3, 2024
cdbfc4d
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 3, 2024
3ad7faa
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 3, 2024
1b02b1e
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 4, 2024
e11937e
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 5, 2024
5298fe4
chore(js): remove redundant config patch in e2e tests
fahslaj Feb 5, 2024
9d47498
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 5, 2024
7efd2c0
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 5, 2024
7831e50
fix(release): filter to only projects with package.json files by default
fahslaj Feb 12, 2024
3974139
fix(release): filter root project by default if it is private
fahslaj Feb 12, 2024
a087ecf
fix(js): use projectRoot over projectName in generated target options
fahslaj Feb 12, 2024
bf0dd72
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 12, 2024
c7fc2f9
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 13, 2024
65f3fa6
fix(js): do not add release projects config if it doesn't exist already
fahslaj Feb 13, 2024
4ff49bf
fix(js): warn if local registry script is outdated and link to doc
fahslaj Feb 13, 2024
6e91019
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 13, 2024
a183782
chore(js): remove unused function
fahslaj Feb 13, 2024
0c44003
Merge branch 'feat/nx-release-in-nxjs-generator' of https://github.co…
fahslaj Feb 13, 2024
bc6e9c8
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 13, 2024
9082d29
chore(js): update e2e test
fahslaj Feb 14, 2024
b998f6e
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 14, 2024
25eced5
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 15, 2024
b01291a
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 21, 2024
b610b10
feat(release): add preVersionCommand option to config
fahslaj Feb 21, 2024
95afc7b
chore(release): add e2e test for preversion command
fahslaj Feb 22, 2024
9510ce1
fix(release): fix preVersionCommand addition in config
fahslaj Feb 22, 2024
d1e960d
fix(release): gracefully skip git ignored files
fahslaj Feb 22, 2024
f2ef797
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 22, 2024
9c77f5e
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 22, 2024
4e8435f
chore(release): fix unit tests
fahslaj Feb 22, 2024
583f49b
chore(js): update e2e
fahslaj Feb 23, 2024
3b3a7c0
chore(release): remove comment
fahslaj Feb 23, 2024
85f22a7
chore(js): remove explicit release config from e2e tests
fahslaj Feb 23, 2024
458a15c
fix(release): exclude private packages in zero-config case
fahslaj Feb 23, 2024
71cadc6
fix(release): simplify public logic and update test
fahslaj Feb 23, 2024
166ff10
fix(js): add private true with npm-scripts config
fahslaj Feb 24, 2024
9078051
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 24, 2024
69a99b5
chore(linter): update e2e test
fahslaj Feb 24, 2024
a7f5701
chore(js): update e2e test
fahslaj Feb 24, 2024
8753a1a
fix(js): use git-tag for current version resolver
fahslaj Feb 25, 2024
aeba8f7
fix(js): set first-release option in e2e setup
fahslaj Feb 25, 2024
c47df61
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 27, 2024
3dfd7e5
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 27, 2024
cdc9a72
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 28, 2024
b06def6
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 28, 2024
95264e7
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Feb 29, 2024
3359042
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Mar 1, 2024
b702c11
chore(js): update local registry setup doc
fahslaj Mar 1, 2024
c516225
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Mar 4, 2024
32db2a3
Merge branch 'master' into feat/nx-release-in-nxjs-generator
fahslaj Mar 4, 2024
ee0d29f
chore(js): update imports and guard against undefined targets obj
fahslaj Mar 5, 2024
7e3be66
chore(js): remove redundant build from add-local-registry-scripts
fahslaj Mar 5, 2024
22273b2
chore(js): remove redundant e2e tests
fahslaj Mar 5, 2024
d75c6e7
chore(release): remove imports from devkit-exports
fahslaj Mar 5, 2024
697fd3e
chore(release): use TempFs helper
fahslaj Mar 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/generated/manifests/menus.json
Original file line number Diff line number Diff line change
Expand Up @@ -2323,6 +2323,14 @@
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Update Your Local Registry Setup to use Nx Release",
"path": "/recipes/nx-release/update-local-registry-setup",
"id": "update-local-registry-setup",
"isExternal": false,
"children": [],
"disableCollapsible": false
}
],
"disableCollapsible": false
Expand Down Expand Up @@ -4147,6 +4155,14 @@
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Update Your Local Registry Setup to use Nx Release",
"path": "/recipes/nx-release/update-local-registry-setup",
"id": "update-local-registry-setup",
"isExternal": false,
"children": [],
"disableCollapsible": false
}
],
"disableCollapsible": false
Expand Down Expand Up @@ -4199,6 +4215,14 @@
"children": [],
"disableCollapsible": false
},
{
"name": "Update Your Local Registry Setup to use Nx Release",
"path": "/recipes/nx-release/update-local-registry-setup",
"id": "update-local-registry-setup",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Other",
"path": "/recipes/other",
Expand Down
33 changes: 33 additions & 0 deletions docs/generated/manifests/nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3177,6 +3177,17 @@
"isExternal": false,
"path": "/recipes/nx-release/publish-rust-crates",
"tags": ["nx-release"]
},
{
"id": "update-local-registry-setup",
"name": "Update Your Local Registry Setup to use Nx Release",
"description": "",
"mediaImage": "",
"file": "shared/recipes/nx-release/update-local-registry-setup",
"itemList": [],
"isExternal": false,
"path": "/recipes/nx-release/update-local-registry-setup",
"tags": ["nx-release"]
}
],
"isExternal": false,
Expand Down Expand Up @@ -5678,6 +5689,17 @@
"isExternal": false,
"path": "/recipes/nx-release/publish-rust-crates",
"tags": ["nx-release"]
},
{
"id": "update-local-registry-setup",
"name": "Update Your Local Registry Setup to use Nx Release",
"description": "",
"mediaImage": "",
"file": "shared/recipes/nx-release/update-local-registry-setup",
"itemList": [],
"isExternal": false,
"path": "/recipes/nx-release/update-local-registry-setup",
"tags": ["nx-release"]
}
],
"isExternal": false,
Expand Down Expand Up @@ -5750,6 +5772,17 @@
"path": "/recipes/nx-release/publish-rust-crates",
"tags": ["nx-release"]
},
"/recipes/nx-release/update-local-registry-setup": {
"id": "update-local-registry-setup",
"name": "Update Your Local Registry Setup to use Nx Release",
"description": "",
"mediaImage": "",
"file": "shared/recipes/nx-release/update-local-registry-setup",
"itemList": [],
"isExternal": false,
"path": "/recipes/nx-release/update-local-registry-setup",
"tags": ["nx-release"]
},
"/recipes/other": {
"id": "other",
"name": "Other",
Expand Down
7 changes: 7 additions & 0 deletions docs/generated/manifests/tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,13 @@
"id": "publish-rust-crates",
"name": "Publish Rust Crates",
"path": "/recipes/nx-release/publish-rust-crates"
},
{
"description": "",
"file": "shared/recipes/nx-release/update-local-registry-setup",
"id": "update-local-registry-setup",
"name": "Update Your Local Registry Setup to use Nx Release",
"path": "/recipes/nx-release/update-local-registry-setup"
}
],
"database": [
Expand Down
2 changes: 1 addition & 1 deletion docs/generated/packages/js/generators/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"publishable": {
"type": "boolean",
"default": false,
"description": "Generate a publishable library.",
"description": "Configure the library ready for use with `nx release` (https://nx.dev/core-features/manage-releases).",
"x-priority": "important"
},
"importPath": {
Expand Down
12 changes: 12 additions & 0 deletions docs/generated/packages/js/generators/release-version.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@
"type": "object",
"description": "Additional metadata to pass to the current version resolver.",
"default": {}
},
"skipLockFileUpdate": {
"type": "boolean",
"description": "Whether to skip updating the lock file after updating the version."
},
"installArgs": {
"type": "string",
"description": "Additional arguments to pass to the package manager when updating the lock file with an install command."
},
"installIgnoreScripts": {
"type": "boolean",
"description": "Whether to ignore install lifecycle scripts when updating the lock file with an install command."
}
},
"required": ["projects", "projectGraph", "releaseGroup"],
Expand Down
6 changes: 6 additions & 0 deletions docs/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,12 @@
"id": "publish-rust-crates",
"tags": ["nx-release"],
"file": "shared/recipes/nx-release/publish-rust-crates"
},
{
"name": "Update Your Local Registry Setup to use Nx Release",
"id": "update-local-registry-setup",
"tags": ["nx-release"],
"file": "shared/recipes/nx-release/update-local-registry-setup"
}
]
},
Expand Down
79 changes: 79 additions & 0 deletions docs/shared/recipes/nx-release/update-local-registry-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Update Your Local Registry Setup to use Nx Release

Nx will create a `tools/start-local-registry.ts` script for starting a local registry and publishing packages to it in preparation for running end to end tests. If you have an existing `tools/start-local-registry.ts` script from a previous version of Nx, you should update it to use Nx Release to publish packages to the local registry. This will ensure that newly generated libraries are published appropriately when running end to end tests.

## The Previous Version

The previous version of the `tools/start-local-registry.ts` script used publish targets on each project to publish the packages to the local registry. This is no longer necessary with Nx Release. You can identify the previous version by the `nx run-many` command that publishes the packages:

```typescript
/**
* This script starts a local registry for e2e testing purposes.
* It is meant to be called in jest's globalSetup.
*/
import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry';
import { execFileSync } from 'child_process';

export default async () => {
// local registry target to run
const localRegistryTarget = '@demo-plugin-1800/source:local-registry';
// storage folder for the local registry
const storage = './tmp/local-registry/storage';

global.stopLocalRegistry = await startLocalRegistry({
localRegistryTarget,
storage,
verbose: false,
});
const nx = require.resolve('nx');
execFileSync(
nx,
['run-many', '--targets', 'publish', '--ver', '0.0.0-e2e', '--tag', 'e2e'],
{ env: process.env, stdio: 'inherit' }
);
};
```

If your script looks like this, you should update it.

## The Updated Version

The updated version of the `tools/start-local-registry.ts` script uses Nx Release to publish the packages to the local registry. This is done by running `releaseVersion` and `releasePublish` functions from `nx/release`. Your updated script should look like this:

```typescript
/**
* This script starts a local registry for e2e testing purposes.
* It is meant to be called in jest's globalSetup.
*/
import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry';
import { execFileSync } from 'child_process';
import { releasePublish, releaseVersion } from 'nx/release';

export default async () => {
// local registry target to run
const localRegistryTarget = '@demo-plugin-1800/source:local-registry';
// storage folder for the local registry
const storage = './tmp/local-registry/storage';

global.stopLocalRegistry = await startLocalRegistry({
localRegistryTarget,
storage,
verbose: false,
});

await releaseVersion({
specifier: '0.0.0-e2e',
stageChanges: false,
gitCommit: false,
gitTag: false,
firstRelease: true,
generatorOptionsOverrides: {
skipLockFileUpdate: true,
},
});
await releasePublish({
tag: 'e2e',
firstRelease: true,
});
};
```
1 change: 1 addition & 0 deletions docs/shared/reference/sitemap.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
- [Publish in CI/CD](/recipes/nx-release/publish-in-ci-cd)
- [Automate GitHub Releases](/recipes/nx-release/automate-github-releases)
- [Publish Rust Crates](/recipes/nx-release/publish-rust-crates)
- [Update Your Local Registry Setup to use Nx Release](/recipes/nx-release/update-local-registry-setup)
- [Other](/recipes/other)
- [Rescope Packages from @nrwl to @nx](/recipes/other/rescope)
- [Showcase](/showcase)
Expand Down
3 changes: 1 addition & 2 deletions e2e/esbuild/src/esbuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import {
readJson,
runCLI,
runCommand,
runCommandUntil,
tmpProjPath,
uniq,
updateFile,
updateJson,
waitUntil,
} from '@nx/e2e/utils';
import { join } from 'path';

Expand Down Expand Up @@ -44,6 +42,7 @@ describe('EsBuild Plugin', () => {
expect(packageJson).toEqual({
name: `@proj/${myPkg}`,
version: '0.0.1',
private: true,
type: 'commonjs',
main: './index.cjs',
dependencies: {},
Expand Down
1 change: 1 addition & 0 deletions e2e/eslint/src/linter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ describe('Linter', () => {
},
"main": "./src/index.js",
"name": "@proj/${mylib}",
"private": true,
"type": "commonjs",
"typings": "./src/index.d.ts",
"version": "0.0.1",
Expand Down
3 changes: 2 additions & 1 deletion e2e/plugin/src/nx-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import {
} from '@nx/e2e/utils';
import type { PackageJson } from 'nx/src/utils/package-json';

import { join } from 'path';
import {
ASYNC_GENERATOR_EXECUTOR_CONTENTS,
NX_PLUGIN_V2_CONTENTS,
} from './nx-plugin.fixtures';
import { join } from 'path';

describe('Nx Plugin', () => {
let workspaceName: string;
Expand Down Expand Up @@ -50,6 +50,7 @@ describe('Nx Plugin', () => {
expect(project).toMatchObject({
tags: [],
});

runCLI(`e2e ${plugin}-e2e`);
}, 90000);

Expand Down
Loading