diff --git a/docs/generated/manifests/menus.json b/docs/generated/manifests/menus.json index 4a9a52d5f7..19c574ba4a 100644 --- a/docs/generated/manifests/menus.json +++ b/docs/generated/manifests/menus.json @@ -5520,23 +5520,6 @@ "isExternal": false, "disableCollapsible": false }, - { - "id": "executors", - "path": "/packages/node/executors", - "name": "executors", - "children": [ - { - "id": "node", - "path": "/packages/node/executors/node", - "name": "node", - "children": [], - "isExternal": false, - "disableCollapsible": false - } - ], - "isExternal": false, - "disableCollapsible": false - }, { "id": "generators", "path": "/packages/node/generators", diff --git a/docs/generated/manifests/packages.json b/docs/generated/manifests/packages.json index b978288245..f8117f2c94 100644 --- a/docs/generated/manifests/packages.json +++ b/docs/generated/manifests/packages.json @@ -1451,12 +1451,12 @@ "githubRoot": "https://github.com/nrwl/nx/blob/master", "name": "node", "packageName": "@nx/node", - "description": "The Node Plugin for Nx contains generators and executors to manage Node applications within an Nx workspace.", + "description": "The Node Plugin for Nx contains generators to manage Node applications within an Nx workspace.", "documents": { "/packages/node/documents/overview": { "id": "overview", "name": "Overview", - "description": "The Node Plugin for Nx contains generators and executors to manage Node applications within an Nx workspace.", + "description": "The Node Plugin for Nx contains generators to manage Node applications within an Nx workspace.", "file": "generated/packages/node/documents/overview", "itemList": [], "isExternal": false, @@ -1467,17 +1467,7 @@ }, "root": "/packages/node", "source": "/packages/node/src", - "executors": { - "/packages/node/executors/node": { - "description": "Execute a Node application.", - "file": "generated/packages/node/executors/node.json", - "hidden": false, - "name": "node", - "originalFilePath": "/packages/node/src/executors/node/schema.json", - "path": "/packages/node/executors/node", - "type": "executor" - } - }, + "executors": {}, "generators": { "/packages/node/generators/init": { "description": "Initialize the `@nrwl/node` plugin.", diff --git a/docs/generated/packages-metadata.json b/docs/generated/packages-metadata.json index 13950283cd..406d9b0d5d 100644 --- a/docs/generated/packages-metadata.json +++ b/docs/generated/packages-metadata.json @@ -1433,12 +1433,12 @@ "source": "/packages/next/src" }, { - "description": "The Node Plugin for Nx contains generators and executors to manage Node applications within an Nx workspace.", + "description": "The Node Plugin for Nx contains generators to manage Node applications within an Nx workspace.", "documents": [ { "id": "overview", "name": "Overview", - "description": "The Node Plugin for Nx contains generators and executors to manage Node applications within an Nx workspace.", + "description": "The Node Plugin for Nx contains generators to manage Node applications within an Nx workspace.", "file": "generated/packages/node/documents/overview", "itemList": [], "isExternal": false, @@ -1447,17 +1447,7 @@ "originalFilePath": "shared/packages/node/node-plugin" } ], - "executors": [ - { - "description": "Execute a Node application.", - "file": "generated/packages/node/executors/node.json", - "hidden": false, - "name": "node", - "originalFilePath": "/packages/node/src/executors/node/schema.json", - "path": "node/executors/node", - "type": "executor" - } - ], + "executors": [], "generators": [ { "description": "Initialize the `@nrwl/node` plugin.", diff --git a/nx-dev/nx-dev-e2e/src/e2e/packages.cy.ts b/nx-dev/nx-dev-e2e/src/e2e/packages.cy.ts index 010e17bc42..09fabfffe0 100644 --- a/nx-dev/nx-dev-e2e/src/e2e/packages.cy.ts +++ b/nx-dev/nx-dev-e2e/src/e2e/packages.cy.ts @@ -259,7 +259,6 @@ describe('nx-dev: Packages Section', () => { path: '/packages/node/generators/application', }, { title: '@nx/node:library', path: '/packages/node/generators/library' }, - { title: '@nx/node:node', path: '/packages/node/executors/node' }, { title: 'nx', path: '/packages/nx' }, { title: 'nx:noop', path: '/packages/nx/executors/noop' }, { diff --git a/packages/node/.eslintrc.json b/packages/node/.eslintrc.json index 6f3e8402b8..0b6554fa77 100644 --- a/packages/node/.eslintrc.json +++ b/packages/node/.eslintrc.json @@ -29,12 +29,7 @@ } }, { - "files": [ - "./package.json", - "./generators.json", - "./executors.json", - "./migrations.json" - ], + "files": ["./package.json", "./generators.json", "./migrations.json"], "parser": "jsonc-eslint-parser", "rules": { "@nx/nx-plugin-checks": "error" diff --git a/packages/node/executors.json b/packages/node/executors.json deleted file mode 100644 index 92934806b1..0000000000 --- a/packages/node/executors.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "executors": { - "node": { - "implementation": "./src/executors/node/node.impl", - "schema": "./src/executors/node/schema.json", - "description": "Execute a Node application." - } - }, - "builders": { - "node": { - "implementation": "./src/executors/node/compat", - "schema": "./src/executors/node/schema.json", - "description": "Execute a Node application." - } - } -} diff --git a/packages/node/migrations.json b/packages/node/migrations.json index 2ae3063819..6c316e6f82 100644 --- a/packages/node/migrations.json +++ b/packages/node/migrations.json @@ -47,6 +47,12 @@ "version": "16.3.1-beta.0", "description": "Replace @nx/node:webpack with @nx/node:webpack for all project targets", "implementation": "./src/migrations/update-16-3-1/update-webpack-executor" + }, + "update-16-4-0-replace-node-executor": { + "cli": "nx", + "version": "16.4.0-beta.8", + "description": "Replace @nx/node:node with @nx/js:node for all project targets", + "implementation": "./src/migrations/update-16-4-0/replace-node-executor" } }, "packageJsonUpdates": { diff --git a/packages/node/package.json b/packages/node/package.json index d17ade5156..e7d94a1a38 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -2,7 +2,7 @@ "name": "@nx/node", "version": "0.0.1", "private": false, - "description": "The Node Plugin for Nx contains generators and executors to manage Node applications within an Nx workspace.", + "description": "The Node Plugin for Nx contains generators to manage Node applications within an Nx workspace.", "repository": { "type": "git", "url": "https://github.com/nrwl/nx.git", @@ -25,7 +25,6 @@ }, "homepage": "https://nx.dev", "schematics": "./generators.json", - "builders": "./executors.json", "ng-update": { "requirements": {}, "migrations": "./migrations.json" diff --git a/packages/node/src/executors/node/compat.ts b/packages/node/src/executors/node/compat.ts deleted file mode 100644 index 03735e668e..0000000000 --- a/packages/node/src/executors/node/compat.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { convertNxExecutor } from '@nx/devkit'; -import nodeExecutor from './node.impl'; - -export default convertNxExecutor(nodeExecutor); diff --git a/packages/node/src/executors/node/node.impl.ts b/packages/node/src/executors/node/node.impl.ts deleted file mode 100644 index 4ecf31b26b..0000000000 --- a/packages/node/src/executors/node/node.impl.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ExecutorContext } from '@nx/devkit'; -import type { NodeExecutorOptions } from '@nx/js/src/executors/node/schema'; -import { nodeExecutor as jsNodeExecutor } from '@nx/js/src/executors/node/node.impl'; - -// TODO(jack): Remove for Nx 16 -export async function* nodeExecutor( - options: NodeExecutorOptions, - context: ExecutorContext -) { - yield* jsNodeExecutor(options, context); -} - -export default nodeExecutor; diff --git a/packages/node/src/executors/node/schema.json b/packages/node/src/executors/node/schema.json deleted file mode 100644 index 288313b4d6..0000000000 --- a/packages/node/src/executors/node/schema.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "version": 2, - "outputCapture": "direct-nodejs", - "$schema": "http://json-schema.org/schema", - "cli": "nx", - "title": "Node executor", - "description": "Execute Nodejs applications.", - "type": "object", - "properties": { - "buildTarget": { - "type": "string", - "description": "The target to run to build you the app." - }, - "buildTargetOptions": { - "type": "object", - "description": "Additional options to pass into the build target.", - "default": {} - }, - "waitUntilTargets": { - "type": "array", - "description": "The targets to run before starting the node app.", - "default": [], - "items": { - "type": "string" - } - }, - "host": { - "type": "string", - "default": "localhost", - "description": "The host to inspect the process on." - }, - "port": { - "type": "number", - "default": 9229, - "description": "The port to inspect the process on. Setting port to 0 will assign random free ports to all forked processes." - }, - "inspect": { - "oneOf": [ - { - "type": "string", - "enum": ["inspect", "inspect-brk"] - }, - { - "type": "boolean" - } - ], - "description": "Ensures the app is starting with debugging.", - "default": "inspect" - }, - "runtimeArgs": { - "type": "array", - "description": "Extra args passed to the node process.", - "default": [], - "items": { - "type": "string" - } - }, - "args": { - "type": "array", - "description": "Extra args when starting the app.", - "default": [], - "items": { - "type": "string" - } - }, - "watch": { - "type": "boolean", - "description": "Enable re-building when files change.", - "default": true - } - }, - "additionalProperties": false, - "required": ["buildTarget"] -} diff --git a/packages/node/src/migrations/update-16-4-0/replace-node-executor.spec.ts b/packages/node/src/migrations/update-16-4-0/replace-node-executor.spec.ts new file mode 100644 index 0000000000..3e947bf22c --- /dev/null +++ b/packages/node/src/migrations/update-16-4-0/replace-node-executor.spec.ts @@ -0,0 +1,79 @@ +import { addProjectConfiguration, readProjectConfiguration } from '@nx/devkit'; +import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; +import update from './replace-node-executor'; + +describe('Migration: replace @nx/node:node executor', () => { + it(`should replace @nx/node:node executor with @nx/js:node`, async () => { + let tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' }); + + addProjectConfiguration(tree, 'myapp', { + root: 'apps/myapp', + sourceRoot: 'apps/myapp/src', + projectType: 'application', + targets: { + foo: { + executor: '@nx/node:node', + options: {}, + }, + bar: { + executor: '@nx/node:node', + options: {}, + }, + }, + }); + + addProjectConfiguration(tree, 'myapp2', { + root: 'apps/myapp2', + sourceRoot: 'apps/myapp2/src', + projectType: 'application', + targets: { + foo: { + executor: '@nx/node:node', + options: {}, + }, + bar: { + executor: '@nx/node:node', + options: {}, + }, + }, + }); + + await update(tree); + + expect(readProjectConfiguration(tree, 'myapp')).toEqual({ + $schema: '../../node_modules/nx/schemas/project-schema.json', + name: 'myapp', + root: 'apps/myapp', + sourceRoot: 'apps/myapp/src', + projectType: 'application', + targets: { + foo: { + executor: '@nx/js:node', + options: {}, + }, + bar: { + executor: '@nx/js:node', + options: {}, + }, + }, + }); + + expect(readProjectConfiguration(tree, 'myapp2')).toEqual({ + $schema: '../../node_modules/nx/schemas/project-schema.json', + name: 'myapp2', + root: 'apps/myapp2', + sourceRoot: 'apps/myapp2/src', + projectType: 'application', + targets: { + foo: { + executor: '@nx/js:node', + options: {}, + }, + bar: { + executor: '@nx/js:node', + options: {}, + }, + }, + }); + }); +}); diff --git a/packages/node/src/migrations/update-16-4-0/replace-node-executor.ts b/packages/node/src/migrations/update-16-4-0/replace-node-executor.ts new file mode 100644 index 0000000000..950413dea1 --- /dev/null +++ b/packages/node/src/migrations/update-16-4-0/replace-node-executor.ts @@ -0,0 +1,19 @@ +import { + formatFiles, + readProjectConfiguration, + Tree, + updateProjectConfiguration, +} from '@nx/devkit'; +import { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils'; + +export default async function update(tree: Tree) { + const migrateProject = (_options, projectName, targetName) => { + const projectConfig = readProjectConfiguration(tree, projectName); + projectConfig.targets[targetName].executor = '@nx/js:node'; + updateProjectConfiguration(tree, projectName, projectConfig); + }; + + forEachExecutorOptions(tree, '@nx/node:node', migrateProject); + + await formatFiles(tree); +}