Skip to content

Commit

Permalink
fix(eslint formatting): resolved eslint errors
Browse files Browse the repository at this point in the history
affects: @nodejs-code-generator/server
  • Loading branch information
saloni-dhiwise committed Jan 11, 2022
1 parent a7fe3c0 commit 2c71bf2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"release_patch": "lerna publish patch --conventional-commits && conventional-github-releaser --preset angular",
"release_premajor": "lerna publish premajor --conventional-commits && conventional-github-releaser --preset angular",
"release": "lerna publish --conventional-commits && conventional-github-releaser --preset angular",
"lint": "eslint ."
"lint": "eslint . --ext .js --fix"
},
"jest": {
"modulePathIgnorePatterns": [
Expand Down
1 change: 1 addition & 0 deletions packages/server/usecase/application/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ const generate = (applicationRepo, schemaRepo, generatorRepo) => async (params)
const generatedApps = await generatorRepo.getDetails(query);

if (generatedApps.length > 0) {
// eslint-disable-next-line prefer-destructuring
generated = generatedApps[0]; // latest App
generated.id = generated._id;
isReBuild = true;
Expand Down
20 changes: 10 additions & 10 deletions packages/server/usecase/application/node-generator/codeGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ const { configureMongoAuthTestCases } = require('./createApplication/createTestC
const { configureSequelizeAuthTestCases } = require('./createApplication/createTestCases/sequelizeTestCases');

class CodeGenerator {
constructor(projectType) {
constructor (projectType) {
this.projectType = projectType;
const settingJson = projectSetting.setup(this.projectType);
this.setup = settingJson[this.projectType];
}

async createApp(params) {
async createApp (params) {
const {
steps, templateFolderName, templateRegistry, userDirectoryStructure,
} = this.setup;
Expand Down Expand Up @@ -233,10 +233,10 @@ class CodeGenerator {
database: this.jsonData.config.databaseName,
port: this.jsonData.config.port,
},
{
socialAuth: _.cloneDeep(this.auth.socialAuth),
env,
});
{
socialAuth: _.cloneDeep(this.auth.socialAuth),
env,
});
this.env = envs;
this.jsonData = jsonData;
this.postmanCollection.config = this.jsonData.config;
Expand All @@ -251,9 +251,9 @@ class CodeGenerator {
envs, jsonData,
} = await generateService.createEnvFileSequelize(this.setup.templateFolderName,
this.jsonData, {
database: this.jsonData.config.databaseName,
port: this.jsonData.config.port,
},
database: this.jsonData.config.databaseName,
port: this.jsonData.config.port,
},
{
socialAuth: this.auth.socialAuth,
env,
Expand Down Expand Up @@ -616,7 +616,7 @@ class CodeGenerator {
}

// ? create root directory
async createProjectRootDirectory(directory, projectName) {
async createProjectRootDirectory (directory, projectName) {
writeOperations.mkdir(directory, projectName);
writeOperations.mkdir(`${directory}${path.sep}${projectName}`, 'logs');
return `${directory}${path.sep}${projectName}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const fakeDataMongoose = require('../generateFakeData');
const fakeDataSequelize = require('../generateFakeDataSequelize');
const { removeGivenKeyFromObject } = require('../utils/common');

async function createMVCBlankFolder(dir, userDirectoryStructure) {
async function createMVCBlankFolder (dir, userDirectoryStructure) {
writeOperations.mkdir(dir, userDirectoryStructure.controllerFolderPath);
writeOperations.mkdir(dir, userDirectoryStructure.modelFolderPath);
writeOperations.mkdir(dir, userDirectoryStructure.configFolderPath);
Expand All @@ -29,13 +29,13 @@ async function createMVCBlankFolder(dir, userDirectoryStructure) {
writeOperations.mkdir(dir, userDirectoryStructure.viewsFolderPath);
writeOperations.mkdir(dir, 'postman');
}
function createAppName(Name) {
function createAppName (Name) {
return Name
.replace(/[^A-Za-z0-9.-]+/g, '-')
.replace(/^[-_.]+|-+$/g, '')
.toLowerCase();
}
async function createPackageJson({
async function createPackageJson ({
name,
packages,
mainJsFile,
Expand Down Expand Up @@ -94,7 +94,7 @@ async function createPackageJson({
return pkg;
}

async function createPackageJsonForSequelize({
async function createPackageJsonForSequelize ({
name,
packages,
mainJsFile,
Expand Down Expand Up @@ -152,7 +152,7 @@ async function createPackageJsonForSequelize({
return pkg;
}

async function setUpAppJS(templateFolder, jsonData) {
async function setUpAppJS (templateFolder, jsonData) {
const app = writeOperations.loadTemplate(`${templateFolder}/app.js`);

app.locals.NO_PLATFORM = false;
Expand Down Expand Up @@ -188,7 +188,7 @@ async function setUpAppJS(templateFolder, jsonData) {
return app;
}

async function setDB(dir, adapter = '') {
async function setDB (dir, adapter = '') {
const db = writeOperations.loadTemplate(`${dir}/db.js`);
if (!isEmpty(adapter)) {
db.locals.ADAPTER = adapter;
Expand All @@ -200,7 +200,7 @@ async function setDB(dir, adapter = '') {
}
return db;
}
async function createEnvFile(templateFolder, jsonData, {
async function createEnvFile (templateFolder, jsonData, {
database, port,
}, options = {}) {
const env = writeOperations.loadTemplate(`${templateFolder}/.env`);
Expand Down Expand Up @@ -326,7 +326,7 @@ async function createEnvFile(templateFolder, jsonData, {
};
}

async function createEnvFileSequelize(templateFolder, jsonData, {
async function createEnvFileSequelize (templateFolder, jsonData, {
database, port,
}, options = {}) {
const env = writeOperations.loadTemplate(`${templateFolder}/.env`);
Expand Down Expand Up @@ -470,7 +470,7 @@ async function createEnvFileSequelize(templateFolder, jsonData, {
};
}

async function createValidationFile(validationFilePath, jsonData, auth, adapter = '', enumData) {
async function createValidationFile (validationFilePath, jsonData, auth, adapter = '', enumData) {
const {
isAuth, userModel, socialAuth,
} = auth;
Expand Down Expand Up @@ -546,7 +546,7 @@ async function createValidationFile(validationFilePath, jsonData, auth, adapter
});
return validatedObj;
}
async function createPostmanCollection(pName, postmanCollections, auth) {
async function createPostmanCollection (pName, postmanCollections, auth) {
const {
isAuth, userModel, userLoginWith, loginAccessPlatform, userRoles, socialAuth,
} = auth;
Expand All @@ -563,7 +563,7 @@ async function createPostmanCollection(pName, postmanCollections, auth) {
const envPostman = await postman.generateEnvForPostman(postmanCollections.config);
return [jsonCollectionsV20, jsonCollectionsV21, envPostman];
}
async function createCCBlankFolder(dir, userDirectoryStructure) {
async function createCCBlankFolder (dir, userDirectoryStructure) {
writeOperations.mkdir(dir, userDirectoryStructure.controllerFolderPath);
writeOperations.mkdir(dir, userDirectoryStructure.modelFolderPath);
writeOperations.mkdir(dir, userDirectoryStructure.entityFolderPath);
Expand All @@ -580,7 +580,7 @@ async function createCCBlankFolder(dir, userDirectoryStructure) {
writeOperations.mkdir(dir, 'seeders');
}

async function envParser(env) {
async function envParser (env) {
const envObj = {};
forEach(env.environments, (value) => {
envObj[value] = {};
Expand All @@ -591,7 +591,7 @@ async function envParser(env) {
return envObj;
}

async function addSeederMongoose(jsonData, filePath, authObj) {
async function addSeederMongoose (jsonData, filePath, authObj) {
const roles = authObj.userRoles;
const { models } = jsonData;
const seeder = writeOperations.loadTemplate(`${filePath}/index.js`);
Expand Down Expand Up @@ -681,7 +681,7 @@ async function addSeederMongoose(jsonData, filePath, authObj) {
return [seeder, user];
}

async function addSeederSequelize(jsonData, filePath, authObj) {
async function addSeederSequelize (jsonData, filePath, authObj) {
// const roles = commonService.uniqRolesFromRolePermissions(jsonData.rolePermission);
const roles = authObj.userRoles;
const { models } = jsonData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { PROJECT_TYPE } = require('./constants/constant');
global.__basedir = __dirname;
const CodeGenerator = require('./codeGenerator');

function trimModelNameFromInput(models) {
function trimModelNameFromInput (models) {
const oldModelNames = _.keys(models);
let newModelNames = [];
_.forEach(models, (model, modelName) => {
Expand All @@ -18,7 +18,7 @@ function trimModelNameFromInput(models) {
throw new Error('modelName should not contain spaces');
}

async function main(inputFilepath, isReBuild) {
async function main (inputFilepath, isReBuild) {
let projectPath;
try {
const inputData = fs.readFileSync(inputFilepath, { encoding: 'utf8' });
Expand Down

0 comments on commit 2c71bf2

Please sign in to comment.