diff --git a/cli/domain/local.js b/cli/domain/local.js index 492b57af1..3d7d8ab2d 100644 --- a/cli/domain/local.js +++ b/cli/domain/local.js @@ -5,7 +5,6 @@ var format = require('../../utils/format'); var fs = require('fs-extra'); var hashBuilder = require('../../utils/hash-builder'); var request = require('../../utils/request'); -var originalPackage = require('../../package.json'); var path = require('path'); var Targz = require('tar.gz'); var uglifyJs = require('uglify-js'); @@ -143,15 +142,16 @@ module.exports = function(){ } fs.mkdirSync(publishPath); - + var component = fs.readJsonSync(path.join(componentPath, 'package.json')), + ocInfo = fs.readJsonSync(path.join(__dirname, '../../package.json')), template = fs.readFileSync(path.join(componentPath, component.oc.files.template.src)).toString(); if(!validator.validateComponentName(component.name)){ return callback('name not valid'); } - component.oc.version = originalPackage.version; + component.oc.version = ocInfo.version; if(component.oc.files.template.type === 'handlebars'){ diff --git a/components/oc-client/_package/package.json b/components/oc-client/_package/package.json index 47ae16ad7..ac6bd00b8 100644 --- a/components/oc-client/_package/package.json +++ b/components/oc-client/_package/package.json @@ -1,7 +1,7 @@ { "name": "oc-client", "description": "", - "version": "0.3.0", + "version": "0.3.1", "dependencies": {}, "repository": "", "oc": { @@ -21,6 +21,6 @@ "src": "server.js" } }, - "version": "0.2.0" + "version": "0.3.1" } } diff --git a/components/oc-client/_package/src/oc-client.min.js b/components/oc-client/_package/src/oc-client.min.js index cc13fbcc3..572df3bce 100644 --- a/components/oc-client/_package/src/oc-client.min.js +++ b/components/oc-client/_package/src/oc-client.min.js @@ -1 +1 @@ -var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var r;return e.prototype.toString=function(){return""+this.string},r=e}(),r=function(e){"use strict";function r(e){return c[e]||"&"}function n(e,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}function t(e){return e instanceof a?e.toString():e||0===e?(e=""+e,l.test(e)?e.replace(s,r):e):""}function o(e){return e||0===e?f(e)&&0===e.length?!0:!1:!0}var i={},a=e,c={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},s=/[&<>"'`]/g,l=/[&<>"'`]/;i.extend=n;var u=Object.prototype.toString;i.toString=u;var p=function(e){return"function"==typeof e};p(/x/)&&(p=function(e){return"function"==typeof e&&"[object Function]"===u.call(e)});var p;i.isFunction=p;var f=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===u.call(e):!1};return i.isArray=f,i.escapeExpression=t,i.isEmpty=o,i}(e),n=function(){"use strict";function e(e,r){var t;r&&r.firstLine&&(t=r.firstLine,e+=" - "+t+":"+r.firstColumn);for(var o=Error.prototype.constructor.call(this,e),i=0;i0?e.helpers.each(r,n):t(this):o(r)}),e.registerHelper("each",function(e,r){var n,t=r.fn,o=r.inverse,i=0,a="";if(f(e)&&(e=e.call(this)),r.data&&(n=v(r.data)),e&&"object"==typeof e)if(p(e))for(var c=e.length;c>i;i++)n&&(n.index=i,n.first=0===i,n.last=i===e.length-1),a+=t(e[i],{data:n});else for(var s in e)e.hasOwnProperty(s)&&(n&&(n.key=s,n.index=i,n.first=0===i),a+=t(e[s],{data:n}),i++);return 0===i&&(a=o(this)),a}),e.registerHelper("if",function(e,r){return f(e)&&(e=e.call(this)),!r.hash.includeZero&&!e||a.isEmpty(e)?r.inverse(this):r.fn(this)}),e.registerHelper("unless",function(r,n){return e.helpers["if"].call(this,r,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,r){return f(e)&&(e=e.call(this)),a.isEmpty(e)?void 0:r.fn(e)}),e.registerHelper("log",function(r,n){var t=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(t,r)})}function o(e,r){m.log(e,r)}var i={},a=e,c=r,s="1.3.0";i.VERSION=s;var l=4;i.COMPILER_REVISION=l;var u={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};i.REVISION_CHANGES=u;var p=a.isArray,f=a.isFunction,d=a.toString,h="[object Object]";i.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,r,n){if(d.call(e)===h){if(n||r)throw new c("Arg not supported with multiple helpers");a.extend(this.helpers,e)}else n&&(r.not=n),this.helpers[e]=r},registerPartial:function(e,r){d.call(e)===h?a.extend(this.partials,e):this.partials[e]=r}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,r){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,r)}}};i.logger=m,i.log=o;var v=function(e){var r={};return a.extend(r,e),r};return i.createFrame=v,i}(r,n),o=function(e,r,n){"use strict";function t(e){var r=e&&e[0]||1,n=f;if(r!==n){if(n>r){var t=d[n],o=d[r];throw new p("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+t+") or downgrade your runtime to an older version ("+o+").")}throw new p("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,r){if(!r)throw new p("No environment passed to template");var n=function(e,n,t,o,i,a){var c=r.VM.invokePartial.apply(this,arguments);if(null!=c)return c;if(r.compile){var s={helpers:o,partials:i,data:a};return i[n]=r.compile(e,{data:void 0!==a},r),i[n](t,s)}throw new p("The partial "+n+" could not be compiled when running in runtime-only mode")},t={escapeExpression:u.escapeExpression,invokePartial:n,programs:[],program:function(e,r,n){var t=this.programs[e];return n?t=a(e,r,n):t||(t=this.programs[e]=a(e,r)),t},merge:function(e,r){var n=e||r;return e&&r&&e!==r&&(n={},u.extend(n,r),u.extend(n,e)),n},programWithDepth:r.VM.programWithDepth,noop:r.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var i,a,c=o.partial?o:r;o.partial||(i=o.helpers,a=o.partials);var s=e.call(t,c,n,i,a,o.data);return o.partial||r.VM.checkRevision(t.compilerInfo),s}}function i(e,r,n){var t=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},r.apply(this,[e,o.data||n].concat(t))};return o.program=e,o.depth=t.length,o}function a(e,r,n){var t=function(e,t){return t=t||{},r(e,t.data||n)};return t.program=e,t.depth=0,t}function c(e,r,n,t,o,i){var a={partial:!0,helpers:t,partials:o,data:i};if(void 0===e)throw new p("The partial "+r+" could not be found");return e instanceof Function?e(n,a):void 0}function s(){return""}var l={},u=e,p=r,f=n.COMPILER_REVISION,d=n.REVISION_CHANGES;return l.checkRevision=t,l.template=o,l.programWithDepth=i,l.program=a,l.invokePartial=c,l.noop=s,l}(r,n,t),i=function(e,r,n,t,o){"use strict";var i,a=e,c=r,s=n,l=t,u=o,p=function(){var e=new a.HandlebarsEnvironment;return l.extend(e,a),e.SafeString=c,e.Exception=s,e.Utils=l,e.VM=u,e.template=function(r){return u.template(r,e)},e},f=p();return f.create=p,i=f}(t,e,n,r,o);return i}(),oc=oc||{};!function(e,r,n){Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)});var t=[],o="undefined"!=typeof jQuery?jQuery:void 0,i="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js",a=5e3,c=function(){},s={error:function(e){return console.log(e)},info:function(e){return n?console.log(e):void 0}},l=function(e,r){for(var n=0;n=0;)e=e.replace(t,'');return e},oc.renderNestedComponent=function(e,r){e.html('
LOADING...
'),oc.renderByHref(e.attr("href"),function(n,t){return!n&&t&&t.html?void p(e,t,r):s.error(n)})},oc.renderByHref=function(e,r){return""===e?r("Failed to retrieve the component. Href parameter missing.",null):void o.ajax({url:e,headers:{"render-mode":"pre-rendered"},success:function(e){u(e.template.src,function(){oc.render(e.template.key,e.data,function(n,t){return n?r("Error rendering component: "+e.href+", error: "+n,null):(t=oc.resolveNestedComponents(t,e.components),s.info("Component '"+e.template.src+"' correctly loaded."),void r(null,{html:t,key:e.template.key,version:e.version}))})})},error:function(){s.error("Failed to retrieve the component. Retrying in 5 seconds..."),setTimeout(function(){oc.renderByHref(e,r)},a)}})},oc.renderUnloadedComponents=oc.refresh=function(){var e=o("oc-component[data-rendered!=true]"),r=function(e,n){s.info("Unloaded component found. Trying to retrieve it..."),oc.renderNestedComponent(o(e[n]),function(){n++,n0&&r(e,0)},oc.setEventListeners=function(e){e.off("reRender"),e.on("reRender",function(e,r){var n=o(e.target);return r&&""!==r&&n.attr("href",r),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")},oc.load=function(e,r,n){if(o(e)){o(e).html('');var t=o("oc-component",e);oc.renderNestedComponent(t,function(){"function"==typeof n&&n(t)})}},o?oc.renderUnloadedComponents():u(i,function(){o=jQuery,oc.renderUnloadedComponents()})}(Handlebars,document,!0),oc.clientVersion="0.3.0"; \ No newline at end of file +var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var r;return e.prototype.toString=function(){return""+this.string},r=e}(),r=function(e){"use strict";function r(e){return c[e]||"&"}function n(e,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}function t(e){return e instanceof a?e.toString():e||0===e?(e=""+e,l.test(e)?e.replace(s,r):e):""}function o(e){return e||0===e?f(e)&&0===e.length?!0:!1:!0}var i={},a=e,c={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},s=/[&<>"'`]/g,l=/[&<>"'`]/;i.extend=n;var u=Object.prototype.toString;i.toString=u;var p=function(e){return"function"==typeof e};p(/x/)&&(p=function(e){return"function"==typeof e&&"[object Function]"===u.call(e)});var p;i.isFunction=p;var f=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===u.call(e):!1};return i.isArray=f,i.escapeExpression=t,i.isEmpty=o,i}(e),n=function(){"use strict";function e(e,r){var t;r&&r.firstLine&&(t=r.firstLine,e+=" - "+t+":"+r.firstColumn);for(var o=Error.prototype.constructor.call(this,e),i=0;i0?e.helpers.each(r,n):t(this):o(r)}),e.registerHelper("each",function(e,r){var n,t=r.fn,o=r.inverse,i=0,a="";if(f(e)&&(e=e.call(this)),r.data&&(n=v(r.data)),e&&"object"==typeof e)if(p(e))for(var c=e.length;c>i;i++)n&&(n.index=i,n.first=0===i,n.last=i===e.length-1),a+=t(e[i],{data:n});else for(var s in e)e.hasOwnProperty(s)&&(n&&(n.key=s,n.index=i,n.first=0===i),a+=t(e[s],{data:n}),i++);return 0===i&&(a=o(this)),a}),e.registerHelper("if",function(e,r){return f(e)&&(e=e.call(this)),!r.hash.includeZero&&!e||a.isEmpty(e)?r.inverse(this):r.fn(this)}),e.registerHelper("unless",function(r,n){return e.helpers["if"].call(this,r,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,r){return f(e)&&(e=e.call(this)),a.isEmpty(e)?void 0:r.fn(e)}),e.registerHelper("log",function(r,n){var t=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(t,r)})}function o(e,r){m.log(e,r)}var i={},a=e,c=r,s="1.3.0";i.VERSION=s;var l=4;i.COMPILER_REVISION=l;var u={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};i.REVISION_CHANGES=u;var p=a.isArray,f=a.isFunction,d=a.toString,h="[object Object]";i.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,r,n){if(d.call(e)===h){if(n||r)throw new c("Arg not supported with multiple helpers");a.extend(this.helpers,e)}else n&&(r.not=n),this.helpers[e]=r},registerPartial:function(e,r){d.call(e)===h?a.extend(this.partials,e):this.partials[e]=r}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,r){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,r)}}};i.logger=m,i.log=o;var v=function(e){var r={};return a.extend(r,e),r};return i.createFrame=v,i}(r,n),o=function(e,r,n){"use strict";function t(e){var r=e&&e[0]||1,n=f;if(r!==n){if(n>r){var t=d[n],o=d[r];throw new p("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+t+") or downgrade your runtime to an older version ("+o+").")}throw new p("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,r){if(!r)throw new p("No environment passed to template");var n=function(e,n,t,o,i,a){var c=r.VM.invokePartial.apply(this,arguments);if(null!=c)return c;if(r.compile){var s={helpers:o,partials:i,data:a};return i[n]=r.compile(e,{data:void 0!==a},r),i[n](t,s)}throw new p("The partial "+n+" could not be compiled when running in runtime-only mode")},t={escapeExpression:u.escapeExpression,invokePartial:n,programs:[],program:function(e,r,n){var t=this.programs[e];return n?t=a(e,r,n):t||(t=this.programs[e]=a(e,r)),t},merge:function(e,r){var n=e||r;return e&&r&&e!==r&&(n={},u.extend(n,r),u.extend(n,e)),n},programWithDepth:r.VM.programWithDepth,noop:r.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var i,a,c=o.partial?o:r;o.partial||(i=o.helpers,a=o.partials);var s=e.call(t,c,n,i,a,o.data);return o.partial||r.VM.checkRevision(t.compilerInfo),s}}function i(e,r,n){var t=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},r.apply(this,[e,o.data||n].concat(t))};return o.program=e,o.depth=t.length,o}function a(e,r,n){var t=function(e,t){return t=t||{},r(e,t.data||n)};return t.program=e,t.depth=0,t}function c(e,r,n,t,o,i){var a={partial:!0,helpers:t,partials:o,data:i};if(void 0===e)throw new p("The partial "+r+" could not be found");return e instanceof Function?e(n,a):void 0}function s(){return""}var l={},u=e,p=r,f=n.COMPILER_REVISION,d=n.REVISION_CHANGES;return l.checkRevision=t,l.template=o,l.programWithDepth=i,l.program=a,l.invokePartial=c,l.noop=s,l}(r,n,t),i=function(e,r,n,t,o){"use strict";var i,a=e,c=r,s=n,l=t,u=o,p=function(){var e=new a.HandlebarsEnvironment;return l.extend(e,a),e.SafeString=c,e.Exception=s,e.Utils=l,e.VM=u,e.template=function(r){return u.template(r,e)},e},f=p();return f.create=p,i=f}(t,e,n,r,o);return i}(),oc=oc||{};!function(e,r,n){Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)});var t=[],o="undefined"!=typeof jQuery?jQuery:void 0,i="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js",a=5e3,c=function(){},s={error:function(e){return console.log(e)},info:function(e){return n?console.log(e):void 0}},l=function(e,r){for(var n=0;n=0;)e=e.replace(t,'');return e},oc.renderNestedComponent=function(e,r){e.html('
LOADING...
'),oc.renderByHref(e.attr("href"),function(n,t){return!n&&t&&t.html?void p(e,t,r):s.error(n)})},oc.renderByHref=function(e,r){return""===e?r("Failed to retrieve the component. Href parameter missing.",null):void o.ajax({url:e,headers:{"render-mode":"pre-rendered"},success:function(e){u(e.template.src,function(){oc.render(e.template.key,e.data,function(n,t){return n?r("Error rendering component: "+e.href+", error: "+n,null):(t=oc.resolveNestedComponents(t,e.components),s.info("Component '"+e.template.src+"' correctly loaded."),void r(null,{html:t,key:e.template.key,version:e.version}))})})},error:function(){s.error("Failed to retrieve the component. Retrying in 5 seconds..."),setTimeout(function(){oc.renderByHref(e,r)},a)}})},oc.renderUnloadedComponents=oc.refresh=function(){var e=o("oc-component[data-rendered!=true]"),r=function(e,n){s.info("Unloaded component found. Trying to retrieve it..."),oc.renderNestedComponent(o(e[n]),function(){n++,n0&&r(e,0)},oc.setEventListeners=function(e){e.off("reRender"),e.on("reRender",function(e,r){var n=o(e.target);return r&&""!==r&&n.attr("href",r),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")},oc.load=function(e,r,n){if(o(e)){o(e).html('');var t=o("oc-component",e);oc.renderNestedComponent(t,function(){"function"==typeof n&&n(t)})}},o?oc.renderUnloadedComponents():u(i,function(){o=jQuery,oc.renderUnloadedComponents()})}(Handlebars,document,!0),oc.clientVersion="0.3.1"; \ No newline at end of file diff --git a/components/oc-client/package.json b/components/oc-client/package.json index 6b0ab63ac..229512b94 100644 --- a/components/oc-client/package.json +++ b/components/oc-client/package.json @@ -1,7 +1,7 @@ { "name": "oc-client", "description": "", - "version": "0.3.0", + "version": "0.3.1", "dependencies": {}, "repository": "", "oc": { diff --git a/components/oc-client/src/oc-client.min.js b/components/oc-client/src/oc-client.min.js index cc13fbcc3..572df3bce 100644 --- a/components/oc-client/src/oc-client.min.js +++ b/components/oc-client/src/oc-client.min.js @@ -1 +1 @@ -var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var r;return e.prototype.toString=function(){return""+this.string},r=e}(),r=function(e){"use strict";function r(e){return c[e]||"&"}function n(e,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}function t(e){return e instanceof a?e.toString():e||0===e?(e=""+e,l.test(e)?e.replace(s,r):e):""}function o(e){return e||0===e?f(e)&&0===e.length?!0:!1:!0}var i={},a=e,c={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},s=/[&<>"'`]/g,l=/[&<>"'`]/;i.extend=n;var u=Object.prototype.toString;i.toString=u;var p=function(e){return"function"==typeof e};p(/x/)&&(p=function(e){return"function"==typeof e&&"[object Function]"===u.call(e)});var p;i.isFunction=p;var f=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===u.call(e):!1};return i.isArray=f,i.escapeExpression=t,i.isEmpty=o,i}(e),n=function(){"use strict";function e(e,r){var t;r&&r.firstLine&&(t=r.firstLine,e+=" - "+t+":"+r.firstColumn);for(var o=Error.prototype.constructor.call(this,e),i=0;i0?e.helpers.each(r,n):t(this):o(r)}),e.registerHelper("each",function(e,r){var n,t=r.fn,o=r.inverse,i=0,a="";if(f(e)&&(e=e.call(this)),r.data&&(n=v(r.data)),e&&"object"==typeof e)if(p(e))for(var c=e.length;c>i;i++)n&&(n.index=i,n.first=0===i,n.last=i===e.length-1),a+=t(e[i],{data:n});else for(var s in e)e.hasOwnProperty(s)&&(n&&(n.key=s,n.index=i,n.first=0===i),a+=t(e[s],{data:n}),i++);return 0===i&&(a=o(this)),a}),e.registerHelper("if",function(e,r){return f(e)&&(e=e.call(this)),!r.hash.includeZero&&!e||a.isEmpty(e)?r.inverse(this):r.fn(this)}),e.registerHelper("unless",function(r,n){return e.helpers["if"].call(this,r,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,r){return f(e)&&(e=e.call(this)),a.isEmpty(e)?void 0:r.fn(e)}),e.registerHelper("log",function(r,n){var t=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(t,r)})}function o(e,r){m.log(e,r)}var i={},a=e,c=r,s="1.3.0";i.VERSION=s;var l=4;i.COMPILER_REVISION=l;var u={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};i.REVISION_CHANGES=u;var p=a.isArray,f=a.isFunction,d=a.toString,h="[object Object]";i.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,r,n){if(d.call(e)===h){if(n||r)throw new c("Arg not supported with multiple helpers");a.extend(this.helpers,e)}else n&&(r.not=n),this.helpers[e]=r},registerPartial:function(e,r){d.call(e)===h?a.extend(this.partials,e):this.partials[e]=r}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,r){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,r)}}};i.logger=m,i.log=o;var v=function(e){var r={};return a.extend(r,e),r};return i.createFrame=v,i}(r,n),o=function(e,r,n){"use strict";function t(e){var r=e&&e[0]||1,n=f;if(r!==n){if(n>r){var t=d[n],o=d[r];throw new p("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+t+") or downgrade your runtime to an older version ("+o+").")}throw new p("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,r){if(!r)throw new p("No environment passed to template");var n=function(e,n,t,o,i,a){var c=r.VM.invokePartial.apply(this,arguments);if(null!=c)return c;if(r.compile){var s={helpers:o,partials:i,data:a};return i[n]=r.compile(e,{data:void 0!==a},r),i[n](t,s)}throw new p("The partial "+n+" could not be compiled when running in runtime-only mode")},t={escapeExpression:u.escapeExpression,invokePartial:n,programs:[],program:function(e,r,n){var t=this.programs[e];return n?t=a(e,r,n):t||(t=this.programs[e]=a(e,r)),t},merge:function(e,r){var n=e||r;return e&&r&&e!==r&&(n={},u.extend(n,r),u.extend(n,e)),n},programWithDepth:r.VM.programWithDepth,noop:r.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var i,a,c=o.partial?o:r;o.partial||(i=o.helpers,a=o.partials);var s=e.call(t,c,n,i,a,o.data);return o.partial||r.VM.checkRevision(t.compilerInfo),s}}function i(e,r,n){var t=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},r.apply(this,[e,o.data||n].concat(t))};return o.program=e,o.depth=t.length,o}function a(e,r,n){var t=function(e,t){return t=t||{},r(e,t.data||n)};return t.program=e,t.depth=0,t}function c(e,r,n,t,o,i){var a={partial:!0,helpers:t,partials:o,data:i};if(void 0===e)throw new p("The partial "+r+" could not be found");return e instanceof Function?e(n,a):void 0}function s(){return""}var l={},u=e,p=r,f=n.COMPILER_REVISION,d=n.REVISION_CHANGES;return l.checkRevision=t,l.template=o,l.programWithDepth=i,l.program=a,l.invokePartial=c,l.noop=s,l}(r,n,t),i=function(e,r,n,t,o){"use strict";var i,a=e,c=r,s=n,l=t,u=o,p=function(){var e=new a.HandlebarsEnvironment;return l.extend(e,a),e.SafeString=c,e.Exception=s,e.Utils=l,e.VM=u,e.template=function(r){return u.template(r,e)},e},f=p();return f.create=p,i=f}(t,e,n,r,o);return i}(),oc=oc||{};!function(e,r,n){Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)});var t=[],o="undefined"!=typeof jQuery?jQuery:void 0,i="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js",a=5e3,c=function(){},s={error:function(e){return console.log(e)},info:function(e){return n?console.log(e):void 0}},l=function(e,r){for(var n=0;n=0;)e=e.replace(t,'');return e},oc.renderNestedComponent=function(e,r){e.html('
LOADING...
'),oc.renderByHref(e.attr("href"),function(n,t){return!n&&t&&t.html?void p(e,t,r):s.error(n)})},oc.renderByHref=function(e,r){return""===e?r("Failed to retrieve the component. Href parameter missing.",null):void o.ajax({url:e,headers:{"render-mode":"pre-rendered"},success:function(e){u(e.template.src,function(){oc.render(e.template.key,e.data,function(n,t){return n?r("Error rendering component: "+e.href+", error: "+n,null):(t=oc.resolveNestedComponents(t,e.components),s.info("Component '"+e.template.src+"' correctly loaded."),void r(null,{html:t,key:e.template.key,version:e.version}))})})},error:function(){s.error("Failed to retrieve the component. Retrying in 5 seconds..."),setTimeout(function(){oc.renderByHref(e,r)},a)}})},oc.renderUnloadedComponents=oc.refresh=function(){var e=o("oc-component[data-rendered!=true]"),r=function(e,n){s.info("Unloaded component found. Trying to retrieve it..."),oc.renderNestedComponent(o(e[n]),function(){n++,n0&&r(e,0)},oc.setEventListeners=function(e){e.off("reRender"),e.on("reRender",function(e,r){var n=o(e.target);return r&&""!==r&&n.attr("href",r),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")},oc.load=function(e,r,n){if(o(e)){o(e).html('');var t=o("oc-component",e);oc.renderNestedComponent(t,function(){"function"==typeof n&&n(t)})}},o?oc.renderUnloadedComponents():u(i,function(){o=jQuery,oc.renderUnloadedComponents()})}(Handlebars,document,!0),oc.clientVersion="0.3.0"; \ No newline at end of file +var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var r;return e.prototype.toString=function(){return""+this.string},r=e}(),r=function(e){"use strict";function r(e){return c[e]||"&"}function n(e,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}function t(e){return e instanceof a?e.toString():e||0===e?(e=""+e,l.test(e)?e.replace(s,r):e):""}function o(e){return e||0===e?f(e)&&0===e.length?!0:!1:!0}var i={},a=e,c={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},s=/[&<>"'`]/g,l=/[&<>"'`]/;i.extend=n;var u=Object.prototype.toString;i.toString=u;var p=function(e){return"function"==typeof e};p(/x/)&&(p=function(e){return"function"==typeof e&&"[object Function]"===u.call(e)});var p;i.isFunction=p;var f=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===u.call(e):!1};return i.isArray=f,i.escapeExpression=t,i.isEmpty=o,i}(e),n=function(){"use strict";function e(e,r){var t;r&&r.firstLine&&(t=r.firstLine,e+=" - "+t+":"+r.firstColumn);for(var o=Error.prototype.constructor.call(this,e),i=0;i0?e.helpers.each(r,n):t(this):o(r)}),e.registerHelper("each",function(e,r){var n,t=r.fn,o=r.inverse,i=0,a="";if(f(e)&&(e=e.call(this)),r.data&&(n=v(r.data)),e&&"object"==typeof e)if(p(e))for(var c=e.length;c>i;i++)n&&(n.index=i,n.first=0===i,n.last=i===e.length-1),a+=t(e[i],{data:n});else for(var s in e)e.hasOwnProperty(s)&&(n&&(n.key=s,n.index=i,n.first=0===i),a+=t(e[s],{data:n}),i++);return 0===i&&(a=o(this)),a}),e.registerHelper("if",function(e,r){return f(e)&&(e=e.call(this)),!r.hash.includeZero&&!e||a.isEmpty(e)?r.inverse(this):r.fn(this)}),e.registerHelper("unless",function(r,n){return e.helpers["if"].call(this,r,{fn:n.inverse,inverse:n.fn,hash:n.hash})}),e.registerHelper("with",function(e,r){return f(e)&&(e=e.call(this)),a.isEmpty(e)?void 0:r.fn(e)}),e.registerHelper("log",function(r,n){var t=n.data&&null!=n.data.level?parseInt(n.data.level,10):1;e.log(t,r)})}function o(e,r){m.log(e,r)}var i={},a=e,c=r,s="1.3.0";i.VERSION=s;var l=4;i.COMPILER_REVISION=l;var u={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};i.REVISION_CHANGES=u;var p=a.isArray,f=a.isFunction,d=a.toString,h="[object Object]";i.HandlebarsEnvironment=n,n.prototype={constructor:n,logger:m,log:o,registerHelper:function(e,r,n){if(d.call(e)===h){if(n||r)throw new c("Arg not supported with multiple helpers");a.extend(this.helpers,e)}else n&&(r.not=n),this.helpers[e]=r},registerPartial:function(e,r){d.call(e)===h?a.extend(this.partials,e):this.partials[e]=r}};var m={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,r){if(m.level<=e){var n=m.methodMap[e];"undefined"!=typeof console&&console[n]&&console[n].call(console,r)}}};i.logger=m,i.log=o;var v=function(e){var r={};return a.extend(r,e),r};return i.createFrame=v,i}(r,n),o=function(e,r,n){"use strict";function t(e){var r=e&&e[0]||1,n=f;if(r!==n){if(n>r){var t=d[n],o=d[r];throw new p("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+t+") or downgrade your runtime to an older version ("+o+").")}throw new p("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function o(e,r){if(!r)throw new p("No environment passed to template");var n=function(e,n,t,o,i,a){var c=r.VM.invokePartial.apply(this,arguments);if(null!=c)return c;if(r.compile){var s={helpers:o,partials:i,data:a};return i[n]=r.compile(e,{data:void 0!==a},r),i[n](t,s)}throw new p("The partial "+n+" could not be compiled when running in runtime-only mode")},t={escapeExpression:u.escapeExpression,invokePartial:n,programs:[],program:function(e,r,n){var t=this.programs[e];return n?t=a(e,r,n):t||(t=this.programs[e]=a(e,r)),t},merge:function(e,r){var n=e||r;return e&&r&&e!==r&&(n={},u.extend(n,r),u.extend(n,e)),n},programWithDepth:r.VM.programWithDepth,noop:r.VM.noop,compilerInfo:null};return function(n,o){o=o||{};var i,a,c=o.partial?o:r;o.partial||(i=o.helpers,a=o.partials);var s=e.call(t,c,n,i,a,o.data);return o.partial||r.VM.checkRevision(t.compilerInfo),s}}function i(e,r,n){var t=Array.prototype.slice.call(arguments,3),o=function(e,o){return o=o||{},r.apply(this,[e,o.data||n].concat(t))};return o.program=e,o.depth=t.length,o}function a(e,r,n){var t=function(e,t){return t=t||{},r(e,t.data||n)};return t.program=e,t.depth=0,t}function c(e,r,n,t,o,i){var a={partial:!0,helpers:t,partials:o,data:i};if(void 0===e)throw new p("The partial "+r+" could not be found");return e instanceof Function?e(n,a):void 0}function s(){return""}var l={},u=e,p=r,f=n.COMPILER_REVISION,d=n.REVISION_CHANGES;return l.checkRevision=t,l.template=o,l.programWithDepth=i,l.program=a,l.invokePartial=c,l.noop=s,l}(r,n,t),i=function(e,r,n,t,o){"use strict";var i,a=e,c=r,s=n,l=t,u=o,p=function(){var e=new a.HandlebarsEnvironment;return l.extend(e,a),e.SafeString=c,e.Exception=s,e.Utils=l,e.VM=u,e.template=function(r){return u.template(r,e)},e},f=p();return f.create=p,i=f}(t,e,n,r,o);return i}(),oc=oc||{};!function(e,r,n){Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)});var t=[],o="undefined"!=typeof jQuery?jQuery:void 0,i="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js",a=5e3,c=function(){},s={error:function(e){return console.log(e)},info:function(e){return n?console.log(e):void 0}},l=function(e,r){for(var n=0;n=0;)e=e.replace(t,'');return e},oc.renderNestedComponent=function(e,r){e.html('
LOADING...
'),oc.renderByHref(e.attr("href"),function(n,t){return!n&&t&&t.html?void p(e,t,r):s.error(n)})},oc.renderByHref=function(e,r){return""===e?r("Failed to retrieve the component. Href parameter missing.",null):void o.ajax({url:e,headers:{"render-mode":"pre-rendered"},success:function(e){u(e.template.src,function(){oc.render(e.template.key,e.data,function(n,t){return n?r("Error rendering component: "+e.href+", error: "+n,null):(t=oc.resolveNestedComponents(t,e.components),s.info("Component '"+e.template.src+"' correctly loaded."),void r(null,{html:t,key:e.template.key,version:e.version}))})})},error:function(){s.error("Failed to retrieve the component. Retrying in 5 seconds..."),setTimeout(function(){oc.renderByHref(e,r)},a)}})},oc.renderUnloadedComponents=oc.refresh=function(){var e=o("oc-component[data-rendered!=true]"),r=function(e,n){s.info("Unloaded component found. Trying to retrieve it..."),oc.renderNestedComponent(o(e[n]),function(){n++,n0&&r(e,0)},oc.setEventListeners=function(e){e.off("reRender"),e.on("reRender",function(e,r){var n=o(e.target);return r&&""!==r&&n.attr("href",r),n.attr("data-hash",""),n.attr("data-rendered",!1),oc.renderUnloadedComponents(),!1}),e.trigger("loaded")},oc.load=function(e,r,n){if(o(e)){o(e).html('');var t=o("oc-component",e);oc.renderNestedComponent(t,function(){"function"==typeof n&&n(t)})}},o?oc.renderUnloadedComponents():u(i,function(){o=jQuery,oc.renderUnloadedComponents()})}(Handlebars,document,!0),oc.clientVersion="0.3.1"; \ No newline at end of file diff --git a/package.json b/package.json index afad5160e..5a828ce43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oc", - "version": "0.3.0", + "version": "0.3.1", "description": "An experimental framework to develop and distribute html components", "main": "index.js", "bin": { diff --git a/test/unit/cli-domain-local.js b/test/unit/cli-domain-local.js index 222cacfe9..09f0c3596 100644 --- a/test/unit/cli-domain-local.js +++ b/test/unit/cli-domain-local.js @@ -6,40 +6,42 @@ var sinon = require('sinon'); describe('cli : domain : local', function(){ - describe('when packaging', function(){ + describe('when packaging', function(){ - var readJsonSyncStub = sinon.stub(); - var readFileSyncStub = sinon.stub(); - var packageMock = { - version: '1.2.3' - }; - var fsMock = { - readdirSync: sinon.spy(), - mkdirSync: sinon.spy(), - readJsonSync: readJsonSyncStub, - readFileSync: readFileSyncStub - }; - var mockComponent = { - name: 'helloworld', - oc: { - files: { - template: { - type: 'wrongtype', - src: '' - } - } - } - }; - readJsonSyncStub.returns(mockComponent); - readFileSyncStub.returns(''); - var Local = injectr('../../cli/domain/local.js', { 'fs-extra' : fsMock, '../../package.json': packageMock }); + var readJsonSyncStub = sinon.stub(); + var readFileSyncStub = sinon.stub(); - it('should add version to package.json file', function(done){ - var local = new Local(); - local.package('.', function(err, res){ - expect(mockComponent.oc.version).to.eql('1.2.3'); - done(); - }); - }); + var fsMock = { + readdirSync: sinon.spy(), + mkdirSync: sinon.spy(), + readJsonSync: readJsonSyncStub, + readFileSync: readFileSyncStub + }; + + var mockComponent = { + name: 'helloworld', + oc: { + files: { + template: { + type: 'wrongtype', + src: '' + } + } + } + }; + readJsonSyncStub.withArgs('package.json').returns(mockComponent); + readJsonSyncStub.withArgs('../../package.json').returns({ + version: '1.2.3' + }); + readFileSyncStub.returns(''); + var Local = injectr('../../cli/domain/local.js', { 'fs-extra' : fsMock }, { __dirname: '' }); + + it('should add version to package.json file', function(done){ + var local = new Local(); + local.package('.', function(err, res){ + expect(mockComponent.oc.version).to.eql('1.2.3'); + done(); + }); }); + }); }); \ No newline at end of file diff --git a/test/unit/registry-app-start.js b/test/unit/registry-app-start.js index 0da95f75b..16f84465e 100644 --- a/test/unit/registry-app-start.js +++ b/test/unit/registry-app-start.js @@ -7,7 +7,7 @@ var sinon = require('sinon'); var getAppStart = function(mockedRepository, options, callback){ var appStart = injectr('../../registry/app-start.js', { './domain/repository': mockedRepository - }, { console: console, __dirname: '.'}); + }, { console: { log: sinon.stub() }, __dirname: '.'}); return appStart(options, callback); };