-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgenerate-entity.js
executable file
·33 lines (29 loc) · 1.27 KB
/
generate-entity.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var findEntities = require('./cli/entityfinder').entityFinder,
questions = require('./cli/questions'),
pluralize = require('pluralize'),
entity = require('./cli/entity').entity,
entitybuilder = require('./cli/entitybuilder'),
Promise = require('bluebird'),
ucFirst = require('./cli/ucfirst').ucFirst;
Promise.onPossiblyUnhandledRejection(function(error) {
throw error;
});
console.log([
"------------------------------------------------",
" Generate a CreateReadUpdateDelete.js Entity",
"------------------------------------------------"
].join("\n"));
questions.askEntityName().then(
function(answers) {
entity.name = ucFirst(answers.entityName);
entity.table = pluralize.plural(entity.name).toLowerCase();
entity.primary = 'ID_' + entity.name;
console.log("Creating new CRUD Entity: %s\nTable: %s\nPrimary key: %s", entity.name, entity.table, entity.primary);
return questions.addProperty()
.then(questions.addRelations)
.then(entitybuilder.outputEntity)
.then(entitybuilder.outputConnectors)
.then(entitybuilder.injectForeignProperties)
.then(entitybuilder.injectForeignRelations)
.then(entitybuilder.generateForeignMigrations);
});