{"id":18976913,"url":"https://github.com/a11ywatch/rust-to-npm","last_synced_at":"2025-04-19T17:18:39.205Z","repository":{"id":41351703,"uuid":"508867761","full_name":"a11ywatch/rust-to-npm","owner":"a11ywatch","description":"Rust to npm","archived":false,"fork":false,"pushed_at":"2024-02-18T23:11:40.000Z","size":55,"stargazers_count":35,"open_issues_count":2,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T10:43:41.834Z","etag":null,"topics":["cargo","deployment-automation","npm","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/rust-to-npm","language":"Rust","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/a11ywatch.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},"funding":{"github":["a11ywatch"]}},"created_at":"2022-06-29T22:53:49.000Z","updated_at":"2024-12-19T10:42:26.000Z","dependencies_parsed_at":"2024-11-08T15:32:56.132Z","dependency_job_id":"5fa21ed4-bc20-458e-8675-a4249202fb7a","html_url":"https://github.com/a11ywatch/rust-to-npm","commit_stats":{"total_commits":27,"total_committers":2,"mean_commits":13.5,"dds":0.03703703703703709,"last_synced_commit":"a4b028171566f74b6ed9099a56ee30647722ee6a"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a11ywatch%2Frust-to-npm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a11ywatch%2Frust-to-npm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a11ywatch%2Frust-to-npm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a11ywatch%2Frust-to-npm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a11ywatch","download_url":"https://codeload.github.com/a11ywatch/rust-to-npm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249228271,"owners_count":21233852,"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":["cargo","deployment-automation","npm","rust"],"created_at":"2024-11-08T15:26:52.530Z","updated_at":"2025-04-16T10:31:59.773Z","avatar_url":"https://github.com/a11ywatch.png","language":"Rust","funding_links":["https://github.com/sponsors/a11ywatch"],"categories":[],"sub_categories":[],"readme":"# rust-to-npm\n\nDeploy a Rust project to crates.io and npm in one command.\n\nhttps://user-images.githubusercontent.com/8095978/176904499-ef3f5508-1143-491a-bf76-8f240e8b61fb.mov\n\n## Getting Started\n\nConvert and deploy a [Rust](https://www.rust-lang.org) application into a npm package that can be installed on all systems by leveraging cargo.\n\nA valid `license` set if you want to deploy to crates.io (we may auto fill it in the future).\nYou may want to add the following to your `.gitignore` and just reference the project being made with.\n\n```sh\npackage.json\nstart.js\nuninstall.js\npre-install.js\n```\n\n\n## Installation\n\nInstalls can be handled with cargo or npm using the following:\n\n```sh\n# install with cargo\ncargo install rust-to-npm-cli\n# install with npm\nnpm i rust-to-npm-cli -g\n```\n\nYou can also use the crate directly at [rust-to-npm](./rust-to-npm/) with `cargo install rust-to-npm`.\n\n## Account Login\n\nThe cargo crates and npm packages you are deploying should be linked to an account for their respective package managers.\n\nLogin to your crates.io account:\n```sh\ncargo login\n```\n\nLogin to your npm account:\n```sh\nnpm adduser\n```\n\n## Usage\n\nRun the command inside the repo with the Cargo.toml file to deploy to [crates.io](https://crates.io/) and [npm](https://www.npmjs.com/).\n\n```sh\n# to build locally without deploying\nrust-to-npm-cli build\n# to build and deploy to cargo + npm\nrust-to-npm-cli deploy -b\n```\n\nYou can also pass in the `-n` option on `build \u0026 deploy` in order to use a custom npm package name ex: `rust-to-npm-cli build -n @myorg/rust-to-npm-cli`\n\n### Consuming\n\nTo use the node_module you just published run `npm i $PACKAGE_NAME --features=somefeature,nextfeature`.\n\nThen use it via node `node node_modules/$PACKAGE_NAME/start.js`. Replace `$PACKAGE_NAME` with your package name as kebab case.\nYou can also import the module directly at root as a normal module in js like `require(\"node_modules/$PACKAGE_NAME\")`.\nThe features arg is an optional comma seperated list to use for cargo.\n\n## Goals\n\n1. Easy convert installs to `npm`.\n1. Allows full transparency of Rust code that user installs instead of dangerous binaries.\n\n## Steps on how it works\n\n1. convert Cargo.toml to package.json equivalent.\n1. `pre-install` script that builds the rust project to the OS.\n1. `start` script that executes the binary easily in nodejs.\n1. `uninstall` script that removes the binary.\n\nHere is an example of the output from the Cargo.toml to package.json file in the repo.\n\n```toml\n[package]\n\nname = \"rust-to-npm-cli\"\nversion = \"0.4.10\"\nedition = \"2021\"\ndescription = \"ship a rust project to npm on all operating systems leveraging cargo.\"\nrepository = \"https://github.com/a11ywatch/rust-to-npm\"\nreadme = \"README.md\"\nkeywords = [\"rust-to-npm-cli\", \"deploy-rust\", \"npm\", \"rust\"]\ncategories = [\"command-line-utilities\", \"development-tools::build-utils\"]\nlicense = \"MIT\"\nhomepage = \"https://github.com/a11ywatch/rust-to-npm\"\nauthors = [\"Jeff Mendez\"]\n\n[dependencies]\n\nserde = { version = \"1\", features=[\"derive\"]}\nserde_derive = \"1.0.137\"\ntoml = \"0.5.9\"\n```\n\n```json\n{\n  \"name\": \"rust-to-npm-cli\",\n  \"version\": \"0.4.10\",\n  \"description\": \"ship a rust project to npm on all operating systems leveraging cargo.\",\n  \"main\": \"start.js\",\n  \"directories\": {\n    \"test\": \"tests\"\n  },\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" \u0026\u0026 exit 1\",\n    \"postinstall\": \"node ./pre-install.js\",\n    \"uninstall\": \"node ./uninstall.js\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/a11ywatch/rust-to-npm-cli.git\"\n  },\n  \"keywords\": [\"rust-to-npm-cli\", \"deploy-rust\", \"npm\", \"rust\"],\n  \"author\": \"Jeff Mendez\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/a11ywatch/rust-to-npm-cli/issues\"\n  },\n  \"homepage\": \"https://github.com/a11ywatch/rust-to-npm-cli\",\n  \"files\": [\n    \"pre-install.js\",\n    \"start.js\",\n    \"uninstall.js\",\n    \"README.md\",\n    \"LICENSE\"\n  ]\n}\n```\n\n## Options\n\nRun the CLI with `--npm_package_name` in order to add a custom package name for npm to use ( good for org packages ).\nUse `--source` for shipping and compiling the project from source code.\n\n## About\n\nThis project is used to convert the [A11yWatch CLI](https://github.com/a11ywatch/a11ywatch) for usage in node.\n\nSee example usage converting the [rust crawler](https://github.com/a11ywatch/crawler) library as a sidecar into a [node project](https://github.com/a11ywatch/sidecar).\n\nFor shipping projects to github and releasing with binary installs check out the [cargo-dist](https://github.com/axodotdev/cargo-dist) project.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa11ywatch%2Frust-to-npm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa11ywatch%2Frust-to-npm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa11ywatch%2Frust-to-npm/lists"}