1.0.0 • Published 1 year ago

nx-angular-test v1.0.0

Weekly downloads
-
License
Viettel Solutions
Repository
github
Last release
1 year ago

VTS Kit Angular NX Plugin

VTS Kit Angular NX Plugin is a collection of generators to be integrated with Nx Workspace. This library aims to provide a quick way to start a new Angular Project and maintain code structure with least effort.

Requirement

  • Node: 12+
  • Npm: 6+ (included in Node installation)
  • Npx: 6+ (included in Node installation)

Quickstart

  • Update npm registry:
npm config set registry http://10.254.144.164:8081/repository/npm-all/
  • Create a new workspace using VTS Kit Angular NX Plugin:
npx @vts-kit/nx-angular@latest

Structure

.
└── <workspace_name>/
    ├── apps/
    │   └── <app_name>/
    │       ├── src/
    │       │   ├── app/
    │       │   │   ├── app.module.ts           // Root component
    │       │   │   ├── app.component.ts        // Root component, bootstrap
    │       │   │   ├── app.component.spec.ts   // Root component, test
    │       │   │   ├── app.component.html      // Root component, outlet
    │       │   │   └── routes.ts               // RouterModule config, lazy load to feature libraries
    │       │   ├── assets/                     // Public assets
    │       │   └── environments/               // Environment config
    │       │       ├── environment.ts          // Environment profile
    │       │       └── environment.prod.ts     // Environment profile
    │       ├── webpack/                        // Webpack config
    │       │   ├── webpack.config.js           // Webpack profile
    │       │   └── webpack.config.prod.js      // Webpack profile
    │       ├── project.json                    // Nx Project configuration
    │       ├── tsconfig(.|lib|spec).json       // Tsconfig
    │       ├── favicon.ico                     // Angular starter files
    │       ├── index.html                      // Angular starter files
    │       ├── main.ts                         // Angular starter files
    │       ├── polyfills.ts                    // Angular starter files
    │       ├── styles.scss                     // Angular starter files
    │       └── test.ts                         // Angular starter files
    ├── libs/                                   // Shared modules and feature modules
    │   ├── layout/                             // Feature group, layout
    │   │   ├── ui/                             // Library (generatable)
    │   │   │   ├── src/
    │   │   │   │   ├── index.ts                // Automatically exporter on generating
    │   │   │   │   └── lib/
    │   │   │   │       ├── <topbar>            // Standalone UI components, unit (generatable)
    │   │   │   │       └── <sider>             // Standalone UI components, unit (generatable)
    │   │   │   ├── project.json                // NX Project configuration
    │   │   │   └── tsconfig(.|lib|spec).json   // Tsconfig
    │   │   ├── feature/                        // Library (generatable)
    │   │   │   ├── src/
    │   │   │   │   ├── index.ts                // Automatically exporter on generating
    │   │   │   │   └── lib/
    │   │   │   │       ├── <dasboard_layout>   // Standalone UI components, container (ultilize units in template)
    │   │   │   │       ├── <home_layout>       // Standalone UI components, container (ultilize units in template)
    │   │   │   │       ├── routes.ts           // RouterModule config, lazy load
    │   │   │   │       └── *.module.ts
    │   │   │   ├── project.json                // NX Project configuration
    │   │   │   └── tsconfig(.|lib|spec).json   // Tsconfig
    │   │   └── data-access/                    // Library (generatable)
    │   │       ├── src/
    │   │       │   ├── index.ts                // Automatically exporter on generating
    │   │       │   └── lib/
    │   │       │       └── <store_1>           // State management, store
    │   │       ├── project.json                // NX Project configuration
    │   │       └── tsconfig(.|lib|spec).json   // Tsconfig
    │   ├── <feature_product>/                  // Feature group (generatable)
    │   │   ├── ui/                             // Library (generatable)
    │   │   │   ├── src/
    │   │   │   │   ├── index.ts                // Automatically exporter on generating
    │   │   │   │   └── lib/
    │   │   │   │       ├── <product_form>      // Standalone UI components, unit (generatable)
    │   │   │   │       └── <product_table>     // Standalone UI components, unit (generatable)
    │   │   │   ├── project.json                // NX Project configuration
    │   │   │   └── tsconfig(.|lib|spec).json   // Tsconfig
    │   │   ├── feature/                        // Library (generatable)
    │   │   │   ├── src/
    │   │   │   │   ├── index.ts                // Automatically exporter on generating
    │   │   │   │   └── lib/
    │   │   │   │       ├── <list_screen>       // Standalone UI components, container (ultilize units in template)
    │   │   │   │       ├── <detail_screen>     // Standalone UI components, container (ultilize units in template)
    │   │   │   │       ├── routes.ts           // RouterModule config, lazy load
    │   │   │   │       └── *.module.ts
    │   │   │   ├── project.json                // NX Project configuration
    │   │   │   └── tsconfig(.|lib|spec).json   // Tsconfig
    │   │   └── data-access/                    // Library (generatable)
    │   │       ├── src/
    │   │       │   ├── index.ts                // Automatically exporter on generating
    │   │       │   └── lib/
    │   │       │       ├── <item_state>        // State management, store
    │   │       │       └── <filter_state>      // State management, store
    │   │       ├── project.json                // NX Project configuration
    │   │       └── tsconfig(.|lib|spec).json   // Tsconfig
    │   └── share/
    │       └── guards/                         // Library, publishable (generatable)
    │       ├── interceptors/                   // Library, publishable (generatable)
    │       ├── mixins/                         // Library, publishable (generatable)
    │       ├── pipes/                          // Library, publishable (generatable)
    │       ├── services/                       // Library, publishable (generatable)
    │       ├── ui/                             // Library, publishable (generatable)
    │       ├── utils/                          // Library, publishable (generatable)
    │       └── validators/                     // Library, publishable (generatable)
    ├── package.json
    ├── nx.json                                 // NX Workspace configuration
    └── tsconfig.base.json                      // Tsconfig, automatically update project alias

