├── .editorconfig ├── .eslintrc ├── .gitattributes ├── .gitignore ├── .npmignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── app ├── alfresco-license-check.json ├── alfresco-license-header.ts ├── index.js └── templates │ ├── _.editorconfig │ ├── _.gitignore │ ├── _.npmignore │ ├── _README.md │ ├── _index.ts │ ├── _karma-test-shim.js │ ├── _karma.conf.js │ ├── _package.json │ ├── _sourceFile.ts │ ├── _testFile.spec.ts │ ├── _tsconfig.json │ ├── _webpack.build.js │ ├── _webpack.coverage.js │ ├── _webpack.test.js │ ├── config │ ├── _helpers.js │ ├── _webpack.build.js │ ├── _webpack.common.js │ ├── _webpack.coverage.js │ ├── _webpack.test.js │ ├── assets │ │ ├── _license_header.txt │ │ ├── _license_header_add.txt │ │ └── _tslint.json │ └── custom-loaders │ │ ├── _file-loader-multi.js │ │ └── _license-check.js │ ├── demo │ ├── _.editorconfig │ ├── _.gitignore │ ├── _README.md │ ├── _index.html │ ├── _main.ts │ ├── _package.json │ ├── _systemjs.config.js │ ├── _tsconfig.json │ └── _tslint.json │ └── i18n │ └── _en.json ├── assets ├── alfresco.png ├── generator.png └── yeoman.png ├── browserstack.err ├── gulpfile.js ├── package.json └── test ├── app-creation.js ├── app.js ├── conf └── local.conf.js └── specs └── my-app-generation.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.md] 11 | trim_trailing_whitespace = false 12 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint:recommended", 3 | "env": { 4 | "node": true, 5 | "mocha": true, 6 | "browser": true, 7 | "jasmine": true, 8 | "es6": true 9 | }, 10 | "globals": { 11 | "System": true, 12 | "__karma__": true 13 | }, 14 | "rules": { 15 | "no-console": 0, 16 | "array-bracket-spacing": [ 17 | 2, 18 | "never" 19 | ], 20 | "brace-style": [ 21 | 2, 22 | "1tbs" 23 | ], 24 | "consistent-return": 0, 25 | "indent": [ 26 | 2, 27 | 2 28 | ], 29 | "no-multiple-empty-lines": [ 30 | 2, 31 | { 32 | "max": 2 33 | } 34 | ], 35 | "no-use-before-define": [ 36 | 2, 37 | "nofunc" 38 | ], 39 | "quotes": [ 40 | 2, 41 | "single" 42 | ], 43 | "keyword-spacing": 2, 44 | "space-before-function-paren": [ 45 | 2, 46 | { 47 | "anonymous": "always", 48 | "named": "always" 49 | } 50 | ], 51 | "space-in-parens": [ 52 | 2, 53 | "never" 54 | ], 55 | "curly": [ 56 | 2, 57 | "all" 58 | ], 59 | "eol-last": 2, 60 | "key-spacing": [ 61 | 2, 62 | { 63 | "beforeColon": false, 64 | "afterColon": true 65 | } 66 | ], 67 | "no-eval": 2, 68 | "no-with": 2, 69 | "space-infix-ops": 2, 70 | "dot-notation": [ 71 | 2, 72 | { 73 | "allowKeywords": true 74 | } 75 | ], 76 | "eqeqeq": 2, 77 | "no-alert": 2, 78 | "no-caller": 2, 79 | "no-extend-native": 2, 80 | "no-extra-bind": 2, 81 | "no-implied-eval": 2, 82 | "no-iterator": 2, 83 | "no-label-var": 2, 84 | "no-labels": 2, 85 | "no-lone-blocks": 2, 86 | "no-loop-func": 2, 87 | "no-multi-spaces": 2, 88 | "no-multi-str": 2, 89 | "no-native-reassign": 2, 90 | "no-new": 2, 91 | "no-new-func": 2, 92 | "no-new-wrappers": 2, 93 | "no-octal-escape": 2, 94 | "no-proto": 2, 95 | "no-return-assign": 2, 96 | "no-script-url": 2, 97 | "no-sequences": 2, 98 | "no-unused-expressions": 2, 99 | "yoda": 2, 100 | "no-shadow": 2, 101 | "no-shadow-restricted-names": 2, 102 | "no-undef-init": 2, 103 | "camelcase": 2, 104 | "comma-spacing": 2, 105 | "new-cap": 0, 106 | "new-parens": 2, 107 | "no-array-constructor": 2, 108 | "no-extra-parens": 2, 109 | "no-new-object": 2, 110 | "no-spaced-func": 2, 111 | "no-trailing-spaces": 2, 112 | "no-underscore-dangle": [ 113 | 2, 114 | allow: ['__karma__'] 115 | ], 116 | "semi": 2, 117 | "semi-spacing": [ 118 | 2, 119 | { 120 | "before": false, 121 | "after": true 122 | } 123 | ] 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /npm-debug.log 2 | /.idea 3 | node_modules 4 | coverage 5 | temp/ 6 | /local.log 7 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .idea 2 | 3 | coverage/ 4 | node_modules 5 | temp/ 6 | test/ 7 | 8 | /.editorconfig 9 | /.travis.yml 10 | /gulpfile.js 11 | /.npmignore 12 | 13 | *.tgz 14 | 15 | /assets/ 16 | /local.log 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "7" 4 | addons: 5 | browserstack: 6 | username: "hussainashraf1" 7 | access_key: 8 | secure: "rsSKRFNukmPtPVsoYIu3tIzLhvP8erIAH4YAAh/PClhcMylsqveZf93HWeUooflchpqts4rapRXbaAIk3Su9fcqw1cbNLbw2On6YP0thxpl6bQroWQjt73C9Aa31Z4gNMRkFU7kWXKLN4mUuusJIHeMwciHO9wEzMEtPLktjIgii0enm/WeOs4qzu3oaqafgX4a1On0ZCXvX/lhL9zoNBxZajazrNBwiqY40bD82Fj7xHZG0KOkW+/BnWTnjIeS2GtUC4DoawvXHlJmJ4cPQB0rJcSWEpkg3hPzzwYYH2XhRbCo6HQY1sDXehPc7ajot/mgrXlxdDUL02rxt0/UMMvuQEcXbovzkHuKv/zfNW66wdY93bEujtlB1owHnzXM8y1jpuAKzi1UH0S6SzBuCp9Gq73NrcWTt0UNxJQoVLOhj2FwvVXsqNy5J3Apr7uOz0Cku7f6wDwLzKZogbjMWO56IEWdKWjK0+bcYHkqAvho3X5RZJircjG4dfLjs0TXO5cF8sFg3i8Y3y7m3FCxerXhSjvEKxUwgn9ipcvfbEK4Pji8ccUjljEY2L5cPyjaE297z7FSWhhbF2EXdbeSL+UD2P20Yjxmh0NfAQWprV51GI4feoOB6xyIg3VDBqXrf3QByF/KLjQPzIgpehLpJ61G+hRox0Rv3/3fP8F7rQp0=" 9 | forcelocal: true 10 | install: npm install 11 | sudo: false 12 | script: 13 | - npm run test 14 | - travis_wait 30 npm run test-generation-component 15 | - travis_wait 30 npm run test-install-component-dependencies 16 | - travis_wait 30 npm run test-install-demo-component-dependencies 17 | - travis_wait 30 npm run test-build-component 18 | - travis_wait 30 npm run test-cross-browsers 19 | after_success: 20 | - npm run coveralls 21 | - bash <(curl -s https://codecov.io/bash) 22 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 |

2 | alfresco 3 |

4 | 5 | Yeoman Generator Angular 2 Alfresco Component 6 | 7 | 8 | # [1.0.0](https://github.com/Alfresco/generator-ng2-alfresco-component/releases) (19-12-2016) 9 | ## fix 10 | - [App generation fails when no email provided #35](https://github.com/Alfresco/alfresco-js-api/pull/35) 11 | 12 | ## Features 13 | - [Update generator to last version ADF 1.0 support UMD Bundle #38](https://github.com/Alfresco/alfresco-js-api/issues/38) 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Yeoman Generator for Alfresco Angular 2 Component

2 |

3 | yeoman logo 4 |

5 |

6 | 7 | Build Status 8 | 9 | 10 | Coverage Status 11 | 12 | 13 | license 14 | 15 | 16 | downloads stats 17 | 18 | 19 | npm version 20 | 21 |

22 | 23 | ## Introduction 24 | 25 | See the following [page](https://github.com/Alfresco/app-dev-framework/blob/master/INTRODUCTION.md) for an introduction to the Alfresco Application Development Framework. 26 | 27 | ## Prerequisites 28 | 29 | Before you start using this development framework and the generator, make sure you have installed all required software and done all the 30 | necessary configuration, see this [page](https://github.com/Alfresco/app-dev-framework/blob/master/PREREQUISITES.md). 31 | 32 | ## Installing Yeoman and the Component Generator 33 | 34 | First, install [Yeoman](http://yeoman.io): 35 | 36 | ```sh 37 | npm install -g yo 38 | ``` 39 | 40 | Then the Alfresco Component Generator: 41 | 42 | ```sh 43 | npm install -g generator-ng2-alfresco-component 44 | ``` 45 | 46 | ## Generating a new component project 47 | 48 | First, move into the folder where you want create your component. 49 | 50 | ```sh 51 | yo ng2-alfresco-component 52 | ``` 53 | 54 | ![alfresco generator](assets/generator.png) 55 | 56 | Which will generate project structure similar to the following: 57 | 58 | ├── assets/ 59 | │ └── license_header.txt 60 | ├── demo/ 61 | │ ├── src/ 62 | │ │ └── main.ts 63 | │ ├── .editorconfig 64 | │ ├── .gitignore 65 | │ ├── index.html 66 | │ ├── package.json 67 | │ ├── README.md 68 | │ ├── systemjs.config.js 69 | │ ├── tsconfig.json 70 | │ ├── tslint.json 71 | │ └── typings.json 72 | ├── src/ 73 | │ ├── my-element.component.spec.ts 74 | │ └── my-element.component.ts 75 | ├── .editorconfig 76 | ├── .gitignore 77 | ├── gulpfile.ts 78 | ├── index.ts 79 | ├── karma-test-shim.js 80 | ├── karma.conf.js 81 | ├── LICENSE 82 | ├── package.json 83 | ├── README.md 84 | ├── tsconfig.json 85 | ├── tslint.json 86 | └── typings.json 87 | 88 | You will need to run the following scripts in the generated folder: 89 | 90 | ```sh 91 | npm install 92 | npm run build 93 | ``` 94 | 95 | Alternatively you can use generator with `install` switch to trigger automatic installation of dependencies via `npm install` script: 96 | 97 | ```sh 98 | yo ng2-alfresco-component --install 99 | ``` 100 | 101 | _Optinally you can use `npm run link` script to locally link ADF libraries if necessary._ 102 | 103 | ## npm scripts 104 | 105 | | Command | Description | 106 | | --- | --- | 107 | | npm run build | compiles component | 108 | | npm run build:w | compiles component, watches for changes and recompiles if needed | 109 | | npm run test | compiles, runs and watches the karma unit tests (console version) | 110 | | npm run test-browser | compiles, runs and watches the karma unit tests (browser version) | 111 | | num run coverage | runs unit tests, generates and opens code coverage report in browser | 112 | | npm run link | Link ADF components locally by means of `npm link` | 113 | | npm run build.umd |Build the UMD bundle package | 114 | 115 | ## Running demo 116 | 117 | If you have answered `Yes` for the generator question `Do you want a demo project to be generated?` you will get an additional demo project in the `demo` folder. 118 | 119 | You will need installing npm dependencies for the generated demo project separately: 120 | 121 | ```sh 122 | cd demonpm run test 123 | npm install 124 | npm run start 125 | ``` 126 | 127 | _Optinally you can use `npm run link` script to locally link ADF libraries if necessary._ 128 | 129 | ## Contributing to the generator 130 | 131 | 1. Fork it! 132 | 2. Create your feature branch: `git checkout -b my-new-feature` 133 | 3. Make some changes 134 | 4. Commit your changes: `git commit -m 'Add some feature'` 135 | 5. Push to the branch: `git push origin my-new-feature` 136 | 6. Submit a pull request 137 | 138 | >To contribute to the existing code base add test cases to cover the new behaviour, and make sure all the existing tests are still green. 139 | 140 | To test the generator run: 141 | 142 | ```sh 143 | npm run test 144 | ``` 145 | 146 | ### Debugging generator 147 | 148 | ```sh 149 | # OS X / Linux 150 | DEBUG=yeoman:generator yo ng2-alfresco-component 151 | 152 | # Windows 153 | set DEBUG=yeoman:generator & yo ng2-alfresco-component 154 | ``` 155 | 156 | More on [debugging generators](http://yeoman.io/authoring/debugging.html). 157 | 158 | ## Advanced options 159 | 160 | ```sh 161 | yo ng2-alfresco-component --alfresco 162 | ``` 163 | 164 | Typically used for internal purposes and adds the following extras to the generated project structure: 165 | 166 | - adds Alfresco license headers to all code files 167 | - configures component `package.json` with additional license checker configurations (devDependencies, scripts, etc.) 168 | 169 | ## History 170 | 171 | For detailed changelog, see [Releases](https://github.com/Alfresco/generator-ng2-alfresco-component/releases). 172 | 173 | ## Contributors 174 | 175 | | Contributor | GitHub profile | Twitter profile | 176 | | --- | --- | --- | 177 | | Eugenio Romano | [Eugenio Romano](https://github.com/eromano) | [@RomanoEugenio](https://twitter.com/RomanoEugenio) | 178 | | Denys Vuika | [Denys Vuika](https://github.com/denisvuyka) | [@denisvuyka](https://twitter.com/denisvuyka) | 179 | | Mario Romano | [Mario Romano](https://github.com/magemello) | [@MagemelloMario](https://twitter.com/MagemelloMario) | 180 | 181 | [See all contributors](https://github.com/alfresco/generator-ng2-alfresco-component/graphs/contributors) 182 | 183 | ## License 184 | [Apache Version 2.0](https://github.com/alfresco/generator-ng2-alfresco-component/blob/master/LICENSE) 185 | -------------------------------------------------------------------------------- /app/alfresco-license-check.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "license-check": "license-check" 4 | }, 5 | "devDependencies": { 6 | "license-check": "1.1.5" 7 | }, 8 | "license-check-config": { 9 | "src": [ 10 | "./dist/**/*.js" 11 | ], 12 | "path": "assets/license_header.txt", 13 | "blocking": true, 14 | "logInfo": false, 15 | "logError": true 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/alfresco-license-header.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * @license 3 | * Copyright 2016 Alfresco Software, Ltd. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | -------------------------------------------------------------------------------- /app/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var alflogo = require('alfresco-logo'); 3 | var yeoman = require('yeoman-generator'); 4 | var githubUsername = require('github-username'); 5 | var path = require('path'); 6 | var mkdirp = require('mkdirp'); 7 | var _ = require('lodash'); 8 | 9 | function validateEmail (email) { 10 | var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 11 | return re.test(email); 12 | } 13 | 14 | module.exports = yeoman.Base.extend({ 15 | 16 | initializing: function () { 17 | this.props = { 18 | licenseHeader: '', 19 | licenseChecker: false 20 | }; 21 | 22 | this.props.licenseHeader = this.fs.read(path.join(__dirname, './alfresco-license-header.ts')); 23 | if (this.options.alfresco) { 24 | this.props.licenseChecker = true; 25 | } 26 | }, 27 | 28 | prompting: function () { 29 | var done = this.async(); 30 | 31 | this.log(alflogo( 32 | 'Welcome to the awesome\nAngular 2 component\ngenerator for Alfresco!\n', 33 | {'left-pad': ' '})); 34 | 35 | var prompts = [{ 36 | name: 'projectName', 37 | message: 'What\'s the name of your component?', 38 | validate: function (str) { 39 | return str.length > 0; 40 | } 41 | }]; 42 | 43 | this.prompt(prompts, function (props) { 44 | this.props = _.extend(this.props, props); 45 | done(); 46 | }.bind(this)); 47 | }, 48 | 49 | default: function () { 50 | if (path.basename(this.destinationPath()) !== this.props.projectName) { 51 | this.log( 52 | 'Your generator must be inside a folder named ' + this.props.projectName + '\n' + 53 | 'I\'ll automatically create this folder.' 54 | ); 55 | mkdirp(this.props.projectName); 56 | this.destinationRoot(this.destinationPath(this.props.projectName)); 57 | } 58 | }, 59 | 60 | askFor: function () { 61 | var done = this.async(); 62 | 63 | var prompts = [ 64 | { 65 | name: 'description', 66 | message: 'How would you describe the element?' 67 | }, 68 | { 69 | name: 'authorName', 70 | message: 'Author\'s Name', 71 | default: this.user.git.name(), 72 | store: true 73 | }, 74 | { 75 | name: 'authorEmail', 76 | message: 'Author\'s Email', 77 | default: this.user.git.email(), 78 | store: true 79 | }, 80 | { 81 | name: 'authorUrl', 82 | message: 'Author\'s Homepage', 83 | store: true 84 | }, 85 | { 86 | name: 'keywords', 87 | message: 'Package keywords (comma to split)', 88 | filter: function (words) { 89 | if (words) { 90 | return words.split(/\s*,\s*/g); 91 | } else { 92 | return []; 93 | } 94 | } 95 | } 96 | ]; 97 | 98 | this.prompt(prompts, function (props) { 99 | this.props = _.extend(this.props, props); 100 | 101 | var projectAuthor = this.props.authorName; 102 | if (this.props.authorEmail) { 103 | projectAuthor += ' <' + this.props.authorEmail + '>'; 104 | } 105 | this.props.projectAuthor = projectAuthor; 106 | 107 | done(); 108 | }.bind(this)); 109 | }, 110 | 111 | askForGithubAccount: function () { 112 | var done = this.async(); 113 | 114 | if (validateEmail(this.props.authorEmail)) { 115 | githubUsername(this.props.authorEmail, function (err, username) { 116 | if (err) { 117 | username = username || ''; 118 | } 119 | 120 | var prompts = [{ 121 | name: 'githubAccount', 122 | message: 'GitHub username or organization', 123 | default: username 124 | }]; 125 | 126 | this.prompt(prompts, function (props) { 127 | this.props = _.extend(this.props, props); 128 | done(); 129 | }.bind(this)); 130 | }.bind(this)); 131 | } else { 132 | done(); 133 | } 134 | }, 135 | 136 | writing: function () { 137 | this.props.projectNameCamelCase = _.chain(this.props.projectName).camelCase().upperFirst(); 138 | 139 | this.fs.copyTpl( 140 | this.templatePath('_karma.conf.js'), 141 | this.destinationPath('karma.conf.js') 142 | ); 143 | 144 | this.fs.copyTpl( 145 | this.templatePath('_karma-test-shim.js'), 146 | this.destinationPath('karma-test-shim.js') 147 | ); 148 | 149 | ////config folder 150 | // 151 | this.fs.copy( 152 | this.templatePath('config/assets/_license_header.txt'), 153 | this.destinationPath('config/assets/license_header.txt') 154 | ); 155 | 156 | this.fs.copy( 157 | this.templatePath('config/assets/_license_header_add.txt'), 158 | this.destinationPath('config/assets/license_header_add.txt') 159 | ); 160 | 161 | this.fs.copy( 162 | this.templatePath('config/assets/_tslint.json'), 163 | this.destinationPath('config/assets/tslint.json') 164 | ); 165 | 166 | this.fs.copy( 167 | this.templatePath('config/custom-loaders/_file-loader-multi.js'), 168 | this.destinationPath('config/custom-loaders/file-loader-multi.js') 169 | ); 170 | 171 | this.fs.copy( 172 | this.templatePath('config/custom-loaders/_license-check.js'), 173 | this.destinationPath('config/custom-loaders/license-check.js') 174 | ); 175 | 176 | this.fs.copy( 177 | this.templatePath('config/_helpers.js'), 178 | this.destinationPath('config/helpers.js') 179 | ); 180 | 181 | this.fs.copy( 182 | this.templatePath('config/_webpack.common.js'), 183 | this.destinationPath('config/webpack.common.js') 184 | ); 185 | 186 | this.fs.copy( 187 | this.templatePath('config/_webpack.coverage.js'), 188 | this.destinationPath('config/webpack.coverage.js') 189 | ); 190 | 191 | this.fs.copy( 192 | this.templatePath('config/_webpack.build.js'), 193 | this.destinationPath('config/webpack.build.js') 194 | ); 195 | 196 | this.fs.copy( 197 | this.templatePath('config/_webpack.test.js'), 198 | this.destinationPath('config/webpack.test.js') 199 | ); 200 | 201 | this.fs.copy( 202 | this.templatePath('i18n/_en.json'), 203 | this.destinationPath('src/i18n/en.json') 204 | ); 205 | 206 | this.fs.copyTpl( 207 | this.templatePath('_webpack.build.js'), 208 | this.destinationPath('webpack.build.js'), 209 | this.props 210 | ); 211 | 212 | this.fs.copy( 213 | this.templatePath('_webpack.test.js'), 214 | this.destinationPath('webpack.test.js') 215 | ); 216 | 217 | this.fs.copy( 218 | this.templatePath('_webpack.coverage.js'), 219 | this.destinationPath('webpack.coverage.js') 220 | ); 221 | // 222 | //// 223 | 224 | this.fs.copy( 225 | this.templatePath('_tsconfig.json'), 226 | this.destinationPath('tsconfig.json') 227 | ); 228 | 229 | this.fs.copy( 230 | this.templatePath('_.gitignore'), 231 | this.destinationPath('.gitignore') 232 | ); 233 | 234 | this.fs.copy( 235 | this.templatePath('_.npmignore'), 236 | this.destinationPath('.npmignore') 237 | ); 238 | 239 | this.fs.copyTpl( 240 | this.templatePath('_.editorconfig'), 241 | this.destinationPath('.editorconfig') 242 | ); 243 | 244 | this.fs.copyTpl( 245 | this.templatePath('_index.ts'), 246 | this.destinationPath('index.ts'), 247 | this.props 248 | ); 249 | 250 | this.fs.copyTpl( 251 | this.templatePath('_sourceFile.ts'), 252 | this.destinationPath('src/' + this.props.projectName + '.component.ts'), 253 | this.props 254 | ); 255 | 256 | this.fs.copyTpl( 257 | this.templatePath('_testFile.spec.ts'), 258 | this.destinationPath('src/' + this.props.projectName + '.component.spec.ts'), 259 | this.props 260 | ); 261 | 262 | mkdirp('src/app'); 263 | 264 | this.fs.copyTpl( 265 | this.templatePath('_package.json'), 266 | this.destinationPath('package.json'), 267 | this.props 268 | ); 269 | 270 | var currentPkg = this.fs.readJSON(this.destinationPath('package.json'), {}); 271 | this.props.keywords.push('alfresco-component'); 272 | 273 | var pkg = _.merge( 274 | currentPkg, 275 | {keywords: this.props.keywords} 276 | ); 277 | 278 | if (this.props.licenseChecker) { 279 | pkg = _.merge( 280 | currentPkg, 281 | this.fs.readJSON(path.join(__dirname, './alfresco-license-check.json'), {}) 282 | ); 283 | } 284 | 285 | this.fs.writeJSON(this.destinationPath('package.json'), pkg); 286 | 287 | this.fs.copyTpl( 288 | this.templatePath('_README.md'), 289 | this.destinationPath('README.md'), 290 | this.props 291 | ); 292 | 293 | this.composeWith('license', { 294 | options: { 295 | name: this.props.authorName, 296 | email: this.props.authorEmail, 297 | website: this.props.authorUrl 298 | } 299 | }, { 300 | local: require.resolve('generator-license/app') 301 | }); 302 | }, 303 | 304 | writeDemo: function () { 305 | this.props.projectNameCamelCase = _.chain(this.props.projectName).camelCase().upperFirst(); 306 | 307 | this.fs.copyTpl( 308 | this.templatePath('demo/_index.html'), 309 | this.destinationPath('demo/index.html'), 310 | this.props 311 | ); 312 | 313 | this.fs.copyTpl( 314 | this.templatePath('demo/_main.ts'), 315 | this.destinationPath('demo/src/main.ts'), 316 | this.props 317 | ); 318 | 319 | this.fs.copy( 320 | this.templatePath('demo/_.editorconfig'), 321 | this.destinationPath('demo/.editorconfig') 322 | ); 323 | 324 | this.fs.copy( 325 | this.templatePath('demo/_.gitignore'), 326 | this.destinationPath('demo/.gitignore') 327 | ); 328 | 329 | this.fs.copy( 330 | this.templatePath('demo/_tsconfig.json'), 331 | this.destinationPath('demo/tsconfig.json') 332 | ); 333 | 334 | this.fs.copy( 335 | this.templatePath('demo/_tslint.json'), 336 | this.destinationPath('demo/tslint.json') 337 | ); 338 | 339 | this.fs.copyTpl( 340 | this.templatePath('demo/_package.json'), 341 | this.destinationPath('demo/package.json'), 342 | this.props 343 | ); 344 | 345 | this.fs.copyTpl( 346 | this.templatePath('demo/_README.md'), 347 | this.destinationPath('demo/README.md'), 348 | this.props 349 | ); 350 | 351 | this.fs.copyTpl( 352 | this.templatePath('demo/_systemjs.config.js'), 353 | this.destinationPath('demo/systemjs.config.js'), 354 | this.props 355 | ); 356 | }, 357 | 358 | install: function () { 359 | if (this.options.install) { 360 | this.npmInstall(); 361 | } 362 | } 363 | }); 364 | -------------------------------------------------------------------------------- /app/templates/_.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | indent_style = space 8 | indent_size = 4 9 | end_of_line = lf 10 | insert_final_newline = true 11 | trim_trailing_whitespace = true 12 | 13 | [package.json] 14 | indent_style = space 15 | indent_size = 2 16 | 17 | [karma.conf.js] 18 | indent_style = space 19 | indent_size = 2 20 | 21 | [*.md] 22 | insert_final_newline = false 23 | trim_trailing_whitespace = false 24 | -------------------------------------------------------------------------------- /app/templates/_.gitignore: -------------------------------------------------------------------------------- 1 | npm-debug.log 2 | node_modules 3 | .idea 4 | .npmrc 5 | typings 6 | coverage 7 | dist 8 | src/**/*.js 9 | src/**/*.js.map 10 | src/**/*.d.ts 11 | demo/**/*.js 12 | demo/**/*.js.map 13 | demo/**/*.d.ts 14 | index.js 15 | index.js.map 16 | !systemjs.config.js 17 | *.tgz 18 | /package/ 19 | /bundles/ 20 | index.d.ts 21 | -------------------------------------------------------------------------------- /app/templates/_.npmignore: -------------------------------------------------------------------------------- 1 | npm-debug.log 2 | .idea 3 | .npmrc 4 | 5 | coverage/ 6 | demo/ 7 | node_modules 8 | typings/ 9 | fonts/ 10 | 11 | /.editorconfig 12 | /.travis.yml 13 | /*.json 14 | /karma-test-shim.js 15 | /karma.conf.js 16 | /gulpfile.ts 17 | /.npmignore 18 | -------------------------------------------------------------------------------- /app/templates/_README.md: -------------------------------------------------------------------------------- 1 | # <%= projectName %> 2 | 3 | 4 | 5 | 6 | 7 | - [Prerequisites](#prerequisites) 8 | - [Install](#install) 9 | - [Basic usage](#basic-usage) 10 | - [alfresco-tag-node-actions-list](#alfresco-tag-node-actions-list) 11 | * [Properties](#properties) 12 | - [alfresco-tag-node-list](#alfresco-tag-node-list) 13 | * [Properties](#properties-1) 14 | - [alfresco-tag-list](#alfresco-tag-list) 15 | - [Build from sources](#build-from-sources) 16 | - [NPM scripts](#npm-scripts) 17 | - [Demo](#demo) 18 | - [License](#license) 19 | 20 | 21 | 22 | 23 | 24 | ## Prerequisites 25 | 26 | Before you start using this development framework, make sure you have installed all required software and done all the 27 | necessary configuration [prerequisites](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md). 28 | 29 | ## Install 30 | 31 | Follow the 3 steps below: 32 | 33 | 1. Npm 34 | 35 | ```sh 36 | npm install <%= projectName %> --save 37 | ``` 38 | 39 | 2. Html 40 | 41 | Include these dependencies in your index.html page: 42 | 43 | ```html 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | ``` 69 | 70 | 3. SystemJs 71 | 72 | Add the following components to your systemjs.config.js file: 73 | 74 | - ng2-translate 75 | - alfresco-js-api 76 | - ng2-alfresco-core 77 | - <%= projectName %> 78 | 79 | Please refer to the following example file: [systemjs.config.js](demo/systemjs 80 | .config.js) . 81 | 82 | <%= description %> 83 | 84 | ## Basic usage 85 | 86 | ```html 87 | <<%= projectName %>>> 88 | ``` 89 | 90 | Usage example of this component : 91 | 92 | **main.ts** 93 | ```ts 94 | 95 | ``` 96 | 97 | #### Events 98 | 99 | Method | Parameters | Returns | Description 100 | --- | --- | --- | --- 101 | `methodName()` | None. | void | Lorem ipsum dolor. 102 | 103 | #### Options 104 | 105 | Attribute | Options | Default | Description 106 | --- | --- | --- | --- 107 | `foo` | *string* | `bar` | Lorem ipsum dolor. 108 | 109 | 110 | ## Build from sources 111 | 112 | Alternatively you can build component from sources with the following commands: 113 | 114 | 115 | ```sh 116 | npm install 117 | npm run build 118 | ``` 119 | 120 | ### Build the files and keep watching for changes 121 | 122 | ```sh 123 | $ npm run build:w 124 | ``` 125 | 126 | ## Running unit tests 127 | 128 | ```sh 129 | npm test 130 | ``` 131 | 132 | ### Running unit tests in browser 133 | 134 | ```sh 135 | npm test-browser 136 | ``` 137 | 138 | This task rebuilds all the code, runs tslint, license checks and other quality check tools 139 | before performing unit testing. 140 | 141 | ### Code coverage 142 | 143 | ```sh 144 | npm run coverage 145 | ``` 146 | 147 | ## Demo 148 | 149 | If you want have a demo of how the component works, please check the demo folder : 150 | 151 | ```sh 152 | cd demo 153 | npm install 154 | npm start 155 | ``` 156 | 157 | ## NPM scripts 158 | 159 | | Command | Description | 160 | | --- | --- | 161 | | npm run build | Build component | 162 | | npm run build:w | Build component and keep watching the changes | 163 | | npm run test | Run unit tests in the console | 164 | | npm run test-browser | Run unit tests in the browser 165 | | npm run coverage | Run unit tests and display code coverage report | 166 | | npm run build.umd |Build the UMD bundle package | 167 | <% if (authorEmail) { %> 168 | 169 | ## History 170 | 171 | For detailed changelog, check [Releases](https://github.com/<%= githubAccount %>/<%= projectName %>/releases). 172 | 173 | ## Contributors 174 | 175 | [Contributors](https://github.com/<%= githubAccount %>/<%= projectName %>/graphs/contributors) 176 | <% } %> 177 | -------------------------------------------------------------------------------- /app/templates/_index.ts: -------------------------------------------------------------------------------- 1 | <%- licenseHeader %> 2 | import { NgModule } from '@angular/core'; 3 | import { CoreModule } from 'ng2-alfresco-core'; 4 | 5 | import { <%= projectNameCamelCase %>Component } from './src/<%= projectName %>.component'; 6 | 7 | export * from './src/<%= projectName %>.component'; 8 | 9 | @NgModule({ 10 | imports: [ 11 | CoreModule 12 | ], 13 | declarations: [ 14 | <%= projectNameCamelCase %>Component 15 | ], 16 | providers: [ 17 | ], 18 | exports: [ 19 | <%= projectNameCamelCase %>Component 20 | ] 21 | }) 22 | export class <%= projectNameCamelCase %>Module {} 23 | -------------------------------------------------------------------------------- /app/templates/_karma-test-shim.js: -------------------------------------------------------------------------------- 1 | Error.stackTraceLimit = Infinity; 2 | 3 | require('core-js/es6'); 4 | require('core-js/es7/reflect'); 5 | 6 | require('zone.js/dist/zone'); 7 | require('zone.js/dist/long-stack-trace-zone'); 8 | require('zone.js/dist/proxy'); 9 | require('zone.js/dist/sync-test'); 10 | require('zone.js/dist/jasmine-patch'); 11 | require('zone.js/dist/async-test'); 12 | require('zone.js/dist/fake-async-test'); 13 | 14 | jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; 15 | 16 | var appContext = require.context('./src', true, /\.spec\.ts/); 17 | appContext.keys().forEach(appContext); 18 | 19 | 20 | var testing = require('@angular/core/testing'); 21 | var browser = require('@angular/platform-browser-dynamic/testing'); 22 | 23 | testing.TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule, browser.platformBrowserDynamicTesting()); 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/templates/_karma.conf.js: -------------------------------------------------------------------------------- 1 | var webpackConfig = require('./webpack.test'); 2 | 3 | module.exports = function (config) { 4 | var _config = { 5 | basePath: '.', 6 | 7 | frameworks: ['jasmine-ajax', 'jasmine'], 8 | 9 | files: [ 10 | './node_modules/hammerjs/hammer.js', 11 | {pattern: './node_modules/@angular/material/prebuilt-themes/indigo-pink.css', included: true, watched: false}, 12 | 13 | //diagrams 14 | './node_modules/chart.js/dist/Chart.js', 15 | './node_modules/alfresco-js-api/dist/alfresco-js-api.js', 16 | './node_modules/raphael/raphael.js', 17 | './node_modules/moment/min/moment.min.js', 18 | './node_modules/md-date-time-picker/dist/js/mdDateTimePicker.js', 19 | 20 | {pattern: './node_modules/ng2-translate/**/*.js', included: false, watched: false}, 21 | {pattern: './node_modules/ng2-charts/**/*.js', included: false, served: true, watched: false}, 22 | {pattern: './node_modules/md-date-time-picker/**/*.js', included: false, served: true, watched: false}, 23 | {pattern: './node_modules/moment/**/*.js', included: false, served: true, watched: false}, 24 | 25 | {pattern: 'karma-test-shim.js', watched: false}, 26 | {pattern: './src/assets/**/*.*', included: false, served: true, watched: false}, 27 | {pattern: './src/i18n/**/*.*', included: false, served: true, watched: false}, 28 | {pattern: './src/**/*.ts', included: false, served: true, watched: false} 29 | ], 30 | 31 | webpack: (config.mode === 'coverage') ? require('./webpack.coverage') : require('./webpack.test'), 32 | 33 | webpackMiddleware: { 34 | stats: 'errors-only' 35 | }, 36 | 37 | port: 9876, 38 | 39 | // level of logging 40 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 41 | logLevel: config.LOG_INFO, 42 | 43 | colors: true, 44 | 45 | autoWatch: true, 46 | 47 | captureTimeout: 180000, 48 | browserDisconnectTimeout: 180000, 49 | browserDisconnectTolerance: 3, 50 | browserNoActivityTimeout: 300000, 51 | 52 | browsers: ['Chrome'], 53 | 54 | customLaunchers: { 55 | Chrome_travis_ci: { 56 | base: 'Chrome', 57 | flags: ['--no-sandbox'] 58 | } 59 | }, 60 | 61 | // Karma plugins loaded 62 | plugins: [ 63 | require('./node_modules/karma-jasmine'), 64 | require('./node_modules/karma-coverage'), 65 | require('./node_modules/karma-sourcemap-loader'), 66 | require('./node_modules/karma-jasmine-ajax'), 67 | require('./node_modules/karma-chrome-launcher'), 68 | require('./node_modules/karma-mocha-reporter'), 69 | require('./node_modules/karma-webpack'), 70 | require('./node_modules/karma-jasmine-html-reporter') 71 | ], 72 | 73 | webpackServer: { 74 | noInfo: true 75 | }, 76 | 77 | // Coverage reporter generates the coverage 78 | reporters: ['mocha', 'coverage', 'kjhtml'], 79 | 80 | preprocessors: { 81 | 'karma-test-shim.js': ['webpack', 'sourcemap'], 82 | './src/**/!(*spec|index|*mock|*model|*event).js': 'coverage' 83 | }, 84 | 85 | coverageReporter: { 86 | includeAllSources: true, 87 | dir: 'coverage', 88 | subdir: 'report', 89 | reporters: [ 90 | {type: 'text'}, 91 | {type: 'text-summary'}, 92 | {type: 'json', file: 'coverage-final.json'}, 93 | {type: 'html'}, 94 | {type: 'lcov'} 95 | ] 96 | } 97 | }; 98 | 99 | if (process.env.TRAVIS) { 100 | config.browsers = ['Chrome_travis_ci']; 101 | } 102 | 103 | config.set(_config); 104 | }; 105 | -------------------------------------------------------------------------------- /app/templates/_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= projectName %>", 3 | "description": "<%= description %>", 4 | "version": "0.1.0", 5 | "author": "<%- projectAuthor %>", 6 | "scripts": { 7 | "clean": "rimraf dist node_modules typings bundles coverage .npmrc", 8 | "rimraf": "rimraf", 9 | "build": "webpack --config webpack.build.js --progress --profile --bail", 10 | "test": "karma start karma.conf.js --reporters mocha,coverage --single-run --component", 11 | "test-browser": "karma start karma.conf.js --reporters kjhtml --component", 12 | "coverage": "npm run test && wsrv -o -p 9875 ./coverage/report", 13 | "prepublish": "npm run build" 14 | }, 15 | "main": "./index.js", 16 | "module": "./index.js", 17 | "typings": "./index.d.ts", 18 | <% if (authorEmail) { %> 19 | "repository": { 20 | "type": "git", 21 | "url": "https://github.com/<%= githubAccount %>/<%= projectName %>.git" 22 | }, 23 | "bugs": { 24 | "url": "https://github.com/<%= githubAccount %>/<%= projectName %>/issues" 25 | }, 26 | <% } %> 27 | "dependencies": { 28 | "@angular/animations": "4.3.6", 29 | "@angular/cdk": "2.0.0-beta.10", 30 | "@angular/common": "4.3.6", 31 | "@angular/compiler": "4.3.6", 32 | "@angular/core": "4.3.6", 33 | "@angular/forms": "4.3.6", 34 | "@angular/http": "4.3.6", 35 | "@angular/material": "2.0.0-beta.10", 36 | "@angular/platform-browser": "4.3.6", 37 | "@angular/platform-browser-dynamic": "4.3.6", 38 | "@angular/router": "4.3.6", 39 | "@ngx-translate/core": "7.0.0", 40 | "alfresco-js-api": "1.9.0", 41 | "core-js": "2.4.1", 42 | "hammerjs": "2.0.8", 43 | "moment": "2.15.1", 44 | "ng2-alfresco-core": "1.9.0", 45 | "reflect-metadata": "0.1.10", 46 | "rxjs": "5.1.0", 47 | "systemjs": "0.19.27", 48 | "zone.js": "0.8.12" 49 | }, 50 | "devDependencies": { 51 | "@types/hammerjs": "2.0.34", 52 | "@types/jasmine": "2.5.35", 53 | "@types/node": "6.0.45", 54 | "adf-tslint-rules": "0.0.3", 55 | "angular2-template-loader": "0.6.2", 56 | "autoprefixer": "6.5.4", 57 | "codelyzer": "3.1.2", 58 | "copy-webpack-plugin": "4.0.1", 59 | "css-loader": "0.25.0", 60 | "css-to-string-loader": "0.1.2", 61 | "cssnano": "3.8.1", 62 | "extract-text-webpack-plugin": "2.0.0-rc.3", 63 | "file-loader": "0.11.1", 64 | "fork-ts-checker-webpack-plugin": "0.2.3", 65 | "happypack": "3.0.0", 66 | "html-loader": "0.4.4", 67 | "html-webpack-plugin": "2.28.0", 68 | "istanbul-instrumenter-loader": "0.2.0", 69 | "jasmine-ajax": "3.2.0", 70 | "jasmine-core": "2.4.1", 71 | "karma": "0.13.22", 72 | "karma-chrome-launcher": "~1.0.1", 73 | "karma-coverage": "1.1.1", 74 | "karma-jasmine": "~1.0.2", 75 | "karma-jasmine-ajax": "0.1.13", 76 | "karma-jasmine-html-reporter": "0.2.0", 77 | "karma-mocha-reporter": "2.2.2", 78 | "karma-remap-istanbul": "0.6.0", 79 | "karma-sourcemap-loader": "0.3.7", 80 | "karma-systemjs": "0.16.0", 81 | "karma-webpack": "2.0.3", 82 | "loader-utils": "1.1.0", 83 | "merge-stream": "1.0.1", 84 | "node-sass": "4.5.3", 85 | "null-loader": "0.1.1", 86 | "package-json-merge": "0.0.1", 87 | "raw-loader": "0.5.1", 88 | "remap-istanbul": "0.6.3", 89 | "rimraf": "2.6.1", 90 | "run-sequence": "1.2.2", 91 | "sass-loader": "6.0.5", 92 | "script-loader": "0.7.0", 93 | "source-map-loader": "0.1.6", 94 | "style-loader": "0.13.1", 95 | "systemjs-builder": "0.15.34", 96 | "to-string-loader": "1.1.5", 97 | "traceur": "0.0.91", 98 | "ts-loader": "2.2.1", 99 | "ts-node": "1.7.0", 100 | "tslint": "5.5.0", 101 | "tslint-loader": "3.5.3", 102 | "typescript": "2.5.2", 103 | "webpack": "2.2.1", 104 | "webpack-dev-server": "2.3.0", 105 | "webpack-merge": "2.6.1", 106 | "wsrv": "0.1.7" 107 | }, 108 | "keywords": [ 109 | "alfresco-component" 110 | ], 111 | "license": "Apache-2.0" 112 | } 113 | -------------------------------------------------------------------------------- /app/templates/_sourceFile.ts: -------------------------------------------------------------------------------- 1 | <%- licenseHeader %> 2 | import { Component } from '@angular/core'; 3 | 4 | @Component({ 5 | selector: '<%= projectName %>', 6 | styles: [`:host h1 { font-size:22px }`], 7 | template: `

Hello World Angular 2 <%= projectName %>

` 8 | }) 9 | export class <%= projectNameCamelCase %>Component {} 10 | -------------------------------------------------------------------------------- /app/templates/_testFile.spec.ts: -------------------------------------------------------------------------------- 1 | <%- licenseHeader %> 2 | import { ComponentFixture, TestBed, async } from '@angular/core/testing'; 3 | import { DebugElement } from '@angular/core'; 4 | import { AlfrescoSettingsService, AlfrescoApiService, AlfrescoAuthenticationService, CoreModule } from 'ng2-alfresco-core'; 5 | 6 | import { <%= projectNameCamelCase %>Component } from '../src/<%= projectName %>.component'; 7 | 8 | describe('<%= projectName %>', () => { 9 | 10 | let component: <%= projectNameCamelCase %>Component; 11 | let fixture: ComponentFixture<<%= projectNameCamelCase %>Component>; 12 | let debug: DebugElement; 13 | let element: any; 14 | 15 | beforeEach(async(() => { 16 | TestBed.configureTestingModule({ 17 | imports: [ 18 | CoreModule 19 | ], 20 | declarations: [<%= projectNameCamelCase %>Component], 21 | providers: [ 22 | AlfrescoSettingsService, 23 | AlfrescoAuthenticationService, 24 | AlfrescoApiService 25 | /*, 26 | {provide: AlfrescoAuthenticationService, useClass: AuthenticationMock}, 27 | {provide: AlfrescoTranslationService, useClass: TranslationMock} 28 | */ 29 | ] 30 | }).compileComponents(); 31 | })); 32 | 33 | beforeEach(() => { 34 | fixture = TestBed.createComponent(<%= projectNameCamelCase %>Component); 35 | 36 | debug = fixture.debugElement; 37 | element = fixture.nativeElement; 38 | component = fixture.componentInstance; 39 | 40 | fixture.detectChanges(); 41 | }); 42 | 43 | it('should display hello world', () => { 44 | expect(element.querySelector('h1')).toBeDefined(); 45 | expect(element.getElementsByTagName('h1')[0].innerHTML).toEqual('Hello World Angular 2 test01'); 46 | }); 47 | 48 | }); 49 | -------------------------------------------------------------------------------- /app/templates/_tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": true, 7 | "emitDecoratorMetadata": true, 8 | "experimentalDecorators": true, 9 | "skipLibCheck": true, 10 | "noLib": false, 11 | "allowUnreachableCode": false, 12 | "allowUnusedLabels": false, 13 | "noImplicitAny": false, 14 | "noImplicitReturns": false, 15 | "noImplicitUseStrict": false, 16 | "noFallthroughCasesInSwitch": true, 17 | "removeComments": true, 18 | "declaration": true, 19 | "outDir": "./dist", 20 | "baseUrl" : "./", 21 | "paths": { 22 | "ng2-alfresco-core": ["../ng2-alfresco-core/"], 23 | "ng2-alfresco-datatable": ["../ng2-alfresco-datatable/"], 24 | "ng2-activiti-diagrams": ["../ng2-activiti-diagrams/"], 25 | "ng2-activiti-analytics":["../ng2-activiti-analytics/"], 26 | "ng2-activiti-form":["../ng2-activiti-form/"], 27 | "ng2-activiti-tasklist": ["../ng2-activiti-tasklist/"], 28 | "ng2-activiti-processlist": ["../ng2-activiti-processlist/"], 29 | "ng2-alfresco-documentlist": ["../ng2-alfresco-documentlist/"], 30 | "ng2-alfresco-login": ["../ng2-alfresco-login/"], 31 | "ng2-alfresco-search": ["../ng2-alfresco-search/"], 32 | "ng2-alfresco-social": ["../ng2-alfresco-social/"], 33 | "ng2-alfresco-tag": ["../ng2-alfresco-tag/"], 34 | "ng2-alfresco-upload": ["../ng2-alfresco-upload/"], 35 | "ng2-alfresco-viewer": ["../ng2-alfresco-viewer/"], 36 | "ng2-alfresco-webscript": ["../ng2-alfresco-webscript/"], 37 | "ng2-alfresco-userinfo": ["../ng2-alfresco-userinfo"], 38 | "alfresco-js-api": ["./node_modules/alfresco-js-api/"], 39 | "@angular/*": ["./node_modules/@angular/*"], 40 | "rxjs/*": ["./node_modules/rxjs/*"] 41 | }, 42 | "lib": [ 43 | "es2015", 44 | "dom" 45 | ], 46 | "suppressImplicitAnyIndexErrors": true 47 | }, 48 | "exclude": [ 49 | "demo", 50 | "node_modules", 51 | "dist" 52 | ], 53 | "angularCompilerOptions": { 54 | "strictMetadataEmit": false, 55 | "skipTemplateCodegen": true 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/templates/_webpack.build.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./config/webpack.build.js'); 2 | -------------------------------------------------------------------------------- /app/templates/_webpack.coverage.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./config/webpack.coverage.js'); 2 | -------------------------------------------------------------------------------- /app/templates/_webpack.test.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./config/webpack.test.js'); 2 | -------------------------------------------------------------------------------- /app/templates/config/_helpers.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | var _root = path.resolve(__dirname, '..'); 4 | 5 | function root(args) { 6 | args = Array.prototype.slice.call(arguments, 0); 7 | return path.join.apply(path, [_root].concat(args)); 8 | } 9 | 10 | exports.root = root; 11 | -------------------------------------------------------------------------------- /app/templates/config/_webpack.build.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const webpackMerge = require('webpack-merge'); 3 | const commonConfig = require('./webpack.common.js'); 4 | 5 | module.exports = webpackMerge(commonConfig, { 6 | 7 | devtool: 'cheap-module-source-map', 8 | 9 | externals: [ 10 | /^\@angular\//, 11 | /^rxjs\//, 12 | 'moment', 13 | 'raphael', 14 | 'ng2-charts', 15 | 'alfresco-js-api', 16 | 'ng2-alfresco-core', 17 | 'ng2-alfresco-datatable', 18 | 'ng2-activiti-analytics', 19 | 'ng2-activiti-diagrams', 20 | 'ng2-activiti-form', 21 | "ng2-activiti-tasklist", 22 | 'ng2-alfresco-documentlist' 23 | ], 24 | 25 | output: { 26 | filename: './bundles/[name].js', 27 | library: '[name]', 28 | libraryTarget: 'umd', 29 | chunkFilename: '[id].chunk.js' 30 | }, 31 | 32 | entry: { 33 | "ng2-alfresco-webscript": "./index.ts" 34 | } 35 | }); 36 | -------------------------------------------------------------------------------- /app/templates/config/_webpack.common.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const helpers = require('./helpers'); 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const CopyWebpackPlugin = require('copy-webpack-plugin'); 6 | var HappyPack = require('happypack'); 7 | const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); 8 | 9 | const ENV = process.env.NODE_ENV = process.env.ENV = 'production'; 10 | 11 | module.exports = { 12 | 13 | resolveLoader: { 14 | alias: { 15 | "file-multi-loader": path.resolve(__dirname, "./custom-loaders/file-loader-multi"), 16 | "license-check": path.resolve(__dirname, "./custom-loaders/license-check") 17 | } 18 | }, 19 | 20 | resolve: { 21 | alias: { 22 | "ng2-alfresco-core$": helpers.root('../ng2-alfresco-core/index.ts'), 23 | "ng2-alfresco-core": helpers.root('../ng2-alfresco-core') 24 | }, 25 | extensions: ['.ts', '.js'], 26 | symlinks: false, 27 | modules: [helpers.root('../../ng2-components'), helpers.root('node_modules')] 28 | }, 29 | 30 | module: { 31 | rules: [ 32 | { 33 | enforce: 'pre', 34 | test: /\.js$/, 35 | loader: 'source-map-loader', 36 | exclude: [/node_modules/, /bundles/, /dist/, /demo/] 37 | }, 38 | { 39 | enforce: 'pre', 40 | test: /\.ts$/, 41 | loader: 'tslint-loader', 42 | options: { 43 | emitErrors: true, 44 | failOnHint: true, 45 | fix: true 46 | }, 47 | exclude: [/node_modules/, /bundles/, /dist/, /demo/] 48 | }, 49 | { 50 | test: /\.ts$/, 51 | loader: ['happypack/loader?id=ts', 'angular2-template-loader'], 52 | exclude: [/node_modules/, /bundles/, /dist/, /demo/] 53 | }, 54 | { 55 | test: /\.html$/, 56 | loader: 'html-loader', 57 | exclude: [/node_modules/, /bundles/, /dist/, /demo/] 58 | }, 59 | { 60 | test: /\.css$/, 61 | loader: ['to-string-loader', 'css-loader'], 62 | exclude: [/node_modules/, /bundles/, /dist/, /demo/] 63 | }, 64 | { 65 | test: /\.scss$/, 66 | use: [{ 67 | loader: "to-string-loader" 68 | }, { 69 | loader: "raw-loader" 70 | }, { 71 | loader: "sass-loader" 72 | }], 73 | exclude: [/node_modules/, /bundles/, /dist/, /demo/] 74 | }, 75 | //{ 76 | // enforce: 'pre', 77 | // test: /\.ts$/, 78 | // loader: 'license-check', 79 | // options: { 80 | // emitErrors: true, 81 | // licenseFile: path.resolve(__dirname, './assets/license_header.txt') 82 | // }, 83 | // exclude: [/node_modules/, /bundles/, /dist/, /demo/, /rendering-queue.services.ts/], 84 | //}, 85 | { 86 | test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/, 87 | loader: 'file-multi-loader', 88 | query: { 89 | name: '[name].[hash].[ext]', 90 | outputPath: (url, resourcePath)=> { 91 | return resourcePath.replace('src', 'bundles') + url; 92 | }, 93 | publicPath: (url, resourcePath)=> { 94 | var component = resourcePath.substring(0, resourcePath.indexOf('src')); 95 | var path = resourcePath.replace(component, '').replace('src/', ''); 96 | return path + url; 97 | } 98 | } 99 | } 100 | ] 101 | }, 102 | 103 | plugins: [ 104 | new ForkTsCheckerWebpackPlugin(), 105 | new HappyPack({ 106 | id: 'ts', 107 | threads: 8, 108 | loaders: [ 109 | { 110 | path: 'ts-loader', 111 | query: { 112 | happyPackMode: true, 113 | "compilerOptions": { 114 | "paths": {} 115 | } 116 | } 117 | } 118 | ] 119 | }), 120 | 121 | new CopyWebpackPlugin([{ 122 | from: `src/i18n/`, 123 | to: `bundles/assets/${path.basename(helpers.root(''))}/i18n/` 124 | }]), 125 | 126 | new webpack.NoEmitOnErrorsPlugin(), 127 | 128 | new webpack.BannerPlugin(fs.readFileSync(path.resolve(__dirname, './assets/license_header_add.txt'), 'utf8')), 129 | 130 | new webpack.ContextReplacementPlugin( 131 | /angular(\\|\/)core(\\|\/)@angular/, 132 | helpers.root('./src'), 133 | {} 134 | ), 135 | new webpack.DefinePlugin({ 136 | 'process.env': { 137 | 'ENV': JSON.stringify(ENV) 138 | } 139 | }), 140 | new webpack.LoaderOptionsPlugin({ 141 | htmlLoader: { 142 | minimize: false // workaround for ng2 143 | } 144 | }) 145 | ], 146 | 147 | node: { 148 | fs: 'empty', 149 | module: false 150 | } 151 | }; 152 | -------------------------------------------------------------------------------- /app/templates/config/_webpack.coverage.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const webpackMerge = require('webpack-merge'); 3 | const testConfig = require('./webpack.test.js'); 4 | const helpers = require('./helpers'); 5 | 6 | module.exports = webpackMerge(testConfig, { 7 | 8 | module: { 9 | rules: [ 10 | { 11 | enforce: 'post', 12 | test: /^(?!(.*spec|index|.*mock|.*model|.*event)).*\.ts?$/, 13 | include: [helpers.root('src')], 14 | loader: 'istanbul-instrumenter-loader', 15 | exclude: [ 16 | /node_modules/, 17 | /test/ 18 | ] 19 | } 20 | ] 21 | } 22 | }); 23 | -------------------------------------------------------------------------------- /app/templates/config/_webpack.test.js: -------------------------------------------------------------------------------- 1 | const helpers = require('./helpers'); 2 | const webpackMerge = require('webpack-merge'); 3 | const commonConfig = require('./webpack.common.js'); 4 | 5 | module.exports = webpackMerge(commonConfig, { 6 | 7 | devtool: 'inline-source-map' 8 | }); 9 | -------------------------------------------------------------------------------- /app/templates/config/assets/_license_header.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | * @license 3 | * Copyright 2016 Alfresco Software, Ltd. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | -------------------------------------------------------------------------------- /app/templates/config/assets/_license_header_add.txt: -------------------------------------------------------------------------------- 1 | @license 2 | Copyright 2016 Alfresco Software, Ltd. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | -------------------------------------------------------------------------------- /app/templates/config/assets/_tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "align": [ 4 | true, 5 | "parameters", 6 | "statements" 7 | ], 8 | "ban": false, 9 | "class-name": true, 10 | "comment-format": [ 11 | true, 12 | "check-space" 13 | ], 14 | "curly": true, 15 | "eofline": true, 16 | "forin": true, 17 | "indent": [ 18 | true, 19 | "spaces" 20 | ], 21 | "interface-name": false, 22 | "jsdoc-format": true, 23 | "label-position": true, 24 | "max-line-length": [ 25 | true, 26 | 180 27 | ], 28 | "member-ordering": [ 29 | true, 30 | "static-before-instance", 31 | "variables-before-functions" 32 | ], 33 | "no-any": false, 34 | "no-arg": true, 35 | "no-bitwise": false, 36 | "no-conditional-assignment": true, 37 | "no-consecutive-blank-lines": true, 38 | "no-console": [ 39 | true, 40 | "debug", 41 | "info", 42 | "time", 43 | "timeEnd", 44 | "trace" 45 | ], 46 | "no-construct": true, 47 | "no-constructor-vars": false, 48 | "no-debugger": true, 49 | "no-duplicate-variable": true, 50 | "no-empty": false, 51 | "no-eval": true, 52 | "no-inferrable-types": false, 53 | "no-internal-module": true, 54 | "no-require-imports": false, 55 | "no-shadowed-variable": true, 56 | "no-switch-case-fall-through": true, 57 | "no-trailing-whitespace": true, 58 | "no-unused-expression": true, 59 | "no-unused-variable": true, 60 | "no-use-before-declare": true, 61 | "no-var-keyword": true, 62 | "no-var-requires": true, 63 | "object-literal-sort-keys": false, 64 | "one-line": [ 65 | true, 66 | "check-open-brace", 67 | "check-catch", 68 | "check-else", 69 | "check-whitespace" 70 | ], 71 | "quotemark": [ 72 | true, 73 | "single", 74 | "avoid-escape" 75 | ], 76 | "radix": true, 77 | "semicolon": true, 78 | "switch-default": true, 79 | "trailing-comma": [ 80 | true, 81 | { 82 | "multiline": "never", 83 | "singleline": "never" 84 | } 85 | ], 86 | "triple-equals": [ 87 | true, 88 | "allow-null-check" 89 | ], 90 | "typedef": false, 91 | "typedef-whitespace": [ 92 | true, 93 | { 94 | "call-signature": "nospace", 95 | "index-signature": "nospace", 96 | "parameter": "nospace", 97 | "property-declaration": "nospace", 98 | "variable-declaration": "nospace" 99 | } 100 | ], 101 | "use-strict": false, 102 | "variable-name": [ 103 | true, 104 | "check-format", 105 | "allow-leading-underscore", 106 | "ban-keywords" 107 | ], 108 | "whitespace": [ 109 | true, 110 | "check-branch", 111 | "check-operator", 112 | "check-separator", 113 | "check-type", 114 | "check-module", 115 | "check-decl" 116 | ] 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /app/templates/config/custom-loaders/_file-loader-multi.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | var loaderUtils = require('loader-utils'); 3 | 4 | module.exports = function(content) { 5 | this.cacheable && this.cacheable(); 6 | if(!this.emitFile) throw new Error('emitFile is required from module system'); 7 | 8 | var query = loaderUtils.getOptions(this) || {}; 9 | var configKey = query.config || 'multiFileLoader'; 10 | var options = this.options[configKey] || {}; 11 | var config = { 12 | publicPath: false, 13 | useRelativePath: false, 14 | name: '[hash].[ext]' 15 | }; 16 | 17 | // options takes precedence over config 18 | Object.keys(options).forEach(function(attr) { 19 | config[attr] = options[attr]; 20 | }); 21 | 22 | // query takes precedence over config and options 23 | Object.keys(query).forEach(function(attr) { 24 | config[attr] = query[attr]; 25 | }); 26 | 27 | var context = config.context || this.options.context; 28 | var url = loaderUtils.interpolateName(this, config.name, { 29 | context: context, 30 | content: content, 31 | regExp: config.regExp 32 | }); 33 | var path = loaderUtils.interpolateName(this, '[path]', { 34 | context: context, 35 | content: content, 36 | regExp: config.regExp 37 | }); 38 | 39 | var outputPath = ''; 40 | 41 | if (config.outputPath) { 42 | outputPath = ( 43 | typeof config.outputPath === 'function' 44 | ? config.outputPath(url, path) 45 | : config.outputPath + url 46 | ); 47 | } else { 48 | outputPath = url; 49 | } 50 | 51 | var publicPath = JSON.stringify(url); 52 | 53 | if (config.publicPath) { 54 | publicPath = JSON.stringify( 55 | typeof config.publicPath === 'function' 56 | ? config.publicPath(url, path) 57 | : config.publicPath + url 58 | ); 59 | } 60 | 61 | publicPath = '__webpack_public_path__ + ' + publicPath; 62 | 63 | if (query.emitFile === undefined || query.emitFile) { 64 | this.emitFile(outputPath, content); 65 | } 66 | 67 | return 'module.exports = ' + publicPath + ';'; 68 | }; 69 | 70 | module.exports.raw = true; 71 | -------------------------------------------------------------------------------- /app/templates/config/custom-loaders/_license-check.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | var loaderUtils = require('loader-utils'); 3 | var fs = require('fs'); 4 | 5 | var licenseFileUtf8Store = undefined; 6 | 7 | function readLicenseHeaderFile(licenseFilePath) { 8 | if (licenseFileUtf8Store) { 9 | return licenseFileUtf8Store; 10 | } 11 | 12 | if (fs.existsSync(licenseFilePath)) { 13 | licenseFileUtf8Store = fs.readFileSync(licenseFilePath, 'utf8').split(/\r?\n/); 14 | return licenseFileUtf8Store; 15 | } 16 | 17 | throw new Error('The license header file path is wrong ' + licenseFilePath); 18 | } 19 | 20 | function isFileEmpty(fileContents) { 21 | return fileContents.toString('utf8').trim() === ''; 22 | } 23 | 24 | function readCurrentFile(fileContent) { 25 | return fileContent.toString('utf8').split(/\r?\n/); 26 | } 27 | 28 | function isLicenseHeaderPresent(currentFileContent, licenseFilePath) { 29 | if (!isFileEmpty(currentFileContent)) { 30 | var currentFileUtf8 = readCurrentFile(currentFileContent), 31 | licenseFileUtf8 = readLicenseHeaderFile(licenseFilePath); 32 | skipStrict = 0; 33 | 34 | if(currentFileUtf8[0] === '"use strict";' ) { 35 | skipStrict = 1; 36 | } 37 | 38 | for (var i = skipStrict; i < licenseFileUtf8.length; i++) { 39 | if (currentFileUtf8[i + skipStrict] !== licenseFileUtf8[i]) { 40 | return false; 41 | } 42 | } 43 | } 44 | return true; 45 | } 46 | 47 | function report(hasHeader, emitter, filename) { 48 | if (hasHeader) return; 49 | emitter('Missing license header file : ' + filename); 50 | } 51 | 52 | function licenseCheck(webpackInstance, input, options) { 53 | var isLicensePresent = isLicenseHeaderPresent(input, options.licenseFile); 54 | 55 | var emitter = options.emitErrors ? webpackInstance.emitError : webpackInstance.emitWarning; 56 | 57 | report(isLicensePresent, emitter, webpackInstance.resourcePath); 58 | } 59 | 60 | module.exports = function(input, map) { 61 | this.cacheable && this.cacheable(); 62 | var callback = this.async(); 63 | 64 | var options = loaderUtils.getOptions(this); 65 | licenseCheck(this, input, options); 66 | callback(null, input, map); 67 | }; 68 | -------------------------------------------------------------------------------- /app/templates/demo/_.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | indent_style = space 8 | indent_size = 4 9 | end_of_line = lf 10 | insert_final_newline = true 11 | trim_trailing_whitespace = true 12 | 13 | [package.json] 14 | indent_style = space 15 | indent_size = 2 16 | 17 | [karma.conf.js] 18 | indent_style = space 19 | indent_size = 2 20 | 21 | [*.md] 22 | insert_final_newline = false 23 | trim_trailing_whitespace = false 24 | -------------------------------------------------------------------------------- /app/templates/demo/_.gitignore: -------------------------------------------------------------------------------- 1 | typings/ 2 | node_modules/ 3 | .idea 4 | dist/ 5 | !systemjs.config.js 6 | !browser-sync-config.js 7 | -------------------------------------------------------------------------------- /app/templates/demo/_README.md: -------------------------------------------------------------------------------- 1 | # <%= projectName %> - Demo 2 | 3 | * To install dependencies 4 | 5 | ```sh 6 | $ npm install 7 | ``` 8 | 9 | * To provide a live demo 10 | 11 | ```sh 12 | $ npm run start 13 | ``` 14 | 15 | * To clean npm_modules and typings folder 16 | 17 | ```sh 18 | $ npm run clean 19 | ``` 20 | 21 | ## How to test a change to a generic component in its own demo 22 | 23 | Let's suppose that for some reason you have changed a component and you want to test this changes. 24 | The example is based on the ng2-alfresco-login component, but you can use the same steps for any component. 25 | 26 | 27 | 1. Move inside the component folder and link it. 28 | ```sh 29 | 30 | cd ng2-alfresco-login 31 | npm link 32 | 33 | ``` 34 | 35 | 2. Build the component with the watcher enabled. 36 | ```sh 37 | 38 | npm run build:w 39 | 40 | ``` 41 | 42 | 3. Move inside the demo folder and link the component to the local node_modules folder. 43 | ```sh 44 | 45 | cd demo 46 | npm link ng2-alfresco-login 47 | 48 | ``` 49 | 50 | 4. Start the demo project. 51 | ```sh 52 | 53 | npm run start 54 | ``` 55 | -------------------------------------------------------------------------------- /app/templates/demo/_index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | <%= projectName %> Angular 2 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 41 | 42 | 43 | 44 | 45 |
46 |
47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /app/templates/demo/_main.ts: -------------------------------------------------------------------------------- 1 | <%- licenseHeader %> 2 | import { NgModule, Component } from '@angular/core'; 3 | import { BrowserModule } from '@angular/platform-browser'; 4 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 5 | import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService, StorageService, LogService } from 'ng2-alfresco-core'; 6 | 7 | import { <%= projectNameCamelCase %>Module } from '<%= projectName %>'; 8 | 9 | @Component({ 10 | selector: 'my-app', 11 | template: `<<%= projectName %>>>` 12 | }) 13 | class DemoApp { 14 | 15 | constructor(private authService: AlfrescoAuthenticationService, 16 | private settingsService: AlfrescoSettingsService, 17 | private storage: StorageService, 18 | private logService: LogService) { 19 | this.logService.info('constructor'); 20 | } 21 | } 22 | 23 | @NgModule({ 24 | imports: [ 25 | BrowserModule, 26 | CoreModule.forRoot(), 27 | <%= projectNameCamelCase %>Module 28 | ], 29 | declarations: [ DemoApp ], 30 | bootstrap: [ DemoApp ] 31 | }) 32 | export class AppModule { } 33 | 34 | platformBrowserDynamic().bootstrapModule(AppModule); 35 | -------------------------------------------------------------------------------- /app/templates/demo/_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= projectName %>-demo", 3 | "description": "<%= description %> - Demo", 4 | "version": "0.1.0", 5 | "author": "<%- projectAuthor %>", 6 | "main": "./dist/index.js", 7 | "typings": "./dist/index.d.ts", 8 | "scripts": { 9 | "clean": "npm install rimraf && npm run clean-build && rimraf dist node_modules typings dist", 10 | "clean-build" : "rimraf 'src/{,**/}**.js' 'src/{,**/}**.js.map' 'src/{,**/}**.d.ts'", 11 | "postinstall": "npm run build", 12 | "start": "npm run build && concurrently \"npm run tsc:w\" \"npm run server\" ", 13 | "server": "wsrv -o -s -l --port=3000", 14 | "build": "npm run tslint && npm run clean-build && npm run tsc", 15 | "build:w": "npm run tslint && rimraf dist && npm run tsc:w", 16 | "tsc": "tsc", 17 | "tsc:w": "tsc -w", 18 | "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json src/{,**/}**.ts -e '{,**/}**.d.ts'" 19 | }, 20 | "keywords": [ 21 | "ng2", 22 | "angular", 23 | "angular2", 24 | "alfresco", 25 | "demo" 26 | ], 27 | "dependencies": { 28 | "@angular/animations": "~4.0.0", 29 | "@angular/common": "~4.0.0", 30 | "@angular/compiler": "~4.0.0", 31 | "@angular/core": "~4.0.0", 32 | "@angular/forms": "~4.0.0", 33 | "@angular/http": "~4.0.0", 34 | "@angular/platform-browser": "~4.0.0", 35 | "@angular/platform-browser-dynamic": "~4.0.0", 36 | "@angular/router": "~4.0.0", 37 | 38 | "@angular/material": "2.0.0-beta.1", 39 | "alfresco-js-api": "~1.4.0", 40 | "core-js": "2.4.1", 41 | "hammerjs": "2.0.8", 42 | "ng2-alfresco-core": "1.5.0", 43 | "ng2-translate": "5.0.0", 44 | "reflect-metadata": "0.1.10", 45 | "rxjs": "5.1.0", 46 | "systemjs": "0.19.27", 47 | "zone.js": "0.7.6", 48 | 49 | "<%= projectName %>": "file:../" 50 | }, 51 | "devDependencies": { 52 | "@types/hammerjs": "^2.0.34", 53 | "@types/jasmine": "2.5.35", 54 | "@types/node": "6.0.45", 55 | "concurrently": "^2.2.0", 56 | "rimraf": "2.5.2", 57 | "tslint": "3.15.1", 58 | "typescript": "^2.0.3", 59 | "wsrv": "^0.1.5" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/templates/demo/_systemjs.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * System configuration for Angular 2 samples 3 | * Adjust as necessary for your application needs. 4 | */ 5 | (function (global) { 6 | System.config({ 7 | paths: { 8 | // paths serve as alias 9 | 'npm:': 'node_modules/' 10 | }, 11 | // map tells the System loader where to look for things 12 | map: { 13 | // our app is within the app folder 14 | app: 'src', 15 | // angular bundles 16 | '@angular/core': 'npm:@angular/core/bundles/core.umd.js', 17 | '@angular/common': 'npm:@angular/common/bundles/common.umd.js', 18 | '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', 19 | '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', 20 | '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', 21 | '@angular/http': 'npm:@angular/http/bundles/http.umd.js', 22 | '@angular/router': 'npm:@angular/router/bundles/router.umd.js', 23 | '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', 24 | '@angular/material': 'npm:@angular/material/bundles/material.umd.js', 25 | '@angular/animations': 'npm:@angular/animations/bundles/animations.umd.min.js', 26 | '@angular/animations/browser':'npm:@angular/animations/bundles/animations-browser.umd.js', 27 | '@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js', 28 | 29 | // other libraries 30 | 'rxjs': 'npm:rxjs', 31 | 'ng2-translate': 'npm:ng2-translate', 32 | 'alfresco-js-api': 'npm:alfresco-js-api/dist', 33 | 'ng2-alfresco-core': 'npm:ng2-alfresco-core', 34 | '<%= projectName %>': 'npm:<%= projectName %>' 35 | }, 36 | // packages tells the System loader how to load when no filename and/or no extension 37 | packages: { 38 | app: { 39 | main: './main.js', 40 | defaultExtension: 'js' 41 | }, 42 | rxjs: { 43 | defaultExtension: 'js' 44 | }, 45 | 'ng2-translate': { defaultExtension: 'js' }, 46 | 'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'}, 47 | 'ng2-alfresco-core': {main: './bundles/ng2-alfresco-core.js', defaultExtension: 'js'}, 48 | '<%= projectName %>': {main: './bundles/<%= projectName %>.js', defaultExtension: 'js'} 49 | } 50 | }); 51 | })(this); 52 | -------------------------------------------------------------------------------- /app/templates/demo/_tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": true, 7 | "emitDecoratorMetadata": true, 8 | "experimentalDecorators": true, 9 | "skipLibCheck": true, 10 | "noLib": false, 11 | "allowUnreachableCode": false, 12 | "allowUnusedLabels": false, 13 | "noImplicitAny": false, 14 | "noImplicitReturns": false, 15 | "noImplicitUseStrict": false, 16 | "noFallthroughCasesInSwitch": true, 17 | "removeComments": true, 18 | "declaration": true, 19 | "lib": [ 20 | "es2015", 21 | "dom" 22 | ], 23 | "suppressImplicitAnyIndexErrors": true 24 | }, 25 | "exclude": [ 26 | "node_modules" 27 | ], 28 | "angularCompilerOptions": { 29 | "strictMetadataEmit": false, 30 | "skipTemplateCodegen": true 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/templates/demo/_tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "align": [ 4 | true, 5 | "parameters", 6 | "arguments", 7 | "statements" 8 | ], 9 | "ban": false, 10 | "class-name": true, 11 | "comment-format": [ 12 | true, 13 | "check-space", 14 | "check-lowercase" 15 | ], 16 | "curly": true, 17 | "eofline": true, 18 | "forin": true, 19 | "indent": [ 20 | true, 21 | "spaces" 22 | ], 23 | "interface-name": false, 24 | "jsdoc-format": true, 25 | "label-position": true, 26 | "label-undefined": true, 27 | "max-line-length": [ 28 | true, 29 | 180 30 | ], 31 | "member-ordering": [ 32 | true, 33 | "public-before-private", 34 | "static-before-instance", 35 | "variables-before-functions" 36 | ], 37 | "no-any": false, 38 | "no-arg": true, 39 | "no-bitwise": true, 40 | "no-conditional-assignment": true, 41 | "no-consecutive-blank-lines": true, 42 | "no-console": [ 43 | true, 44 | "debug", 45 | "info", 46 | "time", 47 | "timeEnd", 48 | "trace" 49 | ], 50 | "no-construct": true, 51 | "no-constructor-vars": false, 52 | "no-debugger": true, 53 | "no-duplicate-key": true, 54 | "no-duplicate-variable": true, 55 | "no-empty": true, 56 | "no-eval": true, 57 | "no-inferrable-types": false, 58 | "no-internal-module": true, 59 | "no-require-imports": true, 60 | "no-shadowed-variable": true, 61 | "no-switch-case-fall-through": true, 62 | "no-trailing-whitespace": true, 63 | "no-unreachable": true, 64 | "no-unused-expression": true, 65 | "no-unused-variable": true, 66 | "no-use-before-declare": true, 67 | "no-var-keyword": true, 68 | "no-var-requires": true, 69 | "object-literal-sort-keys": false, 70 | "one-line": [ 71 | true, 72 | "check-open-brace", 73 | "check-catch", 74 | "check-else", 75 | "check-whitespace" 76 | ], 77 | "quotemark": [ 78 | true, 79 | "single", 80 | "avoid-escape" 81 | ], 82 | "radix": true, 83 | "semicolon": true, 84 | "switch-default": true, 85 | "trailing-comma": [ 86 | true, 87 | { 88 | "multiline": "never", 89 | "singleline": "never" 90 | } 91 | ], 92 | "triple-equals": [ 93 | true, 94 | "allow-null-check" 95 | ], 96 | "typedef": false, 97 | "typedef-whitespace": [ 98 | true, 99 | { 100 | "call-signature": "nospace", 101 | "index-signature": "nospace", 102 | "parameter": "nospace", 103 | "property-declaration": "nospace", 104 | "variable-declaration": "nospace" 105 | } 106 | ], 107 | "use-strict": false, 108 | "variable-name": [ 109 | true, 110 | "check-format", 111 | "allow-leading-underscore", 112 | "ban-keywords" 113 | ], 114 | "whitespace": [ 115 | true, 116 | "check-branch", 117 | "check-operator", 118 | "check-separator", 119 | "check-type", 120 | "check-module", 121 | "check-decl" 122 | ] 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /app/templates/i18n/_en.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /assets/alfresco.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alfresco/generator-ng2-alfresco-component/821d141ca7eec1206c7415e6d1f8be5f378add01/assets/alfresco.png -------------------------------------------------------------------------------- /assets/generator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alfresco/generator-ng2-alfresco-component/821d141ca7eec1206c7415e6d1f8be5f378add01/assets/generator.png -------------------------------------------------------------------------------- /assets/yeoman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alfresco/generator-ng2-alfresco-component/821d141ca7eec1206c7415e6d1f8be5f378add01/assets/yeoman.png -------------------------------------------------------------------------------- /browserstack.err: -------------------------------------------------------------------------------- 1 | [object Object] -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var gulp = require('gulp'); 3 | var eslint = require('gulp-eslint'); 4 | var excludeGitignore = require('gulp-exclude-gitignore'); 5 | var mocha = require('gulp-mocha'); 6 | var istanbul = require('gulp-istanbul'); 7 | var plumber = require('gulp-plumber'); 8 | 9 | gulp.task('static', function () { 10 | return gulp.src(['**/*.js', '!**/templates/**', '!**/temp/**', '!**/test/**']) 11 | .pipe(excludeGitignore()) 12 | .pipe(eslint()) 13 | .pipe(eslint.format()) 14 | .pipe(eslint.failAfterError()); 15 | }); 16 | 17 | gulp.task('pre-test', function () { 18 | return gulp.src(['app/index.js']).pipe(istanbul({includeUntested: true})).pipe(istanbul.hookRequire()); 19 | }); 20 | 21 | gulp.task('test', ['pre-test'], function (cb) { 22 | var mochaErr; 23 | 24 | gulp.src('test/app.js') 25 | .pipe(plumber()) 26 | .pipe(mocha({reporter: 'spec', timeout: 5000})) 27 | .on('error', function (err) { 28 | mochaErr = err; 29 | }) 30 | .pipe(istanbul.writeReports()) 31 | .on('end', function () { 32 | cb(mochaErr); 33 | }); 34 | }); 35 | 36 | gulp.task('generation-component-test', ['pre-test'], function (cb) { 37 | var mochaErr; 38 | 39 | gulp.src('test/app-creation.js') 40 | .pipe(plumber()) 41 | .pipe(mocha({reporter: 'spec', timeout: 1000000})) 42 | .on('error', function (err) { 43 | mochaErr = err; 44 | }) 45 | .on('end', function () { 46 | cb(mochaErr); 47 | }); 48 | }); 49 | 50 | gulp.task('default', ['static', 'test']); 51 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-ng2-alfresco-component", 3 | "version": "1.9.0", 4 | "description": "Yeoman generator generating angular 2 Alfresco component", 5 | "homepage": "https://github.com/Alfresco/generator-ng2-alfresco-component", 6 | "author": "Alfresco Software, Ltd.", 7 | "contributors": [ 8 | { 9 | "name": "Eugenio Romano", 10 | "email": "eugenio.romano@alfresco.com" 11 | }, 12 | { 13 | "name": "Denys Vuika", 14 | "email": "denys.vuika@gmail.com" 15 | }, 16 | { 17 | "name": "Mario Romano", 18 | "email": "mario.romano83@gmail.com" 19 | } 20 | ], 21 | "files": [ 22 | "app" 23 | ], 24 | "main": "app/index.js", 25 | "keywords": [ 26 | "ng2", 27 | "angular2", 28 | "component", 29 | "generator", 30 | "boilerplate", 31 | "scaffolding", 32 | "yeoman-generator", 33 | "custom-component" 34 | ], 35 | "dependencies": { 36 | "alfresco-logo": "1.0.1", 37 | "generator-license": "3.0.0", 38 | "github-username": "2.0.0", 39 | "lodash": "4.6.1", 40 | "mkdirp": "0.5.1", 41 | "yeoman-generator": "0.22.0" 42 | }, 43 | "devDependencies": { 44 | "browserstack-local": "1.3.0", 45 | "eslint": "2.1.0", 46 | "eslint-config-xo-space": "0.10.0", 47 | "gulp": "3.9.0", 48 | "gulp-eslint": "2.0.0", 49 | "gulp-exclude-gitignore": "1.0.0", 50 | "gulp-line-ending-corrector": "1.0.1", 51 | "gulp-istanbul": "0.10.3", 52 | "gulp-mocha": "2.0.0", 53 | "gulp-plumber": "1.0.0", 54 | "mocha": "2.2.3", 55 | "mockery": "1.4.0", 56 | "protractor": "5.1.1", 57 | "rimraf": "2.5.2", 58 | "yeoman-assert": "2.0.0", 59 | "yeoman-test": "1.0.0" 60 | }, 61 | "eslintConfig": { 62 | "extends": "xo-space", 63 | "env": { 64 | "mocha": true 65 | } 66 | }, 67 | "repository": { 68 | "type": "git", 69 | "url": "https://github.com/Alfresco/generator-ng2-alfresco-component.git" 70 | }, 71 | "scripts": { 72 | "clean": "rimraf node_modules typings", 73 | "test": "gulp ", 74 | "test-generation-component": "rimraf temp && gulp generation-component-test", 75 | "test-install-component-dependencies": "cd temp/component-test && npm install && cd -", 76 | "test-install-demo-component-dependencies": "cd temp/component-test/demo && npm install && cd -", 77 | "test-build-component": "cd temp/component-test && npm run build && cd -", 78 | "test-cross-browsers": "cd temp/component-test/demo && npm run start & npm run protractor-test", 79 | "coveralls": "gulp coveralls", 80 | "protractor-test": "./node_modules/.bin/protractor test/conf/local.conf.js" 81 | }, 82 | "license": "MIT" 83 | } 84 | -------------------------------------------------------------------------------- /test/app-creation.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var path = require('path'); 3 | var helpers = require('yeoman-test'); 4 | var mockery = require('mockery'); 5 | var tempDir; 6 | 7 | describe('Alfresco component Integration test generator', function () { 8 | before(function () { 9 | tempDir = path.join(__dirname, '../temp'); 10 | 11 | mockery.enable({ 12 | warnOnReplace: false, 13 | warnOnUnregistered: false 14 | }); 15 | }); 16 | 17 | after(function () { 18 | mockery.disable(); 19 | }); 20 | 21 | describe('Component ', function () { 22 | 23 | it('creation', function (done) { 24 | 25 | helpers.run(path.join(__dirname, '../app')) 26 | .inDir(tempDir + '/') 27 | .withPrompts({ 28 | projectName: 'component-test', 29 | description: 'A awesome angular 2 component', 30 | githubAccount: 'componentCreatorAccount', 31 | authorName: 'Alfresco Team', 32 | authorEmail: 'Sonikku.Hejjihoggu@alfresco.com', 33 | authorUrl: 'http://Hejjihoggu.io', 34 | keywords: ['generator-keyword', 'component-keyword', 'angular2-keyword'], 35 | license: 'MIT' 36 | }) 37 | .withOptions({alfresco: true}) 38 | .on('end', done); 39 | }); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /test/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var path = require('path'); 3 | var assert = require('yeoman-assert'); 4 | var helpers = require('yeoman-test'); 5 | var mockery = require('mockery'); 6 | var os = require('os'); 7 | 8 | describe('Alfresco component generator', function() { 9 | before(function() { 10 | mockery.enable({ 11 | warnOnReplace: false, 12 | warnOnUnregistered: false 13 | }); 14 | }); 15 | 16 | after(function() { 17 | mockery.disable(); 18 | }); 19 | 20 | it('can be imported without blowing up', function() { 21 | var app = require('../app'); 22 | assert(app !== undefined); 23 | }); 24 | 25 | describe('defaults', function() { 26 | before(function(done) { 27 | helpers.run(path.join(__dirname, '../app')) 28 | .inDir(path.join(os.tmpdir(), './temp')) 29 | .withPrompts({ 30 | projectName: 'component-fake', 31 | description: 'A awesome angular 2 component', 32 | githubAccount: 'componentCreatorAccount', 33 | authorName: 'Alfresco Team', 34 | authorEmail: 'Sonikku.Hejjihoggu@alfresco.com', 35 | authorUrl: 'http://Hejjihoggu.io', 36 | keywords: ['generator-keyword', 'component-keyword', 'angular2-keyword'], 37 | license: 'MIT' 38 | }) 39 | .withOptions({ alfresco: true }) 40 | .on('end', done); 41 | }); 42 | 43 | it('created and CD into a folder named like the component', function() { 44 | assert.equal(path.basename(process.cwd()), 'component-fake'); 45 | }); 46 | 47 | it('creates files', function() { 48 | var expected = [ 49 | '.gitignore', 50 | '.editorconfig', 51 | 'LICENSE', 52 | 'README.md', 53 | 'package.json', 54 | 'tsconfig.json', 55 | 'index.ts', 56 | 'karma.conf.js', 57 | 'karma-test-shim.js', 58 | 'config/assets/license_header.txt', 59 | 'config/assets/license_header_add.txt', 60 | 'config/assets/tslint.json', 61 | 'config/custom-loaders/file-loader-multi.js', 62 | 'config/custom-loaders/license-check.js', 63 | 'config/helpers.js', 64 | 'config/webpack.build.js', 65 | 'config/webpack.coverage.js', 66 | 'config/webpack.common.js', 67 | 'config/webpack.test.js', 68 | 'webpack.test.js', 69 | 'webpack.build.js', 70 | 'webpack.coverage.js', 71 | 'src/i18n/en.json', 72 | 'src/component-fake.component.ts', 73 | 'src/component-fake.component.spec.ts', 74 | 'demo/.gitignore', 75 | 'demo/.editorconfig', 76 | 'demo/tsconfig.json', 77 | 'demo/tslint.json', 78 | 'demo/package.json', 79 | 'demo/README.md', 80 | 'demo/index.html', 81 | 'demo/src/main.ts', 82 | 'demo/systemjs.config.js' 83 | ]; 84 | 85 | assert.file(expected); 86 | }); 87 | 88 | it('fills the README with project data', function() { 89 | assert.fileContent('README.md', 'component-fake'); 90 | assert.fileContent('README.md', 'A awesome angular 2 component'); 91 | assert.fileContent('README.md', 'https://github.com/componentCreatorAccount/component-fake/releases'); 92 | }); 93 | 94 | it('fills the package.json with project data', function() { 95 | assert.fileContent('package.json', '"name": "component-fake"'); 96 | assert.fileContent('package.json', '"author": "Alfresco Team "'); 97 | assert.fileContent('package.json', '"description": "A awesome angular 2 component"'); 98 | assert.fileContent('package.json', '"url": "https://github.com/componentCreatorAccount/component-fake/issues"'); 99 | assert.fileContent('package.json', '"alfresco-component"'); 100 | assert.fileContent('package.json', '"generator-keyword"'); 101 | }); 102 | 103 | it('fills the src file with project data', function() { 104 | assert.fileContent('src/component-fake.component.ts', 'class ComponentFake'); 105 | assert.fileContent('src/component-fake.component.ts', 'Hello World Angular 2 component-fake'); 106 | }); 107 | 108 | it('fills the test file with project data', function() { 109 | assert.fileContent('src/component-fake.component.spec.ts', 'should display hello world'); 110 | assert.fileContent('src/component-fake.component.spec.ts', 'ComponentFake'); 111 | }); 112 | 113 | it('fills the barrel file with project data', function() { 114 | assert.fileContent('index.ts', './src/component-fake.component'); 115 | }); 116 | 117 | it('fills the demo package.json with project data', function() { 118 | assert.fileContent('demo/package.json', '"name": "component-fake-demo"'); 119 | assert.fileContent('demo/package.json', '"description": "A awesome angular 2 component - Demo"'); 120 | assert.fileContent('demo/package.json', '"author": "Alfresco Team "'); 121 | assert.fileContent('demo/package.json', '"component-fake": "file:../"'); 122 | }); 123 | 124 | it('fills the demo README with project data', function() { 125 | assert.fileContent('demo/README.md', 'component-fake - Demo'); 126 | }); 127 | 128 | it('fills the demo file with project data', function() { 129 | assert.fileContent('demo/index.html', 'component-fake Angular 2'); 130 | }); 131 | 132 | it('fills the systemjs.config.js file with project data', function() { 133 | assert.fileContent('demo/systemjs.config.js', '\'component-fake\': \'npm:component-fake\''); 134 | }); 135 | 136 | it('fills the main file with project data', function() { 137 | assert.fileContent('demo/src/main.ts', 'component-fake'); 138 | }); 139 | 140 | }); 141 | }); 142 | -------------------------------------------------------------------------------- /test/conf/local.conf.js: -------------------------------------------------------------------------------- 1 | var browserstack = require('browserstack-local'); 2 | 3 | exports.config = { 4 | 'specs': ['../specs/my-app-generation.js'], 5 | 'seleniumAddress': 'http://hub-cloud.browserstack.com/wd/hub', 6 | 7 | 'commonCapabilities': { 8 | 'browserstack.user': process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME', 9 | 'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY', 10 | 'build': 'protractor-browserstack', 11 | 'name': 'generetor_component_test', 12 | 'browserstack.local': true, 13 | 'browserstack.debug': 'true' 14 | }, 15 | 16 | 'multiCapabilities': [ { 17 | 'browserName': 'Firefox' 18 | }], 19 | 20 | // Code to start browserstack local before start of test 21 | beforeLaunch: function () { 22 | console.log("Connecting local"); 23 | return new Promise(function (resolve, reject) { 24 | exports.bs_local = new browserstack.Local(); 25 | exports.bs_local.start({'key': exports.config.commonCapabilities['browserstack.key']}, function (error) { 26 | if (error) return reject(error); 27 | console.log('Connected. Now testing...'); 28 | 29 | resolve(); 30 | }); 31 | }); 32 | }, 33 | 34 | // Code to stop browserstack local after end of test 35 | afterLaunch: function () { 36 | return new Promise(function (resolve, reject) { 37 | exports.bs_local.stop(resolve); 38 | }); 39 | } 40 | }; 41 | 42 | // Code to support common capabilities 43 | exports.config.multiCapabilities.forEach(function (caps) { 44 | for (var i in exports.config.commonCapabilities) caps[i] = caps[i] || exports.config.commonCapabilities[i]; 45 | }); 46 | -------------------------------------------------------------------------------- /test/specs/my-app-generation.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | describe('Test component', function () { 4 | 5 | beforeEach(function () { 6 | browser.driver.manage().timeouts().implicitlyWait(1220000); 7 | browser.driver.get('http://localhost:3000'); 8 | }); 9 | 10 | afterAll(function () { 11 | browser.driver.close(); 12 | }); 13 | 14 | it('Hello world page should be loaded', function (done) { 15 | browser.driver.sleep(12); 16 | 17 | browser.driver.findElement(By.tagName('component-test')).then(()=> { 18 | done(); 19 | }); 20 | }); 21 | }); 22 | --------------------------------------------------------------------------------