docs(nxdev): generate menu api (#10272)

This commit is contained in:
Benjamin Cabanes 2022-05-12 14:12:04 -04:00 committed by GitHub
parent a2d9d5664e
commit d46e49cd61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 574 additions and 988 deletions

View File

@ -8,6 +8,7 @@
{
"name": "Overview",
"id": "overview",
"path": "/packages/angular",
"file": "shared/angular-plugin",
"content": "![Angular logo](/shared/angular-logo.png)\n\nThe Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides:\n\n- Integration with libraries such as Storybook, Jest, Cypress, Karma, and Protractor.\n- Generators to help scaffold code quickly, including:\n - Micro Frontends\n - Libraries, both internal to your codebase and publishable to npm\n - Upgrading AngularJS applications\n - Single Component Application Modules (SCAMs)\n- NgRx helpers.\n- Utilities for automatic workspace refactoring.\n\n## Setting up the Angular plugin\n\nAdding the Angular plugin to an existing Nx workspace can be done with the following:\n\n```bash\nyarn add -D @nrwl/angular\n```\n\n```bash\nnpm install -D @nrwl/angular\n```\n\n## Using the Angular Plugin\n\n### Generating an application\n\nIt's straightforward to generate an Angular application:\n\n```bash\nnx g @nrwl/angular:app appName\n```\n\nBy default, the application will be generated with:\n\n- ESLint as the linter.\n- Jest as the unit test runner.\n- Cypress as the E2E test runner.\n\nWe can then serve, build, test, lint, and run e2e tests on the application with the following commands:\n\n```bash\nnx serve appName\nnx build appName\nnx test appName\nnx lint appName\nnx e2e appName\n```\n\n### Generating a library\n\nGenerating an Angular library is very similar to generating an application:\n\n```bash\nnx g @nrwl/angular:lib libName\n```\n\nBy default, the library will be generated with:\n\n- ESLint as the linter.\n- Jest as the unit test runner.\n\nWe can then test and lint the library with the following commands:\n\n```bash\nnx test libName\nnx lint libName\n```\n\nRead more about:\n\n- [Creating Libraries](/structure/creating-libraries)\n- [Library Types](/structure/library-types)\n- [Buildable and Publishable Libraries](/structure/buildable-and-publishable-libraries)\n\n## More Documentation\n\n- [Angular Nx Tutorial](/angular-tutorial/01-create-application)\n- [Setup Module Federation with Angular and Nx](/module-federation/faster-builds)\n- [Using NgRx](/guides/misc-ngrx)\n- [Using DataPersistence](/guides/misc-data-persistence)\n- [Upgrading an AngularJS application to Angular](/guides/misc-upgrade)\n- [Using Tailwind CSS with Angular projects](/guides/using-tailwind-css-with-angular-projects)\n"
}

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,7 @@
{
"name": "Overview",
"id": "overview",
"path": "/packages/cypress",
"file": "shared/cypress-plugin",
"content": "![Cypress logo](/shared/cypress-logo.png)\n\nCypress is an e2e test runner built for modern web. It has a lot of great features:\n\n- Time travel\n- Real-time reloads\n- Automatic waiting\n- Spies, stubs, and clocks\n- Network traffic control\n- Screenshots and videos\n\n## Setting Up Cypress\n\n### Generating Applications\n\nBy default, when creating a new frontend application, Nx will use Cypress to create the e2e tests project.\n\n```bash\nnx g @nrwl/web:app frontend\n```\n\n### Creating a Cypress E2E project for an existing project\n\nYou can create a new Cypress E2E project for an existing project.\n\nIf the `@nrwl/cypress` package is not installed, install the version that matches your `@nrwl/workspace` version.\n\n```bash\nyarn add --dev @nrwl/cypress\n```\n\n```bash\nnpm install --save-dev @nrwl/cypress\n```\n\nNext, generate an E2E project based on an existing project.\n\n```bash\nnx g @nrwl/cypress:cypress-project your-app-name-e2e --project=your-app-name\n```\n\nReplace `your-app-name` with the app's name as defined in your `workspace.json` file.\n\n## Using Cypress\n\n### Testing Applications\n\nSimply run `nx e2e frontend-e2e` to execute e2e tests with Cypress.\n\nBy default, Cypress will run in headless mode. You will have the result of all the tests and errors (if any) in your terminal. Screenshots and videos will be accessible in `dist/apps/frontend/screenshots` and `dist/apps/frontend/videos`.\n\n### Watching for Changes\n\nWith, `nx e2e frontend-e2e --watch` Cypress will start in the application mode.\n\nRunning Cypress with `--watch` is a great way to enhance dev workflow - you can build up test files with the application running and Cypress will re-run those tests as you enhance and add to the suite.\n\nCypress doesn't currently re-run your tests after changes are made to application code when it runs in “headed” mode.\n\n### Using Cypress in the Headed Mode\n\nYou can run Cypress in headed mode to see your app being tested. To do this, pass in the `--watch` option. E.g: `nx frontend-e2e --watch`\n\n### Testing Against Prod Build\n\nYou can run your e2e test against a production build like this: `nx e2e frontend-e2e --prod`.\n\n## Configuration\n\n### Specifying a Custom Url to Test\n\nThe `baseUrl` property provides you the ability to test an application hosted on a specific domain.\n\n```bash\nnx e2e frontend-e2e --baseUrl=https://frontend.com\n```\n\n> If no `baseUrl` and no `devServerTarget` are provided, Cypress will expect to have the `baseUrl` property in the `cypress.json` file, or will error.\n\n### Using cypress.json\n\nIf you need to fine tune your Cypress setup, you can do so by modifying `cypress.json` in the e2e project. For instance, you can easily add your `projectId` to save all the screenshots and videos into your Cypress dashboard. The complete configuration is documented on [the official website](https://docs.cypress.io/guides/references/configuration.html#Options).\n\n## More Documentation\n\nReact Nx Tutorial\n\n- [Step 2: Add E2E Tests](/react-tutorial/02-add-e2e-test)\n- [Step 3: Display Todos](/react-tutorial/03-display-todos)\n\nAngular Nx Tutorial\n\n- [Step 2: Add E2E Tests](/angular-tutorial/02-add-e2e-test)\n- [Step 3: Display Todos](/angular-tutorial/03-display-todos)\n"
}

View File

@ -8,6 +8,7 @@
{
"id": "overview",
"name": "Overview",
"path": "/packages/detox",
"file": "shared/detox-plugin",
"content": "![Detox logo](/shared/detox-logo.png)\n\nDetox is gray box end-to-end testing and automation library for mobile apps. It has a lot of great features:\n\n- Cross Platform\n- Runs on Devices\n- Automatically Synchronized\n- Test Runner Independent\n- Debuggable\n\n## Setting Up Detox\n\n### Install applesimutils (Mac only)\n\n[applesimutils](https://github.com/wix/AppleSimulatorUtils) is a collection of utils for Apple simulators.\n\n```sh\nbrew tap wix/brew\nbrew install applesimutils\n```\n\n### Install Jest Globally\n\n```sh\nnpm install -g jest\n```\n\n### Generating Applications\n\nBy default, when creating a mobile application, Nx will use Detox to create the e2e tests project.\n\n```bash\nnx g @nrwl/react-native:app frontend\n```\n\n### Creating a Detox E2E project for an existing project\n\nYou can create a new Detox E2E project for an existing mobile project.\n\nIf the `@nrwl/detox` package is not installed, install the version that matches your `@nrwl/workspace` version.\n\n```sh\n# yarn\nyarn add --dev @nrwl/detox\n```\n\n```sh\n# npm\nnpm install --save-dev @nrwl/detox\n```\n\nNext, generate an E2E project based on an existing project.\n\n```sh\nnx g @nrwl/detox:app your-app-name-e2e --project=your-app-name\n```\n\nReplace `your-app-name` with the app's name as defined in your `workspace.json` file.\n\nIn addition, you need to follow [instructions at Detox](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md) to do manual setup for Android files.\n\n## Using Detox\n\n### Testing Applications\n\n- Run `nx test-ios frontend-e2e` to build the iOS app and execute e2e tests with Detox for iOS (Mac only)\n- Run `nx test-android frontend-e2e` to build the Android app and execute e2e tests with Detox for Android\n\nYou can run below commands:\n\n- `nx build-ios frontend-e2e`: build the iOS app (Mac only)\n- `nx build-android frontend-e2e`: build the Android app\n\n### Testing against Prod Build\n\nYou can run your e2e test against a production build:\n\n- `nx test-ios frontend-e2e --prod`: to build the iOS app and execute e2e tests with Detox for iOS with Release configuration (Mac only)\n- `nx test-android frontend-e2e`: rto build the Android app and execute e2e tests with Detox for Android with release build type\n- `nx build-ios frontend-e2e --prod`: build the iOS app using Release configuration (Mac only)\n- `nx build-android frontend-e2e --prod`: build the Android app using release build type\n\n## Configuration\n\n### Using .detoxrc.json\n\nIf you need to fine tune your Detox setup, you can do so by modifying `.detoxrc.json` in the e2e project.\n\n#### Change Testing Simulator/Emulator\n\nFor iOS, in terminal, run `xcrun simctl list` to view a list of simulators on your Mac. To open your active simulator, `run open -a simulator`. In `frontend-e2e/.detoxrc.json`, you could change the simulator under `devices.simulator.device`.\n\nFor Android, in terminal, run `emulator -list-avds` to view a list of emulators installed. To open your emulator, run `emulator -avd <your emulator name>`. In `frontend-e2e/.detoxrc.json`, you could change the simulator under `devices.emulator.device`.\n\nIn additon, to override the device name specified in a configuration, you could use `--device-name` option: `nx test-ios <app-name-e2e> --device-name \"iPhone 11\"`. The `device-name` property provides you the ability to test an application run on specific device.\n\n```bash\nnx test-ios frontend-e2e --device-name \"iPhone 11\"\nnx test-android frontend-e2e --device-name \"Pixel_4a_API_30\"\n```\n"
}

View File

@ -4,7 +4,15 @@
"description": "ESLint Plugin for Nx",
"root": "/packages/eslint-plugin-nx",
"source": "/packages/eslint-plugin-nx/src",
"documentation": [],
"documentation": [
{
"id": "overview",
"name": "Overview",
"path": "/packages/eslint-plugin-nx",
"file": "shared/eslint-plugin-nx",
"content": "![ESLint logo](/shared/eslint-logo.png)\n\nA plugin containing a collection of recommended ESLint rule configurations wrapped as ESLint plugins and an Nx specific [enforce-module-boundaries](#enforce-module-boundaries) rule.\n\n## Setting Up ESLint Plugin\n\n### Installation\n\nIn any Nx workspace, you can install `@nrwl/eslint-plugin-nx` by running the following commands if the package is not already installed:\n\n```bash\nnpm i --save-dev @nrwl/eslint-plugin-nx\n```\n\n```bash\nyarn add --dev @nrwl/eslint-plugin-nx\n```\n\n## ESLint plugins\n\nThe plugin contains the following rule configurations divided into sub-plugins.\n\n### JavaScript\n\nThe `@nrwl/nx/javascript` ESLint plugin contains best practices when using JavaScript.\n\n### TypeScript\n\nThe `@nrwl/nx/typescript` ESLint plugin contains best practices when using TypeSript.\n\n### Angular\n\nContains configurations matching best practices when using Angular framework:\n\n- @nrwl/nx/angular\n- @nrwl/nx/angular-template\n\n### React\n\nContains configurations matching best practices when using React framework:\n\n- @nrwl/nx/react-base\n- @nrwl/nx/react-jsx\n- @nrwl/nx/react-typescript\n\nYou can also use `@nrwl/nx/react` which includes all three `@nrwl/nx/react-*` plugins\n\n## enforce-module-boundaries\n\nThe `@nrwl/nx/enforce-module-boundaries` ESLint rule enables you to define strict rules for accessing resources between different projects in the repository. By enforcing strict boundaries it helps keep prevent unplanned cross-dependencies.\n\n### Usage\n\nYou can use `enforce-module-boundaries` rule by adding it to your ESLint rules configuration:\n\n```json\n{\n // ... more ESLint config here\n \"overrides\": [\n {\n \"files\": [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"],\n \"rules\": {\n \"@nrwl/nx/enforce-module-boundaries\": [\n \"error\",\n {\n // ...rule specific configuration\n }\n ]\n }\n }\n // ... more ESLint overrides here\n ]\n}\n```\n\nRead more about proper usage of this rule:\n\n- [Imposing Constraints on the Project Graph](/structure/monorepo-tags)\n- [Taming Code Organization with Module Boundaries in Nx](https://blog.nrwl.io/mastering-the-project-boundaries-in-nx-f095852f5bf4)\n"
}
],
"generators": [],
"executors": []
}

