{"id":16682610,"url":"https://github.com/jchip/publish-util","last_synced_at":"2025-09-10T17:41:23.335Z","repository":{"id":65477474,"uuid":"363497226","full_name":"jchip/publish-util","owner":"jchip","description":"Some util to clean up package.json for npm publish","archived":false,"fork":false,"pushed_at":"2024-04-05T16:55:13.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-29T01:38:45.945Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jchip.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-01T20:04:21.000Z","updated_at":"2025-05-13T06:06:26.000Z","dependencies_parsed_at":"2023-01-25T06:35:21.179Z","dependency_job_id":null,"html_url":"https://github.com/jchip/publish-util","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/jchip/publish-util","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchip%2Fpublish-util","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchip%2Fpublish-util/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchip%2Fpublish-util/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchip%2Fpublish-util/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jchip","download_url":"https://codeload.github.com/jchip/publish-util/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchip%2Fpublish-util/sbom","scorecard":{"id":511370,"data":{"date":"2025-08-11","repo":{"name":"github.com/jchip/publish-util","commit":"d929bd021cf8fbad733a64bd8d958819444c7e3d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"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":"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":"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":"Code-Review","score":0,"reason":"Found 1/30 approved changesets -- score normalized to 0","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":"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":"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":"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":"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":"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":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"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 'main'"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 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-20T00:37:36.719Z","repository_id":65477474,"created_at":"2025-08-20T00:37:36.719Z","updated_at":"2025-08-20T00:37:36.719Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274496707,"owners_count":25296441,"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-09-10T02:00:12.551Z","response_time":83,"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-12T14:08:04.686Z","updated_at":"2025-09-10T17:41:23.297Z","avatar_url":"https://github.com/jchip.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# publish-util\n\nClean up `package.json` for publishing.\n\nYour `package.json`:\n\n```json\n{\n  \"name\": \"...\",\n  \"version\": \"...\",\n  \"description\": \"...\",\n  \"scripts\": {\n    \"test\": \"...\",\n    \"coverage\": \"...\",\n    \"build\": \"...\",\n    \"prepack\": \"npm run build \u0026\u0026 publish-util-prepack\",\n    \"postpack\": \"publish-util-postpack\"\n  },\n  \"publishUtil\": {\n    \"remove\": [\"devDependencies\", { \"scripts\": [\"test\", \"coverage\", \"build\"] }],\n    \"keep\": [\"options\"]\n  },\n  \"dependencies\": {\n    \"react\": \"^17.0.0\",\n    \"react-dom\": \"^17.0.0\"\n  },\n  \"devDependencies\": {\n    \"tap\": \"^15.0.0\",\n    \"publish-util\": \"^1.0.0\"\n  },\n  \"nyc\": {\n    \"reporter\": [\"lcov\", \"text\", \"text-summary\"]\n  },\n  \"options\": {}\n}\n```\n\nYour `package.json` published:\n\n```json\n{\n  \"name\": \"...\",\n  \"version\": \"...\",\n  \"description\": \"...\",\n  \"scripts\": {\n    \"postpack\": \"publish-util-postpack\"\n  },\n  \"dependencies\": {\n    \"react\": \"^17.0.0\",\n    \"react-dom\": \"^17.0.0\"\n  },\n  \"options\": {}\n}\n```\n\n## Usage\n\nJust install this to your module:\n\n`npm install --save-dev publish-util`\n\nIt will automatically add `prepack` and `postpack` scripts to your package.json for you.\n\nOut of the box it will clean up non-standard fields plus `workspaces` and `devDependencies` from your `package.json`. To keep `devDependencies`, see [details below](#removing-non-standard-fields)\n\n## Publishing\n\nThis module offers a custom publishing script to fix some behaviors of `npm publish`.\n\nThe problem is that before any thing can process `package.json`, `npm publish` will load and upload it to the registry as packument (meta for the package).\n\nIf you want the copy of `package.json` after this module processed it to be the packument meta, then use the `do-publish` command:\n\n`npx do-publish`\n\nThe script use whatever version of `npm` you have to do the actual work. It takes all CLI arguments that `npm publish` accepts and will pass them through.\n\n## `publishUtil` configs:\n\nYou can configure some behaviors with `publishUtil` in your `package.json`.\n\n| Config            | Description                                                             | Default |\n| ----------------- | ----------------------------------------------------------------------- | ------- |\n| `rename`          | object map of keys to rename from `package.json` - done before `remove` |         |\n| `remove`          | array of keys and nesting keys to remove from `package.json`            |         |\n| `keep`            | array of keys and nesting keys to keep from `package.json`.             |         |\n| `removeExtraKeys` | remove top level non-standard fields.                                   | `true`  |\n| `autoPostPack`    | insert `scripts.postpack` if it's missing.                              | `true`  |\n| `silent`          | don't log message with console                                          | `false` |\n\n- `publishUtil` is removed automatically.\n\n- `rename` details. The rename config is an object map, with key being the field to rename, and its value being the target name.\n\nFor example:\n\n```json\n{\n  \"publishUtil\": {\n    \"rename\": {\n      \"scripts.foo\": \"scripts.renamedFoo\"\n    }\n  }\n}\n```\n\n- `scripts.prepublishOnly` is removed automatically if it's just `\"publish-util-prepublishonly\"`. Add it to `publishUtil.keep` to keep it:\n\n```json\n{\n  \"publishUtil\": {\n    \"keep\": [{ \"scripts\": [\"prepublishOnly\"] }]\n  }\n}\n```\n\n- Can't remove `scripts.postpack` because npm needs that to restore `package.json`.\n\n- Can't use `prepack` because `npm publish` uploads meta data before that so if you want to publish with different `dependencies` it will break.\n\n### `remove` and `keep` formats\n\nThe config `remove` and `keep` can be:\n\n- Array of strings that are either keys in the object or a regular expression to match keys in the object.\n- To specify a regular expression, use the format `\"/\u003cregexp\u003e/\u003cflags\u003e\"`\n- To reach into a nesting object, use an object of keys and array of keys/regex.\n\nFor example, to reach `pkg.key1.key2`, and `pkg.key1.xyz*`:\n\n```json\n[\n  {\n    \"key1\": [\"key2\", \"/xyz.*/\"]\n  }\n]\n```\n\n## Removing Non-standard Fields\n\nThese top level fields are considered standard fields:\n\n- all top level fields defined at [npm package.json](https://docs.npmjs.com/cli/v7/configuring-npm/package-json), except `workspaces` and `devDependencies`\n- And these fields: `module`\n\nAny extra top level fields not in the standard fields are automatically removed.\n\n- To skip this automatic removal, set `publishUtil.removeExtraKeys` to `false`.\n- You can also add fields to `publishUtil.keep` to avoid them being removed.\n\nFor example, to keep `devDependencies`:\n\n```json\n{\n  \"publishUtil\": {\n    \"keep\": [\"devDependencies\"]\n  }\n}\n```\n\n## Auto `postpack` Insert\n\nIf you don't have a `scripts.postpack`, then it's automatically added with `\"publish-util-postpack\"` to ensure your package.json is restored after packing.\n\n- Set `publishUtil.autoPostPack` to `false` to skip this.\n\n## Dry Run and Verify\n\nTo verify `package.json` content.\n\n1. Run `npm run prepack`\n2. Inspect `package.json` to ensure everything is in order\n3. Run `npm run postpack` to restore `package.json`\n4. Inspect `package.json` again\n\nUsing `npm pack`\n\n1. Run `npm pack`\n2. Inspect `package.json` to ensure it's not modified\n3. Look for the `.tgz` file and extract it\n4. Inspect `package/package.json` to ensure it's as expected.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjchip%2Fpublish-util","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjchip%2Fpublish-util","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjchip%2Fpublish-util/lists"}