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

make Heroku sub generator blueprint aware #11919

Merged

Conversation

atomfrede
Copy link
Member

This makes the Heroku sub generator extend BaseBlueprintGenerator, such that blueprints can overwrite e.g. generated property files to match their own configuration. A concrete use case can be found in the micronaut blueprint where e.g. the datasource properties and the procfile is different from the main generator.

@atomfrede atomfrede merged commit b24652d into jhipster:master Jun 9, 2020
@atomfrede
Copy link
Member Author

Thanks for approving. I have problem applying it to the micronaut blueprint (although it worked once during testing this PR).

when doing jhipster heroku --blueprints micronaut I get the following:

INFO! Executing jhipster:heroku
     info Using blueprint generator-jhipster-micronaut for heroku subgenerator
TypeError: (intermediate value)._initializing is not a function
    at module.exports.get initializing [as initializing] (/home/fred/git/github/jhipster/generator-jhipster-micronaut/generators/heroku/index.js:21:22)
    at module.exports.queueOwnTask (/home/fred/git/github/jhipster/generator-jhipster-micronaut/node_modules/yeoman-generator/lib/index.js:797:65)
    at /home/fred/git/github/jhipster/generator-jhipster-micronaut/node_modules/yeoman-generator/lib/index.js:843:45
    at Array.forEach (<anonymous>)
    at module.exports.queueOwnTasks (/home/fred/git/github/jhipster/generator-jhipster-micronaut/node_modules/yeoman-generator/lib/index.js:843:18)
    at /home/fred/git/github/jhipster/generator-jhipster-micronaut/node_modules/yeoman-generator/lib/index.js:1024:12
    at new Promise (<anonymous>)
    at module.exports.runWithOptions (/home/fred/git/github/jhipster/generator-jhipster-micronaut/node_modules/yeoman-generator/lib/index.js:1004:21)
    at runGenerator (/home/fred/git/github/jhipster/generator-jhipster/node_modules/yeoman-generator/lib/index.js:34:15)
    at Array.forEach (<anonymous>)

It looks like some trivial thing I forgot here, but I don't see it. I tried already to replace the heroku subgen in the blueprint with basically a noop generator, but still no luck. I also did change the heroku subgen in the main generator with a subgen that works for micronaut (e.g. service), but when creating the heroku gen in the blueprint via instantiateBlueprints I get again that message. So I am a bit confused where the error is, main generator (don't think so), micronaut blueprint (not sure) or in my local testing environment.

I did npm link on both projects and npm link generator-jhipster on the micronaut blueprint. In the folder I did a npm link generator-jhipster-micronaut and npm link generator-jhipster and I can see the up-to-date code in the node_modules folder.

@kaidohallik
Copy link
Contributor

I also encounter strange npm link behaviour (I'm on Windows) when using linked module. My anomaly seems to be different but just in case describing that and workaroud to fix this in my case.

First step:

  • going to generator-jhipster folder
  • running npm link

Second step:

  • going to module folder
  • running npm link
  • running npm link generator-jhipster

This second step deletes 38 folders from generator-jhipster/node_modules and running jhipster gives errors due to missing modules in node_modules folder.

If I run this second step in different order:

  • first npm link generator-jhipster
  • second npm link

then result is the same, 38 folders are deleted from generator-jhipster/node_modules

Third step:

  • going to generator-jhipster folder again
  • running npm link again

This restores those 38 deleted folders in node_modules and jhipster is running successfully after that and local generator-jhipster and module are used in generation.

@mshima
Copy link
Member

mshima commented Jun 10, 2020

Those npm link problems are npm 6 problems and can be fixed by running npm ci on generator-jhipster every time npm link is executed or using yeoman plugin notation.

@atomfrede if that problem persists post you updated branch.
The PR seems right.

@atomfrede
Copy link
Member Author

Thanks I did some npm ci but before doing npm link. Will try it later today.

@atomfrede
Copy link
Member Author

@mshima No luck with doing npm ci after each linking. Still having the same error with the subgen in the blueprint. The corresponding PR is here https://github.com/jhipster/generator-jhipster-micronaut/pull/85/files. Althought I still think it might be an environment error.

@mshima
Copy link
Member

mshima commented Jun 10, 2020

Seems to be working:

$ jhipster heroku --blueprints micronaut
INFO! Using JHipster version installed globally
INFO! No custom sharedOptions found within blueprint: generator-jhipster-micronaut at /usr/local/lib/node_modules/generator-jhipster-micronaut
INFO! No custom commands found within blueprint: generator-jhipster-micronaut at /usr/local/lib/node_modules/generator-jhipster-micronaut
INFO! Executing jhipster:heroku
     info Using blueprint generator-jhipster-micronaut for heroku subgenerator
Heroku configuration is starting
? Name to deploy as: micronaut
? On which region do you want to deploy ? us
? Which type of deployment do you want ? Git (compile on Heroku)
? Which Java version would you like to use to build and run your app ? 11
✖ You don't have the Heroku CLI installed. Download it from https://cli.heroku.com/
 conflict pom.xml
? Overwrite pom.xml? show the differences between the old and the new

The steps I've done:

npm install -g jhipster/generator-jhipster
git clone https://github.com/atomfrede/generator-jhipster-micronaut
cd generator-jhipster-micronaut/
git checkout origin/82-support-heroku-deployment
npm ci
npm install jhipster/generator-jhipster

Created a default jhipster project at another folder and run jhipster heroku --blueprints micronaut

@mshima
Copy link
Member

mshima commented Jun 10, 2020

@mshima No luck with doing npm ci after each linking. Still having the same error with the subgen in the blueprint. The corresponding PR is here https://github.com/jhipster/generator-jhipster-micronaut/pull/85/files. Althought I still think it might be an environment error.

The order should be:
Supposing you've done generator-jhipster: npm link
1 - generator-jhipster-(micronaut): npm link
2 - generator-jhipster-(micronaut): npm link generator-jhipster
3 - generator-jhipster: npm ci to fix generator-jhipster node-modules.

What causes problems:
generator-jhipster-(micronaut): npm ci will install the package.json's generator-jhipster version.
generator-jhipster-(micronaut): npm link will mess with the linked generator-jhipster node_modules due to dedupe
generator-jhipster-(micronaut): npm link generator-jhipster will mess with the linked generator-jhipster node_modules due to dedupe

@atomfrede
Copy link
Member Author

🎉 Thanks Marcelo for the detailed explanation. I did one npm ci to much inside micronaut blueprint. Now it works.

@pascalgrimaud pascalgrimaud added this to the 6.10.0 milestone Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants