Skip to content

Commit

Permalink
client: default client source dir to src if clientRootDir is not empt…
Browse files Browse the repository at this point in the history
…y and add to ci sample (#27819)
  • Loading branch information
mshima authored Nov 6, 2024
1 parent ef834dc commit 64960c3
Show file tree
Hide file tree
Showing 12 changed files with 1,582 additions and 1,538 deletions.
1,389 changes: 699 additions & 690 deletions generators/angular/__snapshots__/generator.spec.ts.snap

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion generators/angular/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe(`generator - ${clientFramework}`, () => {

describe('withAdminUi', () => {
const { applicationType, withAdminUi, clientRootDir = '' } = sampleConfig;
const clientSrcDir = `${clientRootDir}${CLIENT_MAIN_SRC_DIR}`;
const clientSrcDir = `${clientRootDir}${clientRootDir ? 'src/' : CLIENT_MAIN_SRC_DIR}`;
const generateAdminUi = applicationType !== 'microservice' && withAdminUi;
const adminUiComponents = generateAdminUi ? 'should generate admin ui components' : 'should not generate admin ui components';

Expand Down
10 changes: 10 additions & 0 deletions generators/angular/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ export default class AngularGenerator extends BaseApplicationGenerator {
}),
);
};

if (application.clientRootDir) {
// Overrides only works if added in root package.json
this.packageJson.merge({
overrides: {
'browser-sync': application.nodeDependencies['browser-sync'],
webpack: application.nodeDependencies.webpack,
},
});
}
},
});
}
Expand Down
12 changes: 12 additions & 0 deletions generators/client/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,18 @@ export default class JHipsterClientGenerator extends BaseApplicationGenerator {
scriptsStorage.set('ci:frontend:build', 'npm run webapp:build:$npm_package_config_default_environment');
scriptsStorage.set('ci:frontend:test', 'npm run ci:frontend:build && npm test');
}

if (application.clientRootDir) {
// Add scripts to map to client package.json
this.packageJson.merge({
workspaces: [application.clientRootDir],
scripts: {
'webapp:build': `npm run -w ${application.clientRootDir} webapp:build`,
'ci:frontend:test': `npm run -w ${application.clientRootDir} ci:frontend:test`,
'e2e:headless': `npm run -w ${application.clientRootDir} e2e:headless`,
},
});
}
},

microfrontend({ application, source }) {
Expand Down
6 changes: 4 additions & 2 deletions generators/client/support/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export const loadClientConfig = ({ config, application }: { config: any; applica
application.devServerPort = config.devServerPort;

application.clientRootDir = config.clientRootDir ?? '';
application.clientSrcDir = config.clientSrcDir ?? `${application.clientRootDir}${CLIENT_MAIN_SRC_DIR}`;
application.clientTestDir = config.clientTestDir ?? `${application.clientRootDir}${CLIENT_TEST_SRC_DIR}`;
application.clientSrcDir =
config.clientSrcDir ?? `${application.clientRootDir}${application.clientRootDir ? 'src/' : CLIENT_MAIN_SRC_DIR}`;
application.clientTestDir =
config.clientTestDir ?? `${application.clientRootDir}${application.clientRootDir ? 'test/' : CLIENT_TEST_SRC_DIR}`;
};

/**
Expand Down
74 changes: 37 additions & 37 deletions generators/cypress/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,58 +14,58 @@ exports[`generator - cypress jwt-cypressAudit(false)-angular-withAdminUi(false)-
"clientRoot/package.json": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/account/login-page.cy.ts": {
"clientRoot/test/cypress/e2e/account/login-page.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/account/logout.cy.ts": {
"clientRoot/test/cypress/e2e/account/logout.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/account/password-page.cy.ts": {
"clientRoot/test/cypress/e2e/account/password-page.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/account/register-page.cy.ts": {
"clientRoot/test/cypress/e2e/account/register-page.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/account/reset-password-page.cy.ts": {
"clientRoot/test/cypress/e2e/account/reset-password-page.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/account/settings-page.cy.ts": {
"clientRoot/test/cypress/e2e/account/settings-page.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/administration/administration.cy.ts": {
"clientRoot/test/cypress/e2e/administration/administration.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/entity/authority.cy.ts": {
"clientRoot/test/cypress/e2e/entity/authority.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/entity/entity-a.cy.ts": {
"clientRoot/test/cypress/e2e/entity/entity-a.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/fixtures/integration-test.png": {
"clientRoot/test/cypress/fixtures/integration-test.png": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/plugins/index.ts": {
"clientRoot/test/cypress/plugins/index.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/support/account.ts": {
"clientRoot/test/cypress/support/account.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/support/commands.ts": {
"clientRoot/test/cypress/support/commands.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/support/entity.ts": {
"clientRoot/test/cypress/support/entity.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/support/index.ts": {
"clientRoot/test/cypress/support/index.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/support/management.ts": {
"clientRoot/test/cypress/support/management.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/support/navbar.ts": {
"clientRoot/test/cypress/support/navbar.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/tsconfig.json": {
"clientRoot/test/cypress/tsconfig.json": {
"stateCleared": "modified",
},
}
Expand All @@ -88,61 +88,61 @@ exports[`generator - cypress jwt-cypressAudit(true)-vue-withAdminUi(true)-cypres
"clientRoot/package.json": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/account/login-page.cy.ts": {
"clientRoot/test/cypress/e2e/account/login-page.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/account/logout.cy.ts": {
"clientRoot/test/cypress/e2e/account/logout.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/account/password-page.cy.ts": {
"clientRoot/test/cypress/e2e/account/password-page.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/account/register-page.cy.ts": {
"clientRoot/test/cypress/e2e/account/register-page.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/account/reset-password-page.cy.ts": {
"clientRoot/test/cypress/e2e/account/reset-password-page.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/account/settings-page.cy.ts": {
"clientRoot/test/cypress/e2e/account/settings-page.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/administration/administration.cy.ts": {
"clientRoot/test/cypress/e2e/administration/administration.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/entity/entity-a.cy.ts": {
"clientRoot/test/cypress/e2e/entity/entity-a.cy.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/e2e/lighthouse.audits.ts": {
"clientRoot/test/cypress/e2e/lighthouse.audits.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/fixtures/integration-test.png": {
"clientRoot/test/cypress/fixtures/integration-test.png": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/plugins/global.d.ts": {
"clientRoot/test/cypress/plugins/global.d.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/plugins/index.ts": {
"clientRoot/test/cypress/plugins/index.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/support/account.ts": {
"clientRoot/test/cypress/support/account.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/support/commands.ts": {
"clientRoot/test/cypress/support/commands.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/support/entity.ts": {
"clientRoot/test/cypress/support/entity.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/support/index.ts": {
"clientRoot/test/cypress/support/index.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/support/management.ts": {
"clientRoot/test/cypress/support/management.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/support/navbar.ts": {
"clientRoot/test/cypress/support/navbar.ts": {
"stateCleared": "modified",
},
"clientRoot/src/test/javascript/cypress/tsconfig.json": {
"clientRoot/test/cypress/tsconfig.json": {
"stateCleared": "modified",
},
}
Expand Down
7 changes: 4 additions & 3 deletions generators/cypress/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,21 @@ describe(`generator - ${generator}`, () => {

if (applicationType !== 'microservice') {
const adminUiRoutingTitle = generateAdminUi ? 'should generate admin routing' : 'should not generate admin routing';
const cypressAdminRoot = clientRootDir ? `${clientRootDir}test/` : 'src/test/javascript/';
it(adminUiRoutingTitle, () => {
const assertion = (...args) =>
generateAdminUi ? (runResult.assertFileContent as any)(...args) : (runResult.assertNoFileContent as any)(...args);

assertion(
`${clientRootDir}src/test/javascript/cypress/e2e/administration/administration.cy.ts`,
`${cypressAdminRoot}cypress/e2e/administration/administration.cy.ts`,
' metricsPageHeadingSelector,\n' +
' healthPageHeadingSelector,\n' +
' logsPageHeadingSelector,\n' +
' configurationPageHeadingSelector,',
);

assertion(
`${clientRootDir}src/test/javascript/cypress/e2e/administration/administration.cy.ts`,
`${cypressAdminRoot}cypress/e2e/administration/administration.cy.ts`,
" describe('/metrics', () => {\n" +
" it('should load the page', () => {\n" +
" cy.clickOnAdminMenuItem('metrics');\n" +
Expand Down Expand Up @@ -139,7 +140,7 @@ describe(`generator - ${generator}`, () => {
);

assertion(
`${clientRootDir}src/test/javascript/cypress/support/commands.ts`,
`${cypressAdminRoot}cypress/support/commands.ts`,
'export const metricsPageHeadingSelector = \'[data-cy="metricsPageHeading"]\';\n' +
'export const healthPageHeadingSelector = \'[data-cy="healthPageHeading"]\';\n' +
'export const logsPageHeadingSelector = \'[data-cy="logsPageHeading"]\';\n' +
Expand Down
Loading

0 comments on commit 64960c3

Please sign in to comment.