Skip to content

Commit

Permalink
Merge pull request #77 from MitocGroup/dev
Browse files Browse the repository at this point in the history
New release 1.5.0
  • Loading branch information
Goria Marcel committed Jan 11, 2016
2 parents 8aaa4bc + fc883fa commit d92de16
Show file tree
Hide file tree
Showing 1,419 changed files with 378 additions and 339,572 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ language: node_js
sudo: false
node_js:
- '0.12'
- '4.2'
- '5.3'
cache:
directories:
- $(npm root -g)
- "$(npm root -g)"
- node_modules
notifications:
email:
- [email protected]
Expand All @@ -21,10 +24,8 @@ env:
before_install:
- npm install -g [email protected]
- npm install -g [email protected]
- npm install -g [email protected]
- npm install -g [email protected]
- npm install -g [email protected]
- npm install -g [email protected]
- npm install -g [email protected]
- npm install -g [email protected]
- npm install -g [email protected]
- cp test/package.json .
Expand Down
2 changes: 1 addition & 1 deletion bin/_head.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish_npm_package() {
echo "Publishing "${name}

if [ -z $2 ] || ! $2; then
cd $1 && rm -rf node_modules/ && npm install --production && ${npm} version $3 && ${npm} publish
cd $1 && rm -rf node_modules/ && npm install --production --no-bin-links --no-optional && ${npm} version $3 && ${npm} publish
else
cd $1 && ${npm} version $3
fi
Expand Down
77 changes: 49 additions & 28 deletions src/bin/commands/compile-prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = function(mainPath) {
var LambdaExtractor = require('../../lib.compiled/Helpers/LambdasExtractor').LambdasExtractor;
var DepsTreeOptimizer = require('../../lib.compiled/NodeJS/DepsTreeOptimizer').DepsTreeOptimizer;
var NpmInstall = require('../../lib.compiled/NodeJS/NpmInstall').NpmInstall;
var NpmInstallLibs = require('../../lib.compiled/NodeJS/NpmInstallLibs').NpmInstallLibs;
var NpmPrune = require('../../lib.compiled/NodeJS/NpmPrune').NpmPrune;
var NpmDedupe = require('../../lib.compiled/NodeJS/NpmDedupe').NpmDedupe;
var NpmRun = require('../../lib.compiled/NodeJS/NpmRun').NpmRun;
Expand All @@ -25,6 +26,7 @@ module.exports = function(mainPath) {
var tmp = require('tmp');

var removeSource = this.opts.locate('remove-source').exists;
var installSdk = this.opts.locate('aws-sdk').exists;
var microservicesToDeploy = this.opts.locate('partial').value;

if (mainPath.indexOf('/') !== 0) {
Expand Down Expand Up @@ -246,41 +248,60 @@ module.exports = function(mainPath) {
if (result.failed) {
console.error(result.error);
} else {
console.log('Removed aws-sdk@* in ' + lambdaTmpPath);
console.log('Cleanup Lambda sources in ' + lambdaTmpPath);
}

var outputFile = path.join(
lambdaPath,
'..',
path.basename(lambdaPath) + '.zip'
);

console.log('Packing Lambda code into ' + outputFile + ' (' + lambdaTmpPath + ')');

// @todo: replace this with a node native
var zip = new Exec(
Bin.resolve('zip'),
'-y',
'-r',
outputFile,
'.'
);

zip.cwd = lambdaTmpPath;
zip.avoidBufferOverflow();

zip.run(function(result) {
if (result.failed) {
console.error(result.error);
this.exit(1);
}
if (installSdk) {
console.log('Installing latest aws-sdk into ' + lambdaTmpPath);

var npmLink = new NpmInstallLibs(lambdaTmpPath);
npmLink.libs = 'aws-sdk';

remaining--;
}.bind(this));
npmLink.run(function() {
packSingle.bind(this)(lambdaPath, lambdaTmpPath, function() {
remaining--;
}.bind(this));
}.bind(this));
} else {
packSingle.bind(this)(lambdaPath, lambdaTmpPath, function() {
remaining--;
}.bind(this));
}
}.bind(this, lambdaPath, lambdaTmpPath));
}
}

function packSingle(lambdaPath, lambdaTmpPath, cb) {
var outputFile = path.join(
lambdaPath,
'..',
path.basename(lambdaPath) + '.zip'
);

console.log('Packing Lambda code into ' + outputFile + ' (' + lambdaTmpPath + ')');

// @todo: replace this with a node native
var zip = new Exec(
Bin.resolve('zip'),
'-y',
'-r',
outputFile,
'.'
);

zip.cwd = lambdaTmpPath;
zip.avoidBufferOverflow();

zip.run(function(result) {
if (result.failed) {
console.error(result.error);
this.exit(1);
}

cb();
}.bind(this));
}

function getMicroservicesToDeploy() {
if (!microservicesToDeploy) {
return [];
Expand Down
4 changes: 3 additions & 1 deletion src/bin/commands/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = function(mainPath) {
var S3Service = require('deep-package-manager').Provisioning_Service_S3Service;
var ProvisioningCollisionsDetectedException = require('deep-package-manager').Property_Exception_ProvisioningCollisionsDetectedException;

var installSdk = this.opts.locate('aws-sdk').exists;
var localOnly = this.opts.locate('dry-run').exists;
var fastDeploy = this.opts.locate('fast').exists;
var dumpCodePath = this.opts.locate('dump-local').value;
Expand Down Expand Up @@ -201,7 +202,8 @@ module.exports = function(mainPath) {
);

!fastDeploy && cmd.addArg('--remove-source');
microservicesToDeploy && cmd.addArg('--partial');
microservicesToDeploy && cmd.addArg('--partial ' + microservicesToDeploy);
installSdk && cmd.addArg('--aws-sdk');

cmd.run(function(result) {
if (result.failed) {
Expand Down
2 changes: 1 addition & 1 deletion src/bin/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = function(microserviceRepo, dumpPath) {

prompt.readConfirm(function(result) {
if (result) {
console.log('Start preparing for production');
console.log('Start initializing backend...');

var cmd = new Exec(
Bin.node,
Expand Down
65 changes: 17 additions & 48 deletions src/bin/commands/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ module.exports = function(mainPath) {
var openBrowser = this.opts.locate('open-browser').exists;
var skipBuildHook = this.opts.locate('skip-build-hook').exists;
var skipBackendBuild = this.opts.locate('skip-backend-build').exists;
var profiling = this.opts.locate('profiling').exists;
var skipFrontendBuild = this.opts.locate('skip-frontend-build').exists;

// @todo: implement it in a better way
Expand All @@ -55,7 +54,6 @@ module.exports = function(mainPath) {

if (skipBackendBuild) {
server = new Server(property);
server.profiling = profiling;

startServer();
return;
Expand All @@ -68,35 +66,32 @@ module.exports = function(mainPath) {

property.runInitMsHooks(function() {
server = new Server(property);
server.profiling = profiling;

var lambdasToInstall = LambdaExtractor
.createFromServer(server)
.extract();

runInstallHook(function() {
console.log('Running "npm install" on ' + lambdasToInstall.length + ' Lambdas');
console.log('Running "npm install" on ' + lambdasToInstall.length + ' Lambdas');

var npmInstall = new NpmInstall(lambdasToInstall);
var npmInstall = new NpmInstall(lambdasToInstall);

npmInstall.runChunk(function() {
if (Bin.npmModuleInstalled('aws-sdk', true)) {
console.log('Start linking aws-sdk');
npmInstall.runChunk(function() {
if (Bin.npmModuleInstalled('aws-sdk', true)) {
console.log('Start linking aws-sdk');

linkAwsSdk.bind(this)(lambdasToInstall, startServer);
} else {
var awsSdkInstall = new NpmInstallLibs();
awsSdkInstall.libs = 'aws-sdk';
awsSdkInstall.global = true;

awsSdkInstall.run(function() {
console.log('Installing aws-sdk globally');

linkAwsSdk.bind(this)(lambdasToInstall, startServer);
} else {
var awsSdkInstall = new NpmInstallLibs();
awsSdkInstall.libs = 'aws-sdk';
awsSdkInstall.global = true;

awsSdkInstall.run(function() {
console.log('Installing aws-sdk globally');

linkAwsSdk.bind(this)(lambdasToInstall, startServer);
}.bind(this));
}
}.bind(this), NpmInstall.DEFAULT_CHUNK_SIZE);
}.bind(this));
}.bind(this));
}
}.bind(this), NpmInstall.DEFAULT_CHUNK_SIZE);
}.bind(this));
}.bind(this));

Expand All @@ -109,32 +104,6 @@ module.exports = function(mainPath) {
}.bind(this));
}

function runInstallHook(cb) {
if (skipBuildHook) {
cb();
return;
}

var hookPath = path.join(mainPath, 'hook.server.js');

console.log('Checking for build hook in ' + hookPath);

if (!fs.existsSync(hookPath)) {
cb();
return;
}

console.log('Running build hook from ' + hookPath);

var hook = require(hookPath);

if (typeof hook === 'function') {
hook.bind(server)(cb);
} else {
cb();
}
}

function startServer() {
if (buildPath) {
server.buildPath = buildPath;
Expand Down
19 changes: 12 additions & 7 deletions src/bin/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
},
'install': {
example: 'deepify install https://github.com/MitocGroup/deep-microservices-todo-app.git path/to/web_app',
description: 'Installs an microservice from remote git repository',
description: 'Install an microservice from remote git repository',
opts: {
},
args: {
Expand All @@ -46,11 +46,6 @@ module.exports = {
example: 'deepify server path/to/web_app -o',
description: 'Run local development server',
opts: {
profiling: {
alias: 'd',
description: 'Enable Lambdas profiling',
required: false,
},
'build-path': {
alias: 'b',
description: 'The path to the build (in order to pick up config)',
Expand Down Expand Up @@ -128,6 +123,11 @@ module.exports = {
description: 'Faster deployment without copying the sources (may alter the web app state)',
required: false,
},
'aws-sdk': {
alias: 'a',
description: 'Force latest aws-sdk in Lambda',
required: false,
},
},
args: {
path: {
Expand Down Expand Up @@ -182,7 +182,7 @@ module.exports = {
},
'compile-es6': {
example: 'deepify compile-es6 path/to/lambda',
description: 'Compiles ES6 scripts to ES5 using babel (matched by *.es6)',
description: 'Compile ES6 scripts to ES5 using babel (matched by *.es6)',
opts: {
},
args: {
Expand All @@ -206,6 +206,11 @@ module.exports = {
description: 'Partial deploy (one or several comma separated microservices identifiers)',
required: false,
},
'aws-sdk': {
alias: 'a',
description: 'Force latest aws-sdk in Lambda',
required: false,
},
},
args: {
path: {
Expand Down
Loading

0 comments on commit d92de16

Please sign in to comment.