|
| 1 | +# jhip01 |
| 2 | +This application was generated using JHipster 4.7.0, you can find documentation and help at [https://jhipster.github.io/documentation-archive/v4.7.0](https://jhipster.github.io/documentation-archive/v4.7.0). |
| 3 | + |
| 4 | +## Development |
| 5 | + |
| 6 | +Before you can build this project, you must install and configure the following dependencies on your machine: |
| 7 | + |
| 8 | +1. [Node.js][]: We use Node to run a development web server and build the project. |
| 9 | + Depending on your system, you can install Node either from source or as a pre-packaged bundle. |
| 10 | +2. [Yarn][]: We use Yarn to manage Node dependencies. |
| 11 | + Depending on your system, you can install Yarn either from source or as a pre-packaged bundle. |
| 12 | + |
| 13 | +After installing Node, you should be able to run the following command to install development tools. |
| 14 | +You will only need to run this command when dependencies change in [package.json](package.json). |
| 15 | + |
| 16 | + yarn install |
| 17 | + |
| 18 | +We use yarn scripts and [Webpack][] as our build system. |
| 19 | + |
| 20 | + |
| 21 | +Run the following commands in two separate terminals to create a blissful development experience where your browser |
| 22 | +auto-refreshes when files change on your hard drive. |
| 23 | + |
| 24 | + ./mvnw |
| 25 | + yarn start |
| 26 | + |
| 27 | +[Yarn][] is also used to manage CSS and JavaScript dependencies used in this application. You can upgrade dependencies by |
| 28 | +specifying a newer version in [package.json](package.json). You can also run `yarn update` and `yarn install` to manage dependencies. |
| 29 | +Add the `help` flag on any command to see how you can use it. For example, `yarn help update`. |
| 30 | + |
| 31 | +The `yarn run` command will list all of the scripts available to run for this project. |
| 32 | + |
| 33 | +### Service workers |
| 34 | + |
| 35 | +Service workers are commented by default, to enable them please uncomment the following code. |
| 36 | + |
| 37 | +* The service worker registering script in index.html |
| 38 | +``` |
| 39 | +<script> |
| 40 | + if ('serviceWorker' in navigator) { |
| 41 | + navigator.serviceWorker |
| 42 | + .register('./sw.js') |
| 43 | + .then(function() { console.log('Service Worker Registered'); }); |
| 44 | + } |
| 45 | +</script> |
| 46 | +``` |
| 47 | +* The copy file option in webpack-common.js |
| 48 | +```js |
| 49 | +{ from: './src/main/webapp/sw.js', to: 'sw.js' }, |
| 50 | +``` |
| 51 | +Note: Add the respective scripts/assets in `sw.js` that is needed to be cached. |
| 52 | + |
| 53 | +### Managing dependencies |
| 54 | + |
| 55 | +For example, to add [Leaflet][] library as a runtime dependency of your application, you would run following command: |
| 56 | + |
| 57 | + yarn add --exact leaflet |
| 58 | + |
| 59 | +To benefit from TypeScript type definitions from [DefinitelyTyped][] repository in development, you would run following command: |
| 60 | + |
| 61 | + yarn add --dev --exact @types/leaflet |
| 62 | + |
| 63 | +Then you would import the JS and CSS files specified in library's installation instructions so that [Webpack][] knows about them: |
| 64 | + |
| 65 | +Edit [src/main/webapp/app/vendor.ts](src/main/webapp/app/vendor.ts) file: |
| 66 | +~~~ |
| 67 | +import 'leaflet/dist/leaflet.js'; |
| 68 | +~~~ |
| 69 | + |
| 70 | +Edit [src/main/webapp/content/css/vendor.css](src/main/webapp/content/css/vendor.css) file: |
| 71 | +~~~ |
| 72 | +@import '~leaflet/dist/leaflet.css'; |
| 73 | +~~~ |
| 74 | + |
| 75 | +Note: there are still few other things remaining to do for Leaflet that we won't detail here. |
| 76 | + |
| 77 | +For further instructions on how to develop with JHipster, have a look at [Using JHipster in development][]. |
| 78 | + |
| 79 | +### Using angular-cli |
| 80 | + |
| 81 | +You can also use [Angular CLI][] to generate some custom client code. |
| 82 | + |
| 83 | +For example, the following command: |
| 84 | + |
| 85 | + ng generate component my-component |
| 86 | + |
| 87 | +will generate few files: |
| 88 | + |
| 89 | + create src/main/webapp/app/my-component/my-component.component.html |
| 90 | + create src/main/webapp/app/my-component/my-component.component.ts |
| 91 | + update src/main/webapp/app/app.module.ts |
| 92 | + |
| 93 | +## Building for production |
| 94 | + |
| 95 | +To optimize the jhip01 application for production, run: |
| 96 | + |
| 97 | + ./mvnw -Pprod clean package |
| 98 | + |
| 99 | +This will concatenate and minify the client CSS and JavaScript files. It will also modify `index.html` so it references these new files. |
| 100 | +To ensure everything worked, run: |
| 101 | + |
| 102 | + java -jar target/*.war |
| 103 | + |
| 104 | +Then navigate to [http://localhost:8080](http://localhost:8080) in your browser. |
| 105 | + |
| 106 | +Refer to [Using JHipster in production][] for more details. |
| 107 | + |
| 108 | +## Testing |
| 109 | + |
| 110 | +To launch your application's tests, run: |
| 111 | + |
| 112 | + ./mvnw clean test |
| 113 | + |
| 114 | +### Client tests |
| 115 | + |
| 116 | +Unit tests are run by [Karma][] and written with [Jasmine][]. They're located in [src/test/javascript/](src/test/javascript/) and can be run with: |
| 117 | + |
| 118 | + yarn test |
| 119 | + |
| 120 | +UI end-to-end tests are powered by [Protractor][], which is built on top of WebDriverJS. They're located in [src/test/javascript/e2e](src/test/javascript/e2e) |
| 121 | +and can be run by starting Spring Boot in one terminal (`./mvnw spring-boot:run`) and running the tests (`yarn run e2e`) in a second one. |
| 122 | +### Other tests |
| 123 | + |
| 124 | +Performance tests are run by [Gatling][] and written in Scala. They're located in [src/test/gatling](src/test/gatling) and can be run with: |
| 125 | + |
| 126 | + ./mvnw gatling:execute |
| 127 | + |
| 128 | +For more information, refer to the [Running tests page][]. |
| 129 | + |
| 130 | +## Using Docker to simplify development (optional) |
| 131 | + |
| 132 | +You can use Docker to improve your JHipster development experience. A number of docker-compose configuration are available in the [src/main/docker](src/main/docker) folder to launch required third party services. |
| 133 | +For example, to start a mongodb database in a docker container, run: |
| 134 | + |
| 135 | + docker-compose -f src/main/docker/mongodb.yml up -d |
| 136 | + |
| 137 | +To stop it and remove the container, run: |
| 138 | + |
| 139 | + docker-compose -f src/main/docker/mongodb.yml down |
| 140 | + |
| 141 | +You can also fully dockerize your application and all the services that it depends on. |
| 142 | +To achieve this, first build a docker image of your app by running: |
| 143 | + |
| 144 | + ./mvnw package -Pprod docker:build |
| 145 | + |
| 146 | +Then run: |
| 147 | + |
| 148 | + docker-compose -f src/main/docker/app.yml up -d |
| 149 | + |
| 150 | +For more information refer to [Using Docker and Docker-Compose][], this page also contains information on the docker-compose sub-generator (`jhipster docker-compose`), which is able to generate docker configurations for one or several JHipster applications. |
| 151 | + |
| 152 | +## Continuous Integration (optional) |
| 153 | + |
| 154 | +To configure CI for your project, run the ci-cd sub-generator (`jhipster ci-cd`), this will let you generate configuration files for a number of Continuous Integration systems. Consult the [Setting up Continuous Integration][] page for more information. |
| 155 | + |
| 156 | +[JHipster Homepage and latest documentation]: https://jhipster.github.io |
| 157 | +[JHipster 4.7.0 archive]: https://jhipster.github.io/documentation-archive/v4.7.0 |
| 158 | + |
| 159 | +[Using JHipster in development]: https://jhipster.github.io/documentation-archive/v4.7.0/development/ |
| 160 | +[Using Docker and Docker-Compose]: https://jhipster.github.io/documentation-archive/v4.7.0/docker-compose |
| 161 | +[Using JHipster in production]: https://jhipster.github.io/documentation-archive/v4.7.0/production/ |
| 162 | +[Running tests page]: https://jhipster.github.io/documentation-archive/v4.7.0/running-tests/ |
| 163 | +[Setting up Continuous Integration]: https://jhipster.github.io/documentation-archive/v4.7.0/setting-up-ci/ |
| 164 | + |
| 165 | +[Gatling]: http://gatling.io/ |
| 166 | +[Node.js]: https://nodejs.org/ |
| 167 | +[Yarn]: https://yarnpkg.org/ |
| 168 | +[Webpack]: https://webpack.github.io/ |
| 169 | +[Angular CLI]: https://cli.angular.io/ |
| 170 | +[BrowserSync]: http://www.browsersync.io/ |
| 171 | +[Karma]: http://karma-runner.github.io/ |
| 172 | +[Jasmine]: http://jasmine.github.io/2.0/introduction.html |
| 173 | +[Protractor]: https://angular.github.io/protractor/ |
| 174 | +[Leaflet]: http://leafletjs.com/ |
| 175 | +[DefinitelyTyped]: http://definitelytyped.org/ |
| 176 | +======= |
| 177 | +# github-demo |
| 178 | +A simple demo repository to show the basic Git workflow |
| 179 | + |
0 commit comments