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

fix ci-cd prompts #24568

Merged
merged 2 commits into from
Dec 15, 2023
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
46 changes: 23 additions & 23 deletions generators/ci-cd/ci-cd.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(mavenSample)
.withAnswers({
ciCd: 'jenkins',
ciCd: ['jenkins'],
insideDocker: false,
ciCdIntegrations: [],
})
Expand All @@ -63,7 +63,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(gradleSample)
.withAnswers({
ciCd: 'jenkins',
ciCd: ['jenkins'],
insideDocker: false,
ciCdIntegrations: [],
})
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -163,7 +163,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(mavenSample)
.withAnswers({
ciCd: 'gitlab',
ciCd: ['gitlab'],
insideDocker: false,
ciCdIntegrations: [],
})
Expand All @@ -189,7 +189,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(gradleSample)
.withAnswers({
ciCd: 'gitlab',
ciCd: ['gitlab'],
ciCdIntegrations: [],
})
.run();
Expand All @@ -214,7 +214,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(skipServerSample)
.withAnswers({
ciCd: 'gitlab',
ciCd: ['gitlab'],
insideDocker: true,
ciCdIntegrations: [],
})
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -338,7 +338,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(mavenSample)
.withAnswers({
ciCd: 'travis',
ciCd: ['travis'],
ciCdIntegrations: [],
})
.run();
Expand All @@ -361,7 +361,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(gradleSample)
.withAnswers({
ciCd: 'travis',
ciCd: ['travis'],
ciCdIntegrations: [],
})
.run();
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -431,7 +431,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(mavenSample)
.withAnswers({
ciCd: 'azure',
ciCd: ['azure'],
ciCdIntegrations: ['cypressDashboard'],
})
.run();
Expand All @@ -456,7 +456,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(gradleSample)
.withAnswers({
ciCd: 'azure',
ciCd: ['azure'],
ciCdIntegrations: [],
})
.run();
Expand All @@ -479,7 +479,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(mavenSample)
.withAnswers({
ciCd: 'azure',
ciCd: ['azure'],
ciCdIntegrations: ['snyk'],
})
.run();
Expand All @@ -501,7 +501,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(gradleSample)
.withAnswers({
ciCd: 'azure',
ciCd: ['azure'],
ciCdIntegrations: ['snyk'],
})
.run();
Expand Down Expand Up @@ -541,7 +541,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(mavenSample)
.withAnswers({
ciCd: 'github',
ciCd: ['github'],
ciCdIntegrations: [],
})
.run();
Expand All @@ -560,7 +560,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(gradleSample)
.withAnswers({
ciCd: 'github',
ciCd: ['github'],
ciCdIntegrations: [],
})
.run();
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -671,7 +671,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(mavenSample)
.withAnswers({
ciCd: 'circle',
ciCd: ['circle'],
ciCdIntegrations: ['cypressDashboard'],
})
.run();
Expand All @@ -697,7 +697,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(gradleSample)
.withAnswers({
ciCd: 'circle',
ciCd: ['circle'],
ciCdIntegrations: [],
})
.run();
Expand All @@ -723,7 +723,7 @@ describe('generator - CI-CD', () => {
.createJHipster(GENERATOR_CI_CD)
.withJHipsterConfig(mavenSample)
.withAnswers({
ciCd: 'circle',
ciCd: ['circle'],
ciCdIntegrations: ['snyk'],
})
.run();
Expand Down
12 changes: 8 additions & 4 deletions generators/ci-cd/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand Down Expand Up @@ -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),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mshima It should includes also 'github', 'gitlab', 'travis'?

Copy link
Member Author

@mshima mshima Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even not sure travis is well or maintained at all. I haven't used it for a long time.

type: 'input',
message: `${chalk.yellow('*Sonar*')}: what is the name of the Sonar server ?`,
},
Expand All @@ -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 ?`,
},
Expand All @@ -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 ?`,
},
Expand Down
Loading