Skip to content

This is a sample .NET application created with the JHipster .NET blueprint

Notifications You must be signed in to change notification settings

kraneesh/jhipster-sample-app-dotnetcore

 
 

Repository files navigation

Jhipster

This application was generated using JHipster 6.10.5 and JHipster .Net Core 2.1.0, you can find documentation and help at https://www.jhipster.tech/documentation-archive/v6.10.5.

Development

Before you can build this project, you must install and configure the following dependencies on your machine:

  1. Node.js: We use Node to run a development web server and build the project. Depending on your system, you can install Node either from source or as a pre-packaged bundle.

After installing Node, you should be able to run the following command to install development tools. You will only need to run this command when dependencies change in package.json.

In ./src/Jhipster/ClientApp run

npm install

We use npm scripts and Webpack as our build system.

Run the following commands in two separate terminals to create a blissful development experience where your browser auto-refreshes when files change on your hard drive.

dotnet run --verbosity normal --project ./src/Jhipster/Jhipster.csproj
npm --prefix ./src/Jhipster/ClientApp start

npm is also used to manage CSS and JavaScript dependencies used in this application. You can upgrade dependencies by specifying a newer version in package.json. You can also run npm update and npm install to manage dependencies. Add the help flag on any command to see how you can use it. For example, npm help update.

The npm --prefix ./src/Jhipster/ClientApp run command will list all of the scripts available to run for this project.

Service workers

Service workers are commented by default, to enable them please uncomment the following code.

  • The service worker registering script in index.html
<script>
  if ('serviceWorker' in navigator) {
    navigator.serviceWorker.register('./service-worker.js').then(function () {
      console.log('Service Worker Registered');
    });
  }
</script>

Note: workbox creates the respective service worker and dynamically generate the service-worker.js

Managing dependencies

For example, to add Leaflet library as a runtime dependency of your application, you would run following command:

npm --prefix ./src/Jhipster/ClientApp install --save --save-exact leaflet

To benefit from TypeScript type definitions from DefinitelyTyped repository in development, you would run following command:

npm --prefix ./src/Jhipster/ClientApp install --save-dev --save-exact @types/leaflet

Then you would import the JS and CSS files specified in library's installation instructions so that Webpack knows about them: Edit Jhipster/ClientApp/app/vendor.ts file:

import 'leaflet/dist/leaflet.js';

Edit Jhipster/ClientApp/content/css/vendor.css file:

@import '~leaflet/dist/leaflet.css';

Note: there are still few other things remaining to do for Leaflet that we won't detail here.

For further instructions on how to develop with JHipster, have a look at [Using JHipster in development][].

Using angular-cli

You can also use Angular CLI to generate some custom client code.

For example, the following command:

ng generate component my-component

will generate few files:

create Jhipster/ClientApp/src/app/my-component/my-component.component.html
create Jhipster/ClientApp/src/app/my-component/my-component.component.ts
update Jhipster/ClientApp/src/app/app.module.ts

Building for production

To build the arifacts and optimize the Jhipster application for production, run:

cd ./src/Jhipster
rm -rf ./src/Jhipster/wwwroot
dotnet publish --verbosity normal -c Release -o ./app/out ./Jhipster.csproj

The ./src/Jhipster/app/out directory will contain your application dll and its depedencies.

This will concatenate and minify the client CSS and JavaScript files. It will also modify index.html so it references these new files.

Code style / formatting

To format the dotnet code, run

dotnet format

Testing

To launch your application's tests, run:

dotnet test --verbosity normal

Client tests

In ClientApp folder run :

npm test

Code quality

By Script :

  1. Run Sonar in container : docker-compose -f ./docker/sonar.yml up -d

  2. Wait container was up Run SonarAnalysis.ps1 and go to http://localhost:9001

Manually :

  1. Run Sonar in container : docker-compose -f ./docker/sonar.yml up -d

  2. Install sonar scanner for .net :

dotnet tool install --global dotnet-sonarscanner

  1. Run dotnet sonarscanner begin /d:sonar.login=admin /d:sonar.password=admin /k:"Jhipster" /d:sonar.host.url="http://localhost:9001" /s:"`pwd`/SonarQube.Analysis.xml"

  2. Build your application : dotnet build

  3. Publish sonar results : dotnet sonarscanner end /d:sonar.login=admin /d:sonar.password=admin

  4. Go to http://localhost:9001

Monitoring

  1. Run container (uncomment chronograf and kapacitor if you would use it): docker-compose -f ./docker/monitoring.yml up -d

  2. Go to http://localhost:3000 (or http://localhost:8888 if you use chronograf)

  3. (Only for chronograf) Change influxdb connection string by YourApp-influxdb

  4. (Only for chronograf) Change kapacitor connection string by YourApp-kapacitor

  5. (Only for chronograf) You can now add dashboard (like docker), see your app log in Cronograf Log viewer and send alert with kapacitor

Build a Docker image

You can also fully dockerize your application and all the services that it depends on. To achieve this, first build a docker image of your app by running:

docker build -f ./src/Jhipster/Dockerfile -t Jhipster .

Then run:

docker run -p 80:80 Jhipster

About

This is a sample .NET application created with the JHipster .NET blueprint

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 42.4%
  • C# 35.9%
  • HTML 18.5%
  • JavaScript 1.8%
  • SCSS 0.9%
  • CSS 0.4%
  • Other 0.1%