From f384be06f14d0fa43fe3d381fc6ac33340699b78 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Thu, 5 Aug 2021 15:43:00 -0300 Subject: [PATCH 1/5] Execute customInstallTask for maven and gradle only. --- generators/server/index.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/generators/server/index.js b/generators/server/index.js index a00c429329a0..61bb0230d8d0 100644 --- a/generators/server/index.js +++ b/generators/server/index.js @@ -28,7 +28,7 @@ const constants = require('../generator-constants'); const statistics = require('../statistics'); const { getBase64Secret, getRandomHex } = require('../utils'); const { defaultConfig } = require('../generator-defaults'); -const { GRADLE } = require('../../jdl/jhipster/build-tool-types'); +const { GRADLE, MAVEN } = require('../../jdl/jhipster/build-tool-types'); const { ELASTICSEARCH } = require('../../jdl/jhipster/search-engine-types'); let useBlueprints; @@ -58,23 +58,26 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator { // Not using normal blueprints or this is a normal blueprint. if (!useBlueprints || (this.fromBlueprint && this.sbsBlueprint)) { this.setFeatures({ - customInstallTask: function customInstallTask(preferredPm, defaultInstallTask) { - if ((preferredPm && preferredPm !== 'npm') || this.skipClient || this.jhipsterConfig.skipClient) { + customInstallTask: async function customInstallTask(preferredPm, defaultInstallTask) { + const buildTool = this.jhipsterConfig.buildTool; + if ( + (preferredPm && preferredPm !== 'npm') || + this.skipClient || + this.jhipsterConfig.skipClient || + (buildTool !== GRADLE && buildTool !== MAVEN) + ) { return defaultInstallTask(); } - const gradle = this.jhipsterConfig.buildTool === GRADLE; + const gradle = buildTool === GRADLE; const command = gradle ? './gradlew' : './npmw'; const args = gradle ? ['npmInstall'] : ['install']; - const failureCallback = error => { + try { + await this.spawnCommand(command, args, { preferLocal: true }); + } catch (error) { this.log(chalk.red(`Error executing '${command} ${args.join(' ')}', execute it yourself. (${error.shortMessage})`)); - return true; - }; - - return this.spawnCommand(command, args, { preferLocal: true }).then( - () => true, - error => failureCallback(error) - ); + } + return true; }.bind(this), }); } From 17d0af7fe8b6c86750659d640d7b1ce52194b2d3 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Thu, 5 Aug 2021 15:44:23 -0300 Subject: [PATCH 2/5] Add @angular-devkit/build-angular dep to match @angular/cli version --- generators/client/templates/angular/package.json.ejs | 1 + 1 file changed, 1 insertion(+) diff --git a/generators/client/templates/angular/package.json.ejs b/generators/client/templates/angular/package.json.ejs index 2042a9281e9e..f2eb4db58cec 100644 --- a/generators/client/templates/angular/package.json.ejs +++ b/generators/client/templates/angular/package.json.ejs @@ -99,6 +99,7 @@ "@angular/compiler-cli": "<%= dependabotPackageJson.dependencies['@angular/common'] %>", "@angular-builders/custom-webpack": "<%= dependabotPackageJson.devDependencies['@angular-builders/custom-webpack'] %>", "@angular-builders/jest": "<%= dependabotPackageJson.devDependencies['@angular-builders/jest'] %>", + "@angular-devkit/build-angular": "<%= dependabotPackageJson.devDependencies['@angular/cli'] %>", "@angular/service-worker": "<%= dependabotPackageJson.dependencies['@angular/common'] %>", "@angular-eslint/eslint-plugin": "<%= dependabotPackageJson.devDependencies['@angular-eslint/eslint-plugin'] %>", "@types/jest": "<%= dependabotPackageJson.devDependencies['@types/jest'] %>", From f6f9a9a78474eb51aab0c7971e8c0f9773e41ae7 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Thu, 5 Aug 2021 15:45:14 -0300 Subject: [PATCH 3/5] Use npm dedupe instead of npm install for new projects with maven. --- generators/server/index.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/generators/server/index.js b/generators/server/index.js index 61bb0230d8d0..9c63047d6269 100644 --- a/generators/server/index.js +++ b/generators/server/index.js @@ -18,6 +18,7 @@ */ /* eslint-disable consistent-return */ const chalk = require('chalk'); +const { stat } = require('fs').promises; const _ = require('lodash'); const os = require('os'); const prompts = require('./prompts'); @@ -68,9 +69,25 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator { ) { return defaultInstallTask(); } + const newInstall = await stat(this.destinationPath('package-lock.json')) + .then( + () => false, + () => stat(this.destinationPath('node_modules')) + ) + .then( + () => false, + () => true + ); const gradle = buildTool === GRADLE; const command = gradle ? './gradlew' : './npmw'; - const args = gradle ? ['npmInstall'] : ['install']; + let args; + if (gradle) { + args = ['npmInstall']; + } else if (newInstall) { + args = ['dedupe']; + } else { + args = ['install']; + } try { await this.spawnCommand(command, args, { preferLocal: true }); From d18ba20c854ed0688696251f8634052b3e9dffc6 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sat, 7 Aug 2021 16:52:03 -0300 Subject: [PATCH 4/5] Revert "Use npm dedupe instead of npm install for new projects with maven." This reverts commit f6f9a9a78474eb51aab0c7971e8c0f9773e41ae7. --- generators/server/index.js | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/generators/server/index.js b/generators/server/index.js index 9c63047d6269..61bb0230d8d0 100644 --- a/generators/server/index.js +++ b/generators/server/index.js @@ -18,7 +18,6 @@ */ /* eslint-disable consistent-return */ const chalk = require('chalk'); -const { stat } = require('fs').promises; const _ = require('lodash'); const os = require('os'); const prompts = require('./prompts'); @@ -69,25 +68,9 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator { ) { return defaultInstallTask(); } - const newInstall = await stat(this.destinationPath('package-lock.json')) - .then( - () => false, - () => stat(this.destinationPath('node_modules')) - ) - .then( - () => false, - () => true - ); const gradle = buildTool === GRADLE; const command = gradle ? './gradlew' : './npmw'; - let args; - if (gradle) { - args = ['npmInstall']; - } else if (newInstall) { - args = ['dedupe']; - } else { - args = ['install']; - } + const args = gradle ? ['npmInstall'] : ['install']; try { await this.spawnCommand(command, args, { preferLocal: true }); From c6b4cba2bcfddee7e86075a284e00ea4f4ea2c52 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sun, 8 Aug 2021 08:11:22 -0300 Subject: [PATCH 5/5] Update index.js --- generators/server/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/generators/server/index.js b/generators/server/index.js index 9aa049a6f0f1..292503d6d52f 100644 --- a/generators/server/index.js +++ b/generators/server/index.js @@ -24,7 +24,6 @@ const prompts = require('./prompts'); const { GENERATOR_COMMON, GENERATOR_LANGUAGES, GENERATOR_SERVER } = require('../generator-list'); const databaseTypes = require('../../jdl/jhipster/database-types'); const { OAUTH2, SESSION } = require('../../jdl/jhipster/authentication-types'); -const { GRADLE, MAVEN } = require('../../jdl/jhipster/build-tool-types'); const { CASSANDRA, COUCHBASE, MARIADB, MSSQL, MYSQL, ORACLE, POSTGRESQL, SQL } = require('../../jdl/jhipster/database-types'); const { CAFFEINE, EHCACHE, HAZELCAST, INFINISPAN, MEMCACHED, REDIS } = require('../../jdl/jhipster/cache-types'); const BaseBlueprintGenerator = require('../generator-base-blueprint');