anton / ng2-template
CLI generator for ankor webpack angular 2 start kit
Requires
This package is not auto-updated.
Last update: 2024-12-21 21:08:47 UTC
README
Creation main project elements with unit tests
Installation
ln -s $(realpath ng-templator.php) ~/bin/ngt chmod +x ~/bin/ngt
Notice: ~/bin
should be added to $PATH.
Generating of blanks
Component
$ ngt component my-component
Makes structure:
.
└───my-component
├───index.ts
├───my-component.component.pug
├───my-component.component.less
├───my-component.component.ts
├───my-component.component.spec.ts
Parameters:
-tp\--tag-prefix my
- (Note! without dash) makes prefixmy-
for component tag selector.
Default value isapp-
-s\--style less
- generate styles in.less
format instead of.scss
Small Component
$ ngt small-component my-component
Makes component with inline styles and template
Makes structure:
.
├───my-component.component.ts
├───my-component.component.spec.ts
Parameters:
-tp\--tag-prefix my
- (Note! without dash) makes prefixmy-
for component tag selector.
Default value isapp-
-s\--style less
- generate styles in.less
format instead of.scss
Module
$ ngt module my-module
Makes structure:
.
└───my-module
├───index.ts
├───my-routes.module.ts
Parameters:
-
-wc\--with-component
- additionally makes main component for the module.
File structure:. └───my-module ├───index.ts ├───my-routes.module.ts ├───my-component.component.pug ├───my-component.component.less ├───my-component.component.ts ├───my-component.component.spec.ts
Component parameters
-tp
,-s
also available when you creates component with a module.
Directive
$ ngt directive super-highlight
Makes structure:
.
├───super-highlight.directive.ts
├───super-highlight.directive.spec.ts
Parameters:
-sp\--selector-prefix my
(value without dash) makes prefixmy
for directive selector.
Result will bemySuperHighlight
Default value isapp
Pipe
$ ngt pipe pretty
Makes structure:
.
├───pretty.pipe.ts
├───pretty.pipe.spec.ts
Service
$ ngt service auth
Makes structure:
.
├───auth.service.ts
├───auth.service.spec.ts
Api Service
$ ngt api user
Makes structure:
.
├───user-api.service.ts
├───user-api.service.spec.ts
Model
$ ngt model user
Makes structure:
.
├───user.model.ts
├───user.model.spec.ts
Parameters:
-
-f\--fields
makes fields for the model.
Available modifiers:s
- string (also default if not specified)b
- booleann
- numbera
- anyMyClass
- custom type definition
Every model has
id:n
field by default.
If you don't want to useid
just specify field-id
in fields. Example:-f '-id'
. Notice: Specify-id
as first column will not works.Example:
name;surname;email:s;age:n;isAdmin:b;currency:Currency;createdAt:a
Result will beuser.model.ts
Declarations:
Initializations:public id: number; public name: string; public surname: string; public email: string; public age: number; public isAdmin: boolean; public currency: Currency; public createdAt: any;
Data inthis.id = +data.id || null; this.name = data.name || null; this.surname = data.surname || null; this.email = data.email || null; this.age = +data.age || null; this.isAdmin = data.isAdmin !== undefined && data.isAdmin !== null ? Boolean(data.isAdmin) : null; this.currency = data.currency || null; this.createdAt = data.createdAt || null;
.spec.ts
:id: 1, name: 'Test string 1', surname: 'Test string 2', email: 'Test string 3', age: 2, isAdmin: true, currency: 'No generator. Using some string 1', createdAt: 'Any as string 1',