{"id":18512415,"url":"https://github.com/flauc/angular2-generator","last_synced_at":"2025-04-09T05:33:16.419Z","repository":{"id":57179575,"uuid":"53223298","full_name":"flauc/angular2-generator","owner":"flauc","description":"angular2-generator is a command line code generator for angular2 projects.","archived":false,"fork":false,"pushed_at":"2016-05-09T18:43:15.000Z","size":98,"stargazers_count":9,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T00:05:17.096Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flauc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-05T21:05:44.000Z","updated_at":"2017-12-01T17:16:30.000Z","dependencies_parsed_at":"2022-09-01T06:11:26.948Z","dependency_job_id":null,"html_url":"https://github.com/flauc/angular2-generator","commit_stats":null,"previous_names":["flauc/genli"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flauc%2Fangular2-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flauc%2Fangular2-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flauc%2Fangular2-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flauc%2Fangular2-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flauc","download_url":"https://codeload.github.com/flauc/angular2-generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987060,"owners_count":21028891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T15:34:06.467Z","updated_at":"2025-04-09T05:33:11.401Z","avatar_url":"https://github.com/flauc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Angular2 Generator\n\nAngular2 Generator is a command line code generator for Angular 2 applications. It supports initialising a starter application and creating components, directives, services and pipes through the command line.\n\n## Setup\n\nInstall globally for easiest use.\n\n```\nnpm install -g angular2-generator\n```\n\n## Init\n\nRun the following command to create an empty starter project for an angular2 application based on the [5 Min Quickstart.](https://angular.io/docs/ts/latest/quickstart.html) The created application uses SystemJs as the module loader.\n```\nng2 init\n```\nThe init command will also generate an ng2config.json file which contains all the necessary configuration for using Angular2 Generator.\n\nAt the end of the init you will be prompted to create a starting app. If you chose to create one make sure you have typings installed globaly because the script will try to run typings install after executing npm install.\n\nng2config.json values:\n\nKey | Value | Description\n------------ | ------------- | -------------\nappFolder | String | Route of the angular2 aplication folder with out the leading slash. For example \"foo/bar\" or \"app\" is ok but \"/app\" or \"app/\" might cause errors.\nbootLocation | String | Path to the file where the application is bootstraped (this is only needed if you want the option of auto injecting services). The path starts from the appFolder route. For example if bootLocation has the value \"boot.ts\" then angular2-generator will expect to find it at: appFolder/boot.ts\ncomponentsFolder | String | Location of the folder where all generated components get placed. This route also starts with the appFolder. So for example if componentsFolder has the value \"something/components\" angular2-generator will generate componets at this location: appFolder/something/components\nservicesFolder | String | Location of the folder where all the generated services get placed. Also starts with the appFolder.\ndirectivesFolder | String | Location of the folder where all the generated directives get placed. Starts with the appFolder.\npipesFolder | String | Location of the folder where all the generated pipes get placed. Starts with the appFolder.\n\n## Generating Files\n\nCommand | Functionality | Additional Options\n------------ | ------------- | -------------\nc or component [fileName] | Create a component | true\nd or directive [fileName] | Create a directive | false\ns or service [fileName] | Create a service | true\np or pipe [fileName] | Create a pipe | false\n\nExample command:\n\n```Shell\nng2 c test\n```\n\nWhen this command runs the file test.component.ts gets created at the location specified in the ng2config.json file or if no location was provided then it gets created in the appFolder of the application or in the root folder if the appFolder was also not provided.\n\nThe following is also a valid [fileName] format: \"something/foo/bar/test\". In this case the file test.component.ts would be created at this location appFolder/something/foo/bar/.\n\n### Component additional option\n\nOption: -t or -template\n\n```\nng2 c test -t\n```\nWould create the file test.component.ts and the file test.html at the same location\n\n### Service additional option\n\nOption: -i or -inject\n\nTo use this option you need to provide a bootLocation in the ng2config.json file and comments specifying inject locations.\n\nboot.ts\n```js\nimport {bootstrap}    from 'angular2/platform/browser';\nimport {AppComponent} from './app.component';\n// ng2:bootImport\n\nbootstrap(AppComponent, [\n    // ng2:bootInject\n\n]);\n```\n\nThe \"// ng2:bootImport\" comment sets the location of the import that should be injected.\nThe \"// ng2:bootInject\" comment sets the location of the service that should be injected.\n\nCommand example\n```Shell\nng2 s test -i\n```\n\n## Generated files content\n\n###Component\n\nWhen the following command is called:\n```Shell\nng2 c test\n```\n```ts\nimport {Component} from \"angular2/core\"\n\n@Component({\n    selector: \"test\",\n    template: \"\u003cp\u003eWe Work!\u003c/p\u003e\"\n})\nexport class TestComponent {\n    constructor() {}\n}\n```\n\n###Service\n\nWhen the following command is called:\n```Shell\nng2 s test\n```\n```ts\nimport {Injectable} from \"angular2/core\";\n\n@Injectable()\nexport class TestService {\n    constructor() {}\n}\n```\n\n###Directive\n\nWhen the following command is called:\n```Shell\nng2 d test\n```\n```ts\nimport {Directive, Input, ElementRef, TemplateRef, ViewContainerRef} from \"angular2/core\";\n\n/*\n * Description:\n *\n * Usage:\n *\n * Example:\n *\n */\n@Directive({ selector: \"[test]\" })\nexport class TestDirective {\n    constructor(\n        private _templateRef: TemplateRef,\n        private _viewContainer: ViewContainerRef,\n        private  _elementRef: ElementRef\n    ) {}\n\n}\n```\n\n###Pipe\n\nWhen the following command is called:\n```Shell\nng2 p test\n```\n```ts\nimport {Pipe, PipeTransform} from \"angular2/core\";\n\n/*\n * Description:\n *\n * Usage:\n *\n * Example:\n *\n */\n@Pipe({name: \"test\"})\nexport class TestPipe implements PipeTransform {\n    transform(value: any, args: string[]): any {\n\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflauc%2Fangular2-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflauc%2Fangular2-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflauc%2Fangular2-generator/lists"}