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

Миронов Данил #17

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 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
1 change: 1 addition & 0 deletions .bem/level.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports.baseLevelPath = require.resolve('bem/lib/levels/project');
32 changes: 32 additions & 0 deletions .bem/levels/blocks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var PATH = require('path'),
environ = require('bem-environ'),
getTechResolver = environ.getTechResolver,

PRJ_ROOT = environ.PRJ_ROOT,
PRJ_TECHS = PATH.resolve(PRJ_ROOT, '.bem/techs'),
BEMCORE_TECHS = environ.getLibPath('bem-core', '.bem/techs');

exports.getTechs = function() {
var techs = {
'stylus' : 'v2/styl',
'css' : 'v2/css',
'ie.css' : 'v2/ie.css',
'ie6.css' : 'v2/ie6.css',
'ie7.css' : 'v2/ie7.css',
'ie8.css' : 'v2/ie8.css',
'ie9.css' : 'v2/ie9.css',
'js' : 'v2/js-i',
'bemdecl.js' : 'v2/bemdecl.js',
'deps.js' : 'v2/deps.js'
};

// use techs from project (.bem/techs)
['bemjson.js'].forEach(getTechResolver(techs, PRJ_TECHS));

// use techs from bem-core library
['bemhtml', 'bemtree', 'vanilla.js', 'browser.js', 'node.js'].forEach(getTechResolver(techs, BEMCORE_TECHS));

return techs;
};

exports.defaultTechs = ['stylus', 'browser.js', 'bemhtml'];
19 changes: 19 additions & 0 deletions .bem/levels/bundles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var PATH = require('path'),
environ = require('bem-environ'),
getTechResolver = environ.getTechResolver,

BEMCORE_TECHS = environ.getLibPath('bem-core', '.bem/techs');

exports.baseLevelPath = require.resolve('./blocks');

exports.getTechs = function() {
var techs = this.__base();

// Use techs from lib bem-core
['browser.js+bemhtml', 'html'].forEach(getTechResolver(techs, BEMCORE_TECHS));

return techs;
};

// Create bundles in bemjson.js tech
exports.defaultTechs = ['bemjson.js'];
83 changes: 83 additions & 0 deletions .bem/make.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* global MAKE:false */

// process.env.YENV = 'production';

var PATH = require('path');

require('bem-tools-autoprefixer').extendMake(MAKE);

MAKE.decl('Arch', {

blocksLevelsRegexp : /^.+?\.blocks/,
bundlesLevelsRegexp : /^.+?\.bundles$/

});


MAKE.decl('BundleNode', {

getTechs : function() {

return [
'bemjson.js',
'bemdecl.js',
'deps.js',
'bemtree',
'bemhtml',
'browser.js+bemhtml',
'stylus',
'css',
'html'
];

},

getForkedTechs : function() {
return this.__base().concat(['browser.js+bemhtml', 'stylus']);
},

getLevelsMap : function() {
return {
desktop : [
'libs/bem-core/common.blocks',
'libs/bem-core/desktop.blocks',
'libs/bem-components/common.blocks',
'libs/bem-components/desktop.blocks',
'libs/bem-components/design/common.blocks',
'libs/bem-components/design/desktop.blocks',
'common.blocks',
'desktop.blocks'
]
};
},

getLevels : function() {
var resolve = PATH.resolve.bind(PATH, this.root),
buildLevel = this.getLevelPath().split('.')[0],
levels = this.getLevelsMap()[buildLevel] || [];

return levels
.map(function(path) { return resolve(path); })
.concat(resolve(PATH.dirname(this.getNodePrefix()), 'blocks'));
},

'create-css-node' : function(tech, bundleNode, magicNode) {
var source = this.getBundlePath('stylus');
if(this.ctx.arch.hasNode(source)) {
return this.createAutoprefixerNode(tech, this.ctx.arch.getNode(source), bundleNode, magicNode);
}
}

});

MAKE.decl('AutoprefixerNode', {

getBrowsers : function() {
return [
'last 2 versions',
'ie 10',
'opera 12.16'
];
}

});
32 changes: 32 additions & 0 deletions .bem/techs/bemjson.js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

var Template = require('bem/lib/template');

exports.API_VER = 2;

