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

Adjusts to Microfrontend. #15312

Merged
merged 8 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from 6 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
3 changes: 1 addition & 2 deletions .github/workflows/jdl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ jobs:
- jdl: blog-store-microfrontend
environment: prod
# Use monorepository for diff
extra-args: --workspaces --monorepository --interactive
new-extra-args: --microfrontend
extra-args: --workspaces --monorepository --microfrontend
# Backend is failing, disable it
skip-backend-tests: 1
skip-frontend-tests: 0
Expand Down
24 changes: 15 additions & 9 deletions cli/import-jdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,22 +414,28 @@ class JDLProcessor {
return Promise.resolve();
}

applicationsWithEntities.forEach((applicationWithEntities, idx) => {
applicationWithEntities.config.applicationIndex = idx;
});
const allApplications = Object.fromEntries(
applicationsWithEntities.map((applicationWithEntities, applicationIndex) => {
applicationWithEntities.config.applicationIndex = applicationIndex;
return [applicationWithEntities.config.baseName, applicationWithEntities.config];
})
);

const allApplications = applicationsWithEntities.map(applicationWithEntities => [
applicationWithEntities.config.baseName,
{ applicationIndex: applicationWithEntities.config.applicationIndex, serverPort: applicationWithEntities.config.serverPort },
]);
applicationsWithEntities.forEach((applicationWithEntities, idx) => {
const relatedApplications = allApplications.filter(
const relatedApplications = Object.entries(allApplications).filter(
([baseName]) =>
applicationWithEntities.config.baseName !== baseName &&
applicationWithEntities.entities.find(entity => entity.microserviceName === baseName)
);
const { serverPort: gatewayServerPort } = applicationWithEntities.config;
if (relatedApplications.length > 0) {
applicationWithEntities.config.applications = Object.fromEntries(relatedApplications);
applicationWithEntities.config.applications = Object.fromEntries(
relatedApplications.map(([baseName, config]) => {
config.gatewayServerPort = gatewayServerPort;
const { serverPort, applicationIndex } = config;
return [baseName, { serverPort, applicationIndex }];
})
);
}
});

Expand Down
6 changes: 6 additions & 0 deletions generators/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ module.exports = class JHipsterClientGenerator extends BaseBlueprintGenerator {
this.loadTranslationConfig();
},

checkMicrofrontend() {
if (this.microfrontend && !this.clientFrameworkAngular) {
MathieuAA marked this conversation as resolved.
Show resolved Hide resolved
throw new Error(`Microfrontend requires ${ANGULAR} client framework.`);
}
},

validateSkipServer() {
if (
this.jhipsterConfig.skipServer &&
Expand Down
4 changes: 2 additions & 2 deletions generators/client/templates/angular/webpack/proxy.conf.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ function setupProxy() {
'/auth',
'/health',
],
target: `http${tls ? 's' : ''}://localhost:<%= serverPort %>`,
target: `http${tls ? 's' : ''}://localhost:<%= applicationTypeMicroservice ? gatewayServerPort : serverPort %>`,
secure: false,
changeOrigin: tls,
},
<%_ if (communicationSpringWebsocket) { _%>
{
context: ['/websocket'],
target: 'ws://127.0.0.1:<%= serverPort %>',
target: 'ws://127.0.0.1:<%= applicationTypeMicroservice ? gatewayServerPort : serverPort %>',
ws: true,
},
<%_ } _%>
Expand Down
1 change: 1 addition & 0 deletions generators/generator-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2481,6 +2481,7 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`;
dest.skipJhipsterDependencies = !!config.skipJhipsterDependencies;
dest.withAdminUi = config.withAdminUi;
dest.microfrontend = config.microfrontend;
dest.gatewayServerPort = config.gatewayServerPort;

dest.testFrameworks = config.testFrameworks || [];
dest.cypressCoverage = config.cypressCoverage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@
<p>This application is a microservice, which has been generated using <a href="https://www.jhipster.tech/" rel="noopener noreferrer">JHipster</a>.</p>

<ul>
<%_ if (microfrontend) { %>
<li>Microfrontends packages doesn't provide a stand-alone front-end. Packaged microfrontend should be accessed through a JHipster gateway.</li>
DanielFran marked this conversation as resolved.
Show resolved Hide resolved
<li>Stand-alone development server can be started by `npm start`.</li>
<%_ } else { %>
<li>It does not have a front-end. The front-end should be generated on a JHipster gateway.</li>
<%_ } %>
<li>It is serving REST APIs, under the '/api' URLs.</li>
<li>To manage this microservice, you will probably want to use the <a href="https://www.jhipster.tech/jhipster-registry/">JHipster Registry</a>:
<ul>
Expand Down
Loading