{"id":17399000,"url":"https://github.com/cdata/noosphere-npm","last_synced_at":"2025-03-27T22:17:00.548Z","repository":{"id":232296323,"uuid":"674834078","full_name":"cdata/noosphere-npm","owner":"cdata","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-04T23:02:47.000Z","size":557,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T00:31:56.973Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/cdata.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}},"created_at":"2023-08-04T23:02:44.000Z","updated_at":"2023-08-04T23:02:51.000Z","dependencies_parsed_at":"2024-04-09T01:15:23.598Z","dependency_job_id":null,"html_url":"https://github.com/cdata/noosphere-npm","commit_stats":null,"previous_names":["cdata/noosphere-npm"],"tags_count":0,"template":false,"template_full_name":"napi-rs/package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdata%2Fnoosphere-npm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdata%2Fnoosphere-npm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdata%2Fnoosphere-npm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdata%2Fnoosphere-npm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdata","download_url":"https://codeload.github.com/cdata/noosphere-npm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245931897,"owners_count":20695964,"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-10-16T15:03:54.580Z","updated_at":"2025-03-27T22:17:00.516Z","avatar_url":"https://github.com/cdata.png","language":"TypeScript","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 `yarn 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```\nyarn add @napi-rs/package-template\n```\n\n## Support matrix\n\n### Operating Systems\n\n|                  | node14 | node16 | node18 |\n| ---------------- | ------ | ------ | ------ |\n| Windows x64      | ✓      | ✓      | ✓      |\n| Windows x32      | ✓      | ✓      | ✓      |\n| Windows arm64    | ✓      | ✓      | ✓      |\n| macOS x64        | ✓      | ✓      | ✓      |\n| macOS arm64      | ✓      | ✓      | ✓      |\n| Linux x64 gnu    | ✓      | ✓      | ✓      |\n| Linux x64 musl   | ✓      | ✓      | ✓      |\n| Linux arm gnu    | ✓      | ✓      | ✓      |\n| Linux arm64 gnu  | ✓      | ✓      | ✓      |\n| Linux arm64 musl | ✓      | ✓      | ✓      |\n| Android arm64    | ✓      | ✓      | ✓      |\n| Android armv7    | ✓      | ✓      | ✓      |\n| FreeBSD x64      | ✓      | ✓      | ✓      |\n\n## Ability\n\n### Build\n\nAfter `yarn build/npm run 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 `yarn test/npm run 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@14`, `node@16`, `@node18`] 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 `yarn add @napi-rs/package-template` to see how it works.\n\n## Develop requirements\n\n- Install the latest `Rust`\n- Install `Node.js@10+` which fully supported `Node-API`\n- Install `yarn@1.x`\n\n## Test in local\n\n- yarn\n- yarn build\n- yarn 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%2Fcdata%2Fnoosphere-npm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdata%2Fnoosphere-npm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdata%2Fnoosphere-npm/lists"}