Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const path = require('path');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');
const constants = require('generator-jhipster/generators/generator-constants');
const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR;
const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR;
const CLIENT_WEBPACK_DIR = constants.CLIENT_WEBPACK_DIR;
describe('Subgenerator languages of Vue.js JHipster blueprint', () => {
context('Creates default i18n files', () => {
before((done) => {
helpers
.run('generator-jhipster/generators/app')
.withOptions({
'from-cli': true,
skipInstall: true,
blueprint: 'vuejs',
skipChecks: true
})
.withGenerators([
[
require('../generators/client/index.js'), // eslint-disable-line global-require
var fs = require('fs');
// 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
//******************************************
//
// Adding a new payment entity
//
//******************************************
var shell = require('shelljs');
//adding ngx-stripe dependency
if (shell.exec('npm install ngx-stripe').code !== 0) {
shell.echo('Error: ngx-stripe installation failed');
shell.exit(1);
// this variable is used in templates
if (this.clientFramework === 'angularX') {
this.angularXAppName = this.getAngularXAppName ? this.getAngularXAppName() : config.angularXAppName;
} else if (this.clientFramework === 'angular1') {
this.angularAppName = this.getAngularAppName ? this.getAngularAppName() : config.angularAppName;
}
if (this.jhipsterMajorVersion > 2) {
this.appFolder = 'app/admin/elasticsearch-reindex/';
this.serviceFolder = this.appFolder;
} else {
this.appFolder = 'scripts/app/admin/elasticsearch-reindex/';
this.serviceFolder = 'scripts/components/admin/';
}
jhipsterVar.javaDir = `${jhipsterConstants.SERVER_MAIN_SRC_DIR + this.packageFolder}/`;
jhipsterVar.resourceDir = jhipsterConstants.SERVER_MAIN_RES_DIR;
jhipsterVar.webappDir = jhipsterConstants.CLIENT_MAIN_SRC_DIR;
function getConfig(context) {
if (context.getJhipsterAppConfig) {
return context.getJhipsterAppConfig();
}
var fromPath = '.yo-rc.json';
if (shelljs.test('-f', fromPath)) {
var fileData = fse.readJsonSync(fromPath);
if (fileData && fileData['generator-jhipster']) {
return fileData['generator-jhipster'];
}
}
return false;
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
*
* 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 cleanup = require('generator-jhipster/generators/cleanup');
const constants = require('generator-jhipster/generators/generator-constants');
const baseServerFiles = require('generator-jhipster/generators/server/files').serverFiles;
/* Constants use throughout */
const INTERPOLATE_REGEX = constants.INTERPOLATE_REGEX;
const SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR;
const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR;
const SERVER_TEST_SRC_DIR = constants.SERVER_TEST_SRC_DIR;
const SERVER_TEST_RES_DIR = constants.SERVER_TEST_RES_DIR;
/* TODO: Do a PR in the parent JHipster project to export and re-use here as well in order to have a single source of truth!!!
const TEST_DIR = constants.TEST_DIR;
const shouldSkipUserManagement = generator =>
generator.skipUserManagement && (generator.applicationType !== 'monolith' || generator.authenticationType !== 'oauth2');
*/
/**
* 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 serverFiles = {
...baseServerFiles,
serverResource: [
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();
// const webappDir = jhipsterConstants.CLIENT_MAIN_SRC_DIR;
this.log(`\nmessage broker type = ${this.messageBrokerType}`);
this.log(`\nmessage broker type = ${this.rabbitMqNameOfMessage}`);
this.log('------\n');
// use constants from generator-constants.js
const javaDir = `${jhipsterConstants.SERVER_MAIN_SRC_DIR + this.packageFolder}/`;
const resourceDir = jhipsterConstants.SERVER_MAIN_RES_DIR;
// add dependencies
if (this.buildTool === 'maven') {
if (typeof this.addMavenDependencyManagement === 'function') {
this.addMavenDependencyManagement('org.springframework.cloud', 'spring-cloud-stream-dependencies', STREAM_CLOUD_DEPENDENCY_VERSION, 'pom', 'import');
this.addMavenDependency('org.springframework.cloud', 'spring-cloud-stream');
this.addMavenDependency('org.springframework.cloud', 'spring-cloud-starter-stream-rabbit');
} else {
this.addMavenDependency('org.springframework.cloud', 'spring-cloud-stream', STREAM_CLOUD_STREAM_VERSION);
this.addMavenDependency('org.springframework.cloud', 'spring-cloud-starter-stream-rabbit', STREAM_RABBIT_VERSION);
}
} else if (this.buildTool === 'gradle') {
if (typeof this.addGradleDependencyManagement === 'function') {
this.addGradleDependencyManagement('mavenBom', 'org.springframework.cloud', 'spring-cloud-stream-dependencies', STREAM_CLOUD_DEPENDENCY_VERSION);
this.addGradleDependency('compile', 'org.springframework.cloud', 'spring-cloud-stream');
this.addGradleDependency('compile', 'org.springframework.cloud', 'spring-cloud-starter-stream-rabbit');
} else {
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;
},
this.templatePath(source),
this.destinationPath(destination),
this
);
};
this.message = this.props.message;
this.baseName = this.props.fxName;
this.packageName = this.props.packageName;
this.path = this.props.path;
this.packageFolder = `${this.props.path}${this.props.fxName}`;
this.buildTool = this.props.buildTool;
// use constants from generator-constants.js
const javaDir = `${jhipsterConstants.SERVER_MAIN_SRC_DIR + this.path}/`;
const resourceDir = jhipsterConstants.SERVER_MAIN_RES_DIR;
// variable from questions
// show all variables
this.log('\n--- some config read from config ---');
this.log(`baseName=${this.baseName}`);
this.log(`packageName=${this.packageName}`);
this.log(`path=${this.path}`);
this.log(`packageFolder=${this.packageFolder}`);
this.log(`buildTool=${this.buildTool}`);
this.log('\n--- some const ---');
this.log(`javaDir=${javaDir}`);
this.log(`resourceDir=${resourceDir}`);
this.composeWith(require.resolve('../kotlin'));
try {
// read config from .yo-rc.json
this.baseName = this.jhAppConfig.baseName;
this.packageName = this.jhAppConfig.packageName;
this.packageFolder = this.jhAppConfig.packageFolder;
this.clientFramework = this.jhAppConfig.clientFramework;
this.clientPackageManager = this.jhAppConfig.clientPackageManager;
this.buildTool = this.jhAppConfig.buildTool;
this.cacheProvider = this.jhAppConfig.cacheProvider;
// 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;
this.javaTemplateDir = 'src/main/java/package';
if (this.entityConfig.entityClass) {
this.log(`\n${chalk.bold.green('I\'m updating the entity for audit ')}${chalk.bold.yellow(this.entityConfig.entityClass)}`);
const entityName = this.entityConfig.entityClass;
const jsonObj = this.entityConfig.data;
this.changelogDate = this.entityConfig.data.changelogDate || this.dateFormatForLiquibase();
genUtils.updateEntityAudit.call(this, entityName, jsonObj, javaDir, resourceDir, true);
}
},
updateConfig() {
const path = require('path');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');
const constants = require('generator-jhipster/generators/generator-constants');
const blueprintPackagejs = require('../package.json');
const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR;
const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR;
const CLIENT_TEST_SRC_DIR = constants.CLIENT_TEST_SRC_DIR;
const CLIENT_SPEC_SRC_DIR = `${CLIENT_TEST_SRC_DIR}spec/`;
const CLIENT_WEBPACK_DIR = constants.CLIENT_WEBPACK_DIR;
const expectedFiles = {
i18n: [
`${CLIENT_MAIN_SRC_DIR}app/locale/translation.service.ts`,
`${CLIENT_MAIN_SRC_DIR}app/shared/config/store/translation-store.ts`,
`${CLIENT_MAIN_SRC_DIR}i18n/en/activate.json`,
`${CLIENT_MAIN_SRC_DIR}i18n/en/audits.json`,
`${CLIENT_MAIN_SRC_DIR}i18n/en/configuration.json`,
`${CLIENT_MAIN_SRC_DIR}i18n/en/error.json`,
`${CLIENT_MAIN_SRC_DIR}i18n/en/global.json`,
`${CLIENT_MAIN_SRC_DIR}i18n/en/health.json`,
`${CLIENT_MAIN_SRC_DIR}i18n/en/login.json`,