{"id":19435395,"url":"https://github.com/nestjsplus/dyn-schematics","last_synced_at":"2025-04-24T21:30:30.713Z","repository":{"id":46919858,"uuid":"209425436","full_name":"nestjsplus/dyn-schematics","owner":"nestjsplus","description":"NestJS Dynamic Module Schematics for @nestjs/cli","archived":false,"fork":false,"pushed_at":"2024-04-27T20:01:38.000Z","size":433,"stargazers_count":40,"open_issues_count":17,"forks_count":15,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-29T00:30:40.575Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nestjsplus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-19T00:06:14.000Z","updated_at":"2024-10-04T15:47:30.000Z","dependencies_parsed_at":"2024-06-18T19:50:17.145Z","dependency_job_id":"2c5f5d87-ed3d-4bbb-8cb1-a5a43f1b38be","html_url":"https://github.com/nestjsplus/dyn-schematics","commit_stats":{"total_commits":16,"total_committers":2,"mean_commits":8.0,"dds":0.0625,"last_synced_commit":"9a3542bb8b1b7ba017f4549643a57c4ede961e41"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjsplus%2Fdyn-schematics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjsplus%2Fdyn-schematics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjsplus%2Fdyn-schematics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjsplus%2Fdyn-schematics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nestjsplus","download_url":"https://codeload.github.com/nestjsplus/dyn-schematics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223968412,"owners_count":17233445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T15:06:07.995Z","updated_at":"2024-11-10T15:06:08.581Z","avatar_url":"https://github.com/nestjsplus.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"http://nestjs.com/\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://nestjs.com/img/logo_text.svg\" width=\"150\" alt=\"Nest Logo\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003ch3 align=\"center\"\u003eNestJS CLI Schematics for Dynamic Module Generation\u003c/h3\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://nestjs.com\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/license-MIT-brightgreen.svg\" alt=\"License\" /\u003e\n    \u003cimg src=\"https://badge.fury.io/js/%40nestjsplus%2Fdyn-schematics.svg\" alt=\"npm version\" height=\"18\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/built%20with-NestJs-red.svg\" alt=\"Built with NestJS\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n### Overview\n\nThis package contains a set of [NestJS CLI](https://docs.nestjs.com/cli/overview) schematics for generating modules that can be dynamically configured.  The concepts behind the generated code is covered in detail [in this article](https://dev.to/nestjs/advanced-nestjs-how-to-build-completely-dynamic-nestjs-modules-1370).\n\nSee [below](#dynamic-package-generation) for a description of the use cases.\n\n### Installation\n\nInstall the package **globally** as shown below.  Due to the implementation of the NestJS CLI, the package **must** be global.\n\n```bash\nnpm install -g @nestjsplus/dyn-schematics\n```\n\n### Dynamic Package Generation\n\nCurrently, there are two use cases supported, each with a corresponding schematic:\n\n1. Generating a complete, new standalone NestJS *package* containing a dynamic module. Such a package can easily be installed locally with npm, or packaged and distributed via the [npm registry](https://npmjs.com), or a private registry.  In other words, use this to build a re-usable library.\n2. Adding a generated dynamic module *to an existing NestJS project*. In this case, the module is created in its own folder, and is wired in to the existing project using appropriate module metadata, includes, etc.  This schematic works much like Nest's built-in `module` schematic, but creates a fully implemented *dynamic module*.\n\n### Nest CLI\n\nThese schematics are built on top of the [Nest CLI](https://docs.nestjs.com/cli/usages) infrastructure, so their usage is exactly as documented on that page.\n\n\u003e Note: since these schematics are built on top of the Nest CLI, all of the optional arguments (such as specifying an optional path in which to generate the code) and options (such as `--dry-run`, `--flat`) are available.  Currently, however, the schematics do not generate spec files.\n\n\u003e Note: I'm working on schematics to add new components to an existing dynamic module, such as additional *options providers*. This should be coming soon.\n\n### Use-case #1: Generating a standalone package\n\nThe following step will create a new folder using `\u003cpkg-name\u003e`, which will contain the standalone package files and folders for your new dynamic module package.\n\n#### Use the `dynpkg` schematic\n\n```bash\nnest g -c @nestjsplus/dyn-schematics dynpkg \u003cpkg-name\u003e\n```\n\n- `dynpkg` is the name of the schematic used to generate a new standalone package containing a dynamic module.\n- `\u003cpkg-name\u003e` is the name of the new package you're building.\n\nThe schematic will prompt you asking whether to create a *test client*.  If you answer yes, it will add a small module, which you can later easily remove, to test out the newly generated schematic.  I recommend you choose `yes` when first testing out the schematic.\n\nMove to the sub-folder just created:\n\n```bash\ncd \u003cpkg-name\u003e\n```\n- where `pkg-name` is the name you supplied in the original `nest g` command above.\n\nInstall the dependencies for the generated package:\n\n```bash\nnpm install\n```\n\n#### Verify generated package\n\nIf you answered `yes` to the prompt `Generate a testing client?`, a small testing module was automatically generated called `\u003cpkg-name\u003eClientModule`.  You can test that the template was properly generated by running:\n\n```bash\nnpm run start:dev\n```\n\nThen browse to [http://localhost:3000](http://localhost:3000).  Your browser should display `Hello from \u003cpkg-name\u003eModule!`.\n\n#### Optionally publish package\n\nThe `package.json` and `tsconfig.json` files are generated according to the process described [in this article](https://dev.to/nestjs/publishing-nestjs-packages-with-npm-21fm).  This means that publishing the package to npm is as simple as:\n1. updating the `package.json` with your author information, etc.\n2. running `npm publish`\n\nSee [the npm packaging](https://dev.to/nestjs/publishing-nestjs-packages-with-npm-21fm) article for more information.\n\n### Use-case #2: Adding a dynamic module to an existing project\n\nMake sure you're in the project root folder, just as you would be if running something like `nest g controller myController`.\n\n#### Use the `dnymod` schematic\n\n```bash\nnest g -c @nestjsplus/dyn-schematics dynmod \u003cmodule-name\u003e\n```\n\n- `dynmod` is the name of the schematic used to generate a new dynamic module (which will be added to your existing project).\n- `\u003cmodule-name\u003e` is the name of the new module you're building.\n\nThe schematic adds the new module in a folder named `\u003cmodule-name\u003e`.  Just like using the built-in module schematic (e.g., `nest g module myNewModule`), this will add the generated module to the imports list of your root module with the appropriate metadata and includes.  At this point, you can customize the generated module as needed.\n\n### Customizing\n\nThe files in the project have comments that should help guide you.\n\n#### More help\n\nYou can also refer to these articles:\n\n[How to build completely dynamic NestJS mdoules](https://dev.to/nestjs/advanced-nestjs-how-to-build-completely-dynamic-nestjs-modules-1370) - for details on the concepts behind the *dynamic module pattern*.\n\n[Built a NestJS module for Knex.js in 5 minutes](https://dev.to/nestjs/build-a-nestjs-module-for-knex-js-or-other-resource-based-libraries-in-5-minutes-12an) - an end-to-end tutorial on using these schematics.\n\n\n### Change Log\n\nSee [Changelog](CHANGELOG.md) for more information.\n\n### Contributing\n\nContributions welcome! See [Contributing](CONTRIBUTING.md).\n\n### Author\n\n**John Biundo (Y Prospect on [Discord](https://discord.gg/G7Qnnhy))**\n\n### License\n\nLicensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnestjsplus%2Fdyn-schematics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnestjsplus%2Fdyn-schematics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnestjsplus%2Fdyn-schematics/lists"}