├── .eslintignore ├── image └── sample-application.png ├── .gitignore ├── .yo-rc.json ├── .editorconfig ├── .travis.yml ├── .gitattributes ├── .eslintrc.json ├── LICENSE ├── test ├── templates │ ├── maven-angularX │ │ └── .yo-rc.json │ └── gradle-angular1 │ │ └── .yo-rc.json └── test-app.js ├── package.json ├── generators └── app │ ├── templates │ └── jh-material.module.ts │ └── index.js └── README.md /.eslintignore: -------------------------------------------------------------------------------- 1 | coverage 2 | generators/**/templates 3 | node_modules 4 | travis 5 | -------------------------------------------------------------------------------- /image/sample-application.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/contribution-jhipster-uga/generator-jhipster-angular-material-integration/HEAD/image/sample-application.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | .idea 4 | *.iml 5 | *.ipr 6 | *.iws 7 | atlassian-ide-plugin.xml 8 | /.project 9 | test/temp/ 10 | *debug.log* 11 | .vscode 12 | -------------------------------------------------------------------------------- /.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-jhipster-module": { 3 | "promptValues": { 4 | "githubName": "contribution-jhipster-uga", 5 | "authorName": "Contribution Jhipster UGA", 6 | "authorEmail": "contribution.jhispter.uga@gmail.com", 7 | "authorUrl": "https://github.com/contribution-jhipster-uga" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 4 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [{package,bower}.json] 16 | indent_style = space 17 | indent_size = 2 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | os: 2 | - linux 3 | language: node_js 4 | node_js: 5 | - "8.9.1" 6 | before_install: 7 | - npm install -g npm 8 | # Repo for Yarn 9 | - curl -o- -L https://yarnpkg.com/install.sh | bash 10 | - export PATH=$HOME/.yarn/bin:$PATH 11 | install: 12 | - yarn install 13 | - yarn link 14 | script: 15 | - yarn test 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # All text files should have the "lf" (Unix) line endings 2 | * text eol=lf 3 | 4 | # Explicitly declare text files you want to always be normalized and converted 5 | # to native line endings on checkout. 6 | *.java text 7 | *.js text 8 | *.css text 9 | *.html text 10 | 11 | # Denote all files that are truly binary and should not be modified. 12 | *.png binary 13 | *.jpg binary 14 | *.jar binary 15 | *.pdf binary 16 | *.eot binary 17 | *.ttf binary 18 | *.gzip binary 19 | *.gz binary 20 | *.ai binary 21 | *.eps binary 22 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "node": true, 4 | "es6": true 5 | }, 6 | "extends": ["airbnb-base"], 7 | "rules": { 8 | "indent": [2, 4], 9 | "linebreak-style": 0, 10 | "eol-last": 2, 11 | "quotes": [2, "single"], 12 | "semi": [2, "always"], 13 | "eqeqeq": [2, "smart"], 14 | "no-use-before-define": [2, "nofunc"], 15 | "no-unused-vars": [2, {"vars": "local", "args": "none"}], 16 | "no-multi-str": 2, 17 | "no-irregular-whitespace": 2, 18 | "comma-dangle": "off", 19 | "max-len": "off", 20 | "func-names": "off", 21 | "class-methods-use-this": "off", 22 | "no-underscore-dangle": "off", 23 | "no-plusplus": "off", 24 | "no-unused-expressions": [2, { "allowShortCircuit": true, "allowTernary": true } ], 25 | "prefer-destructuring": "off", 26 | 27 | "no-multi-assign": "off", 28 | "no-param-reassign": "off", 29 | "no-shadow": "off" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Contribution Jhipster UGA 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /test/templates/maven-angularX/.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-jhipster": { 3 | "promptValues": { 4 | "packageName": "com.mycompany.myapp", 5 | "nativeLanguage": "en" 6 | }, 7 | "baseName": "sampleMysql", 8 | "packageName": "com.mycompany.myapp", 9 | "packageFolder": "com/mycompany/myapp", 10 | "serverPort": "8080", 11 | "authenticationType": "jwt", 12 | "cacheProvider": "ehcache", 13 | "enableHibernateCache": true, 14 | "clusteredHttpSession": false, 15 | "websocket": false, 16 | "databaseType": "sql", 17 | "devDatabaseType": "h2Disk", 18 | "prodDatabaseType": "mysql", 19 | "searchEngine": false, 20 | "messageBroker": false, 21 | "serviceDiscoveryType": false, 22 | "buildTool": "maven", 23 | "enableSocialSignIn": false, 24 | "jwtSecretKey": "0dd28f2f65d1860f1068b9fbefb3973c54f22f7a", 25 | "clientFramework": "angularX", 26 | "useSass": false, 27 | "clientPackageManager": "yarn", 28 | "applicationType": "monolith", 29 | "testFrameworks": [], 30 | "jhiPrefix": "jhi", 31 | "enableTranslation": true, 32 | "nativeLanguage": "en", 33 | "languages": [ 34 | "en" 35 | ] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test/templates/gradle-angular1/.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-jhipster": { 3 | "promptValues": { 4 | "packageName": "com.mycompany.myapp", 5 | "nativeLanguage": "en" 6 | }, 7 | "baseName": "sampleMysql", 8 | "packageName": "com.mycompany.myapp", 9 | "packageFolder": "com/mycompany/myapp", 10 | "serverPort": "8080", 11 | "authenticationType": "jwt", 12 | "cacheProvider": "ehcache", 13 | "enableHibernateCache": true, 14 | "clusteredHttpSession": false, 15 | "websocket": false, 16 | "databaseType": "sql", 17 | "devDatabaseType": "h2Disk", 18 | "prodDatabaseType": "mysql", 19 | "searchEngine": false, 20 | "messageBroker": false, 21 | "serviceDiscoveryType": false, 22 | "buildTool": "gradle", 23 | "enableSocialSignIn": false, 24 | "jwtSecretKey": "0dd28f2f65d1860f1068b9fbefb3973c54f22f7a", 25 | "clientFramework": "angular1", 26 | "useSass": false, 27 | "clientPackageManager": "yarn", 28 | "applicationType": "monolith", 29 | "testFrameworks": [], 30 | "jhiPrefix": "jhi", 31 | "enableTranslation": true, 32 | "nativeLanguage": "en", 33 | "languages": [ 34 | "en" 35 | ] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test/test-app.js: -------------------------------------------------------------------------------- 1 | /* global describe, beforeEach, it */ 2 | 3 | const path = require('path'); 4 | const fse = require('fs-extra'); 5 | const assert = require('yeoman-assert'); 6 | const helpers = require('yeoman-test'); 7 | 8 | describe('JHipster generator angular-material-integration', () => { 9 | describe('Test with Maven and AngularX', () => { 10 | beforeEach((done) => { 11 | helpers 12 | .run(path.join(__dirname, '../generators/app')) 13 | .inTmpDir((dir) => { 14 | fse.copySync(path.join(__dirname, '../test/templates/maven-angularX'), dir); 15 | }) 16 | .withOptions({ 17 | testmode: true 18 | }) 19 | .withPrompts({ 20 | message: 'simple message to say hello' 21 | }) 22 | .on('end', done); 23 | }); 24 | 25 | it('generate dummy.txt file', () => { 26 | assert.file([ 27 | 'dummy-maven.txt', 28 | 'dummy-angularX.txt', 29 | ]); 30 | }); 31 | }); 32 | 33 | describe('Test with Gradle and Angular1', () => { 34 | beforeEach((done) => { 35 | helpers 36 | .run(path.join(__dirname, '../generators/app')) 37 | .inTmpDir((dir) => { 38 | fse.copySync(path.join(__dirname, '../test/templates/gradle-angular1'), dir); 39 | }) 40 | .withOptions({ 41 | testmode: true 42 | }) 43 | .withPrompts({ 44 | message: 'simple message to say hello' 45 | }) 46 | .on('end', done); 47 | }); 48 | 49 | it('generate dummy.txt file', () => { 50 | assert.file([ 51 | 'dummy-gradle.txt', 52 | 'dummy-angular1.txt', 53 | ]); 54 | }); 55 | }); 56 | }); 57 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-jhipster-angular-material-integration", 3 | "version": "1.0.16", 4 | "description": "This generator allows you to set up and download the dependencies necessary to use Angular Material.", 5 | "keywords": [ 6 | "yeoman-generator", 7 | "jhipster-module", 8 | "jhipster-5", 9 | "angular", 10 | "material" 11 | ], 12 | "homepage": "https://github.com/contribution-jhipster-uga/generator-jhipster-angular-material-integration", 13 | "author": { 14 | "name": "Contribution Jhipster UGA, Julien Courtial, Hugo Gros-Daillon, Cédric Lafrasse, Bastien Terrier (https://github.com/contribution-jhipster-uga)", 15 | "email": "contribution.jhispter.uga@gmail.com", 16 | "url": "https://github.com/contribution-jhipster-uga" 17 | }, 18 | "files": [ 19 | "generators" 20 | ], 21 | "main": "generators/app/index.js", 22 | "repository": { 23 | "type": "git", 24 | "url": "git+https://github.com/contribution-jhipster-uga/generator-jhipster-angular-material-integration.git" 25 | }, 26 | "dependencies": { 27 | "chalk": "^2.4.1", 28 | "generator-jhipster": ">=5.0.0", 29 | "mkdirp": "0.5.1", 30 | "semver": "5.3.0", 31 | "shelljs": "0.5.3", 32 | "yeoman-generator": "3.1.1" 33 | }, 34 | "devDependencies": { 35 | "eslint": "5.1.0", 36 | "eslint-config-airbnb-base": "13.0.0", 37 | "eslint-plugin-import": "2.13.0", 38 | "fs-extra": "6.0.1", 39 | "mocha": "5.2.0", 40 | "yeoman-assert": "3.1.1", 41 | "yeoman-test": "2.0.0" 42 | }, 43 | "scripts": { 44 | "pretest": "eslint .", 45 | "lint": "eslint .", 46 | "lint-fix": "eslint . --fix", 47 | "release": "git push && git push --tags && npm publish", 48 | "release:patch": "npm version patch -a -m \"Update to %s\" && npm run release", 49 | "release:minor": "npm version minor -a -m \"Update to %s\" && npm run release", 50 | "release:major": "npm version major -a -m \"Update to %s\" && npm run release", 51 | "test": "mocha test" 52 | }, 53 | "license": "MIT", 54 | "bugs": { 55 | "url": "https://github.com/contribution-jhipster-uga/generator-jhipster-angular-material-integration/issues" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /generators/app/templates/jh-material.module.ts: -------------------------------------------------------------------------------- 1 | import {A11yModule} from '@angular/cdk/a11y'; 2 | import {DragDropModule} from '@angular/cdk/drag-drop'; 3 | import {ScrollingModule} from '@angular/cdk/scrolling'; 4 | import {CdkStepperModule} from '@angular/cdk/stepper'; 5 | import {CdkTableModule} from '@angular/cdk/table'; 6 | import {CdkTreeModule} from '@angular/cdk/tree'; 7 | import {NgModule} from '@angular/core'; 8 | import { MatAutocompleteModule } from '@angular/material/autocomplete'; 9 | import { MatBadgeModule } from '@angular/material/badge'; 10 | import { MatBottomSheetModule } from '@angular/material/bottom-sheet'; 11 | import { MatButtonModule } from '@angular/material/button'; 12 | import { MatButtonToggleModule } from '@angular/material/button-toggle'; 13 | import { MatCardModule } from '@angular/material/card'; 14 | import { MatCheckboxModule } from '@angular/material/checkbox'; 15 | import { MatChipsModule } from '@angular/material/chips'; 16 | import { MatDatepickerModule } from '@angular/material/datepicker'; 17 | import { MatDialogModule } from '@angular/material/dialog'; 18 | import { MatDividerModule } from '@angular/material/divider'; 19 | import { MatExpansionModule } from '@angular/material/expansion'; 20 | import { MatGridListModule } from '@angular/material/grid-list'; 21 | import { MatIconModule } from '@angular/material/icon'; 22 | import { MatInputModule } from '@angular/material/input'; 23 | import { MatListModule } from '@angular/material/list'; 24 | import { MatMenuModule } from '@angular/material/menu'; 25 | // import { MatNativeDateModule } from '@angular/material/core/datetime'; 26 | import { MatPaginatorModule } from '@angular/material/paginator'; 27 | import { MatProgressBarModule } from '@angular/material/progress-bar'; 28 | import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; 29 | import { MatRadioModule } from '@angular/material/radio'; 30 | import { MatRippleModule } from '@angular/material/core'; 31 | import { MatSelectModule } from '@angular/material/select'; 32 | import { MatSidenavModule } from '@angular/material/sidenav'; 33 | import { MatSliderModule } from '@angular/material/slider'; 34 | import { MatSlideToggleModule } from '@angular/material/slide-toggle'; 35 | import { MatSnackBarModule } from '@angular/material/snack-bar'; 36 | import { MatSortModule } from '@angular/material/sort'; 37 | import { MatStepperModule } from '@angular/material/stepper'; 38 | import { MatTableModule } from '@angular/material/table'; 39 | import { MatTabsModule } from '@angular/material/tabs'; 40 | import { MatToolbarModule } from '@angular/material/toolbar'; 41 | import { MatTooltipModule } from '@angular/material/tooltip'; 42 | import { MatTreeModule } from '@angular/material/tree'; 43 | 44 | @NgModule({ 45 | exports: [ 46 | A11yModule, 47 | CdkStepperModule, 48 | CdkTableModule, 49 | CdkTreeModule, 50 | DragDropModule, 51 | MatAutocompleteModule, 52 | MatBadgeModule, 53 | MatBottomSheetModule, 54 | MatButtonModule, 55 | MatButtonToggleModule, 56 | MatCardModule, 57 | MatCheckboxModule, 58 | MatChipsModule, 59 | MatStepperModule, 60 | MatDatepickerModule, 61 | MatDialogModule, 62 | MatDividerModule, 63 | MatExpansionModule, 64 | MatGridListModule, 65 | MatIconModule, 66 | MatInputModule, 67 | MatListModule, 68 | MatMenuModule, 69 | // MatNativeDateModule, 70 | MatPaginatorModule, 71 | MatProgressBarModule, 72 | MatProgressSpinnerModule, 73 | MatRadioModule, 74 | MatRippleModule, 75 | MatSelectModule, 76 | MatSidenavModule, 77 | MatSliderModule, 78 | MatSlideToggleModule, 79 | MatSnackBarModule, 80 | MatSortModule, 81 | MatTableModule, 82 | MatTabsModule, 83 | MatToolbarModule, 84 | MatTooltipModule, 85 | MatTreeModule, 86 | ScrollingModule, 87 | ] 88 | }) 89 | export class JhMaterialModule {} 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # generator-jhipster-angular-material-integration 2 | [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] 3 | > JHipster module, Module for installing the dependencies needed to use Angular Material in a Jhipster project. 4 | 5 | # Introduction 6 | 7 | This is a [JHipster](http://jhipster.github.io/) module, that is meant to be used in a JHipster application. 8 | 9 | This generator allows you to set up and download the dependencies necessary to use Angular Material. 10 | 11 | ![Sample application](image/sample-application.png) 12 | 13 | You can find a sample application using this generator [here](https://github.com/contribution-jhipster-uga/sample-application-angular-material). 14 | 15 | # Prerequisites 16 | 17 | As this is a [JHipster](http://jhipster.github.io/) module, we expect you have JHipster and its related tools already installed: 18 | 19 | - [Installing JHipster](https://jhipster.github.io/installation.html) 20 | 21 | # Installation 22 | 23 | ## With Yarn 24 | 25 | To install this module: 26 | 27 | ```bash 28 | yarn global add generator-jhipster-angular-material-integration 29 | ``` 30 | 31 | To update this module: 32 | 33 | ```bash 34 | yarn global upgrade generator-jhipster-angular-material-integration 35 | ``` 36 | 37 | ## With NPM 38 | 39 | To install this module: 40 | 41 | ```bash 42 | npm install -g generator-jhipster-angular-material-integration 43 | ``` 44 | 45 | To update this module: 46 | 47 | ```bash 48 | npm update -g generator-jhipster-angular-material-integration 49 | ``` 50 | 51 | # Usage 52 | 53 | First, you have to run the generator using the following command : 54 | 55 | ```bash 56 | yo jhipster-angular-material-integration 57 | ``` 58 | 59 | Please check that @angular/animations, @angular/cdk, @angular/flex-layout, @angular/material and hammerjs has been added to your package.json. If not, please add it yourself with version "latest" (example: "@angular/animations": "latest") and execute npm install. 60 | Now you have all the necessary elements to use Angular Material's tools : [Angular Material Website](https://v6.material.angular.io/). 61 | 62 | # How 63 | 64 | This generator will first add a jh-material.module.ts file, which imports all material component, in Shared folder. 65 | This module will then be imported in shared.module.ts : 66 | ```bash 67 | import {JhMaterialModule} from \'app/shared/jh-material.module\'; 68 | ``` 69 | BrowserAnimationsModule and hammerjs (which is not necesary but useful for some components) are imported in app.module.ts file : 70 | ```bash 71 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 72 | import 'hammerjs'; 73 | ``` 74 | Then, it imports a css-theme in your vendor.scss. 75 | 76 | Finally, it adds hammerjs, @angular/material, @angular/flex-layout, @angular/cdk and @angular/animations to your package.json and launch an install. 77 | 78 | # License 79 | 80 | MIT © [Contribution Jhipster UGA](https://github.com/contribution-jhipster-uga) 81 | Julien Courtial, Hugo Gros-Daillon, Cédric Lafrasse, Bastien Terrier 82 | 83 | This generator has been inspired by the tutorial of [Cyril Casaucau](https://medium.com/@cyril.casaucau/how-to-add-angular-material-on-an-jhipster-5-x-app-97c9569c9f97). 84 | 85 | [npm-image]: https://img.shields.io/npm/v/generator-jhipster-angular-material-integration.svg 86 | [npm-url]: https://npmjs.org/package/generator-jhipster-angular-material-integration 87 | [travis-image]: https://travis-ci.org/contribution-jhipster-uga/generator-jhipster-angular-material-integration.svg?branch=master 88 | [travis-url]: https://travis-ci.org/contribution-jhipster-uga/generator-jhipster-angular-material-integration 89 | [daviddm-image]: https://david-dm.org/contribution-jhipster-uga/generator-jhipster-angular-material-integration.svg?theme=shields.io 90 | [daviddm-url]: https://david-dm.org/contribution-jhipster-uga/generator-jhipster-angular-material-integration 91 | -------------------------------------------------------------------------------- /generators/app/index.js: -------------------------------------------------------------------------------- 1 | const chalk = require('chalk'); 2 | const packagejs = require('../../package.json'); 3 | const semver = require('semver'); 4 | const BaseGenerator = require('generator-jhipster/generators/generator-base'); 5 | const jhipsterConstants = require('generator-jhipster/generators/generator-constants'); 6 | const jhipsterUtils = require('generator-jhipster/generators/utils'); 7 | 8 | module.exports = class extends BaseGenerator { 9 | get initializing() { 10 | return { 11 | init(args) { 12 | if (args === 'default') { 13 | // do something when argument is 'default' 14 | } 15 | }, 16 | readConfig() { 17 | this.jhipsterAppConfig = this.getAllJhipsterConfig(); 18 | if (!this.jhipsterAppConfig) { 19 | this.error('Can\'t read .yo-rc.json'); 20 | } 21 | }, 22 | displayLogo() { 23 | // it's here to show that you can use functions from generator-jhipster 24 | // this function is in: generator-jhipster/generators/generator-base.js 25 | this.printJHipsterLogo(); 26 | 27 | // Have Yeoman greet the user. 28 | this.log(`\nWelcome to the ${chalk.bold.yellow('JHipster angular-material-integration')} generator! ${chalk.yellow(`v${packagejs.version}\n`)}`); 29 | }, 30 | checkJhipster() { 31 | const currentJhipsterVersion = this.jhipsterAppConfig.jhipsterVersion; 32 | const minimumJhipsterVersion = packagejs.dependencies['generator-jhipster']; 33 | if (!semver.satisfies(currentJhipsterVersion, minimumJhipsterVersion)) { 34 | this.warning(`\nYour generated project used an old JHipster version (${currentJhipsterVersion})... you need at least (${minimumJhipsterVersion})\n`); 35 | } 36 | } 37 | }; 38 | } 39 | 40 | writing() { 41 | // function to use directly template 42 | this.template = function(source, destination) { 43 | this.fs.copyTpl( 44 | this.templatePath(source), 45 | this.destinationPath(destination), 46 | this 47 | ); 48 | }; 49 | 50 | // read config from .yo-rc.json 51 | this.baseName = this.jhipsterAppConfig.baseName; 52 | this.packageName = this.jhipsterAppConfig.packageName; 53 | this.packageFolder = this.jhipsterAppConfig.packageFolder; 54 | this.clientFramework = this.jhipsterAppConfig.clientFramework; 55 | this.clientPackageManager = this.jhipsterAppConfig.clientPackageManager; 56 | this.buildTool = this.jhipsterAppConfig.buildTool; 57 | 58 | // use function in generator-base.js from generator-jhipster 59 | this.angularAppName = this.getAngularAppName(); 60 | 61 | // use constants from generator-constants.js 62 | const javaDir = `${jhipsterConstants.SERVER_MAIN_SRC_DIR + this.packageFolder}/`; 63 | const resourceDir = jhipsterConstants.SERVER_MAIN_RES_DIR; 64 | const webappDir = jhipsterConstants.CLIENT_MAIN_SRC_DIR; 65 | 66 | 67 | // // show all variables 68 | // this.log('\n--- some config read from config ---'); 69 | // this.log(`baseName=${this.baseName}`); 70 | // this.log(`packageName=${this.packageName}`); 71 | // this.log(`clientFramework=${this.clientFramework}`); 72 | // this.log(`clientPackageManager=${this.clientPackageManager}`); 73 | // this.log(`buildTool=${this.buildTool}`); 74 | // 75 | // this.log('\n--- some function ---'); 76 | // this.log(`angularAppName=${this.angularAppName}`); 77 | // 78 | // this.log('\n--- some const ---'); 79 | // this.log(`javaDir=${javaDir}`); 80 | // this.log(`resourceDir=${resourceDir}`); 81 | // this.log(`webappDir=${webappDir}`); 82 | if (this.clientFramework === 'angularX' || this.clientFramework === 'angular2') { 83 | this.template('jh-material.module.ts', `${webappDir}app/shared/jh-material.module.ts`); 84 | jhipsterUtils.rewriteFile({ 85 | file: `${webappDir}app/app.module.ts`, 86 | needle: 'jhipster-needle-angular-add-module-import', 87 | splicable: [`import { BrowserAnimationsModule } from '@angular/platform-browser/animations';`] 88 | }, this); 89 | jhipsterUtils.rewriteFile({ 90 | file: `${webappDir}app/app.module.ts`, 91 | needle: 'jhipster-needle-angular-add-module-import', 92 | splicable: [`import {FlexLayoutModule} from '@angular/flex-layout';`] 93 | }, this); 94 | jhipsterUtils.rewriteFile({ 95 | file: `${webappDir}app/app.module.ts`, 96 | needle: 'jhipster-needle-angular-add-module-import', 97 | splicable: [`import 'hammerjs';`] 98 | }, this); 99 | jhipsterUtils.rewriteFile({ 100 | file: `${webappDir}content/scss/vendor.scss`, 101 | needle: 'jhipster-needle-scss-add-vendor', 102 | splicable: [`@import "~@angular/material/prebuilt-themes/indigo-pink.css";`] 103 | }, this); 104 | jhipsterUtils.rewriteFile({ 105 | file: `${webappDir}app/shared/shared.module.ts`, 106 | needle: '@NgModule({', 107 | splicable: [`import {JhMaterialModule} from 'app/shared/jh-material.module';`] 108 | }, this); 109 | jhipsterUtils.rewriteFile({ 110 | file: `${webappDir}index.html`, 111 | needle: 'jhipster-needle-add-resources-to-root', 112 | splicable: [``] 113 | }, this); 114 | jhipsterUtils.rewriteFile({ 115 | file: `${webappDir}app/shared/shared-libs.module.ts`, 116 | needle: '@NgModule({', 117 | splicable: [`import { ReactiveFormsModule } from '@angular/forms';`] 118 | }, this); 119 | 120 | var sharedModule = this.fs.read(`${webappDir}app/shared/shared.module.ts`); 121 | var res = sharedModule.replace('imports: [', 'imports: [JhMaterialModule, '); 122 | var toWrite = res.replace('exports: [', 'exports: [JhMaterialModule, '); 123 | this.fs.write(`${webappDir}app/shared/shared.module.ts`, toWrite); 124 | 125 | var sharedLibsModule = this.fs.read(`${webappDir}app/shared/shared-libs.module.ts`); 126 | var res = sharedLibsModule.replace(' ],exports: [', ',ReactiveFormsModule],exports: ['); 127 | var toWrite = res.replace('exports: [', 'exports: [ReactiveFormsModule, '); 128 | this.fs.write(`${webappDir}app/shared/shared-libs.module.ts`, toWrite); 129 | 130 | var appModule = this.fs.read(`${webappDir}app/app.module.ts`); 131 | var res = appModule.replace('BrowserModule,', `BrowserModule, 132 | BrowserAnimationsModule, 133 | FlexLayoutModule,`); 134 | this.fs.write(`${webappDir}app/app.module.ts`, res); 135 | 136 | this.addNpmDependency('@angular/animations', 'latest'); 137 | this.addNpmDependency('hammerjs', 'latest'); 138 | this.addNpmDependency('@angular/material', 'latest'); 139 | this.addNpmDependency('@angular/cdk', 'latest'); 140 | this.addNpmDependency('@angular/flex-layout', 'latest'); 141 | 142 | } 143 | else{ 144 | this.log("Error : You cannot install Angular Material to this project because you are not using Angular."); 145 | } 146 | } 147 | 148 | 149 | install() { 150 | let logMsg = 151 | `To install your dependencies manually, run: ${chalk.yellow.bold(`${this.clientPackageManager} install`)}`; 152 | 153 | if (this.clientFramework === 'angular1') { 154 | logMsg = 155 | `To install your dependencies manually, run: ${chalk.yellow.bold(`${this.clientPackageManager} install & bower install`)}`; 156 | } 157 | const injectDependenciesAndConstants = (err) => { 158 | if (err) { 159 | this.warning('Install of dependencies failed!'); 160 | this.log(logMsg); 161 | } else if (this.clientFramework === 'angular1') { 162 | this.spawnCommand('gulp', ['install']); 163 | } 164 | }; 165 | const installConfig = { 166 | bower: this.clientFramework === 'angular1', 167 | npm: this.clientPackageManager !== 'yarn', 168 | yarn: this.clientPackageManager === 'yarn', 169 | callback: injectDependenciesAndConstants 170 | }; 171 | if (this.options['skip-install']) { 172 | this.log(logMsg); 173 | } else { 174 | this.installDependencies(installConfig); 175 | } 176 | } 177 | 178 | end() { 179 | this.log('End of angular-material-integration generator'); 180 | } 181 | }; 182 | --------------------------------------------------------------------------------