Using NX generators to generate necessary items and keep structure sync.

Generators

Schematics

NoNameDescription
1LibraryCreates an Angular library.
2Feature GroupGenerate an Angular Feature group.
3ComponentGenerate an Angular Component.
4DirectiveGenerate an Angular Directive.
5PipeGenerate an Angular Pipe.
6ServiceGenerate an Angular Service.
7ClassGenerate an Angular Class.
8InterfaceGenerate an Angular Interface.
9EnumGenerate an Angular Enum.
10GuardGenerate an Angular Guard.
11InterceptorGenerate an Angular Interceptor.
12ResolverGenerate an Angular Resolver.
13ValidatorGenerate an Angular Validator.

Usage

Using Nx CLI

  • Make sure NX CLI has been installed.
npm i -g nx
  • Using VTS Kit generators.
nx g @vts-kit/nx-angular:<generator_name> <generator_args>

Using Nx Console (GUI)

  • Install Nx Console in VSCode
  • Using generator:

    • Option 1: Select generate Nx Console Tab and select a generator

    • Option 2: Right click on a library and select nx generate in context menu

  • Fill in options

  • Preview changes
  • Press Run to make changes

Generator: Library

NoNameDescriptionTypeRequireDefault
1nameThe name of the library.string
2directoryA directory where the library is placed.stringfalse
3publishableGenerate a publishable library. Must specify importPath for other projects be able to import it.booleanfalse
4importPathThe library name used to import it, like @organize/lib-name. Must be a valid npm name.string
5buildableGenerate a buildable library.booleanfalse
6skipPackageJsonDo not add dependencies to package.json.booleanfalse
7skipTsConfigDo not update tsconfig.json for development experience.booleanfalse
8tagAdd tags to the library (used for linting)string
9unitTestRunnerTest runner to use for unit tests.karma jest nonejest
10strictCreate a library with stricter type checking and build optimization options.booleantrue
11linterThe tool to use for running lint checks.eslint noneeslint
12compilationModeSpecifies the compilation mode to use. If not specified, it will default to partial for publishable libraries and to full for buildable libraries. The full value can not be used for publishable libraries.full partialdepend
13featureGenerate additional NgModule and Routing config with library. Every component generated inside feature library will automatically create a route to it.booleanfalse
14appRoutingProject(Only work with feature library) The name of the app where feature will be imported for routing. Only projects of application are validstringdefaultProject

Generator: Feature Group

NoNameDescriptionTypeRequireDefault
1nameThe name of the feature group.string
2appRoutingProject(Only work with feature library) The name of the app where feature will be imported for routing. Only projects of application are validstringdefaultProject

Generator: Component

NoNameDescriptionTypeRequireDefault
1pathThe path at which to create the component file, relative to the selected project (\/src\/(lib|app)\/\<relative_path>) or relative to workspace (\<root_workspace>\/\<relative_path>).string
2projectThe name of the project.stringdefaultProject
3nameThe name of the component.string
4displayBlockSpecifies if the style will contain :host { display: block; }.booleanfalse
5inlineStyleInclude styles inline in the component.ts file. Only CSS styles can be included inline. By default, an external styles file is created and referenced in the component.ts file.booleanfalse
6inlineTemplateInclude template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file.booleanfalse
7viewEncapsulationThe view encapsulation strategy to use in the new component.Emulated None ShadowDom
8changeDetectionThe change detection strategy to use in the new component.Default OnPushDefault
9styleThe file extension or preprocessor to use for style files, or none to skip generating the style file.scss css lessscss
10skipTestsDo not create spec.ts test files for the new component.booleanfalse
11skipImportDo not import this component into the owning NgModule.booleanfalse
12skipSelectorSpecifies if the component should have a selector or not.booleanfalse
13selectorThe HTML selector to use for this component.string

