diff mbox series

[v2] web-app: update node.js components to latest versions

Message ID 20190117124814.15238-1-andrey.z@gmail.com
State Accepted
Headers show
Series [v2] web-app: update node.js components to latest versions | expand

Commit Message

Andrey Zhizhikin Jan. 17, 2019, 12:48 p.m. UTC
Some components were severely oudated, and some
components are suggested to be upgraded due to
security issues. This patch brings all components
to their actual version.

Major upgrade includes switching to gulp 4.0,
which requires the new task generation scheme,
this is also included in this patch.

Signed-off-by: Andrey Zhizhikin <andrey.z@gmail.com>
---
 web-app/gulpfile.js  | 26 +++++++++++++-------------
 web-app/index.html   |  4 ++--
 web-app/package.json | 34 ++++++++++++++++++----------------
 3 files changed, 33 insertions(+), 31 deletions(-)

Comments

Andrey Zhizhikin Feb. 1, 2019, 7:56 a.m. UTC | #1
Hello all,

Is there any update regarding this patch? Would you still be
interested to merge it to SWUpdate repository?

Thanks a lot!
-- Andrey

On Thu, Jan 17, 2019 at 1:48 PM Andrey Zhizhikin <andrey.z@gmail.com> wrote:
>
> Some components were severely oudated, and some
> components are suggested to be upgraded due to
> security issues. This patch brings all components
> to their actual version.
>
> Major upgrade includes switching to gulp 4.0,
> which requires the new task generation scheme,
> this is also included in this patch.
>
> Signed-off-by: Andrey Zhizhikin <andrey.z@gmail.com>
> ---
>  web-app/gulpfile.js  | 26 +++++++++++++-------------
>  web-app/index.html   |  4 ++--
>  web-app/package.json | 34 ++++++++++++++++++----------------
>  3 files changed, 33 insertions(+), 31 deletions(-)
>
Stefano Babic Feb. 1, 2019, 9:13 a.m. UTC | #2
Hi Andrey,

On 01/02/19 08:56, Andrey Zhizhikin wrote:
> Hello all,
> 
> Is there any update regarding this patch? Would you still be
> interested to merge it to SWUpdate repository?
> 

Yes, of course - I will just test your patch myself and I will then push it.

Regards,
Stefano Babic


> Thanks a lot!
> -- Andrey
> 
> On Thu, Jan 17, 2019 at 1:48 PM Andrey Zhizhikin <andrey.z@gmail.com> wrote:
>>
>> Some components were severely oudated, and some
>> components are suggested to be upgraded due to
>> security issues. This patch brings all components
>> to their actual version.
>>
>> Major upgrade includes switching to gulp 4.0,
>> which requires the new task generation scheme,
>> this is also included in this patch.
>>
>> Signed-off-by: Andrey Zhizhikin <andrey.z@gmail.com>
>> ---
>>  web-app/gulpfile.js  | 26 +++++++++++++-------------
>>  web-app/index.html   |  4 ++--
>>  web-app/package.json | 34 ++++++++++++++++++----------------
>>  3 files changed, 33 insertions(+), 31 deletions(-)
>>
>
Andrey Zhizhikin Feb. 1, 2019, 12:04 p.m. UTC | #3
Hi Stefano,

On Fri, Feb 1, 2019 at 10:13 AM Stefano Babic <sbabic@denx.de> wrote:
>
> Hi Andrey,
>
> On 01/02/19 08:56, Andrey Zhizhikin wrote:
> > Hello all,
> >
> > Is there any update regarding this patch? Would you still be
> > interested to merge it to SWUpdate repository?
> >
>
> Yes, of course - I will just test your patch myself and I will then push it.
>

Thanks a lot for the update here! It's not a problem - just wanted to
make sure it is still interesting for integration and not getting
lost.

> Regards,
> Stefano Babic
>

Regards,
Andrey
Stefano Babic Feb. 1, 2019, 2:03 p.m. UTC | #4
On 17/01/19 13:48, Andrey Zhizhikin wrote:
> Some components were severely oudated, and some
> components are suggested to be upgraded due to
> security issues. This patch brings all components
> to their actual version.
> 
> Major upgrade includes switching to gulp 4.0,
> which requires the new task generation scheme,
> this is also included in this patch.
> 
> Signed-off-by: Andrey Zhizhikin <andrey.z@gmail.com>
> ---
Tested-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
Stefano Babic Feb. 1, 2019, 2:28 p.m. UTC | #5
Hi Andy, Stefan,

On 17/01/19 13:48, Andrey Zhizhikin wrote:
> Some components were severely oudated, and some
> components are suggested to be upgraded due to
> security issues. This patch brings all components
> to their actual version.
> 
> Major upgrade includes switching to gulp 4.0,
> which requires the new task generation scheme,
> this is also included in this patch.
> 
> Signed-off-by: Andrey Zhizhikin <andrey.z@gmail.com>
> ---

Applied to -master, thanks !

Do you know why this line cause lint error (npm run lint):

web-app/js/swupdate.js:121:105: Unnecessary escape character:

  /home/stefano/Projects/swupdate/web-app/js/swupdate.js:121:105:
Unnecessary escape character: \/.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! swupdate@0.2.0 lint: `standard --fix && htmlhint && sass-lint
-v scss/* && csslint css/*`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the swupdate@0.2.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.

It looks to me correct that escape is required. Dropping

var ws = new WebSocket(protocol + '//' + window.location.host +
window.location.pathname.replace(/\/[^\/]*$/, '') + '/ws')

But dropping the .replace() part of the stament removes the error, so it
is surely caused by this line.

Best regards,
Stefano
Andrey Zhizhikin Feb. 4, 2019, 9:34 a.m. UTC | #6
Hello Stefano,

On Fri, Feb 1, 2019 at 3:28 PM Stefano Babic <sbabic@denx.de> wrote:
>
> Applied to -master, thanks !

Thanks a lot!

>
> Do you know why this line cause lint error (npm run lint):
>
> web-app/js/swupdate.js:121:105: Unnecessary escape character:
>
>   /home/stefano/Projects/swupdate/web-app/js/swupdate.js:121:105:
> Unnecessary escape character: \/.
> npm ERR! code ELIFECYCLE
> npm ERR! errno 1
> npm ERR! swupdate@0.2.0 lint: `standard --fix && htmlhint && sass-lint
> -v scss/* && csslint css/*`
> npm ERR! Exit status 1
> npm ERR!
> npm ERR! Failed at the swupdate@0.2.0 lint script.
> npm ERR! This is probably not a problem with npm. There is likely
> additional logging output above.
>
> It looks to me correct that escape is required. Dropping
>
> var ws = new WebSocket(protocol + '//' + window.location.host +
> window.location.pathname.replace(/\/[^\/]*$/, '') + '/ws')
>
> But dropping the .replace() part of the stament removes the error, so it
> is surely caused by this line.

Indeed, it does. I believe this came with the update from standard.js
where they enforced the no-useless-escape rule.

I've removed the escape in question in replace() statement to this one:
-  var ws = new WebSocket(protocol + '//' + window.location.host +
window.location.pathname.replace(/\/[^\/]*$/, '') + '/ws')
+  var ws = new WebSocket(protocol + '//' + window.location.host +
window.location.pathname.replace(/\/[^/]*$/, '') + '/ws')

and lint was pretty happy to swallow it. However, when I run the build
- the escape was back in place:
(from dist/js/swupdate.min.js):
var e=new WebSocket(s+"//"+window.location.host+window.location.pathname.replace(/\/[^\/]*$/,"")+"/ws");

At this point, I believe that this is pure linting issue and the
escape is correctly set. This can be disabled in JS file like this:
/* eslint no-useless-escape: "off" */

Maybe Stefan can comment here further.

>
> Best regards,
> Stefano
>
diff mbox series

Patch

diff --git a/web-app/gulpfile.js b/web-app/gulpfile.js
index 2ba5b9a..19d17a1 100755
--- a/web-app/gulpfile.js
+++ b/web-app/gulpfile.js
@@ -27,7 +27,7 @@  var knownOptions = {
 
 var options = minimist(process.argv.slice(2), knownOptions)
 
-gulp.task('sass', ['clean'], () => {
+gulp.task('sass', async function () {
   return gulp.src('scss/*.scss')
     .pipe(sass().on('error', sass.logError))
     .pipe(cleanCSS({ compatibility: '*' }))
@@ -37,7 +37,7 @@  gulp.task('sass', ['clean'], () => {
     .pipe(gulp.dest('dist/css'))
 })
 
-gulp.task('minify-css', ['clean'], () => {
+gulp.task('minify-css', async function () {
   return gulp.src('css/*.css')
     .pipe(cleanCSS({ compatibility: '*' }))
     .pipe(rename({
@@ -46,7 +46,7 @@  gulp.task('minify-css', ['clean'], () => {
     .pipe(gulp.dest('dist/css'))
 })
 
-gulp.task('minify-js', ['clean'], () => {
+gulp.task('minify-js', async function () {
   return gulp.src('js/*.js')
     .pipe(minify({
       ext: {
@@ -58,7 +58,7 @@  gulp.task('minify-js', ['clean'], () => {
     .pipe(gulp.dest('dist/js'))
 })
 
-gulp.task('minify-html', ['clean'], () => {
+gulp.task('minify-html', async function () {
   return gulp.src('*.html')
     .pipe(replace('node_modules/bootstrap/dist/css', 'css'))
     .pipe(useref({ noconcat: true }))
@@ -71,7 +71,7 @@  gulp.task('minify-html', ['clean'], () => {
     .pipe(gulp.dest('dist'))
 })
 
-gulp.task('copy-css', ['clean'], () => {
+gulp.task('copy-css', async function () {
   return gulp.src('*.html')
     .pipe(useref({ noconcat: true }))
     .pipe(filter('**/*.css'))
@@ -83,7 +83,7 @@  gulp.task('copy-css', ['clean'], () => {
     .pipe(gulp.dest('dist'))
 })
 
-gulp.task('copy-js', ['clean'], () => {
+gulp.task('copy-js', async function () {
   return gulp.src('*.html')
     .pipe(useref({ noconcat: true }))
     .pipe(filter('**/*.js'))
@@ -100,20 +100,20 @@  gulp.task('copy-js', ['clean'], () => {
     .pipe(gulp.dest('dist'))
 })
 
-gulp.task('copy-fonts', ['clean'], () => {
+gulp.task('copy-fonts', async function () {
   return gulp.src([
-    'node_modules/@fortawesome/fontawesome-free-webfonts/webfonts/fa-solid-900.{ttf,woff,woff2}'
+   'node_modules/@fortawesome/fontawesome-free/webfonts/fa-solid-900.{ttf,woff,woff2}' 
   ])
   .pipe(gulp.dest('dist/webfonts'))
 })
 
-gulp.task('resize-images', ['clean'], () => {
+gulp.task('resize-images', async function () {
   return gulp.src('images/*')
     .pipe(imagemin({ verbose: true }))
     .pipe(gulp.dest('dist/images'))
 })
 
-gulp.task('package', () => {
+gulp.task('package', function () {
   var name = options.output.replace('.tar', '').replace('.gz', '')
   return gulp.src('dist/**')
     .pipe(tar(name + '.tar'))
@@ -121,10 +121,10 @@  gulp.task('package', () => {
     .pipe(gulp.dest('.'))
 })
 
-gulp.task('clean', () => {
+gulp.task('clean', function () {
   return del('dist/**', { force: true })
 })
 
-gulp.task('build', ['copy-css', 'copy-js', 'copy-fonts', 'sass', 'minify-css', 'minify-js', 'minify-html', 'resize-images'])
+gulp.task('build', gulp.series('clean', gulp.parallel('copy-css', 'copy-js', 'copy-fonts', 'sass', 'minify-css', 'minify-js', 'minify-html', 'resize-images')))
 
-gulp.task('default', ['build'])
+gulp.task('default', gulp.series('build'))
diff --git a/web-app/index.html b/web-app/index.html
index 82d22bf..641cb8c 100755
--- a/web-app/index.html
+++ b/web-app/index.html
@@ -10,8 +10,8 @@ 
   <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.css">
   <!-- build:css -->
   <link rel="stylesheet" href="node_modules/dropzone/dist/dropzone.css">
-  <link rel="stylesheet" href="node_modules/@fortawesome/fontawesome-free-webfonts/css/fontawesome.css">
-  <link rel="stylesheet" href="node_modules/@fortawesome/fontawesome-free-webfonts/css/fa-solid.css">
+  <link rel="stylesheet" href="node_modules/@fortawesome/fontawesome-free/css/fontawesome.css">
+  <link rel="stylesheet" href="node_modules/@fortawesome/fontawesome-free/css/solid.css">
   <link rel="stylesheet" href="css/swupdate.css">
   <!-- endbuild -->
 
diff --git a/web-app/package.json b/web-app/package.json
index 5daf6a7..2909b45 100755
--- a/web-app/package.json
+++ b/web-app/package.json
@@ -1,6 +1,6 @@ 
 {
   "name": "swupdate",
-  "version": "0.1.0",
+  "version": "0.2.0",
   "description": "Software Update for Embedded Systems Web Front End",
   "main": "index.html",
   "scripts": {
@@ -16,28 +16,30 @@ 
   "devDependencies": {
     "csslint": "^1.0.5",
     "del": "^3.0.0",
-    "gulp": "^3.9.1",
-    "gulp-clean-css": "^3.9.0",
+    "gulp": "^4.0.0",
+    "gulp-clean-css": "^4.0.0",
     "gulp-filter": "^5.1.0",
-    "gulp-gzip": "^1.4.1",
+    "gulp-gzip": "^1.4.2",
     "gulp-html-replace": "^1.6.2",
-    "gulp-htmlmin": "^4.0.0",
-    "gulp-imagemin": "^4.1.0",
-    "gulp-minify": "^2.1.0",
-    "gulp-rename": "^1.2.2",
-    "gulp-replace": "^0.6.1",
-    "gulp-sass": "^3.1.0",
+    "gulp-htmlmin": "^5.0.1",
+    "gulp-imagemin": "^5.0.3",
+    "gulp-minify": "^3.1.0",
+    "gulp-rename": "^1.4.0",
+    "gulp-replace": "^1.0.0",
+    "gulp-sass": "^4.0.2",
     "gulp-tar": "^2.1.0",
-    "gulp-useref": "^3.1.4",
-    "htmlhint": "^0.9.13",
+    "gulp-useref": "^3.1.6",
+    "htmlhint": "^0.10.1",
     "minimist": "^1.2.0",
     "sass-lint": "^1.12.1",
-    "standard": "^10.0.3"
+    "standard": "^12.0.1",
+    "eslint": "^5.11.1"
   },
   "dependencies": {
-    "@fortawesome/fontawesome-free-webfonts": "^1.0.3",
-    "bootstrap": "^4.0.0",
-    "dropzone": "5.2.0",
+    "@fortawesome/fontawesome-free": "^5.6.3",
+    "bootstrap": "^4.2.1",
+    "popper.js": "^1.14.6",
+    "dropzone": "5.5.1",
     "jquery": "^3.3.1"
   },
   "standard": {