Skip to content

Commit

Permalink
use shelljs and lodash instead of fs-extra and underscore.string
Browse files Browse the repository at this point in the history
  • Loading branch information
ecostanzi committed Sep 2, 2019
1 parent f96ecbb commit 2cc6672
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
12 changes: 5 additions & 7 deletions generators/openapi-client/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@

const path = require('path');
const shelljs = require('shelljs');
const s = require('underscore.string');
const _ = require('lodash');
const chalk = require('chalk');
const fs = require('fs-extra');
const jhipsterConstants = require('../generator-constants');

module.exports = {
Expand Down Expand Up @@ -56,11 +54,11 @@ function writeFiles() {
let command;
if (generatorName === 'spring') {
this.log(chalk.green(`\n\nGenerating java client code for client ${cliName} (${inputSpec})`));
const cliPackage = `${this.packageName}.client.${s.underscored(cliName)}`;
const cliPackage = `${this.packageName}.client.${_.snakeCase(cliName)}`;
const clientPackageLocation = path.resolve('src', 'main', 'java', ...cliPackage.split('.'));
if (fs.pathExistsSync(clientPackageLocation)) {
if (shelljs.test('-d', clientPackageLocation)) {
this.log(`cleanup generated java code for client ${cliName} in directory ${clientPackageLocation}`);
fs.removeSync(clientPackageLocation);
shelljs.rm('-rf', clientPackageLocation);
}

JAVA_OPTS = ' -Dmodels -Dapis -DsupportingFiles=ApiKeyRequestInterceptor.java,ClientConfiguration.java ';
Expand All @@ -69,12 +67,12 @@ function writeFiles() {
' generate -g spring ' +
` -t ${path.resolve(__dirname, 'templates/swagger-codegen/libraries/spring-cloud')} ` +
' --library spring-cloud ' +
` -i ${inputSpec} --artifact-id ${s.camelize(cliName)} --api-package ${cliPackage}.api` +
` -i ${inputSpec} --artifact-id ${_.camelCase(cliName)} --api-package ${cliPackage}.api` +
` --model-package ${cliPackage}.model` +
' --type-mappings DateTime=OffsetDateTime,Date=LocalDate ' +
' --import-mappings OffsetDateTime=java.time.OffsetDateTime,LocalDate=java.time.LocalDate' +
` -DdateLibrary=custom,basePackage=${this.packageName}.client,configPackage=${cliPackage},` +
`title=${s.camelize(cliName)}`;
`title=${_.camelCase(cliName)}`;

if (this.clientsToGenerate[cliName].useServiceDiscovery) {
params += ' --additional-properties ribbon=true';
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
"through2": "3.0.1",
"uuid": "3.3.2",
"sync-request": "6.0.0",
"underscore.string": "3.3.4",
"yeoman-environment": "2.3.4",
"yeoman-generator": "3.2.0",
"yo": "3.1.0"
Expand Down

0 comments on commit 2cc6672

Please sign in to comment.