{"name":"napi-postinstall","version":"0.2.0","author":{"url":"https://www.1stG.me","name":"JounQin","email":"admin@1stg.me"},"license":"MIT","_id":"napi-postinstall@0.2.0","maintainers":[{"name":"jounqin","email":"admin@1stg.me"}],"homepage":"https://github.com/un-ts/napi-postinstall#readme","bugs":{"url":"https://github.com/un-ts/napi-postinstall/issues"},"bin":{"napi-postinstall":"lib/cli.js"},"dist":{"shasum":"5287f2d85e926ade914688ed3ce29e53efb0036a","tarball":"http://registry-npm.ywwl.com/napi-postinstall/download/napi-postinstall-0.2.0.tgz","fileCount":21,"integrity":"sha512-Cs4QwMscJ5UnKxgYWqWcX1L8nijfm+C9f2QqZyt3VbTwuBSRT05aLS39BvMO0asGv8EUfuY0IOsfYSv0NfzFcA==","signatures":[{"sig":"MEQCIGtI+9lnhxAxQsV2bVeCQwaV3Ts8YEhDHh9bSpcnzQIiAiAH3OYz1ysUPi+8qkzr3OXck4k4bw6wVueqf0FW2UG8Qg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/napi-postinstall@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":42492,"size":11884,"noattachment":false,"key":"/napi-postinstall/-/napi-postinstall-0.2.0.tgz"},"main":"./lib/index.js","type":"commonjs","types":"./lib/index.d.ts","engines":{"node":"^12.20.0 || ^14.18.0 || >=16.0.0"},"exports":{".":{"types":"./lib/index.d.ts","default":"./lib/index.js"},"./package.json":"./package.json"},"funding":"https://opencollective.com/napi-postinstall","gitHead":"ca5a744a5e8fbdeace76100ddc61cff0602b48da","_npmUser":{"name":"jounqin","email":"admin@1stg.me"},"repository":{"url":"git+https://github.com/un-ts/napi-postinstall.git","type":"git"},"_npmVersion":"10.9.2","description":"The `postinstall` script helper for handling native bindings in legacy `npm` versions","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/napi-postinstall_0.2.0_1745668777119_0.2524328256326518","host":"s3://npm-registry-packages-npm-production"},"readme":"# napi-postinstall\n\n[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/un-ts/napi-postinstall/ci.yml?branch=main)](https://github.com/un-ts/napi-postinstall/actions/workflows/ci.yml?query=branch%3Amain)\n[![Codecov](https://img.shields.io/codecov/c/github/un-ts/napi-postinstall.svg)](https://codecov.io/gh/un-ts/napi-postinstall)\n[![type-coverage](https://img.shields.io/badge/dynamic/json.svg?label=type-coverage&prefix=%E2%89%A5&suffix=%&query=$.typeCoverage.atLeast&uri=https%3A%2F%2Fraw.githubusercontent.com%2Fun-ts%2Fnapi-postinstall%2Fmain%2Fpackage.json)](https://github.com/plantain-00/type-coverage)\n[![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/un-ts/napi-postinstall)](https://coderabbit.ai)\n[![npm](https://img.shields.io/npm/v/napi-postinstall.svg)](https://www.npmjs.com/package/napi-postinstall)\n[![GitHub Release](https://img.shields.io/github/release/un-ts/napi-postinstall)](https://github.com/un-ts/napi-postinstall/releases)\n\n[![Conventional Commits](https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg)](https://conventionalcommits.org)\n[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![changesets](https://img.shields.io/badge/maintained%20with-changesets-176de3.svg)](https://github.com/changesets/changesets)\n\nThe `postinstall` script helper for handling native bindings in legacy `npm` versions, this is a reimplementation of the [`node-install`][node-install] functionality from [`esbuild`][esbuild] for [`napi-rs`][napi-rs] ecosystem packages like [`rollup`][rollup], [`@swc/core`][swc-core] and [`unrs-resolver`][unrs-resolver].\n\nFor more details, please refer to the following issues:\n\n- [npm/cli#4828](https://github.com/npm/cli/issues/4828) -- root cause\n- [napi-rs/napi-rs#2569](https://github.com/napi-rs/napi-rs/issues/2569)\n- [unrs/unrs-resolver#56](https://github.com/unrs/unrs-resolver/issues/56)\n\n## TOC <!-- omit in toc -->\n\n- [Usage](#usage)\n  - [Install](#install)\n  - [CLI](#cli)\n  - [API](#api)\n    - [Types](#types)\n    - [Example](#example)\n- [Sponsors and Backers](#sponsors-and-backers)\n  - [Sponsors](#sponsors)\n  - [Backers](#backers)\n- [Changelog](#changelog)\n- [License](#license)\n\n## Usage\n\n### Install\n\n```sh\n# pnpm\npnpm add napi-postinstall\n\n# yarn\nyarn add napi-postinstall\n\n# npm\nnpm i napi-postinstall\n\n# bun\nbun add napi-postinstall\n```\n\n### CLI\n\n```sh\nnapi-postinstall unrs-resolver #<napi-package-name>\n```\n\nYou can put it into `scripts#postinstall` of your `package.json`:\n\n```json\n{\n  \"scripts\": {\n    \"postinstall\": \"napi-postinstall unrs-resolver\"\n  }\n}\n```\n\nThis will check and prepare the napi binding packages for you automatically.\n\n### API\n\n#### Types\n\n```ts\n// napi-postinstall\nexport interface PackageJson {\n  name: string\n  version: string\n}\n\nexport declare function checkAndPreparePackage(\n  packageNameOrPackageJson: PackageJson | string,\n  checkVersion?: boolean,\n): Promise<void>\n\n// napi-postinstall/fallback\ndeclare function fallback<T = unknown>(\n  packageJsonPath: string,\n  checkVersion?: boolean,\n): T\nexport = fallback\n```\n\n#### Example\n\n```js\n// index.js\nconst { checkAndPreparePackage, isNpm } = require('napi-postinstall')\n\nif (isNpm()) {\n  void checkAndPreparePackage('unrs-resolver' /* <napi-package-name> */)\n}\n\n// fallback.js\nmodule.exports = require('napi-postinstall/fallback')(\n  require.resolve('./package.json') /* <napi-package-json-path> */,\n  true /* <check-version> */,\n)\n```\n\n## Sponsors and Backers\n\n[![Sponsors](https://raw.githubusercontent.com/1stG/static/master/sponsors.svg)](https://github.com/sponsors/JounQin)\n\n### Sponsors\n\n| 1stG                                                                                                                   | RxTS                                                                                                                   | UnTS                                                                                                                   |\n| ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |\n| [![1stG Open Collective sponsors](https://opencollective.com/1stG/organizations.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective sponsors](https://opencollective.com/rxts/organizations.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective sponsors](https://opencollective.com/unts/organizations.svg)](https://opencollective.com/unts) |\n\n### Backers\n\n| 1stG                                                                                                                | RxTS                                                                                                                | UnTS                                                                                                                |\n| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |\n| [![1stG Open Collective backers](https://opencollective.com/1stG/individuals.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective backers](https://opencollective.com/rxts/individuals.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective backers](https://opencollective.com/unts/individuals.svg)](https://opencollective.com/unts) |\n\n## Changelog\n\nDetailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.md).\n\n## License\n\n[MIT][] © [JounQin][]@[1stG.me][]\n\n[node-install]: https://github.com/evanw/esbuild/blob/4475787eef4c4923b92b9fa37ebba1c88b9e1d9b/lib/npm/node-install.ts\n[esbuild]: https://github.com/evanw/esbuild\n[napi-rs]: https://github.com/napi-rs/napi-rs\n[rollup]: https://github.com/rollup/rollup\n[swc-core]: https://github.com/swc-project/swc\n[unrs-resolver]: https://github.com/unrs/unrs-resolver\n[1stG.me]: https://www.1stG.me\n[JounQin]: https://github.com/JounQin\n[MIT]: http://opensource.org/licenses/MIT\n","publish_time":1745668777303,"_cnpm_publish_time":1745668777303,"dist-tags":{"latest":"0.3.8"}}