| ### 0.0.2 / 28.09.2012 | ||
| * add --disable and --enable command line options | ||
| * add an empty values rejecting to coa.js | ||
| * update README | ||
| ### 0.0.1 / 27.09.2012 | ||
| * initial public version |
+21
-2
| var Q = require('q'), | ||
| info = JSON.parse(require('fs').readFileSync(__dirname + '/../package.json')); | ||
| module.exports = require('coa').Cmd() | ||
| var coa = module.exports = require('coa').Cmd() | ||
| .helpful() | ||
@@ -20,4 +20,23 @@ .name(info.name) | ||
| .short('c').long('config') | ||
| .val(function(val) { | ||
| return val || coa.reject('Option --config must have a value.'); | ||
| }) | ||
| .end() | ||
| .opt() | ||
| .name('disable').title('Disable plugin') | ||
| .short('d').long('disable') | ||
| .arr() | ||
| .val(function(val) { | ||
| return val || coa.reject('Option --disable must have a value.'); | ||
| }) | ||
| .end() | ||
| .opt() | ||
| .name('enable').title('Enable plugin') | ||
| .short('e').long('enable') | ||
| .arr() | ||
| .val(function(val) { | ||
| return val || coa.reject('Option --enable must have a value.'); | ||
| }) | ||
| .end() | ||
| .opt() | ||
| .name('input').title('Input file (default: stdin)') | ||
@@ -49,3 +68,3 @@ .short('i').long('input') | ||
| .then(function(svg) { | ||
| return SVGO(svg, options); | ||
| return SVGO(svg, { coa: options }); | ||
| }) | ||
@@ -52,0 +71,0 @@ .then(function(svgmin) { |
+61
-20
@@ -9,36 +9,59 @@ var QFS = require('q-fs'), | ||
| if (!options || !options.config) return readConfig(defaultConfigPath); | ||
| // if there are no any options then return default config | ||
| if (!options) return readConfig(defaultConfigPath); | ||
| return readConfig(defaultConfigPath) | ||
| .then(function(defaultConfig) { | ||
| // COA options | ||
| if (options.coa) { | ||
| if (typeof options.config === 'string') { | ||
| options = options.coa; | ||
| var localConfigPath = PATH.resolve(process.cwd, options.config); | ||
| return readConfig(defaultConfigPath) | ||
| .then(function(defaultConfig) { | ||
| return QFS.exists(localConfigPath) | ||
| .then(function(exists) { | ||
| // --disable | ||
| if (options.disable) return pluginsFromCOA(defaultConfig, options.disable, false); | ||
| if (!exists) return defaultConfig; | ||
| // --enable | ||
| if (options.enable) return pluginsFromCOA(defaultConfig, options.enable, true); | ||
| return readConfig(localConfigPath) | ||
| .then(function(localConfig) { | ||
| return extend(true, defaultConfig, localConfig); | ||
| }); | ||
| // --config | ||
| if (options.config) { | ||
| }); | ||
| var localConfigPath = PATH.resolve(process.cwd, options.config); | ||
| } else if (Object.prototype.toString.call(options.config) === '[object Object]') { | ||
| // check for the local config file | ||
| return QFS.exists(localConfigPath) | ||
| .then(function(exist) { | ||
| return extend(true, defaultConfig, options.config); | ||
| // if it doesn't exists then return default | ||
| if (!exist) return defaultConfig; | ||
| } else { | ||
| // console.log(exists); | ||
| // TODO: ... | ||
| throw new Error('...'); | ||
| // if it exists then return extended default | ||
| return readConfig(localConfigPath) | ||
| .then(function(localConfig) { | ||
| return extend(true, defaultConfig, localConfig); | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
| return defaultConfig; | ||
| }); | ||
| // inline {} options | ||
| } else { | ||
| // return extended default | ||
| return readConfig(defaultConfigPath) | ||
| .then(function(defaultConfig) { | ||
| return extend(true, defaultConfig, options); | ||
| }); | ||
| } | ||
| }; | ||
@@ -54,1 +77,19 @@ | ||
| }; | ||
| function pluginsFromCOA(defaultConfig, names, active) { | ||
| var plugins = defaultConfig.plugins; | ||
| for (var type in plugins) { | ||
| plugins[type].forEach(function(plugin) { | ||
| names.forEach(function(name) { | ||
| if (plugin.name === name) { | ||
| plugin.active = active; | ||
| } | ||
| }); | ||
| }); | ||
| }; | ||
| return defaultConfig; | ||
| }; |
+0
-2
@@ -80,4 +80,2 @@ /** | ||
| exports.inspect = require('eyes').inspector({ maxLength: 99999 }); | ||
| exports.flatten = function(array) { | ||
@@ -84,0 +82,0 @@ var result = [], |
+18
-10
| { | ||
| "name": "svgo", | ||
| "version": "0.0.1", | ||
| "description": "SVG Optimizer", | ||
| "version": "0.0.2", | ||
| "description": "Nodejs-based tool for optimizing SVG vector graphics files", | ||
| "keywords": ["svgo", "svg", "optimize", "minify"], | ||
| "homepage": " ", | ||
| "homepage": "http://deepsweet.github.com/svgo", | ||
| "bugs": { | ||
@@ -13,2 +13,3 @@ "url": "https://github.com/deepsweet/svgo/issues", | ||
| "contributors": [ | ||
| "Sergey Belov <peimei@ya.ru> (http://github.com/arikon)" | ||
| ], | ||
@@ -32,14 +33,21 @@ "repository": { | ||
| "dependencies": { | ||
| "inherit": "*", | ||
| "q": "0.8", | ||
| "sax": "0.4.x", | ||
| "q": "0.8.x", | ||
| "q-fs": "", | ||
| "coa": "0.3.x", | ||
| "sax": "0.4.x", | ||
| "inherit": "" | ||
| }, | ||
| "devDependencies": { | ||
| "mocha": "1.4.x", | ||
| "should": "", | ||
| "eyes": "" | ||
| "should": "" | ||
| }, | ||
| "engines": { | ||
| "node": ">=0.4.0" | ||
| } | ||
| "node": ">=0.6.0" | ||
| }, | ||
| "licenses": [ | ||
| { | ||
| "type": "MIT", | ||
| "url": "https://raw.github.com/deepsweet/svgo/master/LICENSE" | ||
| } | ||
| ] | ||
| } |
+21
-16
@@ -23,17 +23,17 @@ ``` | ||
| * [ [>](svgo/tree/master/plugins/cleanupAttrs.js) ] cleanup attributes from newlines, trailing and repeating spaces | ||
| * [ [>](svgo/tree/master/plugins/removeDoctype.js) ] remove doctype declaration | ||
| * [ [>](svgo/tree/master/plugins/removeXMLProcInst.js) ] remove XML processing instructions | ||
| * [ [>](svgo/tree/master/plugins/removeComments.js) ] remove comments | ||
| * [ [>](svgo/tree/master/plugins/removeMetadata.js) ] remove metadata | ||
| * [ [>](svgo/tree/master/plugins/removeEditorsNSData.js) ] remove editors namespaces, elements and attributes | ||
| * [ [>](svgo/tree/master/plugins/removeEmptyAttrs.js) ] remove empty attributes | ||
| * [ [>](svgo/tree/master/plugins/removeDefaultPx.js) ] remove default "px" unit | ||
| * [ [>](svgo/tree/master/plugins/removeHiddenElems.js) ] remove a lot of hidden elements | ||
| * [ [>](svgo/tree/master/plugins/removeEmptyText.js) ] remove empty Text elements | ||
| * [ [>](svgo/tree/master/plugins/removeEmptyContainers.js) ] remove empty Container elements | ||
| * [ [>](svgo/tree/master/plugins/convertStyleToAttrs.js) ] convert styles into attributes | ||
| * [ [>](svgo/tree/master/plugins/convertColors.js) ] convert colors | ||
| * [ [>](svgo/tree/master/plugins/moveElemsAttrsToGroup.js) ] move elements attributes to the existing group wrapper | ||
| * [ [>](svgo/tree/master/plugins/collapseGroups.js) ] collapse groups | ||
| * [ [>](//github.com/deepsweet/svgo/blob/master/plugins/cleanupAttrs.js) ] cleanup attributes from newlines, trailing and repeating spaces | ||
| * [ [>](//github.com/deepsweet/svgo/blob/master/plugins/removeDoctype.js) ] remove doctype declaration | ||
| * [ [>](//github.com/deepsweet/svgo/blob/master/plugins/removeXMLProcInst.js) ] remove XML processing instructions | ||
| * [ [>](//github.com/deepsweet/svgo/blob/master/plugins/removeComments.js) ] remove comments | ||
| * [ [>](//github.com/deepsweet/svgo/blob/master/plugins/removeMetadata.js) ] remove metadata | ||
| * [ [>](//github.com/deepsweet/svgo/blob/master/plugins/removeEditorsNSData.js) ] remove editors namespaces, elements and attributes | ||
| * [ [>](//github.com/deepsweet/svgo/blob/master/plugins/removeEmptyAttrs.js) ] remove empty attributes | ||
| * [ [>](//github.com/deepsweet/svgo/blob/master/plugins/removeDefaultPx.js) ] remove default "px" unit | ||
| * [ [>](//github.com/deepsweet/svgo/blob/master/plugins/removeHiddenElems.js) ] remove a lot of hidden elements | ||
| * [ [>](//github.com/deepsweet/svgo/blob/master/plugins/removeEmptyText.js) ] remove empty Text elements | ||
| * [ [>](//github.com/deepsweet/svgo/blob/master/plugins/removeEmptyContainers.js) ] remove empty Container elements | ||
| * [ [>](//github.com/deepsweet/svgo/blob/master/plugins/convertStyleToAttrs.js) ] convert styles into attributes | ||
| * [ [>](//github.com/deepsweet/svgo/blob/master/plugins/convertColors.js) ] convert colors | ||
| * [ [>](//github.com/deepsweet/svgo/blob/master/plugins/moveElemsAttrsToGroup.js) ] move elements attributes to the existing group wrapper | ||
| * [ [>](//github.com/deepsweet/svgo/blob/master/plugins/collapseGroups.js) ] collapse groups | ||
@@ -60,2 +60,4 @@ But it's not only about rude removing, SVG has a strict [specification](http://www.w3.org/TR/SVG/expanded-toc.html) with a lot of opportunities for optimizations, default values, geometry hacking and more. | ||
| -c CONFIG, --config=CONFIG : Local config | ||
| -d DISABLE, --disable=DISABLE : Disable plugin | ||
| -e ENABLE, --enable=ENABLE : Enable plugin | ||
| -i INPUT, --input=INPUT : Input file (default: stdin) | ||
@@ -66,4 +68,7 @@ -o OUTPUT, --output=OUTPUT : Output file (default: stdout) | ||
| ``` | ||
| svgo -i myTestFile.svg -o myTestFile.min.svg | ||
| svgo -i test.svg -o test.min.svg | ||
| ``` | ||
| ``` | ||
| cat test.svg | svgo -d removeDoctype -d removeComment > test.min.svg | ||
| ``` | ||
@@ -70,0 +75,0 @@ ## TODO |
+10
-8
@@ -49,9 +49,7 @@ var should = require('should'), | ||
| var myConfig = { | ||
| config: { | ||
| plugins: { | ||
| directPass: [ | ||
| { name: 'removeDoctype', active: false }, | ||
| { name: 'myTestPlugin', active: true } | ||
| ] | ||
| } | ||
| plugins: { | ||
| directPass: [ | ||
| { name: 'removeDoctype', active: false }, | ||
| { name: 'myTestPlugin', active: true } | ||
| ] | ||
| } | ||
@@ -87,3 +85,5 @@ }, | ||
| var myConfig = { | ||
| config: './test/config.cfg' | ||
| coa: { | ||
| config: './test/config.cfg' | ||
| } | ||
| }, | ||
@@ -93,2 +93,4 @@ result; | ||
| before(function(done) { | ||
| // console.log(config(myConfig)); | ||
| config(myConfig).then(function(data) { | ||
@@ -95,0 +97,0 @@ result = data; |
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
82347
3.31%5
-37.5%36
2.86%2267
2.21%2
-50%79
6.76%2
Infinity%2
100%- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated