clwy-express-generator 5.2.0 → 5.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/express-cli.js
CHANGED
|
@@ -315,7 +315,7 @@ function createApplication(name, dir, options, done) {
|
|
|
315
315
|
mkdir(dir, 'migrations')
|
|
316
316
|
mkdir(dir, 'seeders')
|
|
317
317
|
mkdir(dir, 'models')
|
|
318
|
-
copyTemplateMulti('sequelize/models', dir + '/models', 'index.js')
|
|
318
|
+
copyTemplateMulti(options.es6 ? 'sequelize/models/mjs' : 'sequelize/models/js', dir + '/models', 'index.js')
|
|
319
319
|
copyTemplateMulti('sequelize/config', dir + '/config', 'config.json')
|
|
320
320
|
break
|
|
321
321
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "clwy-express-generator",
|
|
3
3
|
"description": "Express' application generator",
|
|
4
4
|
"homepage": "https://github.com/clwy-cn/clwy-express-generator",
|
|
5
|
-
"version": "5.2.
|
|
5
|
+
"version": "5.2.1",
|
|
6
6
|
"author": "TJ Holowaychuk <tj@vision-media.ca>",
|
|
7
7
|
"contributors": [
|
|
8
8
|
"Aaron Heckmann <aaron.heckmann+github@gmail.com>",
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const Sequelize = require('sequelize');
|
|
6
|
+
const process = require('process');
|
|
7
|
+
const basename = path.basename(__filename);
|
|
8
|
+
const env = process.env.NODE_ENV || 'development';
|
|
9
|
+
const config = require(__dirname + '/../config/config.json')[env];
|
|
10
|
+
const db = {};
|
|
11
|
+
|
|
12
|
+
let sequelize;
|
|
13
|
+
if (config.use_env_variable) {
|
|
14
|
+
sequelize = new Sequelize(process.env[config.use_env_variable], config);
|
|
15
|
+
} else {
|
|
16
|
+
sequelize = new Sequelize(config.database, config.username, config.password, config);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
fs.readdirSync(__dirname)
|
|
20
|
+
.filter((file) => {
|
|
21
|
+
return (
|
|
22
|
+
file.indexOf('.') !== 0 &&
|
|
23
|
+
file !== basename &&
|
|
24
|
+
file.slice(-3) === '.js' &&
|
|
25
|
+
file.indexOf('.test.js') === -1
|
|
26
|
+
);
|
|
27
|
+
})
|
|
28
|
+
.forEach((file) => {
|
|
29
|
+
const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
|
|
30
|
+
db[model.name] = model;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
Object.keys(db).forEach((modelName) => {
|
|
34
|
+
if (db[modelName].associate) {
|
|
35
|
+
db[modelName].associate(db);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
db.sequelize = sequelize;
|
|
40
|
+
db.Sequelize = Sequelize;
|
|
41
|
+
|
|
42
|
+
module.exports = db;
|
|
File without changes
|