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

daemonix

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

daemonix - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

npm-shrinkwrap.json

268

lib/deploid.js

@@ -8,2 +8,36 @@ "use strict";

var processExecDebugOn = false;
var processExec = function() {
var logging = [];
var done = null;
var storeDone = function( args, i ) {
done = args[ i ];
args[ i ] = function() {
if ( processExecDebugOn ) {
console.error( 'result', arguments );
}
done.apply( {}, arguments );
};
};
for ( var i = 0; i < arguments.length; i++ ) {
if ( done === null && typeof arguments[ i ] === 'function' ) {
storeDone( arguments, i );
break;
} else {
logging.push( arguments[ i ] );
}
}
if ( processExecDebugOn ) {
console.error( 'executing', logging );
}
childProcess.exec.apply( childProcess, arguments );
};
var Deploid = function( config ) {

@@ -13,2 +47,4 @@

processExecDebugOn = this._config.debug;
if ( !config.hasOwnProperty( 'user' ) ) {

@@ -97,4 +133,11 @@ config.user = config.name;

if ( this._tmpDir ) {
// leave tmp files in place for debugging
if ( this._tmpDir && !processExecDebugOn ) {
this._rmdir( this._tmpDir, done );
} else {
if ( processExecDebugOn ) {
console.error( 'Temporary directory not deleted for debugging: ', this._tmpDir );
}
done();

@@ -118,2 +161,6 @@ }

var nodeBinaryDirOffset = null;
var packageJson = {};
async.series( [

@@ -131,10 +178,11 @@ function( done ) {

console.error( 'Cloning source dir.' );
childProcess.exec( 'rsync -azr ' + self._config.srcDir.replace( /\/$/, '' ) + '/ ' + tmpSrcDir, done );
processExec( 'rsync -azr ' + self._config.srcDir.replace( /\/$/, '' ) + '/ ' + tmpSrcDir, done );
},
function( done ) {
console.error( 'Checking out ' + self._config.version + '.' );
childProcess.exec( 'git checkout ' + self._config.branch, { cwd: tmpSrcDir }, done );
processExec( 'git checkout ' + self._config.branch, { cwd: tmpSrcDir }, done );
},
function( done ) {
getNodeVersion( tmpSrcDir + '/package.json', function( err, nodeVersion ) {
getPackageFile( tmpSrcDir + '/package.json', function( err, contents ) {
if ( err ) {

@@ -145,2 +193,15 @@ done( err );

packageJson = contents;
done();
} );
},
function( done ) {
getNodeVersion( packageJson, function( err, nodeVersion ) {
if ( err ) {
done( err );
return;
}
self._config.nodeVersion = nodeVersion;

@@ -156,16 +217,8 @@

function( done ) {
console.error( 'Performing npm installation.' );
childProcess.exec( 'npm install --production', { cwd: tmpSrcDir }, done );
},
function( done ) {
console.error( 'Performing npm build.' );
childProcess.exec( 'npm run-script build', { cwd: tmpSrcDir }, done );
},
function( done ) {
console.error( 'Copying NVM src.' );
childProcess.exec( 'rsync -azr /tmp/nvm.tmp/ ' + tmpNvmDir, done );
processExec( 'rsync -azr /tmp/nvm.tmp/ ' + tmpNvmDir, done );
},
function( done ) {
console.error( 'Installing node version ' + self._config.nodeVersion + ' in NVM.' );
childProcess.exec( __dirname + '/nvmSetup.sh ' + tmpNvmDir + ' ' + self._config.nodeVersion, function( err ) {
processExec( __dirname + '/nvmSetup.sh ' + tmpNvmDir + ' ' + self._config.nodeVersion, function( err, data ) {

@@ -177,2 +230,3 @@ if ( err ) {

console.error( 'NVM data' );
done();

@@ -182,23 +236,67 @@ } );

function( done ) {
fs.readdir( tmpNvmDir, function( err, files ) {
if ( err ) {
done( err );
return;
}
var newNodeVersion = null;
for ( var i = 0; i < files.length && newNodeVersion === null; i++ ) {
var match = files[i].match( /^v([0-9]+\.[0-9]+\.[0-9]+)$/ );
if ( match ) {
newNodeVersion = match[1];
}
self._config.nodeVersion = null;
async.parallel( [
function( done ) {
fs.readdir( tmpNvmDir, function( err, files ) {
if ( err ) {
done();
return;
}
var newNodeVersion = null;
for ( var i = 0; i < files.length && newNodeVersion === null; i++ ) {
var match = files[ i ].match( /^v([0-9]+\.[0-9]+\.[0-9]+)$/ );
if ( match ) {
newNodeVersion = match[ 1 ];
}
}
if ( newNodeVersion === null ) {
done();
return;
}
self._config.nodeVersion = newNodeVersion;
nodeBinaryDirOffset = '';
done();
} );
},
function( done ) {
fs.readdir( tmpNvmDir + '/versions/node', function( err, files ) {
if ( err ) {
done();
return;
}
var newNodeVersion = null;
for ( var i = 0; i < files.length && newNodeVersion === null; i++ ) {
var match = files[ i ].match( /^v([0-9]+\.[0-9]+\.[0-9]+)$/ );
if ( match ) {
newNodeVersion = match[ 1 ];
}
}
if ( newNodeVersion === null ) {
done();
return;
}
self._config.nodeVersion = newNodeVersion;
nodeBinaryDirOffset = 'versions/node/';
done();
} );
}
if ( newNodeVersion === null ) {
done( 'failed to find node installation in NVM' );
], function() {
if ( self._config.nodeVersion === null ) {
done( new Error( 'could not find node installation' ) );
return;
}
self._config.nodeVersion = newNodeVersion;
done();

@@ -208,8 +306,21 @@ } );

function( done ) {
console.error( 'Linking to current node version.' );
childProcess.exec( 'ln -s v' + self._config.nodeVersion + ' vCurrent', { cwd: tmpNvmDir }, done );
console.error( 'Linking to current node version: ' + nodeBinaryDirOffset + 'v' + self._config.nodeVersion );
processExec( 'ln -s ' + nodeBinaryDirOffset + 'v' + self._config.nodeVersion + ' vCurrent', { cwd: tmpNvmDir }, done );
},
function( done ) {
console.error( 'Performing npm installation.' );
processExec( tmpNvmDir + '/vCurrent/bin/npm install --production', { cwd: tmpSrcDir }, done );
},
function( done ) {
if ( packageJson && packageJson.scripts && packageJson.scripts.build ) {
console.error( 'Performing npm build.' );
processExec( tmpNvmDir + '/vCurrent/bin/npm run-script build', { cwd: tmpSrcDir }, done );
} else {
console.error( 'No npm build script.' );
done();
}
},
function( done ) {
console.error( 'Boxing up package.' );
childProcess.exec( 'tar -cz ' + self._config.version + ' >| ' + self._config.version + '.tar.gz', { cwd: self._tmpDir }, done );
processExec( 'tar -cz ' + self._config.version + ' >| ' + self._config.version + '.tar.gz', { cwd: self._tmpDir }, done );
},

@@ -220,3 +331,3 @@ function( done ) {

}
], function( err ) {
], function( err, results ) {

@@ -276,3 +387,3 @@ if ( err ) {

var regEx = new RegExp( '\\{\\{' + field + '\\}\\}', 'g' );
data = data.replace( regEx, self._config[field] );
data = data.replace( regEx, self._config[ field ] );
}

@@ -330,3 +441,2 @@ }

self._runSshCmd( node, 'sudo service ' + self._config.daemon + ' start', function( err ) {

@@ -528,7 +638,7 @@

if ( self._config.debug ) {
console.error( 'DEBUG', scpCmd );
}
//if ( self._config.debug ) {
// console.error( 'DEBUG', scpCmd );
//}
childProcess.exec( scpCmd, done );
processExec( scpCmd, done );

@@ -565,17 +675,4 @@ };

childProcess.exec( sshCmd, { maxBuffer: maxBuffer }, function( err, stdout, stderr ) {
processExec( sshCmd, { maxBuffer: maxBuffer }, done );
if ( self._config.debug ) {
console.error( 'DEBUG', sshCmd );
if ( stdout ) {
console.error( "\nSTDOUT:\n", stdout );
}
if ( stderr ) {
console.error( "\nSTDERR:\n", stderr );
}
}
done( err, stdout, stderr );
} );
};

@@ -601,3 +698,3 @@

function( done ) {
childProcess.exec( 'git clone https://github.com/creationix/nvm.git /tmp/nvm.tmp', function( err, stdOut, stdErr ) {
processExec( 'git clone https://github.com/creationix/nvm.git /tmp/nvm.tmp', function( err, stdOut, stdErr ) {

@@ -614,3 +711,3 @@ if ( err && !stdErr.match( /already exists and is not an empty directory/ ) ) {

function( done ) {
childProcess.exec( 'git pull', { cwd: '/tmp/nvm.tmp' }, done );
processExec( 'git pull', { cwd: '/tmp/nvm.tmp' }, done );
}

@@ -652,6 +749,6 @@ ], function( err ) {

function( done ) {
childProcess.exec( 'rm -rf ' + self._config.srcDir, done );
processExec( 'rm -rf ' + self._config.srcDir, done );
},
function( done ) {
childProcess.exec( 'mkdir ' + self._config.srcDir, done );
processExec( 'mkdir ' + self._config.srcDir, done );
}

@@ -680,3 +777,3 @@ ], done );

childProcess.exec( 'git status', { cwd: self._config.srcDir }, function( err ) {
processExec( 'git status', { cwd: self._config.srcDir }, function( err ) {

@@ -701,3 +798,3 @@ if ( err ) {

childProcess.exec( 'git config --get remote.origin.url', { cwd: self._config.srcDir }, function( err, stdout ) {
processExec( 'git config --get remote.origin.url', { cwd: self._config.srcDir }, function( err, stdout ) {

@@ -742,3 +839,3 @@ if ( !stdout && !err ) {

clearSrc( function() {
childProcess.exec( 'git clone ' + self._config.source + ' ' + self._config.srcDir, function( err ) {
processExec( 'git clone ' + self._config.source + ' ' + self._config.srcDir, function( err ) {
if ( err ) {

@@ -758,3 +855,3 @@ done( err );

childProcess.exec( 'git pull --all', { cwd: self._config.srcDir }, function( err ) {
processExec( 'git pull --all', { cwd: self._config.srcDir }, function( err ) {
if ( err ) {

@@ -798,3 +895,3 @@ done( err );

if ( realpath.length < 2 ) {
done( 'path is invalid' );
done( new Error( 'path is invalid' ) );
return;

@@ -809,3 +906,3 @@ }

function( done ) {
childProcess.exec( 'rm -rf ' + path, done );
processExec( 'rm -rf ' + path, done );
}

@@ -816,10 +913,8 @@ ], done );

function getNodeVersion( packageFile, done ) {
function getPackageFile( packageFile, done ) {
var nodeVersion = null;
fs.readFile( packageFile, { encoding: 'utf8' }, function( err, data ) {
if ( typeof data !== 'string' ) {
err = 'could not get file data';
err = new Error( 'could not get file data' );
}

@@ -832,16 +927,13 @@

data = JSON.parse( data );
try {
data = JSON.parse( data );
} catch ( e ) {
done( e );
return;
}
if ( data && data.engines && data.engines.node ) {
nodeVersion = data.engines.node;
// convert dynamic version numbers to something NVM can understand
if ( nodeVersion.match( />=|~/ ) ) {
nodeVersion = nodeVersion.replace( /^[^0-9]*/, '' ).replace( /\.[^\.]*$/, '' );
}
nodeVersion = nodeVersion.replace( /\.x$/, '' );
done( null, nodeVersion );
if ( data ) {
done( null, data );
} else {
done( 'package.json missing engines.node field' );
done( new Error( 'package.json missing data' ) );
}

@@ -852,3 +944,19 @@

function getNodeVersion( packageFile, done ) {
if ( packageFile && packageFile.engines && packageFile.engines.node ) {
var nodeVersion = packageFile.engines.node;
// convert dynamic version numbers to something NVM can understand
if ( nodeVersion.match( />=|~/ ) ) {
nodeVersion = nodeVersion.replace( /^[^0-9]*/, '' ).replace( /\.[^\.]*$/, '' );
}
done( null, nodeVersion.replace( /\.x$/, '' ) );
} else {
done( new Error( 'package.json missing engines.node field' ) );
}
}
module.exports = Deploid;
{
"name": "daemonix",
"description": "Daemonix is a tool for deploying and managing NodeJS systems as a daemon in Linux/Unix environments.",
"version": "0.4.1",
"version": "0.4.2",
"author": "Anthony Hildoer <anthony@bluerival.com>",

@@ -14,12 +14,12 @@ "repository": {

"dependencies": {
"async": "~0.8",
"commander": "~2.2",
"inquirer": "~0.5",
"mkdirp": "~0.5",
"semver": "~2.3",
"sidi": "~0.0",
"temporary": "~0.0"
"async": "1.2.1",
"commander": "2.8.1",
"inquirer": "0.8.5",
"mkdirp": "0.5.1",
"semver": "4.3.6",
"sidi": "0.0.1",
"temporary": "0.0.8"
},
"devDependencies": {
"mocha": "~1"
"mocha": "2.2.5"
},

@@ -26,0 +26,0 @@ "keywords": [

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