Generator: Directive

NoNameDescriptionTypeRequireDefault
1pathThe path at which to create the directive file, relative to the selected project (\/src\/(lib|app)\/\<relative_path>) or relative to workspace (\<root_workspace>\/\<relative_path>).string
2projectThe name of the project.stringdefaultProject
3nameThe name of the directive.string
4prefixA prefix to apply to generated selectors.string
5skipTestsDo not create spec.ts test files for the new directive.booleanfalse
6selectorThe HTML selector to use for this directive.string

Generator: Pipe

NoNameDescriptionTypeRequireDefault
1pathThe path at which to create the pipe file, relative to the selected project (\/src\/(lib|app)\/\<relative_path>) or relative to workspace (\<root_workspace>\/\<relative_path>).string
2projectThe name of the project.stringdefaultProject
3nameThe name of the pipe.string
4skipTestsDo not create spec.ts test files for the new pipe.booleanfalse

Generator: Service

NoNameDescriptionTypeRequireDefault
1pathThe path at which to create the service file, relative to the selected project (\/src\/(lib|app)\/\<relative_path>) or relative to workspace (\<root_workspace>\/\<relative_path>).string
2projectThe name of the project.stringdefaultProject
3nameThe name of the service.string
4skipTestsDo not create spec.ts test files for the new service.booleanfalse

Generator: Class

NoNameDescriptionTypeRequireDefault
1pathThe path at which to create the service file, relative to the selected project (\/src\/(lib|app)\/\<relative_path>) or relative to workspace (\<root_workspace>\/\<relative_path>).string
2projectThe name of the project.stringdefaultProject
3nameThe name of the class.string
4skipTestsDo not create spec.ts test files for the new class.booleanfalse
5typeAdds a developer-defined type to the filename, in the format \"name..ts\".string

Generator: Interface

NoNameDescriptionTypeRequireDefault
1pathThe path at which to create the interface file, relative to the selected project (\/src\/(lib|app)\/\<relative_path>) or relative to workspace (\<root_workspace>\/\<relative_path>).string
2projectThe name of the project.stringdefaultProject
3nameThe name of the interface.string
4typeAdds a developer-defined type to the filename, in the format \"name..ts\".string
5prefixPrefix to be added before interface namestring

Generator: Enum

NoNameDescriptionTypeRequireDefault
1pathThe path at which to create the enum file, relative to the selected project (\/src\/(lib|app)\/\<relative_path>) or relative to workspace (\<root_workspace>\/\<relative_path>).string
2projectThe name of the project.stringdefaultProject
3nameThe name of the enum.string
4typeAdds a developer-defined type to the filename, in the format \"name..ts\".string

Generator: Guard

NoNameDescriptionTypeRequireDefault
1pathThe path at which to create the guard file, relative to the selected project (\/src\/(lib|app)\/\<relative_path>) or relative to workspace (\<root_workspace>\/\<relative_path>).string
2projectThe name of the project.stringdefaultProject
3nameThe name of the guard.string
4skipTestsDo not create spec.ts test files for the new guard.booleanfalse
5implementsSpecifies which route guards to implement (hold Ctrl to multiselect).Multiple choice "CanActivate", "CanActivateChild", "CanDeactivate", "CanLoad""CanActivate"

Generator: Interceptor

NoNameDescriptionTypeRequireDefault
1pathThe path at which to create the interceptor file, relative to the selected project (\/src\/(lib|app)\/\<relative_path>) or relative to workspace (\<root_workspace>\/\<relative_path>).string
2projectThe name of the project.stringdefaultProject
3nameThe name of the interceptor.string
4skipTestsDo not create spec.ts test files for the new interceptor.booleanfalse

Generator: Resolver

NoNameDescriptionTypeRequireDefault
1pathThe path at which to create the resolver file, relative to the selected project (\/src\/(lib|app)\/\<relative_path>) or relative to workspace (\<root_workspace>\/\<relative_path>).string
2projectThe name of the project.stringdefaultProject
3nameThe name of the resolver.string
4skipTestsDo not create spec.ts test files for the new resolver.booleanfalse

Generator: Validator

NoNameDescriptionTypeRequireDefault
1pathThe path at which to create the validator file, relative to the selected project (\/src\/(lib|app)\/\<relative_path>) or relative to workspace (\<root_workspace>\/\<relative_path>).string
2projectThe name of the project.stringdefaultProject
3nameThe name of the validator.string
4skipTestsDo not create spec.ts test files for the new validator.booleanfalse
5typeSpecifies type of validator."sync", "async"
6formSpecifies type of Angular form in which validator be used (Reactive form / Template-driven form)."reactive", "template"

Intergrated Features

References

Contribute Guidelines

If you have any ideas, just open an issue and tell us what you think.

If you'd like to contribute, please refer Contributors Guide

License

This code is under the MIT License.

See the LICENSE file for required notices and attributions.

1.0.0

1 year ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago