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

migrate remaining cjs files to mjs #20680

Merged
merged 9 commits into from
Dec 28, 2022
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: 1 addition & 2 deletions cli/environment-builder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ import { dirname } from 'path';
import { fileURLToPath } from 'url';

import { CLI_NAME, logger } from './utils.mjs';
import generatorUtils from '../generators/utils.cjs';
import { packageNameToNamespace } from '../generators/utils.mjs';
import { parseBlueprintInfo, loadBlueprintsFromConfiguration, mergeBlueprints } from '../utils/blueprint.mjs';

const { packageNameToNamespace } = generatorUtils;
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

Expand Down
3 changes: 1 addition & 2 deletions cli/program.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ import SUB_GENERATORS from './commands.mjs';
import JHipsterCommand from './jhipster-command.mjs';
import { CLI_NAME, logger, getCommand, done } from './utils.mjs';
import { packageJson } from '../lib/index.mjs';
import generatorUtils from '../generators/utils.cjs';
import { packageNameToNamespace } from '../generators/utils.mjs';

const { packageNameToNamespace } = generatorUtils;
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

Expand Down
3 changes: 1 addition & 2 deletions generators/angular/generator.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Generator from './index.mjs';
import { defaultHelpers as helpers } from '../../test/support/helpers.mjs';

import { clientFrameworkTypes } from '../../jdl/jhipster/index.mjs';
import constants from '../generator-constants.cjs';
import { CLIENT_MAIN_SRC_DIR } from '../generator-constants.mjs';
import BaseApplicationGenerator from '../base-application/index.mjs';

const { snakeCase } = lodash;
Expand All @@ -21,7 +21,6 @@ const generator = basename(__dirname);
const generatorFile = join(__dirname, 'index.mts');

const { ANGULAR: clientFramework } = clientFrameworkTypes;
const { CLIENT_MAIN_SRC_DIR } = constants;
const commonConfig = { clientFramework, nativeLanguage: 'en', languages: ['fr', 'en'] };

const samplesBuilder = () =>
Expand Down
2 changes: 1 addition & 1 deletion generators/aws/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import chalk from 'chalk';
import BaseGenerator from '../base/index.mjs';

import prompts from './prompts.mjs';
import AwsFactory from './lib/aws.cjs';
import AwsFactory from './lib/aws.mjs';
import statistics from '../statistics.cjs';
import { GENERATOR_AWS } from '../generator-list.mjs';
import { applicationOptions, databaseTypes } from '../../jdl/jhipster/index.mjs';
Expand Down
14 changes: 8 additions & 6 deletions generators/aws/lib/aws.cjs → generators/aws/lib/aws.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const S3 = require('./s3.cjs');
const Rds = require('./rds.cjs');
const Eb = require('./eb.cjs');
const Iam = require('./iam.cjs');
import S3 from './s3.mjs';
import Rds from './rds.mjs';
import Eb from './eb.mjs';
import Iam from './iam.mjs';

let Aws;
let generator;

const AwsFactory = (module.exports = function AwsFactory(generatorRef, cb) {
const AwsFactory = function AwsFactory(generatorRef, cb) {
generator = generatorRef;
try {
Aws = require('aws-sdk'); // eslint-disable-line
cb();
} catch (e) {
generator.error(`Something went wrong while running jhipster:aws:\n${e}`);
}
});
};

AwsFactory.prototype.init = function initAws(options) {
Aws.config.region = options.region;
Expand All @@ -53,3 +53,5 @@ AwsFactory.prototype.getEb = function getEb() {
AwsFactory.prototype.getIam = function getIa() {
return new Iam(Aws, generator);
};

export default AwsFactory;
5 changes: 3 additions & 2 deletions generators/aws/lib/eb.cjs → generators/aws/lib/eb.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
let aws;
let uuidV4;

const Eb = (module.exports = function Eb(Aws, generator) {
const Eb = function Eb(Aws, generator) {
aws = Aws;
try {
const { v4 } = require('uuid'); // eslint-disable-line
uuidV4 = v4;
} catch (e) {
generator.error(`Something went wrong while running jhipster:aws:\n${e}`);
}
});
};

Eb.prototype.createApplication = function createApplication(params, callback) {
const applicationName = params.applicationName;
Expand Down Expand Up @@ -245,3 +245,4 @@ function updateEnvironment(params, callback) {
}
});
}
export default Eb;
5 changes: 3 additions & 2 deletions generators/aws/lib/iam.cjs → generators/aws/lib/iam.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ const AWS_SERVICE_ARN = suffix => `arn:aws:iam::aws:policy/service-role/${suffix
let aws;
let log;

const Iam = (module.exports = function Iam(Aws, generator) {
const Iam = function Iam(Aws, generator) {
aws = Aws;
log = generator.log;
});
};

const createRole = (RoleName, Description, AssumeRolePolicyDocument) => {
const iam = new aws.IAM();
Expand Down Expand Up @@ -219,3 +219,4 @@ Iam.prototype.verifyRoles = function verifyRoles(params, callback) {
);
});
};
export default Iam;
5 changes: 3 additions & 2 deletions generators/aws/lib/rds.cjs → generators/aws/lib/rds.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
let aws;

const Rds = (module.exports = function Rds(Aws) {
const Rds = function Rds(Aws) {
aws = Aws;
});
};

Rds.prototype.createDatabase = function createDatabase(params, callback) {
const dbInstanceClass = params.dbInstanceClass;
Expand Down Expand Up @@ -148,3 +148,4 @@ function createDbInstance(params, callback) {
}
});
}
export default Rds;
12 changes: 7 additions & 5 deletions generators/aws/lib/s3.cjs → generators/aws/lib/s3.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const fs = require('fs');

const { GRADLE } = require('../../../jdl/jhipster/build-tool-types');
import fs from 'fs';
import { buildToolTypes } from '../../../jdl/jhipster/index.mjs';

const { GRADLE } = buildToolTypes;
const FILE_EXTENSION = '.war';
const S3_STANDARD_REGION = 'us-east-1';

let Progressbar;

const S3 = (module.exports = function S3(Aws, generator) {
const S3 = function S3(Aws, generator) {
this.Aws = Aws;
try {
Progressbar = require('progress'); // eslint-disable-line
} catch (e) {
generator.error(`Something went wrong while running jhipster:aws:\n${e}`);
}
});
};

S3.prototype.createBucket = function createBucket(params, callback) {
const bucket = params.bucket;
Expand Down Expand Up @@ -161,3 +161,5 @@ function success(message, callback) {
function error(message, callback) {
callback({ message }, null);
}

export default S3;
6 changes: 3 additions & 3 deletions generators/azure-app-service/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import statistics from '../statistics.cjs';
import generatorDefaults from '../generator-defaults.mjs';

// Global constants
import constants from '../generator-constants.cjs';
import { JAVA_VERSION, SERVER_MAIN_RES_DIR } from '../generator-constants.mjs';

import { GENERATOR_AZURE_APP_SERVICE } from '../generator-list.mjs';
import { buildToolTypes } from '../../jdl/jhipster/index.mjs';
Expand Down Expand Up @@ -93,7 +93,7 @@ export default class AzureAppServiceGenerator extends BaseGenerator {
this.azureGroupId = '';
},
loadConstants() {
this.JAVA_VERSION = constants.JAVA_VERSION;
this.JAVA_VERSION = JAVA_VERSION;
},
};
}
Expand Down Expand Up @@ -512,7 +512,7 @@ which is free for the first 30 days`);
writeFiles() {
if (this.abort) return;
this.log(chalk.bold('\nCreating Azure App Service deployment files'));
this.template('application-azure.yml.ejs', `${constants.SERVER_MAIN_RES_DIR}/config/application-azure.yml`);
this.template('application-azure.yml.ejs', `${SERVER_MAIN_RES_DIR}/config/application-azure.yml`);
if (this.azureAppServiceDeploymentType === 'github-action') {
this.template('github/workflows/azure-app-service.yml.ejs', '.github/workflows/azure-app-service.yml');
}
Expand Down
10 changes: 5 additions & 5 deletions generators/azure-spring-cloud/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import BaseGenerator from '../base/index.mjs';

import statistics from '../statistics.cjs';

import constants from '../generator-constants.cjs';
import { JAVA_VERSION, CLIENT_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR } from '../generator-constants.mjs';

import { cacheTypes, buildToolTypes } from '../../jdl/jhipster/index.mjs';
import { GENERATOR_AZURE_SPRING_CLOUD } from '../generator-list.mjs';
Expand Down Expand Up @@ -75,7 +75,7 @@ export default class AzureSpringCloudGenerator extends BaseGenerator {
this.loadDerivedPlatformConfig();
},
getConfig() {
this.env.options.appPath = this.config.get('appPath') || constants.CLIENT_MAIN_SRC_DIR;
this.env.options.appPath = this.config.get('appPath') || CLIENT_MAIN_SRC_DIR;
this.cacheProvider = this.cacheProvider || NO_CACHE_PROVIDER;
this.enableHibernateCache = this.enableHibernateCache && ![NO_CACHE_PROVIDER, MEMCACHED].includes(this.cacheProvider);
this.frontendAppName = this.getFrontendAppName();
Expand All @@ -85,7 +85,7 @@ export default class AzureSpringCloudGenerator extends BaseGenerator {
this.azureSpringCloudDeploymentType = this.config.get('azureSpringCloudDeploymentType');
},
loadConstants() {
this.JAVA_VERSION = constants.JAVA_VERSION;
this.JAVA_VERSION = JAVA_VERSION;
},
};
}
Expand Down Expand Up @@ -337,8 +337,8 @@ ${chalk.red('az extension add --name spring-cloud')}`
copyAzureSpringCloudFiles() {
if (this.abort) return;
this.log(chalk.bold('\nCreating Azure Spring Cloud deployment files'));
this.template('application-azure.yml.ejs', `${constants.SERVER_MAIN_RES_DIR}/config/application-azure.yml`);
this.template('bootstrap-azure.yml.ejs', `${constants.SERVER_MAIN_RES_DIR}/config/bootstrap-azure.yml`);
this.template('application-azure.yml.ejs', `${SERVER_MAIN_RES_DIR}/config/application-azure.yml`);
this.template('bootstrap-azure.yml.ejs', `${SERVER_MAIN_RES_DIR}/config/bootstrap-azure.yml`);
if (this.azureSpringCloudDeploymentType === 'github-action') {
this.template('github/workflows/azure-spring-cloud.yml.ejs', '.github/workflows/azure-spring-cloud.yml');
}
Expand Down
138 changes: 0 additions & 138 deletions generators/base-application/priorities.cjs

This file was deleted.

Loading