Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring, cleanup #67

Merged
merged 1 commit into from
May 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions cli/domain/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var path = require('path');
var settings = require('../../resources/settings');
var Targz = require('tar.gz');
var uglifyJs = require('uglify-js');
var validator = require('../../registry/domain/validator');
var validator = require('../../registry/domain/validators');
var _ = require('underscore');

module.exports = function(){
Expand Down Expand Up @@ -119,11 +119,20 @@ module.exports = function(){
var components = fs.readdirSync(componentsDir).filter(function(file){

var filePath = path.resolve(componentsDir, file),
isDir = fs.lstatSync(filePath).isDirectory();
isDir = fs.lstatSync(filePath).isDirectory(),
packagePath = path.join(filePath, 'package.json');

return isDir ? (fs.readdirSync(filePath).filter(function(file){
return file === 'package.json';
}).length === 1) : false;
if(!isDir || !fs.existsSync(packagePath)){
return false;
}

var content = fs.readJsonSync(packagePath);

if(!content.oc || !!content.oc.packaged){
return false;
}

return true;
});

var fullPathComponents = _.map(components, function(component){
Expand Down Expand Up @@ -278,6 +287,7 @@ module.exports = function(){

delete component.oc.files.client;
component.oc.version = ocInfo.version;
component.oc.packaged = true;

if(!!component.oc.files.data){
var dataPath = path.join(componentPath, component.oc.files.data),
Expand Down
20 changes: 13 additions & 7 deletions cli/facade/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = function(dependencies){

if(!packaging){
packaging = true;
logger.log('Packaging components...'.yellow);
logger.logNoNewLine('Packaging components...'.yellow);

async.eachSeries(componentsDirs, function(dir, cb){
local.package(dir, false, function(err){
Expand All @@ -85,15 +85,15 @@ module.exports = function(dependencies){
}, function(error){
if(!!error){
var errorDescription = ((error instanceof SyntaxError) || !!error.message) ? error.message : error;
logger.log(format('An error happened while packaging {0}: {1}', componentsDirs[i], errorDescription.red));
logger.log('retrying in 10 seconds...'.yellow);
logger.log(format('an error happened while packaging {0}: {1}', componentsDirs[i], errorDescription.red));
logger.log('Retrying in 10 seconds...'.yellow);
setTimeout(function(){
packaging = false;
packageComponents(componentsDirs);
}, 10000);
} else {
packaging = false;
logger.log('complete'.green);
logger.log('OK'.green);
if(_.isFunction(callback)){
callback();
}
Expand All @@ -103,7 +103,7 @@ module.exports = function(dependencies){
};

var loadDependencies = function(components, cb){
logger.log('Ensuring dependencies are loaded'.yellow);
logger.logNoNewLine('Ensuring dependencies are loaded...'.yellow);

var dependencies = getDepsFromComponents(components),
missing = [];
Expand Down Expand Up @@ -131,12 +131,13 @@ module.exports = function(dependencies){
});
});
} else {
logger.log('OK'.green);
cb(dependencies);
}
});
};

logger.log('Looking for components...'.yellow);
logger.logNoNewLine('Looking for components...'.yellow);
local.getComponentsByDir(componentsDir, function(err, components){

if(err){
Expand All @@ -145,9 +146,14 @@ module.exports = function(dependencies){
return logger.log(format(errors.DEV_FAIL, errors.COMPONENTS_NOT_FOUND).red);
}

logger.log('OK'.green);
_.forEach(components, function(component){
logger.log('>> '.green + component);
});

loadDependencies(components, function(dependencies){
packageComponents(components, function(){
logger.log('Starting dev registry on localhost:' + port);
logger.logNoNewLine(format('Starting dev registry on localhost:{0}...', port).yellow);

var conf = {
local: true,
Expand Down
7 changes: 6 additions & 1 deletion cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ var _ = require('underscore');

var dependencies = {
local: new Local(),
logger: console,
logger: {
log: console.log,
logNoNewLine: function(msg){
return process.stdout.write(msg.toString());
}
},
registry: new Registry()
};

Expand Down
3 changes: 2 additions & 1 deletion components/oc-client/_package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"src": "server.js"
}
},
"version": "0.15.3"
"version": "0.15.3",
"packaged": true
}
}
Loading