Skip to content

Commit

Permalink
Merge branch 'main' into rspack
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima authored Oct 18, 2024
2 parents 7a8a6b5 + 302387d commit 3bcbb7b
Show file tree
Hide file tree
Showing 51 changed files with 1,250 additions and 1,640 deletions.
11 changes: 2 additions & 9 deletions .blueprint/generate-sample/generator.mts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default class extends BaseGenerator {
const sample = await generateSample(this.sampleName, {
destProjectFolder: this.projectFolder,
fork: false,
entity: this.entitiesSample,
});
assert.ok(sample, `Sample ${this.sampleName} not found`);

Expand Down Expand Up @@ -103,20 +104,12 @@ export default class extends BaseGenerator {
const entitiesFiles = entitiesByType[this.entitiesSample];
if (entitiesFiles) {
this.jhipsterConfig.entities = entitiesFiles;
/*
this.log.info(`Copying entities ${this.entitiesSample} (${entitiesFiles})`);
this.copyTemplate(
entitiesFiles.map(entity => `.jhipster/${entity}.json`),
this.projectFolder,
{ noGlob: true, fromBasePath: this.templatePath('../../../test-integration/samples/') },
);
*/
entitiesFiles.forEach(entity =>
this.copyTemplate(
`../../../test-integration/samples/.jhipster/${entity}.json`,
`${this.projectFolder}/.jhipster/${entity}.json`,
{ noGlob: true },
),
);
}
await this.composeWithJHipster(GENERATOR_APP, { generatorOptions: { destinationRoot: this.projectFolder } });
},
Expand Down
2 changes: 1 addition & 1 deletion .blueprint/github-build-matrix/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
type: String,
},
scope: 'generator',
choices: ['testcontainers'],
choices: ['testcontainers', 'dev-server'],
},
},
} as const satisfies JHipsterCommandDefinition;
17 changes: 17 additions & 0 deletions .blueprint/github-build-matrix/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import BaseGenerator from '../../generators/base/index.js';
import { setGithubTaskOutput } from '../../lib/testing/index.js';
import { convertToGitHubMatrix } from './support/github-ci-matrix.js';
import { dockerComposeMatrix } from './samples/docker-compose-integration.js';
import { getGitChanges } from './support/git-changes.js';
import { devServerMatrix } from './samples/dev-server.js';

export default class extends BaseGenerator {
workflow;
Expand All @@ -15,6 +17,21 @@ export default class extends BaseGenerator {
async buildMatrix() {
if (this.workflow === 'docker-compose-integration') {
setGithubTaskOutput('matrix', JSON.stringify(convertToGitHubMatrix(dockerComposeMatrix), null, 2));
} else if (this.workflow === 'dev-server') {
const { devBlueprint, devserverCi, client, angular, react, vue } = await getGitChanges();
const matrix = {};
if (devBlueprint || devserverCi || client || angular) {
Object.assign(matrix, devServerMatrix.angular);
}
if (devBlueprint || devserverCi || client || react) {
Object.assign(matrix, devServerMatrix.react);
}
if (devBlueprint || devserverCi || client || vue) {
Object.assign(matrix, devServerMatrix.vue);
}
const githubMatrix = convertToGitHubMatrix(matrix);
setGithubTaskOutput('matrix', JSON.stringify(githubMatrix, null, 2));
setGithubTaskOutput('empty-matrix', githubMatrix.include.length === 0);
}
},
});
Expand Down
20 changes: 20 additions & 0 deletions .blueprint/github-build-matrix/samples/dev-server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export const devServerMatrix = {
angular: {
'ng-default': {
sample: 'samples/ng-default',
args: '--sample-yorc-folder --entities-sample sqllight',
},
},
react: {
'react-default': {
sample: 'samples/react-default',
args: '--sample-yorc-folder --entities-sample sqllight',
},
},
vue: {
'vue-default': {
sample: 'samples/vue-default',
args: '--sample-yorc-folder --entities-sample sqllight',
},
},
};
26 changes: 26 additions & 0 deletions .blueprint/github-build-matrix/support/git-changes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { fileURLToPath } from 'url';
import { minimatch } from 'minimatch';
import { simpleGit } from 'simple-git';

