jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.46k stars 4.02k forks source link

Jhipster blueprint - Base server generators package.json's 'scripts' data not available to blueprints client generator #19158

Closed dwarakaprasad closed 2 years ago

dwarakaprasad commented 2 years ago
Overview of the issue

I am writing a blue print to replace

  1. Jhipster's angular UI (client sub-generator)
  2. Modify the spring-boot backend (add new endpoints in the server sub-generator) to support the new UI.

I have completed the angular part and now in the process of modifying the server side

My current Setup: (highlighting only the important part)

jhipster-myblueprint
  generators
    app
    common
    client
      templates
        package.json
      ...everything else need for client
    server
      template
        no package.json file**
        other templates
      file.js (containing only the modified templates)

The code generation works fine and I am able to bring the application up and able to access the new front end. The issue is in the generated code, specifically in the package.json file, the script part only contains the client side scripts and none of the server side scripts (built in the server's 'postWriting' phase) are available

What I understood from Jhipster's code: On the server sub-generator, during the 'postWriting' phase, the server's 'scripts' part of the package.json file is built/modified based on the user selected options (db, auth, e2e, etc) and a similar technique is followed on the client sub-generator, at the end the generated package.json file contains both the 'scripts'.

What I am trying to achieve: Combine the blueprints UI scripts with the Jhipster's server scripts and have them in the generated code (package.json). Unfortunately I only see the blueprints client scripts.

My research: Case1: When running Jhipster without the blueprint, the following is the call stack,

  1. Server's write priority
  2. Client's write priority
  3. Server's posWriting priority
  4. Client's postWriting priority

Case 2: The following is the call stack with blueprint

  1. Jhipster's server write
  2. Jhipster's server postwriting
  3. blueprint's server write
  4. blueprint's client write
  5. blueprint's client postwriting

In both the cases the server's write priority does not create/write package.json file (because the skipClient is undefined there), but in case 1 the server's write is followed by the client's write which creates the package.json file and is then available to the 'postWriting' of both server and client (I am assuming this is how the servers script are visible to the client).

But in case 2, the server's postWriting (2) doesn't have a package.json file and so what ever was added to the 'scripts' is flushed when the blueprint's client write phase (4) creates a new package.json file which is then available to blueprints 'postwriting' which has no access to the server's 'scripts'. (this is purely my speculation).

Motivation for or Use Case

Need this to have a proper package.json

Reproduce the error
Related issues
Suggest a Fix
JHipster Version(s): 7.8.1
JHipster configuration
Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System
mshima commented 2 years ago

You should post a repro. I am not sure it's possible to reproduce with current information.

dwarakaprasad commented 2 years ago

Thankyou @mshima for your response. I was able to get both server & client scripts generated this morning by simply calling the super._postWriting() from the blueprint's server sub-generator (I dint realize that it wasn't being called in the first place and was looking all over).

This is not an issue and I am closing this.

Thank you once again...