Comparing version 0.4.2 to 1.0.0
@@ -1,7 +0,17 @@ | ||
## 0.4.2 (November 30, 2013) | ||
## 1.0.0 | ||
- [SemVer](http://semver.org/) support | ||
- [Add wildcard support for freeze_path](https://github.com/bem/borschik/issues/23). This feature break compatibility: | ||
- path to freeze relative to config now (like `paths` or `follow_symlinks`) | ||
- path must be valid wildcard (paths like `./i/` must be replaced with `./i/**`) | ||
- Add support for [freeze nesting path](https://github.com/bem/borschik/pull/55). This options improve server performance for projects with a lot of freeze files. | ||
- Add support for [custom tech options](https://github.com/bem/borschik/pull/56). | ||
- New `borschik.include()` [syntax for JS tech](https://github.com/bem/borschik/pull/48). | ||
## 0.4.2 | ||
- borschik can inline .jpg files now. | ||
- Update dependencies: csso@1.3.10, uglify-js@2.4.6, vow@0.3.12 | ||
## 0.4.1 (November 25, 2013) | ||
## 0.4.1 | ||
@@ -11,3 +21,3 @@ - borschik can inline .ttf files now. | ||
## 0.4.0 (October 2, 2013) | ||
## 0.4.0 | ||
This version is partially incompatible with 0.3.x | ||
@@ -25,6 +35,6 @@ | ||
## 0.3.5 (July 30, 2013) | ||
## 0.3.5 | ||
- Fix regression after https://github.com/bem/borschik/issues/7 | ||
## 0.3.4 (July 29, 2013) | ||
## 0.3.4 | ||
[Milestone 0.3.4](https://github.com/bem/borschik/issues?milestone=3&state=closed) | ||
@@ -36,3 +46,3 @@ | ||
## 0.3.3 (July 18, 2013) | ||
## 0.3.3 | ||
Update dependencies versions | ||
@@ -48,3 +58,3 @@ | ||
## 0.3.2 (July 06, 2013) | ||
## 0.3.2 | ||
- UglifyJS updated to ~2.3 | ||
@@ -51,0 +61,0 @@ - CSSO updated to 1.3.7 |
var PATH = require('path'), | ||
FS = require('./fs'), | ||
FS = require('fs'), | ||
U = require('./util'); | ||
@@ -21,2 +21,11 @@ | ||
.opt() | ||
// Give ability for external technologies to has its own options without conflicts with borschik | ||
.name('techOptions') .title('Additional options for tech in JSON format') | ||
.short('to').long('tech-options') | ||
.def("{}") | ||
.val(function(v) { | ||
return JSON.parse(v); | ||
}) | ||
.end() | ||
.opt() | ||
.name('input').title('Input path') | ||
@@ -23,0 +32,0 @@ .short('i').long('input') |
var CRYPTO = require('crypto'), | ||
FS = require('./fs'), | ||
FS = require('fs'), | ||
PATH = require('path'), | ||
@@ -7,2 +7,4 @@ configs, | ||
var minimatch = require('minimatch'); | ||
if (!PATH.sep) PATH.sep = process.platform === 'win32'? '\\' : '/'; | ||
@@ -37,3 +39,4 @@ | ||
paths: {}, | ||
freezePaths: {}, | ||
freezeNestingLevel: {}, | ||
freezeWildcards: {}, | ||
followSymlinks: {} | ||
@@ -128,4 +131,8 @@ }; | ||
var hash = fixBase64(sha1Base64(content)); | ||
filePath = PATH.join(_freezeDir, hash + PATH.extname(filePath)); | ||
var nestingLevel = configFreezeNestingLevel(_freezeDir); | ||
var nestingPath = getFreezeNestingPath(hash, nestingLevel); | ||
filePath = PATH.join(_freezeDir, nestingPath + PATH.extname(filePath)); | ||
if (content && !FS.existsSync(filePath)) { | ||
@@ -149,20 +156,45 @@ save(filePath, content); | ||
if (filePath !== realpathSync(filePath)) throw new Error(); | ||
if (filePath !== realpathSync(filePath)) { | ||
throw new Error(); | ||
} | ||
var suffix = filePath, | ||
prefix = '', | ||
freezeDir, | ||
rePrefix = new RegExp('^(' + rePathSep + '*[^' + rePathSep +']+)', 'g'), | ||
matched; | ||
loadConfig(filePath); | ||
while (matched = filePath.match(rePrefix)) { | ||
prefix += matched[0]; | ||
freezeDir = freezePath(prefix) || freezeDir; | ||
filePath = filePath.replace(rePrefix, ''); | ||
for (var wildcard in config.freezeWildcards) { | ||
if (minimatch(filePath, wildcard)) { | ||
return config.freezeWildcards[wildcard]; | ||
} | ||
} | ||
return freezeDir; | ||
return null; | ||
}; | ||
/** | ||
* Returns nesting path. | ||
* @example | ||
* getFreezeNestingPath('abc', 1) -> a/bc | ||
* getFreezeNestingPath('abc', 2) -> a/b/c | ||
* getFreezeNestingPath('abc', 5) -> a/b/c | ||
* | ||
* @param {String} hash Freezed filename. | ||
* @param {Number} nestingLevel | ||
* @returns {String} | ||
*/ | ||
var getFreezeNestingPath = function(hash, nestingLevel) { | ||
// reduce nestingLevel to hash size | ||
nestingLevel = Math.min(hash.length - 1, nestingLevel); | ||
if (nestingLevel === 0) { | ||
return hash; | ||
} | ||
var hashArr = hash.split(''); | ||
for (var i = 0; i < nestingLevel; i++) { | ||
hashArr.splice(i * 2 + 1, 0, '/'); | ||
} | ||
return hashArr.join(''); | ||
}; | ||
/** | ||
* Recursivly freeze all files in path. | ||
@@ -241,10 +273,8 @@ * @param {String} input File or directory path | ||
/** | ||
* Get path from "freeze path" config by path if any. | ||
* | ||
* Returns freeze nesting level for given path. | ||
* @param {String} path Path to search config for. | ||
* @returns {String} Path. | ||
* @returns {Number} | ||
*/ | ||
var freezePath = exports.freezePath = function(path) { | ||
loadConfig(path); | ||
return config.freezePaths[path]; | ||
var configFreezeNestingLevel = function(path) { | ||
return config.freezeNestingLevel[path] || 0; | ||
}; | ||
@@ -295,14 +325,24 @@ | ||
var freezePaths = _config.freeze_paths || _config.hashsum_paths || {}; | ||
for (var dir in freezePaths) { | ||
var realpath = realpathSync(PATH.resolve(path, dir)); | ||
if (!config.freezePaths[realpath]) { | ||
var value = freezePaths[dir]; | ||
var freezePaths = _config.freeze_paths || {}; | ||
for (var freezeConfigWildcard in freezePaths) { | ||
var freezeRealPath = realpathSync(PATH.resolve(path, freezeConfigWildcard)); | ||
if (!config.freezeWildcards[realpath]) { | ||
var freezeToPath = freezePaths[freezeConfigWildcard]; | ||
// :base64: and :encodeURIComponent: are special syntax for images inlining | ||
if (value !== ':base64:' && value !== ':encodeURIComponent:') { | ||
value = realpathSync(PATH.resolve(PATH.resolve(path, dir), value)); | ||
if (value) value = value.replace(/\*/g, PATH.sep); | ||
if (freezeToPath !== ':base64:' && freezeToPath !== ':encodeURIComponent:') { | ||
freezeToPath = realpathSync(PATH.resolve(path, freezeToPath)); | ||
// freeze nesting level | ||
// 0: all files freeze to given dir | ||
// 1: all files freeze to | ||
// freeze-dir/a/bcde.png | ||
// freeze-dir/b/acde.png | ||
// freeze-dir/c/abde.png | ||
var _freezeNestingLevel = Math.max(parseInt(_config['freeze_nesting_level'], 10) || 0, 0); | ||
if (!config.freezeNestingLevel[freezeToPath]) { | ||
config.freezeNestingLevel[freezeToPath] = _freezeNestingLevel; | ||
} | ||
} | ||
config.freezePaths[realpath] = value; | ||
config.freezeWildcards[freezeRealPath] = freezeToPath; | ||
} | ||
@@ -520,1 +560,3 @@ } | ||
} | ||
exports.getFreezeNestingPath = getFreezeNestingPath; |
@@ -1,2 +0,2 @@ | ||
var FS = require('./fs'), | ||
var FS = require('fs'), | ||
PATH = require('path'), | ||
@@ -3,0 +3,0 @@ FREEZE = require('./freeze'), |
@@ -17,3 +17,3 @@ /** | ||
*/ | ||
const allIncRe = /<!-->|<!--[^\[<][\s\S]*?-->|href="(.+?)"|src="(.+?)"/g; | ||
const allIncRe = /<!-->|<!--[^\[<][\s\S]*?-->|href="(.+?)"|src="(.+?)"|background="(.+?)"/g; | ||
@@ -37,3 +37,3 @@ exports.Tech = CSSBASE.Tech.inherit({ | ||
var texts = text | ||
.replace(allIncRe, function(_, includeHref, includeSrc) { | ||
.replace(allIncRe, function(_, includeHref, includeSrc, includeBackground) { | ||
if (includeHref && U.isLinkProcessable(includeHref) && _this.isFreezableUrl(includeHref)) { | ||
@@ -51,2 +51,8 @@ includes.push({ | ||
} else if (includeBackground && U.isLinkProcessable(includeBackground) && _this.isFreezableUrl(includeBackground)) { | ||
includes.push({ | ||
url: _this.pathTo(includeBackground), | ||
type: 'background' | ||
}); | ||
} else { | ||
@@ -85,3 +91,3 @@ includes.push({ | ||
if (item.type == 'href' || item.type == 'src') { | ||
if (item.type == 'href' || item.type == 'src' || item.type == 'background') { | ||
// freeze images with cssBase.processLink | ||
@@ -88,0 +94,0 @@ parsed[i] = item.type + '=' + this.child(item.type, item.url).process(baseFile); |
var base = require('./css-base'), | ||
FS = require('../fs'), | ||
FS = require('fs'), | ||
PATH = require('path'); | ||
@@ -42,3 +42,6 @@ | ||
// RegExp to find borschik.link("path/to/image.png") | ||
'borschik\\.link\\([\'"]([^@][^"\']+?)[\'"]\\)', | ||
'borschik\\.link\\([\'"]([^@][^"\']+?)[\'"]\\)' | ||
+ '|' + | ||
// RegExp to find borschik.include("path/to/file.js") | ||
'borschik\\.include\\([\'"]([^@][^"\']+?)[\'"]\\)', | ||
'g'), | ||
@@ -52,4 +55,4 @@ | ||
// finds /*borschik:include:*/ and "borschik:include:" | ||
.replace(allIncRe, function(_, incObjectFile, incArrayFile, incCommFile, incStrFile, borschikLink) { | ||
var incFile = incObjectFile || incArrayFile || incCommFile || incStrFile; | ||
.replace(allIncRe, function(_, incObjectFile, incArrayFile, incCommFile, incStrFile, borschikLink, borschikInc) { | ||
var incFile = incObjectFile || incArrayFile || incCommFile || incStrFile || borschikInc; | ||
if (incFile) { | ||
@@ -56,0 +59,0 @@ includes.push({ |
{ | ||
"name": "borschik", | ||
"description": "Extendable builder for text-based file formats", | ||
"version": "0.4.2", | ||
"version": "1.0.0", | ||
"homepage": "http://github.com/bem/borschik", | ||
@@ -18,14 +18,14 @@ "author": "Sergey Berezhnoy <veged@ya.ru> (http://github.com/veged)", | ||
"dependencies": { | ||
"minimatch": "0.2.14", | ||
"coa": "0.4.0", | ||
"inherit": "2.1.0", | ||
"inherit": "2.2.1", | ||
"vow": "0.3.12", | ||
"vow-fs": "0.2.3", | ||
"csso": "1.3.10", | ||
"uglify-js": "2.4.6" | ||
"csso": "1.3.11", | ||
"uglify-js": "2.4.13" | ||
}, | ||
"devDependencies": { | ||
"istanbul": "~0.1.42", | ||
"mocha-as-promised": "*", | ||
"mocha-istanbul": "*", | ||
"mocha": "~1.12.0" | ||
"istanbul": "0.2.x", | ||
"mocha-istanbul": "0.2.x", | ||
"mocha": "1.18.x" | ||
}, | ||
@@ -37,5 +37,5 @@ "scripts": { | ||
"engines": [ | ||
"node >= 0.6.0" | ||
"node >= 0.8.0" | ||
], | ||
"license": "MIT" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
49455
3
1209
0
7
17
11
+ Addedminimatch@0.2.14
+ Addedcsso@1.3.11(transitive)
+ Addedinherit@2.2.1(transitive)
+ Addedlru-cache@2.7.3(transitive)
+ Addedminimatch@0.2.14(transitive)
+ Addedsigmund@1.0.1(transitive)
+ Addeduglify-js@2.4.13(transitive)
- Removedcsso@1.3.10(transitive)
- Removedinherit@2.1.0(transitive)
- Removeduglify-js@2.4.6(transitive)
Updatedcsso@1.3.11
Updatedinherit@2.2.1
Updateduglify-js@2.4.13