diff --git a/docs/nx-cloud/enterprise/conformance/publish-conformance-rules-to-nx-cloud.md b/docs/nx-cloud/enterprise/conformance/publish-conformance-rules-to-nx-cloud.md index beb544cd3f..e2213d709c 100644 --- a/docs/nx-cloud/enterprise/conformance/publish-conformance-rules-to-nx-cloud.md +++ b/docs/nx-cloud/enterprise/conformance/publish-conformance-rules-to-nx-cloud.md @@ -11,16 +11,21 @@ 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](/nx-api/powerpack-conformance/documents/create-conformance-rule) in the dedicated guide. For this recipe, we'll generate a default rule to use in the publishing process. ```shell -nx g @nx/powerpack-conformance:create-rule --name=test-cloud-rule --directory=cloud-conformance-rules/src/test-cloud-rule --category=reliability --description="A test cloud rule" --reporter=non-project-files-reporter +nx g @nx/powerpack-conformance:create-rule --name=test-cloud-rule --directory=cloud-conformance-rules/src --category=reliability --description="A test cloud rule" --reporter=non-project-files-reporter ``` -We now have a valid implementation of a rule and we are ready to build it and publish it to Nx Cloud. The [`@nx/powerpack-conformance` plugin](/nx-api/powerpack-conformance) provides a [dedicated executor called `bundle-rules`](/nx-api/powerpack-conformance/executors/bundle-rules) for creating appropriate build artifacts for this purpose, so we will wire that executor up to a new build target in our `cloud-conformance-rules` project's `project.json` file: +{% callout type="warning" title="Adding the @nx/powerpack-conformance plugin" %} +If you get an error resolving the `@nx/powerpack-conformance` plugin, you may need to add it. You can do this by running `nx add @nx/powerpack-conformance` in your workspace. +{% /callout %} + +We now have a valid implementation of a rule and we are ready to build it and publish it to Nx Cloud. The [`@nx/powerpack-conformance` plugin](/nx-api/powerpack-conformance) provides a [dedicated executor called `bundle-rules`](/nx-api/powerpack-conformance/executors/bundle-rules) for creating appropriate build artifacts for this purpose. We will replace the existing build target and wire up that executor in our `cloud-conformance-rules` project's `project.json` file: ```jsonc {% fileName="cloud-conformance-rules/project.json" %} { // ...any existing project.json content "targets": { - // ...any existing targets + // ...any other existing targets + // new build target: "build": { "executor": "@nx/powerpack-conformance:bundle-rules", "outputs": ["{options.outputPath}"], @@ -32,6 +37,10 @@ We now have a valid implementation of a rule and we are ready to build it and pu } ``` +{% callout type="note" %} +Remove the existing `lib` directory within the `cloud-conformance-rules` project, as it is no longer needed. Each rule will have its own directory, which is generated by the `create-rule` generator, and will need to always have `index.ts` and `schema.json` files. +{% /callout %} + We can now run `nx build cloud-conformance-rules` to build our rule and create the build artifacts in the `cloud-conformance-rules/dist` directory (or wherever you prefer to configure that `outputPath` location). If we take a look at the output path location we will see the same structure of one named subdirectory per rule, now containing the (bundled) `index.js` and `schema.json` files. 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: