From c8e437a30646360e2bda46e613aea9e741e110fd Mon Sep 17 00:00:00 2001 From: Panu Valtanen Date: Sat, 28 May 2022 08:28:53 +0000 Subject: [PATCH 1/4] (Chore) Update node-sass-middleware to v1.0.1 This closes issues: Running tests locally fails #308 and Sass Generator not working out of the box #296 --- bin/express-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index 380a447d..d8ef9995 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -212,7 +212,7 @@ function createApplication (name, dir, options, done) { case 'sass': app.locals.modules.sassMiddleware = 'node-sass-middleware' app.locals.uses.push("sassMiddleware({\n src: path.join(__dirname, 'public'),\n dest: path.join(__dirname, 'public'),\n indentedSyntax: true, // true = .sass and false = .scss\n sourceMap: true\n})") - pkg.dependencies['node-sass-middleware'] = '0.11.0' + pkg.dependencies['node-sass-middleware'] = '1.0.1' break case 'stylus': app.locals.modules.stylus = 'stylus' From 0c4375143da7a029647183fab5d7fde2950e62a1 Mon Sep 17 00:00:00 2001 From: Panu Valtanen Date: Sat, 28 May 2022 11:21:14 +0000 Subject: [PATCH 2/4] Add backwards compatibility for node-sass-middleware dependency. Update node-sass-middleware to version >= 1 when nodejs version is >= 10. This should fix the errors with earlier node versions to pass the tests. --- bin/express-cli.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index d8ef9995..34089d65 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -77,6 +77,16 @@ function copyTemplateMulti (fromDir, toDir, nameGlob) { }) } +/** + * Get Node version. + * @returns {number} Node Major Version + */ + +function getNodeMajorVersion () { + var nodeVersion = process.versions.node.split('.') + return parseInt(nodeVersion[0], 10) +} + /** * Create application at the given directory. * @@ -212,7 +222,15 @@ function createApplication (name, dir, options, done) { case 'sass': app.locals.modules.sassMiddleware = 'node-sass-middleware' app.locals.uses.push("sassMiddleware({\n src: path.join(__dirname, 'public'),\n dest: path.join(__dirname, 'public'),\n indentedSyntax: true, // true = .sass and false = .scss\n sourceMap: true\n})") - pkg.dependencies['node-sass-middleware'] = '1.0.1' + try { + if (getNodeMajorVersion() >= 10) { + pkg.dependencies['node-sass-middleware'] = '1.0.1' + } else { + throw new Error('node-sass-middleware version >=1.0 requires Node.js 10 or higher. Using Node.js 9 or lower.') + } + } catch (e) { + pkg.dependencies['node-sass-middleware'] = '0.11.0' + } break case 'stylus': app.locals.modules.stylus = 'stylus' From 6abc9db86e4401c1d61480d9ca164a3df39e22a7 Mon Sep 17 00:00:00 2001 From: Panu Valtanen Date: Sat, 28 May 2022 13:51:53 +0000 Subject: [PATCH 3/4] Use semver instead of custom function for nodejs version testing. --- bin/express-cli.js | 13 ++----------- package.json | 1 + 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index 34089d65..911b71a8 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -9,6 +9,7 @@ var path = require('path') var readline = require('readline') var sortedObject = require('sorted-object') var util = require('util') +var semver = require('semver') var MODE_0666 = parseInt('0666', 8) var MODE_0755 = parseInt('0755', 8) @@ -77,16 +78,6 @@ function copyTemplateMulti (fromDir, toDir, nameGlob) { }) } -/** - * Get Node version. - * @returns {number} Node Major Version - */ - -function getNodeMajorVersion () { - var nodeVersion = process.versions.node.split('.') - return parseInt(nodeVersion[0], 10) -} - /** * Create application at the given directory. * @@ -223,7 +214,7 @@ function createApplication (name, dir, options, done) { app.locals.modules.sassMiddleware = 'node-sass-middleware' app.locals.uses.push("sassMiddleware({\n src: path.join(__dirname, 'public'),\n dest: path.join(__dirname, 'public'),\n indentedSyntax: true, // true = .sass and false = .scss\n sourceMap: true\n})") try { - if (getNodeMajorVersion() >= 10) { + if (semver.satisfies(process.version, '>=10.0.0')) { pkg.dependencies['node-sass-middleware'] = '1.0.1' } else { throw new Error('node-sass-middleware version >=1.0 requires Node.js 10 or higher. Using Node.js 9 or lower.') diff --git a/package.json b/package.json index c8fb0b19..d52b9583 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "minimatch": "3.0.4", "minimist": "1.2.5", "mkdirp": "0.5.1", + "semver": "^7.3.7", "sorted-object": "2.0.1" }, "main": "bin/express-cli.js", From 839367cd9f80494b2712b1a3cec1f76b68c694f6 Mon Sep 17 00:00:00 2001 From: Panu Valtanen Date: Sat, 28 May 2022 14:00:16 +0000 Subject: [PATCH 4/4] Downgrade semver version to use `var`s --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d52b9583..2bc2b344 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "minimatch": "3.0.4", "minimist": "1.2.5", "mkdirp": "0.5.1", - "semver": "^7.3.7", + "semver": "5.5.0", "sorted-object": "2.0.1" }, "main": "bin/express-cli.js",