Generator-jhipster: Subgenerator CI/CD fails with SyntaxError referring repeaded Map key "dispalyName"

Created on 13 Dec 2019  路  9Comments  路  Source: jhipster/generator-jhipster

Overview of the issue

If I try to do jhipster ci-cd for Azure Pipelines it fails

> jhipster ci-cd
INFO! Using JHipster version installed locally in current project's node_modules
INFO! Executing jhipster:ci-cd
INFO! Options: from-cli: true
馃殌 Welcome to the JHipster CI/CD Sub-Generator 馃殌
? What CI/CD pipeline do you want to generate? Azure Pipelines
SyntaxError: Map keys must be unique; "displayName" is repeated (29:5)
  27 |   # Tests
  28 |   #----------------------------------------------------------------------
> 29 |   - script: npm install
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 30 |     displayName: 'INSTALL: launch npm install'
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 31 |     displayName: 'TESTS: backend'
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 32 |     displayName: 'TESTS: frontend'
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 33 |     displayName: 'TESTS: packaging'
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 34 |
##### **Motivation for or Use Case** Well, I can not generate Azure CI-CD pipelines. ##### **Reproduce the error** 1. Generate simple frontend only project `jhipster --skip-server` 1. Execute `jhipster ci-cd` 1. Choose Azure Pipelines ##### **JHipster Version(s)**
[email protected] D:\ACTTool\Repos\App-ACTTool-FrontEnd-SysAdmin
`-- [email protected]

##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "6.5.1",
    "applicationType": "monolith",
    "baseName": "ACTTool",
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "react",
    "clientTheme": "cosmo",
    "clientThemeVariant": "light",
    "authenticationType": "jwt",
    "cacheProvider": "no",
    "databaseType": "mongodb",
    "devDatabaseType": "mongodb",
    "prodDatabaseType": "mongodb",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": [
      "en",
      "fr",
      "de"
    ],
    "blueprints": [],
    "skipServer": true
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory


JDL entity definitions


Environment and Tools

java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)

git version 2.22.0.windows.1

node: v13.2.0

npm: 6.13.1

Docker version 19.03.5, build 633a0ea

docker-compose version 1.24.1, build 4667896b

Browsers and Operating System

Browser: Chrome
OS: Windows 10
Shell: Powershell

  • [x] Checking this box is mandatory (this is just to show you read everything)
$$ bug-bounty $$ $100 area Continuous Integration

Most helpful comment

@SudharakaP I can take this one if no one else has it. Would be a nice one to get some initial exposure :)

All 9 comments

I've recreated this error. Currently investigating. Seems like something related to prettier. This not only effects this sub-generator but also other sub-generators I believe. For example use the gae sub-generator and a similar error appears.

SyntaxError: Map keys must be unique; "displayName" is repeated (29:5)
  27 |   # Tests
  28 |   #----------------------------------------------------------------------
> 29 |   - script: npm install
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 30 |     displayName: 'INSTALL: launch npm install'
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 31 |     displayName: 'TESTS: backend'
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 32 |     displayName: 'TESTS: frontend'
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 33 |     displayName: 'TESTS: packaging'
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 34 | 
     | ^
    at e (/home/sudharaka/IdeaProjects/generator-jhipster/node_modules/prettier/parser-yaml.js:1:261)
    at Object.parse (/home/sudharaka/IdeaProjects/generator-jhipster/node_modules/prettier/parser-yaml.js:1:135253)
    at Object.parse$2 [as parse] (/home/sudharaka/IdeaProjects/generator-jhipster/node_modules/prettier/index.js:10629:19)
    at coreFormat (/home/sudharaka/IdeaProjects/generator-jhipster/node_modules/prettier/index.js:13888:23)
    at format (/home/sudharaka/IdeaProjects/generator-jhipster/node_modules/prettier/index.js:14146:73)
    at formatWithCursor (/home/sudharaka/IdeaProjects/generator-jhipster/node_modules/prettier/index.js:14162:12)
    at /home/sudharaka/IdeaProjects/generator-jhipster/node_modules/prettier/index.js:42756:15
    at Object.format (/home/sudharaka/IdeaProjects/generator-jhipster/node_modules/prettier/index.js:42775:12)
    at /home/sudharaka/IdeaProjects/generator-jhipster/generators/generator-transforms.js:44:39

Problem is that if skipping server then buildTool is not defined.

So https://github.com/jhipster/generator-jhipster/blob/master/generators/ci-cd/templates/azure-pipelines.yml.ejs#L69-L73 doesn't generate script part - maybe use npm/yarn directly here instead of doing that via gradle/maven?

And https://github.com/jhipster/generator-jhipster/blob/master/generators/ci-cd/templates/azure-pipelines.yml.ejs#L76-L80 - if server side is not generated then this probably needs to be excluded with condition if (!skipServer)

@kaidohallik : But I was wondering aren't we supposed to ignore the template files as per; https://github.com/jhipster/generator-jhipster/blob/master/.prettierignore and therefore these files shouldn't even be parse by prettier? :thinking:

@SudharakaP We ignore the templates folder when running prettier on the generator, but we pass each template file through prettier during generation: https://github.com/jhipster/generator-jhipster/blob/ba88f1424ddffd08589377a1dba9e432ceaa8a0b/generators/generator-base-private.js#L1502-L1511

@ruddell : Ah thanks, got it. 馃槃

Let me do a fix for this in the evening. If anyone wants to do it before that feel free to do so. 馃槃

Just added the label bug as @SudharakaP managed to reproduce the issue
And adding a bounty, as it's a bug

@SudharakaP I can take this one if no one else has it. Would be a nice one to get some initial exposure :)

@bradsheppard : Hey Brad. By all means go ahead. Thanks for contributing. 馃槃 馃槃

We also need to do similar fix on the github ci template. I will spend some time today / tomorrow to fix that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

frantzynicolas picture frantzynicolas  路  3Comments

lsadehaan picture lsadehaan  路  3Comments

sdoxsee picture sdoxsee  路  4Comments

trajakovic picture trajakovic  路  4Comments

RizziCR picture RizziCR  路  3Comments