Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cloudappx

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudappx - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

README.md

105

cloudappx.js

@@ -8,3 +8,7 @@ #! /usr/bin/env node

var path = require('path');
var Q = require('q');
var domain = 'https://90f18825.ngrok.io';
//var domain = 'http://localhost:8080';
function isValidFile (dir) {

@@ -23,43 +27,55 @@ if (!fs.existsSync(dir) || !fs.lstatSync(dir).isFile() || path.extname(dir) !== '.zip') {

program
.version('0.0.1')
.usage('<input app directory>')
.option('-z, --zipped', 'Run on zipped file')
.option('-v, --verbose', 'Print debug info')
.parse(process.argv);
function main() {
program
.version('0.0.1')
.usage('<input app directory>')
.option('-z, --zipped', 'Run on zipped file')
.option('-v, --verbose', 'Print debug info')
.parse(process.argv);
if (!program.args.length) {
program.help();
} else {
var dir = program.args[0];
cloudappx(dir);
}
}
if (!program.args.length) {
program.help();
} else {
var dir = program.args[0];
if (!program.zip) {
if (isValidDir(dir)) {
var outfile = 'package.zip';
var output = fs.createWriteStream(outfile);
var archive = archiver('zip');
output.on('close', function () {
console.log(archive.pointer() + ' total bytes');
console.log('archiver has been finalized and the output file descriptor has closed.');
uploadFile(outfile);
});
function cloudappx(dir) {
zip(dir).then(uploadFile).then(getResult);
}
archive.on('error', function(err){
throw err;
});
archive.pipe(output);
archive.directory(dir);
archive.finalize();
function zip(dir) {
var deferred = Q.defer();
if (isValidDir(dir)) {
var outfile = dir + '.zip';
var output = fs.createWriteStream(outfile);
var archive = archiver('zip');
output.on('close', function() {
console.log(archive.pointer() + ' total byes');
console.log('archiver has been finalized and the output file descriptor has closed.');
deferred.resolve(outfile);
});
archive.on('error', function(err) {
deferred.reject(err);
throw err;
});
archive.pipe(output);
archive.directory(dir);
archive.finalize();
} else if (isValidFile(dir)) {
console.log(dir);
uploadFile(dir);
} else {
console.log('invalid input');
}
} else if (isValidFile(dir)) {
console.log(dir);
deferred.resolve(dir);
} else {
console.log('invalid input');
deferred.reject();
}
return deferred.promise;
}
function uploadFile(file) {
var req = request.post('http://localhost:8080/v1/upload', function (err, resp, body) {
var deferred = Q.defer();
console.log('uploading file');
var req = request.post(domain + '/v1/upload', function (err, resp, body) {
if (err) {

@@ -69,2 +85,3 @@ console.log('Error!');

console.log('URL: ' + body);
deferred.resolve(body);
}

@@ -74,2 +91,24 @@ });

form.append('xml', fs.createReadStream(file));
return deferred.promise;
}
function getResult(url) {
var deferred = Q.defer();
var req = request.get(domain + '/' + url)
.on('response', function(res) {
var filename = 'package.appx';
res.pipe(fs.createWriteStream('./' + filename));
deferred.resolve();
});
return deferred.promise;
}
if (!module.parent) {
main();
} else {
module.exports = {
uploadFile: uploadFile,
getResult: getResult,
cloudappx: cloudappx
};
}
{
"name": "cloudappx",
"version": "0.0.1",
"version": "0.0.2",
"description": "Cloudy with a chance of AppX",

@@ -28,4 +28,5 @@ "main": "cloudappx.js",

"commander": "^2.8.1",
"q": "^1.4.1",
"request": "^2.58.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc