exportWorkingCopy: function() { var self = this, label = 'Export working copy [' + self.pathSelf.green + ']', cmd = [ 'rsync', '-a', '--exclude=/.git', '--exclude=/.svn', '--exclude=/' + self.pathTmp, '.', self.pathTmp + self.pathSelf ].join(' '); LOGGER.time(label); return U.exec(cmd) .fail(function(err) { LOGGER.error('exportWorkingCopy'.blue); return Q.reject(err); }) .then(function() { LOGGER.timeEnd(label); return self.pathSelf; }); },
getBenchmarksPaths: function(treeishPath, levelPath) { var self = this, level = LEVEL.createLevel(PATH.join(treeishPath, levelPath)), benchmarks; if (self.benchmarks && self.benchmarks.length) { // if -b flag detected then compare not all benchmarks benchmarks = U.arrayUnique(self.benchmarks) .map(function(b) { return U.bemParseKey(b); }); } else { // if -b flag not detected then all benchmarks benchmarks = level.getItemsByIntrospection() .filter(function(item) { return item.tech === 'bemjson.js'; }); } return benchmarks .map(function(benchmark) { return level.getPathByObj(benchmark, 'bemjson.js'); }); },
getCreateResults: function(prefix, vars) { var _this = this, source = this.getPath(prefix, this.getSourceSuffix()); return BEM.util.readJsonJs(source) .then(function(data) { var res = {}; _this.getLangs().forEach(function(lang) { var suffix = _this.getCreateSuffixForLang(lang), dataLang = _this.extendLangDecl({}, data['all'] || {}); dataLang = _this.extendLangDecl(dataLang, data[lang] || {}); res[suffix] = _this.getCreateResult( _this.getPath(prefix, suffix), suffix, BEM.util.extend({}, vars, { data: dataLang, lang: lang })); }); // NOTE: hack to pass outputName to storeCreateResult() res[_this.getBaseTechSuffix()] = prefix; return Q.shallow(res); }); },
getBuildResults: function(prefixes, outputDir, outputName) { var _this = this, prefix = PATH.resolve(outputDir, outputName), source = this.getPath(prefix, this.getSourceSuffix()); return BEM.util.readJsonJs(source) .then(function(data) { var res = {}; _this.getLangs().forEach(function(lang) { var suffix = _this.getBuildSuffixForLang(lang), dataLang = _this.extendLangDecl({}, data['all'] || {}); dataLang = _this.extendLangDecl(dataLang, data[lang] || {}); res[suffix] = _this.getBuildResult(prefixes, suffix, outputDir, outputName, dataLang, lang); }); // NOTE: hack to pass outputName to storeBuildResult() res[_this.getBaseTechSuffix()] = outputName; return Q.shallow(res); }); },
makeTarget: function(target) { var self = this, targets = [self.pathBenchmarks], label = '[' + target.green + '] has been assembled'; LOGGER.time(label); if (self.benchmarks && self.benchmarks.length) { targets = self.benchmarks .map(function(b) { return PATH.join(self.pathBenchmarks, b); }); } return U.exec('cd ' + PATH.join(self.pathTmp, target) + ' && npm install && ./node_modules/.bin/bem make ' + targets.join(' ')) .fail(function(err) { LOGGER.error(target.red + ' not make'); return Q.reject(err); }) .then(function() { LOGGER.timeEnd(label); }); },
storeBuildResult: function(path, suffix, res) { BEM.util.mkdirs(PATH.dirname(path)); res = '(' + JSON.stringify(res, null, 4) + ')\n'; return this.__base(path, suffix, res); },
exports.getTechs = function() { return BEM.util.extend(require('./blocks').getTechs(), { 'blocks' : 'level-proto', 'title.txt' : 'bem/lib/tech/v2', 'bemjson.js' : 'bem/lib/tech/v2' }); };
getJson: function(prefix) { var path = this.getPath(prefix, 'json.js'); return BEM.util.readFile(path) .then(function(c) { return VM.runInThisContext(c, path); }); },
var getBemjson = function(str) { var path = str.replace('bemhtml', 'bemjson'); return BEM.util.readFile(path) .then(function(c) { return VM.runInThisContext(c, path); }); };
getCreateResults: function(prefix, vars) { var _this = this, source = this.getPath(prefix, this.getSourceSuffix()); return BEM.util.readJsonJs(source) .then(function(data) { return Q.shallow(_this.getCreateResultsForLangs(prefix, data)); }); },
getBemhtml: function(prefix) { var path = this.getPath(prefix, 'bemhtml.js'); return BEM.util.readFile(path) .then(function(c) { var ctx = VM.createContext({ require: require, console: console }); VM.runInContext(c, ctx, path); return ctx.BEMHTML; }); },
getBemtree: function(prefix) { var path = this.getPath(prefix, 'bemtree.js'); return BEM.util.readFile(path) .then(function(c) { /** @name BEMHTML variable appears after runInThisContext() call */ VM.runInThisContext(c, path); return BEMHTML; }); },
var getBemhtml = function(str) { var path = str; return BEM.util.readFile(path) .then(function(c) { /** @name BEMHTML variable appears after runInThisContext() call */ VM.runInThisContext(c, path); return BEMHTML; }); };
getBemjson: function(prefix) { var path = this.getPath(prefix, 'bemjson.js'); return BEM.util.readFile(path) .then(function(c) { return VM.runInNewContext( c, { require: require, console: console }, path); }); }
exports.getConfig = function () { return BEM.util.extend(this.__base() || {}, { bundleBuildLevels: [].concat( this.__base().bundleBuildLevels, this.resolvePaths(['../unit/geoapi']) ) }); };
exports.getConfig = function() { return BEM.util.extend(this.__base() || {}, { bundleBuildLevels: [ 'blocks-common', 'blocks-desktop' ] .map(environ.getLibPath.bind(null, 'bem-bl')) .concat(this.resolvePaths(['../../common.blocks'])) }); };
_this.getLangs().forEach(function(lang) { var suffix = _this.getCreateSuffixForLang(lang), dataLang = _this.extendLangDecl({}, data['all'] || {}); dataLang = _this.extendLangDecl(dataLang, data[lang] || {}); res[suffix] = _this.getCreateResult( _this.getPath(prefix, suffix), suffix, BEM.util.extend({}, vars, { data: dataLang, lang: lang })); });
.map(function(treeish) { var cmd = "git show " + treeish + " | grep Date | awk -F': ' '{print $2}'"; return U.exec(cmd, null, true) .then(function(output) { return { treeish: treeish, date: output.replace('\n', '') }; }); })
.then(function() { var cmd = [ 'cp', '-R', PATH.join(self.pathTmp, source, self.pathBenchmarks + '*'), PATH.join(self.pathTmp, target, self.pathBenchmarks) ].join(' '); return U.exec(cmd) .fail(onFail); });
exports.getConfig = function() { return BEM.util.extend(this.__base() || {}, { bundleBuildLevels: this.resolvePaths([ '../../bem-bl/blocks-common', '../../bem-bl/blocks-desktop', '../../bemhtml/common.blocks', '../../john-lib/blocks/', '../../desktop.blocks' ]) }); };
Object.keys(ext).forEach(function(keyset) { // fallback to BEM.util.extend() on normal keysets if (keyset !== '') { // TODO: here will also go merge of i18n:js and i18n:xsl content of key values in the future decl[keyset] = BEM.util.extend(true, decl[keyset] || {}, ext[keyset]); return; } // concatenate values of empty keysets decl[keyset] || (decl[keyset] = ''); decl[keyset] += '\n' + ext[keyset]; });
storeBuildResult: function(path, suffix, res) { if (suffix === this.getBaseTechSuffix()) { return BEM.util.symbolicLink( path, this.getPath( res, this.getBuildSuffixForLang(this.getDefaultLang())), true); } return this.__base(path, suffix, res); },
cleanTempDir: function() { var cmd = 'rm -rf ./' + this.pathTmp + '*', label = 'TMP folder has been cleaned'; LOGGER.info('Cleaning a TMP folder'); LOGGER.time(label); return U.exec(cmd) .fin(function() { LOGGER.timeEnd(label); }); },
storeCreateResult: function(path, suffix, res, force) { if (suffix === this.getBaseTechSuffix()) { return BEM.util.symbolicLink( path, this.getPath( PATH.basename(res), this.getCreateSuffixForLang(this.getDefaultLang())), true); } return this.__base(path, suffix, res, force); },
getCreateResult: function(path, suffix, vars) { var data = vars.data, i18n = data && !BEM.util.isEmptyObject(data)? this.serializeI18nData(data, vars.lang) .concat([this.serializeI18nInit(vars.lang)]) .join('\n') : ''; return this.getHtml( this.getBemhtml(vars.Prefix, i18n), this.getBemjson(vars.Prefix)); },
exports.getConfig = function() { return BEM.util.extend(this.__base() || {}, { bundleBuildLevels: this.resolvePaths([ 'bem-core/common.blocks' ] .map(function(path) { return PATH.resolve(environ.LIB_ROOT, path); }) .concat([ 'common.blocks', 'desktop.blocks' ] .map(function(path) { return PATH.resolve(environ.PRJ_ROOT, path); }))) }); };
exports.getBuildResultChunk = function(relPath, path, suffix) { return BEM.util.readFile(path) .then(function(c) { return [ '/* ' + path + ': start */', c, '/* ' + path + ': end */', '\n' ].join('\n'); }); };
getBuildResults: function(decl, levels, output, opts) { var _this = this, source = this.getPath(output, this.getSourceSuffix()), base = this.__base; return BEM.util.readJsonJs(source) .then(function(data) { opts = opts || {}; opts.ctx = { data: data }; return base.call(_this, decl, levels, output, opts); }); },
getLevels : function() { var resolve = PATH.resolve.bind(PATH, this.root), buildLevel = this.getLevelPath(), getPlatformLevelsFn = 'get' + U.toUpperCaseFirst(this.getPlatform(buildLevel)) + 'Levels', levels = []; if(typeof this[getPlatformLevelsFn] === 'function') { Array.prototype.push.apply(levels, this[getPlatformLevelsFn].apply(this, arguments)); } if(!levels.length) { return []; } return levels .map(function(path) { return resolve(path); }) .concat(resolve(PATH.dirname(this.getNodePrefix()), 'blocks')); },
getBemhtml: function(prefix, i18n) { var path = this.getPath(prefix, 'bemhtml.js'); return Q.all([BEM.util.readFile(path), i18n]) .spread(function(bemhtml, i18n) { return VM.runInThisContext([ '(function(){', // make local var BEM to prevent global assignment in i18n code 'var BEM = {};', i18n, bemhtml, 'return BEMHTML;', '})()' ].join('\n'), path); }); },