assets-manager
Advanced tools
Comparing version 0.1.9 to 0.2.0
@@ -38,9 +38,11 @@ 'use strict'; | ||
_createClass(Finder, [{ | ||
key: 'classifyFiles', | ||
value: function classifyFiles(dir) { | ||
var types = arguments.length <= 1 || arguments[1] === undefined ? _types2.default : arguments[1]; | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
key: 'classifyFilesFromGlobs', | ||
value: function classifyFilesFromGlobs(dir, globs) { | ||
var types = arguments.length <= 2 || arguments[2] === undefined ? _types2.default : arguments[2]; | ||
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; | ||
var result = {}; | ||
var files = this.listFiles(dir, globs, options); | ||
var _iteratorNormalCompletion = true; | ||
@@ -54,10 +56,6 @@ var _didIteratorError = false; | ||
if (Array.isArray(dir)) { | ||
options = (0, _deepExtend2.default)({ | ||
matchBase: true | ||
}, options); | ||
result[type] = dir.filter(_minimatch2.default.filter(types[type], options)); | ||
} else { | ||
result[type] = this.filterFilesByType(dir, type, types, options); | ||
} | ||
options = (0, _deepExtend2.default)({ | ||
matchBase: true | ||
}, options); | ||
result[type] = files.filter(_minimatch2.default.filter(types[type], options)); | ||
} | ||
@@ -82,5 +80,83 @@ } catch (err) { | ||
}, { | ||
key: 'classifyFilesFromDir', | ||
value: function classifyFilesFromDir(dir) { | ||
var types = arguments.length <= 1 || arguments[1] === undefined ? _types2.default : arguments[1]; | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var result = {}; | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator2 = Object.keys(types)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var type = _step2.value; | ||
result[type] = this.filterFilesByType(dir, type, types, options); | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return) { | ||
_iterator2.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
}, { | ||
key: 'classifyFiles', | ||
value: function classifyFiles(files) { | ||
var types = arguments.length <= 1 || arguments[1] === undefined ? _types2.default : arguments[1]; | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var result = {}; | ||
if (!Array.isArray(files)) { | ||
files = [files]; | ||
} | ||
var _iteratorNormalCompletion3 = true; | ||
var _didIteratorError3 = false; | ||
var _iteratorError3 = undefined; | ||
try { | ||
for (var _iterator3 = Object.keys(types)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
var type = _step3.value; | ||
options = (0, _deepExtend2.default)({ | ||
matchBase: true | ||
}, options); | ||
result[type] = files.filter(_minimatch2.default.filter(types[type], options)); | ||
} | ||
} catch (err) { | ||
_didIteratorError3 = true; | ||
_iteratorError3 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion3 && _iterator3.return) { | ||
_iterator3.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError3) { | ||
throw _iteratorError3; | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
}, { | ||
key: 'listFiles', | ||
value: function listFiles(dir) { | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var glob = arguments.length <= 1 || arguments[1] === undefined ? '**/*' : arguments[1]; | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
@@ -92,3 +168,3 @@ options = (0, _deepExtend2.default)({ | ||
return this.filterFiles(dir, '**/*', options); | ||
return this.filterFiles(dir, glob, options); | ||
} | ||
@@ -95,0 +171,0 @@ }, { |
@@ -7,4 +7,2 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -59,3 +57,2 @@ | ||
flattenTypes: _configure2.default.get('flattenTypes', false), | ||
main: _configure2.default.get('main', false), | ||
override: _configure2.default.get('override', true), | ||
@@ -134,7 +131,10 @@ registry: _configure2.default.get('defaultRegistry', 'npm'), | ||
this.typedFiles = this.registry.getPackageTypedFiles(this.name, { | ||
main: this.options.main | ||
main: true | ||
}); | ||
} | ||
if ((typeof defination === 'undefined' ? 'undefined' : _typeof(defination)) === 'object') { | ||
} else if (typeof defination === 'string' || Array.isArray(defination)) { | ||
this.typedFiles = this.registry.getPackageTypedFiles(this.name, { | ||
main: false, | ||
globs: defination | ||
}); | ||
} else if ((0, _isPlainObject2.default)(defination)) { | ||
var types = {}; | ||
@@ -160,3 +160,3 @@ var packagePath = this.getPath(); | ||
types: types, | ||
main: this.options.main | ||
main: false | ||
}); | ||
@@ -163,0 +163,0 @@ } |
@@ -65,3 +65,3 @@ 'use strict'; | ||
return _finder2.default.listFiles(this.getPackagePath(packageName), options); | ||
return _finder2.default.listFiles(this.getPackagePath(packageName), '**/*', options); | ||
} | ||
@@ -75,2 +75,3 @@ }, { | ||
main: false, | ||
globs: null, | ||
types: _configure2.default.get('types') | ||
@@ -81,14 +82,24 @@ }, options); | ||
var types = options.types; | ||
var globs = options.globs; | ||
delete options.main; | ||
delete options.types; | ||
delete options.glob; | ||
var dir = void 0; | ||
if (main === false) { | ||
dir = this.getPackagePath(packageName); | ||
} else { | ||
dir = this.getPackageMainFiles(packageName); | ||
var dir = this.getPackagePath(packageName); | ||
if (main === true) { | ||
var files = this.getPackageMainFiles(packageName); | ||
return _finder2.default.classifyFiles(files, types, options); | ||
} | ||
return _finder2.default.classifyFiles(dir, types, options); | ||
if (globs) { | ||
if (!Array.isArray(globs)) { | ||
globs = [globs]; | ||
} | ||
return _finder2.default.classifyFilesFromGlobs(dir, globs, types, options); | ||
} | ||
return _finder2.default.classifyFilesFromDir(dir, types, options); | ||
} | ||
@@ -95,0 +106,0 @@ }, { |
{ | ||
"name": "assets-manager", | ||
"version": "0.1.9", | ||
"version": "0.2.0", | ||
"description": "Copy packages files based on manifest file", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/amazingSurge/assets-manager", |
@@ -166,17 +166,7 @@ # assets-manager [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][coveralls-image]][coveralls-url] | ||
"registry:package" | ||
"registry:package@version" | ||
"package" | ||
"package@version" | ||
``` | ||
The "package" and "package@version" shorter form will use the default registry. | ||
The "package" shorter form will use the default registry. | ||
The name of the dependency in the package can be any custom alias, that is then only locally scoped to that specific package. | ||
Typically semver-compatible versions should be used of the form ^x.y.z. Tilde ranges, ~x.y.z are also supported. Ranges without a patch or minor are also supported - x, x.y, ~x.y, ^x.y. | ||
More info about versions: | ||
https://docs.npmjs.com/getting-started/semantic-versioning | ||
https://github.com/npm/node-semver#ranges | ||
### Package definition | ||
@@ -190,3 +180,3 @@ You can write in the following ways define the package. | ||
It will use default types config and use default options. | ||
It will use main files and use default options. | ||
@@ -203,6 +193,31 @@ 2.use options only | ||
It will use default types config and custom options. | ||
It will use main files custom options. | ||
3.use types only | ||
3.use auto types only | ||
It will look for all files in the package folder, and classify the files automatically. The default options will be used in this mode. | ||
```js | ||
"PACKAGEKEY": "**/*" | ||
``` | ||
You can use glob array also. | ||
```js | ||
"PACKAGEKEY": ["dist/**/*.js", "!dist/**/*.min.js"] | ||
``` | ||
4.use auto types and options | ||
```js | ||
"PACKAGEKEY": ["**/*", { | ||
"registry": "bower" | ||
}] | ||
``` | ||
glob array supported too. | ||
```js | ||
"PACKAGEKEY": [["**/*", "!**/*.min.js"], { | ||
"registry": "bower" | ||
}] | ||
``` | ||
5.use types only | ||
```js | ||
"PACKAGEKEY": [{ | ||
@@ -216,3 +231,3 @@ "js": "dist/js", | ||
4.use types only alternatively | ||
6.use types only alternatively | ||
```js | ||
@@ -225,3 +240,3 @@ "PACKAGEKEY": { | ||
5.use types and options | ||
7.use types and options | ||
```js | ||
@@ -287,3 +302,2 @@ "PACKAGEKEY": [ | ||
registry: 'npm', | ||
main: false, | ||
replaces: {}, | ||
@@ -297,5 +311,2 @@ renames: {} | ||
#### main | ||
Set to true will use bower/npm's main files. | ||
#### replaces | ||
@@ -302,0 +313,0 @@ It will replace the content when copy to target directory. Regex supported. |
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
65689
1411
353