Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ Don't be too anxious about choosing the exact right folder structure from the be

For instance, if a project under the `booking` folder is now being shared by multiple apps, you can move it to the shared folder like this:

```shell {% frame="none" %}
```shell
nx g move --project booking-some-project shared/some-project
```

## Remove Generator

Similarly, if you no longer need a project, you can remove it with the [`@nx/workspace:remove` generator](/docs/reference/workspace/generators#remove).

```shell {% frame="none" %}
```shell
nx g remove booking-some-project
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Each executor definition has an `executor` property and, optionally, an `options

Once configured, you can run an executor the same way you would [run any target](/docs/features/run-tasks):

```shell {% frame="none" %}
```shell
nx [command] [project]
nx build cart
```
Expand Down Expand Up @@ -79,7 +79,7 @@ Nx comes with a Devkit that allows you to build your own executor to automate yo

You can use a specific configuration preset like this:

```shell {% frame="none" %}
```shell
nx [command] [project] --configuration=[configuration]
nx build cart --configuration=production
```
Expand Down
6 changes: 3 additions & 3 deletions astro-docs/src/content/docs/concepts/how-caching-works.mdoc
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ results.
Note, only the flags passed to the npm scripts itself affect results of the computation. For instance, the following
commands are identical from the caching perspective.

```shell {% frame="none" %}
```shell
npx nx build remixapp
npx nx run-many -t build -p remixapp
```
Expand All @@ -201,13 +201,13 @@ If you build/test/lint… multiple projects, each individual build has its own h
from
cache or run. This means that from the caching point of view, the following command:

```shell {% frame="none" %}
```shell
npx nx run-many -t build -p header footer
```

is identical to the following two commands:

```shell {% frame="none" %}
```shell
npx nx build header
npx nx build footer
```
Expand Down
2 changes: 1 addition & 1 deletion astro-docs/src/content/docs/concepts/inferred-tasks.mdoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Plugins are processed in the order that they appear in the `plugins` array in `n

To view the task settings for projects in your workspace, [show the project details](/docs/features/explore-graph) either from the command line or using Nx Console.

```shell {% frame="none" %}
```shell
nx show project my-project --web
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ In CI, the sync generator is run in `--dry-run` mode and if files would be chang

Use the project details view to **find registered sync generators** for a given task.

```shell {% frame="none" %}
```shell
nx show project <name>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ There are two different methods that Nx supports for linking TypeScript projects

Create a new Nx workspace that links projects with package manager workspaces:

```shell {% frame="none" %}
```shell
npx create-nx-workspace
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ filter: 'type:Guides'

Let's create a custom rule which we can then publish to Nx Cloud. We will first create a new library project to contain our rule (and any others we might create in the future):

```shell {% frame="none" %}
```shell
nx generate @nx/js:library cloud-conformance-rules
```

The Nx Cloud distribution mechanism expects each rule to be created in a named subdirectory in the `src/` directory of our new project, and each rule directory to contain an `index.ts` and a `schema.json` file. You can read more about [creating a conformance rule](/docs/reference/powerpack/conformance/create-conformance-rule) in the dedicated guide. For this recipe, we'll generate a default rule to use in the publishing process.

```shell {% frame="none" %}
```shell
nx g @nx/conformance:create-rule --name=test-cloud-rule --directory=cloud-conformance-rules/src --category=reliability --description="A test cloud rule" --reporter=non-project-files-reporter
```

Expand Down Expand Up @@ -50,7 +50,7 @@ We can now run `nx build cloud-conformance-rules` to build our rule and create t

Our final step is to publish the rule artifacts to Nx Cloud. We achieve this by running the `publish-conformance-rules` command on the `nx-cloud` CLI, passing the output path location as the first positional argument:

```shell {% frame="none" %}
```shell
nx-cloud publish-conformance-rules cloud-conformance-rules/dist
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ And create a new consumer.

Give the app a name. The callback URL is the important bit. It needs to be in this form:

```
```text
[your-nx-cloud-url]/auth-callback

# for example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ And create a new OAuth app:

Give it a name, and a homepage URL. The authorization callback is the important bit. It needs to be in this form:

```
```text
[your-nx-cloud-url]/auth-callback

# for example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Then "Applications" from the left-hand menu:

Give the app a name. The authorization callback is the important bit. It needs to be in this form:

```
```text
[your-nx-cloud-url]/auth-callback

# for example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ And create a new GitHub app:

Give it a name, and a homepage URL. The callback URL is the important bit. It needs to be in this form:

```
```text
[your-nx-cloud-url]/callbacks/github-user

# for example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ If you are unsure how to proceed, starting with a trial process is recommended,

To register the activation key in your repository, run the `nx register` command.

```shell {% frame="none" %}
```shell
nx register YOUR_ACTIVATION_KEY
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ These packages are used to set up a new project in some form.

Customizing your initial project setup is already possible with an [Nx Preset generator](/docs/extending-nx/create-preset). By creating and shipping a generator named `preset` in your Nx plugin, you can then pass it via the `--preset` flag to the `create-nx-workspace` command:

```shell {% frame="none" %}
```shell
npx create-nx-workspace --preset my-plugin
```

Expand All @@ -29,13 +29,13 @@ There are a few methods to create a package that will work with `create-nx-works

You can setup a new Nx plugin workspace and immediately pass the `--create-package-name`:

```shell {% frame="none" %}
```shell
npx create-nx-plugin my-plugin --create-package-name create-my-plugin
```

Alternatively, if you already have an existing Nx plugin workspace, you can run the following generator to set up a new create package:

```shell {% frame="none" %}
```shell
nx g create-package create-my-plugin --project my-plugin
```

