template-engine
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -49,2 +49,5 @@ var core = require('core'); | ||
Platform.prototype.getPaths = function () { | ||
if (!this._platformManager.allPlatformsReady() && !this._platformManager.cacheAllPlatformsReady()) { | ||
throw new Error(Platform.MESSAGES.PLATFORMS_NOT_READY); | ||
} | ||
var retVal = {}; | ||
@@ -68,4 +71,6 @@ var storePlatform = this._platformManager.getPlatformsPaths(); | ||
Platform.MESSAGES = {}; | ||
Platform.MESSAGES.PLATFORMS_NOT_READY = 'Platform/getPaths: Platforms not ready'; | ||
exports.Platform = Platform; | ||
@@ -19,2 +19,4 @@ var core = require('core'); | ||
this._shims = {}; | ||
this._platformsReady = null; | ||
this._cachePlatformsReady = null; | ||
@@ -38,7 +40,7 @@ this._job = setInterval(function(){PlatformManager.getInstance().job();}, 60 * 1000); | ||
if (!platformsYaml.hasOwnProperty('platform') || platformsYaml.platform == null) { | ||
console.info('PlatformManager/init: no platforms in resource.yaml'); | ||
console.info('PlatformManager/init: no platforms in resources.yaml'); | ||
return; | ||
} | ||
if (!platformsYaml.platform.hasOwnProperty('dependencies') || platformsYaml.platform.dependencies == null) { | ||
console.info('PlatformManager/init: no platform dependencies in resource.yaml'); | ||
console.info('PlatformManager/init: no platform dependencies in resources.yaml'); | ||
return; | ||
@@ -49,3 +51,3 @@ } | ||
if (!platformsYaml.platform.hasOwnProperty('name')) { | ||
console.log('PlatformManager/init: not declared local platform name in resource.yaml', err); | ||
console.info('PlatformManager/init: not declared local platform name in resources.yaml', err); | ||
} else { | ||
@@ -82,6 +84,8 @@ var localName = platformsYaml.platform.name; | ||
if (err) { | ||
console.log('PlatformManager/init: _loadAllPlatforms: ', err); | ||
console.warn('PlatformManager/init: _loadAllPlatforms: ', err); | ||
return; | ||
} | ||
console.log('PlatformManager/_loadAllPlatforms: loaded all platform'); | ||
that._platformsReady = true; | ||
that._cachePlatformsReady = true; | ||
@@ -95,4 +99,4 @@ if (!platformsYaml.platform.hasOwnProperty('map') || platformsYaml.platform.map == null) { | ||
console.log('PlatformManager/init: _mergeMapAndShim: ', err); | ||
return; | ||
} | ||
console.log('PlatformManager/_mergeMapAndShim: merged Maps'); | ||
@@ -108,2 +112,3 @@ }); | ||
console.log('PlatformManager/init: _mergeMapAndShim: ', err); | ||
return; | ||
} | ||
@@ -113,4 +118,2 @@ console.log('PlatformManager/_mergeMapAndShim: merged Shims'); | ||
} | ||
}); | ||
@@ -130,3 +133,5 @@ }); | ||
var keys = Object.keys(loadedPlatforms); | ||
if (keys.length == 0) { | ||
return callback(null); | ||
} | ||
for (var i=0, len = keys.length; i<len; i++) { | ||
@@ -147,3 +152,4 @@ platformUrl = loadedPlatforms[keys[i]]; | ||
if (err) { | ||
console.error('TE/PlatformManager/_fetchRemotePlatform: ', err); | ||
console.warn('TE/PlatformManager/_fetchRemotePlatform: ', err); | ||
return callback('NOT loaded all platforms!'); | ||
} | ||
@@ -166,3 +172,3 @@ counter += 1; | ||
if (cachePlatformsKeys == 0) { | ||
// console.log('PlatformManager/_loadAllPlatforms: no nested platforms); | ||
console.log('PlatformManager/_loadAllPlatforms: no nested platforms'); | ||
return callback(null); | ||
@@ -184,4 +190,4 @@ } | ||
if (e.data.getStatusCode() != 200) { | ||
console.log('PlatformManager/_fetchRemotePlatform: platform %s URL %s is unavailable', platform, url); | ||
return callback(null); | ||
that._platformsReady = false; | ||
return callback(new Error('platform '+platform+' URL '+url +' is unavailable ')); | ||
} | ||
@@ -216,2 +222,3 @@ var externalPlatformManifest = YAML.parse(e.data.getBody().toBuffer().toString()).pop(); | ||
console.error('PlatformManager/_fetchRemotePlatform: ', url, e.data, e.code, e.message); | ||
that._platformsReady = false; | ||
that._fetchRemotePlatform(url, platform, callback); | ||
@@ -286,2 +293,10 @@ }); | ||
PlatformManager.prototype.allPlatformsReady = function () { | ||
return this._platformsReady; | ||
}; | ||
PlatformManager.prototype.cacheAllPlatformsReady = function () { | ||
return this._cachePlatformsReady; | ||
}; | ||
PlatformManager.prototype._stopJob = function () { | ||
@@ -306,3 +321,7 @@ clearInterval(this._job); | ||
console.error('TE/PlatformManager/_fetchRemotePlatform: ', err); | ||
return; | ||
} | ||
console.log('PlatformManager/_loadAllPlatforms: loaded all platform'); | ||
that._platformsReady = true; | ||
that._cachePlatformsReady = true; | ||
}); | ||
@@ -309,0 +328,0 @@ }; |
@@ -37,3 +37,3 @@ var Resource = require('./Resource.js').Resource; | ||
} | ||
}, (this._refresh_counter == 1) ? ResourceToInject.FIRST_PLATFORM_REFRESHi : ResourceToInject.PLATFORM_REFRESH); | ||
}, (this._refresh_counter == 1) ? ResourceToInject.FIRST_PLATFORM_REFRESH : ResourceToInject.PLATFORM_REFRESH); | ||
} else if (this._config.source.indexOf('http') === -1) { | ||
@@ -40,0 +40,0 @@ this._config.files.inject = this._ocdn.getUrl(this._config.source, this._config.param).toString(); |
{ | ||
"name": "template-engine", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Engine that renders templates of any kind", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -81,2 +81,8 @@ var rewire = require('rewire'); | ||
it('should return platforms paths', function() { | ||
spyOn(platformManager, "allPlatformsReady").andCallFake(function () { | ||
return true; | ||
}); | ||
spyOn(platformManager, "cacheAllPlatformsReady").andCallFake(function () { | ||
return true; | ||
}); | ||
@@ -83,0 +89,0 @@ expect(platform.getPaths()).toEqual(JSON.stringify({"moja": "http://cdpte.dl-username.cde.dev.onet/static/build", "gallery": "http://test.dl-username.cde.dev.onet/static/build"})); |
6133121
41318