generator-jhipster-entity-audit icon indicating copy to clipboard operation
generator-jhipster-entity-audit copied to clipboard

Cannot read property 'changelogDate' of undefined

Open devMaheshJava opened this issue 6 years ago • 11 comments

We're generating entities using

jhipster entity EntityName

after entering all the fields and relations, it prompted for entity audit like below

Running post run module hooks

Running JHipster Entity Audit Generator! v3.1.0

? Do you want to enable audit for this entity(PersonCompany)? Yes (selected by me)

then it threw the following error I'm updating the entity for audit PersonCompany events.js:183 throw er; // Unhandled 'error' event ^

TypeError: Cannot read property 'changelogDate' of undefined
    at module.exports.updateFiles (D:\ESA-ws\apps\eti-sap-26-04_merge\node_modules\generator-jhipster-entity-audit\generators\entity\index.js:119:55)
    at Object.<anonymous> (D:\ESA-ws\apps\eti-sap-26-04_merge\node_modules\yeoman-generator\lib\index.js:399:25)
    at D:\ESA-ws\apps\eti-sap-26-04_merge\node_modules\run-async\index.js:25:25
    at new Promise (<anonymous>)
    at D:\ESA-ws\apps\eti-sap-26-04_merge\node_modules\run-async\index.js:24:19
    at self.env.runLoop.add.completed (D:\ESA-ws\apps\eti-sap-26-04_merge\node_modules\yeoman-generator\lib\index.js:400:11)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)

devMaheshJava avatar Apr 29 '18 12:04 devMaheshJava

Which JHipster version are you using?

On Sun, 29 Apr 2018, 2:39 pm devMaheshJava, [email protected] wrote:

We're generating entities using

jhipster entity EntityName after entering all the fields and relations, it prompted for entity audit like below

Running post run module hooks

Running JHipster Entity Audit Generator! v3.1.0

? Do you want to enable audit for this entity(PersonCompany)? Yes (selected by me)

then it threw the following error I'm updating the entity for audit PersonCompany events.js:183 throw er; // Unhandled 'error' event ^

TypeError: Cannot read property 'changelogDate' of undefined at module.exports.updateFiles (D:\ESA-ws\apps\eti-sap-26-04_merge\node_modules\generator-jhipster-entity-audit\generators\entity\index.js:119:55) at Object. (D:\ESA-ws\apps\eti-sap-26-04_merge\node_modules\yeoman-generator\lib\index.js:399:25) at D:\ESA-ws\apps\eti-sap-26-04_merge\node_modules\run-async\index.js:25:25 at new Promise () at D:\ESA-ws\apps\eti-sap-26-04_merge\node_modules\run-async\index.js:24:19 at self.env.runLoop.add.completed (D:\ESA-ws\apps\eti-sap-26-04_merge\node_modules\yeoman-generator\lib\index.js:400:11) at runCallback (timers.js:789:20) at tryOnImmediate (timers.js:751:5) at processImmediate [as _immediateCallback] (timers.js:722:5)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hipster-labs/generator-jhipster-entity-audit/issues/91, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDlF5XR-xcejjAMPkGYCGnwGH3Qo5Uoks5ttbR7gaJpZM4TryQi .

deepu105 avatar Apr 30 '18 06:04 deepu105

sorry @deepu105 I didn't visited github from last 4 days the version is 4.13.3

devMaheshJava avatar May 04 '18 11:05 devMaheshJava

This issue turn up while new entity created. entityConfig data property undefined for new entities.

// generators/enttiy/index.js
118          const jsonObj = this.entityConfig.data;
119          this.changelogDate = this.entityConfig.data.changelogDate || this.dateFormatForLiquibase();

We can change 118,119 and 120 like below:

          var jsonObj = {};
          if(this.entityConfig.data === undefined) {
            jsonObj = {
                "changelogDate": this.entityConfig.changelogDate,
                "entityTableName": this.entityConfig.entityTableName
            }
          } else {
            jsonObj = this.entityConfig.data;
          }
          this.changelogDate = jsonObj.changelogDate || this.dateFormatForLiquibase();

mkysoft avatar May 28 '18 09:05 mkysoft

Not sure if this helps, but I've experienced this in 7.0.1 and the fix was to remove the entities from the .yo-rc.json and then they could be added back as entities using the entity json files.

ryandanieldonovan avatar May 27 '21 18:05 ryandanieldonovan

Same problem here in 7.0.1 .. problem solved by removing entities in .yo-rc.json like proposed by @ryandanieldonovan

wael-sakhri avatar Jun 21 '21 10:06 wael-sakhri

Also having the same problem with 7.1.0 on an existing 6.10.1 monolith project using jhipster upgrade :

WARNING! Unable to parse /Users/redacted/Projects/com.github/redacted/prj/.jhipster/App.json, is the entity file malformed or invalid? ERROR! Cannot read property 'changelogDate' of undefined TypeError: Cannot read property 'changelogDate' of undefined at isBefore (/Users/redacted/Projects/com.github/redacted/prj/node_modules/generator-jhipster/generators/generator-base.js:1561:28) at Array.sort (<anonymous>) at module.exports.getExistingEntities (/Users/redacted/Projects/com.github/redacted/prj/node_modules/generator-jhipster/generators/generator-base.js:1583:8) at module.exports.getExistingEntityNames (/Users/redacted/Projects/com.github/redacted/prj/node_modules/generator-jhipster/generators/generator-base.js:1536:17) at new module.exports (/Users/redacted/Projects/com.github/redacted/prj/node_modules/generator-jhipster/generators/entities/index.js:108:36) at Environment.instantiate (/Users/redacted/Projects/com.github/redacted/prj/node_modules/yeoman-environment/lib/environment.js:794:23) at Environment.create (/Users/redacted/Projects/com.github/redacted/prj/node_modules/yeoman-environment/lib/environment.js:766:17) at Environment.composeWith (/Users/redacted/Projects/com.github/redacted/prj/node_modules/yeoman-environment/lib/environment.js:818:36) at JHipsterAppGenerator.composeWithJHipster (/Users/redacted/Projects/com.github/redacted/prj/node_modules/generator-jhipster/generators/generator-base.js:1497:21) at JHipsterAppGenerator.composeEntities (/Users/redacted/Projects/com.github/redacted/prj/node_modules/generator-jhipster/generators/app/index.js:447:14) at Object.<anonymous> (/Users/redacted/Projects/com.github/redacted/prj/node_modules/yeoman-generator/lib/index.js:1024:25) at /Users/redacted/Projects/com.github/redacted/prj/node_modules/run-async/index.js:49:25 at new Promise (<anonymous>) at /Users/redacted/Projects/com.github/redacted/prj/node_modules/run-async/index.js:26:19 at runLoop.add.once.once (/Users/redacted/Projects/com.github/redacted/prj/node_modules/yeoman-generator/lib/index.js:1025:11) at Immediate.<anonymous> (/Users/redacted/Projects/com.github/redacted/prj/node_modules/grouped-queue/lib/subqueue.js:48:34) ERROR! Something went wrong while generating project! Error: Command failed: "/Users/redacted/Projects/com.github/redacted/prj/node_modules/.bin/jhipster" --with-entities --force --skip-install --skip-git --no-insight Error: Something went wrong while generating project! Error: Command failed: "/Users/redacted/Projects/com.github/redacted/prj/node_modules/.bin/jhipster" --with-entities --force --skip-install --skip-git --no-insight at module.exports.error (/Users/redacted/.nvm/versions/node/v14.17.0/lib/node_modules/generator-jhipster/generators/generator-base.js:1788:11) at module.exports._generate (/Users/redacted/.nvm/versions/node/v14.17.0/lib/node_modules/generator-jhipster/generators/upgrade/index.js:174:12) at module.exports._regenerate (/Users/redacted/.nvm/versions/node/v14.17.0/lib/node_modules/generator-jhipster/generators/upgrade/index.js:190:10) at module.exports.generateWithTargetVersion (/Users/redacted/.nvm/versions/node/v14.17.0/lib/node_modules/generator-jhipster/generators/upgrade/index.js:478:14) at Object.<anonymous> (/Users/redacted/.nvm/versions/node/v14.17.0/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/lib/index.js:1024:25) at /Users/redacted/.nvm/versions/node/v14.17.0/lib/node_modules/generator-jhipster/node_modules/run-async/index.js:49:25 at new Promise (<anonymous>) at /Users/redacted/.nvm/versions/node/v14.17.0/lib/node_modules/generator-jhipster/node_modules/run-async/index.js:26:19 at runLoop.add.once.once (/Users/redacted/.nvm/versions/node/v14.17.0/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/lib/index.js:1025:11) at Immediate.<anonymous> (/Users/redacted/.nvm/versions/node/v14.17.0/lib/node_modules/generator-jhipster/node_modules/grouped-queue/lib/subqueue.js:48:34)

steveswing avatar Jun 22 '21 05:06 steveswing

The issue is still there in JHipster 7.2.0. I created a repo that demonstrates the bug and filed it as a new issue over here.

ksilz avatar Oct 08 '21 11:10 ksilz

If you know what the issue is, a PR would be appreciated.

Thanks & Regards, Deepu

On Fri, Oct 8, 2021 at 1:13 PM Karsten Silz @.***> wrote:

The issue is still there in JHipster 7.2.0. I created a repo that demonstrates the bug and filed it as a new issue over here https://github.com/jhipster/generator-jhipster/issues/16613.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hipster-labs/generator-jhipster-entity-audit/issues/91#issuecomment-938557873, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIOKF4UMJ5YOWTDCXK2SELUF3G65ANCNFSM4E5PEQRA .

deepu105 avatar Oct 08 '21 11:10 deepu105

The same issue with 7.2.0 - thanks to Ryan Donovan for the suggestion above, deleting all items form the entities array in .yo-rc.json, then committing the changes, then running JHipster Online / Apply JDL Model worked correctly.

piprog avatar Oct 10 '21 19:10 piprog

I think the root issue is that the entities array of .yo-rc.json contains an entity that has no matching file in the .jhipster directory. To fix it, remove the entity (or entities) from the entities array of .yo-rc.json that have no matching file in the .jhipster directory.

ksilz avatar Oct 11 '21 05:10 ksilz

@ksilz is on to something: it is definitely the otherwise deleted entity hanging around in the entity list in .yo-rc.json - which begs the question: wouldn't it be nice to have a delete entity command? :)

piprog avatar Nov 04 '21 22:11 piprog