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

Rename generators files from js to ts. #27187

Merged
merged 12 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default ts.config(
},
rules: {
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/ban-ts-comment': ['off', { 'ts-nocheck': true }],
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-unused-vars': 'off',
Expand All @@ -38,7 +39,7 @@ export default ts.config(
},
},
{
files: ['**/*.spec.{js,ts}'],
files: ['**/*.spec.ts'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
Expand Down
2 changes: 1 addition & 1 deletion generators/angular/entity-files-angular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type { GeneratorDefinition } from '../base-application/generator.js';
import { clientApplicationTemplatesBlock } from '../client/support/files.js';
import type CoreGenerator from '../base-core/index.js';
import type { WriteFileSection } from '../base/api.js';
import { asWritingEntitiesTask } from '../base-application/support/task-type-inference.js';
import { asWritingEntitiesTask } from '../base-application/support/index.js';

const entityModelFiles = clientApplicationTemplatesBlock({
templates: ['entities/_entityFolder_/_entityFile_.model.ts', 'entities/_entityFolder_/_entityFile_.test-samples.ts'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { asWritingTask } from '../base-application/support/index.js';
import { clientApplicationTemplatesBlock, clientRootTemplatesBlock, clientSrcTemplatesBlock } from '../client/support/files.js';

export const files = {
Expand Down Expand Up @@ -437,11 +437,11 @@ export const files = {
],
};

export async function writeFiles({ application }) {
export const writeFiles = asWritingTask(async function writeFiles({ application }) {
if (!application.clientFrameworkAngular) return;

await this.writeFiles({
sections: files,
context: application,
});
}
});
1 change: 1 addition & 0 deletions generators/angular/generator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
6 changes: 4 additions & 2 deletions generators/app/cleanup.js → generators/app/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
* limitations under the License.
*/

import { asWritingTask } from '../base-application/support/index.js';

/**
* Removes files that where generated in previous JHipster versions and therefore
* need to be removed.
*/
export default function cleanupOldFilesTask() {
export default asWritingTask(function cleanupOldFilesTask() {
if (this.isJhipsterVersionLessThan('6.1.0')) {
this.config.delete('blueprint');
this.config.delete('blueprintVersion');
}
}
});
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ const getEnums = (enums, customValuesState, comments) => {

const matched = /\s*(.+?)\s*\((.+?)\)/.exec(enumValue);
return {
name: matched[1],
value: matched[2],
comment: comments && comments[matched[1]] && formatDocAsJavaDoc(comments[matched[1]], 4),
name: matched![1],
value: matched![2],
comment: comments && comments[matched![1]] && formatDocAsJavaDoc(comments[matched![1]], 4),
};
});
};
Expand All @@ -84,7 +84,7 @@ const extractEnumEntries = field => {
* @return {Object} the enum info.
*/

export const getEnumInfo = (field, clientRootFolder) => {
export const getEnumInfo = (field, clientRootFolder?) => {
field.enumInstance = extractEnumInstance(field); // TODO remove side effect
const enums = extractEnumEntries(field);
const customValuesState = getCustomValuesState(enums);
Expand Down
1 change: 1 addition & 0 deletions generators/base-application/support/prepare-field.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ describe('generator - base-application - support - prepareField', () => {
describe('getEnumValuesWithCustomValues', () => {
describe('when not passing anything', () => {
it('should fail', () => {
// @ts-expect-error testing invalid arguments
expect(() => getEnumValuesWithCustomValues()).to.throw(/^Enumeration values must be passed to get the formatted values\.$/);
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/* eslint-disable no-console */
import chalk from 'chalk';
import { camelCase } from 'lodash-es';
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions generators/bootstrap-application-base/generator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
1 change: 1 addition & 0 deletions generators/bootstrap/support/multi-step-transform/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
export default class TemplateData {
constructor(templateFile, defaultData = {}) {
this._templateFile = templateFile;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import assert from 'assert';
import path from 'path';
import debugBuilder from 'debug';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down Expand Up @@ -55,11 +56,11 @@ export default class CiCdGenerator extends BaseApplicationGenerator {

// Public API method used by the getter and also by Blueprints
get loading() {
return {
return this.asLoadingTaskGroup({
loadSharedConfig({ application }) {
loadConfig.call(this, command.configs, { application });
},
};
});
}

get [BaseApplicationGenerator.LOADING]() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ describe('generator - client - support - template-utils', () => {
});
describe('when passing undefined', () => {
it('returns an empty string', () => {
// @ts-expect-error testing invalid argument
expect(getEntityParentPathAddition()).to.equal('');
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down Expand Up @@ -43,7 +44,7 @@ export const filterRelevantRelationships = relationships => {
* @param {string} clientFramework the client framework, 'angular', 'vue' or 'react'.
* @returns typeImports: Map
*/
export const generateEntityClientImports = (relationships, dto, clientFramework) => {
export const generateEntityClientImports = (relationships, dto?, clientFramework?) => {
const typeImports = new Map();

const relevantRelationships = filterRelevantRelationships(relationships);
Expand Down
1 change: 1 addition & 0 deletions generators/common/files.js → generators/common/files.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
1 change: 1 addition & 0 deletions generators/docker/utils.js → generators/docker/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
15 changes: 12 additions & 3 deletions generators/entity/generator.js → generators/entity/generator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down Expand Up @@ -134,7 +135,9 @@ export default class EntityGenerator extends BaseApplicationGenerator {
context.microserviceFileName = this.destinationPath(this.entityConfig.microservicePath, context.filename);
context.useConfigurationFile = true;

this.log.verboseInfo(`\nThe entity ${context.name} is being updated.\n`);
this.log.verboseInfo(`
The entity ${context.name} is being updated.
`);
try {
// We are generating a entity from a microservice.
// Load it directly into our entity configuration.
Expand Down Expand Up @@ -177,14 +180,20 @@ export default class EntityGenerator extends BaseApplicationGenerator {
}
context.useConfigurationFile = context.configurationFileExists || context.useConfigurationFile;
if (context.configurationFileExists) {
this.log.log(chalk.green(`\nFound the ${context.filename} configuration file, entity can be automatically generated!\n`));
this.log.log(
chalk.green(`
Found the ${context.filename} configuration file, entity can be automatically generated!
`),
);
}

// Structure for prompts.
this.entityStorage.defaults({ fields: [], relationships: [] });

if (!context.useConfigurationFile) {
this.log.verboseInfo(`\nThe entity ${entityName} is being created.\n`);
this.log.verboseInfo(`
The entity ${entityName} is being created.
`);
}
},
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down Expand Up @@ -27,8 +28,8 @@
* @returns {number} parsed number if valid input; <code>NaN</code> otherwise
*/
const filterNumber = (input, isSigned, isDecimal) => {
const signed = isSigned ? '(\\-|\\+)?' : '';
const decimal = isDecimal ? '(\\.[0-9]+)?' : '';
const signed = isSigned ? '(-|+)?' : '';
const decimal = isDecimal ? '(.[0-9]+)?' : '';
const regex = new RegExp(`^${signed}([0-9]+${decimal})$`);

if (regex.test(input)) return Number(input);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand All @@ -16,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { asWriteFilesSection } from '../base-application/support/task-type-inference.js';
import { asWriteFilesSection } from '../base-application/support/index.js';
import { LOCAL_BLUEPRINT_OPTION } from './constants.js';

export const files = asWriteFilesSection({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
5 changes: 3 additions & 2 deletions generators/javascript/generators/eslint/support/tasks.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand All @@ -16,10 +17,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { asWritingTask } from '../../../../base-application/support/task-type-inference.js';
import { asWritingTask } from '../../../../base-application/support/index.js';
import { clientRootTemplatesBlock } from '../../../../client/support/files.js';

export const writeEslintClientRootConfigFile = asWritingTask(async function writingEslintFile({ application }) {
export const writeEslintClientRootConfigFile: any = asWritingTask(async function writingEslintFile({ application }) {
await this.writeFiles({
blocks: [
clientRootTemplatesBlock({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down Expand Up @@ -133,6 +134,7 @@ export default class KubernetesHelmGenerator extends BaseWorkspacesGenerator {

setPostPromptProp() {
this.appConfigs.forEach(element => {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
element.clusteredDb ? (element.dbPeerCount = 3) : (element.dbPeerCount = 1);
if (element.messageBroker === KAFKA) {
this.useKafka = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down
Loading
Loading