Skip to content

Latest commit

 

History

History
155 lines (120 loc) · 5.24 KB

README.md

File metadata and controls

155 lines (120 loc) · 5.24 KB

angular 1.5 generator

Latest NPM release TravisCI Build Status AppVeyor Build Status Test Coverage Dependency Status devDependency Status

A command line utility to quickly generate angular 1.5 component and route-component written in TypeScript.

Prerequisites

The generated project has dependencies that require Node 4.5.x and NPM 3.x.x.

Table of Contents

Installation

BEFORE YOU INSTALL: please read the prerequisites

npm install -g angular15-generator

Default structure

By default the tool assume that you use the following project structure:

root
└── src
    └── app
        ├── components
        ├── filters
        ├── routes
        └── services

If this is not your project structure, please have a look at the Configuration section.

Usage

ag --help
ag -v  / ag --version
ag g --help
ag g component --help
ag g route --help
ag g service --help
ag g filter --help

Generating Components

You can use the ag g command to generate Angular components:

ag g component my-new-component
ag g route my-new-route-component
ag g service my-new-route-service
ag g filter my-new-route-filter

If you want to create your component/route/service/filter in an other folder that the one configured you can use the following syntax (even on Windows system) :

ag g component down/my-new-component
    => will create the component in /src/app/components/down/my-new-component
ag g route ../up/my-new-route-component
    => will create the route in /src/app/up/my-new-route-component

Please note that this is also compatible with the --uc flag describe below.

Generating or Updating module's index file

You can use the --uc to update or create the module's index.ts file (with a name or not, the default one is in the config file).

ag g component my-new-component --uc
ag g route my-new-route-component --uc routes.ts

Alternatively you can set the option updateOrCreate to true in your config file to always update module's index.ts file.

If you use WebPack to build your project by setting the flag useWebpackRequire in the configuration file the tool will require the html template file instead of using the template URL.

Configuration

If our project's structure does not match yours, you can override it:

ag config

This will add a new file angular-generator.config.json in your root directory.

You can edit this file to specify your project's structure.

{
  "componentsRoot": "src/app/components",
  "routesRoot": "src/app/routes",
  "servicesRoot": "src/app/services",
  "filtersRoot": "src/app/filters",
  "componentsRootModuleName": "index.ts",
  "routesRootModuleName": "index.ts",
  "servicesRootModuleName": "index.ts",
  "filtersRootModuleName": "index.ts",
  "updateOrCreate": false,
  "useWebpackRequire": false
}

(This is the config.json file for our default project structure) N.B: even on Windows you should use the / separator, the CLI will handle it correctly.

Updating

Before updating it is recommended to backup your custom config file and regenerate it

To update angular15-generator to a new version, you must update both the global package and your project's local package.

Global package:

npm uninstall -g angular15-generator
npm cache clean
npm install -g angular15-generator@latest

=> then check for new configuration options in the config file.

Contributing

Currently the tool is available in French and English.

Feel free to send a PR with your locale file (see in /lib/cli/locales).

License

This project is licensed under the MIT License.