Skip to content

Commit 284e8a1

Browse files
authored
Merge pull request #26 from simongfxu/master
init命令完善以及替换bcrypt库
2 parents b9bba3c + 7f6b196 commit 284e8a1

File tree

6 files changed

+18
-11
lines changed

6 files changed

+18
-11
lines changed

bin/db

+13-9
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,43 @@
66
var fs = require('fs');
77
var path = require('path');
88
var _ = require('lodash');
9+
var mysql = require('mysql');
10+
var Promise = require("bluebird");
911
var yargs = require('yargs')
1012
.usage('Usage: $0 <command> [options]')
1113
.command('init', '初始化数据库')
12-
.example('$0 init --dbname codepush --dbhost localhost --dbuser root --dbpassword 123456', '初始化code-push-server数据库')
14+
.example('$0 init --dbname codepush --dbhost localhost --dbuser root --dbpassword 123456 --dbport 3306 --force', '初始化code-push-server数据库')
1315
.default({dbname: 'codepush', dbhost: 'localhost', dbuser: 'root', dbpassword: null})
1416
.help('h')
1517
.alias('h', 'help');
16-
var argv = yargs
17-
.argv;
18+
var argv = yargs.argv;
1819
var command = argv._[0];
19-
var mysql = require('mysql');
20-
var Promise = require("bluebird");
2120
var dbname = argv.dbname ? argv.dbname : 'codepush';
2221
var dbhost = argv.dbhost ? argv.dbhost : 'localhost';
2322
var dbuser = argv.dbuser ? argv.dbuser : 'root';
23+
var dbport = argv.dbport ? argv.dbport : 3306;
2424
var dbpassword = _.isString(argv.dbpassword) ? argv.dbpassword : null;
2525
if (command === 'init') {
2626
var connection2;
2727
var connection = mysql.createConnection({
2828
host: dbhost,
2929
user: dbuser,
30-
password: dbpassword
30+
password: dbpassword,
31+
port: dbport
3132
});
33+
var createDatabaseSql = argv.force ? `CREATE DATABASE if not exists ${dbname}` :
34+
`CREATE DATABASE ${dbname}`;
3235
Promise.promisifyAll(connection);
3336
connection.connect();
34-
connection.queryAsync(`CREATE DATABASE ${dbname}`)
37+
connection.queryAsync(createDatabaseSql)
3538
.then(function(){
3639
connection2 = mysql.createConnection({
3740
host: dbhost,
3841
user: dbuser,
3942
password: dbpassword,
4043
database: dbname,
41-
multipleStatements: true
44+
multipleStatements: true,
45+
port: dbport
4246
});
4347
connection2.connect();
4448
Promise.promisifyAll(connection2);
@@ -68,4 +72,4 @@ if (command === 'init') {
6872
});
6973
} else {
7074
yargs.showHelp();
71-
}
75+
}

config/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ config.development = {
66
password: null,
77
database: "codepush",
88
host: "127.0.0.1",
9+
port: 3306,
910
dialect: "mysql"
1011
},
1112
// Config for qiniu (http://www.qiniu.com/) cloud storage when storageType value is "qiniu".

config/config.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ config.test = {
77
password: null,
88
database: "codepush_test",
99
host: "127.0.0.1",
10+
port: 3306,
1011
dialect: "mysql"
1112
},
1213
local: {

config/config.testwin.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ config.test = {
77
password: "Password12!",
88
database: "codepush_test",
99
host: "127.0.0.1",
10+
port: 3306,
1011
dialect: "mysql"
1112
},
1213
local: {

core/utils/security.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
var bcrypt = require('bcrypt');
2+
var bcrypt = require('bcryptjs');
33
var crypto = require('crypto');
44
var fs = require('fs');
55
var Promise = require('bluebird');

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
},
3737
"dependencies": {
3838
"aws-sdk": "^2.7.0",
39-
"bcrypt": "^0.8.7",
39+
"bcryptjs": "^2.3.0",
4040
"bluebird": "^3.4.1",
4141
"body-parser": "^1.15.2",
4242
"cookie-parser": "^1.4.3",

0 commit comments

Comments
 (0)