assets-manager
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -7,3 +7,3 @@ '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 _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
@@ -10,0 +10,0 @@ 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; }; }(); |
@@ -45,3 +45,3 @@ 'use strict'; | ||
value: function locate(filepath) { | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -103,3 +103,3 @@ if (_path2.default.isAbsolute(filepath)) { | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -106,0 +106,0 @@ options = Object.assign({ |
@@ -40,4 +40,4 @@ 'use strict'; | ||
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 types = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _types2.default; | ||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
@@ -81,4 +81,4 @@ var result = {}; | ||
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 types = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _types2.default; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
@@ -117,4 +117,4 @@ var result = {}; | ||
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 types = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _types2.default; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
@@ -160,4 +160,4 @@ var result = {}; | ||
value: function listFiles(dir) { | ||
var glob = arguments.length <= 1 || arguments[1] === undefined ? '**/*' : arguments[1]; | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var glob = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '**/*'; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
@@ -174,3 +174,3 @@ options = (0, _deepExtend2.default)({ | ||
value: function filterFiles(dir, filter) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
@@ -187,4 +187,4 @@ options = Object.assign({ | ||
value: function filterFilesByType(dir, type) { | ||
var types = arguments.length <= 2 || arguments[2] === undefined ? _types2.default : arguments[2]; | ||
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; | ||
var types = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _types2.default; | ||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
@@ -191,0 +191,0 @@ options = (0, _deepExtend2.default)({ |
@@ -53,2 +53,6 @@ 'use strict'; | ||
var _es6Template = require('es6-template'); | ||
var _es6Template2 = _interopRequireDefault(_es6Template); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -64,20 +68,20 @@ | ||
var Manifest = function () { | ||
function Manifest(path) { | ||
var override = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
function Manifest(filepath) { | ||
var override = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
_classCallCheck(this, Manifest); | ||
if ((0, _isPlainObject2.default)(path)) { | ||
this.path = '.'; | ||
this.data = path; | ||
if ((0, _isPlainObject2.default)(filepath)) { | ||
this.filepath = '.'; | ||
this.data = filepath; | ||
} else { | ||
if (typeof path === 'undefined') { | ||
this.path = './manifest.json'; | ||
if (typeof filepath === 'undefined') { | ||
this.filepath = './manifest.json'; | ||
} else { | ||
this.path = path; | ||
this.filepath = filepath; | ||
} | ||
(0, _assert2.default)(_file2.default.exists(this.path), 'Manifest file is not exists'); | ||
(0, _assert2.default)(_file2.default.exists(this.filepath), 'Manifest file is not exists'); | ||
this.data = _file2.default.readJSON(this.path); | ||
this.data = _file2.default.readJSON(this.filepath); | ||
} | ||
@@ -91,2 +95,3 @@ | ||
this.prepareDests(); | ||
this.preparePaths(); | ||
} | ||
@@ -154,4 +159,2 @@ | ||
value: function getPackageFileMapping(name) { | ||
var _this = this; | ||
var pkg = this.getPackage(name); | ||
@@ -167,2 +170,3 @@ if (pkg === null) { | ||
var dests = Object.assign(this.dests, pkg.getDests()); | ||
var paths = Object.assign(this.paths, pkg.getPaths()); | ||
var typedFiles = pkg.getTypedFiles(); | ||
@@ -177,26 +181,32 @@ var files = []; | ||
typedFiles[type].forEach(function (filepath) { | ||
// ${dest}/${type}/${package}/${file} | ||
var vars = { | ||
dest: pkg.options.dest, | ||
package: '', | ||
type: '', | ||
file: _path2.default.basename(filepath) | ||
}; | ||
var dest = void 0; | ||
var basename = _path2.default.basename(filepath); | ||
if (!pkg.options.flatten) { | ||
basename = _file2.default.getRelativeFromGlobs(filepath, pkg.getGlobByType(type)); | ||
vars.file = _file2.default.getRelativeFromGlobs(filepath, pkg.getGlobByType(type)); | ||
} | ||
if (renameRules) { | ||
basename = (0, _rename2.default)(basename, renameRules); | ||
vars.file = (0, _rename2.default)(vars.file, renameRules); | ||
} | ||
/*eslint no-lonely-if: "off"*/ | ||
if (pkg.options.flattenPackages) { | ||
if (pkg.options.flattenTypes) { | ||
dest = _path2.default.join(_this.dest, basename); | ||
} else { | ||
dest = _path2.default.join(dests[type], basename); | ||
} | ||
if (!pkg.options.flattenPackages) { | ||
vars.package = pkg.name; | ||
} | ||
if (!pkg.options.flattenTypes) { | ||
vars.type = dests[type]; | ||
} | ||
if (type in paths) { | ||
dest = (0, _es6Template2.default)(paths[type], vars); | ||
} else { | ||
if (pkg.options.flattenTypes) { | ||
dest = _path2.default.join(_this.dest, pkg.name, basename); | ||
} else { | ||
dest = _path2.default.join(dests[type], pkg.name, basename); | ||
} | ||
dest = (0, _es6Template2.default)(pkg.options.path, vars); | ||
} | ||
@@ -228,3 +238,3 @@ | ||
value: function copyPackages() { | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -244,5 +254,5 @@ options = Object.assign({ | ||
value: function copyPackage(name) { | ||
var _this2 = this; | ||
var _this = this; | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -263,3 +273,3 @@ options = Object.assign({ | ||
if (!_this2.hasPackage(name)) { | ||
if (!_this.hasPackage(name)) { | ||
if (options.ignoreError) { | ||
@@ -272,3 +282,3 @@ log(_chalk2.default.red('Error: Package ' + name + ' is not exists.')); | ||
var pkg = _this2.getPackage(name); | ||
var pkg = _this.getPackage(name); | ||
@@ -285,3 +295,3 @@ if (!pkg.isInstalled()) { | ||
try { | ||
files = _this2.getPackageFileMapping(name); | ||
files = _this.getPackageFileMapping(name); | ||
} catch (error) { | ||
@@ -293,3 +303,3 @@ reject(error); | ||
cwd: _configure2.default.get('cwd'), | ||
replaces: Object.assign(_this2.getConfigure('replaces'), pkg.options.replaces) | ||
replaces: Object.assign(_this.getConfigure('replaces'), pkg.options.replaces) | ||
}, options)).then(resolve).catch(reject); | ||
@@ -301,3 +311,3 @@ }); | ||
value: function cleanPackages() { | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -317,5 +327,5 @@ options = Object.assign({ | ||
value: function cleanPackage(name) { | ||
var _this3 = this; | ||
var _this2 = this; | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -335,3 +345,3 @@ options = Object.assign({ | ||
if (!_this3.hasPackage(name)) { | ||
if (!_this2.hasPackage(name)) { | ||
if (options.ignoreError) { | ||
@@ -344,3 +354,3 @@ log(_chalk2.default.red('Error: Package ' + name + ' is not exists.')); | ||
var pkg = _this3.getPackage(name); | ||
var pkg = _this2.getPackage(name); | ||
@@ -357,3 +367,3 @@ if (!pkg.isInstalled()) { | ||
try { | ||
files = _this3.getPackageFileMapping(name); | ||
files = _this2.getPackageFileMapping(name); | ||
} catch (error) { | ||
@@ -393,4 +403,4 @@ reject(error); | ||
value: function getPackagesInfo() { | ||
var keys = arguments.length <= 0 || arguments[0] === undefined ? ['name', 'version', 'license'] : arguments[0]; | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['name', 'version', 'license']; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -450,2 +460,4 @@ var info = {}; | ||
this.setConfigure('replaces', this.data.replaces, {}); | ||
this.setConfigure('dest', this.data.dest, 'assets'); | ||
this.setConfigure('path', this.data.path, '${dest}/${type}/${package}/${file}'); | ||
@@ -455,3 +467,3 @@ var cwd = this.data.cwd; | ||
if (!_path2.default.isAbsolute(cwd)) { | ||
cwd = _path2.default.resolve(this.path === '.' ? '' : _path2.default.dirname(this.path), cwd); | ||
cwd = _path2.default.resolve(this.filepath === '.' ? '' : _path2.default.dirname(this.filepath), cwd); | ||
} | ||
@@ -470,7 +482,12 @@ } | ||
}, { | ||
key: 'preparePaths', | ||
value: function preparePaths() { | ||
this.paths = Object.assign({}, this.data.paths || {}); | ||
Object.assign(this.paths, _util2.default.parseOptions(this.data, 'path')); | ||
} | ||
}, { | ||
key: 'prepareDests', | ||
value: function prepareDests() { | ||
this.dest = this.data.dest || 'assets'; | ||
var dests = Object.assign({ | ||
this.dests = Object.assign({ | ||
images: 'images', | ||
@@ -488,7 +505,2 @@ fonts: 'fonts', | ||
this.dests = {}; | ||
for (var type in dests) { | ||
this.dests[type] = _path2.default.join(this.dest, dests[type]); | ||
} | ||
Object.assign(this.dests, _util2.default.parseOptions(this.data, 'dest')); | ||
@@ -495,0 +507,0 @@ } |
@@ -47,3 +47,3 @@ 'use strict'; | ||
function Package(name, defination) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
@@ -61,3 +61,5 @@ _classCallCheck(this, Package); | ||
renames: {}, | ||
replaces: {} | ||
replaces: {}, | ||
dest: _configure2.default.get('dest', 'assets'), | ||
path: _configure2.default.get('path', '${dest}/${type}/${package}/${file}') | ||
}, options); | ||
@@ -108,2 +110,14 @@ | ||
}, { | ||
key: 'getPaths', | ||
value: function getPaths() { | ||
if (this.paths) { | ||
return this.paths; | ||
} | ||
var paths = _util2.default.parseOptions(this.options, 'path'); | ||
this.paths = Object.assign(this.options.paths || {}, paths); | ||
return this.paths; | ||
} | ||
}, { | ||
key: 'getMainFiles', | ||
@@ -125,3 +139,3 @@ value: function getMainFiles() { | ||
value: function getFiles() { | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -128,0 +142,0 @@ if (this.files) { |
@@ -34,3 +34,3 @@ 'use strict'; | ||
function Registry() { | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -66,3 +66,3 @@ _classCallCheck(this, Registry); | ||
value: function getPackageFiles(packageName) { | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -74,3 +74,3 @@ return _finder2.default.listFiles(this.getRelativePackagePath(packageName), '**/*', options); | ||
value: function getPackageTypedFiles(packageName) { | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -77,0 +77,0 @@ options = Object.assign({ |
@@ -41,3 +41,3 @@ 'use strict'; | ||
function Bower() { | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -44,0 +44,0 @@ _classCallCheck(this, Bower); |
@@ -41,3 +41,3 @@ 'use strict'; | ||
function Custom(name) { | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -44,0 +44,0 @@ _classCallCheck(this, Custom); |
@@ -37,3 +37,3 @@ 'use strict'; | ||
function Npm() { | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -40,0 +40,0 @@ _classCallCheck(this, Npm); |
@@ -14,3 +14,3 @@ 'use strict'; | ||
parseOptions: function parseOptions(data) { | ||
var base = arguments.length <= 1 || arguments[1] === undefined ? 'dest' : arguments[1]; | ||
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'dest'; | ||
@@ -17,0 +17,0 @@ var keys = Object.keys(data); |
{ | ||
"name": "assets-manager", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Copy packages files based on manifest file", | ||
@@ -73,2 +73,3 @@ "homepage": "https://github.com/amazingSurge/assets-manager", | ||
"dot-prop": "^4.0.0", | ||
"es6-template": "^1.0.4", | ||
"fs-extra": "^0.30.0", | ||
@@ -75,0 +76,0 @@ "glob-parent": "^3.0.0", |
@@ -109,2 +109,3 @@ # 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] | ||
"dest": "assets", | ||
"path": "${dest}/${type}/${package}/${file}", | ||
"dests": { | ||
@@ -152,2 +153,6 @@ "images": "images", | ||
### path | ||
The destination file path template. It's used to generate the destination file path. | ||
Defaults to `${dest}/${type}/${package}/${file}` | ||
### flattenPackages | ||
@@ -381,2 +386,4 @@ Whether to remove all package path parts from generated dest paths. | ||
- Package name duplicate in different registries | ||
- Clean empty package folder when cleanPackages | ||
- npm versions | ||
- File collections | ||
@@ -383,0 +390,0 @@ - Dependencies |
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
76187
1656
401
11
+ Addedes6-template@^1.0.4
+ Addedes6-template@1.0.4(transitive)
+ Addedes6-template-regex@0.1.1(transitive)
+ Addedextend-shallow@2.0.1(transitive)
+ Addedget-value@2.0.6(transitive)
+ Addedis-extendable@0.1.1(transitive)
+ Addedlazy-cache@1.0.4(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedsliced@1.0.1(transitive)