@bluecadet/bcdb
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -6,2 +6,32 @@ const fs = require('fs'); | ||
function processResponse(response, filepath) { | ||
let db_user = response.db_user ? response.db_user : 'root'; | ||
let db_pass = response.db_pass ? response.db_pass : 'root'; | ||
let db_host = response.db_host ? response.db_host : 'localhost'; | ||
let data = `module.exports = { | ||
site: '${response.pantheon_site}', | ||
localDatabase: { | ||
name: '${response.db_name}', | ||
user: '${db_user}', | ||
pass: '${db_pass}', | ||
host: '${db_host}', | ||
}, | ||
format: '${response.setup}', | ||
file_path: '${filepath}', | ||
}`; | ||
// Write file with config data | ||
fs.writeFileSync(utils.BCDB_PROJECT_FILE, data, function(err) { | ||
if (err) { | ||
throw Error(err); | ||
} | ||
}); | ||
console.log(chalk.green('⚡️ Project config complete!')); | ||
} | ||
module.exports = function() { | ||
@@ -41,3 +71,3 @@ | ||
type: 'input', | ||
query: `${chalk.cyan('Local database hostname')} (root):`, | ||
query: `${chalk.cyan('Local database hostname')} (localhost):`, | ||
handle: 'db_host' | ||
@@ -57,28 +87,19 @@ }, | ||
let db_user = response.db_user ? response.db_user : 'root'; | ||
let db_pass = response.db_pass ? response.db_pass : 'root'; | ||
let db_host = response.db_host ? response.db_host : 'localhost'; | ||
let data = `module.exports = { | ||
site: '${response.pantheon_site}', | ||
localDatabase: { | ||
name: '${response.db_name}', | ||
user: '${db_user}', | ||
pass: '${db_pass}', | ||
host: '${db_host}', | ||
}, | ||
format: '${response.setup}', | ||
file_path: '${utils.cmsFilePath(response.setup)}', | ||
}`; | ||
let filepath = false; | ||
// Write file with config data | ||
fs.writeFileSync(utils.BCDB_PROJECT_FILE, data, function(err) { | ||
if (err) { | ||
throw Error(err); | ||
} | ||
}); | ||
if ( response.setup === 'Custom File Path' ) { | ||
qoa.prompt([{ | ||
type: 'input', | ||
query: `${chalk.cyan('Relative path to files:')}`, | ||
handle: 'file_path' | ||
}]) | ||
.then((fp_response) => { | ||
processResponse(response, fp_response.file_path); | ||
}); | ||
} else { | ||
processResponse(response, utils.cmsFilePath(response.setup)); | ||
} | ||
console.log(chalk.green('⚡️ Project config complete!')); | ||
}); | ||
} |
@@ -137,22 +137,18 @@ const utils = require('./utils.js'); | ||
.set('ipv4') | ||
.progress() | ||
.set('out-format', '%n') | ||
// .progress() | ||
.exclude(ryscExcludes) | ||
.shell('ssh -p 2222') | ||
.source(`${creds.sftp_username}@${creds.sftp_host}:files`) | ||
.destination(SITE_PATH); | ||
.source(`${creds.sftp_username}@${creds.sftp_host}:files/`) | ||
.destination(FILES_PATH); | ||
console.log(chalk.blue(`...Syncing files...`)); | ||
rsync.execute(function(err) { | ||
rsync.execute(function(err, code, cmd) { | ||
if (err) { | ||
console.log(chalk.red('Error @ rsync')); | ||
console.log(err); | ||
throw Error(err); | ||
} | ||
// Copy all that jazz | ||
console.log(chalk.blue(`...Moving files into place...`)); | ||
fsx.emptyDirSync(FILES_PATH); | ||
fsx.copySync(`${SITE_PATH}/files`, FILES_PATH, { overwrite: true }); | ||
fsx.emptyDirSync(SITE_PATH); | ||
console.log(chalk.green('💫 File import complete!')); | ||
@@ -162,7 +158,3 @@ | ||
var out = data.toString('utf-8').split(/\r?\n/); | ||
out.forEach(str => { | ||
if ( str.startsWith('files/') ) { | ||
console.log(str); | ||
} | ||
}); | ||
console.log(out[0]); | ||
}); | ||
@@ -169,0 +161,0 @@ |
@@ -24,2 +24,3 @@ const os = require('os'); | ||
'WordPress: Default', | ||
'Custom File Path' | ||
]; | ||
@@ -26,0 +27,0 @@ |
{ | ||
"name": "@bluecadet/bcdb", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "bugs": { |
@@ -46,4 +46,9 @@ # BCDB | ||
### pull | ||
### pull [--exclude=file/path] | ||
Run `bcdb pull` to pull a database or files from a specfic Pantheon enviornment | ||
Run `bcdb pull` to pull a database or files from a specfic Pantheon enviornment | ||
You can optionally pass directories or other rsync `exclude` parameters with the `--exclude=` argument. Seperate excludes with a comma: | ||
`bcdb pull --exclude=files/path` | ||
`bcdb pull --exclude=files/path,another/path` |
16945
441
53