chore(nx-plugin): add examples for generators (#17346)

This commit is contained in:
Craigory Coppola 2023-07-25 18:15:26 -04:00 committed by GitHub
parent 7d1a44bc57
commit 901b70a4fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 90 additions and 16 deletions

View File

@ -7,6 +7,7 @@
"$id": "NxPluginCreatePackage", "$id": "NxPluginCreatePackage",
"title": "Create a framework package", "title": "Create a framework package",
"description": "Create a framework package that uses Nx CLI.", "description": "Create a framework package that uses Nx CLI.",
"examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Basic executable\" %}\n\nCreate an executable that initializes an Nx workspace with {my-plugin}'s preset:\n\n```bash\nnx g @nx/plugin:create-package create-my-plugin --project my-plugin\n```\n\n{% /tab %}\n{% /tabs %}\n",
"type": "object", "type": "object",
"properties": { "properties": {
"name": { "name": {

View File

@ -7,6 +7,7 @@
"$id": "NxPluginE2E", "$id": "NxPluginE2E",
"title": "Create an E2E app for a Nx Plugin", "title": "Create an E2E app for a Nx Plugin",
"description": "Create an E2E app for a Nx Plugin.", "description": "Create an E2E app for a Nx Plugin.",
"examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"E2E Project\" %}\n\nScaffolds an E2E project for the plugin `my-plugin`.\n\n```bash\nnx g @nx/plugin:e2e-project --pluginName my-plugin --npmPackageName my-plugin --pluginOutputPath dist/my-plugin\n```\n\n{% /tab %}\n{% /tabs %}\n",
"type": "object", "type": "object",
"properties": { "properties": {
"pluginName": { "pluginName": {
@ -29,12 +30,6 @@
"x-priority": "important" "x-priority": "important"
}, },
"jestConfig": { "type": "string", "description": "Jest config file." }, "jestConfig": { "type": "string", "description": "Jest config file." },
"standaloneConfig": {
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
"type": "boolean",
"default": true,
"x-deprecated": "Nx only supports standaloneConfig"
},
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",

View File

@ -7,6 +7,7 @@
"$id": "NxPluginExecutor", "$id": "NxPluginExecutor",
"title": "Create an Executor for an Nx Plugin", "title": "Create an Executor for an Nx Plugin",
"description": "Create an Executor for an Nx Plugin.", "description": "Create an Executor for an Nx Plugin.",
"examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Basic executor\" %}\n\nCreate a new executor called `build` inside the plugin `my-plugin`:\n\n```bash\nnx g @nx/plugin:executor build --project my-plugin\n```\n\n{% /tab %}\n{% tab label=\"With custom hashing\" %}\n\nCreate a new executor called `build` inside the plugin `my-plugin`, that uses a custom hashing function:\n\n```bash\nnx g @nx/plugin:executor build --project my-plugin --includeHasher\n```\n\n{% /tab %}\n{% /tabs %}\n",
"type": "object", "type": "object",
"examples": [ "examples": [
{ {

View File

@ -11,7 +11,7 @@
"examples": [ "examples": [
{ {
"command": "nx g migration my-migration --project=my-plugin --version=1.0.0", "command": "nx g migration my-migration --project=my-plugin --version=1.0.0",
"description": "Generate `libs/my-plugin/src/migrations/my-migration`" "description": "Adds a new migration to the project `my-plugin`, which will be triggered when migrating to version 1.0.0 or above from a previous version."
} }
], ],
"properties": { "properties": {

View File

@ -8,6 +8,12 @@
"title": "", "title": "",
"type": "object", "type": "object",
"description": "Adds linting configuration to validate common json files for nx plugins.", "description": "Adds linting configuration to validate common json files for nx plugins.",
"examples": [
{
"command": "nx g @nx/plugin:lint-checks",
"description": "Sets up linting configuration to validate common json files for an nx plugin project."
}
],
"properties": { "properties": {
"projectName": { "projectName": {
"type": "string", "type": "string",

View File

@ -11,7 +11,7 @@
"examples": [ "examples": [
{ {
"command": "nx g plugin my-plugin --directory=plugins --importPath=@myorg/my-plugin", "command": "nx g plugin my-plugin --directory=plugins --importPath=@myorg/my-plugin",
"description": "Generate `libs/plugins/my-plugin`" "description": "Generates an Nx plugin project called `plugins-my-plugin` at `libs/plugins/my-plugin`. The project will have an npm package name and import path of `@myorg/my-plugin`."
} }
], ],
"properties": { "properties": {

View File

@ -7,6 +7,16 @@
"$id": "NxPluginPreset", "$id": "NxPluginPreset",
"title": "Generator ran by create-nx-plugin", "title": "Generator ran by create-nx-plugin",
"description": "Initializes a workspace with an nx-plugin inside of it. Use as: `create-nx-plugin` or `create-nx-workspace --preset @nx/nx-plugin`.", "description": "Initializes a workspace with an nx-plugin inside of it. Use as: `create-nx-plugin` or `create-nx-workspace --preset @nx/nx-plugin`.",
"examples": [
{
"command": "npx create-nx-plugin",
"description": "Creates a new Nx workspace containing an Nx plugin."
},
{
"command": "npx create-nx-workspace --preset @nx/plugin",
"description": "Creates a new Nx workspace containing an Nx plugin."
}
],
"type": "object", "type": "object",
"properties": { "properties": {
"pluginName": { "pluginName": {

View File

@ -0,0 +1,13 @@
## Examples
{% tabs %}
{% tab label="Basic executable" %}
Create an executable that initializes an Nx workspace with {my-plugin}'s preset:
```bash
nx g @nx/plugin:create-package create-my-plugin --project my-plugin
```
{% /tab %}
{% /tabs %}

View File

@ -0,0 +1,13 @@
## Examples
{% tabs %}
{% tab label="E2E Project" %}
Scaffolds an E2E project for the plugin `my-plugin`.
```bash
nx g @nx/plugin:e2e-project --pluginName my-plugin --npmPackageName my-plugin --pluginOutputPath dist/my-plugin
```
{% /tab %}
{% /tabs %}

View File

@ -0,0 +1,22 @@
## Examples
{% tabs %}
{% tab label="Basic executor" %}
Create a new executor called `build` inside the plugin `my-plugin`:
```bash
nx g @nx/plugin:executor build --project my-plugin
```
{% /tab %}
{% tab label="With custom hashing" %}
Create a new executor called `build` inside the plugin `my-plugin`, that uses a custom hashing function:
```bash
nx g @nx/plugin:executor build --project my-plugin --includeHasher
```
{% /tab %}
{% /tabs %}

View File

@ -4,6 +4,7 @@
"$id": "NxPluginCreatePackage", "$id": "NxPluginCreatePackage",
"title": "Create a framework package", "title": "Create a framework package",
"description": "Create a framework package that uses Nx CLI.", "description": "Create a framework package that uses Nx CLI.",
"examplesFile": "../../../docs/generators/create-package-examples.md",
"type": "object", "type": "object",
"properties": { "properties": {
"name": { "name": {

View File

@ -4,6 +4,7 @@
"$id": "NxPluginE2E", "$id": "NxPluginE2E",
"title": "Create an E2E app for a Nx Plugin", "title": "Create an E2E app for a Nx Plugin",
"description": "Create an E2E app for a Nx Plugin.", "description": "Create an E2E app for a Nx Plugin.",
"examplesFile": "../../../docs/generators/e2e-project-examples.md",
"type": "object", "type": "object",
"properties": { "properties": {
"pluginName": { "pluginName": {
@ -29,12 +30,6 @@
"type": "string", "type": "string",
"description": "Jest config file." "description": "Jest config file."
}, },
"standaloneConfig": {
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
"type": "boolean",
"default": true,
"x-deprecated": "Nx only supports standaloneConfig"
},
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",

View File

@ -4,6 +4,7 @@
"$id": "NxPluginExecutor", "$id": "NxPluginExecutor",
"title": "Create an Executor for an Nx Plugin", "title": "Create an Executor for an Nx Plugin",
"description": "Create an Executor for an Nx Plugin.", "description": "Create an Executor for an Nx Plugin.",
"examplesFile": "../../../docs/generators/executor-examples.md",
"type": "object", "type": "object",
"examples": [ "examples": [
{ {

View File

@ -5,6 +5,12 @@
"title": "", "title": "",
"type": "object", "type": "object",
"description": "Adds linting configuration to validate common json files for nx plugins.", "description": "Adds linting configuration to validate common json files for nx plugins.",
"examples": [
{
"command": "nx g @nx/plugin:lint-checks",
"description": "Sets up linting configuration to validate common json files for an nx plugin project."
}
],
"properties": { "properties": {
"projectName": { "projectName": {
"type": "string", "type": "string",

View File

@ -8,7 +8,7 @@
"examples": [ "examples": [
{ {
"command": "nx g migration my-migration --project=my-plugin --version=1.0.0", "command": "nx g migration my-migration --project=my-plugin --version=1.0.0",
"description": "Generate `libs/my-plugin/src/migrations/my-migration`" "description": "Adds a new migration to the project `my-plugin`, which will be triggered when migrating to version 1.0.0 or above from a previous version."
} }
], ],
"properties": { "properties": {

View File

@ -8,7 +8,7 @@
"examples": [ "examples": [
{ {
"command": "nx g plugin my-plugin --directory=plugins --importPath=@myorg/my-plugin", "command": "nx g plugin my-plugin --directory=plugins --importPath=@myorg/my-plugin",
"description": "Generate `libs/plugins/my-plugin`" "description": "Generates an Nx plugin project called `plugins-my-plugin` at `libs/plugins/my-plugin`. The project will have an npm package name and import path of `@myorg/my-plugin`."
} }
], ],
"properties": { "properties": {

View File

@ -4,6 +4,16 @@
"$id": "NxPluginPreset", "$id": "NxPluginPreset",
"title": "Generator ran by create-nx-plugin", "title": "Generator ran by create-nx-plugin",
"description": "Initializes a workspace with an nx-plugin inside of it. Use as: `create-nx-plugin` or `create-nx-workspace --preset @nx/nx-plugin`.", "description": "Initializes a workspace with an nx-plugin inside of it. Use as: `create-nx-plugin` or `create-nx-workspace --preset @nx/nx-plugin`.",
"examples": [
{
"command": "npx create-nx-plugin",
"description": "Creates a new Nx workspace containing an Nx plugin."
},
{
"command": "npx create-nx-workspace --preset @nx/plugin",
"description": "Creates a new Nx workspace containing an Nx plugin."
}
],
"type": "object", "type": "object",
"properties": { "properties": {
"pluginName": { "pluginName": {