Comparing version 1.1.2 to 1.1.3
@@ -14,12 +14,18 @@ /** | ||
exec = require('child_process').exec, | ||
cloudpt = require('nodecloudpt')(config); | ||
meocloud = require('meocloud')(config); | ||
var CLOUDIFY_FOLDER = '/cloudify'; | ||
var run = function() { | ||
var options = { path: '/cloudify', list: false }; | ||
cloudpt.metadata(options, function(data) { | ||
// we dont support directories, for now | ||
if (data && data.is_dir === false) { | ||
cloudpt.createFolder({ path: '/cloudify' }, upload); | ||
var options = { list: false }; | ||
meocloud.metadata(CLOUDIFY_FOLDER, options, function(err, data) { | ||
if (data && data.is_dir === true && !data.is_deleted) { | ||
upload(true); | ||
} else { | ||
upload(); | ||
console.log('Cloudify folder does not exist. Creating...'); | ||
meocloud.createFolder({ path: CLOUDIFY_FOLDER }, function(err, data) { | ||
if (err) { throw err; } | ||
var success = data && data.is_dir === true; | ||
return upload(success); | ||
}); | ||
} | ||
@@ -30,13 +36,21 @@ return; | ||
var upload = function() { | ||
var options = { | ||
path: '/cloudify/' + path.basename(filename), | ||
file: filename | ||
}; | ||
var upload = function(data) { | ||
if (!data) { | ||
console.log('Error: /cloudify folder could not be created remotely'); | ||
process.exit(-1); | ||
} | ||
var destinationPath = CLOUDIFY_FOLDER + '/' + path.basename(filename); | ||
var fileStats = fs.statSync(filename); | ||
var fileSize = getPrettyFileSize(fileStats.size); | ||
console.log('Uploading (' + fileSize +') ...'); | ||
cloudpt.upload(options, function(data) { | ||
meocloud.upload(filename, destinationPath, {}, function(err, data, status) { | ||
if (err) { throw err; } | ||
if (status !== 200) { | ||
console.log('Warning: File with same name already exists. Aborting.'); | ||
process.exit(1); | ||
} | ||
if (data) { getPublicLink(); } | ||
@@ -48,10 +62,7 @@ return; | ||
var getPublicLink = function() { | ||
var options = { path: '/cloudify/' + path.basename(filename) }; | ||
cloudpt.shares(options, function(data) { | ||
data = data || null; | ||
try { | ||
data = JSON.parse(data); | ||
} | ||
catch(e) { | ||
console.log('Error: service returned unhandled exception'); | ||
var cpath = CLOUDIFY_FOLDER + '/' + path.basename(filename); | ||
meocloud.shares(cpath, function(err, data, status) { | ||
if (err) { throw err; } | ||
if (status !== 200) { | ||
console.log('Error: service returned status ' + status); | ||
process.exit(0); | ||
@@ -66,4 +77,3 @@ } | ||
saveToPasteboard(outURL); | ||
} | ||
else { | ||
} else { | ||
console.log('Error: unable to get public URL'); | ||
@@ -70,0 +80,0 @@ } |
@@ -17,3 +17,3 @@ { | ||
], | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"repository": { | ||
@@ -24,4 +24,4 @@ "type": "git", | ||
"dependencies": { | ||
"nodecloudpt": ">= 0.5.3", | ||
"oauth": ">= 0.9.10" | ||
"oauth": ">= 0.9.10", | ||
"meocloud": "~0.0.2" | ||
}, | ||
@@ -40,2 +40,5 @@ "engines": { | ||
], | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"licenses": [ | ||
@@ -50,4 +53,6 @@ { | ||
"grunt": "~0.4.1", | ||
"grunt-shell": "~0.4.0" | ||
"grunt-shell": "~0.4.0", | ||
"chai": "~1.8.1", | ||
"mocha": "~1.14.0" | ||
} | ||
} |
@@ -1,21 +0,41 @@ | ||
var assert = require('assert'); | ||
var expect = require('chai').expect, | ||
exec = require('child_process').exec; | ||
describe('Cloudify bin', function() { | ||
describe('test --help', function() { | ||
process.argv = [ | ||
'node', | ||
'cloudify.js', | ||
'--help' | ||
]; | ||
var cloudify = require('./../bin/cloudify'); | ||
it('should output help info when passed -h', function(done) { | ||
exec('./bin/cloudify -h --test', function(error, stdout, stderr) { | ||
expect(error).to.be.null; | ||
expect(stdout).to.match(/^Usage\: cloudify \[options\] \<file\_to\_share\>/); | ||
expect(stderr).to.be.empty; | ||
done(); | ||
}); | ||
}); | ||
describe('test --version', function() { | ||
process.argv = [ | ||
'node', | ||
'cloudify.js', | ||
'--version' | ||
]; | ||
var cloudify = require('./../bin/cloudify'); | ||
it('should output help info when passed --help', function(done) { | ||
exec('./bin/cloudify --help --test', function(error, stdout, stderr) { | ||
expect(error).to.be.null; | ||
expect(stdout).to.match(/^Usage\: cloudify \[options\] \<file\_to\_share\>/); | ||
expect(stderr).to.be.empty; | ||
done(); | ||
}); | ||
}); | ||
it('should output version number when passed -v', function(done) { | ||
exec('./bin/cloudify -v --test', function(error, stdout, stderr) { | ||
expect(error).to.be.null; | ||
expect(stdout).to.match(/^cloudify version/); | ||
expect(stderr).to.be.empty; | ||
done(); | ||
}); | ||
}); | ||
it('should output version number when passed --version', function(done) { | ||
exec('./bin/cloudify --version --test', function(error, stdout, stderr) { | ||
expect(error).to.be.null; | ||
expect(stdout).to.match(/^cloudify version/); | ||
expect(stderr).to.be.empty; | ||
done(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
15114
13
255
5
2
+ Addedmeocloud@~0.0.2
+ Addedasn1@0.1.11(transitive)
+ Addedassert-plus@0.1.5(transitive)
+ Addedasync@0.9.2(transitive)
+ Addedaws-sign@0.3.0(transitive)
+ Addedboom@0.4.2(transitive)
+ Addedcombined-stream@0.0.7(transitive)
+ Addedcookie-jar@0.3.0(transitive)
+ Addedcryptiles@0.2.2(transitive)
+ Addedctype@0.5.3(transitive)
+ Addeddelayed-stream@0.0.5(transitive)
+ Addedforever-agent@0.5.2(transitive)
+ Addedform-data@0.1.4(transitive)
+ Addedhawk@1.0.0(transitive)
+ Addedhoek@0.9.1(transitive)
+ Addedhttp-signature@0.10.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedmeocloud@0.0.4(transitive)
+ Addedmime@1.2.11(transitive)
+ Addednode-uuid@1.4.8(transitive)
+ Addedoauth-sign@0.3.0(transitive)
+ Addedqs@0.6.6(transitive)
+ Addedrequest@2.27.0(transitive)
+ Addedsntp@0.2.4(transitive)
+ Addedtunnel-agent@0.3.0(transitive)
- Removednodecloudpt@>= 0.5.3
- Removednodecloudpt@0.5.3(transitive)
- Removedrequest@2.12.0(transitive)