Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to npm install #15868

Merged
merged 6 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions generators/client/templates/angular/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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'] %>",
Expand Down
27 changes: 15 additions & 12 deletions generators/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -33,6 +32,7 @@ const packagejs = require('../../package.json');
const constants = require('../generator-constants');
const statistics = require('../statistics');
const { defaultConfig } = require('../generator-defaults');
const { GRADLE, MAVEN } = require('../../jdl/jhipster/build-tool-types');
const { ELASTICSEARCH } = require('../../jdl/jhipster/search-engine-types');

const NO_DATABASE = databaseTypes.NO;
Expand Down Expand Up @@ -64,23 +64,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),
});
}
Expand Down