Expand Down Expand Up @@ -118,7 +118,7 @@ _(If you don't have such a `local-registry` target, refer to the following [docs

By running

```shell {% frame="none" %}
```shell
npx nx local-registry
```

Expand All @@ -130,23 +130,23 @@ Note, after terminating the terminal window where the `nx local-registry` comman

Next, you can **publish** your packages to your new local registry. All of the generated packages can use `nx release` to publish whatever is in your `build` output folder, so you can simply run:

```shell {% frame="none" %}
```shell
npx nx run-many --targets build
npx nx release version 1.0.0
npx nx release publish --tag latest
```

Once the packages are published, you should be able to test the behavior of your "create package" as follows:

```shell {% frame="none" %}
```shell
npx create-my-plugin test-workspace
```

## Writing and running e2e tests

When setting up the workspace, you should also have gotten a `my-plugin-e2e` package. This package contains the e2e tests for your plugin, and can be run with the following command:

```shell {% frame="none" %}
```shell
npx nx e2e my-plugin-e2e
```

Expand Down
8 changes: 4 additions & 4 deletions astro-docs/src/content/docs/extending-nx/create-preset.mdoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ All first-party Nx presets are built into Nx itself, but you can [create your ow

To use a concrete example, let's look at the [`qwik-nx`](https://www.npmjs.com/package/qwik-nx) Nx community plugin. They include a [preset generator](https://github.com/qwikifiers/qwik-nx/tree/main/packages/qwik-nx/src/generators/preset) that you can use to create a new Nx workspace with Qwik support.

```shell {% frame="none" %}
```shell
npx create-nx-workspace --preset=qwik-nx
```

## Create a new Nx plugin

If you **don't** have an existing plugin you can create one by running

```shell {% frame="none" %}
```shell
npx create-nx-plugin my-org --pluginName my-plugin
```

## Creating a "Preset" generator

To create our preset inside of our plugin we can run

```shell {% frame="none" %}
```shell
nx generate @nx/plugin:generator packages/happynrwl/src/generators/preset
```

Expand Down Expand Up @@ -104,6 +104,6 @@ Before you are able to use your newly created preset you must package and publis

After you have published your plugin to a registry you can now use your preset when creating a new workspace

```shell {% frame="none" %}
```shell
npx create-nx-workspace my-workspace --preset=my-plugin-name
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ You can create a new sync generator by hand or use the built-in generator that N

Make sure you have `@nx/plugin` installed or add it to your workspace:

```shell {% frame="none" %}
```shell
nx add @nx/plugin
```

### Step 2: Create a local plugin

Create a new local plugin where we can add our new sync generator. You can also add it to an existing local plugin if you already have one. In that case you can skip this step.

```shell {% frame="none" %}
```shell
nx g @nx/plugin:plugin tools/my-plugin
```

### Step 3: Scaffold a new sync generator

Create a sync generator the same way you would [create any generator](/docs/extending-nx/local-generators).

```shell {% frame="none" %}
```shell
nx g @nx/plugin:generator --path=tools/my-plugin/src/generators/my-sync-generator
```

Expand Down Expand Up @@ -181,7 +181,7 @@ For projects using [inferred targets](/docs/concepts/inferred-tasks) (no project
{% aside type="caution" title="Verify the name of your plugin" %}
You might have to adjust the name of your plugin based on your specific workspace scope. Verify the name in `tools/my-plugin/package.json`. If the name there is `@myorg/my-plugin` you have to register it as:

```
```jsonc
{
"syncGenerators": ["@myorg/my-plugin:my-sync-generator"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ nx generate my-generator mylib

The following information will be displayed.

```{% title="nx generate my-generator mylib" %}
```text {% title="nx generate my-generator mylib" %}
CREATE libs/mylib/README.md
CREATE libs/mylib/.babelrc
CREATE libs/mylib/src/index.ts
Expand Down
8 changes: 4 additions & 4 deletions astro-docs/src/content/docs/extending-nx/intro.mdoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ Get started developing your own plugin with a few terminal commands:
{% tabs %}
{% tabitem label="Create a plugin in a new workspace" %}

```shell {% frame="none" %}
```shell
npx create-nx-plugin my-plugin
```

{% /tabitem %}

{% tabitem label="Add a plugin to an existing workspace" %}

```shell {% frame="none" %}
```shell
npx nx add @nx/plugin
npx nx g plugin tools/my-plugin
```
Expand Down Expand Up @@ -59,7 +59,7 @@ You can follow along with one of the step by step tutorials below that is focuse

Wire up a new generator with this terminal command:

```shell {% frame="none" %}
```shell
npx nx g generator my-plugin/src/generators/library-with-readme
```

Expand Down Expand Up @@ -110,7 +110,7 @@ The template files that are used in the `generateFiles` function can inject vari

You can test your generator in dry-run mode with the following command:

```shell {% frame="none" %}
```shell
npx nx g my-plugin:library-with-readme mylib --dry-run
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ This guide shows you how to create, run, and customize executors within your Nx

If you don't already have a plugin, use Nx to generate one:

```shell {% frame="none" %}
```shell
nx add @nx/plugin
nx g @nx/plugin:plugin tools/my-plugin
```

Use the Nx CLI to generate the initial files needed for your executor.

```shell {% frame="none" %}
```shell
nx generate @nx/plugin:executor tools/my-plugin/src/executors/echo
```

Expand Down Expand Up @@ -126,13 +126,13 @@ If your package.json has a different name, adjust the command accordingly.

Finally, you run the executor via the CLI as follows:

```shell {% frame="none" %}
```shell
nx run my-project:echo
```

To which we'll see the console output:

```{% title="nx run my-project:echo" frame="terminal" %}
```text {% title="nx run my-project:echo" frame="terminal" %}
Executing "echo"...
Options: {
"textToEcho": "Hello World"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ caption="Demoes how to use Nx generators in a PNPM workspace to automate the cre

If you don't already have a local plugin, use Nx to generate one:

```shell {% frame="none" %}
```shell
nx add @nx/plugin
nx g @nx/plugin:plugin tools/my-plugin
```
Expand Down Expand Up @@ -101,7 +101,7 @@ The `$default` object is used to read arguments from the command-line that are p

To run a generator, invoke the `nx generate` command with the name of the generator.

```shell {% frame="none" %}
```shell
nx generate @myorg/my-plugin:my-generator mylib
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For this example, we'll create a new migration generator that updates repos to u

### 1. Generate a migration

```shell {% frame="none" %}
```shell
nx generate @nx/plugin:migration libs/pluginName/src/migrations/change-executor-name \
--name='Change Executor Name' \
--packageVersion=2.0.1 \
Expand Down
Loading
Loading