diff --git a/generators/ci-cd/ci-cd.spec.ts b/generators/ci-cd/ci-cd.spec.ts index 1b935e5bc3a4..79c020e3435f 100644 --- a/generators/ci-cd/ci-cd.spec.ts +++ b/generators/ci-cd/ci-cd.spec.ts @@ -37,7 +37,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(mavenSample) .withAnswers({ - ciCd: 'jenkins', + ciCd: ['jenkins'], insideDocker: false, ciCdIntegrations: [], }) @@ -63,7 +63,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(gradleSample) .withAnswers({ - ciCd: 'jenkins', + ciCd: ['jenkins'], insideDocker: false, ciCdIntegrations: [], }) @@ -90,7 +90,7 @@ describe('generator - CI-CD', () => { .withJHipsterConfig(mavenSample) .withFiles({ 'pom.xml': pomFile }) .withAnswers({ - ciCd: 'jenkins', + ciCd: ['jenkins'], insideDocker: false, ciCdIntegrations: ['deploy', 'sonar', 'publishDocker', 'heroku', 'snyk'], artifactorySnapshotsId: 'snapshots', @@ -125,7 +125,7 @@ describe('generator - CI-CD', () => { .withJHipsterConfig(mavenSample) .withFiles({ 'pom.xml': pomFile }) .withAnswers({ - ciCd: 'jenkins', + ciCd: ['jenkins'], insideDocker: true, ciCdIntegrations: ['deploy', 'sonar', 'publishDocker', 'heroku', 'snyk'], artifactorySnapshotsId: 'snapshots', @@ -163,7 +163,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(mavenSample) .withAnswers({ - ciCd: 'gitlab', + ciCd: ['gitlab'], insideDocker: false, ciCdIntegrations: [], }) @@ -189,7 +189,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(gradleSample) .withAnswers({ - ciCd: 'gitlab', + ciCd: ['gitlab'], ciCdIntegrations: [], }) .run(); @@ -214,7 +214,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(skipServerSample) .withAnswers({ - ciCd: 'gitlab', + ciCd: ['gitlab'], insideDocker: true, ciCdIntegrations: [], }) @@ -238,7 +238,7 @@ describe('generator - CI-CD', () => { .withJHipsterConfig(mavenSample) .withFiles({ 'pom.xml': pomFile }) .withAnswers({ - ciCd: 'gitlab', + ciCd: ['gitlab'], insideDocker: false, ciCdIntegrations: ['deploy', 'sonar', 'heroku', 'snyk'], artifactorySnapshotsId: 'snapshots', @@ -273,7 +273,7 @@ describe('generator - CI-CD', () => { .withJHipsterConfig(mavenSample) .withFiles({ 'pom.xml': pomFile }) .withAnswers({ - ciCd: 'gitlab', + ciCd: ['gitlab'], insideDocker: true, ciCdIntegrations: ['deploy', 'sonar', 'heroku', 'snyk'], artifactorySnapshotsId: 'snapshots', @@ -338,7 +338,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(mavenSample) .withAnswers({ - ciCd: 'travis', + ciCd: ['travis'], ciCdIntegrations: [], }) .run(); @@ -361,7 +361,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(gradleSample) .withAnswers({ - ciCd: 'travis', + ciCd: ['travis'], ciCdIntegrations: [], }) .run(); @@ -389,7 +389,7 @@ describe('generator - CI-CD', () => { .withJHipsterConfig(mavenSample) .withFiles({ 'pom.xml': pomFile }) .withAnswers({ - ciCd: 'travis', + ciCd: ['travis'], ciCdIntegrations: ['deploy', 'sonar', 'heroku', 'snyk', 'cypressDashboard'], artifactorySnapshotsId: 'snapshots', artifactorySnapshotsUrl: 'http://artifactory:8081/artifactory/libs-snapshot', @@ -431,7 +431,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(mavenSample) .withAnswers({ - ciCd: 'azure', + ciCd: ['azure'], ciCdIntegrations: ['cypressDashboard'], }) .run(); @@ -456,7 +456,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(gradleSample) .withAnswers({ - ciCd: 'azure', + ciCd: ['azure'], ciCdIntegrations: [], }) .run(); @@ -479,7 +479,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(mavenSample) .withAnswers({ - ciCd: 'azure', + ciCd: ['azure'], ciCdIntegrations: ['snyk'], }) .run(); @@ -501,7 +501,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(gradleSample) .withAnswers({ - ciCd: 'azure', + ciCd: ['azure'], ciCdIntegrations: ['snyk'], }) .run(); @@ -541,7 +541,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(mavenSample) .withAnswers({ - ciCd: 'github', + ciCd: ['github'], ciCdIntegrations: [], }) .run(); @@ -560,7 +560,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(gradleSample) .withAnswers({ - ciCd: 'github', + ciCd: ['github'], ciCdIntegrations: [], }) .run(); @@ -580,7 +580,7 @@ describe('generator - CI-CD', () => { .withJHipsterConfig(mavenSample) .withFiles({ 'pom.xml': pomFile }) .withAnswers({ - ciCd: 'github', + ciCd: ['github'], ciCdIntegrations: ['deploy', 'sonar', 'publishDocker', 'heroku', 'snyk', 'cypressDashboard'], dockerImage: 'jhipster-publish-docker', artifactorySnapshotsId: 'snapshots', @@ -620,7 +620,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(gradleSample) .withAnswers({ - ciCd: 'github', + ciCd: ['github'], ciCdIntegrations: ['sonar', 'publishDocker', 'heroku', 'snyk'], dockerImage: 'jhipster-publish-docker', sonarUrl: 'http://sonar.com:9000', @@ -671,7 +671,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(mavenSample) .withAnswers({ - ciCd: 'circle', + ciCd: ['circle'], ciCdIntegrations: ['cypressDashboard'], }) .run(); @@ -697,7 +697,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(gradleSample) .withAnswers({ - ciCd: 'circle', + ciCd: ['circle'], ciCdIntegrations: [], }) .run(); @@ -723,7 +723,7 @@ describe('generator - CI-CD', () => { .createJHipster(GENERATOR_CI_CD) .withJHipsterConfig(mavenSample) .withAnswers({ - ciCd: 'circle', + ciCd: ['circle'], ciCdIntegrations: ['snyk'], }) .run(); diff --git a/generators/ci-cd/command.ts b/generators/ci-cd/command.ts index a42269a2668c..8db9de14f2df 100644 --- a/generators/ci-cd/command.ts +++ b/generators/ci-cd/command.ts @@ -22,7 +22,7 @@ import { JHipsterCommandDefinition } from '../base/api.js'; const { kebabCase, intersection } = _; -const includesValue = (prop, values) => answers => answers[prop] && intersection(answers[prop], values); +const includesValue = (prop, values) => answers => answers[prop] && intersection(answers[prop], values).length > 0; const command: JHipsterCommandDefinition = { options: {}, @@ -133,7 +133,7 @@ const command: JHipsterCommandDefinition = { }, sonarName: { prompt: { - when: answers => includesValue('ciCd', ['jenkins'])(answers) && includesValue('ciCdIntegrations', ['ciCdIntegrations'])(answers), + when: answers => includesValue('ciCd', ['jenkins'])(answers) && includesValue('ciCdIntegrations', ['sonar'])(answers), type: 'input', message: `${chalk.yellow('*Sonar*')}: what is the name of the Sonar server ?`, }, @@ -142,7 +142,9 @@ const command: JHipsterCommandDefinition = { }, sonarUrl: { prompt: { - when: answers => includesValue('ciCd', ['jenkins'])(answers) && includesValue('ciCdIntegrations', ['ciCdIntegrations'])(answers), + when: answers => + includesValue('ciCd', ['jenkins', 'github', 'gitlab', 'travis'])(answers) && + includesValue('ciCdIntegrations', ['sonar'])(answers), type: 'input', message: `${chalk.yellow('*Sonar*')}: what is the URL of the Sonar server ?`, }, @@ -151,7 +153,9 @@ const command: JHipsterCommandDefinition = { }, sonarOrga: { prompt: { - when: answers => includesValue('ciCd', ['jenkins'])(answers) && includesValue('ciCdIntegrations', ['ciCdIntegrations'])(answers), + when: answers => + includesValue('ciCd', ['jenkins', 'github', 'gitlab', 'travis'])(answers) && + includesValue('ciCdIntegrations', ['sonar'])(answers), type: 'input', message: `${chalk.yellow('*Sonar*')}: what is the Organization of the Sonar server ?`, },