A command line utility to quickly generate angular 1.5 component and route-component written in TypeScript.
The generated project has dependencies that require Node 4.5.x and NPM 3.x.x.
- Installation
- Usage
- Generating Components and Routes Components
- Generating or Updating Components/Routes module's index file
- Configuration
- Updating
- Contributing
BEFORE YOU INSTALL: please read the prerequisites
npm install -g angular15-generator
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.
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
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.
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.
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.
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.
Currently the tool is available in French and English.
Feel free to send a PR with your locale file (see in /lib/cli/locales
).
This project is licensed under the MIT License.