View File

@ -8,6 +8,7 @@
{
"id": "overview",
"name": "Overview",
"path": "/packages/express",
"file": "shared/express-plugin",
"content": "![Express Logo](/shared/express-logo.png)\n\n[Express](https://expressjs.com/) is mature, minimal, and an open source web framework for making web applications and\napis.\n\n## Setting Up Express\n\nTo create a new workspace with Express, run the following command:\n\n```shell\n npx create-nx-workspace --preset=express\n```\n\n### Adding Express to an Existing Project\n\nInstall the express plugin\n\n```shell\nnpm install --save-dev @nrwl/express\n```\n\n```shell\nyarn add --dev @nrwl/express\n```\n\n## Creating Applications\n\nAdd a new application to your workspace with the following command:\n\n```shell\nnx g @nrwl/express:app my-app\n```\n\nServe the application by running\n\n```shell\nnx serve my-app\n```\n\nThis starts the application on localhost:3333/api by default.\n\n> Express does not come with any library generators, but you can leverage the[`@nrwl/js`](/js/overview#create-libraries) plugin to generate a Node.js library for your express application.\n\n### Application Proxies\n\nThe Express application generator has an option to configure other projects in the workspace to proxy API requests. This\ncan be done by passing the `--frontendProject` with the project name you wish to enable proxy support for.\n\n```shell\nnx g @nrwl/express:app <express-app> --frontendProject my-react-app\n```\n\n## Using Express\n\n### Testing Projects\n\nYou can run unit tests with:\n\n```shell\nnx test <project-name>\n```\n\n### Building Projects\n\nExpress projects can be built with:\n\n```shell\nnx build <project-name>\n```\n\nBuild artifacts will be found in the `dist` directory under `apps/<project-name>` by default. Customize the build\nconfiguration by editing `outputPath` in the [project configuration](/configuration/projectjson).\n\n### Waiting for Other Tasks\n\nYou can wait for other tasks to run before serving the express app which can be handy for spinning up various services\nthe application depends on— for example, other apis in a microservice.\n\nSetting the `waitUntilTargets` option with an array of targets (format: `\"project:target\"`) executes those tasks\nbefore serving the Express application.\n\n## More Documentation\n\n- [Using Jest](/jest/overview)\n- [@nrwl/js](/js/overview)\n- [Express](https://expressjs.com/)\n"
}

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,7 @@
{
"name": "Overview",
"id": "overview",
"path": "/packages/js",
"file": "shared/js-plugin",
"content": "The JS plugin contains executors and generators that are useful for JavaScript/TypeScript projects in an Nx workspace.\n\n## Setting Up JS\n\n### Installation\n\nIn any Nx workspace, you can install `@nrwl/js` by running the following commands if `@nrwl/js` package is not installed:\n\n```shell\nnpm i --save-dev @nrwl/js\n```\n\n```shell\nyarn add --dev @nrwl/js\n```\n\n### `ts` Preset\n\nWhen initializing a new Nx workspace, specifying `--preset=ts` will generate a workspace with `@nrwl/js` pre-installed.\n\n```shell\nnpx create-nx-workspace my-org --preset=ts\n```\n\n```shell\nyarn create nx-workspace my-org --preset=ts\n```\n\n## Create Libraries\n\nYou can add a new JS/TS library with the following command:\n\n```shell\nnx g @nrwl/js:lib my-lib\n```\n\n## Build\n\nYou can `build` libraries that are generated with `--buildable` flag.\n\n```shell\nnx g @nrwl/js:lib my-buildable-lib --buildable\n```\n\nGenerating a library with `--buildable` will add a `build` target to the library's `project.json` file allows the library to be built.\n\n```shell\nnx build my-buildable-lib\n```\n\n## Test\n\nYou can test a library with the following command:\n\n```shell\nnx test my-lib\n```\n\n## Lint\n\nYou can lint a library with the following command:\n\n```shell\nnx lint my-lib\n```\n\n## Compiler\n\nBy default, `@nrwl/js` uses [TypeScript Compiler (TSC)](https://www.typescriptlang.org/docs/handbook/2/basic-types.html#tsc-the-typescript-compiler), via `@nrwl/js:tsc` executor, to compile your libraries. Optionally, you can switch `tsc` out for a different compiler with `--compiler` flag when executing the generators.\n\nCurrently, `@nrwl/js` supports the following compilers:\n\n- [Speedy Web Compiler (SWC)](https://swc.rs)\n\n### SWC\n\n- Create a buildable library with `swc`\n\n```shell\nnx g @nrwl/js:lib my-swc-lib --compiler=swc --buildable\n```\n\n- Convert a `tsc` library to use `swc`\n\n```shell\nnx g @nrwl/js:convert-to-swc my-buildable-lib\n```\n\nNow the `build` command will use `@nrwl/js:swc` executor to compile your libraries.\n\n> The first time you generate a `swc` library or convert a `tsc` library over to `swc`, `@nrwl/js` will install the necessary dependencies to use `swc`.\n"
}

