Which linting tool to use for Angular with JHipster - eslint

I've recently discovered JHipster and I'm giving it a try. Reading the official web page, it says that JHipster uses Sonar as its linting tool. But I've also noticed that the project has a .eslintrc.json file configured to work with Angular and Eslint dependencies/scripts in package.json. However, the sonar-project.properties file isn't configured to import Eslint's report into SonarQube (via sonar.eslint.reportPaths).
So I'm left wondering how the linting analisis should be done with JHipster's stack. Am I supposed to use sonar-scanner's report or import Eslint's report into SonarQube?
Thanks in advance,
Urko

JHipster uses SonarQube to analyze your java source code and usually this is done by your build tool (maven or gradle) and/or your java IDE.
Then there's static code analysis for frontend code which can be run using npm lint and which uses eslint. JHipster does not configure .eslintrc.json to use eslint-plugin-sonarjs so there's no link with Sonar here but you could add it if you want to use additional eslint rules provided by Sonar.

Related

CKEditor5 Online Editor - How to configure a custom npm package for strapi

i use strapi and i want to change the default text editor with the ckeditor5 classic.
On the strapi website is a guide how to configure the default ckeditor5 classic for strapi.
Strapi Guide
But there are some important tools missing so I want to build my custom fork of the ckeditor5 classic package.
I started with the ckeditor5 online builder. Downloaded the build package and want to import it in the strapi project.
Online Builder
My problems starting here.
First of all, how I can use a downloaded package in a project instead of download it over npm/yarn?
Package Structure:
build
sample
src
Licsence
package.json
webpack.config
I saw that package has no main command in the package.json. So an import in a node.js file to this package doesn't work. Here is my question, is this package i build with the online generator intended for usage in a node project?
Look at the truth, I don't know very well, I'm not an expert on the subject yet ... I'm really new and I'm working with strapi, but as I see these plugins have an install command with NPM. Example:
enter image description here
Try to download the plugins by NPM or Yarn and then import them as they say in this post: Customizing CKEditor for Strapi gives "ckeditor-duplicated-modules" error

How to run OWASP Dependency Check for an Angular project?

I'm trying to use this in an Angular project:
https://owasp.org/www-project-dependency-check/
We use the Database server approach explained in https://jeremylong.github.io/DependencyCheck/data/database.html in all our builds, but I been unable to trigger this analysis for the Angular project.
The official documentation offers this:
https://jeremylong.github.io/DependencyCheck/analyzers/nodejs.html
Alas, I could not figure out how to use for the angular build. I have also tried the command below with no success either.
$ npm audit
What am I missing here?

How to replace strapis default wysiwyg editor to CKEditor

I am trying to use CKEditor for strapi project, but failing to integrate.
What I did so far:
strapi new cms --quickstart It is starting me new cms application.
npm install ckeditor
Edit the code located at ./plugins/content-manager/admin/src/component/Edit/index.js to CKEditor implementation
npm run build to see my changes, tried npm run setup too
But here I'm getting error webpackJsonp is not defined
I'm not providing the code how I modified, because, build command is not reaching till there.
I appreciate any help you can provide
In order to change the default WYSIWYG in Strapi you will need to
Fork the repository check out the CONTRIBUTING GUIDE
Once you have the development setup you can directly modify the code in packages/strapi-plugin-content-manager/admin/src/components/WYSIWYGWithErrors and its related children. Install the dependency in strapi-admin
Uninstall the content manager plugin (again make sure you are running the latest version of Strapi
Copy the strapi-plugin-content-manager package inside your app's plugin folder (rename it content-manager)
Copy the following file in my-app/admin/src/plugins.js and change the paths of the plugins so it matches your new one
run yarn develop

Testing a module

I just implemented a Jhipster module to provide Maven site generation as well as maven release process within Jhipster.
I implemented mocha tests to verify that files are generated (which pass), but it looks like they aren't generated in a real scaffolded context (if you have any clue on the error, I would be really thankful).
The only way I found to test that module with a scaffolded sample is to publish it in the npm registry in order to be able to select it in module choices radio, but it's not really a good option, as it exposes a non working module on the Jhipster marketplace (I'm really sorry about it).
To test a module locally, do the following:
run npm link in your module directory
generate a project
run npm link generator-jhipster-enterprise-pom in your project
Now when you run yo jhipster-enterprise-pom it will use your local code instead of requiring installation from npmjs.
Looking at your module's code, it looks like you renamed the app folder to server. A yeoman generator runs the code found in the app folder which is why your local test is failing. According to the Writing Your Own Yeoman Generator docs:
The default generator used when you call yo name is the app generator. This must be contained within the app/ directory.
It's currently accessible by running yo jhipster-enterprise-pom:server but I imagine you don't want the :server included in the default command.

How to package & deploy Node.js + express web application?

I am new to Node.js programming and I have recently created a sample working web application using (express, backbone & other complimentary view technologies, with mongoDB). Now i am at a point where I want to deploy the same on a staging environment and I am not sure how to package this application and distribute the same. [I can take care of mongoDb and setting it up seperately]
I am from Java world and in there we create jars for reusable libs and war/ear packages for web applications which is deployed in a servlet container. Now in this case since node.js itself acts as a web container as well, how do i package my webapp?
Is there any standard format/guidelines of packaging node webapps built using express? (Is there a similar jar/war packaging systems for node apps?)
How do I deploy it once packaged? Would it become an exe, since it is also its own container?
PS: As of now I am thinking of just manually copying all the required source files into the staging environment and run npm commands to download all dependencies on that machine and then use 'forever' or some other mechanism to run my server.js. (Also, add some sort of monitoring, just in case app crashes and forever fails) I am not sure if that is the right way? I am sure there must be some standardized way of addressing this problem.
Deploying Node.js applications is very easy stuff. In maven, there is pom.xml. Related concept in Node.js is package.json. You can state your dependencies on package.json. You can also do environmental setup on package.json. For example, in dev environment you can say that
I want to run unit tests.
but in production;
I want to skip unit tests.
You have local repositories for maven under .m2 folder. In Node.js, there is node_modules folder under your Node.js project. You can see module folders with its name.
Let's come to the grunt part of this answer. Grunt is a task manager for your frontend assets, html, javascript, css. For example, before deployment you can minify html, css, javascript even images. You can also put grunt task run functions in package.json.
If you want to look at a sample application, you can find an example blog application here. Check folder structure and package.json for reference.
For deployment, I suggest you heroku deployment for startup applciations. You can find howto here. This is simple git based deployment.
On project running part, simply set your environment NODE_ENV=development and node app.js. Here app.js is in your project.
Here is relative concept for java and nodejs;
maven clean install => npm install
.m2 folder => node_modules(Under project folder)
mvn test => npm test(test section on package.json)
junit, powermock, ... => mocha, node-unit, ...
Spring MVC => Express.JS
pom.xml => package.json
import package => require('module_name')
There is no standardized way, but you're on the right track. If your package.json is up to date and well kept, you can just copy/zip/clone your app directory to the production system, excluding the node_modules.
On your production system, run
npm install to install your dependencies, npm test if you have tests and finally NODE_ENV=production node server.js
Some recent slides I considered to be quite helpful that also include the topic of wrappers like forever, can be found here.
Hope this might be helpful for somebody looking for the solution,Packaging of Node js apps can be done using "npm pack" command.It creates a zip file of your application which can be run in production/staging environment.
Is there any standard format/guidelines of packaging node webapps
built using express? (Is there a similar jar/war packaging systems for
node apps?)
Yes, the CommonJS Packages specification:
This specification describes the CommonJS package format for
distributing CommonJS programs and libraries. A CommonJS package is a
cohesive wrapping of a collection of modules, code and other assets
into a single form. It provides the basis for convenient delivery,
installation and management of CommonJS components.
For your next question:
2. How do I deploy it once packaged? Would it become an exe, since it is also its own container?
I second Hüseyin's suggestion to deploy on Heroku for production. For development and staging I use Node-Appliance with VirtualBox and Amazon EC2, respectively:
This program takes a Debian machine built by build-debian-cloud or
Debian-VirtualBox-Appliance and turns it into a Node.js "appliance",
capable of running a Node application deployed via git.
Your webapp will not become an exe.
few ways to approach this:
Push your code into Git repository, excluding everything that isn't your code (node_modules/**), then pull it in your staging environment, run npm install to restore all dependencies
create an NPM package out of it , install it via npm in your staging environment (this should also take care of all of the dependencies)
manual copy/ssh files to your staging environment (this can be automated with Grunt), than restore your dependencies via npm
I used zeit's pkg module. It can create cross platform deliverables for linux/win/macos. Actually used it in production and works fine without any issues.
It takes in all the js scripts and packages it into a single file.
The reason I used it is because it helps in securing your source code. That way in production at customers environment they will have access to application but not the source code.
Also one of the advantages is that at production environment, you do not actually need to have the customer install node.js as the node binaries also get packaged inside the build.
https://www.npmjs.com/package/pkg

Resources