anton/ng2-template

There is no license information available for the latest version (v1.0.0) of this package.

CLI generator for ankor webpack angular 2 start kit

Installs: 19

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Type:project

v1.0.0 2016-09-26 09:46 UTC

This package is not auto-updated.

Last update: 2024-11-09 20:17:49 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 prefix my- for component tag selector.
    Default value is app-
  • -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 prefix my- for component tag selector.
    Default value is app-
  • -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 prefix my for directive selector.
    Result will be mySuperHighlight
    Default value is app

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 - boolean
    • n - number
    • a - any
    • MyClass - custom type definition

    Every model has id:n field by default.
    If you don't want to use id 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 be

    • user.model.ts
      Declarations:
      public id: number;
      public name: string;
      public surname: string;
      public email: string;
      public age: number;
      public isAdmin: boolean;
      public currency: Currency;
      public createdAt: any;
      
      Initializations:
      this.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;
      
      Data in .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',