export const getGitChanges = async () => {
const git = simpleGit({ baseDir: fileURLToPath(new URL('../../', import.meta.url).href) });
const summary = await git.diffSummary({ '@~1': null });
const files = summary.files.map(({ file }) => file);
const hasPatternChanges = (pattern: string) => files.some(file => minimatch(file, pattern, { dot: true }));
return {
files,
base:
hasPatternChanges('lib/**') ||
hasPatternChanges('generators/*') ||
hasPatternChanges('generators/{base*,bootstrap*,git,jdl,project-name}/**'),
devBlueprint: hasPatternChanges('.blueprint/**'),
ci: hasPatternChanges('.github/{actions,workflows}/**') || hasPatternChanges('generators/{docker-compose,kubernetes*,workspaces}/**'),
devserverCi: hasPatternChanges('.github/workflows/devserver.yml'),
common: hasPatternChanges('generators/{app,common,cypress,docker,languages}/**'),
client: hasPatternChanges('generators/{client,init,javascript}/**'),
angular: hasPatternChanges('generators/angular/**'),
react: hasPatternChanges('generators/react/**'),
vue: hasPatternChanges('generators/vue/**'),
java: hasPatternChanges('generators/{cucumber,feign-client,gatling,gradle,java,liquibase,maven,server,spring*}/**'),
};
};
2 changes: 2 additions & 0 deletions .blueprint/github-build-matrix/support/github-ci-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type GitHubMatrix = {
'java-version': string;
'default-environment': string;
'job-name': string;
sample: string;
args: string;
};

