{"id":15684048,"url":"https://github.com/bubkoo/grunt-file-hash","last_synced_at":"2025-10-31T00:48:03.434Z","repository":{"id":17688571,"uuid":"20494484","full_name":"bubkoo/grunt-file-hash","owner":"bubkoo","description":"👾 Generate hashed mapping for your static files.","archived":false,"fork":false,"pushed_at":"2017-01-11T13:35:27.000Z","size":22,"stargazers_count":10,"open_issues_count":2,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-17T02:25:14.953Z","etag":null,"topics":[],"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/bubkoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-04T18:19:09.000Z","updated_at":"2019-10-14T17:58:35.000Z","dependencies_parsed_at":"2022-09-26T22:01:19.086Z","dependency_job_id":null,"html_url":"https://github.com/bubkoo/grunt-file-hash","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bubkoo/grunt-file-hash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fgrunt-file-hash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fgrunt-file-hash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fgrunt-file-hash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fgrunt-file-hash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bubkoo","download_url":"https://codeload.github.com/bubkoo/grunt-file-hash/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fgrunt-file-hash/sbom","scorecard":{"id":257037,"data":{"date":"2025-08-11","repo":{"name":"github.com/bubkoo/grunt-file-hash","commit":"2c0870924f805232713d5969c5e32683f7462276"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":2,"reason":"Found 6/24 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE-MIT:0","Info: FSF or OSI recognized license: MIT License: LICENSE-MIT:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 12 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T09:55:59.757Z","repository_id":17688571,"created_at":"2025-08-17T09:55:59.762Z","updated_at":"2025-08-17T09:55:59.762Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281908615,"owners_count":26582147,"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-10-30T02:00:06.501Z","response_time":61,"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":[],"created_at":"2024-10-03T17:10:11.750Z","updated_at":"2025-10-31T00:48:03.389Z","avatar_url":"https://github.com/bubkoo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grunt-file-hash\n\n\u003e Create version mapping for your static files.\n\n[![MIT License](https://img.shields.io/badge/license-MIT_License-green.svg?style=flat-square)](https://github.com/bubkoo/grunt-file-hash/blob/master/LICENSE)\n[![Package Quality](http://npm.packagequality.com/shield/grunt-file-hash.svg)](http://packagequality.com/#?package=grunt-file-hash)\n\n\n## Getting Started\n\nThis plugin requires Grunt `~0.4.5`\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-file-hash --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-file-hash');\n```\n\n## The \"filehash\" task\n\n### Overview\nIn your project's Gruntfile, add a section named `filehash` to the data object passed into `grunt.initConfig()`.\n\n```javascript\ngrunt.initConfig({\n  filehash: {\n    options: {\n      mapping: '{{= dest}}/hash.json',                      // the mapping file path\n      mappingKey: '{{= cwd}}/{{= basename}}{{= extname}}', // mapping key options\n      mappingValue: '{{= dest}}/{{= basename}}.{{= hash}}{{= extname}}', // mapping value options\n      etag: null,\n      algorithm: 'md5', // the algorithm to create the hash\n      rename: '{{= dirname}}/{{= basename}}.{{= hash}}{{= extname}}', // save the original file as what\n      keep: true,      // should we keep the original file or not\n      merge: false,    // merge hash results into existing `hash.json` file or override it.\n      hashlen: 10     // length for hashsum digest\n    },\n    your_target: {\n      // Target-specific file lists and/or options go here.\n      options: {\n        mapping: 'static/mapping.json'\n      },\n      files: [{\n        cwd: 'static/dist',\n        src: ['js/**/*.js', 'css/**/*.css'],\n        dest: 'static/dist'\n      }]\n    }\n  }\n});\n```\n\n### Options\n\n#### options.mapping\nType: `String`\nDefault value: `'{{= dest}}/mapping.json'`\n\nWhere to save the hash mapping json file.\nAvailable variables are `dest`, `cwd`.\nYou can always use `{{= grunt.config.get(...) }}'` to access config data in your `Gruntfile`.\n\nSet to `null` will disable the output.\n\n#### options.mappingKey\nType: `String`\nDefault value: `'{{= cwd}}/{{= basename}}{{= extname}}'`\n\nA string value that is used to define the json file's key.\n\n#### options.mappingValue\nType: `String`\nDefault value: `'{{= dest}}/{{= basename}}.{{= hash}}{{= extname}}'`\n\nA string value that is used to define the json file's value.\n\nWith the default options, the output would be like this:\n\n```js\n{\n  \"src/js/a.js\": \"dest/js/a.aaa93n3f2.js\",\n  \"src/css/foo.css\": \"dest/css/foo.maaof33mao.css\"\n}\n```\n\n#### options.etag \u003ca id=\"option-etag\"\u003e\u003c/a\u003e\nType: `String`\nDefault value: `null`\n\nIn spite of standard digest algorithms provided by the\n[crypto]('http://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm') module,\nyou can set a \"etag\" format to use as file version.\n\nSet `etag` to `true` will use the default format: `{{= size}}-{{= +mtime}}`.\n\nAll values in a [fs.Stats](http://nodejs.org/api/fs.html#fs_class_fs_stats) result are available.\n\n#### options.algorithm\nType: `String`\nDefault value: `'md5'`\n\nThe algorithm to generate hash digests. Depend on the version of OpenSSL on the platform.\nExamples are `'sha1'`, `'md5'`, `'sha256'`, etc.\n\n#### options.hashlen\nType: `Number`\nDefault value: `10`\n\nThe length of a hash digest hex value.\n\n#### options.rename\nType: `String`\nDefault value: `'{{= dirname}}/{{= basename}}.{{= hash}}{{= extname}}'`\n\nRename files, to include a hash in it. This is often for safely bursting cache.\nAvailable variables are:\n\n  - **hash**      - The hash/etag value.\n  - **dest**      - The destination directory.\n  - **cwd**       - The `cwd` you setted for `files` prop section.\n  - **filepath**  - The path of the file.\n  - **basename**  - The basename of the file, with extension name excluded.\n  - **dirname**   - The directory name of the file.\n  - **extname**   - The extension name of the file.\n\nExamples:\n\n    \"abc/defg/hijk.js\" =\u003e\n    {\n      filepath: \"abc/defg/hijk.js\",\n      basename: \"hijk\",\n      dirname: \"abc/defg\",\n      extname: \"js\"\n    }\n\nWith the default rename format, the result will be something like `\"abc/defg/hijk\\_e8e7f9e4.js\"`.\n\nWill raise a warning if the renamed target is not in dest directory.\n  \n#### options.keep\nType: `String`\nDefault value: `true`\n\nWhether to keep the original files after rename it.\n\n#### options.merge\nType: `String`\nDefault value: `false`\n\nThis option is mainly for cases like this:\n\n```js\ngrunt.initConfig({\n  hashmap: {\n    options: {\n      mapping: 'static/hash.json',\n      merge: true,\n    },\n    js: [{\n      cwd: 'static/dist',\n      src: 'js/**/*.js',\n      dest: 'static/dist'\n    }],\n    css: [{\n      cwd: 'static/dist',\n      src: 'css/**/*.css',\n      dest: 'static/dist'\n    }],\n  },\n  watch: {\n    js: {\n      files: ['static/js/**/*.js'],\n      tasks: ['hashmap:js']\n    }, \n    css: {\n      files: ['static/css/**/*.css'],\n      tasks: ['hashmap:css']\n    }\n  },\n})\n```\n\nfilehash tasks for css and js are created seperately.\nSo with the `grunt-contrib-watch` running, when you modify one single file,\ngrunt won't need to run the whole hash mapping process for all files.\n\nSince all the hash results will be written to the same file, and the mapping file\nare automatically merged. It is safe to refer to `mapping.json` for all static files\nin your application's static url generator.\n\nThe downside of this practice is that hashes for deleted files will never be removed,\nunless `mapping.json` is removed. But of course, you can always set up a `grunt clean` task. \n\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbubkoo%2Fgrunt-file-hash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbubkoo%2Fgrunt-file-hash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbubkoo%2Fgrunt-file-hash/lists"}