Skip to content

softoika/schematics

Repository files navigation

@softoika/schematics

npm version Actions Status MIT License

A miscellaneous schematics collection for Angular.

  • Injectable class schematic (something like service and class schematics combined)
  • Interceptor schematic (deprecated)

The other schematics will be added.

Getting started

Install this package to execute the schematics

npm install -D @softoika/schematics

Injectable class schematic

This schematic is a service schematic that can be given any name instead of service. For example, the following command creates a service class whose name is repository.

$ ng g @softoika/schematics:injectable user --type repository
# or
$ ng g @softoika/schematics:ij user -t repository
CREATE src/app/user.repository.spec.ts (345 bytes)
CREATE src/app/user.repository.ts (137 bytes)

And the other options are available.

$ ng g @softoika/schematics:injectable --help
...
Help for schematic @softoika/schematics:injectable

arguments:
  name
    The prefix name of the injectable class.

options:
  --flat
    When true (the default), creates files at the top level of the project.
  --lint-fix
    When true, applies lint fixes after generating the injectable class.
  --project
    The name of the project
  --skip-tests
    When true, does not create "spec.ts" test file.
  --type (-t)
    The suffix name of the injectable class. (default: service)

Interceptor schematic (deprecated)

The interceptor schematic is officially supported by angular/cli now.

This schematic creates a new generic interceptor definition that implements HttpInterceptor.

$ ng g @softoika/schematics:interceptor auth
# or
$ ng g @softoika/schematics:ic auth
CREATE /auth.interceptor.ts (385 bytes)

The options same as the service schematic except for --skip-test are available.

$ ng g @softoika/schematics:interceptor --help
...
Help for schematic @softoika/schematics:interceptor
Creates a new generic interceptor definition in the given or default project.
arguments:
  name
    The name of the interceptor

options:
  --flat
    When true (the default), creates files at the top level of the project.
  --lint-fix
    When true, applies lint fixes after generating the interceptor.
  --project
    The name of the project