Expand All @@ -31,6 +32,7 @@ export const convertToGitHubMatrix = (matrix: Record<string, any>): GitHubMatrix
return {
include: Object.entries(matrix).map(([key, value]) => ({
'job-name': key,
sample: key,
...defaultEnvironment,
...value,
})),
Expand Down
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ updates:
# Should match generated project node major version.
- dependency-name: '@types/node'
versions: ['>=19']
# https://github.com/jhipster/generator-jhipster/issues/27464#issuecomment-2400505558, https://github.com/twbs/bootstrap/issues/40849
- dependency-name: 'sass'
versions: ['*']
groups:
eslint:
patterns:
Expand Down Expand Up @@ -178,6 +181,9 @@ updates:
# https://github.com/bootstrap-vue/bootstrap-vue/issues/5507
- dependency-name: 'bootstrap'
versions: ['>=5']
# Bootstrap v4 issue https://github.com/jhipster/generator-jhipster/issues/23770, https://github.com/twbs/bootstrap/issues/39028, https://github.com/jhipster/generator-jhipster/issues/27464#issuecomment-2400505558, https://github.com/twbs/bootstrap/issues/40849
- dependency-name: 'sass'
versions: ['*']
# Should match generated project node major version.
- dependency-name: '@types/node'
versions: ['>=19']
Expand Down
48 changes: 19 additions & 29 deletions .github/workflows/devserver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ on:
- '.github/workflows/devserver.yml'
- 'generators/angular/**'
- 'generators/client/**'
- 'generators/javascript/**'
- 'generators/react/**'
- 'generators/vue/**'
- 'generators/*'
Expand All @@ -49,15 +50,13 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: 'Build matrix'
id: build
uses: ./.github/actions/build-matrix
with:
workflow-file-prefix: devserver
- run: npm ci --ignore-scripts
- id: build
run: bin/jhipster.cjs github-build-matrix dev-server
applications:
name: ${{ matrix.app-sample }}
name: ${{ matrix.job-name }}
needs: build-matrix
runs-on: ubuntu-20.04
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ${{ github.workspace }}/app
Expand All @@ -75,44 +74,35 @@ jobs:
with:
path: generator-jhipster
fetch-depth: 2
- name: 'SETUP: environment'
id: setup
uses: ./generator-jhipster/.github/actions/setup
with:
application-sample: ${{ matrix.setup-application-sample }}
entities-sample: ${{ matrix.setup-entities-sample }}
jdl-entities-sample: ${{ matrix.setup-jdl-entities-sample }}
jdl-sample: ${{ matrix.setup-jdl-sample }}
application-environment: ${{ matrix.setup-application-environment }}
application-packaging: ${{ matrix.setup-application-packaging }}
- uses: jhipster/actions/setup-runner@v0
with:
node-version: ${{ steps.setup.outputs.node-version }}
java-version: ${{ steps.setup.outputs.java-version }}
node-version: ${{ matrix.node-version }}
java-version: ${{ matrix.java-version }}
npm-version: ${{ matrix.npm-version }}
maven-cache: true
binary-dir: ${{ github.workspace }}/generator-jhipster/bin
#----------------------------------------------------------------------
# Install JHipster and generate project+entities
#----------------------------------------------------------------------
- name: 'GENERATION: install JHipster'
run: $JHI_SCRIPTS/10-install-jhipster.sh
- name: 'GENERATION: config'
run: $JHI_SCRIPTS/11-generate-config.sh
- run: npm ci --ignore-scripts
working-directory: ${{ github.workspace }}/generator-jhipster
- name: 'GENERATION: project'
run: $JHI_SCRIPTS/12-generate-project.sh ${{ matrix.extra-args }} ${{ matrix.new-extra-args }}
- name: 'GENERATION: jhipster info'
run: $JHI_SCRIPTS/14-jhipster-info.sh
run: jhipster.cjs generate-sample ${{ matrix.sample }} --skip-jhipster-dependencies --skip-install ${{ matrix.args }}
- run: jhipster.cjs info
#----------------------------------------------------------------------
# Launch tests
#----------------------------------------------------------------------
- name: 'E2E: Run'
id: e2e
run: ./npmw run e2e:devserver --if-present
run: |
./npmw install
./npmw run e2e:devserver --if-present
- name: 'E2E: Store failure screenshots'
uses: actions/upload-artifact@v4
if: always() && steps.e2e.outcome == 'failure'
with:
name: screenshots-${{ matrix.app-sample }}
path: ${{ steps.setup.outputs.application-path }}/*/cypress/screenshots
name: screenshots-${{ matrix.job-name }}
path: ${{ github.workspace }}/app/*/cypress/screenshots
check-dev-server:
permissions:
contents: none
Expand Down
6 changes: 0 additions & 6 deletions bin/cli.cjs

This file was deleted.

11 changes: 6 additions & 5 deletions bin/jhipster.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// Executable file that runs jhipster sources in JIT mode.
// This file should be used for development purposes and should not be distributed in the npm package.
// Executable should be written in commonjs https://github.com/nodejs/modules/issues/152.
const { join } = require('path');
const { Module } = require('module');
const { pathToFileURL } = require('url');

const [_nodeExec, _exec, ...args] = process.argv;
// eslint-disable-next-line no-console
console.error('jhipster', ...args);

(async () => {
const { default: esbuildx } = await import('@node-loaders/esbuildx');
await esbuildx(join(__dirname, 'cli.cjs'));
})();
process.env.JHIPSTER_DEV_BLUEPRINT = true;
Module.register(pathToFileURL(require.resolve('@node-loaders/esbuild/strict')).href);

require('../cli/jhipster.cjs');
5 changes: 2 additions & 3 deletions cli/cli.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { execaCommandSync } from 'execa';
import type { GeneratorMeta } from '@yeoman/types';
import type FullEnvironment from 'yeoman-environment';
import { coerce } from 'semver';
import quibble from 'quibble';

import { defaultHelpers as helpers, createBlueprintFiles } from '../lib/testing/index.js';
import { getCommand as actualGetCommonand } from './utils.mjs';
Expand Down Expand Up @@ -96,7 +95,7 @@ describe('cli', () => {
let argv;

before(async () => {
await quibble.esm('./utils.mjs', { logger, getCommand, CLI_NAME: 'jhipster', done: () => {} });
await esmocha.mock('./utils.mjs', { logger, getCommand, CLI_NAME: 'jhipster', done: () => {} } as any);
const { buildJHipster } = await import('./program.mjs');

mockCli = async (argv: string[], opts = {}) => {
Expand All @@ -105,7 +104,7 @@ describe('cli', () => {
};
});
after(() => {
quibble.reset();
esmocha.reset();
});

beforeEach(async () => {
Expand Down
14 changes: 8 additions & 6 deletions cli/jhipster-command.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,14 @@ export default class JHipsterCommand extends Command {

addJHipsterConfigs(configs = {}, blueprintOptionDescription) {
Object.assign(blueprintOptionDescription ? this.blueprintConfigs : this.configs, configs);
Object.entries(configs).forEach(([name, config]) => {
const option = convertConfigToOption(name, config);
if (option) {
this._addGeneratorOption(kebabCase(option.name), option, blueprintOptionDescription);
}
});
Object.entries(configs)
.filter(([_name, config]) => config.cli)
.forEach(([name, config]) => {
const option = convertConfigToOption(name, config);
if (option) {
this._addGeneratorOption(kebabCase(option.name), option, blueprintOptionDescription);
}
});
return this;
}

Expand Down
10 changes: 5 additions & 5 deletions generators/angular/resources/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"@angular/common": "18.2.7",
"@angular/common": "18.2.8",
"@fortawesome/angular-fontawesome": "0.15.0",
"@fortawesome/fontawesome-svg-core": "6.6.0",
"@fortawesome/free-solid-svg-icons": "6.6.0",
Expand All @@ -15,15 +15,15 @@
"ngx-infinite-scroll": "18.0.0",
"rxjs": "7.8.1",
"sockjs-client": "1.6.1",
"tslib": "2.7.0",
"tslib": "2.8.0",
"zone.js": "0.14.10"
},
"devDependencies": {
"@angular-architects/module-federation": "18.0.6",
"@angular-architects/module-federation-runtime": "18.0.6",
"@angular-builders/custom-webpack": "18.0.0",
"@angular-builders/jest": "18.0.0",
"@angular/cli": "18.2.7",
"@angular/cli": "18.2.9",
"@types/jest": "29.5.13",
"@types/node": "20.11.25",
"@types/sockjs-client": "1.5.4",
Expand All @@ -37,7 +37,7 @@
"eslint-plugin-prettier": "5.2.1",
"eslint-webpack-plugin": "4.2.0",
"folder-hash": "4.0.4",
"globals": "15.10.0",
"globals": "15.11.0",
"jest": "29.7.0",
"jest-date-mock": "1.0.10",
"jest-junit": "16.0.0",
Expand All @@ -48,7 +48,7 @@
"rimraf": "5.0.8",
"ts-jest": "29.2.5",
"typescript": "5.5.4",
"typescript-eslint": "8.8.0",
"typescript-eslint": "8.10.0",
"webpack": "5.95.0",
"webpack-bundle-analyzer": "4.10.2",
"webpack-merge": "6.0.1",
Expand Down
8 changes: 4 additions & 4 deletions generators/app/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Options:
--skip-jhipster-dependencies Don't write jhipster dependencies to package.json. (env: JHI_SKIP_JHIPSTER_DEPENDENCIES)
--creation-timestamp <value> Project creation timestamp (used for reproducible builds)
--jdl-store <value> JDL store
--prettier-tab-width <value> Default tab width for prettier
--prettier-tab-width <value> Default tab width for prettier (default: 2)
--monorepository Use monorepository
--skip-commit-hook Skip adding husky commit hooks
--db <value> Provide DB name for the application when skipping server side generation
Expand All @@ -47,14 +47,14 @@ Options:
--reactive Generate a reactive backend
--service-discovery-type <value> Service discovery type (choices: "consul", "eureka", "no")
--auth <value> Provide authentication type for the application when skipping server side generation (choices: "jwt", "oauth2", "session")
--feign-client Generate a feign client
--feign-client Generate a feign client (default: false)
--sync-user-with-idp Allow relationships with User for oauth2 applications
--message-broker <value> message broker (choices: "kafka", "pulsar", "no")
--database-migration <value> Database migration (choices: "liquibase")
--with-generated-flag Add a GeneratedByJHipster annotation to all generated java classes and interfaces
--package-name <value> The package name for the generated application
--build <value> Provide build tool for the application when skipping server side generation (choices: "maven", "gradle")
--enable-gradle-enterprise Enable Gradle Enterprise integration
--build <value> Provide build tool for the application when skipping server side generation (default: maven) (choices: "maven", "gradle")
--enable-gradle-enterprise Enable Gradle Enterprise integration (default: false)
--gradle-enterprise-host <value> Gradle Enterprise Host
--incremental-changelog Creates incremental database changelogs
--dev-database-type <value> Development database
Expand Down
2 changes: 0 additions & 2 deletions generators/app/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ describe(`generator - ${generator}`, () => {
"databaseType",
"prodDatabaseType",
"devDatabaseType",
"cacheProvider",
"enableHibernateCache",
"serverSideOptions",
"enableGradleEnterprise",
"clientFramework",
Expand Down
Loading

0 comments on commit 3bcbb7b

Please sign in to comment.