Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Jul 15, 2024
1 parent 502b1ca commit e89145f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
7 changes: 6 additions & 1 deletion generators/base-core/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,12 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`;

const normalizedFile = resolveCallback(sourceFile || file);
sourceFile = join(blockPath, normalizedFile);
destinationFile = this.destinationPath(blockTo, join(resolveCallback(destinationFile || renameTo, normalizedFile)));
destinationFile = join(resolveCallback(destinationFile || renameTo, normalizedFile));
if (blockRenameTo) {
destinationFile = this.destinationPath(blockRenameTo.call(this, context, destinationFile, this));
} else {
destinationFile = this.destinationPath(blockTo, destinationFile);
}

const override = resolveCallback(fileSpec.override);
if (override !== undefined && !override && (this as any).fs.exists(destinationFile)) {
Expand Down
6 changes: 3 additions & 3 deletions generators/javascript/generators/eslint/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class EslintGenerator extends BaseApplicationGenerator {
get preparing() {
return this.asPreparingTaskGroup({
source({ application, source }) {
application.eslintConfigFile = `${application.clientRootDir ?? ''}eslint.config.${application.packageJsonType === 'module' ? 'js' : 'mjs'}`;
application.eslintConfigFile = `eslint.config.${application.packageJsonType === 'module' ? 'js' : 'mjs'}`;
source.addEslintConfig = ({ import: importToAdd, config }) =>
this.editFile(
application.eslintConfigFile!,
Expand All @@ -71,9 +71,9 @@ export default class EslintGenerator extends BaseApplicationGenerator {
async writing({ application }) {
await this.writeFiles({
blocks: [
clientRootTemplatesBlock({
{
templates: [{ sourceFile: 'eslint.config.js.jhi', destinationFile: ctx => `${ctx.eslintConfigFile}.jhi` }],
}),
},
],
context: application,
});
Expand Down
29 changes: 26 additions & 3 deletions generators/react/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
generateEntityClientImports as formatEntityClientImports,
generateTestEntityId as getTestEntityId,
generateTestEntityPrimaryKey as getTestEntityPrimaryKey,
clientRootTemplatesBlock,
} from '../client/support/index.js';
import { createNeedleCallback, upperFirstCamelCase } from '../base/support/index.js';
import { writeEntitiesFiles, postWriteEntitiesFiles, cleanupEntitiesFiles } from './entity-files-react.js';
Expand All @@ -48,6 +49,7 @@ export default class ReactGenerator extends BaseApplicationGenerator {
}

if (!this.delegateToBlueprint) {
await this.dependsOnJHipster('jhipster:javascript:bootstrap');
await this.dependsOnJHipster(GENERATOR_CLIENT);
await this.dependsOnJHipster(GENERATOR_LANGUAGES);
}
Expand All @@ -56,7 +58,6 @@ export default class ReactGenerator extends BaseApplicationGenerator {
get composing() {
return this.asComposingTaskGroup({
async composeClientCommon() {
await this.composeWithJHipster('jhipster:javascript:eslint', { generatorOptions: { typescriptEslint: true } });
await this.composeWithJHipster('jhipster:client:common');
},
});
Expand All @@ -74,6 +75,12 @@ export default class ReactGenerator extends BaseApplicationGenerator {
this.fetchFromInstalledJHipster(GENERATOR_REACT, 'resources', 'package.json'),
);
},
applicationDefauts({ applicationDefaults }) {
applicationDefaults({
__override__: true,
typescriptEslint: true,
});
},
});
}

Expand All @@ -83,9 +90,14 @@ export default class ReactGenerator extends BaseApplicationGenerator {

get preparing() {
return this.asPreparingTaskGroup({
applicationDefauts({ applicationDefaults }) {
applicationDefaults({
__override__: true,
eslintConfigFile: app => `eslint.config.${app.packageJsonType === 'module' ? 'js' : 'mjs'}`,
webappEnumerationsDir: app => `${app.clientSrcDir}app/shared/model/enumerations/`,
});
},
prepareForTemplates({ application, source }) {
application.webappEnumerationsDir = `${application.clientSrcDir}app/shared/model/enumerations/`;

source.addWebpackConfig = args => {
const webpackPath = `${application.clientRootDir}webpack/webpack.common.js`;
const ignoreNonExisting = this.sharedData.getControl().ignoreNeedlesError && 'Webpack configuration file not found';
Expand Down Expand Up @@ -147,6 +159,17 @@ export default class ReactGenerator extends BaseApplicationGenerator {
});
},
cleanupOldFilesTask,
async writingEslintFile({ application }) {
await this.writeFiles({
blocks: [
clientRootTemplatesBlock({
templates: [{ sourceFile: 'eslint.config.js.jhi', destinationFile: ctx => `${ctx.eslintConfigFile}.jhi` }],
}),
],
context: application,
rootTemplatesPath: this.fetchFromInstalledJHipster('javascript/generators/eslint/templates'),
});
},
writeFiles,
});
}
Expand Down

0 comments on commit e89145f

Please sign in to comment.