{"id":20699717,"url":"https://github.com/napi-rs/package-template-pnpm","last_synced_at":"2025-06-25T19:37:46.862Z","repository":{"id":215947748,"uuid":"740068817","full_name":"napi-rs/package-template-pnpm","owner":"napi-rs","description":"Template project for using napi-rs to build native package via pnpm.","archived":false,"fork":false,"pushed_at":"2025-04-16T08:11:47.000Z","size":372,"stargazers_count":17,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-19T23:03:54.873Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/napi-rs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-07T12:40:52.000Z","updated_at":"2025-04-17T14:22:59.000Z","dependencies_parsed_at":"2024-02-15T14:25:14.566Z","dependency_job_id":"f61947fa-a0d5-4cab-8f2e-53f666b36b90","html_url":"https://github.com/napi-rs/package-template-pnpm","commit_stats":{"total_commits":53,"total_committers":4,"mean_commits":13.25,"dds":0.3584905660377359,"last_synced_commit":"08edd6f1ec6280ded5350d5ba7483c4d26901ee8"},"previous_names":["napi-rs/package-template-pnpm"],"tags_count":6,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/napi-rs%2Fpackage-template-pnpm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/napi-rs%2Fpackage-template-pnpm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/napi-rs%2Fpackage-template-pnpm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/napi-rs%2Fpackage-template-pnpm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/napi-rs","download_url":"https://codeload.github.com/napi-rs/package-template-pnpm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250333137,"owners_count":21413335,"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","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-11-17T00:31:37.691Z","updated_at":"2025-04-22T22:25:54.019Z","avatar_url":"https://github.com/napi-rs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@napi-rs/package-template`\n\n![https://github.com/napi-rs/package-template/actions](https://github.com/napi-rs/package-template/workflows/CI/badge.svg)\n\n\u003e Template project for writing node packages with napi-rs.\n\n# Usage\n\n1. Click **Use this template**.\n2. **Clone** your project.\n3. Run `pnpm install` to install dependencies.\n4. Run `npx napi rename -n [name]` command under the project folder to rename your package.\n\n## Install this test package\n\n```\npnpm add @napi-rs/package-template\n```\n\n## Usage\n\n### Build\n\nAfter `pnpm build` command, you can see `package-template.[darwin|win32|linux].node` file in project root. This is the native addon built from [lib.rs](./src/lib.rs).\n\n### Test\n\nWith [ava](https://github.com/avajs/ava), run `pnpm test` to testing native addon. You can also switch to another testing framework if you want.\n\n### CI\n\nWith GitHub Actions, each commit and pull request will be built and tested automatically in [`node@18`, `node@20`] x [`macOS`, `Linux`, `Windows`] matrix. You will never be afraid of the native addon broken in these platforms.\n\n### Release\n\nRelease native package is very difficult in old days. Native packages may ask developers who use it to install `build toolchain` like `gcc/llvm`, `node-gyp` or something more.\n\nWith `GitHub actions`, we can easily prebuild a `binary` for major platforms. And with `N-API`, we should never be afraid of **ABI Compatible**.\n\nThe other problem is how to deliver prebuild `binary` to users. Downloading it in `postinstall` script is a common way that most packages do it right now. The problem with this solution is it introduced many other packages to download binary that has not been used by `runtime codes`. The other problem is some users may not easily download the binary from `GitHub/CDN` if they are behind a private network (But in most cases, they have a private NPM mirror).\n\nIn this package, we choose a better way to solve this problem. We release different `npm packages` for different platforms. And add it to `optionalDependencies` before releasing the `Major` package to npm.\n\n`NPM` will choose which native package should download from `registry` automatically. You can see [npm](./npm) dir for details. And you can also run `pnpm add @napi-rs/package-template` to see how it works.\n\n## Develop requirements\n\n- Install the latest `Rust`\n- Install `Node.js@16+` which fully supported `Node-API`\n- Run `corepack enable`\n\n## Test in local\n\n- pnpm\n- pnpm build\n- pnpm test\n\nAnd you will see:\n\n```bash\n$ ava --verbose\n\n  ✔ sync function from native code\n  ✔ sleep function from native code (201ms)\n  ─\n\n  2 tests passed\n✨  Done in 1.12s.\n```\n\n## Release package\n\nEnsure you have set your **NPM_TOKEN** in the `GitHub` project setting.\n\nIn `Settings -\u003e Secrets`, add **NPM_TOKEN** into it.\n\nWhen you want to release the package:\n\n```\nnpm version [\u003cnewversion\u003e | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=\u003cprerelease-id\u003e] | from-git]\n\ngit push\n```\n\nGitHub actions will do the rest job for you.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnapi-rs%2Fpackage-template-pnpm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnapi-rs%2Fpackage-template-pnpm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnapi-rs%2Fpackage-template-pnpm/lists"}