Skip to content

Commit

Permalink
update jhipster to main branch (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima authored Sep 11, 2023
1 parent 236dc8a commit 7708517
Show file tree
Hide file tree
Showing 18 changed files with 226 additions and 301 deletions.
1 change: 0 additions & 1 deletion .blueprint/generate-sample/command.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const command = {
arguments: {
sampleName: {
type: String,
required: true,
},
},
options: {},
Expand Down
20 changes: 18 additions & 2 deletions .blueprint/generate-sample/generator.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { readdir } from 'node:fs/promises';
import BaseGenerator from 'generator-jhipster/generators/base';
import command from './command.mjs';

Expand All @@ -8,14 +9,30 @@ export default class extends BaseGenerator {
return this.asInitializingTaskGroup({
async initializeOptions() {
this.parseJHipsterArguments(command.arguments);
if (!this.sampleName.endsWith('.jdl')) {
if (this.sampleName && !this.sampleName.endsWith('.jdl')) {
this.sampleName += '.jdl';
}
this.parseJHipsterOptions(command.options);
},
});
}

get [BaseGenerator.PROMPTING]() {
return this.asPromptingTaskGroup({
async askForSample() {
if (!this.sampleName) {
const answers = await this.prompt({
type: 'list',
name: 'sampleName',
message: 'which sample do you want to generate?',
choices: async () => readdir(this.templatePath('samples')),
});
this.sampleName = answers.sampleName;
}
},
});
}

get [BaseGenerator.WRITING]() {
return this.asWritingTaskGroup({
async copySample() {
Expand All @@ -33,7 +50,6 @@ export default class extends BaseGenerator {
skipJhipsterDependencies: true,
insight: false,
skipChecks: true,
skipInstall: true,
},
});
},
Expand Down
11 changes: 2 additions & 9 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,17 @@
"node": true,
"es2020": true
},
"extends": ["airbnb-base", "plugin:mocha/recommended", "plugin:prettier/recommended"],
"extends": ["airbnb-base", "plugin:prettier/recommended"],
"parserOptions": {
"ecmaVersion": 11,
"sourceType": "module"
},
"overrides": [
{
"files": ["**/*.spec.{c,m,}js", "test/**/*.{c,m,}js"],
"env": {
"mocha": true
}
"files": ["**/*.spec.{c,m,}js", "test/**/*.{c,m,}js"]
}
],
"rules": {
"class-methods-use-this": "off",
"no-underscore-dangle": "off",
"no-param-reassign": "off",
"mocha/no-mocha-arrows": "off",
"func-names": "off",
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
"import/no-unresolved": "off",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ permissions:
jobs:
entity-audit:
name: npm-test
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions .yo-rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"localBlueprint": false,
"prettierDefaultIndent": 2,
"projectName": "Entity Audit Application",
"sampleWritten": true,
"skipCommitHook": true,
"subGenerators": ["app", "client"]
}
Expand Down
20 changes: 9 additions & 11 deletions cli/cli.mjs → cli/cli.cjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#!/usr/bin/env node

import { runJHipster, done, logger } from 'generator-jhipster/cli';
import { readFile } from 'fs/promises';
import { fileURLToPath } from 'url';
import { dirname, basename, join } from 'path';
const { dirname, basename, join } = require('path');
const { version, bin } = require('../package.json');

// Get package name to use as namespace.
// Allows blueprints to be aliased.
const packagePath = dirname(dirname(fileURLToPath(import.meta.url)));
const packagePath = dirname(__dirname);
const packageFolderName = basename(packagePath);
const devBlueprintPath = join(packagePath, '.blueprint');

(async () => {
const { version, bin } = JSON.parse(await readFile(new URL('../package.json', import.meta.url)));
const { runJHipster, done, logger } = await import('generator-jhipster/cli');
const executableName = Object.keys(bin)[0];

runJHipster({
Expand All @@ -29,9 +27,9 @@ const devBlueprintPath = join(packagePath, '.blueprint');
},
lookups: [{ packagePaths: [packagePath], lookups: ['generators'] }],
}).catch(done);
})();

process.on('unhandledRejection', up => {
logger.error('Unhandled promise rejection at:');
logger.fatal(up);
});
process.on('unhandledRejection', up => {
logger.error('Unhandled promise rejection at:');
logger.fatal(up);
});
})();
15 changes: 6 additions & 9 deletions generators/angular-audit/generator.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import { beforeAll, describe, expect, it } from 'vitest';

