boom-deploy
Advanced tools
Comparing version 0.2.75 to 0.2.76
@@ -120,3 +120,2 @@ | ||
); | ||
// lazySsh('tar --remove-files -zcvf {{mongoDumpDir}}/' + dumpName + '.tar.gz -C {{mongoDumpDir}}/' + dumpName + '/' + exportMongo.database + ' ./'); | ||
@@ -123,0 +122,0 @@ lazySsh('du -sh {{mongoDumpDir}}/' + dumpName + '.tar.gz'); |
@@ -91,3 +91,3 @@ new Helper(function webMysqlExport(dumpPath, options){ | ||
new Task('web:mysql:dump', function (importEnv){ | ||
new Helper(function webMysqlDump (importEnv, options){ | ||
@@ -106,3 +106,3 @@ if (!importEnv) { | ||
var options = appendMysqlCliOptions({}); | ||
options = appendMysqlCliOptions({}); | ||
console.log(options); | ||
@@ -142,6 +142,73 @@ | ||
}); | ||
new Helper(function selectBuilder (tableName, developers){ | ||
var developersString = '\'' + developers.join('\',\'') + '\''; | ||
var tablesForReplace = { | ||
users: { | ||
login : 'IF(login IN (' + developersString + '), login, SHA1(login))', | ||
role_id : 'IF(login IN (' + developersString + '), \'developer\', role_id)', | ||
password : 'IF(login IN (' + developersString + '), password, SUBSTRING(SHA1(PASSWORD), 1, 8))', | ||
mail : 'IF(login IN (' + developersString + '), mail, CONCAT(SHA1(mail), \'@pochta.com\'))', | ||
phone : 'IF(login IN (' + developersString + '), phone, user_id + 80000000000)' | ||
} | ||
}; | ||
var mysql = get('mysql'); | ||
var fieldsForRaplace = tablesForReplace[tableName]; | ||
if (!fieldsForRaplace) { | ||
return 'SELECT * FROM ' + mysql.dbname + '.' + tableName; | ||
} | ||
var out = lazySsh('mysql ' + getMysqlConnectParams(mysql) + | ||
' -e \"SELECT group_concat(COLUMN_NAME) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = \'' + mysql.dbname + '\' AND TABLE_NAME = \'' + tableName + '\'\"'); | ||
var fields = out.split('\n')[1].split(','); | ||
var replacedFields = fields.map(function(value){ | ||
if (!fieldsForRaplace[value]) return value; | ||
return fieldsForRaplace[value]; | ||
}); | ||
var sql = 'SELECT '; | ||
sql += replacedFields.join(', '); | ||
sql += ' FROM ' + mysql.dbname + '.' + tableName + ' LIMIT 10'; | ||
return sql; | ||
}); | ||
new Task('view:build', function (){ | ||
for (var i in arguments) { | ||
var tableName = arguments[i]; | ||
var dumpTmpPath = '/tmp/' + tableName + '.csv'; | ||
var sql = selectBuilder(tableName, [ | ||
'jiexa', | ||
'ashpumpkin@gmail.com', | ||
'kozirevss@gmail.com', | ||
'aleksandrzen@gmail.com', | ||
'panait.v@yandex.ru', | ||
'ivanfetischev@gmail.com', | ||
'mav-kz@mail.ru' | ||
]); | ||
if (!sql) return; | ||
console.log('########## ' + tableName + ' ##########\n' + sql); | ||
lazySsh('mysql ' + getMysqlConnectParams(get('mysql')) + | ||
' -e ' + JSON.stringify(sql) + ' > ' + dumpTmpPath + | ||
' && cp ' + dumpTmpPath + ' {{mysqlDumpDir}}/'); | ||
lazySsh('ls -lah {{mysqlDumpDir}}'); | ||
// lazySsh('echo "SELECT login, password, role_id, mail, phone FROM view_users WHERE role_id=\'developer\' LIMIT 20" | mysql ' + getMysqlConnectParams(mysql)); | ||
} | ||
}); | ||
new Task('web:mysql:dump', function (importEnv){ | ||
webMysqlDump(importEnv, { | ||
developers: [ | ||
'jiexa', | ||
'ashpumpkin', | ||
'kozirevss@gmail.com', | ||
'aleksandrzen@gmail.com', | ||
'panait.v@yandex.ru', | ||
'ivanfetischev@gmail.com', | ||
'mav-kz@mail.ru' | ||
] | ||
}); | ||
}, 'mysql dump'); | ||
new Helper(function appendMongoCliOptions(options){ | ||
@@ -170,4 +237,10 @@ | ||
new Task('web:mongo:dump', function (importEnv){ | ||
webMongoDump(importEnv); | ||
}, 'mongo dump'); | ||
new Helper(function webMongoDump (importEnv){ | ||
if (!importEnv) { | ||
@@ -205,4 +278,5 @@ exit('Import env not defined.'); | ||
}, 'mongo dump'); | ||
}); | ||
new Helper(function webMongoExport(dumpPath, options){ | ||
@@ -209,0 +283,0 @@ |
@@ -89,3 +89,5 @@ var _ = require('lodash'); | ||
// TODO send to API | ||
fiber.async.bind(fiber, scope.task.bind(scope, taskname, args)), | ||
fiber.async.bind(fiber, function(){ | ||
return scope.task.apply(scope, [taskname].concat(args)) | ||
}), | ||
], function(err){ | ||
@@ -92,0 +94,0 @@ if (err) return exports.error(err); |
@@ -61,3 +61,4 @@ var _ = require('lodash'); | ||
task: function(taskname, args){ | ||
task: function(taskname){ | ||
var args = [].slice.call(arguments, 1); | ||
var task = tasks.get(taskname); | ||
@@ -64,0 +65,0 @@ if (!task) { |
{ | ||
"name": "boom-deploy", | ||
"main": "boom.js", | ||
"version": "0.2.75", | ||
"version": "0.2.76", | ||
"description": "deploy your app", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90181
2492