View File

@ -8,6 +8,7 @@
{
"id": "overview",
"name": "Overview",
"path": "/packages/linter",
"file": "shared/linter-plugin",
"content": "The Linter plugin contains executors, generator, plugin and utilities used for linting JavaScript/TypeScript projects within an Nx workspace.\n\n## Setting Up Linter\n\n### Installation\n\nIn any Nx workspace, you can install `@nrwl/linter` by running the following commands if `@nrwl/linter` package is not installed:\n\n```bash\nnpm i --save-dev @nrwl/linter\n```\n\n```bash\nyarn add --dev @nrwl/linter\n```\n\n## Lint\n\nYou can lint an application or a library with the following command:\n\n```bash\nnx lint my-app\n```\n\n```bash\nnx lint my-lib\n```\n\n## Utils\n\n- [convert-tslint-to-eslint](/angular/convert-tslint-to-eslint) - Converts a project linter from [TSLint](https://palantir.github.io/tslint/) to [ESLint](https://eslint.org/)\n"
},

View File

@ -8,6 +8,7 @@
{
"id": "overview",
"name": "Overview",
"path": "/packages/nest",
"file": "shared/nest-plugin",
"content": "![NestJS logo](/shared/nest-logo.png)\n\nNest.js is a framework designed for building scalable server-side applications. In many ways, Nest is familiar to Angular developers:\n\n- It has excellent TypeScript support.\n- Its dependency injection system is similar to the one in Angular.\n- It emphasises testability.\n- Its configuration APIs are similar to Angular as well.\n\nMany conventions and best practices used in Angular applications can be also be used in Nest.\n\n## Setting Up Nest\n\nTo create a new workspace with Nest, run the following command:\n\n```shell\nnpx create-nx-workspace my-workspace --preset=nest\n```\n\nYarn users can use the following command instead:\n\n```shell\nyarn create nx-workspace my-workspace --preset=nest\n```\n\nTo add the Nest plugin to an existing workspace, run one the following commands:\n\n```shell\nnpm install -D @nrwl/nest\n```\n\n```shell\nyarn add -D @nrwl/nest\n```\n\n### Create Applications\n\nYou can add a new Nest application with the following command:\n\n```shell\nnx g @nrwl/nest:app my-nest-app\n```\n\n#### Application Proxies\n\nGenerating Nest applications has an option to configure other projects in the workspace to proxy API requests. This can be done by passing the `--frontendProject` with the project name you wish to enable proxy support for.\n\n```shell\nnx g @nrwl/nest:app my-nest-app --frontendProject my-angular-app\n```\n\n### Create Libraries\n\nYou can add a new Nest library with the following command:\n\n```shell\nnx g @nrwl/nest:lib my-nest-lib\n```\n\nTo make the library `buildable`, use the following command:\n\n```shell\nnx g @nrwl/nest:lib my-nest-lib --buildable\n```\n\nTo make the library `publishable`, use the following command:\n\n```shell\nnx g @nrwl/nest:lib my-nest-lib --publishable --importPath=@my-workspace/my-nest-lib\n```\n\n> Read more about [building and publishing libraries here](/structure/buildable-and-publishable-libraries).\n\n### Nest Generators\n\nThe Nest plugin for Nx extends the generators provided by Nest. Any commands that can be used with the Nest CLI can also be used with the `nx` command. The `--project` flag should be used for all Nest generators.\n\n> `--project` is used to infer the root of the project where the generators will generate the files.\n\n## Using Nest\n\n### Build\n\nYou can build an application with the following command:\n\n```shell\nnx build my-nest-app\n```\n\nThis applies to `buildable` libraries as well\n\n```shell\nnx build my-nest-lib\n```\n\n#### Waiting for other builds\n\nSetting the `waitUntilTargets` option with an array of projects (with the following format: `\"project:architect\"`) will execute those commands before serving the Nest application.\n\n### Serve\n\nYou can serve an application with the following command:\n\n```shell\nnx serve my-nest-app\n```\n\nThe `serve` command runs the `build` target, and executes the application.\n\nBy default, the serve command will run in `watch` mode. This allows code to be changed, and the Nest application to be rebuilt automatically.\n\n#### Debugging\n\nNest applications also have the `inspect` flag set, so you can attach your debugger to the running instance.\n\nDebugging is set to use a random port that is available on the system. The port can be changed by setting the port option in the `serve` architect in the workspace.json. Or by running the serve command with `--port <number>`.\n\nFor additional information on how to debug Node applications, see the [Node.js debugging getting started guide](https://nodejs.org/en/docs/guides/debugging-getting-started/#inspector-clients).\n\n### Lint\n\nYou can lint an application with the following command:\n\n```shell\nnx lint my-nest-app\n```\n\nYou can lint a library with the following command:\n\n```shell\nnx lint my-nest-lib\n```\n\n### Unit Test\n\nYou can run unit test for an application with the following command:\n\n```shell\nnx test my-nest-app\n```\n\nYou can run unit test for a library with the following command:\n\n```shell\nnx test my-nest-lib\n```\n\n## More Documentation\n\n- [Todo Tutorial](/node-tutorial/01-create-application)\n- [Using Jest](/jest/overview)\n"
}

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,7 @@
{
"id": "overview",
"name": "Overview",
"path": "/packages/node",
"file": "shared/node-plugin",
"content": "The Node Plugin contains generators and executors to manage Node applications within an Nx workspace. It provides:\n\n## Setting Up Node\n\nTo add the Node plugin to an existing workspace, run one of the following:\n\n```bash\n# For npm users\nnpm install -D @nrwl/node\n\n# For yarn users\nyarn add -D @nrwl/node\n```\n\n### Creating Applications\n\nYou can add a new application with the following:\n\n```bash\nnx g @nrwl/node:application my-new-app\n```\n\nYou can run your application with `nx serve my-new-app`, which starts it in watch mode.\n\n### Creating Libraries\n\nNode libraries are a good way to separate features within your organization. To create a Node library run the following command:\n\n```bash\nnx g @nrwl/js:node my-new-lib\n\n# If you want the library to be buildable or publishable to npm\nnx g @nrwl/node:lib my-new-lib --buildable\nnx g @nrwl/node:lib my-new-lib \\\n--publishable \\\n--importPath=@myorg/my-new-lib\n```\n\n## Using Node\n\n### Testing Projects\n\nYou can run unit tests with:\n\n```bash\nnx test my-new-app\nnx test my-new-lib\n```\n\nReplace `my-new-app` with the name or your project. This command works for both applications and libraries.\n\n### Building Projects\n\nNode applications can be build with:\n\n```bash\nnx build my-new-app\n```\n\nAnd if you generated a library with `--buildable`, then you can build a library as well:\n\n```bash\nnx build my-new-lib\n```\n\nThe output is in the `dist` folder. You can customize the output folder by setting `outputPath` in the project's `project.json` file.\n\n### Application Proxies\n\nGenerating Node applications has an option to configure other projects in the workspace to proxy API requests. This can be done by passing the `--frontendProject` with the project name you wish to enable proxy support for.\n\n```bash\nnx g @nrwl/node:application my-new-app \\\n--frontendProject my-react-app\n```\n\n### Debugging\n\nDebugging is set to use a random port that is available on the system. The port can be changed by setting the port option in the `serve` architect in the project.json. Or by running the serve command with `--port <number>`.\n\nFor additional information on how to debug Node applications, see the [Node.js debugging getting started guide](https://nodejs.org/en/docs/guides/debugging-getting-started/#inspector-clients).\n\n## More Documentation\n\n- [Using Cypress](/cypress/overview)\n- [Using Jest](/jest/overview)\n"
}

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,7 @@
{
"id": "overview",
"name": "Overview",
"path": "/packages/react-native",
"file": "shared/react-native-plugin",
"content": "![React Logo](/shared/react-logo.png)\n\nReact Native brings React's declarative UI framework to iOS and Android. With React Native, you use native UI controls and have full access to the native platform.\n\nThe Nx Plugin for React Native contains generators for managing React Native applications and libraries within an Nx workspace. It provides:\n\n- Integration with libraries such as Jest, Detox, and Storybook.\n- Scaffolding for creating buildable libraries that can be published to npm.\n- Utilities for automatic workspace refactoring.\n\n## Setting Up React Native\n\n### Create a New Workspace\n\nThe easiest way to create your workspace is via `npx`.\n\n```bash\nnpx create-nx-workspace your-workspace-name \\\n--preset=react-native \\\n--appName=your-app-name\n```\n\n**Note:** You can also run the command without arguments to go through the interactive prompts.\n\n```bash\nnpx create-nx-workspace your-workspace-name\n```\n\n### Adding React Native to an Existing Workspace\n\nFor existing Nx workspaces, install the `@nrwl/react-native` package to add React Native capabilities to it.\n\n```bash\nnpm install @nrwl/react-native --save-dev\n\n# Or with yarn\nyarn add @nrwl/react-native --dev\n```\n\n### Generating Applications\n\nTo create additional React Native apps run:\n\n```bash\nnx g @nrwl/react-native:app your-app-name\n```\n\n### Generating Libraries\n\nTo generate a new library run:\n\n```bash\nnpx nx g @nrwl/react-native:lib your-lib-name\n```\n\n### Generating Components\n\nTo generate a new component inside library run:\n\n```bash\nnpx nx g @nrwl/react-native:component your-component-name --project=your-lib-name --export\n```\n\nReplace `your-lib-name` with the app's name as defined in your workspace.json file.\n\n## Using React Native\n\n- [run-ios](/react-native/run-ios) - Builds your app and starts it on iOS simulator or device\n- [run-android](/react-native/run-android) - Builds your app and starts it on a connected Android emulator or device\n- [build-android](/react-native/build-android) - Release Build for Android\n- [start](/react-native/package) - Starts the server that communicates with connected devices\n- [bundle](/web/package) - Builds the JavaScript bundle for offline use\n- [sync-deps](/react-native/sync-deps) - Syncs dependencies to package.json (required for autolinking)\n- [ensure-symlink](/react-native/ensure-symlink) - Ensure workspace node_modules is symlink under app's node_modules folder\n\n## More Documentation\n\n- [Using Detox](/detox/overview)\n- [Using Jest](/jest/overview)\n"
}