exports.techMixin = {

getCreateResult : function(path, suffix, vars) {

if (vars.opts && vars.opts.content) return vars.opts.content;

return Template.process([
"({",
" block: 'page',",
" title: '{{bemBlockName}}',",
" head: [",
" { elem: 'css', url: '_{{bemBlockName}}.css' }",
" ],",
" scripts: [{ elem: 'js', url: '_{{bemBlockName}}.js' }],",
" content: [",
" {",
" block: 'content',",
" content: [",
" 'block content'",
" ]",
" }",
" ]",
"})"], vars);
}

};
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "libs"
}
108 changes: 108 additions & 0 deletions .enb/make.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
var techs = {
// essential
fileProvider: require('enb/techs/file-provider'),
fileMerge: require('enb/techs/file-merge'),

// optimization
borschik: require('enb-borschik/techs/borschik'),

// css
cssStylus: require('enb-stylus/techs/css-stylus'),
cssAutoprefixer: require('enb-autoprefixer/techs/css-autoprefixer'),

// js
browserJs: require('enb-diverse-js/techs/browser-js'),
prependYm: require('enb-modules/techs/prepend-modules'),
babel: require('enb-babel/techs/js-babel'),

// bemtree
//bemtree: require('enb-bemxjst/techs/bemtree-old'),

// bemhtml
bemhtml: require('enb-bemxjst/techs/bemhtml-old'),
htmlFromBemjson: require('enb-bemxjst/techs/html-from-bemjson')
},
enbBemTechs = require('enb-bem-techs'),
levels = [
{ path: 'libs/bem-core/common.blocks', check: false },
{ path: 'libs/bem-core/desktop.blocks', check: false },
{ path: 'libs/bem-components/common.blocks', check: false },
{ path: 'libs/bem-components/desktop.blocks', check: false },
{ path: 'libs/bem-components/design/common.blocks', check: false },
{ path: 'libs/bem-components/design/desktop.blocks', check: false },
'common.blocks',
'desktop.blocks'
];

module.exports = function(config) {
var isProd = process.env.YENV === 'production';

config.nodes('*.bundles/*', function(nodeConfig) {
nodeConfig.addTechs([
// essential
[enbBemTechs.levels, { levels: levels }],
[techs.fileProvider, { target: '?.bemjson.js' }],
[enbBemTechs.bemjsonToBemdecl],
// [techs.fileProvider, { target: '?.bemdecl.js' }],
[enbBemTechs.deps],
[enbBemTechs.files],

// css
[techs.cssStylus, { target: '?.noprefix.css' }],
[techs.cssAutoprefixer, {
sourceTarget: '?.noprefix.css',
destTarget: '?.css',
browserSupport: ['last 2 versions', 'ie 10', 'opera 12.16']
}],

// bemtree
//[techs.bemtree, { devMode: process.env.BEMTREE_ENV === 'development' }],

// bemhtml
[techs.bemhtml, { devMode: process.env.BEMHTML_ENV === 'development' }],
[techs.htmlFromBemjson],

// client bemhtml
[enbBemTechs.depsByTechToBemdecl, {
target: '?.bemhtml.bemdecl.js',
sourceTech: 'js',
destTech: 'bemhtml'
}],
[enbBemTechs.deps, {
target: '?.bemhtml.deps.js',
bemdeclFile: '?.bemhtml.bemdecl.js'
}],
[enbBemTechs.files, {
depsFile: '?.bemhtml.deps.js',
filesTarget: '?.bemhtml.files',
dirsTarget: '?.bemhtml.dirs'
}],
[techs.bemhtml, {
target: '?.browser.bemhtml.js',
filesTarget: '?.bemhtml.files',
devMode: process.env.BEMHTML_ENV === 'development'
}],

// js
[techs.babel, {
target: '?.browser.babel.js',
source: '?.browser.js'
}],
[techs.browserJs, {
target: '?.browser.js',
source: '?.browser.babel.js'
}],
[techs.fileMerge, {
target: '?.pre.js',
sources: ['?.browser.bemhtml.js', '?.browser.js']
}],
[techs.prependYm, { source: '?.pre.js' }],

// borschik
[techs.borschik, { sourceTarget: '?.js', destTarget: '_?.js', freeze: true, minify: isProd }],
[techs.borschik, { sourceTarget: '?.css', destTarget: '_?.css', tech: 'cleancss', freeze: true, minify: isProd }]
]);

nodeConfig.addTargets([/*'?.bemtree.js'*/, '?.html', '_?.css', '_?.js']);
});
};
1 change: 1 addition & 0 deletions .enb/tmp/cache.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.idea
/*.env
node_modules
public/
npm-debug.log
libs/

#bem
.bem/cache/
.enb/tmp/
#*bundles*/page/*
#!*bundles*/page/*.bemdecl.js
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: npm i && EXPRESS_BEM_MAKER=enb node app.js
Loading