feat(misc): remove derived generator paths (#27714)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #

---------

Co-authored-by: Nicholas Cunningham <ndcunningham@gmail.com>
This commit is contained in:
Leosvel Pérez Espinosa 2024-09-23 15:19:42 +02:00 committed by GitHub
parent 5216f7aac4
commit c92528f65d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
435 changed files with 1614 additions and 8550 deletions

View File

@ -1,6 +1,6 @@
{
"name": "application",
"factory": "./src/generators/application/application#applicationGeneratorInternal",
"factory": "./src/generators/application/application",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "GeneratorNxApp",
@ -191,7 +191,7 @@
"aliases": ["app"],
"x-type": "application",
"description": "Creates an Angular application.",
"implementation": "/packages/angular/src/generators/application/application#applicationGeneratorInternal.ts",
"implementation": "/packages/angular/src/generators/application/application.ts",
"hidden": false,
"path": "/packages/angular/src/generators/application/schema.json",
"type": "generator"

View File

@ -1,6 +1,6 @@
{
"name": "component",
"factory": "./src/generators/component/component#componentGeneratorInternal",
"factory": "./src/generators/component/component",
"schema": {
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "SchematicsAngularComponent",
@ -27,13 +27,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"type": "string",
"description": "The name of the project.",
"$default": { "$source": "projectName" },
"x-dropdown": "projects",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
},
"prefix": {
"type": "string",
"description": "The prefix to apply to the generated component selector.",
@ -92,12 +85,6 @@
"description": "Do not create `spec.ts` test files for the new component.",
"default": false
},
"flat": {
"type": "boolean",
"description": "Create the new files at the top level of the current project.",
"default": false,
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20."
},
"skipImport": {
"type": "boolean",
"description": "Do not import this component into the owning NgModule.",
@ -137,7 +124,7 @@
},
"aliases": ["c"],
"description": "Generate an Angular Component.",
"implementation": "/packages/angular/src/generators/component/component#componentGeneratorInternal.ts",
"implementation": "/packages/angular/src/generators/component/component.ts",
"hidden": false,
"path": "/packages/angular/src/generators/component/schema.json",
"type": "generator"

View File

@ -1,6 +1,6 @@
{
"name": "cypress-component-configuration",
"factory": "./src/generators/cypress-component-configuration/cypress-component-configuration#cypressComponentConfigurationInternal",
"factory": "./src/generators/cypress-component-configuration/cypress-component-configuration",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxAngularCypressComponentConfigurationGenerator",
@ -41,7 +41,7 @@
"presets": []
},
"description": "Setup Cypress component testing for a project.",
"implementation": "/packages/angular/src/generators/cypress-component-configuration/cypress-component-configuration#cypressComponentConfigurationInternal.ts",
"implementation": "/packages/angular/src/generators/cypress-component-configuration/cypress-component-configuration.ts",
"aliases": [],
"hidden": false,
"path": "/packages/angular/src/generators/cypress-component-configuration/schema.json",

View File

@ -27,13 +27,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"type": "string",
"description": "The name of the project.",
"$default": { "$source": "projectName" },
"x-dropdown": "projects",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
},
"prefix": {
"type": "string",
"description": "A prefix to apply to generated selectors.",
@ -63,12 +56,6 @@
"type": "boolean",
"default": true
},
"flat": {
"type": "boolean",
"description": "When true (the default), creates the new files at the top level of the current project.",
"default": true,
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20."
},
"module": {
"type": "string",
"description": "The filename of the declaring NgModule.",

View File

@ -1,6 +1,6 @@
{
"name": "host",
"factory": "./src/generators/host/host#hostInternal",
"factory": "./src/generators/host/host",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxMFHost",
@ -183,7 +183,7 @@
},
"x-type": "application",
"description": "Generate a Host Angular Module Federation Application.",
"implementation": "/packages/angular/src/generators/host/host#hostInternal.ts",
"implementation": "/packages/angular/src/generators/host/host.ts",
"aliases": [],
"hidden": false,
"path": "/packages/angular/src/generators/host/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "library",
"factory": "./src/generators/library/library#libraryGeneratorInternal",
"factory": "./src/generators/library/library",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "GeneratorAngularLibrary",
@ -210,7 +210,7 @@
"aliases": ["lib"],
"x-type": "library",
"description": "Creates an Angular library.",
"implementation": "/packages/angular/src/generators/library/library#libraryGeneratorInternal.ts",
"implementation": "/packages/angular/src/generators/library/library.ts",
"hidden": false,
"path": "/packages/angular/src/generators/library/schema.json",
"type": "generator"

View File

@ -1,6 +1,6 @@
{
"name": "move",
"factory": "./src/generators/move/move#angularMoveGeneratorInternal",
"factory": "./src/generators/move/move#angularMoveGenerator",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxAngularMove",
@ -63,7 +63,7 @@
"aliases": ["mv"],
"description": "Moves an Angular application or library to another folder within the workspace and updates the project configuration.",
"x-deprecated": "Use the `@nx/workspace:move` generator instead. This generator will be removed in Nx v19.",
"implementation": "/packages/angular/src/generators/move/move#angularMoveGeneratorInternal.ts",
"implementation": "/packages/angular/src/generators/move/move#angularMoveGenerator.ts",
"hidden": false,
"path": "/packages/angular/src/generators/move/schema.json",
"type": "generator"

View File

@ -34,12 +34,6 @@
"x-dropdown": "projects",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
},
"flat": {
"type": "boolean",
"default": true,
"description": "When true (the default) creates files at the top level of the project.",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20."
},
"skipTests": {
"type": "boolean",
"description": "Do not create \"spec.ts\" test files for the new pipe.",

View File

@ -1,6 +1,6 @@
{
"name": "remote",
"factory": "./src/generators/remote/remote#remoteInternal",
"factory": "./src/generators/remote/remote",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxMFRemote",
@ -176,7 +176,7 @@
},
"x-type": "application",
"description": "Generate a Remote Angular Module Federation Application.",
"implementation": "/packages/angular/src/generators/remote/remote#remoteInternal.ts",
"implementation": "/packages/angular/src/generators/remote/remote.ts",
"aliases": [],
"hidden": false,
"path": "/packages/angular/src/generators/remote/schema.json",

View File

@ -88,12 +88,6 @@
"default": true,
"x-priority": "important"
},
"flat": {
"type": "boolean",
"description": "Create the new files at the top level of the current project.",
"default": false,
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20."
},
"selector": {
"type": "string",
"format": "html-selector",

View File

@ -1,6 +1,6 @@
{
"name": "component",
"factory": "./src/generators/component/component#expoComponentGeneratorInternal",
"factory": "./src/generators/component/component",
"schema": {
"cli": "nx",
"$id": "NxExpoComponent",
@ -9,22 +9,15 @@
"type": "object",
"examples": [
{
"command": "g @nx/expo:component my-component --project=mylib",
"command": "g @nx/expo:component my-component --directory=mylib/my-component",
"description": "Generate a component in the mylib library"
},
{
"command": "g @nx/expo:component my-component --project=mylib --classComponent",
"command": "g @nx/expo:component my-component --directory=mylib/my-component --classComponent",
"description": "Generate a class component in the mylib library"
}
],
"properties": {
"project": {
"type": "string",
"description": "The name of the project.",
"alias": "p",
"$default": { "$source": "projectName" },
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
},
"name": {
"type": "string",
"description": "The name of the component.",
@ -57,12 +50,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"flat": {
"type": "boolean",
"description": "Create component at the source root rather than its own directory.",
"default": false,
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19."
},
"export": {
"type": "boolean",
"description": "When true, the component is exported from the project index.ts (if it exists).",
@ -70,13 +57,6 @@
"default": false,
"x-prompt": "Should this component be exported in the project?"
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case component file name (e.g. App.tsx).",
"alias": "P",
"default": false,
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
},
"classComponent": {
"type": "boolean",
"alias": "C",
@ -89,7 +69,7 @@
},
"description": "Create a component",
"aliases": ["c"],
"implementation": "/packages/expo/src/generators/component/component#expoComponentGeneratorInternal.ts",
"implementation": "/packages/expo/src/generators/component/component.ts",
"hidden": false,
"path": "/packages/expo/src/generators/component/schema.json",
"type": "generator"

View File

@ -60,12 +60,6 @@
"description": "Do not update tsconfig.json for development experience.",
"x-priority": "internal"
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case component file name (e.g. App.tsx).",
"alias": "P",
"default": false
},
"publishable": {
"type": "boolean",
"description": "Create a publishable library."

View File

@ -66,12 +66,6 @@
"default": false,
"x-deprecated": "Use --swcJest instead for faster compilation"
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case file names.",
"alias": "P",
"default": false
},
"js": {
"type": "boolean",
"description": "Generate JavaScript files rather than TypeScript files.",

View File

@ -70,12 +70,6 @@
"description": "The test environment to use if unitTestRunner is set to jest or vitest.",
"default": "node"
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case file names.",
"alias": "P",
"default": false
},
"js": {
"type": "boolean",
"description": "Generate JavaScript files rather than TypeScript files.",

View File

@ -1,6 +1,6 @@
{
"name": "class",
"factory": "./src/generators/class/class#classGeneratorInternal",
"factory": "./src/generators/class/class",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestClassGenerator",
@ -61,7 +61,7 @@
"presets": []
},
"description": "Run the `class` NestJS generator with Nx project support.",
"implementation": "/packages/nest/src/generators/class/class#classGeneratorInternal.ts",
"implementation": "/packages/nest/src/generators/class/class.ts",
"aliases": [],
"hidden": false,
"path": "/packages/nest/src/generators/class/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "controller",
"factory": "./src/generators/controller/controller#controllerGeneratorInternal",
"factory": "./src/generators/controller/controller",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestControllerGenerator",
@ -15,13 +15,6 @@
"$default": { "$source": "argv", "index": 0 },
"x-prompt": "What name would you like to use?"
},
"project": {
"description": "The Nest project to target.",
"type": "string",
"$default": { "$source": "projectName" },
"alias": "p",
"x-deprecated": "Provide The `directory` option instead and use the `as-provided` format. the project will be determined from the directory provided. It will be removed in Nx v20."
},
"nameAndDirectoryFormat": {
"description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
"type": "string",
@ -44,12 +37,6 @@
"enum": ["jest", "none"],
"default": "jest"
},
"flat": {
"description": "Flag to indicate if a directory is created.",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.",
"type": "boolean",
"default": false
},
"language": {
"description": "Nest controller language.",
"type": "string",
@ -70,7 +57,7 @@
"presets": []
},
"description": "Run the `controller` NestJS generator with Nx project support.",
"implementation": "/packages/nest/src/generators/controller/controller#controllerGeneratorInternal.ts",
"implementation": "/packages/nest/src/generators/controller/controller.ts",
"aliases": [],
"hidden": false,
"path": "/packages/nest/src/generators/controller/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "decorator",
"factory": "./src/generators/decorator/decorator#decoratorGeneratorInternal",
"factory": "./src/generators/decorator/decorator",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestDecoratorGenerator",
@ -20,13 +20,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"description": "The Nest project to target.",
"type": "string",
"$default": { "$source": "projectName" },
"alias": "p",
"x-deprecated": "Provide The `directory` option instead and use the `as-provided` format. the project will be determined from the directory provided. It will be removed in Nx v20."
},
"directory": {
"description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
"type": "string",
@ -38,12 +31,6 @@
"default": false,
"x-priority": "internal"
},
"flat": {
"description": "Flag to indicate if a directory is created.",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.",
"type": "boolean",
"default": true
},
"language": {
"description": "Nest decorator language.",
"type": "string",
@ -55,7 +42,7 @@
"presets": []
},
"description": "Run the `decorator` NestJS generator with Nx project support.",
"implementation": "/packages/nest/src/generators/decorator/decorator#decoratorGeneratorInternal.ts",
"implementation": "/packages/nest/src/generators/decorator/decorator.ts",
"aliases": [],
"hidden": false,
"path": "/packages/nest/src/generators/decorator/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "filter",
"factory": "./src/generators/filter/filter#filterGeneratorInternal",
"factory": "./src/generators/filter/filter",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestFilterGenerator",
@ -20,13 +20,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"description": "The Nest project to target.",
"type": "string",
"$default": { "$source": "projectName" },
"alias": "p",
"x-deprecated": "Provide The `directory` option instead and use the `as-provided` format. the project will be determined from the directory provided. It will be removed in Nx v20."
},
"directory": {
"description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
"type": "string",
@ -44,12 +37,6 @@
"enum": ["jest", "none"],
"default": "jest"
},
"flat": {
"description": "Flag to indicate if a directory is created.",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.",
"type": "boolean",
"default": true
},
"language": {
"description": "Nest filter language.",
"type": "string",
@ -61,7 +48,7 @@
"presets": []
},
"description": "Run the `filter` NestJS generator with Nx project support.",
"implementation": "/packages/nest/src/generators/filter/filter#filterGeneratorInternal.ts",
"implementation": "/packages/nest/src/generators/filter/filter.ts",
"aliases": [],
"hidden": false,
"path": "/packages/nest/src/generators/filter/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "gateway",
"factory": "./src/generators/gateway/gateway#gatewayGeneratorInternal",
"factory": "./src/generators/gateway/gateway",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestGatewayGenerator",
@ -20,13 +20,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"description": "The Nest project to target.",
"type": "string",
"$default": { "$source": "projectName" },
"alias": "p",
"x-deprecated": "Provide The `directory` option instead and use the `as-provided` format. the project will be determined from the directory provided. It will be removed in Nx v20."
},
"directory": {
"description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
"type": "string",
@ -44,12 +37,6 @@
"enum": ["jest", "none"],
"default": "jest"
},
"flat": {
"description": "Flag to indicate if a directory is created.",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.",
"type": "boolean",
"default": true
},
"language": {
"description": "Nest gateway language.",
"type": "string",
@ -61,7 +48,7 @@
"presets": []
},
"description": "Run the `gateway` NestJS generator with Nx project support.",
"implementation": "/packages/nest/src/generators/gateway/gateway#gatewayGeneratorInternal.ts",
"implementation": "/packages/nest/src/generators/gateway/gateway.ts",
"aliases": [],
"hidden": false,
"path": "/packages/nest/src/generators/gateway/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "guard",
"factory": "./src/generators/guard/guard#guardGeneratorInternal",
"factory": "./src/generators/guard/guard",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestGuardGenerator",
@ -20,13 +20,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"description": "The Nest project to target.",
"type": "string",
"$default": { "$source": "projectName" },
"alias": "p",
"x-deprecated": "Provide The `directory` option instead and use the `as-provided` format. the project will be determined from the directory provided. It will be removed in Nx v20."
},
"directory": {
"description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
"type": "string",
@ -44,12 +37,6 @@
"enum": ["jest", "none"],
"default": "jest"
},
"flat": {
"description": "Flag to indicate if a directory is created.",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.",
"type": "boolean",
"default": true
},
"language": {
"description": "Nest guard language.",
"type": "string",
@ -61,7 +48,7 @@
"presets": []
},
"description": "Run the `guard` NestJS generator with Nx project support.",
"implementation": "/packages/nest/src/generators/guard/guard#guardGeneratorInternal.ts",
"implementation": "/packages/nest/src/generators/guard/guard.ts",
"aliases": [],
"hidden": false,
"path": "/packages/nest/src/generators/guard/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "interceptor",
"factory": "./src/generators/interceptor/interceptor#interceptorGeneratorInternal",
"factory": "./src/generators/interceptor/interceptor",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestInterceptorGenerator",
@ -20,13 +20,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"description": "The Nest project to target.",
"type": "string",
"$default": { "$source": "projectName" },
"alias": "p",
"x-deprecated": "Provide The `directory` option instead and use the `as-provided` format. the project will be determined from the directory provided. It will be removed in Nx v20."
},
"directory": {
"description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
"type": "string",
@ -44,12 +37,6 @@
"enum": ["jest", "none"],
"default": "jest"
},
"flat": {
"description": "Flag to indicate if a directory is created.",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.",
"type": "boolean",
"default": true
},
"language": {
"description": "Nest interceptor language.",
"type": "string",
@ -61,7 +48,7 @@
"presets": []
},
"description": "Run the `interceptor` NestJS generator with Nx project support.",
"implementation": "/packages/nest/src/generators/interceptor/interceptor#interceptorGeneratorInternal.ts",
"implementation": "/packages/nest/src/generators/interceptor/interceptor.ts",
"aliases": [],
"hidden": false,
"path": "/packages/nest/src/generators/interceptor/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "interface",
"factory": "./src/generators/interface/interface#interfaceGeneratorInternal",
"factory": "./src/generators/interface/interface",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestInterfaceGenerator",
@ -50,7 +50,7 @@
"presets": []
},
"description": "Run the `interface` NestJS generator with Nx project support.",
"implementation": "/packages/nest/src/generators/interface/interface#interfaceGeneratorInternal.ts",
"implementation": "/packages/nest/src/generators/interface/interface.ts",
"aliases": [],
"hidden": false,
"path": "/packages/nest/src/generators/interface/schema.json",

View File

@ -30,7 +30,7 @@
"projectNameAndRootFormat": {
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
"type": "string",
"enum": ["as-provided", "derived"]
"enum": ["as-provided"]
},
"linter": {
"description": "The tool to use for running lint checks.",

View File

@ -1,6 +1,6 @@
{
"name": "middleware",
"factory": "./src/generators/middleware/middleware#middlewareGeneratorInternal",
"factory": "./src/generators/middleware/middleware",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestMiddlewareGenerator",
@ -18,14 +18,7 @@
"nameAndDirectoryFormat": {
"description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"description": "The Nest project to target.",
"type": "string",
"$default": { "$source": "projectName" },
"alias": "p",
"x-deprecated": "Provide The `directory` option instead and use the `as-provided` format. the project will be determined from the directory provided. It will be removed in Nx v20."
"enum": ["as-provided"]
},
"directory": {
"description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
@ -44,12 +37,6 @@
"enum": ["jest", "none"],
"default": "jest"
},
"flat": {
"description": "Flag to indicate if a directory is created.",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.",
"type": "boolean",
"default": true
},
"language": {
"description": "Nest middleware language.",
"type": "string",
@ -61,7 +48,7 @@
"presets": []
},
"description": "Run the `middleware` NestJS generator with Nx project support.",
"implementation": "/packages/nest/src/generators/middleware/middleware#middlewareGeneratorInternal.ts",
"implementation": "/packages/nest/src/generators/middleware/middleware.ts",
"aliases": [],
"hidden": false,
"path": "/packages/nest/src/generators/middleware/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "module",
"factory": "./src/generators/module/module#moduleGeneratorInternal",
"factory": "./src/generators/module/module",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestModuleGenerator",
@ -20,13 +20,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"description": "The Nest project to target.",
"type": "string",
"$default": { "$source": "projectName" },
"alias": "p",
"x-deprecated": "Provide The `directory` option instead and use the `as-provided` format. the project will be determined from the directory provided. It will be removed in Nx v20."
},
"directory": {
"description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
"type": "string",
@ -38,12 +31,6 @@
"default": false,
"x-priority": "internal"
},
"flat": {
"description": "Flag to indicate if a directory is created.",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.",
"type": "boolean",
"default": false
},
"language": {
"description": "Nest module language.",
"type": "string",
@ -65,7 +52,7 @@
"presets": []
},
"description": "Run the `module` NestJS generator with Nx project support.",
"implementation": "/packages/nest/src/generators/module/module#moduleGeneratorInternal.ts",
"implementation": "/packages/nest/src/generators/module/module.ts",
"aliases": [],
"hidden": false,
"path": "/packages/nest/src/generators/module/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "pipe",
"factory": "./src/generators/pipe/pipe#pipeGeneratorInternal",
"factory": "./src/generators/pipe/pipe",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestPipeGenerator",
@ -20,13 +20,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"description": "The Nest project to target.",
"type": "string",
"$default": { "$source": "projectName" },
"alias": "p",
"x-deprecated": "Provide The `directory` option instead and use the `as-provided` format. the project will be determined from the directory provided. It will be removed in Nx v20."
},
"directory": {
"description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
"type": "string",
@ -44,12 +37,6 @@
"enum": ["jest", "none"],
"default": "jest"
},
"flat": {
"description": "Flag to indicate if a directory is created.",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.",
"type": "boolean",
"default": true
},
"language": {
"description": "Nest pipe language.",
"type": "string",
@ -61,7 +48,7 @@
"presets": []
},
"description": "Run the `pipe` NestJS generator with Nx project support.",
"implementation": "/packages/nest/src/generators/pipe/pipe#pipeGeneratorInternal.ts",
"implementation": "/packages/nest/src/generators/pipe/pipe.ts",
"aliases": [],
"hidden": false,
"path": "/packages/nest/src/generators/pipe/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "provider",
"factory": "./src/generators/provider/provider#providerGeneratorInternal",
"factory": "./src/generators/provider/provider",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestProviderGenerator",
@ -20,13 +20,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"description": "The Nest project to target.",
"type": "string",
"$default": { "$source": "projectName" },
"alias": "p",
"x-deprecated": "Provide The `directory` option instead and use the `as-provided` format. the project will be determined from the directory provided. It will be removed in Nx v20."
},
"directory": {
"description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
"type": "string",
@ -44,12 +37,6 @@
"enum": ["jest", "none"],
"default": "jest"
},
"flat": {
"description": "Flag to indicate if a directory is created.",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.",
"type": "boolean",
"default": true
},
"language": {
"description": "Nest provider language.",
"type": "string",
@ -61,7 +48,7 @@
"presets": []
},
"description": "Run the `provider` NestJS generator with Nx project support.",
"implementation": "/packages/nest/src/generators/provider/provider#providerGeneratorInternal.ts",
"implementation": "/packages/nest/src/generators/provider/provider.ts",
"aliases": [],
"hidden": false,
"path": "/packages/nest/src/generators/provider/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "resolver",
"factory": "./src/generators/resolver/resolver#resolverGeneratorInternal",
"factory": "./src/generators/resolver/resolver",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestResolverGenerator",
@ -15,13 +15,6 @@
"$default": { "$source": "argv", "index": 0 },
"x-prompt": "What name would you like to use?"
},
"project": {
"description": "The Nest project to target.",
"type": "string",
"$default": { "$source": "projectName" },
"alias": "p",
"x-deprecated": "Provide The `directory` option instead and use the `as-provided` format. the project will be determined from the directory provided. It will be removed in Nx v20."
},
"nameAndDirectoryFormat": {
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
"type": "string",
@ -44,12 +37,6 @@
"enum": ["jest", "none"],
"default": "jest"
},
"flat": {
"description": "Flag to indicate if a directory is created.",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.",
"type": "boolean",
"default": false
},
"language": {
"description": "Nest resolver language.",
"type": "string",
@ -61,7 +48,7 @@
"presets": []
},
"description": "Run the `resolver` NestJS generator with Nx project support.",
"implementation": "/packages/nest/src/generators/resolver/resolver#resolverGeneratorInternal.ts",
"implementation": "/packages/nest/src/generators/resolver/resolver.ts",
"aliases": [],
"hidden": false,
"path": "/packages/nest/src/generators/resolver/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "resource",
"factory": "./src/generators/resource/resource#resourceGeneratorInternal",
"factory": "./src/generators/resource/resource",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestResourceGenerator",
@ -15,13 +15,6 @@
"$default": { "$source": "argv", "index": 0 },
"x-prompt": "What name would you like to use for this resource (plural, e.g., `users`)?"
},
"project": {
"description": "The Nest project to target.",
"type": "string",
"$default": { "$source": "projectName" },
"alias": "p",
"x-deprecated": "Provide The `directory` option instead and use the `as-provided` format. the project will be determined from the directory provided. It will be removed in Nx v20."
},
"nameAndDirectoryFormat": {
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
"type": "string",
@ -44,12 +37,6 @@
"enum": ["jest", "none"],
"default": "jest"
},
"flat": {
"description": "Flag to indicate if a directory is created.",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.",
"type": "boolean",
"default": false
},
"language": {
"description": "Nest class language.",
"type": "string",
@ -101,7 +88,7 @@
"presets": []
},
"description": "Run the `resource` NestJS generator with Nx project support.",
"implementation": "/packages/nest/src/generators/resource/resource#resourceGeneratorInternal.ts",
"implementation": "/packages/nest/src/generators/resource/resource.ts",
"aliases": [],
"hidden": false,
"path": "/packages/nest/src/generators/resource/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "service",
"factory": "./src/generators/service/service#serviceGeneratorInternal",
"factory": "./src/generators/service/service",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxNestServiceGenerator",
@ -20,13 +20,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"description": "The Nest project to target.",
"type": "string",
"$default": { "$source": "projectName" },
"alias": "p",
"x-deprecated": "Provide The `directory` option instead and use the `as-provided` format. the project will be determined from the directory provided. It will be removed in Nx v20."
},
"directory": {
"description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
"type": "string",
@ -44,12 +37,6 @@
"enum": ["jest", "none"],
"default": "jest"
},
"flat": {
"description": "Flag to indicate if a directory is created.",
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.",
"type": "boolean",
"default": false
},
"language": {
"description": "Nest service language.",
"type": "string",
@ -61,7 +48,7 @@
"presets": []
},
"description": "Run the `service` NestJS generator with Nx project support.",
"implementation": "/packages/nest/src/generators/service/service#serviceGeneratorInternal.ts",
"implementation": "/packages/nest/src/generators/service/service.ts",
"aliases": [],
"hidden": false,
"path": "/packages/nest/src/generators/service/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "component",
"factory": "./src/generators/component/component#componentGeneratorInternal",
"factory": "./src/generators/component/component",
"schema": {
"$schema": "https://json-schema.org/schema",
"cli": "nx",
@ -9,13 +9,6 @@
"description": "Create a React Component for Next.",
"type": "object",
"properties": {
"project": {
"type": "string",
"description": "The name of the project.",
"alias": "p",
"$default": { "$source": "projectName" },
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
},
"name": {
"type": "string",
"description": "The name of the component.",
@ -85,26 +78,6 @@
"description": "Generate JavaScript files rather than TypeScript files.",
"default": false
},
"flat": {
"type": "boolean",
"description": "Create component at the source root rather than its own directory.",
"default": false,
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19."
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case component file name (e.g. `App.tsx`).",
"alias": "P",
"default": false,
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
},
"pascalCaseDirectory": {
"type": "boolean",
"description": "Use pascal case directory name (e.g. `App/App.tsx`).",
"alias": "R",
"default": false,
"x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
},
"skipFormat": {
"description": "Skip formatting files.",
"type": "boolean",
@ -117,7 +90,7 @@
"presets": []
},
"description": "Create a component.",
"implementation": "/packages/next/src/generators/component/component#componentGeneratorInternal.ts",
"implementation": "/packages/next/src/generators/component/component.ts",
"aliases": [],
"hidden": false,
"path": "/packages/next/src/generators/component/schema.json",

View File

@ -88,12 +88,6 @@
"default": false,
"description": "Do not update tsconfig.json for development experience."
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case component file name (e.g. `App.tsx`).",
"alias": "P",
"default": false
},
"routing": {
"type": "boolean",
"description": "Generate library with routes."

View File

@ -1,6 +1,6 @@
{
"name": "page",
"factory": "./src/generators/page/page#pageGeneratorInternal",
"factory": "./src/generators/page/page",
"schema": {
"$schema": "https://json-schema.org/schema",
"cli": "nx",
@ -103,7 +103,7 @@
"presets": []
},
"description": "Create a page.",
"implementation": "/packages/next/src/generators/page/page#pageGeneratorInternal.ts",
"implementation": "/packages/next/src/generators/page/page.ts",
"aliases": [],
"hidden": false,
"path": "/packages/next/src/generators/page/schema.json",

View File

@ -72,12 +72,6 @@
"default": false,
"x-deprecated": "Use --swcJest instead for faster compilation"
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case file names.",
"alias": "P",
"default": false
},
"js": {
"type": "boolean",
"description": "Generate JavaScript files rather than TypeScript files.",

View File

@ -104,12 +104,6 @@
"description": "Use `babel` instead of `ts-jest`.",
"default": false
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case file names.",
"alias": "P",
"default": false
},
"js": {
"type": "boolean",
"description": "Generate JavaScript files rather than TypeScript files.",

View File

@ -1,6 +1,6 @@
{
"name": "create-package",
"factory": "./src/generators/create-package/create-package#createPackageGeneratorInternal",
"factory": "./src/generators/create-package/create-package",
"schema": {
"$schema": "https://json-schema.org/schema",
"cli": "nx",
@ -73,7 +73,7 @@
"presets": []
},
"description": "Create a package which can be used by npx to create a new workspace",
"implementation": "/packages/plugin/src/generators/create-package/create-package#createPackageGeneratorInternal.ts",
"implementation": "/packages/plugin/src/generators/create-package/create-package.ts",
"aliases": [],
"hidden": false,
"path": "/packages/plugin/src/generators/create-package/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "executor",
"factory": "./src/generators/executor/executor#executorGeneratorInternal",
"factory": "./src/generators/executor/executor",
"schema": {
"$schema": "https://json-schema.org/schema",
"cli": "nx",
@ -55,13 +55,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"type": "string",
"description": "The name of the project.",
"alias": "p",
"$default": { "$source": "projectName" },
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
},
"skipFormat": {
"type": "boolean",
"description": "Skip formatting files.",
@ -74,7 +67,7 @@
"presets": []
},
"description": "Create an executor for an Nx Plugin.",
"implementation": "/packages/plugin/src/generators/executor/executor#executorGeneratorInternal.ts",
"implementation": "/packages/plugin/src/generators/executor/executor.ts",
"aliases": [],
"hidden": false,
"path": "/packages/plugin/src/generators/executor/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "generator",
"factory": "./src/generators/generator/generator#generatorGeneratorInternal",
"factory": "./src/generators/generator/generator",
"schema": {
"$schema": "https://json-schema.org/schema",
"cli": "nx",
@ -44,13 +44,6 @@
"default": false,
"description": "Do not add an eslint configuration for plugin json files."
},
"project": {
"type": "string",
"description": "The name of the project.",
"alias": "p",
"$default": { "$source": "projectName" },
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
},
"skipFormat": {
"type": "boolean",
"default": false,
@ -68,7 +61,7 @@
"presets": []
},
"description": "Create a generator for an Nx Plugin.",
"implementation": "/packages/plugin/src/generators/generator/generator#generatorGeneratorInternal.ts",
"implementation": "/packages/plugin/src/generators/generator/generator.ts",
"aliases": [],
"hidden": false,
"path": "/packages/plugin/src/generators/generator/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "migration",
"factory": "./src/generators/migration/migration#migrationGeneratorInternal",
"factory": "./src/generators/migration/migration",
"schema": {
"$schema": "https://json-schema.org/schema",
"cli": "nx",
@ -37,13 +37,6 @@
"x-prompt": "What version would you like to use for the migration?",
"x-priority": "important"
},
"project": {
"type": "string",
"description": "The name of the project.",
"alias": "p",
"$default": { "$source": "projectName" },
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
},
"packageJsonUpdates": {
"type": "boolean",
"description": "Whether or not to include `package.json` updates.",
@ -66,7 +59,7 @@
"presets": []
},
"description": "Create a migration for an Nx Plugin.",
"implementation": "/packages/plugin/src/generators/migration/migration#migrationGeneratorInternal.ts",
"implementation": "/packages/plugin/src/generators/migration/migration.ts",
"aliases": [],
"hidden": false,
"path": "/packages/plugin/src/generators/migration/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "plugin",
"factory": "./src/generators/plugin/plugin#pluginGeneratorInternal",
"factory": "./src/generators/plugin/plugin",
"schema": {
"$schema": "https://json-schema.org/schema",
"cli": "nx",
@ -104,7 +104,7 @@
"presets": []
},
"description": "Create a Nx Plugin.",
"implementation": "/packages/plugin/src/generators/plugin/plugin#pluginGeneratorInternal.ts",
"implementation": "/packages/plugin/src/generators/plugin/plugin.ts",
"aliases": [],
"hidden": false,
"path": "/packages/plugin/src/generators/plugin/schema.json",

View File

@ -1,6 +1,6 @@
{
"name": "component",
"factory": "./src/generators/component/component#reactNativeComponentGeneratorInternal",
"factory": "./src/generators/component/component",
"schema": {
"cli": "nx",
"$id": "NxReactNativeApplication",
@ -10,22 +10,15 @@
"type": "object",
"examples": [
{
"command": "nx g @nx/react-native:component my-component --project=mylib",
"command": "nx g @nx/react-native:component my-component --directory=mylib/src/lib/my-component",
"description": "Generate a component in the `mylib` library"
},
{
"command": "nx g @nx/react-native:component my-component --project=mylib --classComponent",
"command": "nx g @nx/react-native:component my-component --directory=mylib/src/lib/my-component --classComponent",
"description": "Generate a class component in the `mylib` library"
}
],
"properties": {
"project": {
"type": "string",
"description": "The name of the project.",
"alias": "p",
"$default": { "$source": "projectName" },
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
},
"name": {
"type": "string",
"description": "The name of the component.",
@ -52,12 +45,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"flat": {
"type": "boolean",
"description": "Create component at the source root rather than its own directory.",
"default": false,
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19."
},
"export": {
"type": "boolean",
"description": "When true, the component is exported from the project `index.ts` (if it exists).",
@ -65,13 +52,6 @@
"default": false,
"x-prompt": "Should this component be exported in the project?"
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case component file name (e.g. `App.tsx`).",
"alias": "P",
"default": false,
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
},
"classComponent": {
"type": "boolean",
"alias": "C",
@ -84,7 +64,7 @@
},
"description": "Create a React Native component.",
"aliases": ["c"],
"implementation": "/packages/react-native/src/generators/component/component#reactNativeComponentGeneratorInternal.ts",
"implementation": "/packages/react-native/src/generators/component/component.ts",
"hidden": false,
"path": "/packages/react-native/src/generators/component/schema.json",
"type": "generator"

View File

@ -62,12 +62,6 @@
"description": "Do not update `tsconfig.json` for development experience.",
"x-priority": "internal"
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case component file name (e.g. `App.tsx`).",
"alias": "P",
"default": false
},
"publishable": {
"type": "boolean",
"description": "Create a publishable library."

View File

@ -126,12 +126,6 @@
"description": "Add tags to the application (used for linting).",
"alias": "t"
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case component file name (e.g. `App.tsx`).",
"alias": "P",
"default": false
},
"classComponent": {
"type": "boolean",
"description": "Use class components instead of functional component.",

View File

@ -1,6 +1,6 @@
{
"name": "component",
"factory": "./src/generators/component/component#componentGeneratorInternal",
"factory": "./src/generators/component/component",
"schema": {
"$schema": "https://json-schema.org/schema",
"cli": "nx",
@ -9,13 +9,6 @@
"description": "Create a React Component for Nx.",
"type": "object",
"properties": {
"project": {
"type": "string",
"description": "The name of the project.",
"alias": "p",
"$default": { "$source": "projectName" },
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
},
"name": {
"type": "string",
"description": "The name of the component.",
@ -79,12 +72,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"flat": {
"type": "boolean",
"description": "Create component at the source root rather than its own directory.",
"default": false,
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19."
},
"export": {
"type": "boolean",
"description": "When true, the component is exported from the project `index.ts` (if it exists).",
@ -92,20 +79,6 @@
"default": false,
"x-prompt": "Should this component be exported in the project?"
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case component file name (e.g. `App.tsx`).",
"alias": "P",
"default": false,
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
},
"pascalCaseDirectory": {
"type": "boolean",
"description": "Use pascal case directory name (e.g. `App/App.tsx`).",
"alias": "R",
"default": false,
"x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
},
"classComponent": {
"type": "boolean",
"alias": "C",
@ -143,7 +116,7 @@
},
"description": "Create a React component.",
"aliases": ["c"],
"implementation": "/packages/react/src/generators/component/component#componentGeneratorInternal.ts",
"implementation": "/packages/react/src/generators/component/component.ts",
"hidden": false,
"path": "/packages/react/src/generators/component/schema.json",
"type": "generator"

View File

@ -1,6 +1,6 @@
{
"name": "hook",
"factory": "./src/generators/hook/hook#hookGeneratorInternal",
"factory": "./src/generators/hook/hook",
"schema": {
"$schema": "https://json-schema.org/schema",
"cli": "nx",
@ -15,13 +15,6 @@
}
],
"properties": {
"project": {
"type": "string",
"description": "The name of the project.",
"alias": "p",
"$default": { "$source": "projectName" },
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
},
"name": {
"type": "string",
"description": "The name of the hook.",
@ -50,32 +43,12 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"flat": {
"type": "boolean",
"description": "Create hook at the source root rather than its own directory.",
"default": false,
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20."
},
"export": {
"type": "boolean",
"description": "When true, the hook is exported from the project `index.ts` (if it exists).",
"alias": "e",
"default": false,
"x-prompt": "Should this hook be exported in the project?"
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case hook file name (e.g. `useHook.ts`).",
"alias": "P",
"default": false,
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
},
"pascalCaseDirectory": {
"type": "boolean",
"description": "Use pascal case directory name (e.g. `useHook/useHook.ts`).",
"alias": "R",
"default": false,
"x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
}
},
"required": ["name"],
@ -83,7 +56,7 @@
},
"description": "Create a hook.",
"aliases": ["c"],
"implementation": "/packages/react/src/generators/hook/hook#hookGeneratorInternal.ts",
"implementation": "/packages/react/src/generators/hook/hook.ts",
"hidden": false,
"path": "/packages/react/src/generators/hook/schema.json",
"type": "generator"

View File

@ -1,6 +1,6 @@
{
"name": "host",
"factory": "./src/generators/host/host#hostGeneratorInternal",
"factory": "./src/generators/host/host",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "GeneratorReactHost",
@ -107,12 +107,6 @@
"description": "Add tags to the application (used for linting).",
"alias": "t"
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case component file name (e.g. App.tsx).",
"alias": "P",
"default": false
},
"classComponent": {
"type": "boolean",
"description": "Use class components instead of functional component.",
@ -193,7 +187,7 @@
},
"x-type": "application",
"description": "Generate a host react application",
"implementation": "/packages/react/src/generators/host/host#hostGeneratorInternal.ts",
"implementation": "/packages/react/src/generators/host/host.ts",
"aliases": [],
"hidden": false,
"path": "/packages/react/src/generators/host/schema.json",

View File

@ -106,12 +106,6 @@
"description": "Do not update `tsconfig.json` for development experience.",
"x-priority": "internal"
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case component file name (e.g. `App.tsx`).",
"alias": "P",
"default": false
},
"routing": {
"type": "boolean",
"description": "Generate library with routes."

View File

@ -1,6 +1,6 @@
{
"name": "redux",
"factory": "./src/generators/redux/redux#reduxGeneratorInternal",
"factory": "./src/generators/redux/redux",
"schema": {
"$schema": "https://json-schema.org/schema",
"cli": "nx",
@ -15,13 +15,6 @@
"$default": { "$source": "argv", "index": 0 },
"x-priority": "important"
},
"project": {
"type": "string",
"description": "The name of the project to add the slice to. If it is an application, then the store configuration will be updated too.",
"alias": "p",
"$default": { "$source": "projectName" },
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
},
"directory": {
"type": "string",
"alias": "dir",
@ -50,7 +43,7 @@
},
"description": "Create a Redux slice for a project.",
"aliases": ["slice"],
"implementation": "/packages/react/src/generators/redux/redux#reduxGeneratorInternal.ts",
"implementation": "/packages/react/src/generators/redux/redux.ts",
"hidden": false,
"path": "/packages/react/src/generators/redux/schema.json",
"type": "generator"

View File

@ -1,6 +1,6 @@
{
"name": "remote",
"factory": "./src/generators/remote/remote#remoteGeneratorInternal",
"factory": "./src/generators/remote/remote",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "GeneratorReactRemote",
@ -113,12 +113,6 @@
"description": "Add tags to the application (used for linting).",
"alias": "t"
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case component file name (e.g. App.tsx).",
"alias": "P",
"default": false
},
"classComponent": {
"type": "boolean",
"description": "Use class components instead of functional component.",
@ -192,7 +186,7 @@
},
"x-type": "application",
"description": "Generate a remote react application",
"implementation": "/packages/react/src/generators/remote/remote#remoteGeneratorInternal.ts",
"implementation": "/packages/react/src/generators/remote/remote.ts",
"aliases": [],
"hidden": false,
"path": "/packages/react/src/generators/remote/schema.json",

View File

@ -17,12 +17,6 @@
"description": "Whether to generate the action in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"type": "string",
"description": "The name of the project.",
"pattern": "^[a-zA-Z].*$",
"x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v20."
}
},
"required": ["path"],

View File

@ -23,12 +23,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"type": "string",
"description": "The name of the project.",
"pattern": "^[a-zA-Z].*$",
"x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v20."
},
"skipFormat": {
"type": "boolean",
"description": "Skip formatting files after generation.",

View File

@ -17,12 +17,6 @@
"description": "Whether to generate the loader in the path as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"type": "string",
"description": "The name of the project.",
"pattern": "^[a-zA-Z].*$",
"x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v20."
}
},
"required": ["path"],

View File

@ -17,12 +17,6 @@
"description": "Whether to generate the meta function in the path as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"type": "string",
"description": "The name of the project.",
"pattern": "^[a-zA-Z].*$",
"x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v20."
}
},
"required": ["path"],

View File

@ -25,12 +25,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"type": "string",
"description": "The name of the project.",
"pattern": "^[a-zA-Z].*$",
"x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v20."
},
"action": {
"type": "boolean",
"description": "Generate an action function",

View File

@ -25,12 +25,6 @@
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"type": "string",
"description": "The name of the project.",
"pattern": "^[a-zA-Z].*$",
"x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v20."
},
"style": {
"type": "string",
"description": "Generate a stylesheet",

View File

@ -24,12 +24,6 @@
"description": "Whether to generate the styles in the path as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
"type": "string",
"enum": ["as-provided", "derived"]
},
"project": {
"type": "string",
"description": "The name of the project.",
"pattern": "^[a-zA-Z].*$",
"x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v20."
}
},
"required": ["path"],

View File

@ -1,6 +1,6 @@
{
"name": "component",
"factory": "./src/generators/component/component#componentGeneratorInternal",
"factory": "./src/generators/component/component",
"schema": {
"$schema": "https://json-schema.org/schema",
"cli": "nx",
@ -15,13 +15,6 @@
}
],
"properties": {
"project": {
"type": "string",
"description": "The name of the project.",
"alias": "p",
"$default": { "$source": "projectName" },
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
},
"name": {
"type": "string",
"description": "The name of the component.",
@ -51,12 +44,6 @@
"alias": "dir",
"x-priority": "important"
},
"flat": {
"type": "boolean",
"description": "Create component at the source root rather than its own directory.",
"default": false,
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20."
},
"export": {
"type": "boolean",
"description": "When true, the component is exported from the project `index.ts` (if it exists).",
@ -64,20 +51,6 @@
"default": false,
"x-prompt": "Should this component be exported in the project?"
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case component file name (e.g. `App.tsx`).",
"alias": "P",
"default": false,
"x-deprecated": "Provide the desired `name` option instead and use the `as-provided` format. It will be removed in Nx v20."
},
"pascalCaseDirectory": {
"type": "boolean",
"description": "Use pascal case directory name (e.g. `App/App.tsx`).",
"alias": "R",
"default": false,
"x-deprecated": "Provide the desired `directory` option instead and use the `as-provided` format. It will be removed in Nx v20."
},
"routing": {
"type": "boolean",
"description": "Generate a library with routes."
@ -104,7 +77,7 @@
"aliases": ["c"],
"x-type": "component",
"description": "Create a Vue component.",
"implementation": "/packages/vue/src/generators/component/component#componentGeneratorInternal.ts",
"implementation": "/packages/vue/src/generators/component/component.ts",
"hidden": false,
"path": "/packages/vue/src/generators/component/schema.json",
"type": "generator"

View File

@ -72,12 +72,6 @@
"description": "Do not update `tsconfig.json` for development experience.",
"x-priority": "internal"
},
"pascalCaseFiles": {
"type": "boolean",
"description": "Use pascal case component file name (e.g. `App.tsx`).",
"alias": "P",
"default": false
},
"routing": {
"type": "boolean",
"description": "Generate library with routes."

View File

@ -1,6 +1,6 @@
{
"name": "move",
"factory": "./src/generators/move/move#moveGeneratorInternal",
"factory": "./src/generators/move/move",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxWorkspaceMove",
@ -60,7 +60,7 @@
},
"aliases": ["mv"],
"description": "Move an application or library to another folder.",
"implementation": "/packages/workspace/src/generators/move/move#moveGeneratorInternal.ts",
"implementation": "/packages/workspace/src/generators/move/move.ts",
"hidden": false,
"path": "/packages/workspace/src/generators/move/schema.json",
"type": "generator"

View File

@ -1,6 +1,6 @@
{
"name": "npm-package",
"factory": "./src/generators/npm-package/npm-package#npmPackageGeneratorInternal",
"factory": "./src/generators/npm-package/npm-package#npmPackageGenerator",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxWorkspaceNpmPackage",
@ -32,7 +32,7 @@
},
"description": "Create a minimal NPM package.",
"x-type": "library",
"implementation": "/packages/workspace/src/generators/npm-package/npm-package#npmPackageGeneratorInternal.ts",
"implementation": "/packages/workspace/src/generators/npm-package/npm-package#npmPackageGenerator.ts",
"aliases": [],
"hidden": false,
"path": "/packages/workspace/src/generators/npm-package/schema.json",

View File

@ -136,7 +136,7 @@ function createApp(appName: string) {
`generate @nx/angular:app ${appName} --bundler=webpack --project-name-and-root-format=as-provided --no-interactive`
);
runCLI(
`generate @nx/angular:component fancy-component --project=${appName} --no-interactive`
`generate @nx/angular:component fancy-component --directory=${appName}/src/lib/fancy-component --no-interactive`
);
}
@ -145,10 +145,10 @@ function createLib(projectName: string, appName: string, libName: string) {
`generate @nx/angular:lib ${libName} --project-name-and-root-format=as-provided --no-interactive`
);
runCLI(
`generate @nx/angular:component btn --project=${libName} --inlineTemplate --inlineStyle --export --no-interactive`
`generate @nx/angular:component btn --directory=${libName}/src/lib/btn --inlineTemplate --inlineStyle --export --no-interactive`
);
runCLI(
`generate @nx/angular:component btn-standalone --project=${libName} --inlineTemplate --inlineStyle --export --standalone --no-interactive`
`generate @nx/angular:component btn-standalone --directory=${libName}/src/lib/btn-standalone --inlineTemplate --inlineStyle --export --standalone --no-interactive`
);
updateFile(
`${libName}/src/lib/btn/btn.component.ts`,
@ -191,11 +191,11 @@ function createBuildableLib(projectName: string, libName: string) {
);
// create cmp for lib
runCLI(
`generate @nx/angular:component input --project=${libName} --inlineTemplate --inlineStyle --export --no-interactive`
`generate @nx/angular:component input --directory=${libName}/src/lib/input --inlineTemplate --inlineStyle --export --no-interactive`
);
// create standlone cmp for lib
runCLI(
`generate @nx/angular:component input-standalone --project=${libName} --inlineTemplate --inlineStyle --export --standalone --no-interactive`
`generate @nx/angular:component input-standalone --directory=${libName}/src/lib/input-standalone --inlineTemplate --inlineStyle --export --standalone --no-interactive`
);
// update cmp implmentation to use tailwind clasasserting in tests
updateFile(

View File

@ -149,60 +149,4 @@ describe('Move Angular Project', () => {
);
expect(lib2File).toContain(`extends ${newModule}`);
});
it('should move projects correctly with --project-name-and-root-format=derived', () => {
const lib1 = uniq('mylib');
const lib2 = uniq('mylib');
runCLI(
`generate @nx/angular:lib ${lib1} --no-standalone --project-name-and-root-format=derived --no-interactive`
);
/**
* Create a library which imports the module from the other lib
*/
runCLI(
`generate @nx/angular:lib ${lib2} --no-standalone --project-name-and-root-format=derived --no-interactive`
);
updateFile(
`libs/${lib2}/src/lib/${lib2}.module.ts`,
`import { ${classify(lib1)}Module } from '@${proj}/${lib1}';
export class ExtendedModule extends ${classify(lib1)}Module { }`
);
const moveOutput = runCLI(
`generate @nx/angular:move --projectName=${lib1} --destination=shared/${lib1} --project-name-and-root-format=derived`
);
const newPath = `libs/shared/${lib1}`;
const newModule = `Shared${classify(lib1)}Module`;
const testSetupPath = `${newPath}/src/test-setup.ts`;
expect(moveOutput).toContain(`CREATE ${testSetupPath}`);
checkFilesExist(testSetupPath);
const modulePath = `${newPath}/src/lib/shared-${lib1}.module.ts`;
expect(moveOutput).toContain(`CREATE ${modulePath}`);
checkFilesExist(modulePath);
const moduleFile = readFile(modulePath);
expect(moduleFile).toContain(`export class ${newModule}`);
const indexPath = `${newPath}/src/index.ts`;
expect(moveOutput).toContain(`CREATE ${indexPath}`);
checkFilesExist(indexPath);
const index = readFile(indexPath);
expect(index).toContain(`export * from './lib/shared-${lib1}.module'`);
/**
* Check that the import in lib2 has been updated
*/
const lib2FilePath = `libs/${lib2}/src/lib/${lib2}.module.ts`;
const lib2File = readFile(lib2FilePath);
expect(lib2File).toContain(
`import { ${newModule} } from '@${proj}/shared/${lib1}';`
);
expect(lib2File).toContain(`extends ${newModule}`);
});
});

View File

@ -274,64 +274,6 @@ test('renders remotes', async ({ page }) => {
}
}, 20_000_000);
it('should should support generating host and remote apps with --project-name-and-root-format=derived', async () => {
const hostApp = uniq('host');
const remoteApp = uniq('remote');
const hostPort = 4800;
const remotePort = 4801;
// generate host app
runCLI(
`generate @nx/angular:host ${hostApp} --no-standalone --project-name-and-root-format=derived --no-interactive`
);
// generate remote app
runCLI(
`generate @nx/angular:remote ${remoteApp} --host=${hostApp} --port=${remotePort} --no-standalone --project-name-and-root-format=derived --no-interactive`
);
// check files are generated with the layout directory ("apps/")
checkFilesExist(
`apps/${hostApp}/src/app/app.module.ts`,
`apps/${remoteApp}/src/app/app.module.ts`
);
// check default generated host is built successfully
const buildOutputSwc = await runCommandUntil(`build ${hostApp}`, (output) =>
output.includes('Successfully ran target build')
);
await killProcessAndPorts(buildOutputSwc.pid);
const buildOutputTsNode = await runCommandUntil(
`build ${hostApp}`,
(output) => output.includes('Successfully ran target build'),
{
env: { NX_PREFER_TS_NODE: 'true' },
}
);
await killProcessAndPorts(buildOutputTsNode.pid);
const processSwc = await runCommandUntil(
`serve ${hostApp} --port=${hostPort} --dev-remotes=${remoteApp}`,
(output) =>
!output.includes(`Remote '${remoteApp}' failed to serve correctly`) &&
output.includes(`listening on localhost:${hostPort}`)
);
await killProcessAndPorts(processSwc.pid, hostPort, remotePort);
const processTsNode = await runCommandUntil(
`serve ${hostApp} --port=${hostPort} --dev-remotes=${remoteApp}`,
(output) =>
!output.includes(`Remote '${remoteApp}' failed to serve correctly`) &&
output.includes(`listening on localhost:${hostPort}`),
{
env: { NX_PREFER_TS_NODE: 'true' },
}
);
await killProcessAndPorts(processTsNode.pid, hostPort, remotePort);
}, 20_000_000);
it('should federate a module from a library and update an existing remote', async () => {
const lib = uniq('lib');
const remote = uniq('remote');

View File

@ -501,46 +501,9 @@ describe('Angular Projects', () => {
expect(buildOutput).toContain('Successfully ran target build');
});
it('should support generating projects with --project-name-and-root-format=derived', () => {
const appName = uniq('app1');
const libName = uniq('lib1');
runCLI(
`generate @nx/angular:app ${appName} --no-standalone --project-name-and-root-format=derived --no-interactive`
);
// check files are generated with the layout directory ("apps/")
checkFilesExist(`apps/${appName}/src/app/app.module.ts`);
// check build works
expect(() => runCLI(`build ${appName}`)).not.toThrow();
// check tests pass
expect(() => runCLI(`test ${appName}`)).not.toThrow();
runCLI(
`generate @nx/angular:lib ${libName} --standalone --buildable --project-name-and-root-format=derived`
);
// check files are generated with the layout directory ("libs/")
checkFilesExist(
`libs/${libName}/src/index.ts`,
`libs/${libName}/src/lib/${libName}/${libName}.component.ts`
);
// check build works
expect(() => runCLI(`build ${libName}`)).not.toThrow();
// check tests pass
expect(() => runCLI(`test ${libName}`)).not.toThrow();
}, 500_000);
it('should support generating libraries with a scoped name when --project-name-and-root-format=as-provided', () => {
const libName = uniq('@my-org/lib1');
// assert scoped project names are not supported when --project-name-and-root-format=derived
expect(() =>
runCLI(
`generate @nx/angular:lib ${libName} --buildable --no-standalone --project-name-and-root-format=derived`
)
).toThrow();
runCLI(
`generate @nx/angular:lib ${libName} --buildable --standalone --project-name-and-root-format=as-provided`
);

View File

@ -49,7 +49,7 @@ describe('Cypress E2E Test runner (legacy)', () => {
{ env: { NX_ADD_PLUGINS: 'false' } }
);
runCLI(
`generate @nx/react:component btn --project=${appName} --no-interactive`,
`generate @nx/react:component btn --directory=${appName}/src/app/btn --no-interactive`,
{ env: { NX_ADD_PLUGINS: 'false' } }
);
runCLI(

View File

@ -26,7 +26,7 @@ describe('Cypress E2E Test runner', () => {
'should generate an app with the Cypress as e2e test runner',
() => {
runCLI(
`generate @nx/react:app ${myapp} --e2eTestRunner=cypress --linter=eslint`
`generate @nx/react:app ${myapp} --directory=apps/${myapp} --e2eTestRunner=cypress --linter=eslint`
);
// Making sure the package.json file contains the Cypress dependency
@ -117,6 +117,7 @@ export default defineConfig({
await killPort(4200);
// make sure project.json env vars also work
checkFilesExist(`apps/${myapp}-e2e/src/e2e/env.cy.ts`);
updateFile(
`apps/${myapp}-e2e/src/e2e/env.cy.ts`,
`
@ -182,10 +183,10 @@ export default defineConfig({
async () => {
let appName = uniq(`angular-cy-app`);
runCLI(
`generate @nx/angular:app ${appName} --e2eTestRunner=none --no-interactive --bundler=webpack`
`generate @nx/angular:app ${appName} --directory=apps/${appName} --e2eTestRunner=none --no-interactive --bundler=webpack`
);
runCLI(
`generate @nx/angular:component btn --project=${appName} --no-interactive`
`generate @nx/angular:component btn --directory=apps/${appName}/src/app/btn --no-interactive`
);
runCLI(
`generate @nx/angular:cypress-component-configuration --project=${appName} --generate-tests --no-interactive`

View File

@ -26,7 +26,7 @@ describe('@nx/detox (legacy)', () => {
it('should create files and run lint command for react-native apps', async () => {
runCLI(
`generate @nx/react-native:app ${appName} --e2eTestRunner=detox --linter=eslint --install=false`
`generate @nx/react-native:app ${appName} --directory=apps/${appName} --e2eTestRunner=detox --linter=eslint --install=false`
);
checkFilesExist(`apps/${appName}-e2e/.detoxrc.json`);
checkFilesExist(`apps/${appName}-e2e/tsconfig.json`);
@ -43,7 +43,7 @@ describe('@nx/detox (legacy)', () => {
it('should create files and run lint command for expo apps', async () => {
const expoAppName = uniq('myapp');
runCLI(
`generate @nx/expo:app ${expoAppName} --e2eTestRunner=detox --linter=eslint`
`generate @nx/expo:app ${expoAppName} --directory=apps/${expoAppName} --e2eTestRunner=detox --linter=eslint`
);
checkFilesExist(`apps/${expoAppName}-e2e/.detoxrc.json`);
checkFilesExist(`apps/${expoAppName}-e2e/tsconfig.json`);

View File

@ -27,7 +27,9 @@ describe('EsBuild Plugin', () => {
it('should setup and build projects using build', async () => {
const myPkg = uniq('my-pkg');
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild`);
runCLI(
`generate @nx/js:lib ${myPkg} --directory=libs/${myPkg} --bundler=esbuild`
);
updateFile(`libs/${myPkg}/src/index.ts`, `console.log('Hello');\n`);
updateJson(join('libs', myPkg, 'project.json'), (json) => {
json.targets.build.options.assets = [`libs/${myPkg}/assets/*`];
@ -125,8 +127,12 @@ describe('EsBuild Plugin', () => {
packageInstall('lodash', undefined, '~4.14.0', 'prod');
const parentLib = uniq('parent-lib');
const childLib = uniq('child-lib');
runCLI(`generate @nx/js:lib ${parentLib} --bundler=esbuild`);
runCLI(`generate @nx/js:lib ${childLib} --bundler=none`);
runCLI(
`generate @nx/js:lib ${parentLib} --directory=libs/${parentLib} --bundler=esbuild`
);
runCLI(
`generate @nx/js:lib ${childLib} --directory=libs/${childLib} --bundler=none`
);
updateFile(
`libs/${parentLib}/src/index.ts`,
`
@ -174,7 +180,9 @@ describe('EsBuild Plugin', () => {
it('should support non-bundle builds', () => {
const myPkg = uniq('my-pkg');
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild`);
runCLI(
`generate @nx/js:lib ${myPkg} --directory=libs/${myPkg} --bundler=esbuild`
);
updateFile(`libs/${myPkg}/src/lib/${myPkg}.ts`, `console.log('Hello');\n`);
updateFile(`libs/${myPkg}/src/index.ts`, `import './lib/${myPkg}.cjs';\n`);
@ -194,7 +202,9 @@ describe('EsBuild Plugin', () => {
it('should support additional entry points', async () => {
const myPkg = uniq('my-pkg');
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild`);
runCLI(
`generate @nx/js:lib ${myPkg} --directory=libs/${myPkg} --bundler=esbuild`
);
updateFile(`libs/${myPkg}/src/index.ts`, `console.log('main');\n`);
updateFile(`libs/${myPkg}/src/extra.ts`, `console.log('extra');\n`);
updateJson(join('libs', myPkg, 'project.json'), (json) => {
@ -220,7 +230,9 @@ describe('EsBuild Plugin', () => {
it('should support external esbuild.config.js file', async () => {
const myPkg = uniq('my-pkg');
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild`);
runCLI(
`generate @nx/js:lib ${myPkg} --directory=libs/${myPkg} --bundler=esbuild`
);
updateFile(
`libs/${myPkg}/esbuild.config.js`,
`console.log('custom config loaded');\nmodule.exports = {};\n`
@ -237,7 +249,10 @@ describe('EsBuild Plugin', () => {
it('should bundle in non-sensitive NX_ environment variables', () => {
const myPkg = uniq('my-pkg');
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild`, {});
runCLI(
`generate @nx/js:lib ${myPkg} --directory=libs/${myPkg} --bundler=esbuild`,
{}
);
updateFile(
`libs/${myPkg}/src/index.ts`,
@ -265,7 +280,9 @@ describe('EsBuild Plugin', () => {
it('should support declaration builds', () => {
const declarationPkg = uniq('declaration-pkg');
runCLI(`generate @nx/js:lib ${declarationPkg} --bundler=esbuild`);
runCLI(
`generate @nx/js:lib ${declarationPkg} --directory=libs/${declarationPkg} --bundler=esbuild`
);
createFile(
`libs/${declarationPkg}/src/lib/testDir/sub.ts`,
`

View File

@ -27,10 +27,13 @@ describe('Linter (legacy)', () => {
newProject({
packages: ['@nx/react', '@nx/js', '@nx/eslint'],
});
runCLI(`generate @nx/react:app ${myapp} --tags=validtag`, {
env: { NX_ADD_PLUGINS: 'false' },
});
runCLI(`generate @nx/js:lib ${mylib}`, {
runCLI(
`generate @nx/react:app ${myapp} --tags=validtag --directory=apps/${myapp}`,
{
env: { NX_ADD_PLUGINS: 'false' },
}
);
runCLI(`generate @nx/js:lib ${mylib} --directory=apps/${mylib}`, {
env: { NX_ADD_PLUGINS: 'false' },
});
});

View File

@ -35,8 +35,10 @@ describe('Linter', () => {
projScope = newProject({
packages: ['@nx/react', '@nx/js', '@nx/eslint'],
});
runCLI(`generate @nx/react:app ${myapp} --tags=validtag`);
runCLI(`generate @nx/js:lib ${mylib}`);
runCLI(
`generate @nx/react:app ${myapp} --tags=validtag --directory=apps/${myapp}`
);
runCLI(`generate @nx/js:lib ${mylib} --directory=libs/${mylib}`);
});
afterAll(() => cleanupProject());
@ -209,10 +211,14 @@ describe('Linter', () => {
const invalidtaglib = uniq('invalidtaglib');
const validtaglib = uniq('validtaglib');
runCLI(`generate @nx/react:app ${myapp2}`);
runCLI(`generate @nx/react:lib ${lazylib}`);
runCLI(`generate @nx/js:lib ${invalidtaglib} --tags=invalidtag`);
runCLI(`generate @nx/js:lib ${validtaglib} --tags=validtag`);
runCLI(`generate @nx/react:app ${myapp2} --directory=apps/${myapp2}`);
runCLI(`generate @nx/react:lib ${lazylib} --directory=libs/${lazylib}`);
runCLI(
`generate @nx/js:lib ${invalidtaglib} --tags=invalidtag --directory=libs/${invalidtaglib}`
);
runCLI(
`generate @nx/js:lib ${validtaglib} --tags=validtag --directory=libs/${validtaglib}`
);
const eslint = readJson('.eslintrc.json');
eslint.overrides[0].rules[
@ -274,9 +280,15 @@ describe('Linter', () => {
beforeAll(() => {
// make these libs non-buildable to avoid dep-checks triggering lint errors
runCLI(`generate @nx/js:lib ${libA} --bundler=none`);
runCLI(`generate @nx/js:lib ${libB} --bundler=none`);
runCLI(`generate @nx/js:lib ${libC} --bundler=none`);
runCLI(
`generate @nx/js:lib ${libA} --bundler=none --directory=libs/${libA}`
);
runCLI(
`generate @nx/js:lib ${libB} --bundler=none --directory=libs/${libB}`
);
runCLI(
`generate @nx/js:lib ${libC} --bundler=none --directory=libs/${libC}`
);
/**
* create tslib-a structure
@ -686,7 +698,9 @@ describe('Linter', () => {
let e2eOverrides = JSON.stringify(e2eEslint.overrides);
expect(e2eOverrides).toContain('plugin:@nx/javascript');
runCLI(`generate @nx/js:lib ${mylib} --unitTestRunner=jest`);
runCLI(
`generate @nx/js:lib ${mylib} --unitTestRunner=jest --directory=libs/${mylib}`
);
verifySuccessfulMigratedSetup(myapp, mylib);
appEslint = readJson(`.eslintrc.json`);
@ -719,7 +733,9 @@ describe('Linter', () => {
let e2eOverrides = JSON.stringify(e2eEslint.overrides);
expect(e2eOverrides).toContain('plugin:@nx/javascript');
runCLI(`generate @nx/js:lib ${mylib} --no-interactive`);
runCLI(
`generate @nx/js:lib ${mylib} --no-interactive --directory=libs/${mylib}`
);
verifySuccessfulMigratedSetup(myapp, mylib);
appEslint = readJson(`.eslintrc.json`);
@ -752,7 +768,9 @@ describe('Linter', () => {
expect(e2eOverrides).toContain('plugin:@nx/javascript');
expect(e2eOverrides).toContain('plugin:@nx/typescript');
runCLI(`generate @nx/js:lib ${mylib} --no-interactive`);
runCLI(
`generate @nx/js:lib ${mylib} --no-interactive --directory=libs/${mylib}`
);
verifySuccessfulMigratedSetup(myapp, mylib);
appEslint = readJson(`.eslintrc.json`);

View File

@ -40,10 +40,10 @@ describe('@nx/expo (legacy)', () => {
return nxJson;
});
runCLI(
`generate @nx/expo:application ${appName} --e2eTestRunner=cypress --no-interactive`
`generate @nx/expo:application ${appName} --directory=apps/${appName} --e2eTestRunner=cypress --no-interactive`
);
runCLI(
`generate @nx/expo:library ${libName} --buildable --publishable --importPath=${proj}/${libName}`
`generate @nx/expo:library ${libName} --directory=libs/${libName} --buildable --publishable --importPath=${proj}/${libName}`
);
});
afterAll(() => {
@ -55,7 +55,7 @@ describe('@nx/expo (legacy)', () => {
const componentName = uniq('Component');
runCLI(
`generate @nx/expo:component ${componentName} --project=${libName} --export --no-interactive`
`generate @nx/expo:component ${componentName} --directory=libs/${libName}/src/${componentName} --export --no-interactive`
);
updateFile(`apps/${appName}/src/app/App.tsx`, (content) => {
@ -223,13 +223,6 @@ describe('@nx/expo (legacy)', () => {
`Successfully ran target test for project ${appName}`
);
// assert scoped project names are not supported when --project-name-and-root-format=derived
expect(() =>
runCLI(
`generate @nx/expo:library ${libName} --buildable --project-name-and-root-format=derived`
)
).toThrow();
runCLI(
`generate @nx/expo:library ${libName} --buildable --project-name-and-root-format=as-provided`
);

View File

@ -18,11 +18,14 @@ describe('Jest', () => {
it('should support multiple `coverageReporters` when using @nx/jest:jest executor', async () => {
const mylib = uniq('mylib');
runCLI(`generate @nx/js:lib ${mylib} --unitTestRunner=jest`, {
env: {
NX_ADD_PLUGINS: 'false',
},
});
runCLI(
`generate @nx/js:lib ${mylib} --directory=libs/${mylib} --unitTestRunner=jest`,
{
env: {
NX_ADD_PLUGINS: 'false',
},
}
);
updateFile(
`libs/${mylib}/src/lib/${mylib}.spec.ts`,

View File

@ -43,10 +43,10 @@ describe('Jest', () => {
const mylib = uniq('mylib');
const utilLib = uniq('util-lib');
runCLI(
`generate @nx/js:lib ${mylib} --unitTestRunner=jest --no-interactive`
`generate @nx/js:lib ${mylib} --directory=libs/${mylib} --unitTestRunner=jest --no-interactive`
);
runCLI(
`generate @nx/js:lib ${utilLib} --importPath=@global-fun/globals --unitTestRunner=jest --no-interactive`
`generate @nx/js:lib ${utilLib} --directory=libs/${utilLib} --importPath=@global-fun/globals --unitTestRunner=jest --no-interactive`
);
updateFile(
`libs/${utilLib}/src/index.ts`,
@ -122,7 +122,9 @@ describe('Jest', () => {
it('should set the NODE_ENV to `test`', async () => {
const mylib = uniq('mylib');
runCLI(`generate @nx/js:lib ${mylib} --unitTestRunner=jest`);
runCLI(
`generate @nx/js:lib ${mylib} --directory=libs/${mylib} --unitTestRunner=jest`
);
updateFile(
`libs/${mylib}/src/lib/${mylib}.spec.ts`,
@ -141,7 +143,7 @@ describe('Jest', () => {
it('should be able to test node lib with babel-jest', async () => {
const libName = uniq('babel-test-lib');
runCLI(
`generate @nx/node:lib ${libName} --buildable --importPath=@some-org/babel-test --publishable --babelJest`
`generate @nx/node:lib ${libName} --directory=libs/${libName} --buildable --importPath=@some-org/babel-test --publishable --babelJest`
);
const cliResults = await runCLIAsync(`test ${libName}`);
@ -152,7 +154,9 @@ describe('Jest', () => {
it('should be able to run e2e tests split by tasks', async () => {
const libName = uniq('lib');
runCLI(`generate @nx/js:lib ${libName} --unitTestRunner=jest`);
runCLI(
`generate @nx/js:lib ${libName} --directory=libs/${libName} --unitTestRunner=jest`
);
updateJson('nx.json', (json) => {
const jestPlugin = json.plugins.find(
(plugin) => plugin.plugin === '@nx/jest/plugin'

View File

@ -21,7 +21,7 @@ describe('js:node executor', () => {
const esbuildLib = uniq('esbuildlib');
runCLI(
`generate @nx/js:lib ${esbuildLib} --bundler=esbuild --no-interactive`
`generate @nx/js:lib ${esbuildLib} --directory=libs/${esbuildLib} --bundler=esbuild --no-interactive`
);
updateFile(`libs/${esbuildLib}/src/index.ts`, () => {
@ -55,7 +55,7 @@ describe('js:node executor', () => {
const rollupLib = uniq('rolluplib');
runCLI(
`generate @nx/js:lib ${rollupLib} --bundler=rollup --no-interactive`
`generate @nx/js:lib ${rollupLib} --directory=libs/${rollupLib} --bundler=rollup --no-interactive`
);
updateFile(`libs/${rollupLib}/src/index.ts`, () => {
@ -82,7 +82,9 @@ describe('js:node executor', () => {
it('should execute library compiled with tsc', async () => {
const tscLib = uniq('tsclib');
runCLI(`generate @nx/js:lib ${tscLib} --bundler=tsc --no-interactive`);
runCLI(
`generate @nx/js:lib ${tscLib} --directory=libs/${tscLib} --bundler=tsc --no-interactive`
);
updateFile(`libs/${tscLib}/src/index.ts`, () => {
return `
@ -108,7 +110,9 @@ describe('js:node executor', () => {
it('should execute library compiled with swc', async () => {
const swcLib = uniq('swclib');
runCLI(`generate @nx/js:lib ${swcLib} --bundler=swc --no-interactive`);
runCLI(
`generate @nx/js:lib ${swcLib} --directory=libs/${swcLib} --bundler=swc --no-interactive`
);
updateFile(`libs/${swcLib}/src/index.ts`, () => {
return `
@ -135,7 +139,7 @@ describe('js:node executor', () => {
const webpackProject = uniq('webpackproject');
runCLI(
`generate @nx/node:application ${webpackProject} --bundler=webpack --no-interactive`
`generate @nx/node:application ${webpackProject} --directory=apps/${webpackProject} --bundler=webpack --no-interactive`
);
updateFile(`apps/${webpackProject}/src/main.ts`, () => {

View File

@ -24,7 +24,9 @@ describe('js:swc executor', () => {
it('should create libs with js executors (--bundler=swc)', async () => {
const lib = uniq('lib');
runCLI(`generate @nx/js:lib ${lib} --bundler=swc --no-interactive`);
runCLI(
`generate @nx/js:lib ${lib} --directory=libs/${lib} --bundler=swc --no-interactive`
);
const libPackageJson = readJson(`libs/${lib}/package.json`);
expect(libPackageJson.scripts).toBeUndefined();
@ -48,7 +50,9 @@ describe('js:swc executor', () => {
it('should handle swcrc path mappings', async () => {
const lib = uniq('lib');
runCLI(`generate @nx/js:lib ${lib} --bundler=swc --no-interactive`);
runCLI(
`generate @nx/js:lib ${lib} --directory=libs/${lib} --bundler=swc --no-interactive`
);
// add a dummy x.ts file for path mappings
updateFile(
@ -95,7 +99,9 @@ myLib();
it('should support --strip-leading-paths option', () => {
const lib = uniq('lib');
runCLI(`generate @nx/js:lib ${lib} --bundler=swc --no-interactive`);
runCLI(
`generate @nx/js:lib ${lib} --directory=libs/${lib} --bundler=swc --no-interactive`
);
runCLI(`build ${lib} --stripLeadingPaths`);

View File

@ -28,7 +28,9 @@ describe('js:tsc executor', () => {
it('should create libs with js executors (--compiler=tsc)', async () => {
const lib = uniq('lib');
runCLI(`generate @nx/js:lib ${lib} --bundler=tsc --no-interactive`);
runCLI(
`generate @nx/js:lib ${lib} --directory=libs/${lib} --bundler=tsc --no-interactive`
);
const libPackageJson = readJson(`libs/${lib}/package.json`);
expect(libPackageJson.scripts).toBeUndefined();
@ -109,7 +111,9 @@ describe('js:tsc executor', () => {
libBuildProcess.kill();
const parentLib = uniq('parentlib');
runCLI(`generate @nx/js:lib ${parentLib} --bundler=tsc --no-interactive`);
runCLI(
`generate @nx/js:lib ${parentLib} --directory=libs/${parentLib} --bundler=tsc --no-interactive`
);
const parentLibPackageJson = readJson(`libs/${parentLib}/package.json`);
expect(parentLibPackageJson.scripts).toBeUndefined();
expect((await runCLIAsync(`test ${parentLib}`)).combinedOutput).toContain(
@ -213,7 +217,7 @@ describe('js:tsc executor', () => {
it('should not create a `.babelrc` file when creating libs with js executors (--compiler=tsc)', () => {
const lib = uniq('lib');
runCLI(
`generate @nx/js:lib ${lib} --compiler=tsc --includeBabelRc=false --no-interactive`
`generate @nx/js:lib ${lib} --compiler=tsc --directory=libs/${lib}--includeBabelRc=false --no-interactive`
);
checkFilesDoNotExist(`libs/${lib}/.babelrc`);
@ -221,10 +225,14 @@ describe('js:tsc executor', () => {
it('should allow wildcard ts path alias', async () => {
const base = uniq('base');
runCLI(`generate @nx/js:lib ${base} --bundler=tsc --no-interactive`);
runCLI(
`generate @nx/js:lib ${base} --directory=libs/${base} --bundler=tsc --no-interactive`
);
const lib = uniq('lib');
runCLI(`generate @nx/js:lib ${lib} --bundler=tsc --no-interactive`);
runCLI(
`generate @nx/js:lib ${lib} --directory=libs/${lib} --bundler=tsc --no-interactive`
);
updateFile(`libs/${base}/src/index.ts`, () => {
return `
@ -274,7 +282,9 @@ export function ${lib}Wildcard() {
it('should update package.json with detected dependencies', async () => {
const pmc = getPackageManagerCommand();
const lib = uniq('lib');
runCLI(`generate @nx/js:lib ${lib} --bundler=tsc --no-interactive`);
runCLI(
`generate @nx/js:lib ${lib} --directory=libs/${lib} --bundler=tsc --no-interactive`
);
// Add a dependency for this lib to check the built package.json
runCommand(`${pmc.addProd} react`);

View File

@ -25,7 +25,7 @@ describe('js e2e', () => {
it('should create libs with npm scripts', () => {
const npmScriptsLib = uniq('npmscriptslib');
runCLI(
`generate @nx/js:lib ${npmScriptsLib} --config=npm-scripts --no-interactive`
`generate @nx/js:lib ${npmScriptsLib} --directory=libs/${npmScriptsLib} --config=npm-scripts --no-interactive`
);
const libPackageJson = readJson(`libs/${npmScriptsLib}/package.json`);
expect(libPackageJson.scripts.test).toBeDefined();
@ -42,7 +42,9 @@ describe('js e2e', () => {
const libName = uniq('mylib');
const dirName = uniq('dir');
runCLI(`generate @nx/js:lib ${libName} --directory ${dirName}`);
runCLI(
`generate @nx/js:lib ${dirName}-${libName} --directory libs/${dirName}/${libName}`
);
checkFilesExist(
`libs/${dirName}/${libName}/src/index.ts`,
@ -65,11 +67,15 @@ describe('js e2e', () => {
it('should be able to add build to non-buildable projects', () => {
const nonBuildable = uniq('nonbuildable');
runCLI(`generate @nx/js:lib ${nonBuildable} --bundler=none`);
runCLI(
`generate @nx/js:lib ${nonBuildable} --directory=libs/${nonBuildable} --bundler=none`
);
expect(() => runCLI(`build ${nonBuildable}`)).toThrow();
checkFilesDoNotExist(`dist/libs/${nonBuildable}/src/index.js`);
runCLI(`generate @nx/js:setup-build ${nonBuildable} --bundler=tsc`);
runCLI(
`generate @nx/js:setup-build ${nonBuildable} --directory=libs/${nonBuildable} --bundler=tsc`
);
runCLI(`build ${nonBuildable}`);
checkFilesExist(`dist/libs/${nonBuildable}/src/index.js`);
});
@ -77,8 +83,12 @@ describe('js e2e', () => {
it('should build buildable libraries using the task graph and handle more scenarios than current implementation', () => {
const lib1 = uniq('lib1');
const lib2 = uniq('lib2');
runCLI(`generate @nx/js:lib ${lib1} --bundler=tsc --no-interactive`);
runCLI(`generate @nx/js:lib ${lib2} --bundler=tsc --no-interactive`);
runCLI(
`generate @nx/js:lib ${lib1} --directory=libs/${lib1} --bundler=tsc --no-interactive`
);
runCLI(
`generate @nx/js:lib ${lib2} --directory=libs/${lib2} --bundler=tsc --no-interactive`
);
// add dep between lib1 and lib2
updateFile(
@ -165,13 +175,6 @@ describe('js e2e', () => {
it('should support generating with a scoped project name when --project-name-and-root-format=as-provided', async () => {
const scopedLib = uniq('@my-org/lib1');
// assert scoped project names are not supported when --project-name-and-root-format=derived
expect(() =>
runCLI(
`generate @nx/js:lib ${scopedLib} --bundler=tsc --project-name-and-root-format=derived`
)
).toThrow();
runCLI(
`generate @nx/js:lib ${scopedLib} --bundler=tsc --project-name-and-root-format=as-provided`
);

View File

@ -23,22 +23,22 @@ describe('inlining', () => {
async (bundler) => {
const parent = uniq('parent');
runCLI(
`generate @nx/js:lib ${parent} --bundler=${bundler} --no-interactive`
`generate @nx/js:lib ${parent} --directory=libs/${parent} --bundler=${bundler} --no-interactive`
);
const buildable = uniq('buildable');
runCLI(
`generate @nx/js:lib ${buildable} --bundler=${bundler} --no-interactive`
`generate @nx/js:lib ${buildable} --directory=libs/${buildable} --bundler=${bundler} --no-interactive`
);
const buildableTwo = uniq('buildabletwo');
runCLI(
`generate @nx/js:lib ${buildableTwo} --bundler=${bundler} --no-interactive`
`generate @nx/js:lib ${buildableTwo} --directory=libs/${buildableTwo} --bundler=${bundler} --no-interactive`
);
const nonBuildable = uniq('nonbuildable');
runCLI(
`generate @nx/js:lib ${nonBuildable} --bundler=none --no-interactive`
`generate @nx/js:lib ${nonBuildable} --directory=libs/${nonBuildable} --bundler=none --no-interactive`
);
updateFile(`libs/${parent}/src/lib/${parent}.ts`, () => {
@ -102,13 +102,19 @@ describe('inlining', () => {
it('should inline nesting libraries', async () => {
const parent = uniq('parent');
runCLI(`generate @nx/js:lib ${parent} --no-interactive`);
runCLI(
`generate @nx/js:lib ${parent} --directory=libs/${parent} --no-interactive`
);
const child = uniq('child');
runCLI(`generate @nx/js:lib ${child} --bundler=none --no-interactive`);
runCLI(
`generate @nx/js:lib ${child} --directory=libs/${child} --bundler=none --no-interactive`
);
const grandChild = uniq('grandchild');
runCLI(`generate @nx/js:lib ${grandChild} --bundler=none --no-interactive`);
runCLI(
`generate @nx/js:lib ${grandChild} --directory=libs/${grandChild} --bundler=none --no-interactive`
);
updateFile(`libs/${parent}/src/lib/${parent}.ts`, () => {
return `
@ -151,7 +157,9 @@ describe('inlining', () => {
it('should allow inlining to be enabled without imports', async () => {
const parent = uniq('parent');
runCLI(`generate @nx/js:lib ${parent} --no-interactive`);
runCLI(
`generate @nx/js:lib ${parent} --directory=libs/${parent} --no-interactive`
);
updateFile(`libs/${parent}/src/lib/${parent}.ts`, () => {
return `

View File

@ -30,11 +30,13 @@ describe('packaging libs', () => {
const rollupLib = uniq('rolluplib');
runCLI(
`generate @nx/js:lib ${esbuildLib} --bundler=esbuild --no-interactive`
`generate @nx/js:lib ${esbuildLib} --directory=libs/${esbuildLib} --bundler=esbuild --no-interactive`
);
runCLI(`generate @nx/js:lib ${viteLib} --bundler=vite --no-interactive`);
runCLI(
`generate @nx/js:lib ${rollupLib} --bundler=rollup --no-interactive`
`generate @nx/js:lib ${viteLib} --directory=libs/${viteLib} --bundler=vite --no-interactive`
);
runCLI(
`generate @nx/js:lib ${rollupLib} --directory=libs/${rollupLib} --bundler=rollup --no-interactive`
);
updateFile(`libs/${rollupLib}/src/index.ts`, (content) => {
// Test that default functions work in ESM (Node).
@ -137,10 +139,18 @@ describe('packaging libs', () => {
const tscEsmLib = uniq('tscesmlib');
const swcEsmLib = uniq('swcesmlib');
runCLI(`generate @nx/js:lib ${tscLib} --bundler=tsc --no-interactive`);
runCLI(`generate @nx/js:lib ${swcLib} --bundler=swc --no-interactive`);
runCLI(`generate @nx/js:lib ${tscEsmLib} --bundler=tsc --no-interactive`);
runCLI(`generate @nx/js:lib ${swcEsmLib} --bundler=swc --no-interactive`);
runCLI(
`generate @nx/js:lib ${tscLib} --directory=libs/${tscLib} --bundler=tsc --no-interactive`
);
runCLI(
`generate @nx/js:lib ${swcLib} --directory=libs/${swcLib} --bundler=swc --no-interactive`
);
runCLI(
`generate @nx/js:lib ${tscEsmLib} --directory=libs/${tscEsmLib} --bundler=tsc --no-interactive`
);
runCLI(
`generate @nx/js:lib ${swcEsmLib} --directory=libs/${swcEsmLib} --bundler=swc --no-interactive`
);
// Change module format to ESM
updateJson(`libs/${tscEsmLib}/tsconfig.json`, (json) => {

View File

@ -1,4 +1,5 @@
import {
checkFilesExist,
cleanupProject,
killPorts,
newProject,
@ -29,8 +30,11 @@ describe('Next.js App Router', () => {
);
runCLI(`generate @nx/js:lib ${jsLib} --no-interactive`);
checkFilesExist(`${appName}/src/app/page.tsx`);
checkFilesExist(`${appName}-e2e/src/example.spec.ts`);
updateFile(
`apps/${appName}/src/app/page.tsx`,
`${appName}/src/app/page.tsx`,
`
import React from 'react';
import { ${jsLib} } from '@${proj}/${jsLib}';
@ -44,7 +48,7 @@ describe('Next.js App Router', () => {
);
updateFile(
`apps/${appName}-e2e/src/example.spec.ts`,
`${appName}-e2e/src/example.spec.ts`,
`
import { test, expect } from '@playwright/test';

View File

@ -187,11 +187,11 @@ describe(Button.name, () => {
function createLibWithCt(libName: string, buildable: boolean) {
runCLI(
`generate @nx/next:lib ${libName} --buildable=${buildable} --no-interactive`
`generate @nx/next:lib ${libName} --directory=libs/${libName} --buildable=${buildable} --no-interactive`
);
runCLI(
`generate @nx/next:component button --project=${libName} --flat --export --no-interactive`
`generate @nx/next:component button --directory=libs/${libName}/src/lib --export --no-interactive`
);
updateFile(`libs/${libName}/src/lib/button.tsx`, (content) => {
return `import { useEffect, useState } from 'react';

View File

@ -62,20 +62,20 @@ describe('@nx/next (legacy)', () => {
env: { NX_ADD_PLUGINS: 'false' },
});
updateFile(`apps/${appName}/redirects.js`, 'module.exports = [];');
updateFile(`${appName}/redirects.js`, 'module.exports = [];');
updateFile(
`apps/${appName}/nested/headers.js`,
`${appName}/nested/headers.js`,
`module.exports = require('./headers-2');`
);
updateFile(`apps/${appName}/nested/headers-2.js`, 'module.exports = [];');
updateFile(`apps/${appName}/next.config.js`, (content) => {
updateFile(`${appName}/nested/headers-2.js`, 'module.exports = [];');
updateFile(`${appName}/next.config.js`, (content) => {
return `const redirects = require('./redirects');\nconst headers = require('./nested/headers.js');\n${content}`;
});
runCLI(`build ${appName}`);
checkFilesExist(`dist/apps/${appName}/redirects.js`);
checkFilesExist(`dist/apps/${appName}/nested/headers.js`);
checkFilesExist(`dist/apps/${appName}/nested/headers-2.js`);
checkFilesExist(`dist/${appName}/redirects.js`);
checkFilesExist(`dist/${appName}/nested/headers.js`);
checkFilesExist(`dist/${appName}/nested/headers-2.js`);
}, 120_000);
it('should build and install pruned lock file', () => {
@ -87,10 +87,10 @@ describe('@nx/next (legacy)', () => {
const result = runCLI(`build ${appName} --generateLockfile=true`);
expect(result).not.toMatch(/Graph is not consistent/);
checkFilesExist(
`dist/apps/${appName}/${packageManagerLockFile[packageManager]}`
`dist/${appName}/${packageManagerLockFile[packageManager]}`
);
runCommand(`${getPackageManagerCommand().ciInstall}`, {
cwd: joinPathFragments(tmpProjPath(), 'dist/apps', appName),
cwd: joinPathFragments(tmpProjPath(), 'dist', appName),
});
}, 1_000_000);

View File

@ -97,12 +97,12 @@ describe('Next.js Styles', () => {
checkExport: false,
});
checkFilesExist(`apps/${tailwindApp}/tailwind.config.js`);
checkFilesExist(`apps/${tailwindApp}/postcss.config.js`);
checkFilesExist(`${tailwindApp}/tailwind.config.js`);
checkFilesExist(`${tailwindApp}/postcss.config.js`);
checkFilesDoNotExist(`apps/${tailwindApp}/pages/index.module.css`);
const appPage = readFile(`apps/${tailwindApp}/pages/index.tsx`);
const globalCss = readFile(`apps/${tailwindApp}/pages/styles.css`);
checkFilesDoNotExist(`${tailwindApp}/pages/index.module.css`);
const appPage = readFile(`${tailwindApp}/pages/index.tsx`);
const globalCss = readFile(`${tailwindApp}/pages/styles.css`);
expect(appPage).not.toContain(`import styles from './index.module.css';`);
expect(globalCss).toContain(`@tailwind base;`);
@ -122,12 +122,12 @@ describe('Next.js Styles', () => {
checkExport: false,
});
checkFilesExist(`apps/${tailwindApp}/tailwind.config.js`);
checkFilesExist(`apps/${tailwindApp}/postcss.config.js`);
checkFilesExist(`${tailwindApp}/tailwind.config.js`);
checkFilesExist(`${tailwindApp}/postcss.config.js`);
checkFilesDoNotExist(`apps/${tailwindApp}/app/page.module.css`);
const appPage = readFile(`apps/${tailwindApp}/app/page.tsx`);
const globalCss = readFile(`apps/${tailwindApp}/app/global.css`);
checkFilesDoNotExist(`${tailwindApp}/app/page.module.css`);
const appPage = readFile(`${tailwindApp}/app/page.tsx`);
const globalCss = readFile(`${tailwindApp}/app/global.css`);
expect(appPage).not.toContain(`import styles from './page.module.css';`);
expect(globalCss).toContain(`@tailwind base;`);

View File

@ -1,4 +1,5 @@
import {
checkFilesExist,
cleanupProject,
createFile,
listFiles,
@ -25,7 +26,7 @@ describe('NextJs SVGR support', () => {
`generate @nx/next:app ${appName} --no-interactive --appDir=true --src=true`
);
createFile(
`apps/${appName}/src/app/nx.svg`,
`${appName}/src/app/nx.svg`,
`
<svg version="1.1" width="300" height="200" xmlns="http://www.w3.org/2000/svg">
<text x="150" y="125" font-size="60" text-anchor="middle" fill="white">SVG for app</text>
@ -33,7 +34,7 @@ describe('NextJs SVGR support', () => {
`
);
updateFile(
`apps/${appName}/src/app/page.tsx`,
`${appName}/src/app/page.tsx`,
`
import Image from 'next/image';
import svgImg, { ReactComponent as Logo } from './nx.svg';
@ -47,8 +48,9 @@ describe('NextJs SVGR support', () => {
}
`
);
checkFilesExist(`${appName}/next.config.js`);
updateFile(
`apps/${appName}/next.config.js`,
`${appName}/next.config.js`,
`
const { composePlugins, withNx } = require('@nx/next');
const nextConfig = {
@ -65,14 +67,14 @@ describe('NextJs SVGR support', () => {
runCLI(`build ${appName}`);
const pageFile = readFile(`apps/${appName}/.next/server/app/page.js`);
const svgFile = listFiles(`apps/${appName}/.next/static/media`).find((f) =>
const pageFile = readFile(`${appName}/.next/server/app/page.js`);
const svgFile = listFiles(`${appName}/.next/static/media`).find((f) =>
/nx\.[a-z0-9]+\.svg$/.test(f)
);
expect(`apps/${appName}/.next/static/chunks/app/${pageFile}`).toMatch(
expect(`${appName}/.next/static/chunks/app/${pageFile}`).toMatch(
/SVG for app/
);
expect(`apps/${appName}/.next/static/chunks/app/${pageFile}`).toMatch(
expect(`${appName}/.next/static/chunks/app/${pageFile}`).toMatch(
/Alt for SVG img tag/
);
expect(svgFile).toBeTruthy();
@ -84,15 +86,16 @@ describe('NextJs SVGR support', () => {
`generate @nx/next:app ${appName} --no-interactive --appDir=true --src=true`
);
createFile(
`apps/${appName}/src/app/nx.svg`,
`${appName}/src/app/nx.svg`,
`
<svg version="1.1" width="300" height="200" xmlns="http://www.w3.org/2000/svg">
<text x="150" y="125" font-size="60" text-anchor="middle" fill="white">SVG for app</text>
</svg>
`
);
checkFilesExist(`${appName}/src/app/page.tsx`);
updateFile(
`apps/${appName}/src/app/page.tsx`,
`${appName}/src/app/page.tsx`,
`
import Image from 'next/image';
import svgImg, { ReactComponent as Logo } from './nx.svg';
@ -106,8 +109,10 @@ describe('NextJs SVGR support', () => {
}
`
);
checkFilesExist(`${appName}/next.config.js`);
updateFile(
`apps/${appName}/next.config.js`,
`${appName}/next.config.js`,
`
const { composePlugins, withNx } = require('@nx/next');
const nextConfig = {
@ -128,14 +133,14 @@ describe('NextJs SVGR support', () => {
runCLI(`build ${appName}`);
const pageFile = readFile(`apps/${appName}/.next/server/app/page.js`);
const svgFile = listFiles(`apps/${appName}/.next/static/media`).find((f) =>
const pageFile = readFile(`${appName}/.next/server/app/page.js`);
const svgFile = listFiles(`${appName}/.next/static/media`).find((f) =>
/nx\.[a-z0-9]+\.svg$/.test(f)
);
expect(`apps/${appName}/.next/static/chunks/app/${pageFile}`).toMatch(
expect(`${appName}/.next/static/chunks/app/${pageFile}`).toMatch(
/SVG for app/
);
expect(`apps/${appName}/.next/static/chunks/app/${pageFile}`).toMatch(
expect(`${appName}/.next/static/chunks/app/${pageFile}`).toMatch(
/Alt for SVG img tag/
);
expect(svgFile).toBeTruthy();

View File

@ -38,8 +38,9 @@ describe('Next.js Webpack', () => {
}
);
checkFilesExist(`${appName}/next.config.js`);
updateFile(
`apps/${appName}/next.config.js`,
`${appName}/next.config.js`,
`
const { withNx } = require('@nx/next');
const nextConfig = {
@ -88,11 +89,11 @@ describe('Next.js Webpack', () => {
delete process.env.NODE_ENV;
const result = runCLI(`build ${appName}`);
checkFilesExist(`dist/apps/${appName}/next.config.js`);
checkFilesExist(`dist/${appName}/next.config.js`);
expect(result).toContain('NODE_ENV is production');
updateFile(
`apps/${appName}/next.config.js`,
`${appName}/next.config.js`,
`
const { withNx } = require('@nx/next');
// Not including "nx" entry should still work.
@ -103,15 +104,15 @@ describe('Next.js Webpack', () => {
);
rmDist();
runCLI(`build ${appName}`);
checkFilesExist(`dist/apps/${appName}/next.config.js`);
checkFilesExist(`dist/${appName}/next.config.js`);
// Make sure withNx works with run-commands.
updateJson(join('apps', appName, 'project.json'), (json) => {
updateJson(join(appName, 'project.json'), (json) => {
json.targets.build = {
command: 'npx next build',
outputs: [`{projectRoot}/.next`],
options: {
cwd: `apps/${appName}`,
cwd: `${appName}`,
},
};
return json;
@ -119,6 +120,6 @@ describe('Next.js Webpack', () => {
expect(() => {
runCLI(`build ${appName}`);
}).not.toThrow();
checkFilesExist(`dist/apps/${appName}/.next/build-manifest.json`);
checkFilesExist(`dist/${appName}/.next/build-manifest.json`);
}, 300_000);
});

View File

@ -74,8 +74,8 @@ describe('Next.js Applications', () => {
`generate @nx/next:app ${appName} --no-interactive --style=css --appDir=false`
);
checkFilesDoNotExist(`apps/${appName}/.next/build-manifest.json`);
checkFilesDoNotExist(`apps/${appName}/.nx-helpers/with-nx.js`);
checkFilesDoNotExist(`${appName}/.next/build-manifest.json`);
checkFilesDoNotExist(`${appName}/.nx-helpers/with-nx.js`);
expect(() => {
runCLI(`build ${appName} --configuration=development`);
@ -89,7 +89,7 @@ describe('Next.js Applications', () => {
`generate @nx/next:app ${appName} --no-interactive --js --appDir=false --e2eTestRunner=playwright`
);
checkFilesExist(`apps/${appName}/src/pages/index.js`);
checkFilesExist(`${appName}/src/pages/index.js`);
await checkApp(appName, {
checkUnitTest: true,
@ -105,7 +105,7 @@ describe('Next.js Applications', () => {
`generate @nx/next:lib ${libName} --no-interactive --style=none --js`
);
const mainPath = `apps/${appName}/src/pages/index.js`;
const mainPath = `${appName}/src/pages/index.js`;
updateFile(
mainPath,
`import '@${proj}/${libName}';\n` + readFile(mainPath)
@ -113,7 +113,7 @@ describe('Next.js Applications', () => {
// Update lib to use css modules
updateFile(
`libs/${libName}/src/lib/${libName}.js`,
`${libName}/src/lib/${libName}.js`,
`
import styles from './style.module.css';
export function Test() {
@ -122,7 +122,7 @@ describe('Next.js Applications', () => {
`
);
updateFile(
`libs/${libName}/src/lib/style.module.css`,
`${libName}/src/lib/style.module.css`,
`
.container {}
`
@ -142,7 +142,7 @@ describe('Next.js Applications', () => {
runCLI(`generate @nx/next:app ${appName} --no-interactive --no-swc`);
// Next.js enables SWC when custom .babelrc is not provided.
checkFilesExist(`apps/${appName}/.babelrc`);
checkFilesExist(`${appName}/.babelrc`);
await checkApp(appName, {
checkUnitTest: false,
@ -157,11 +157,11 @@ describe('Next.js Applications', () => {
runCLI(`generate @nx/next:app ${appName} --no-interactive --custom-server`);
checkFilesExist(`apps/${appName}/server/main.ts`);
checkFilesExist(`${appName}/server/main.ts`);
const result = runCLI(`build ${appName}`);
checkFilesExist(`dist/apps/${appName}/server/main.js`);
checkFilesExist(`dist/${appName}/server/main.js`);
expect(result).toContain(
`Successfully ran target build for project ${appName}`
@ -175,11 +175,11 @@ describe('Next.js Applications', () => {
`generate @nx/next:app ${appName} --swc=false --no-interactive --custom-server`
);
checkFilesExist(`apps/${appName}/server/main.ts`);
checkFilesExist(`${appName}/server/main.ts`);
const result = runCLI(`build ${appName}`);
checkFilesExist(`dist/apps/${appName}/server/main.js`);
checkFilesExist(`dist/${appName}/server/main.js`);
expect(result).toContain(
`Successfully ran target build for project ${appName}`

View File

@ -18,8 +18,6 @@ export async function checkApp(
appsDir?: string;
}
) {
const appsDir = opts.appsDir ?? 'apps';
if (opts.checkLint) {
const lintResults = runCLI(`lint ${appName}`);
expect(lintResults).toContain('Successfully ran target lint');
@ -36,14 +34,14 @@ export async function checkApp(
expect(buildResult).toContain(`Successfully ran target build`);
// Executor will point to dist, whereas inferred build target will output to `<proj-root>/.next`
try {
checkFilesExist(`dist/${appsDir}/${appName}/.next/build-manifest.json`);
checkFilesExist(`dist/${appName}/.next/build-manifest.json`);
} catch {
checkFilesExist(`${appsDir}/${appName}/.next/build-manifest.json`);
checkFilesExist(`${appName}/.next/build-manifest.json`);
}
// Only the executor will output package.json file to dist
if (exists(`dist/${appsDir}/${appName}/package.json`)) {
const packageJson = readJson(`dist/${appsDir}/${appName}/package.json`);
if (exists(`dist/${appName}/package.json`)) {
const packageJson = readJson(`dist/${appName}/package.json`);
expect(packageJson.dependencies.react).toBeDefined();
expect(packageJson.dependencies['react-dom']).toBeDefined();
expect(packageJson.dependencies.next).toBeDefined();

View File

@ -23,7 +23,9 @@ describe('Node Applications + esbuild', () => {
it('should generate an app using esbuild', async () => {
const app = uniq('nodeapp');
runCLI(`generate @nx/node:app ${app} --bundler=esbuild --no-interactive`);
runCLI(
`generate @nx/node:app ${app} --bundler=esbuild --directory=apps/${app} --no-interactive`
);
checkFilesDoNotExist(`apps/${app}/webpack.config.js`);

View File

@ -80,19 +80,21 @@ describe('Node Applications + webpack', () => {
const nestApp = uniq('nest');
beforeAll(() => {
runCLI(`generate @nx/node:lib ${testLib1}`);
runCLI(`generate @nx/node:lib ${testLib2} --importPath=@acme/test2`);
runCLI(`generate @nx/node:lib ${testLib1} --directory=libs/${testLib1}`);
runCLI(
`generate @nx/node:app ${expressApp} --framework=express --port=7000 --no-interactive`
`generate @nx/node:lib ${testLib2} --directory=libs/${testLib2} --importPath=@acme/test2`
);
runCLI(
`generate @nx/node:app ${fastifyApp} --framework=fastify --port=7001 --no-interactive`
`generate @nx/node:app ${expressApp} --directory=apps/${expressApp} --framework=express --port=7000 --no-interactive`
);
runCLI(
`generate @nx/node:app ${koaApp} --framework=koa --port=7002 --no-interactive`
`generate @nx/node:app ${fastifyApp} --directory=apps/${fastifyApp} --framework=fastify --port=7001 --no-interactive`
);
runCLI(
`generate @nx/node:app ${nestApp} --framework=nest --port=7003 --bundler=webpack --no-interactive`
`generate @nx/node:app ${koaApp} --directory=apps/${koaApp} --framework=koa --port=7002 --no-interactive`
);
runCLI(
`generate @nx/node:app ${nestApp} --directory=apps/${nestApp} --framework=nest --port=7003 --bundler=webpack --no-interactive`
);
addLibImport(expressApp, testLib1);
@ -165,7 +167,7 @@ describe('Node Applications + webpack', () => {
const expressApp = 'docker-express-app'; // needs to be consistent for the Dockerfile snapshot
runCLI(
`generate @nx/node:app ${expressApp} --framework=express --docker --no-interactive`
`generate @nx/node:app ${expressApp} --framework=express --directory=apps/${expressApp} --docker --no-interactive`
);
checkFilesExist(`apps/${expressApp}/Dockerfile`);
@ -179,10 +181,10 @@ describe('Node Applications + webpack', () => {
// Set ports to avoid conflicts with other tests that might run in parallel
runCLI(
`generate @nx/node:app ${nodeApp1} --framework=none --no-interactive --port=4444`
`generate @nx/node:app ${nodeApp1} --directory=apps/${nodeApp1} --framework=none --no-interactive --port=4444`
);
runCLI(
`generate @nx/node:app ${nodeApp2} --framework=none --no-interactive --port=4445`
`generate @nx/node:app ${nodeApp2} --directory=apps/${nodeApp2} --framework=none --no-interactive --port=4445`
);
updateJson(join('apps', nodeApp1, 'project.json'), (config) => {
config.targets.serve.options.waitUntilTargets = [`${nodeApp2}:build`];

View File

@ -29,9 +29,12 @@ describe('Node Applications + webpack', () => {
const app = uniq('nodeapp');
// This fails with Crystal enabled because `--optimization` is not a correct flag to pass to `webpack`.
runCLI(`generate @nx/node:app ${app} --bundler=webpack --no-interactive`, {
env: { NX_ADD_PLUGINS: 'false' },
});
runCLI(
`generate @nx/node:app ${app} --directory=apps/${app} --bundler=webpack --no-interactive`,
{
env: { NX_ADD_PLUGINS: 'false' },
}
);
checkFilesExist(`apps/${app}/webpack.config.js`);
@ -62,7 +65,9 @@ describe('Node Applications + webpack', () => {
// Test that serve can re-run dependency builds.
const lib = uniq('nodelib');
runCLI(`generate @nx/js:lib ${lib} --bundler=esbuild --no-interactive`);
runCLI(
`generate @nx/js:lib ${lib} --bundler=esbuild --directory=libs/${lib} --no-interactive`
);
updateJson(join('apps', app, 'project.json'), (config) => {
// Since we read from lib from dist, we should re-build it when lib changes.

View File

@ -71,7 +71,9 @@ describe('Node Applications', () => {
const nodeapp = uniq('nodeapp');
const port = getRandomPort();
process.env.PORT = `${port}`;
runCLI(`generate @nx/node:app ${nodeapp} --port=${port} --linter=eslint`);
runCLI(
`generate @nx/node:app ${nodeapp} --port=${port} --directory=apps/${nodeapp} --linter=eslint`
);
const lintResults = runCLI(`lint ${nodeapp}`);
expect(lintResults).toContain('Successfully ran target lint');
@ -90,7 +92,9 @@ describe('Node Applications', () => {
// TODO(crystal, @ndcunningham): This does not work because NxWebpackPlugin({}) outputFilename does not work.
xit('should be able to generate the correct outputFileName in options', async () => {
const nodeapp = uniq('nodeapp');
runCLI(`generate @nx/node:app ${nodeapp} --linter=eslint`);
runCLI(
`generate @nx/node:app ${nodeapp} --directory=apps/${nodeapp} --linter=eslint`
);
updateJson(join('apps', nodeapp, 'project.json'), (config) => {
config.targets.build.options.outputFileName = 'index.js';
@ -106,7 +110,7 @@ describe('Node Applications', () => {
const port = getRandomPort();
process.env.PORT = `${port}`;
runCLI(
`generate @nx/node:app ${nodeapp} --port=${port} --linter=eslint --bundler=webpack`
`generate @nx/node:app ${nodeapp} --directory=apps/${nodeapp} --port=${port} --linter=eslint --bundler=webpack`
);
const lintResults = runCLI(`lint ${nodeapp}`);
@ -188,7 +192,7 @@ module.exports = {
const nodeapp = uniq('nodeapp');
runCLI(
`generate @nx/node:app ${nodeapp} --linter=eslint --bundler=webpack --framework=none`
`generate @nx/node:app ${nodeapp} --directory=apps/${nodeapp} --linter=eslint --bundler=webpack --framework=none`
);
updateFile('.env', `NX_FOOBAR="test foo bar"`);
@ -246,7 +250,7 @@ module.exports = {
process.env.PORT = `${port}`;
runCLI(
`generate @nx/express:app ${nodeapp} --port=${port} --linter=eslint`
`generate @nx/express:app ${nodeapp} --directory=apps/${nodeapp} --port=${port} --linter=eslint`
);
const lintResults = runCLI(`lint ${nodeapp}`);
@ -296,7 +300,9 @@ module.exports = {
it('should be able to generate a nest application', async () => {
const nestapp = uniq('nestapp');
const port = 3335;
runCLI(`generate @nx/nest:app ${nestapp} --linter=eslint`);
runCLI(
`generate @nx/nest:app ${nestapp} --directory=apps/${nestapp} --linter=eslint`
);
const lintResults = runCLI(`lint ${nestapp}`);
expect(lintResults).toContain('Successfully ran target lint');
@ -424,7 +430,9 @@ describe('Build Node apps', () => {
xit('should generate a package.json with the `--generatePackageJson` flag', async () => {
const packageManager = detectPackageManager(tmpProjPath());
const nestapp = uniq('nestapp');
runCLI(`generate @nx/nest:app ${nestapp} --linter=eslint`);
runCLI(
`generate @nx/nest:app ${nestapp} --linter=eslint --directory=apps/${nestapp}`
);
await runCLIAsync(`build ${nestapp} --generatePackageJson`);
@ -528,7 +536,9 @@ ${jslib}();
const port = getRandomPort();
process.env.PORT = `${port}`;
runCLI(`generate @nx/node:app ${appName} --port=${port} --no-interactive`);
runCLI(
`generate @nx/node:app ${appName} --port=${port} --no-interactive --directory=apps/${appName}`
);
// deleteOutputPath should default to true
createFile(`dist/apps/${appName}/_should_remove.txt`);
@ -584,13 +594,6 @@ ${jslib}();
`Successfully ran target test for project ${appName}`
);
// assert scoped project names are not supported when --project-name-and-root-format=derived
expect(() =>
runCLI(
`generate @nx/node:lib ${libName} --buildable --project-name-and-root-format=derived --no-interactive`
)
).toThrow();
runCLI(
`generate @nx/node:lib ${libName} --buildable --project-name-and-root-format=as-provided --no-interactive`
);
@ -668,7 +671,7 @@ ${jslib}();
describe('nest libraries', function () {
it('should be able to generate a nest library', async () => {
const nestlib = uniq('nestlib');
runCLI(`generate @nx/nest:lib ${nestlib}`);
runCLI(`generate @nx/nest:lib ${nestlib} --directory=libs/${nestlib}`);
const lintResults = runCLI(`lint ${nestlib}`);
expect(lintResults).toContain('Successfully ran target lint');
@ -723,7 +726,9 @@ ${jslib}();
it('should have plugin output if specified in `transformers`', async () => {
const nestlib = uniq('nestlib');
runCLI(`generate @nx/nest:lib ${nestlib} --buildable`);
runCLI(
`generate @nx/nest:lib ${nestlib} --buildable --directory=libs/${nestlib}`
);
packageInstall('@nestjs/swagger', undefined, '^7.0.0');

View File

@ -20,7 +20,7 @@ import { join } from 'path';
describe('Nx Affected and Graph Tests', () => {
let proj: string;
beforeAll(() => (proj = newProject({ packages: ['@nx/web', '@nx/js'] })));
beforeAll(() => (proj = newProject()));
afterAll(() => cleanupProject());
describe('affected:*', () => {
@ -31,12 +31,12 @@ describe('Nx Affected and Graph Tests', () => {
const mylib = uniq('mylib');
const mylib2 = uniq('mylib2');
const mypublishablelib = uniq('mypublishablelib');
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/web:app ${myapp2}`);
runCLI(`generate @nx/js:lib ${mylib}`);
runCLI(`generate @nx/js:lib ${mylib2}`);
runCLI(`generate @nx/web:app ${myapp} --directory apps/${myapp}`);
runCLI(`generate @nx/web:app ${myapp2} --directory apps/${myapp2}`);
runCLI(`generate @nx/js:lib ${mylib} --directory libs/${mylib}`);
runCLI(`generate @nx/js:lib ${mylib2} --directory libs/${mylib2}`);
runCLI(
`generate @nx/js:lib ${mypublishablelib} --publishable --importPath=@${proj}/${mypublishablelib} --tags=ui`
`generate @nx/js:lib ${mypublishablelib} --directory libs/${mypublishablelib} --publishable --importPath=@${proj}/${mypublishablelib} --tags=ui`
);
updateFile(
@ -193,26 +193,26 @@ describe('Nx Affected and Graph Tests', () => {
});
function generateAll() {
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/web:app ${myapp2}`);
runCLI(`generate @nx/js:lib ${mylib}`);
runCLI(`generate @nx/web:app ${myapp} --directory=apps/${myapp}`);
runCLI(`generate @nx/web:app ${myapp2} --directory=apps/${myapp2}`);
runCLI(`generate @nx/js:lib ${mylib} --directory=libs/${mylib}`);
runCommand(`git add . && git commit -am "add all"`);
}
it('should not affect other projects by generating a new project', () => {
// TODO: investigate why affected gives different results on windows
if (isNotWindows()) {
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/web:app ${myapp} --directory=apps/${myapp}`);
expect(runCLI('show projects --affected')).toContain(myapp);
runCommand(`git add . && git commit -am "add ${myapp}"`);
runCLI(`generate @nx/web:app ${myapp2}`);
runCLI(`generate @nx/web:app ${myapp2} --directory=apps/${myapp2}`);
let output = runCLI('show projects --affected');
expect(output).not.toContain(myapp);
expect(output).toContain(myapp2);
runCommand(`git add . && git commit -am "add ${myapp2}"`);
runCLI(`generate @nx/js:lib ${mylib}`);
runCLI(`generate @nx/js:lib ${mylib} --directory=libs/${mylib}`);
output = runCLI('show projects --affected');
expect(output).not.toContain(myapp);
expect(output).not.toContain(myapp2);
@ -314,11 +314,11 @@ describe('Nx Affected and Graph Tests', () => {
mylib = uniq('mylib');
mylib2 = uniq('mylib2');
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/web:app ${myapp2}`);
runCLI(`generate @nx/web:app ${myapp3}`);
runCLI(`generate @nx/js:lib ${mylib}`);
runCLI(`generate @nx/js:lib ${mylib2}`);
runCLI(`generate @nx/web:app ${myapp} --directory=apps/${myapp}`);
runCLI(`generate @nx/web:app ${myapp2} --directory=apps/${myapp2}`);
runCLI(`generate @nx/web:app ${myapp3} --directory=apps/${myapp3}`);
runCLI(`generate @nx/js:lib ${mylib} --directory=libs/${mylib}`);
runCLI(`generate @nx/js:lib ${mylib2} --directory=libs/${mylib2}`);
runCommand(`git init`);
runCommand(`git config user.email "test@test.com"`);
@ -536,11 +536,13 @@ describe('show projects --affected', () => {
const mylib2 = uniq('mylib2');
const mypublishablelib = uniq('mypublishablelib');
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/web:app ${myapp2}`);
runCLI(`generate @nx/js:lib ${mylib}`);
runCLI(`generate @nx/js:lib ${mylib2}`);
runCLI(`generate @nx/js:lib ${mypublishablelib}`);
runCLI(`generate @nx/web:app ${myapp} --directory=apps/${myapp}`);
runCLI(`generate @nx/web:app ${myapp2} --directory=apps/${myapp2}`);
runCLI(`generate @nx/js:lib ${mylib} --directory=libs/${mylib}`);
runCLI(`generate @nx/js:lib ${mylib2} --directory=libs/${mylib2}`);
runCLI(
`generate @nx/js:lib ${mypublishablelib} --directory=libs/${mypublishablelib}`
);
const app1ElementSpec = readFile(
`apps/${myapp}/src/app/app.element.spec.ts`

View File

@ -149,7 +149,7 @@ describe('cache', () => {
it('should support using globs as outputs', async () => {
const mylib = uniq('mylib');
runCLI(`generate @nx/js:library ${mylib}`);
runCLI(`generate @nx/js:library ${mylib} --directory=libs/${mylib}`);
updateJson(join('libs', mylib, 'project.json'), (c) => {
c.targets.build = {
cache: true,
@ -248,9 +248,9 @@ describe('cache', () => {
const parent = uniq('parent');
const child1 = uniq('child1');
const child2 = uniq('child2');
runCLI(`generate @nx/js:lib ${parent}`);
runCLI(`generate @nx/js:lib ${child1}`);
runCLI(`generate @nx/js:lib ${child2}`);
runCLI(`generate @nx/js:lib ${parent} --directory=libs/${parent}`);
runCLI(`generate @nx/js:lib ${child1} --directory=libs/${child1}`);
runCLI(`generate @nx/js:lib ${child2} --directory=libs/${child2}`);
updateJson(`nx.json`, (c) => {
c.namedInputs = {
default: ['{projectRoot}/**/*'],
@ -315,7 +315,7 @@ describe('cache', () => {
it('should support ENV as an input', () => {
const lib = uniq('lib');
runCLI(`generate @nx/js:lib ${lib}`);
runCLI(`generate @nx/js:lib ${lib} --directory=libs/${lib}`);
updateJson(`nx.json`, (c) => {
c.targetDefaults = {
echo: {

View File

@ -20,7 +20,7 @@ describe('Extra Nx Misc Tests', () => {
describe('Output Style', () => {
it('should stream output', async () => {
const myapp = 'abcdefghijklmon';
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/web:app ${myapp} --directory=apps/${myapp}`);
updateJson(join('apps', myapp, 'project.json'), (c) => {
c.targets['inner'] = {
@ -103,7 +103,7 @@ describe('Extra Nx Misc Tests', () => {
describe('Run Commands', () => {
const mylib = uniq('lib');
beforeAll(() => {
runCLI(`generate @nx/js:lib ${mylib}`);
runCLI(`generate @nx/js:lib ${mylib} --directory=libs/${mylib}`);
});
it('should not override environment variables already set when setting a custom env file path', async () => {
@ -249,7 +249,7 @@ describe('Extra Nx Misc Tests', () => {
const folder = `dist/libs/${mylib}/some-folder`;
runCLI(`generate @nx/js:lib ${mylib}`);
runCLI(`generate @nx/js:lib ${mylib} --directory=libs/${mylib}`);
runCLI(
`generate @nx/workspace:run-commands build --command=echo --outputs=${folder}/ --project=${mylib}`
@ -296,7 +296,7 @@ describe('Extra Nx Misc Tests', () => {
beforeAll(() => {
runCLI(
`generate @nx/js:lib ${libName} --bundler=none --unitTestRunner=none --no-interactive`
`generate @nx/js:lib ${libName} --directory=libs/${libName} --bundler=none --unitTestRunner=none --no-interactive`
);
});
@ -366,7 +366,7 @@ NX_USERNAME=$FIRSTNAME $LASTNAME`
const baseLib = 'lib-base-123';
beforeAll(() => {
runCLI(`generate @nx/js:lib ${baseLib}`);
runCLI(`generate @nx/js:lib ${baseLib} --directory=libs/${baseLib}`);
});
it('should correctly expand default task inputs', () => {
@ -387,7 +387,9 @@ NX_USERNAME=$FIRSTNAME $LASTNAME`
it('should correctly expand dependent task inputs', () => {
const dependentLib = 'lib-dependent-123';
runCLI(`generate @nx/js:lib ${dependentLib}`);
runCLI(
`generate @nx/js:lib ${dependentLib} --directory=libs/${dependentLib}`
);
updateJson(join('libs', baseLib, 'project.json'), (config) => {
config.targets['build'].inputs = ['default', '^default'];

View File

@ -16,7 +16,7 @@ describe('Invoke Runner', () => {
it('should invoke runner imperatively ', async () => {
const mylib = uniq('mylib');
runCLI(`generate @nx/js:lib ${mylib}`);
runCLI(`generate @nx/js:lib ${mylib} --directory=libs/${mylib}`);
updateJson(join('libs', mylib, 'project.json'), (c) => {
c.targets['prebuild'] = {
command: 'echo prebuild',

View File

@ -43,8 +43,10 @@ describe('Nx Commands', () => {
runCLI('show projects').replace(/.*nx show projects( --verbose)?\n/, '')
).toEqual('');
runCLI(`generate @nx/web:app ${app1} --tags e2etag`);
runCLI(`generate @nx/web:app ${app2}`);
runCLI(
`generate @nx/web:app ${app1} --tags e2etag --directory=apps/${app1}`
);
runCLI(`generate @nx/web:app ${app2} --directory=apps/${app2}`);
const s = runCLI('show projects').split('\n');
@ -68,7 +70,7 @@ describe('Nx Commands', () => {
it('should show detailed project info', () => {
const app = uniq('myapp');
runCLI(`generate @nx/web:app ${app}`);
runCLI(`generate @nx/web:app ${app} --directory=apps/${app}`);
const project: ProjectConfiguration = JSON.parse(
runCLI(`show project ${app}`)
);
@ -78,7 +80,7 @@ describe('Nx Commands', () => {
it('should open project details view', async () => {
const app = uniq('myapp');
runCLI(`generate @nx/web:app ${app}`);
runCLI(`generate @nx/web:app ${app} --directory=apps/${app}`);
let url: string;
let port: number;
const child_process = await runCommandUntil(
@ -180,8 +182,8 @@ describe('Nx Commands', () => {
const mylib = uniq('mylib');
beforeAll(async () => {
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/js:lib ${mylib}`);
runCLI(`generate @nx/web:app ${myapp} --directory=apps/${myapp}`);
runCLI(`generate @nx/js:lib ${mylib} --directory=libs/${mylib}`);
});
beforeEach(() => {

View File

@ -37,7 +37,7 @@ describe('Nx Running Tests', () => {
describe('(forwarding params)', () => {
let proj = uniq('proj');
beforeAll(() => {
runCLI(`generate @nx/js:lib ${proj}`);
runCLI(`generate @nx/js:lib ${proj} --directory=libs/${proj}`);
updateJson(`libs/${proj}/project.json`, (c) => {
c.targets['echo'] = {
command: 'echo ECHO:',
@ -107,7 +107,7 @@ describe('Nx Running Tests', () => {
it('should execute long running tasks', () => {
const myapp = uniq('myapp');
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/web:app ${myapp} --directory=apps/${myapp}`);
updateJson(`apps/${myapp}/project.json`, (c) => {
c.targets['counter'] = {
executor: '@nx/workspace:counter',
@ -127,7 +127,7 @@ describe('Nx Running Tests', () => {
it('should run npm scripts', async () => {
const mylib = uniq('mylib');
runCLI(`generate @nx/node:lib ${mylib}`);
runCLI(`generate @nx/node:lib ${mylib} --directory=libs/${mylib}`);
// Used to restore targets to lib after test
const original = readJson(`libs/${mylib}/project.json`);
@ -172,7 +172,7 @@ describe('Nx Running Tests', () => {
beforeAll(async () => {
app = uniq('myapp');
runCLI(`generate @nx/web:app ${app}`);
runCLI(`generate @nx/web:app ${app} --directory=apps/${app}`);
});
it('should support using {projectRoot} in options blocks in project.json', async () => {
@ -236,7 +236,7 @@ describe('Nx Running Tests', () => {
it('should pass env option to nx:run-commands executor', () => {
const mylib = uniq('mylib');
runCLI(`generate @nx/js:lib ${mylib}`);
runCLI(`generate @nx/js:lib ${mylib} --directory=libs/${mylib}`);
updateJson(`libs/${mylib}/project.json`, (c) => {
c.targets['echo'] = {
@ -257,7 +257,7 @@ describe('Nx Running Tests', () => {
it('should not run dependencies if --no-dependencies is passed', () => {
const mylib = uniq('mylib');
runCLI(`generate @nx/js:lib ${mylib}`);
runCLI(`generate @nx/js:lib ${mylib} --directory=libs/${mylib}`);
updateJson(`libs/${mylib}/project.json`, (c) => {
c.targets['one'] = {
@ -294,8 +294,8 @@ describe('Nx Running Tests', () => {
it('should stop executing all tasks when one of the tasks fails', async () => {
const myapp1 = uniq('a');
const myapp2 = uniq('b');
runCLI(`generate @nx/web:app ${myapp1}`);
runCLI(`generate @nx/web:app ${myapp2}`);
runCLI(`generate @nx/web:app ${myapp1} --directory=apps/${myapp1}`);
runCLI(`generate @nx/web:app ${myapp2} --directory=apps/${myapp2}`);
updateJson(`apps/${myapp1}/project.json`, (c) => {
c.targets['error'] = {
command: 'echo boom1 && exit 1',
@ -345,14 +345,14 @@ describe('Nx Running Tests', () => {
describe('run-one', () => {
it('should build a specific project', () => {
const myapp = uniq('app');
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/web:app ${myapp} --directory=apps/${myapp}`);
runCLI(`build ${myapp}`);
}, 10000);
it('should support project name positional arg non-consecutive to target', () => {
const myapp = uniq('app');
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/web:app ${myapp} --directory=apps/${myapp}`);
runCLI(`build --verbose ${myapp}`);
}, 10000);
@ -363,7 +363,7 @@ describe('Nx Running Tests', () => {
const expectedOutput = uniq('myEchoedString');
const expectedEnvOutput = uniq('myEnvString');
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/web:app ${myapp} --directory=apps/${myapp}`);
updateFile(
`apps/${myapp}/package.json`,
JSON.stringify({
@ -398,7 +398,7 @@ describe('Nx Running Tests', () => {
it('should run targets inferred from plugin-specified project files', () => {
// Setup an app to extend
const myapp = uniq('app');
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/web:app ${myapp} --directory=apps/${myapp}`);
// Register an Nx plugin
const plugin = `module.exports = {
@ -427,7 +427,7 @@ describe('Nx Running Tests', () => {
it('should build a specific project with the daemon disabled', () => {
const myapp = uniq('app');
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/web:app ${myapp} --directory=apps/${myapp}`);
const buildWithDaemon = runCLI(`build ${myapp}`, {
env: { NX_DAEMON: 'false' },
@ -444,7 +444,7 @@ describe('Nx Running Tests', () => {
it('should build the project when within the project root', () => {
const myapp = uniq('app');
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/web:app ${myapp} --directory=apps/${myapp}`);
// Should work within the project directory
expect(runCommand(`cd apps/${myapp}/src && npx nx build`)).toContain(
@ -523,9 +523,9 @@ describe('Nx Running Tests', () => {
myapp = uniq('myapp');
mylib1 = uniq('mylib1');
mylib2 = uniq('mylib1');
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/js:lib ${mylib1}`);
runCLI(`generate @nx/js:lib ${mylib2}`);
runCLI(`generate @nx/web:app ${myapp} --directory=apps/${myapp}`);
runCLI(`generate @nx/js:lib ${mylib1} --directory=libs/${mylib1}`);
runCLI(`generate @nx/js:lib ${mylib2} --directory=libs/${mylib2}`);
updateFile(
`apps/${myapp}/src/main.ts`,
@ -610,15 +610,19 @@ describe('Nx Running Tests', () => {
const libC = uniq('libc-rand');
const libD = uniq('libd-rand');
runCLI(`generate @nx/web:app ${appA}`);
runCLI(`generate @nx/js:lib ${libA} --bundler=tsc --defaults`);
runCLI(`generate @nx/web:app ${appA} --directory=apps/${appA}`);
runCLI(
`generate @nx/js:lib ${libB} --bundler=tsc --defaults --tags=ui-a`
`generate @nx/js:lib ${libA} --bundler=tsc --defaults --directory=libs/${libA}`
);
runCLI(
`generate @nx/js:lib ${libC} --bundler=tsc --defaults --tags=ui-b,shared`
`generate @nx/js:lib ${libB} --bundler=tsc --defaults --tags=ui-a --directory=libs/${libB}`
);
runCLI(
`generate @nx/js:lib ${libC} --bundler=tsc --defaults --tags=ui-b,shared --directory=libs/${libC}`
);
runCLI(
`generate @nx/node:lib ${libD} --defaults --tags=api --directory=libs/${libD}`
);
runCLI(`generate @nx/node:lib ${libD} --defaults --tags=api`);
// libA depends on libC
updateFile(
@ -723,8 +727,8 @@ describe('Nx Running Tests', () => {
it('should run multiple targets', () => {
const myapp1 = uniq('myapp');
const myapp2 = uniq('myapp');
runCLI(`generate @nx/web:app ${myapp1}`);
runCLI(`generate @nx/web:app ${myapp2}`);
runCLI(`generate @nx/web:app ${myapp1} --directory=apps/${myapp1}`);
runCLI(`generate @nx/web:app ${myapp2} --directory=apps/${myapp2}`);
let outputs = runCLI(
// Options with lists can be specified using multiple args or with a delimiter (comma or space).
@ -750,9 +754,11 @@ describe('Nx Running Tests', () => {
pkg2 = uniq('package');
pkgRoot = tmpProjPath(path.join('libs', pkg));
pkg2Root = tmpProjPath(path.join('libs', pkg2));
runCLI(`generate @nx/js:lib ${pkg} --bundler=none --unitTestRunner=none`);
runCLI(
`generate @nx/js:lib ${pkg2} --bundler=none --unitTestRunner=none`
`generate @nx/js:lib ${pkg} --bundler=none --unitTestRunner=none --directory=libs/${pkg}`
);
runCLI(
`generate @nx/js:lib ${pkg2} --bundler=none --unitTestRunner=none --directory=libs/${pkg2}`
);
updateJson<PackageJson>('package.json', (v) => {

View File

@ -31,9 +31,9 @@ describe('Nx Watch', () => {
let proj3 = uniq('proj3');
beforeAll(() => {
newProject({ packages: ['@nx/js'] });
runCLI(`generate @nx/js:lib ${proj1}`);
runCLI(`generate @nx/js:lib ${proj2}`);
runCLI(`generate @nx/js:lib ${proj3}`);
runCLI(`generate @nx/js:lib ${proj1} --directory=libs/${proj1}`);
runCLI(`generate @nx/js:lib ${proj2} --directory=libs/${proj2}`);
runCLI(`generate @nx/js:lib ${proj3} --directory=libs/${proj3}`);
runCLI('daemon --start', {
env: {
NX_DAEMON: 'true',

View File

@ -32,7 +32,7 @@ describe('@nx/workspace:infer-targets', () => {
// default case, everything is generated with crystal, everything should be skipped
const remixApp = uniq('remix');
runCLI(
`generate @nx/remix:app ${remixApp} --dir apps --unitTestRunner jest --e2eTestRunner=playwright --projectNameAndDirectoryFormat=as-provided --no-interactive`
`generate @nx/remix:app ${remixApp} --dir apps/${remixApp} --unitTestRunner jest --e2eTestRunner=playwright --projectNameAndDirectoryFormat=as-provided --no-interactive`
);
const output = runCLI(`generate infer-targets --no-interactive`);
@ -70,7 +70,7 @@ describe('@nx/workspace:infer-targets', () => {
// default case, everything is generated with crystal, relevant plugins should be skipped
const remixApp = uniq('remix');
runCLI(
`generate @nx/remix:app ${remixApp} --dir apps --unitTestRunner jest --e2eTestRunner=playwright --projectNameAndDirectoryFormat=as-provided --no-interactive`
`generate @nx/remix:app ${remixApp} --dir apps/${remixApp} --unitTestRunner jest --e2eTestRunner=playwright --projectNameAndDirectoryFormat=as-provided --no-interactive`
);
const output = runCLI(
@ -116,7 +116,7 @@ describe('@nx/workspace:infer-targets', () => {
// even if we make sure there are executors for remix & remix-e2e, only remix conversions will run with --project option
const remixApp = uniq('remix');
runCLI(
`generate @nx/remix:app ${remixApp} --dir apps --unitTestRunner jest --e2eTestRunner=playwright --projectNameAndDirectoryFormat=as-provided --no-interactive`
`generate @nx/remix:app ${remixApp} --dir apps/${remixApp} --unitTestRunner jest --e2eTestRunner=playwright --projectNameAndDirectoryFormat=as-provided --no-interactive`
);
updateJson('nx.json', (json) => {
@ -490,143 +490,6 @@ describe('Workspace Tests', () => {
);
});
it('should work for custom workspace layouts with --project-name-and-root-format=derived', async () => {
const lib1 = uniq('mylib');
const lib2 = uniq('mylib');
const lib3 = uniq('mylib');
let nxJson = readJson('nx.json');
nxJson.workspaceLayout = { libsDir: 'packages' };
updateFile('nx.json', JSON.stringify(nxJson));
runCLI(
`generate @nx/js:lib ${lib1}/data-access --unitTestRunner=jest --project-name-and-root-format=derived`
);
updateFile(
`packages/${lib1}/data-access/src/lib/${lib1}-data-access.ts`,
`export function fromLibOne() { console.log('This is completely pointless'); }`
);
updateFile(
`packages/${lib1}/data-access/src/index.ts`,
`export * from './lib/${lib1}-data-access.ts'`
);
/**
* Create a library which imports a class from lib1
*/
runCLI(
`generate @nx/js:lib ${lib2}/ui --unitTestRunner=jest --project-name-and-root-format=derived`
);
updateFile(
`packages/${lib2}/ui/src/lib/${lib2}-ui.ts`,
`import { fromLibOne } from '@${proj}/${lib1}/data-access';
export const fromLibTwo = () => fromLibOne();`
);
/**
* Create a library which has an implicit dependency on lib1
*/
runCLI(
`generate @nx/js:lib ${lib3} --unitTestRunner=jest --project-name-and-root-format=derived`
);
updateFile(join('packages', lib3, 'project.json'), (content) => {
const data = JSON.parse(content);
data.implicitDependencies = [`${lib1}-data-access`];
return JSON.stringify(data, null, 2);
});
/**
* Now try to move lib1
*/
const moveOutput = runCLI(
`generate @nx/workspace:move --project ${lib1}-data-access shared/${lib1}/data-access --project-name-and-root-format=derived`
);
expect(moveOutput).toContain(`DELETE packages/${lib1}/data-access`);
expect(exists(`packages/${lib1}/data-access`)).toBeFalsy();
const newPath = `packages/shared/${lib1}/data-access`;
const newName = `shared-${lib1}-data-access`;
const readmePath = `${newPath}/README.md`;
expect(moveOutput).toContain(`CREATE ${readmePath}`);
checkFilesExist(readmePath);
const jestConfigPath = `${newPath}/jest.config.ts`;
expect(moveOutput).toContain(`CREATE ${jestConfigPath}`);
checkFilesExist(jestConfigPath);
const jestConfig = readFile(jestConfigPath);
expect(jestConfig).toContain(`displayName: 'shared-${lib1}-data-access'`);
expect(jestConfig).toContain(`preset: '../../../../jest.preset.js'`);
expect(jestConfig).toContain(`'../../../../coverage/${newPath}'`);
const tsConfigPath = `${newPath}/tsconfig.json`;
expect(moveOutput).toContain(`CREATE ${tsConfigPath}`);
checkFilesExist(tsConfigPath);
const tsConfigLibPath = `${newPath}/tsconfig.lib.json`;
expect(moveOutput).toContain(`CREATE ${tsConfigLibPath}`);
checkFilesExist(tsConfigLibPath);
const tsConfigLib = readJson(tsConfigLibPath);
expect(tsConfigLib.compilerOptions.outDir).toEqual(
'../../../../dist/out-tsc'
);
const tsConfigSpecPath = `${newPath}/tsconfig.spec.json`;
expect(moveOutput).toContain(`CREATE ${tsConfigSpecPath}`);
checkFilesExist(tsConfigSpecPath);
const tsConfigSpec = readJson(tsConfigSpecPath);
expect(tsConfigSpec.compilerOptions.outDir).toEqual(
'../../../../dist/out-tsc'
);
const indexPath = `${newPath}/src/index.ts`;
expect(moveOutput).toContain(`CREATE ${indexPath}`);
checkFilesExist(indexPath);
const rootClassPath = `${newPath}/src/lib/${lib1}-data-access.ts`;
expect(moveOutput).toContain(`CREATE ${rootClassPath}`);
checkFilesExist(rootClassPath);
expect(moveOutput).toContain('UPDATE tsconfig.base.json');
const rootTsConfig = readJson('tsconfig.base.json');
expect(
rootTsConfig.compilerOptions.paths[`@${proj}/${lib1}/data-access`]
).toBeUndefined();
expect(
rootTsConfig.compilerOptions.paths[
`@${proj}/shared/${lib1}/data-access`
]
).toEqual([`packages/shared/${lib1}/data-access/src/index.ts`]);
const projects = runCLI('show projects').split('\n');
expect(projects).not.toContain(`${lib1}-data-access`);
const project = readJson(join(newPath, 'project.json'));
expect(project).toBeTruthy();
expect(project.sourceRoot).toBe(`${newPath}/src`);
expect(project.tags).toEqual([]);
/**
* Check that the import in lib2 has been updated
*/
const lib2FilePath = `packages/${lib2}/ui/src/lib/${lib2}-ui.ts`;
const lib2File = readFile(lib2FilePath);
expect(lib2File).toContain(
`import { fromLibOne } from '@${proj}/shared/${lib1}/data-access';`
);
nxJson = readJson('nx.json');
delete nxJson.workspaceLayout;
updateFile('nx.json', JSON.stringify(nxJson));
});
it('should work when moving a lib to a subfolder', async () => {
const lib1 = uniq('lib1');
const lib2 = uniq('lib2');
@ -880,14 +743,18 @@ describe('Workspace Tests', () => {
const lib1 = uniq('myliba');
const lib2 = uniq('mylibb');
runCLI(`generate @nx/js:lib ${lib1} --unitTestRunner=jest`);
runCLI(
`generate @nx/js:lib ${lib1} --unitTestRunner=jest --directory=libs/${lib1}`
);
expect(exists(tmpProjPath(`libs/${lib1}`))).toBeTruthy();
/**
* Create a library which has an implicit dependency on lib1
*/
runCLI(`generate @nx/js:lib ${lib2} --unitTestRunner=jest`);
runCLI(
`generate @nx/js:lib ${lib2} --directory=libs/${lib2} --unitTestRunner=jest`
);
updateFile(join('libs', lib2, 'project.json'), (content) => {
const data = JSON.parse(content);
data.implicitDependencies = [lib1];

View File

@ -43,10 +43,10 @@ describe('Nx Plugin', () => {
const buildResults = runCLI(`build ${plugin}`);
expect(buildResults).toContain('Done compiling TypeScript files');
checkFilesExist(
`dist/libs/${plugin}/package.json`,
`dist/libs/${plugin}/src/index.js`
`dist/${plugin}/package.json`,
`dist/${plugin}/src/index.js`
);
const project = readJson(`libs/${plugin}/project.json`);
const project = readJson(`${plugin}/project.json`);
expect(project).toMatchObject({
tags: [],
});
@ -60,7 +60,7 @@ describe('Nx Plugin', () => {
runCLI(`generate @nx/plugin:plugin ${plugin} --linter=eslint`);
runCLI(
`generate @nx/plugin:migration --project=${plugin} --packageVersion=${version} --packageJsonUpdates=false`
`generate @nx/plugin:migration --directory=${plugin}/src/migrations/update-${version} --packageVersion=${version} --packageJsonUpdates=false`
);
const lintResults = runCLI(`lint ${plugin}`);
@ -71,10 +71,10 @@ describe('Nx Plugin', () => {
const buildResults = runCLI(`build ${plugin}`);
expect(buildResults).toContain('Done compiling TypeScript files');
checkFilesExist(
`dist/libs/${plugin}/src/migrations/update-${version}/update-${version}.js`,
`libs/${plugin}/src/migrations/update-${version}/update-${version}.ts`
`dist/${plugin}/src/migrations/update-${version}/update-${version}.js`,
`${plugin}/src/migrations/update-${version}/update-${version}.ts`
);
const migrationsJson = readJson(`libs/${plugin}/migrations.json`);
const migrationsJson = readJson(`${plugin}/migrations.json`);
expect(migrationsJson).toMatchObject({
generators: expect.objectContaining({
[`update-${version}`]: {
@ -91,7 +91,9 @@ describe('Nx Plugin', () => {
const generator = uniq('generator');
runCLI(`generate @nx/plugin:plugin ${plugin} --linter=eslint`);
runCLI(`generate @nx/plugin:generator ${generator} --project=${plugin}`);
runCLI(
`generate @nx/plugin:generator ${generator} --directory=${plugin}/src/generators/${generator}`
);
const lintResults = runCLI(`lint ${plugin}`);
expect(lintResults).toContain('All files pass linting');
@ -101,15 +103,15 @@ describe('Nx Plugin', () => {
const buildResults = runCLI(`build ${plugin}`);
expect(buildResults).toContain('Done compiling TypeScript files');
checkFilesExist(
`libs/${plugin}/src/generators/${generator}/schema.d.ts`,
`libs/${plugin}/src/generators/${generator}/schema.json`,
`libs/${plugin}/src/generators/${generator}/generator.ts`,
`libs/${plugin}/src/generators/${generator}/generator.spec.ts`,
`dist/libs/${plugin}/src/generators/${generator}/schema.d.ts`,
`dist/libs/${plugin}/src/generators/${generator}/schema.json`,
`dist/libs/${plugin}/src/generators/${generator}/generator.js`
`${plugin}/src/generators/${generator}/schema.d.ts`,
`${plugin}/src/generators/${generator}/schema.json`,
`${plugin}/src/generators/${generator}/generator.ts`,
`${plugin}/src/generators/${generator}/generator.spec.ts`,
`dist/${plugin}/src/generators/${generator}/schema.d.ts`,
`dist/${plugin}/src/generators/${generator}/schema.json`,
`dist/${plugin}/src/generators/${generator}/generator.js`
);
const generatorJson = readJson(`libs/${plugin}/generators.json`);
const generatorJson = readJson(`${plugin}/generators.json`);
expect(generatorJson).toMatchObject({
generators: expect.objectContaining({
[generator]: {
@ -127,7 +129,7 @@ describe('Nx Plugin', () => {
runCLI(`generate @nx/plugin:plugin ${plugin} --linter=eslint`);
runCLI(
`generate @nx/plugin:executor ${executor} --project=${plugin} --includeHasher`
`generate @nx/plugin:executor ${executor} --directory=${plugin}/src/executors/${executor} --includeHasher`
);
const lintResults = runCLI(`lint ${plugin}`);
@ -138,17 +140,17 @@ describe('Nx Plugin', () => {
const buildResults = runCLI(`build ${plugin}`);
expect(buildResults).toContain('Done compiling TypeScript files');
checkFilesExist(
`libs/${plugin}/src/executors/${executor}/schema.d.ts`,
`libs/${plugin}/src/executors/${executor}/schema.json`,
`libs/${plugin}/src/executors/${executor}/executor.ts`,
`libs/${plugin}/src/executors/${executor}/hasher.ts`,
`libs/${plugin}/src/executors/${executor}/executor.spec.ts`,
`dist/libs/${plugin}/src/executors/${executor}/schema.d.ts`,
`dist/libs/${plugin}/src/executors/${executor}/schema.json`,
`dist/libs/${plugin}/src/executors/${executor}/executor.js`,
`dist/libs/${plugin}/src/executors/${executor}/hasher.js`
`${plugin}/src/executors/${executor}/schema.d.ts`,
`${plugin}/src/executors/${executor}/schema.json`,
`${plugin}/src/executors/${executor}/executor.ts`,
`${plugin}/src/executors/${executor}/hasher.ts`,
`${plugin}/src/executors/${executor}/executor.spec.ts`,
`dist/${plugin}/src/executors/${executor}/schema.d.ts`,
`dist/${plugin}/src/executors/${executor}/schema.json`,
`dist/${plugin}/src/executors/${executor}/executor.js`,
`dist/${plugin}/src/executors/${executor}/hasher.js`
);
const executorsJson = readJson(`libs/${plugin}/executors.json`);
const executorsJson = readJson(`${plugin}/executors.json`);
expect(executorsJson).toMatchObject({
executors: expect.objectContaining({
[executor]: {
@ -176,32 +178,34 @@ describe('Nx Plugin', () => {
runCLI(`generate @nx/plugin:plugin ${plugin} --linter=eslint`);
runCLI(
`generate @nx/plugin:generator ${goodGenerator} --project=${plugin}`
`generate @nx/plugin:generator ${goodGenerator} --directory=${plugin}/src/generators/${goodGenerator}`
);
runCLI(
`generate @nx/plugin:generator ${badFactoryPath} --project=${plugin}`
);
runCLI(`generate @nx/plugin:executor ${goodExecutor} --project=${plugin}`);
runCLI(
`generate @nx/plugin:executor ${badExecutorBadImplPath} --project=${plugin}`
`generate @nx/plugin:generator ${badFactoryPath} --directory=${plugin}/src/generators/${badFactoryPath}`
);
runCLI(
`generate @nx/plugin:migration ${badMigrationVersion} --project=${plugin} --packageVersion="invalid"`
`generate @nx/plugin:executor ${goodExecutor} --directory=${plugin}/src/executors/${goodExecutor}`
);
runCLI(
`generate @nx/plugin:migration ${missingMigrationVersion} --project=${plugin} --packageVersion="0.1.0"`
`generate @nx/plugin:executor ${badExecutorBadImplPath} --directory=${plugin}/src/executors/${badExecutorBadImplPath}`
);
runCLI(
`generate @nx/plugin:migration ${goodMigration} --project=${plugin} --packageVersion="0.1.0"`
`generate @nx/plugin:migration ${badMigrationVersion} --directory=${plugin} --packageVersion="invalid"`
);
updateFile(`libs/${plugin}/generators.json`, (f) => {
runCLI(
`generate @nx/plugin:migration ${missingMigrationVersion} --directory=${plugin}/migrations/0.1.0 --packageVersion="0.1.0"`
);
runCLI(
`generate @nx/plugin:migration ${goodMigration} --directory=${plugin}/migrations/0.1.0 --packageVersion="0.1.0"`
);
updateFile(`${plugin}/generators.json`, (f) => {
const json = JSON.parse(f);
// @proj/plugin:plugin has an invalid implementation path
json.generators[
@ -212,7 +216,7 @@ describe('Nx Plugin', () => {
return JSON.stringify(json);
});
updateFile(`libs/${plugin}/executors.json`, (f) => {
updateFile(`${plugin}/executors.json`, (f) => {
const json = JSON.parse(f);
// @proj/plugin:badExecutorBadImplPath has an invalid implementation path
json.executors[badExecutorBadImplPath].implementation =
@ -222,7 +226,7 @@ describe('Nx Plugin', () => {
return JSON.stringify(json);
});
updateFile(`libs/${plugin}/migrations.json`, (f) => {
updateFile(`${plugin}/migrations.json`, (f) => {
const json = JSON.parse(f);
delete json.generators[missingMigrationVersion].version;
return JSON.stringify(json);
@ -270,7 +274,7 @@ describe('Nx Plugin', () => {
it('should be able to infer projects and targets (v1)', async () => {
// Setup project inference + target inference
updateFile(
`libs/${plugin}/src/index.ts`,
`${plugin}/src/index.ts`,
`import {basename} from 'path'
export function registerProjectTargets(f) {
@ -299,7 +303,7 @@ describe('Nx Plugin', () => {
// Create project that should be inferred by Nx
const inferredProject = uniq('inferred');
createFile(`libs/${inferredProject}/my-project-file`);
createFile(`${inferredProject}/my-project-file`);
// Attempt to use inferred project w/ Nx
expect(runCLI(`build ${inferredProject}`)).toContain(
@ -309,7 +313,7 @@ describe('Nx Plugin', () => {
it('should be able to infer projects and targets (v2)', async () => {
// Setup project inference + target inference
updateFile(`libs/${plugin}/src/index.ts`, NX_PLUGIN_V2_CONTENTS);
updateFile(`${plugin}/src/index.ts`, NX_PLUGIN_V2_CONTENTS);
// Register plugin in nx.json (required for inference)
updateFile(`nx.json`, (nxJson) => {
@ -325,7 +329,7 @@ describe('Nx Plugin', () => {
// Create project that should be inferred by Nx
const inferredProject = uniq('inferred');
createFile(`libs/${inferredProject}/my-project-file`);
createFile(`${inferredProject}/my-project-file`);
// Attempt to use inferred project w/ Nx
expect(runCLI(`build ${inferredProject}`)).toContain(
@ -343,12 +347,16 @@ describe('Nx Plugin', () => {
const executor = uniq('executor');
const generatedProject = uniq('project');
runCLI(`generate @nx/plugin:generator ${generator} --project=${plugin}`);
runCLI(
`generate @nx/plugin:generator ${generator} --directory=${plugin}/src/generators/${generator}`
);
runCLI(`generate @nx/plugin:executor ${executor} --project=${plugin}`);
runCLI(
`generate @nx/plugin:executor ${executor} --directory=${plugin}/src/executors/${executor}`
);
updateFile(
`libs/${plugin}/src/executors/${executor}/executor.ts`,
`${plugin}/src/executors/${executor}/executor.ts`,
ASYNC_GENERATOR_EXECUTOR_CONTENTS
);
@ -381,7 +389,7 @@ describe('Nx Plugin', () => {
expect(() => {
runCLI(
`generate @nx/plugin:generator ${generator} --project=${plugin}`
`generate @nx/plugin:generator ${generator} --directory=${plugin}/src/generators/${generator}`
);
runCLI(
@ -399,14 +407,14 @@ describe('Nx Plugin', () => {
it('should create a plugin in the specified directory', async () => {
const plugin = uniq('plugin');
runCLI(
`generate @nx/plugin:plugin ${plugin} --linter=eslint --directory subdir --e2eTestRunner=jest`
`generate @nx/plugin:plugin ${plugin} --linter=eslint --directory libs/subdir/${plugin} --e2eTestRunner=jest`
);
checkFilesExist(`libs/subdir/${plugin}/package.json`);
const pluginProject = readJson(
join('libs', 'subdir', plugin, 'project.json')
);
const pluginE2EProject = readJson(
join('apps', 'subdir', `${plugin}-e2e`, 'project.json')
join('libs', 'subdir', `${plugin}-e2e`, 'project.json')
);
expect(pluginProject.targets).toBeDefined();
expect(pluginE2EProject).toBeTruthy();
@ -418,7 +426,7 @@ describe('Nx Plugin', () => {
runCLI(
`generate @nx/plugin:plugin ${plugin} --linter=eslint --tags=e2etag,e2ePackage `
);
const pluginProject = readJson(join('libs', plugin, 'project.json'));
const pluginProject = readJson(join(plugin, 'project.json'));
expect(pluginProject.tags).toEqual(['e2etag', 'e2ePackage']);
}, 90000);
});
@ -437,9 +445,9 @@ describe('Nx Plugin', () => {
expect(buildResults).toContain('Done compiling TypeScript files');
checkFilesExist(
`libs/${plugin}/src/generators/preset`,
`libs/${createAppName}`,
`dist/libs/${createAppName}/bin/index.js`
`${plugin}/src/generators/preset`,
`${createAppName}`,
`dist/${createAppName}/bin/index.js`
);
});
@ -457,9 +465,9 @@ describe('Nx Plugin', () => {
expect(buildResults).toContain('Done compiling TypeScript files');
checkFilesExist(
`libs/${plugin}/src/generators/preset`,
`libs/${createAppName}`,
`dist/libs/${createAppName}/bin/index.js`
`${plugin}/src/generators/preset`,
`${createAppName}`,
`dist/${createAppName}/bin/index.js`
);
runCLI(`e2e ${plugin}-e2e`);

Some files were not shown because too many files have changed in this diff Show More