import { helpers, lookups } from '#test-utils';
import { defaultHelpers as helpers, result } from 'generator-jhipster/testing';

const SUB_GENERATOR = 'angular-audit';
const SUB_GENERATOR_NAMESPACE = `jhipster-entity-audit:${SUB_GENERATOR}`;

describe('SubGenerator angular-audit of entity-audit JHipster blueprint', () => {
describe('run', () => {
let result;
beforeAll(async function () {
result = await helpers
.create(SUB_GENERATOR_NAMESPACE)
await helpers
.run(SUB_GENERATOR_NAMESPACE)
.withJHipsterConfig()
.withOptions({
reproducible: true,
defaults: true,
baseName: 'jhipster',
ignoreNeedlesError: true,
})
.withLookups(lookups)
.run();
.withJHipsterLookup()
.withParentBlueprintLookup();
});

it('should succeed', () => {
Expand Down
16 changes: 7 additions & 9 deletions generators/app/generator.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import { beforeAll, describe, expect, it } from 'vitest';

import { helpers, lookups } from '#test-utils';
import { defaultHelpers as helpers, result } from 'generator-jhipster/testing';

const SUB_GENERATOR = 'app';
const BLUEPRINT_NAMESPACE = `jhipster:${SUB_GENERATOR}`;

describe('SubGenerator app of entity-audit JHipster blueprint', () => {
describe('run', () => {
let result;
beforeAll(async function () {
result = await helpers
.create(BLUEPRINT_NAMESPACE)
await helpers
.run(BLUEPRINT_NAMESPACE)
.withJHipsterConfig()
.withOptions({
reproducible: true,
defaults: true,
creationTimestamp: '2022-01-01',
ignoreNeedlesError: true,
blueprint: 'entity-audit',
})
.withLookups(lookups)
.run();
}, 20000);
.withJHipsterLookup()
.withParentBlueprintLookup();
});

it('should succeed', () => {
expect(result.getStateSnapshot()).toMatchSnapshot();
Expand Down
14 changes: 6 additions & 8 deletions generators/client/generator.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import { beforeAll, describe, expect, it } from 'vitest';

import { helpers, lookups } from '#test-utils';
import { defaultHelpers as helpers, result } from 'generator-jhipster/testing';

const SUB_GENERATOR = 'client';
const BLUEPRINT_NAMESPACE = `jhipster:${SUB_GENERATOR}`;

describe('SubGenerator client of entity-audit JHipster blueprint', () => {
describe('run', () => {
let result;
beforeAll(async function () {
result = await helpers
.create(BLUEPRINT_NAMESPACE)
await helpers
.run(BLUEPRINT_NAMESPACE)
.withJHipsterConfig()
.withOptions({
reproducible: true,
defaults: true,
ignoreNeedlesError: true,
blueprint: 'entity-audit',
})
.withLookups(lookups)
.run();
.withJHipsterLookup()
.withParentBlueprintLookup();
});

it('should succeed', () => {
Expand Down
15 changes: 6 additions & 9 deletions generators/java-audit/generator.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import { beforeAll, describe, expect, it } from 'vitest';

import { helpers, lookups } from '#test-utils';
import { defaultHelpers as helpers, result } from 'generator-jhipster/testing';

const SUB_GENERATOR = 'java-audit';
const SUB_GENERATOR_NAMESPACE = `jhipster-entity-audit:${SUB_GENERATOR}`;

describe('SubGenerator java-audit of entity-audit JHipster blueprint', () => {
describe('run', () => {
let result;
beforeAll(async function () {
result = await helpers
.create(SUB_GENERATOR_NAMESPACE)
await helpers
.run(SUB_GENERATOR_NAMESPACE)
.withJHipsterConfig()
.withOptions({
reproducible: true,
defaults: true,
baseName: 'jhipster',
creationTimestamp: '2022-01-01',
ignoreNeedlesError: true,
})
.withLookups(lookups)
.run();
.withJHipsterLookup()
.withParentBlueprintLookup();
});

it('should succeed', () => {
Expand Down
51 changes: 51 additions & 0 deletions generators/languages/__snapshots__/generator.spec.mjs.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ exports[`SubGenerator languages of entity-audit JHipster blueprint > run > shoul
"src/main/resources/i18n/messages_en.properties": {
"stateCleared": "modified",
},
"src/main/resources/i18n/messages_fr.properties": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/en/activate.json": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -56,11 +59,59 @@ exports[`SubGenerator languages of entity-audit JHipster blueprint > run > shoul
"src/main/webapp/i18n/en/user-management.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/activate.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/configuration.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/entity-audit.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/error.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/global.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/health.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/home.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/login.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/logs.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/metrics.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/password.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/register.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/reset.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/sessions.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/settings.json": {
"stateCleared": "modified",
},
"src/main/webapp/i18n/fr/user-management.json": {
"stateCleared": "modified",
},
"src/test/resources/i18n/messages_en.properties": {
"stateCleared": "modified",
},
"src/test/resources/i18n/messages_fr.properties": {
"stateCleared": "modified",
},
}
`;
15 changes: 6 additions & 9 deletions generators/languages/generator.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import { beforeAll, describe, expect, it } from 'vitest';

import { helpers, lookups } from '#test-utils';
import { defaultHelpers as helpers, result } from 'generator-jhipster/testing';

const SUB_GENERATOR = 'languages';
const BLUEPRINT_NAMESPACE = `jhipster:${SUB_GENERATOR}`;

describe('SubGenerator languages of entity-audit JHipster blueprint', () => {
describe('run', () => {
let result;
beforeAll(async function () {
result = await helpers
.create(BLUEPRINT_NAMESPACE)
await helpers
.run(BLUEPRINT_NAMESPACE)
.withJHipsterConfig()
.withOptions({
reproducible: true,
defaults: true,
baseName: 'jhipster',
ignoreNeedlesError: true,
blueprint: 'entity-audit',
})
.withLookups(lookups)
.run();
.withJHipsterLookup()
.withParentBlueprintLookup();
});

it('should succeed', () => {
Expand Down
15 changes: 6 additions & 9 deletions generators/spring-boot-custom-audit/generator.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import { beforeAll, describe, expect, it } from 'vitest';

import { helpers, lookups } from '#test-utils';
import { defaultHelpers as helpers, result } from 'generator-jhipster/testing';

const SUB_GENERATOR = 'spring-boot-custom-audit';
const SUB_GENERATOR_NAMESPACE = `jhipster-entity-audit:${SUB_GENERATOR}`;

describe('SubGenerator spring-boot-custom-audit of entity-audit JHipster blueprint', () => {
describe('run', () => {
let result;
beforeAll(async function () {
result = await helpers
.create(SUB_GENERATOR_NAMESPACE)
await helpers
.run(SUB_GENERATOR_NAMESPACE)
.withJHipsterConfig()
.withOptions({
reproducible: true,
defaults: true,
creationTimestamp: '2022-01-01',
baseName: 'jhipster',
ignoreNeedlesError: true,
})
.withLookups(lookups)
.run();
.withJHipsterLookup()
.withParentBlueprintLookup();
});

it('should succeed', () => {
Expand Down
Loading

0 comments on commit 7708517

Please sign in to comment.