JHipsterで作ったテンプレートに、モデルを追加してHerokuへデプロイする
TL;DR
- JHipsterを使うとRuby on Railsのgenerate scaffoldingがSpring/Angularのプロジェクトでできる
- Herokuへのデプロイもコマンド一発でできる
モデル作成コマンド
yo jhipster:entity <モデル名>
作成オプション
edo:jhipster-sample shinse$ yo jhipster:entity Team The entity Team is being created. Generating field #1 ? Do you want to add a field to your entity? (Y/n) Y ? What is the name of your field? name ? What is the type of your field? (Use arrow keys) ❯ String Integer Long Float Double BigDecimal LocalDate (Move up and down to reveal more choices) ? Do you want to add validation rules to your field? (y/N) y ? Which validation rules do you want to add? ❯◉ Required ◯ Minimum length ◯ Maximum length ◯ Regular expression pattern Generating field #2 ? Do you want to add a field to your entity? (Y/n) n ================= Team ================= Fields name (String) required Generating relationships to other entities ? Do you want to add a relationship to another entity? (Y/n) y ? What is the name of the other entity? user ? What is the name of the relationship? (user) user ? What is the type of the relationship? many-to-one ❯ many-to-many one-to-one ================= Team ================= Fields name (String) required Relationships user (User) many-to-many Generating relationships to other entities ? Do you want to add a relationship to another entity? (Y/n) n? Do you want to use a Data Transfer Object (DTO)? (Use arrow keys) ❯ No, use the entity directly [BETA] Yes, generate a DTO with MapStruct ? Do you want to use separate service class for your business logic? No, the REST controller should use the repository directly ❯ Yes, generate a separate service class Yes, generate a separate service interface and implementation ? Do you want pagination on your entity? No ❯ Yes, with a simple pager Yes, with pagination links Yes, with infinite scroll Everything is configured, generating the entity... create .jhipster/Team.json create src/main/resources/config/liquibase/changelog/20170112144800_added_entity_Team.xml create src/main/resources/config/liquibase/changelog/20170112144800_added_entity_constraints_Team.xml conflict src/main/resources/config/liquibase/master.xml ? Overwrite src/main/resources/config/liquibase/master.xml? (Ynaxdh) a >> overwrite this and all others force src/main/resources/config/liquibase/master.xml create src/main/java/mrd/shinse/jhipster/sample/domain/Team.java create src/main/java/mrd/shinse/jhipster/sample/repository/TeamRepository.java create src/main/java/mrd/shinse/jhipster/sample/web/rest/TeamResource.java create src/main/java/mrd/shinse/jhipster/sample/service/TeamService.java create src/main/webapp/app/entities/team/teams.html create src/main/webapp/app/entities/team/team-detail.html create src/main/webapp/app/entities/team/team-dialog.html create src/main/webapp/app/entities/team/team-delete-dialog.html force src/main/webapp/app/layouts/navbar/navbar.html create src/main/webapp/app/entities/team/team.state.js create src/main/webapp/app/entities/team/team.controller.js create src/main/webapp/app/entities/team/team-dialog.controller.js create src/main/webapp/app/entities/team/team-delete-dialog.controller.js create src/main/webapp/app/entities/team/team-detail.controller.js create src/main/webapp/app/entities/team/team.service.js create src/main/webapp/i18n/ja/team.json force src/main/webapp/i18n/ja/global.json create src/main/webapp/i18n/zh-cn/team.json force src/main/webapp/i18n/zh-cn/global.json create src/main/webapp/i18n/en/team.json force src/main/webapp/i18n/en/global.json create src/test/javascript/spec/app/entities/team/team-detail.controller.spec.js create src/test/java/mrd/shinse/jhipster/sample/web/rest/TeamResourceIntTest.java create src/test/gatling/simulations/TeamGatlingTest.scala Running gulp Inject to add javascript to index [23:48:15] Using gulpfile ~/programming/github/jhipster-sample/gulpfile.js [23:48:15] Starting 'inject:app'... [23:48:15] gulp-inject 119 files into index.html. [23:48:15] Finished 'inject:app' after 252 ms edo:jhipster-sample shinse$
Herokuデプロイコマンド
yo jhipster:heroku
コンソール
edo:jhipster-sample shinse$ yo jhipster:heroku Heroku configuration is starting ? Name to deploy as: jhipsterSample ? On which region do you want to deploy ? us Using existing Git repository Installing Heroku CLI deployment plugin Creating Heroku application and setting up node environment heroku create jhipster-sample https://jhipster-sample.herokuapp.com/ | https://git.heroku.com/jhipster-sample.git Provisioning addons Created heroku-postgresql --as DATABASE Creating Heroku deployment files create src/main/resources/config/bootstrap-heroku.yml create src/main/resources/config/application-heroku.yml create Procfile Building application Starting a Gradle Daemon (subsequent builds will be faster) :cleanResources :bootBuildInfo :bower :nodeSetup SKIPPED :npmSetup SKIPPED :npmInstall :gulpBuildWithOpts [20:51:57] Using gulpfile ~/programming/github/jhipster-sample/gulpfile.js [20:51:57] Starting 'clean'... [20:51:57] Finished 'clean' after 5.92 ms [20:51:57] Starting 'build'... [20:51:57] Starting 'copy:i18n'... [20:51:57] Starting 'copy:fonts'... [20:51:57] Starting 'copy:common'... [20:51:57] Starting 'inject:vendor'... [20:51:57] Starting 'ngconstant:prod'... [20:51:57] Starting 'copy:languages'... [20:51:57] Finished 'ngconstant:prod' after 62 ms [20:51:57] gulp-inject 1 files into vendor.scss. [20:51:57] Finished 'copy:languages' after 80 ms [20:51:57] Finished 'copy:common' after 169 ms [20:51:57] gulp-inject 22 files into index.html. [20:51:57] Finished 'inject:vendor' after 177 ms [20:51:57] Finished 'copy:fonts' after 217 ms [20:51:57] Finished 'copy:i18n' after 303 ms [20:51:57] Starting 'copy'... [20:51:57] Finished 'copy' after 48 μs [20:51:57] Starting 'inject:app'... [20:51:57] gulp-inject 113 files into index.html. [20:51:57] Finished 'inject:app' after 211 ms [20:51:57] Starting 'inject:troubleshoot'... [20:51:57] gulp-inject Nothing to inject into index.html. [20:51:57] Finished 'inject:troubleshoot' after 6.12 ms [20:51:57] Starting 'images'... [20:51:57] Starting 'sass'... [20:51:57] Starting 'html'... [20:51:57] Starting 'copy:swagger'... [20:51:57] Starting 'copy:images'... [20:51:57] Finished 'copy:images' after 25 ms [20:51:58] Tested 3 tests, 3 passes, 0 failures: PASS [20:51:58] Finished 'sass' after 1.12 s [20:51:58] Starting 'styles'... [20:51:58] Finished 'styles' after 5.74 ms [20:51:58] Finished 'html' after 1.17 s [20:51:59] Finished 'copy:swagger' after 1.2 s [20:51:59] gulp-imagemin: Minified 3 images (saved 0 B - 0%) [20:51:59] Finished 'images' after 1.99 s [20:51:59] Starting 'assets:prod'... [20:52:19] Finished 'assets:prod' after 20 s [20:52:19] Finished 'build' after 22 s :processResources :compileJava :compileScala UP-TO-DATE :classes :findMainClass :war :bootRepackage BUILD SUCCESSFUL Total time: 1 mins 18.679 secs Deploying application Uploading your application code. This may take several minutes depending on your connection speed... Uploading jhipster-sample-0.0.1-SNAPSHOT.war -----> Packaging application... - app: jhipster-sample - including: build/libs/jhipster-sample-0.0.1-SNAPSHOT.war -----> Creating build... - file: slug.tgz - size: 43MB -----> Uploading build... - success -----> Deploying... remote: remote: -----> heroku-deploy app detected remote: -----> Installing OpenJDK 1.8... done remote: -----> Discovering process types remote: Procfile declares types -> web remote: remote: -----> Compressing... remote: Done: 91.6M remote: -----> Launching... remote: Released v4 remote: https://jhipster-sample.herokuapp.com/ deployed to Heroku remote: -----> Done Your app should now be live. To view it run heroku open And you can view the logs with this command heroku logs --tail After application modification, redeploy it with yo jhipster:heroku
Herokuインスタンス停止コマンド
heroku ps:stop web.1
シリーズの一覧はこちら。 mrdshinse.hatenablog.com