vtex.colossus
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -107,35 +107,51 @@ // Generated by CoffeeScript 1.7.1 | ||
Gallery.prototype.saveFile = function(appPath, appName, version, key, content, sandbox) { | ||
return Q.Promise(function(resolve, reject, notify) { | ||
var dir; | ||
dir = path.dirname(appPath + key); | ||
return mkdirp(dir, function(err) { | ||
return fs.writeFile(appPath + key, content, function(err) { | ||
return resolve(appPath); | ||
}); | ||
}); | ||
}); | ||
}; | ||
Gallery.prototype.fileExists = function(path) { | ||
return Q.Promise(function(resolve, reject, notify) { | ||
return fs.exists(path, function(exists) { | ||
return resolve(exists); | ||
}); | ||
}); | ||
}; | ||
Gallery.prototype.downloadFilesFromCustomApp = function(appName, version, sandbox) { | ||
var name, promise, saveFile, vendor; | ||
var appPath, name, promise, sandBoxName, vendor; | ||
vendor = appName.split('.')[0]; | ||
name = appName.split('.')[1]; | ||
saveFile = function(appName, version, key, content, sandbox) { | ||
return Q.Promise(function(resolve, reject, notify) { | ||
var appPath, dir, sandBoxName; | ||
if (!sandbox) { | ||
appPath = './apps/' + appName + '/' + version + '/'; | ||
if (!sandbox) { | ||
appPath = './apps/' + appName + '/' + version + '/'; | ||
} else { | ||
sandBoxName = sandbox.replace(':', '/').split('/')[1]; | ||
appPath = './apps/sandbox/' + sandBoxName + '/' + appName + '/'; | ||
} | ||
promise = this.fileExists(appPath); | ||
promise = promise.then((function(_this) { | ||
return function(exists) { | ||
if (!exists || (sandbox != null)) { | ||
return vtexCredentials.getToken().then(function(token) { | ||
return _this.getFiles(vendor, name, token, version, sandbox).then(function(data) { | ||
var appContent, key, promisses, value; | ||
appContent = JSON.parse(data); | ||
promisses = []; | ||
for (key in appContent) { | ||
value = appContent[key]; | ||
promisses.push(_this.saveFile(appPath, appName, version, key, value.content, sandbox)); | ||
} | ||
return Q.all(promisses); | ||
}); | ||
}); | ||
} else { | ||
sandBoxName = sandbox.replace(':', '/').split('/')[1]; | ||
appPath = './apps/sandbox/' + sandBoxName + '/' + appName + '/'; | ||
return [appPath]; | ||
} | ||
dir = path.dirname(appPath + key); | ||
return mkdirp(dir, function(err) { | ||
return fs.writeFile(appPath + key, content, function(err) { | ||
return resolve(appPath); | ||
}); | ||
}); | ||
}); | ||
}; | ||
promise = vtexCredentials.getToken().then((function(_this) { | ||
return function(token) { | ||
return _this.getFiles(vendor, name, token, version, sandbox).then(function(data) { | ||
var appContent, key, promisses, value; | ||
appContent = JSON.parse(data); | ||
promisses = []; | ||
for (key in appContent) { | ||
value = appContent[key]; | ||
promisses.push(saveFile(appName, version, key, value.content, sandbox)); | ||
} | ||
return Q.all(promisses); | ||
}); | ||
}; | ||
@@ -142,0 +158,0 @@ })(this)); |
{ | ||
"name": "vtex.colossus", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
22143
230