Page MenuHomeSealhub

No OneTemporary

diff --git a/lib/core.js b/lib/core.js
index 40667d35..8f1bc285 100644
--- a/lib/core.js
+++ b/lib/core.js
@@ -1,94 +1,121 @@
var path = require("path");
+var http = require("http");
var ModuleManager = require("./module/module-manager.js");
var ConfigManager = require("./config/config-manager.js");
function SealiousCore(path_to_package_json, mode, layer_name){
this.mode = mode || "local";
this.layer_name = layer_name || null;
if(this.mode=="local"){
this.dispatcher = require("../lib/dispatchers/local/dispatcher-local.js");
}else{
this.dispatcher = require("../lib/dispatchers/" + this.layer_name + "/dispatcher-" + this.layer_name + ".js");
}
this.init(require(path_to_package_json));
}
SealiousCore.prototype = new function(){
+ var check_version = function(package_info){
+ var pkg = require("../package.json")
+ var arraySplit = pkg.version.split(".");
+ var version = arraySplit[0]+"."+arraySplit[1];
+ var url = "http://registry.npmjs.org/sealious/"+version;
+
+ http.get(url, function(res) {
+ res.setEncoding('utf8');
+ var body = "";
+ res.on('data', function (chunk) {
+ body += chunk.toString();
+ });
+ res.on('end', function(){
+ var sealious_npm = JSON.parse(body);
+ if (sealious_npm.version !== pkg.version) {
+ Sealious.Logger.warning("Sealious@"+pkg.version+" - update available. Run `npm install sealious@"+sealious_npm.version+"` to update.");
+ }
+ else {
+ Sealious.Logger.info("Sealious@"+pkg.version+" is up-to-date.");
+ }
+ });
+ });
+ }
+
+
this.load_base_modules = function(){
ModuleManager.add_module(require.resolve("sealious-base-chips"))
}
this.config = function(config_object){
ConfigManager.set_config(config_object);
}
this.config_from_file = function(path_to_file){
this.config(require(path_to_file));
}
this.init = function(package_info){
+ check_version(package_info);
this.load_base_modules();
this.load_all_modules(package_info);
}
this.load_all_modules = function(package_info){
var dependencies = package_info.dependencies;
for(var dependency_name in dependencies){
try{
var dependency_path = require.resolve(dependency_name);
}catch(e){
//in case the module is npm link-ed
var dependency_path = require.resolve(path.resolve(module.parent.parent.filename, "../node_modules/"+dependency_name));
}
var dep_info = path.parse(dependency_path);
if(dep_info.name=="sealious-module" && dep_info.ext==".json"){
ModuleManager.add_module(dependency_path);
}
}
ModuleManager.initialize_all(this.dispatcher);
}
var which_chip_types_to_start_for_layer = {
db: ["datastore"],
biz: ["field_type", "resource_type", "service"],
web: ["field_type", "resource_type", "channel"]
}
function decide_chip_types_to_start(mode, layer_name){
if(mode=="local"){
return ["field_type", "resource_type", "service", "channel", "datastore"];
//}else if(!(layer_name)){
// throw new Sealious.Errors.ValidationError("Invalid layer name: " + layer_name); //~
- }else{
- return which_chip_types_to_start_for_layer[layer_name];
- }
+ }else{
+ return which_chip_types_to_start_for_layer[layer_name];
}
+}
- function getDispatcher(mode, layer_name){
- if(mode=="local"){
- var dispatcher_path = "./dispatchers/local/dispatcher-local.js";
- }else{
- var dispatcher_path = "./dispatchers/" + layer_name + "/dispatcher-" + layer_name + ".js";
- }
- return require(dispatcher_path);
+function getDispatcher(mode, layer_name){
+ if(mode=="local"){
+ var dispatcher_path = "./dispatchers/local/dispatcher-local.js";
+ }else{
+ var dispatcher_path = "./dispatchers/" + layer_name + "/dispatcher-" + layer_name + ".js";
}
+ return require(dispatcher_path);
+}
- this.start = function(){
- Sealious.Dispatcher = this.dispatcher;
- this.dispatcher.init();
- this.dispatcher.start();
+this.start = function(){
+ Sealious.Dispatcher = this.dispatcher;
+ this.dispatcher.init();
+ this.dispatcher.start();
- var chip_types_to_start = decide_chip_types_to_start(this.mode, this.layer_name);
+ var chip_types_to_start = decide_chip_types_to_start(this.mode, this.layer_name);
- return ModuleManager.start(chip_types_to_start);
- }
+ return ModuleManager.start(chip_types_to_start);
+}
}
module.exports = SealiousCore;
\ No newline at end of file
diff --git a/package.json b/package.json
index 8641cae0..ea3f25f7 100755
--- a/package.json
+++ b/package.json
@@ -1,44 +1,44 @@
{
"name": "sealious",
- "version": "0.3.3",
+ "version": "0.3.4",
"description": "",
"main": "./lib/main.js",
"scripts": {
"test": "mocha ./tests/test.js && mocha ./tests/test.js -R travis-cov"
},
"repository": {
"type": "git",
"url": "https://github.com/Sealious/Sealious/"
},
"keywords": [
"sealious"
- ],
+ ],
"author": "Kuba Orlik",
"license": "BSD-2-Clause",
"bugs": {
"url": "https://github.com/Sealious/Sealious/issues"
},
"dependencies": {
"Set": "~0.4.1",
"bluebird": "~2.9.9",
"merge": "^1.2.0",
"socket.io": "~1.2.0",
"socket.io-client": "~1.2.0",
"winston": "^1.0.0",
"uid": "0.0.2"
},
"devDependencies": {
"blanket": "1.1.6",
"mocha": "*",
"should": "~4.4.0",
"travis-cov ": "*"
},
"config": {
"blanket": {
"pattern": "node_modules"
}
},
"peerDependencies": {
"sealious-base-chips": "^0.2.0"
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sat, Nov 8, 02:27 (15 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1033919
Default Alt Text
(5 KB)

Event Timeline