View File

@ -8,6 +8,7 @@
{
"name": "Overview",
"id": "overview",
"path": "/packages/react",
"file": "shared/react-plugin",
"content": "![React Logo](/shared/react-logo.png)\n\nThe React plugin contains executors and generators for managing React applications and libraries within an Nx workspace.\nIt provides:\n\n- Integration with libraries such as Jest, Cypress, and Storybook.\n- Generators for applications, libraries, components, hooks, and more.\n- Library build support for publishing packages to npm or other registries.\n- Utilities for automatic workspace refactoring.\n\n## Setting Up React\n\nTo create a new workspace with React, run `npx create-nx-workspace@latest --preset=react`.\n\nTo add the React plugin to an existing workspace, run one of the following:\n\n```bash\n# For npm users\nnpm install -D @nrwl/react\n\n# For yarn users\nyarn add -D @nrwl/react\n```\n\n### Creating Applications and Libraries\n\nYou can add a new application with the following:\n\n```bash\nnx g @nrwl/react:app my-new-app\n```\n\nTo start the application in development mode, run `nx serve my-new-app`.\n\nAnd add a new library as follows:\n\n```bash\nnx g @nrwl/react:lib my-new-lib\n\n# If you want the library to be buildable or publishable to npm\nnx g @nrwl/react:lib my-new-lib --buildable\nnx g @nrwl/react:lib my-new-lib \\\n--publishable \\\n--importPath=@myorg/my-new-lib\n```\n\nRead more about [building and publishing libraries here](/structure/buildable-and-publishable-libraries).\n\n### Creating Components\n\nAdding a component to an existing project can be done with:\n\n```bash\nnx g @nrwl/react:component my-new-component \\\n--project=my-new-app\n\n# Note: If you want to export the component\n# from the library use --export\nnx g @nrwl/react:component my-new-component \\\n--project=my-new-lib \\\n--export\n```\n\nReplace `my-new-app` and `my-new-lib` with the name of your projects.\n\n### Creating Hooks\n\nIf you want to add a new hook, run the following\n\n```bash\nnx g @nrwl/react:hook my-new-hook --project=my-new-lib\n```\n\nReplace `my-new-lib` with the name of your project.\n\n## Using React\n\n### Testing Projects\n\nYou can run unit tests with:\n\n```bash\nnx test my-new-app\nnx test my-new-lib\n```\n\nReplace `my-new-app` with the name or your project. This command works for both applications and libraries.\n\nYou can also run E2E tests for applications:\n\n```bash\nnx e2e my-new-app-e2e\n```\n\nReplace `my-new-app-e2e` with the name or your project with `-e2e` appended.\n\n### Building Projects\n\nReact applications can be build with:\n\n```bash\nnx build my-new-app\n```\n\nAnd if you generated a library with `--buildable`, then you can build a library as well:\n\n```bash\nnx build my-new-lib\n```\n\nThe output is in the `dist` folder. You can customize the output folder by setting `outputPath` in the\nproject's `project.json` file.\n\nThe application in `dist` is deployable, and you can try it out locally with:\n\n```bash\nnpx http-server dist/apps/my-new-app\n```\n\nThe library in `dist` is publishable to npm or a private registry.\n\n## More Documentation\n\n- [Using Cypress](/cypress/overview)\n- [Using Jest](/jest/overview)\n- [Using Storybook](/storybook/overview-react)\n"
}

