basisjs-tools-build
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -0,1 +1,7 @@ | ||
## 1.1.0 (November 23, 2015) | ||
- build: new option `--silent` to prevent any output to `stdout` | ||
- build: new value `none` for `--target` option (prevents file writing to FS) | ||
- build: don't minimize `id` names when `--css-optimize-names` is using, since unsafe as tools don't found every `id` usage case for now | ||
## 1.0.2 (November 22, 2015) | ||
@@ -2,0 +8,0 @@ |
@@ -6,3 +6,3 @@ var path = require('path'); | ||
var isChildProcess = typeof process.send == 'function'; // child process has send method | ||
var targets = ['fs', 'output-graph']; // first is default | ||
var targets = ['fs', 'output-graph', 'none']; // first is default | ||
@@ -124,2 +124,3 @@ function resolveCwd(value){ | ||
.option('--silent', 'No any output') | ||
.option('--verbose', 'Makes output more verbose') | ||
@@ -126,0 +127,0 @@ .option('--no-color', 'Suppress color output') |
@@ -144,71 +144,75 @@ var atTmpl = require('basisjs-tools-ast').tmpl; | ||
fconsole.start('Process `id` attributes'); | ||
fconsole.start('Process `id` attributes (skip)'); | ||
var idReplaceMap = {}; | ||
var idReplaceIdx = 0; | ||
var idRenameSaving = 0; | ||
var typeSaving = { | ||
html: 0, | ||
style: 0, | ||
tmpl: 0 | ||
}; | ||
// ID could affect many things, for example ID uses in url(), | ||
// in SVG attributes like fill or stroke. For now extract doesn't found | ||
// this ID usage. That's why don't change ID until all cases will be localed. | ||
function getIdReplace(name){ | ||
if (!hasOwnProperty.call(idReplaceMap, name)) | ||
idReplaceMap[name] = toBase52(idReplaceIdx++); | ||
return idReplaceMap[name]; | ||
} | ||
// var idReplaceMap = {}; | ||
// var idReplaceIdx = 0; | ||
// var idRenameSaving = 0; | ||
// var typeSaving = { | ||
// html: 0, | ||
// style: 0, | ||
// tmpl: 0 | ||
// }; | ||
for (var theme in themeIdMap) | ||
{ | ||
fconsole.start(theme); | ||
// function getIdReplace(name){ | ||
// if (!hasOwnProperty.call(idReplaceMap, name)) | ||
// idReplaceMap[name] = toBase52(idReplaceIdx++); | ||
// return idReplaceMap[name]; | ||
// } | ||
var idMap = themeIdMap[theme]; | ||
Object.keys(idMap).sort(function(a, b){ | ||
return (b.length - 1) * idMap[b].length - (a.length - 1) * idMap[a].length; | ||
}).forEach(function(name, idx){ | ||
var list = idMap[name]; | ||
var replace = getIdReplace(name); | ||
var oneSaving = name.length - replace.length; | ||
var saving = oneSaving * list.length; | ||
// for (var theme in themeIdMap) | ||
// { | ||
// fconsole.start(theme); | ||
idRenameSaving += saving; | ||
totalSaving += saving; | ||
fconsole.log(name, '->', replace, '(' + saving + ')'); | ||
// var idMap = themeIdMap[theme]; | ||
// Object.keys(idMap).sort(function(a, b){ | ||
// return (b.length - 1) * idMap[b].length - (a.length - 1) * idMap[a].length; | ||
// }).forEach(function(name, idx){ | ||
// var list = idMap[name]; | ||
// var replace = getIdReplace(name); | ||
// var oneSaving = name.length - replace.length; | ||
// var saving = oneSaving * list.length; | ||
for (var i = 0, item; item = list[i]; i++) | ||
{ | ||
var token = item.token; | ||
typeSaving[item.type.split('-')[0]] += oneSaving; | ||
switch (item.type){ | ||
case 'html-id': | ||
token.id = replace; | ||
break; | ||
case 'style-id': | ||
token[2] = replace; | ||
break; | ||
case 'tmpl-id': | ||
token.context.tokenValue(token, replace); | ||
break; | ||
default: | ||
flow.warn({ | ||
fatal: true, | ||
message: 'Unknown token type - ' + cfg.type | ||
}); | ||
} | ||
} | ||
}); | ||
// idRenameSaving += saving; | ||
// totalSaving += saving; | ||
// fconsole.log(name, '->', replace, '(' + saving + ')'); | ||
fconsole.endl(); | ||
} | ||
fconsole.endl(); | ||
// for (var i = 0, item; item = list[i]; i++) | ||
// { | ||
// var token = item.token; | ||
// typeSaving[item.type.split('-')[0]] += oneSaving; | ||
// switch (item.type){ | ||
// case 'html-id': | ||
// token.id = replace; | ||
// break; | ||
// case 'style-id': | ||
// token[2] = replace; | ||
// break; | ||
// case 'tmpl-id': | ||
// token.context.tokenValue(token, replace); | ||
// break; | ||
// default: | ||
// flow.warn({ | ||
// fatal: true, | ||
// message: 'Unknown token type - ' + cfg.type | ||
// }); | ||
// } | ||
// } | ||
// }); | ||
fconsole.start('Total id rename saving:', idRenameSaving + ' bytes'); | ||
fconsole.list(Object.keys(typeSaving).map(function(type){ | ||
return type + ': ' + typeSaving[type] + ' bytes'; | ||
})); | ||
fconsole.endl(); | ||
// fconsole.endl(); | ||
// } | ||
// fconsole.endl(); | ||
fconsole.start('Total rename saving:', idRenameSaving + ' bytes'); | ||
// fconsole.start('Total id rename saving:', idRenameSaving + ' bytes'); | ||
// fconsole.list(Object.keys(typeSaving).map(function(type){ | ||
// return type + ': ' + typeSaving[type] + ' bytes'; | ||
// })); | ||
// fconsole.endl(); | ||
// fconsole.start('Total rename saving:', idRenameSaving + ' bytes'); | ||
}).handlerName = '[css] Optimize names'; | ||
@@ -215,0 +219,0 @@ |
@@ -74,27 +74,30 @@ var fs = require('fs'); | ||
fconsole.enabled = options.verbose; | ||
fconsole.enabled = !options.silent && options.verbose; | ||
chalk.enabled = options.color && process.stdout.isTTY; | ||
if (options.verbose) | ||
if (!options.silent) | ||
{ | ||
// TODO: add more settings output | ||
fconsole.start('Build with ' + utils.getToolsId()); | ||
fconsole.log('Base path:', options.base); | ||
fconsole.log('Index file:', options.file); | ||
fconsole.log('Output path:', options.output); | ||
fconsole.endl(); | ||
if (options.verbose) | ||
{ | ||
// TODO: add more settings output | ||
fconsole.start('Build with ' + utils.getToolsId()); | ||
fconsole.log('Base path:', options.base); | ||
fconsole.log('Index file:', options.file); | ||
fconsole.log('Output path:', options.output); | ||
fconsole.endl(); | ||
} | ||
else | ||
{ | ||
process.stdout.write( | ||
'Build with ' + chalk.yellow(utils.getToolsId()) + '\n' + | ||
'Base path: ' + | ||
chalk.green(normalizePath(options.base)) + '\n' + | ||
'Index file: ' + | ||
chalk.green(normalizePath(options.file).replace(new RegExp('^' + normalizePath(options.base)), chalk.gray('$&'))) + '\n' + | ||
'Output path: ' + | ||
chalk.green(normalizePath(options.output).replace(new RegExp('^' + normalizePath(options.base)), chalk.gray('$&'))) + '\n' + | ||
'\n' | ||
); | ||
} | ||
} | ||
else | ||
{ | ||
process.stdout.write( | ||
'Build with ' + chalk.yellow(utils.getToolsId()) + '\n' + | ||
'Base path: ' + | ||
chalk.green(normalizePath(options.base)) + '\n' + | ||
'Index file: ' + | ||
chalk.green(normalizePath(options.file).replace(new RegExp('^' + normalizePath(options.base)), chalk.gray('$&'))) + '\n' + | ||
'Output path: ' + | ||
chalk.green(normalizePath(options.output).replace(new RegExp('^' + normalizePath(options.base)), chalk.gray('$&'))) + '\n' + | ||
'\n' | ||
); | ||
} | ||
@@ -262,3 +265,3 @@ | ||
if (!options.verbose && handlers.length) | ||
if (!options.silent && !options.verbose && handlers.length) | ||
{ | ||
@@ -310,24 +313,27 @@ var extraInfo = time.extraInfo ? time.extraInfo(flow) : ''; | ||
if (options.verbose) | ||
if (!options.silent) | ||
{ | ||
fconsole.resetDeep(); | ||
fconsole.start('\n' + title + '\n' + (repeat('=', title.length)) + '\n'); | ||
if (options.verbose) | ||
{ | ||
fconsole.resetDeep(); | ||
fconsole.start('\n' + title + '\n' + (repeat('=', title.length)) + '\n'); | ||
if (skipped) | ||
{ | ||
fconsole.log('Skipped.'); | ||
fconsole.log(skipped); | ||
if (skipped) | ||
{ | ||
fconsole.log('Skipped.'); | ||
fconsole.log(skipped); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
// show short stat for handler except last one | ||
if (!lastHandler && !skipped) | ||
else | ||
{ | ||
fconsole.resetDeep(); | ||
stdoutHandlerTitle = title.replace(/^(?:\[(\S+)\] ?|)/, function(m, topic){ | ||
return ' '.substr((topic || '').length) + chalk.cyan(topic || '') + ' '; | ||
}); | ||
process.stdout.write(stdoutHandlerTitle + '\n'); | ||
stdoutPos = process.stdout._bytesDispatched; | ||
// show short stat for handler except last one | ||
if (!lastHandler && !skipped) | ||
{ | ||
fconsole.resetDeep(); | ||
stdoutHandlerTitle = title.replace(/^(?:\[(\S+)\] ?|)/, function(m, topic){ | ||
return ' '.substr((topic || '').length) + chalk.cyan(topic || '') + ' '; | ||
}); | ||
process.stdout.write(stdoutHandlerTitle + '\n'); | ||
stdoutPos = process.stdout._bytesDispatched; | ||
} | ||
} | ||
@@ -334,0 +340,0 @@ } |
@@ -12,2 +12,6 @@ var chalk = require('chalk'); | ||
// no any output | ||
if (options.silent) | ||
return; | ||
if (!options.verbose) | ||
@@ -14,0 +18,0 @@ { |
@@ -50,1 +50,6 @@ var fs = require('fs'); | ||
} | ||
module.exports.skip = function(flow){ | ||
if (flow.options.target === 'none') | ||
return 'Use option --css-optimize-names'; | ||
}; |
{ | ||
"name": "basisjs-tools-build", | ||
"title": "Basis.js developer build tools", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"homepage": "https://github.com/basisjs/basisjs-tools", | ||
@@ -6,0 +6,0 @@ "description": "Developer build tools for basis.js framework", |
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
282540
8748