{"id":23156476,"url":"https://github.com/thecreation/assets-manager","last_synced_at":"2025-08-17T23:32:35.977Z","repository":{"id":39676103,"uuid":"67557056","full_name":"thecreation/assets-manager","owner":"thecreation","description":"Provides a different approach to transfer the required files from your registry distributions to the target.","archived":false,"fork":false,"pushed_at":"2022-05-27T19:09:17.000Z","size":2358,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-16T20:19:11.928Z","etag":null,"topics":["assets","assets-management","assets-manifest","nodejs-modules","npm-module","npm-package"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thecreation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-07T00:26:06.000Z","updated_at":"2018-11-26T10:08:12.000Z","dependencies_parsed_at":"2022-09-26T18:20:42.758Z","dependency_job_id":null,"html_url":"https://github.com/thecreation/assets-manager","commit_stats":null,"previous_names":["amazingsurge/assets-manager"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/thecreation/assets-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecreation%2Fassets-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecreation%2Fassets-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecreation%2Fassets-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecreation%2Fassets-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecreation","download_url":"https://codeload.github.com/thecreation/assets-manager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecreation%2Fassets-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270764887,"owners_count":24641316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assets","assets-management","assets-manifest","nodejs-modules","npm-module","npm-package"],"created_at":"2024-12-17T21:13:46.305Z","updated_at":"2025-08-17T23:32:34.709Z","avatar_url":"https://github.com/thecreation.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 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]\n\u003e  Assets manager provides a different approach to transfer the required files from your registry distributions to the target.\n\n## Installation\n\n```sh\n$ npm install --save-dev assets-manager\n```\n\n## Work with gulp\nYou can integrate it with gulp easily:\n```js\nvar AssetsManager = require('assets-manager');\nvar manager = new AssetsManager('manifest.json');\n\ngulp.task('assets', function(done){\n  manager.copyPackages().then(function(){\n    done();\n  });\n});\ngulp.task('clean:assets', function(done){\n  manager.cleanPackages().then(function(){\n    done();\n  });\n});\n```\n\n### See in action\n![gulp](https://raw.githubusercontent.com/amazingSurge/assets-manager/master/demo/gulp.gif)\n\n## Usage\n\n```js\nimport AssetsManager from 'assets-manager';\n\nconst assets = new AssetsManager('./manifest.json');\n\n// copy all packages files to destination\nassets.copyPackages();\n\n// clean all packages files from destination\nassets.cleanPackages();\n\n// get packages info\nassets.getPackagesInfo(['name', 'version', 'license']);\n\n// look all packages\nassets.forEachPackage(function(pkg){\n\n});\n\n// loop all js files in the packages\nassets.forEachPackage('js', function(pkg, files){\n\n});\n\n// check if package defined in manifest\nassets.hasPackage('jquery');\n\n// get package handler\nconst pkg = assets.getPackage('bootstrap');\n\n// get package info\npkg.getInfo();\n\n// get package path\npkg.getPath();\n\n// check if package is installed\npkg.isInstalled();\n\n// get all files in package \npkg.getFiles();\n\n// get specfic type files in package\npkg.getFilesByType();\n\n// get main files of package\npkg.getMainFiles();\n```\n\n## Registries\nAssets manager can work with different package manager like **npm**, **bower**. It Also can use custom folders.\n\nJust defined the registries in the manifest.json. The **npm** and **bower** are supported by default, you don't need define them again.\n\n```js\n\"registries\": {\n  \"vendor\": \"path-to-vendor\",\n  \"libs\": \"path-to-lib\"\n}\n```\n\n## Example manifest.json\n```js\n{\n  \"cwd\": \"./\",\n  \"registries\": {\n    \"vendor\": \"libs\"\n  },\n  \"defaultRegistry\": \"npm\",\n  \"verbose\": true,\n  \"override\": true,\n  \"ignoreError\": true,\n  \"flatten\": false,\n  \"flattenPackages\": true,\n  \"flattenTypes\": false,\n  \"dest\": \"assets\",\n  \"path\": \"${dest}/${type}/${package}/${file}\",\n  \"dests\": {\n    \"images\": \"images\",\n    \"fonts\": \"fonts\",\n    \"js\": \"js\",\n    \"coffee\": \"source/coffee\",\n    \"es6\": \"source/es6\",\n    \"css\": \"css\",\n    \"stylus\": \"source/stylus\",\n    \"less\": \"source/less\",\n    \"sass\": \"source/sass\",\n    \"scss\": \"source/scss\"\n  },\n  \"packages\": {\n    \"bower:jquery\": true,\n    \"npm:bootstrap\": [{\n      \"js\": \"dist/js\",\n      \"css\": \"dist/css\",\n      \"less\": \"less\",\n      \"fonts\": \"dist/fonts\"\n    }, {\n      \"replace\": {\n        \"*.css\": {\n          \"../fonts\": \"path-to-fonts\"\n        }\n      }\n    }],\n    \"vendor:modernizr\": {\n      \"modernizr.js\": \"dist/modernizr.min.js\",\n    }\n  }\n}\n```\n\n## Global options\n### cwd\nThe relative path to the root of the project.\nDefaults to the manifest.json directory.\n\n### dest\nThe destination path. It's relative path to cwd.\nDefaults to `assets`.\n\n### path\nThe destination file path template. It's used to generate the destination file path.\nDefaults to `${dest}/${type}/${package}/${file}`\n\n### flattenPackages\nWhether to remove all package path parts from generated dest paths.\nDefaults to true.\n\n### flattenTypes\nWhether to remove all type path parts from generated dest paths.\nDefaults to false.\n\n### flatten\nWhether to remove all path parts from generated dest paths in types.\nDefaults to false.\n\nIt will add index suffix to the duplicate files. \nE.g. If there are three filename.js in the package, it will rename the second file to filename-1.js and the third one to filename-3.js.\n\n### verbose\nWhether to output copy and clean files infos to console.\nDefaults to true.\n\n### override\nWhether to override old exists destination files.\nDefaults to true.\n\n### ignoreError\nWhether to ignore errors when do copy and clean task. If set to false will break the proceeding.\nDefaults to true.\n\n### defaultRegistry\nSet default registry when package dont have a registry specify.\nDefaults to npm.\n\n### types\nSet types that assets manage will classicfy files automatically.\n\nDefaults:\n```js\n{\n  js: '**/*.js',\n  jsx: '**/*.jsx',\n  coffee: '**/*.coffee',\n  es6: '**/*.es6.js',\n  css: '**/*.css',\n  stylus: '**/*.styl',\n  scss: '**/*.scss',\n  sass: '**/*.sass',\n  less: '**/*.less',\n  images: '**/*.{bmp,jpg,jpeg,png,gif,webp,tiff,wbmp,eps}',\n  fonts: '**/*.{eot,otf,svg,ttc,ttf,woff,woff2}'\n}\n```\n\n## Packages\n### Package key\nThe package key in the manifest.json take the following form:\n```\n\"registry:package\"\n\"package\"\n```\n\nThe \"package\" shorter form will use the default registry.\n\n### Package definition\nYou can write in the following ways define the package.\n\n1.simple mode\n```js\n\"PACKAGEKEY\": true\n```\n\nIt will use main files and use default options. \n\n2.use options only\n```js\n\"PACKAGEKEY\": [\n  true,\n  {\n    \"registry\": \"bower\"\n  }\n]\n```\n\nIt will use main files custom options.\n\n3.use auto types only\nIt will look for all files in the package folder, and classify the files automatically. The default options will be used in this mode. \n```js\n\"PACKAGEKEY\": \"**/*\"\n```\n\nYou can use glob array also.\n```js\n\"PACKAGEKEY\": [\"dist/**/*.js\", \"!dist/**/*.min.js\"]\n```\n\n4.use auto types and options\n```js\n\"PACKAGEKEY\": [\"**/*\", {\n  \"registry\": \"bower\"\n}]\n```\n\nglob array supported too.\n```js\n\"PACKAGEKEY\": [[\"**/*\", \"!**/*.min.js\"], {\n  \"registry\": \"bower\"\n}]\n```\n\n5.use types only\n```js\n\"PACKAGEKEY\": [{\n  \"js\": \"dist/js\",\n  \"css\": \"dist/css\"\n}]\n```\n\nIt will use custom types config and default options.\n\n6.use types only alternatively\n```js\n\"PACKAGEKEY\": {\n  \"js\": \"dist/js\",\n  \"css\": \"dist/css\"\n}\n```\n\n7.use types and options\n```js\n\"PACKAGEKEY\": [\n  {\n    \"js\": \"dist/js\",\n    \"css\": \"dist/css\"\n  },\n  {\n    \"registry\": \"bower\"\n  }\n]\n```\n\nIt will use custom types config and custom options.\n\n### Types config in the package definition\n\n1.Simple path mapping\n```js\n{\n  js: 'path-to-js',\n  css: 'path-to-css'\n}\n```\n\n2.Glob support\n```js\n{\n  js: '*.js',\n  css: 'css/*.css'\n}\n```\n\n3.Array support\n```js\n{\n  js: ['a.js', 'b.js'],\n  css: ['css/*.css', '!css/*.min.css']\n}\n```\n\n4.You can rename the files\n```js\njs: {\n  'bootstrap.js': 'dist/js/bootstrap.js'\n},\ncss: {\n  'main.css':'dist/css/bootstrap.css',\n  'theme.css':'dist/css/bootstrap-theme.css'\n}\n```\n\n### Package options\n#### defaults\n```js\n{\n  package: null,\n  flattenPackages: true,\n  flattenTypes: false,\n  flatten: false,\n  verbose: true,\n  override: true,\n  registry: 'npm',\n  replaces: {},\n  processes: {},\n  renames: {}\n}\n```\n\n#### package\nThe directory name of package for destination file. When set to null, it will use package name.\n\n#### flattenPackages, flattenTypes, flatten, verbose, override, registry\nThese options will override the global options.\n\n#### replaces\nIt will replace the content when copy to target directory. Regex supported.\n```js\n\"replaces\": {\n  \"*.css\": {\n    \"../fonts\": \"path-to-fonts\",\n    \"/fa-(\\w+)/g\": \"icon-$1\"\n  }\n}\n```\n\n#### processes\nIt will process the content when copy to target directory.\n```js\n\"processes\": {\n  \"*.css\": function(content) {\n    return content.replace('foo', 'bar');\n  }\n}\n```\n\nIt support function string.\n```js\n\"processes\": {\n  \"*.css\": \"function(content) { return content.replace('foo', 'bar');}\"\n}\n```\n\nAlso it support function array.\n```js\n\"processes\": {\n  \"*.css\": [\"function(content) { return content.replace('foo', 'bar');}\"]\n}\n```\n\n#### renames\nIt will rename the files when copy to target directory. Regex supported.\n```js\n\"renames\": {\n  \"jquery.min.js\": \"jquery.js\",\n  \"*.min.css\": [\"/\\.min\\.css$/\", \".css\"]\n}\n```\n\n#### Hooks\nAssets manager provides 4 separate hooks that can be used to trigger other automated tools during assets copy or clean operate. \n\n```\n\"copy:pre\": \"\u003cyour command here\u003e\",\n\"copy:post\": \"\u003cyour command here\u003e\",\n\"clean:pre\": \"\u003cyour command here\u003e\",\n\"clean:post\": \"\u003cyour command here\u003e\",\n```\n\n## Todos\n-   Hooks\n-   Package name duplicate in different registries\n-   Clean empty package folder when cleanPackages\n-   npm versions\n-   File collections\n-   Dependencies\n\n## License\n\nMIT © [amazingSurge](amazingSurge.com)\n\n[npm-image]: https://badge.fury.io/js/assets-manager.svg\n[npm-url]: https://npmjs.org/package/assets-manager\n[travis-image]: https://travis-ci.org/amazingSurge/assets-manager.svg?branch=master\n[travis-url]: https://travis-ci.org/amazingSurge/assets-manager\n[daviddm-image]: https://david-dm.org/amazingSurge/assets-manager.svg?theme=shields.io\n[daviddm-url]: https://david-dm.org/amazingSurge/assets-manager\n[coveralls-image]: https://coveralls.io/repos/amazingSurge/assets-manager/badge.svg\n[coveralls-url]: https://coveralls.io/r/amazingSurge/assets-manager\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecreation%2Fassets-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecreation%2Fassets-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecreation%2Fassets-manager/lists"}