View File

@ -8,6 +8,7 @@
{
"id": "overview",
"name": "Overview Generic",
"path": "/packages/storybook",
"file": "shared/guides/storybook/plugin-overview",
"content": "![Storybook logo](/shared/storybook-logo.png)\n\nStorybook is a development environment for UI components. It allows you to browse a component library, view the different states of each component, and interactively develop and test components.\n\nThis guide will briefly walk you through using Storybook within an Nx workspace.\n\n## Setting Up Storybook\n\n### Add the Storybook plugin\n\n```bash\nyarn add --dev @nrwl/storybook\n```\n\n## Using Storybook\n\n### Generating Storybook Configuration\n\nYou can generate Storybook configuration for an individual project with this command:\n\n```bash\nnx g @nrwl/react:storybook-configuration project-name\n```\n\n### Running Storybook\n\nServe Storybook using this command:\n\n```bash\nnx run project-name:storybook\n```\n\n## More Documentation\n\nYou can find dedicated information for React and Angular:\n\n- [Overview Storybook For Angular](/storybook/overview-angular)\n- [Overview Storybook For React](/storybook/overview-react)\n\nFor more on using Storybook, see the [official Storybook documentation](https://storybook.js.org/docs/basics/introduction/).\n\n### Migration Scenarios\n\nHere's more information on common migration scenarios for Storybook with Nx. For Storybook specific migrations that are not automatically handled by Nx please refer to the [official Storybook page](https://storybook.js.org/)\n\n- [Upgrading to Storybook 6](/storybook/upgrade-storybook-v6-react)\n- [Migrate to the Nrwl React Storybook Preset](/storybook/migrate-webpack-final-react)\n"
},

View File

@ -8,6 +8,7 @@
{
"name": "Overview",
"id": "overview",
"path": "/packages/web",
"file": "shared/web-plugin",
"content": "The Nx Plugin for Web Components contains generators for managing Web Component applications and libraries within an Nx workspace. It provides:\n\n- Integration with libraries such as Jest, Cypress, and Storybook.\n- Scaffolding for creating buildable libraries that can be published to npm.\n- Utilities for automatic workspace refactoring.\n\n## Setting Up Web\n\nTo create a new workspace with web, run `npx create-nx-workspace@latest --preset=web`.\n\nTo add the web plugin to an existing workspace, run one of the following:\n\n```bash\n# For npm users\nnpm install -D @nrwl/web\n\n# For yarn users\nyarn add -D @nrwl/web\n```\n\n### Creating Applications\n\nYou can add a new application with the following:\n\n```bash\nnx g @nrwl/web:app my-new-app\n```\n\nThe application uses no framework and generates with web components. You can add any framework you want on top of the default setup.\n\nTo start the application in development mode, run `nx serve my-new-app`.\n\n**Note:** If you are looking to add a React application, check out the [React plugin](/react/overview).\n\n### Creating Libraries\n\nTo create a generic TypeScript library (i.e. non-framework specific), use the [`@nrwl/js`](/js/overview) plugin.\n\n```bash\nnx g @nrwl/js:lib my-new-lib\n\n# If you want the library to be buildable or publishable to npm\nnx g @nrwl/web:lib my-new-lib --buildable\nnx g @nrwl/web:lib my-new-lib \\\n--publishable \\\n--importPath=@myorg/my-new-lib\n```\n\n## Using Web\n\n### Testing Projects\n\nYou can run unit tests with:\n\n```bash\nnx test my-new-app\nnx test my-new-lib\n```\n\nReplace `my-new-app` with the name or your project. This command works for both applications and libraries.\n\nYou can also run E2E tests for applications:\n\n```bash\nnx e2e my-new-app-e2e\n```\n\nReplace `my-new-app-e2e` with the name or your project with `-e2e` appended.\n\n### Building Projects\n\nReact applications can be build with:\n\n```bash\nnx build my-new-app\n```\n\nAnd if you generated a library with `--buildable`, then you can build a library as well:\n\n```bash\nnx build my-new-lib\n```\n\nThe output is in the `dist` folder. You can customize the output folder by setting `outputPath` in the project's `project.json` file.\n\nThe application in `dist` is deployable, and you can try it out locally with:\n\n```bash\nnpx http-server dist/apps/my-new-app\n```\n\nThe library in `dist` is publishable to npm or a private registry.\n\n## More Documentation\n\n- [Using Cypress](/cypress/overview)\n- [Using Jest](/cypress/overview)\n"
}

View File

@ -8,6 +8,7 @@
{
"name": "Overview",
"id": "overview",
"path": "/packages/workspace",
"file": "shared/workspace-plugin",
"content": "The workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.\n\n## Creating Workspace Generators\n\nCodifying your organization's best practices into workspace generators is a great way to ensure that the best practices are easy to follow and implement. Running `nx g @nrwl/workspace:workspace-generator feature` will create a workspace generator which is written the same way generators are written for Nx plugins. The workspace generator can then be run with `nx workspace-generator feature`.\n\n> See more about [workspace generators](/generators/workspace-generators)\n\n## Reorganizing Projects\n\nAfter some time of working within a workspace, projects might need to be moved or sometimes even removed.\nThe workspace plugin provides the [`@nrwl/workspace:move`](/workspace/move) and [`@nrwl/workspace:remove`](/workspace/remove) generators to help aid with this.\n\n### Moving Projects\n\nRunning `nx g @nrwl/workspace:move new/location/my-lib --projectName my-lib` will move the `my-lib` library to `libs/new/location/my-lib`.\n\nMoving the files manually can be done easily but a lot of steps are often missed when projects are moved. This generator will also handle the following:\n\n1. The project's files will be moved\n2. The project will be renamed to `new-location-my-lib`\n3. The path mapping in `tsconfig.base.json` will be changed to `@npmScope/new/location/my-lib`\n4. Imports in other projects will be changed to `@npmScope/new/location/my-lib`\n5. Paths in target options such as output path will be changed\n6. Other configuration will be updated too such as `extends` in `tsconfig.json`, the name of the project in `jest.config.js`, and the extends in `.eslintrc.json`\n\n> See more about [`@nrwl/workspace:move`](/workspace/move)\n\n### Removing Projects\n\nRunning `nx g @nrwl/workspace:remove my-lib` will remove the `my-lib` from the workspace. It is important to note that sometimes, projects cannot be removed if they are still depended on by other projects.\n\nLike when moving projects, some steps are often missed when removing projects. This generator will also handle the following:\n\n1. Checks if other projects depend on the project being removed. This can be ignored via the `--forceRemove` flag.\n2. The project's files will be deleted.\n3. The project's configuration will be removed.\n4. The path mapping in `tsconfig.base.json` will be removed.\n\n> See more about [`@nrwl/workspace:remove`](/workspace/remove)\n\n## Running custom commands\n\nExecutors provide an optimized way of running targets but unfortunately, not every target has an executor written for it. The [`nx:run-commands`](/packages/nx/executors/run-commands) executor is an executor that runs any command or multiple commands in the shell. This can be useful when integrating with other tools which do not have an executor provided. There is also a generator to help configure this executor.\n\nRunning `nx g nx:run-commands printhello --project my-feature-lib --command 'echo hello'` will create a `my-feature-lib:printhello` target that executes `echo hello` in the shell.\n\n> See more about [`nx:run-commands`](/packages/nx/executors/run-commands)\n"
}

File diff suppressed because it is too large Load Diff

View File

@ -9,15 +9,26 @@ export interface StaticDocumentPaths {
}
export class DocumentsApi {
private documents: DocumentMetadata;
constructor(
private readonly options: {
publicDocsRoot: string;
documents: DocumentMetadata;
documentSources: DocumentMetadata[];
}
) {
if (!options.publicDocsRoot) {
throw new Error('public docs root cannot be undefined');
}
if (!options.documentSources) {
throw new Error('public document sources cannot be undefined');
}
this.documents = {
id: 'documents',
name: 'documents',
itemList: options.documentSources.flatMap(
(x) => x.itemList
) as DocumentMetadata[],
};
}
getDocument(path: string[]): DocumentData {
@ -41,7 +52,7 @@ export class DocumentsApi {
}
getDocuments(): DocumentMetadata {
const docs = this.options.documents;
const docs = this.documents;
if (docs) return docs;
throw new Error(`Cannot find any documents`);
}
@ -55,14 +66,6 @@ export class DocumentsApi {
recur(ii, [...acc, curr.id]);
});
} else {
/*
* Do not try to get paths for Packages (done by the PackagesApi).
* This should be removed when the packages/schemas menu is inferred directly from PackagesApi.
* TODO@ben: Remove this when packages schemas menu is auto-generated.
*/
if (!!curr['path'] && curr['path'].startsWith('/packages/'))
return void 0; // Do nothing
paths.push({
params: {
segments: [...acc, curr.id],
@ -71,9 +74,9 @@ export class DocumentsApi {
}
}
if (!this.options.documents || !this.options.documents.itemList)
if (!this.documents || !this.documents.itemList)
throw new Error(`Can't find any items`);
this.options.documents.itemList.forEach((item) => {
this.documents.itemList.forEach((item) => {
recur(item, []);
});
@ -81,7 +84,7 @@ export class DocumentsApi {
}
private getFilePath(path: string[]): string {
let items = this.options.documents?.itemList;
let items = this.documents?.itemList;
if (!items) {
throw new Error(`Document not found`);

View File

@ -1,36 +0,0 @@
import { DocumentMetadata } from '@nrwl/nx-dev/models-document';
import { Menu } from '@nrwl/nx-dev/models-menu';
import {
createMenuItems,
getApiSection,
getBasicSection,
getDeepDiveSection,
} from './menu.utils';
export class MenuApi {
private menuCache: Menu | null = null;
constructor(private readonly documents: DocumentMetadata) {}
getMenu(): Menu {
let menu = this.menuCache;
if (!menu) {
const items = createMenuItems(this.documents);
if (items) {
menu = {
sections: [
getBasicSection(items),
getDeepDiveSection(items),
getApiSection(items),
],
};
} else {
throw new Error(`Cannot find any documents`);
}
this.menuCache = menu;
}
return menu;
}
}

View File

@ -1,2 +1 @@
export * from './lib/documents.api';
export * from './lib/menu.api';

View File

@ -0,0 +1,3 @@
{
"presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]]
}

View File

@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}

View File

@ -0,0 +1,11 @@
# nx-dev-data-access-menu
This library was generated with [Nx](https://nx.dev).
## Running unit tests
Run `nx test nx-dev-data-access-menu` to execute the unit tests via [Jest](https://jestjs.io).
## Running lint
Run `nx lint nx-dev-data-access-menu` to execute the lint via [ESLint](https://eslint.org/).

View File

@ -0,0 +1,14 @@
module.exports = {
displayName: 'nx-dev-data-access-menu',
preset: '../../jest.preset.ts',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/nx-dev/data-access-menu',
};

View File

@ -0,0 +1,22 @@
{
"sourceRoot": "nx-dev/data-access-menu/src",
"projectType": "library",
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["nx-dev/data-access-menu/**/*.ts"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/nx-dev/data-access-menu"],
"options": {
"jestConfig": "nx-dev/data-access-menu/jest.config.ts",
"passWithNoTests": true
}
}
},
"tags": []
}

View File

@ -0,0 +1 @@
export * from './lib/menu.api';

View File

@ -0,0 +1,51 @@
import { DocumentMetadata } from '@nrwl/nx-dev/models-document';
import { Menu, MenuSection } from '@nrwl/nx-dev/models-menu';
import {
createMenuItems,
getBasicSection,
getDeepDiveSection,
getPackageApiSection,
} from './menu.utils';
export class MenuApi {
private menuCache: Menu | null = null;
constructor(
private readonly documents: DocumentMetadata,
private readonly packageDocuments: DocumentMetadata[]
) {}
getMenu(): Menu {
let menu = this.menuCache;
if (menu) return menu;
const items = createMenuItems(this.documents);
if (items) {
menu = {
sections: [
getBasicSection(items),
getDeepDiveSection(items),
// getApiSection(items),
this.getReferenceApiMenuSection(),
],
};
} else {
throw new Error(`Cannot find any documents`);
}
this.menuCache = menu;
return menu;
}
getReferenceApiMenuSection(): MenuSection {
const documents: DocumentMetadata = {
id: 'packages',
name: 'Packages',
itemList: this.packageDocuments,
};
const items = createMenuItems(documents);
return getPackageApiSection(items);
}
}

View File

@ -7,7 +7,7 @@ export function createMenuItems(root: DocumentMetadata): MenuItem[] {
const createPathMetadata = (g: DocumentMetadata, parentId = ''): MenuItem => {
const pathData = {
...g,
path: g['path'] ?? `/${parentId}/${g.id}`,
path: g.path ?? `/${parentId}/${g.id}`,
};
if (Array.isArray(g.itemList)) {
@ -86,31 +86,18 @@ export function getDeepDiveSection(items: MenuItem[]): MenuSection {
};
}
export function getApiSection(items: MenuItem[]): MenuSection {
export function getPackageApiSection(items: MenuItem[]): MenuSection {
return {
id: 'api',
name: 'API / Reference',
itemList: items.filter(
(m) =>
// m.id === 'plugins-overview' ||
m.id === 'workspace' ||
m.id === 'js' ||
m.id === 'web' ||
m.id === 'angular' ||
m.id === 'react' ||
m.id === 'jest' ||
m.id === 'cypress' ||
m.id === 'storybook' ||
m.id === 'linter' ||
m.id === 'node' ||
m.id === 'express' ||
m.id === 'nest' ||
m.id === 'next' ||
m.id === 'detox' ||
m.id === 'react-native' ||
m.id === 'nx-plugin' ||
m.id === 'nx-devkit' ||
m.id === 'cli'
m.id !== 'add-nx-to-monorepo' &&
m.id !== 'cra-to-nx' &&
m.id !== 'create-nx-plugin' &&
m.id !== 'create-nx-workspace' &&
m.id !== 'make-angular-cli-faster' &&
m.id !== 'tao'
),
};
}

View File

@ -0,0 +1,19 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
}
}

View File

@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": []
},
"include": ["**/*.ts"],
"exclude": ["jest.config.ts", "**/*.spec.ts"]
}

View File

@ -0,0 +1,20 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"**/*.test.ts",
"**/*.spec.ts",
"**/*.test.tsx",
"**/*.spec.tsx",
"**/*.test.js",
"**/*.spec.js",
"**/*.test.jsx",
"**/*.spec.jsx",
"**/*.d.ts"
]
}

View File

@ -1,3 +1,4 @@
import { DocumentMetadata } from '@nrwl/nx-dev/models-document';
import { PackageMetadata, SchemaMetadata } from '@nrwl/nx-dev/models-package';
import { readFileSync } from 'fs';
@ -24,22 +25,21 @@ export class PackagesApi {
}
}
getPackage(name: string): PackageMetadata {
getPackage(id: string): PackageMetadata {
const packagePath: string | null =
this.options.packagesIndex.find((p) => p.name === name)?.path ?? null;
this.options.packagesIndex.find((p) => p.name === id)?.path ?? null;
if (!packagePath)
throw new Error('Package name could not be found: ' + name);
if (!packagePath) throw new Error('Package name could not be found: ' + id);
if (!this.database[name])
this.database[name] = JSON.parse(
if (!this.database[id])
this.database[id] = JSON.parse(
readFileSync(
[this.options.publicPackagesRoot, packagePath].join('/'),
'utf-8'
)
);
return this.database[name];
return this.database[id];
}
getStaticPackagePaths(): StaticPackagePaths[] {
@ -69,6 +69,38 @@ export class PackagesApi {
return paths;
}
getPackageDocuments(): DocumentMetadata {
return {
id: 'packages',
name: 'packages',
itemList: this.options.packagesIndex.map((p) => ({
id: p.name,
name: p.name.replace(/-/gi, ' '),
path: `/packages/${p.name}`,
itemList: this.getPackage(p.name)
.documentation.map((d) => ({
id: d.id,
name: d.name,
path: d.path,
}))
.concat(
p.schemas.executors.map((e) => ({
id: e,
name: e,
path: `/packages/${p.name}/executors/${e}`,
}))
)
.concat(
p.schemas.generators.map((g) => ({
id: g,
name: g,
path: `/packages/${p.name}/generators/${g}`,
}))
),
})),
};
}
getPackageSchema(
packageName: string,
type: 'executors' | 'generators',

View File

@ -9,5 +9,6 @@ export interface DocumentMetadata {
id: string;
name?: string;
file?: string;
path?: string;
itemList?: DocumentMetadata[];
}

View File

@ -8,7 +8,13 @@ export interface PackageMetadata {
githubRoot: string;
name: string;
description: string;
documentation: { id: string; name: string; content: string; file: string }[];
documentation: {
id: string;
name: string;
content: string;
file: string;
path: string;
}[];
root: string;
source: string;
generators: SchemaMetadata[];

View File

@ -1,7 +1,5 @@
import {
DocumentsApi,
MenuApi,
} from '@nrwl/nx-dev/data-access-documents/node-only';
import { DocumentsApi } from '@nrwl/nx-dev/data-access-documents/node-only';
import { MenuApi } from '@nrwl/nx-dev/data-access-menu';
import { PackagesApi } from '@nrwl/nx-dev/data-access-packages/node-only';
import { DocumentMetadata } from '@nrwl/nx-dev/models-document';
@ -17,7 +15,13 @@ export const packagesApi = new PackagesApi({
export const documentsApi = new DocumentsApi({
publicDocsRoot: 'nx-dev/nx-dev/public/documentation',
documents: documents.find((x) => x.id === 'default') as DocumentMetadata,
documentSources: [
documents.find((x) => x.id === 'default'),
documents.find((x) => x.id === 'additional-api-references'),
].filter((x) => !!x) as DocumentMetadata[],
});
export const menuApi = new MenuApi(documentsApi.getDocuments());
export const menuApi = new MenuApi(
documentsApi.getDocuments(),
packagesApi.getPackageDocuments().itemList as DocumentMetadata[]
);

View File

@ -7,11 +7,32 @@ console.log(`${chalk.blue('i')} Documentation Map Check`);
const basePath = 'docs';
const sharedFilesPattern = 'shared/cli';
// These are Overview documentation files showed at url like `/packages/:name`
const allowedOrphanFiles: string[] = [
'shared/angular-plugin.md',
'shared/cypress-plugin.md',
'shared/detox-plugin.md',
'shared/express-plugin.md',
'shared/guides/storybook/plugin-overview.md',
'shared/jest-plugin.md',
'shared/js-plugin.md',
'shared/linter-plugin.md',
'shared/nest-plugin.md',
'shared/next-plugin.md',
'shared/node-plugin.md',
'shared/nx-plugin.md',
'shared/react-native-plugin.md',
'shared/react-plugin.md',
'shared/web-plugin.md',
'shared/workspace-plugin.md',
].map((x) => x.replace('.md', ''));
const readmePathList: string[] = glob
.sync(`${basePath}/**/*.md`)
.map((path: string) => path.split(basePath)[1])
.map((path: string) => path.slice(1, -3)) // Removing first `/` and `.md`
.filter((path: string) => !path.startsWith(sharedFilesPattern));
.filter((path: string) => !path.startsWith(sharedFilesPattern))
.filter((i) => !allowedOrphanFiles.includes(i)); // Removing the paths allowed to be orphans
function pathExtractor(
pathList: string[] = [],

View File

@ -2,7 +2,13 @@ import { Canvas, Image, SKRSContext2D } from '@napi-rs/canvas';
import { readJSONSync, ensureDir, readFile, writeFileSync } from 'fs-extra';
import { resolve } from 'path';
const documents: any[] = readJSONSync('./docs/map.json', 'utf8')[0]['itemList'];
const mapJson = readJSONSync('./docs/map.json', 'utf8');
const documents: any[] = [
...mapJson.find((x) => x.id === 'default')?.['itemList'],
...mapJson.find((x) => x.id === 'additional-api-references')?.['itemList'],
].filter(Boolean);
const packages: {
name: string;
path: string;

View File

@ -107,6 +107,7 @@ export function getPackageMetadataList(
documentation: !!hasDocumentation
? hasDocumentation.itemList.map((item) => ({
...item,
path: item.path,
file: item.file,
content: readFileSync(join('docs', item.file + '.md'), 'utf8'),
}))

View File

@ -48,6 +48,7 @@
"@nrwl/nx-dev/data-access-documents/node-only": [
"./nx-dev/data-access-documents/src/node.index.ts"
],
"@nrwl/nx-dev/data-access-menu": ["nx-dev/data-access-menu/src/index.ts"],
"@nrwl/nx-dev/data-access-packages": [
"./nx-dev/data-access-packages/src/index.ts"
],

View File

@ -46,6 +46,7 @@
"nx": "packages/nx",
"nx-dev": "nx-dev/nx-dev",
"nx-dev-data-access-documents": "nx-dev/data-access-documents",
"nx-dev-data-access-menu": "nx-dev/data-access-menu",
"nx-dev-data-access-packages": "nx-dev/data-access-packages",
"nx-dev-e2e": "nx-dev/nx-dev-e2e",
"nx-dev-feature-analytics": "nx-dev/feature-analytics",