Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// read config from .yo-rc.json
this.baseName = this.jhipsterAppConfig.baseName;
this.packageName = this.jhipsterAppConfig.packageName;
this.packageFolder = this.jhipsterAppConfig.packageFolder;
this.clientFramework = this.jhipsterAppConfig.clientFramework;
this.clientPackageManager = this.jhipsterAppConfig.clientPackageManager;
this.buildTool = this.jhipsterAppConfig.buildTool;
// use function in generator-base.js from generator-jhipster
this.angularAppName = this.getAngularAppName();
// use constants from generator-constants.js
const javaDir = `${jhipsterConstants.SERVER_MAIN_SRC_DIR + this.packageFolder}/`;
const javaTestDir = `${jhipsterConstants.SERVER_TEST_SRC_DIR + this.packageFolder}/`;
const resourceDir = jhipsterConstants.SERVER_MAIN_RES_DIR;
const webappDir = jhipsterConstants.CLIENT_MAIN_SRC_DIR;
// variable from questions
this.pubStripeKey = this.props.pubStripeKey;
this.priStripeKey = this.props.priStripeKey;
this.template('payment.jh', 'payment.jh');
} else {
this.warning(`\n Your JHipster configuration is not supported yet ! :( Please use Maven and AngularX...`);
console.log(this.jhipsterAppConfig.clientFramework);
console.log(this.jhipsterAppConfig.buildTool);
}
}
updateFiles() {
// read config from .yo-rc.json
this.baseName = this.jhipsterAppConfig.baseName;
this.packageName = this.jhipsterAppConfig.packageName;
this.packageFolder = this.jhipsterAppConfig.packageFolder;
this.clientFramework = this.jhipsterAppConfig.clientFramework;
this.clientPackageManager = this.jhipsterAppConfig.clientPackageManager;
this.buildTool = this.jhipsterAppConfig.buildTool;
// use function in generator-base.js from generator-jhipster
this.angularAppName = this.getAngularAppName();
// use constants from generator-constants.js
const javaDir = `${jhipsterConstants.SERVER_MAIN_SRC_DIR + this.packageFolder}/`;
const resourceDir = jhipsterConstants.SERVER_MAIN_RES_DIR;
const webappDir = jhipsterConstants.CLIENT_MAIN_SRC_DIR;
const entityName = this.entityConfig.entityClass;
// show all variables
this.log('\n--- some const ---');
this.log(`javaDir=${javaDir}`);
this.log(`resourceDir=${resourceDir}`);
this.log(`webappDir=${webappDir}`);
this.log('\n--- entityName ---');
this.log(`\nentityName=${entityName}`);
this.log('------\n');
// do your stuff here
},
this.buildTool = this.jhAppConfig.buildTool;
this.cacheProvider = this.jhAppConfig.cacheProvider;
// use function in generator-base.js from generator-jhipster
this.angularAppName = this.getAngularAppName();
this.angularXAppName = this.getAngularXAppName();
this.changelogDate = this.dateFormatForLiquibase();
this.jhiPrefix = this.jhAppConfig.jhiPrefix;
// if changelogDate for entity audit already exists then use this existing changelogDate
const liguibaseFileName = glob.sync(`${this.jhAppConfig.resourceDir}/config/liquibase/changelog/*_added_entity_EntityAuditEvent.xml`)[0];
if (liguibaseFileName) {
this.changelogDate = new RegExp('/config/liquibase/changelog/(.*)_added_entity_EntityAuditEvent.xml').exec(liguibaseFileName)[1];
}
// use constants from generator-constants.js
this.webappDir = jhipsterConstants.CLIENT_MAIN_SRC_DIR;
this.javaTemplateDir = 'src/main/java/package';
this.javaDir = `${jhipsterConstants.SERVER_MAIN_SRC_DIR + this.packageFolder}/`;
this.resourceDir = jhipsterConstants.SERVER_MAIN_RES_DIR;
this.interpolateRegex = jhipsterConstants.INTERPOLATE_REGEX;
},
writeAdditionalEntries() {
if (!this.enableTranslation) return;
this.tenantName = this.config.get('tenantName');
/* tenant variables */
mtUtils.tenantVariables(this.tenantName, this);
this.addTranslationKeyToAllLanguages(`${this.tenantNameLowerFirst}Management`, `${this.tenantNameUpperFirst} Management`, 'addAdminElementTranslationKey', this.enableTranslation);
this.addTranslationKeyToAllLanguages(`userManagement${this.tenantNameUpperFirst}`, `${this.tenantNameUpperFirst}`, 'addGlobalTranslationKey', this.enableTranslation);
const languageFiles = {
languages: [
{
condition: generator => generator.enableTranslation,
path: jhipsterConstants.CLIENT_MAIN_SRC_DIR,
templates: [
{
file: 'i18n/en/_tenant-management.json',
renameTo: generator => `i18n/${this.currentLanguage}/${this.tenantNameLowerFirst}-management.json`
}
]
}
]
}
this.languages.forEach((language) => {
this.currentLanguage = language;
this.writeFilesToDisk(languageFiles, this, false);
});
},
};
getConfig() {
const context = this.context;
context.useConfigurationFile = false;
this.env.options.appPath = this.config.get('appPath') || constants.CLIENT_MAIN_SRC_DIR;
context.options = this.options;
context.baseName = this.config.get('baseName');
context.packageName = this.config.get('packageName');
context.applicationType = this.config.get('applicationType');
context.packageFolder = this.config.get('packageFolder');
context.authenticationType = this.config.get('authenticationType');
context.hibernateCache = this.config.get('hibernateCache');
context.databaseType = this.config.get('databaseType') || this.getDBTypeFromDBValue(this.options.db) || 'sql';
// todo: read or prompt for databaseType
context.prodDatabaseType = this.config.get('prodDatabaseType') || this.options.db || 'sql';
context.devDatabaseType = this.config.get('devDatabaseType') || this.options.db;
context.searchEngine = this.config.get('searchEngine') === 'no' ? false : this.config.get('searchEngine');
context.messageBroker = this.config.get('messageBroker') === 'no' ? false : this.config.get('messageBroker');
context.enableTranslation = this.config.get('enableTranslation');
context.nativeLanguage = this.config.get('nativeLanguage');
context.languages = this.config.get('languages');
const mkdirp = require('mkdirp');
const constants = require('generator-jhipster/generators/generator-constants');
/* Constants use throughout */
const MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR;
// const TEST_SRC_DIR = constants.CLIENT_TEST_SRC_DIR;
const REACT_DIR = constants.ANGULAR_DIR;
/**
* The default is to use a file path string. It implies use of the template method.
* For any other config an object { file:.., method:.., template:.. } can be used
*/
const files = {
common: [
{
templates: [
'_package.json',
'_.eslintrc.json',
'_.babelrc',
'_.editorconfig',
'webpack/webpack.common.js',
setUpVariables() {
// Ok
this.webappDir = jhipsterConstants.CLIENT_MAIN_SRC_DIR;
this.angularDir = jhipsterConstants.ANGULAR_DIR;
this.reactDir = jhipsterConstants.REACT_DIR;
this.CLIENT_TEST_SRC_DIR = jhipsterConstants.CLIENT_TEST_SRC_DIR;
// template variables
mtUtils.tenantVariables(this.config.get('tenantName'), this);
},
writeAdditionalFile() {
setupClientconsts() {
// Make constants available in templates
this.MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR;
this.TEST_SRC_DIR = constants.CLIENT_TEST_SRC_DIR;
this.serverPort = this.config.get('serverPort') || this.configOptions.serverPort || 8080;
this.applicationType = this.config.get('applicationType') || this.configOptions.applicationType;
if (!this.applicationType) {
this.applicationType = 'monolith';
}
this.clientFramework = this.config.get('clientFramework') || 'react';
this.useSass = this.config.get('useSass');
this.enableTranslation = this.config.get('enableTranslation'); // this is enabled by default to avoid conflicts for existing applications
this.nativeLanguage = this.config.get('nativeLanguage');
this.languages = this.config.get('languages');
this.messageBroker = this.config.get('messageBroker');
this.packagejs = packagejs;
const baseName = this.config.get('baseName');
if (baseName) {
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const mkdirp = require('mkdirp');
const constants = require('generator-jhipster/generators/generator-constants');
const utils = require('../utils');
const MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR;
const TEST_SRC_DIR = constants.CLIENT_TEST_SRC_DIR;
const VUE_DIR = constants.ANGULAR_DIR;
const CLIENT_VUE_TEMPLATES_DIR = 'vue';
module.exports = {
writeFiles
};
const vueFiles = {
common: [
{
templates: [
'package.json',
'tsconfig.json',
'.huskyrc',
'.postcssrc.js',
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const jhipsterUtils = require('generator-jhipster/generators/utils');
const constants = require('generator-jhipster/generators/generator-constants');
const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR;
module.exports = {
addEntityToMenu,
addEntityToRouterImport,
addEntityToRouter,
addEntityServiceToMainImport,
addEntityServiceToMainConst,
addEntityServiceToMain
};
function addEntityToMenu(generator, entityName, translationKey, className) {
const menuI18nTitle = generator.enableTranslation ? `v-text="$t('global.menu.entities.${translationKey}')"` : '';
jhipsterUtils.rewriteFile(
{
file: `${CLIENT_MAIN_SRC_DIR}/app/core/jhi-navbar/jhi-navbar.vue`,
needle: 'jhipster-needle-add-entity-to-menu',