Support for generic task execution, displaying affecting projects, new commands for schematics discovery, and more in Nx 8.7

Brandon Roberts
Nx Devtools
Published in
4 min readOct 28, 2019

--

Today, we are happy to announce the release of Nx 8.7 that includes support for generic task execution!

Nx is a set of Extensible Dev Tools for Monorepos, which we developed at Nrwl based on our experience working at Google and helping Fortune 500 enterprises build ambitious applications at scale.

If you aren’t familiar with it, learn about Nx at nx.dev/angular and nx.dev/react

Support for generic task execution

When running tasks in a large repo, npm-run-all is a viable option for executing multiple tasks in parallel. However, if you want to record the metadata returned for these tasks, such as build times, or offload them to remote machines in a distributed build environment, this becomes more tricky.

Nx allows you more flexibility with support for adding generic task runners. You can have default options for running tasks, or custom options such as running your tasks in a remote build environment.

To use custom task execution, provide a custom runner with the Nx affected commands.

nx affected --target=build --runner=custom-remote --remote-url=https://ci.mydomain.com:3000 -- --

New command for Displaying Affected Projects

When running your projects in a continuous integration(CI) environment, you may need detailed information about which projects were affected in order to trigger some operations. Nx now provides a detailed output about the affected projects in a JSON format that you can parse according to your needs.

To display the affected projects, use the print-affected command.

nx print-affected

For example, if you have an application myapp, with a dependency on a library my-lib and you change something in my-lib, running nx print-affected --target=test will produce JSON output that includes the tasks it would run to test both affected projects.

{
"tasks": [
{
"id": "my-lib:test",
"overrides": {},
"target": {
"project": "my-lib",
"target": "test"
},
"command": "npm run ng -- test my-lib",
"outputs": []
},
{
"id": "myapp:test",
"overrides": {},
"target": {
"project": "myapp",
"target": "test"
},
"command": "npm run ng -- test myapp",
"outputs": []
}
],
...
}

You can use the output of this command to invoke the jobs on a custom remote.

const res = JSON.parse(execSync('nx print-affected --target=test').toString())res.tasks.forEach(t => {
// invokeOnRemote(t.command);
});

New Commands for Easier Discovery

There are usually many different packages in your workspace that offer schematics to help you scaffold out files, and aid in your development workflow. We’ve introduced the list and report commands to make it easier to discover available schematics packages, schematics, and information about your workspace.

nx list lists all schematics collections available in your workspace.

You can take this one step further and display the specific schematics for a collection using nx list [collectionName].

When you need to easily glance at the versions of the Nrwl packages in your workspace, use the nx report command. This is useful for debugging, and providing information when you want to contribute to the Nx open source project.

New video course for Nx Workspaces!

We also recently launched a brand free new video course on Nx workspaces.

In our new course you’ll find all you need to know about how to use Nx! Instructor and Nrwl consultant, Isaac Mann, takes you through 5-minute video sessions on specific topics for a total of 30 minutes of learning time. You’ll learn how an Nx workspace enables you to do more with your Angular and React apps and take advantage of the tool:

  • Out-of-the-box configuration for modern frameworks and tooling
  • Easy code-sharing with enforced API boundaries
  • Dependency-graph-aware tooling that allows you to run commands only on the code affected by a particular change
  • Ensure that Angular and React apps and their backend code all live happily in the same monorepo

Visit Nrwl Connect, our development empowerment platform, and sign up for a free account!

How to Update Nx

Each release of Nx also contains additional minor features, and bug fixes.

Updating Nx can be done with the following commands, and will update your dependencies and code to the latest version:

yarn update

Or for npm

npm run update

As always, if you are looking for enterprise consulting, training and support, you can find out more about how we work with our clients here.

If you liked this, click the 👏 below so other people will see this here on Medium. Follow Brandon Roberts and @nrwl_io to read more about Nx and Nrwl. Also follow Brandon, Nx, and Nrwl on Twitter!

Learn more about Nrwl’s Nx at Nx.dev

--

--

Web dev, tech writer, DevRel at Nrwl, NgRx maintainer, GDE, sports fan, recovering gadget addict, and still learning. Gif game 💪🏿