{"versions":{"0.1.14":{"name":"@endorlabs/go-npm","version":"0.1.14","description":"Distribute and install Go binaries via NPM","main":"index.js","bin":{"go-npm":"bin/index.js"},"scripts":{"test":"jest","build":"rm -rf ./bin && esbuild --bundle src/index.js --outfile=\"./bin/index.js\" --platform=node --target=es6 --minify-whitespace","prepublishOnly":"npm i && npm run build"},"author":{"name":"Endor Labs","email":"npm@endor.ai"},"license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/endorlabs/go-npm.git"},"homepage":"https://github.com/endorlabs/go-npm","devDependencies":{"esbuild":"^0.12.17","jest":"^24.5.0","mkdirp":"^1.0.4","request":"^2.88.2","tar":"^2.2.2","unzipper":"0.10.10"},"gitHead":"97c8ac58d04a410c2af25963dd28492e173c4e91","bugs":{"url":"https://github.com/endorlabs/go-npm/issues"},"_id":"@endorlabs/go-npm@0.1.14","_nodeVersion":"18.17.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-dFPumRwhNXR4DdWLs/r01SjHw+98EUTqQw1q9JuVhpUcM3ruYj+84uJxvfYmKW+85vIAIdJx37YmcNgBR+p0uQ==","shasum":"10f00738e16b2f88e8d1a49c8e46a0724d00f006","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@endorlabs/go-npm/-/go-npm-0.1.14.tgz","fileCount":4,"unpackedSize":1319497,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCZnr5wDOjbOYPytznm8MZLPwPdVavUAeGEXlMZWQk8xAIgPwgmj3vwbLDZrtPbd1JTilceKnJy674xiTy5YmJ1HhQ="}],"size":308111},"_npmUser":{"name":"anonymous","email":"nathanwhughes@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"diamantis@endor.ai"},{"name":"anonymous","email":"seth@sethbro.com"},{"name":"anonymous","email":"nathanwhughes@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/go-npm_0.1.14_1697738912434_0.13033295659151967"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-10-19T18:08:32.760Z","publish_time":1697738912760,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"0.1.14"},"name":"@endorlabs/go-npm","time":{"created":"2023-10-19T22:34:18.759Z","modified":"2023-10-23T20:14:56.601Z","0.1.14":"2023-10-19T18:08:32.760Z"},"readme":"## Go NPM\n\n### (@gzuidhof): MODIFICATIONS FROM BASE `go-npm` PACKAGE\n* Support for zip and non-compressed binaries.\n* Added support for `arm64` architecture.\n* Fix for use on Windows platform (the binary would get placed in the wrong place for consumers).\n* Shipped as a bundle using `esbuild`, removing 70 packages of dependencies (including huge things like Babel). Now your users will only have to download one additional package (`@gzuidhof/go-npm`).\n\n### Distribute cross-platform Go binaries via NPM\n\nApplications written in Golang are portable - you can easily cross-compile binaries that work on Windows, Mac, and Linux. But how do you distribute the binaries to customers? When you publish new releases, how do they update the binary?\n\n**Use NPM to distribute cross-platform Go binaries**\n\n## Kidding me! Why NPM?\n* **Cross-platform**: NPM is the only popular package manager that works cross-platform.\n* **Lower barier to entry**: Most developers have NPM installed already.\n* **Pain free publishing**: It just takes one command to publish - `npm publish`\n* **Dead simple install & update story**: `npm install/update -g your-awesome-app`\n* **Adds $PATH**: NPM will automatically add your binary location to $PATH and generate .cmd file for Windows. Your app just works after installation!\n\n## Okay, tell me how?\n### 1. Publish your binaries\nSetup your Go application to compile and publish binaries to a file server. This could be Github Releases or Amazon S3 or even Dropbox. All you need is a link.\n\nI like to use [GoReleaser](https://github.com/goreleaser/goreleaser) to setup by release process. You create a simple YAML configuration file like this and run `goreleaser` CLI to publish binaries for various platform/architecture combination to Github:\n\n```\n# .goreleaser.yml\n# Build customization\nbuilds:\n  - binary: drum-roll\n    goos:\n      - windows\n      - darwin\n      - linux\n    goarch:\n      - amd64\n```\n\n`go-npm` will pull the appropriate binary for the platform & architecture where the package is being installed.\n\n### 2. Create a package.json file for your NPM app\nTo publish to NPM, you need to create a `package.json` file. You give your application a name, link to Readme, Github repository etc, and more importantly add `go-npm` as a dependency. You can create this file in an empty directory in your project or in a separate Git repository altogether. It is your choice.\n\n**Create package.json**\n\n`$ npm init`\n\nAnswer the questions to create an initial package.json file\n\n**Add go-npm dependency**\n\nFrom the directory containing package.json file, do\n\n`$ npm install @gzuidhof/go-npm --save`\n\nThis will install go-npm under to your package.json file. It will also create a `node_modules` directory where the `go-npm` package is downloaded. You don't need this directory since you are only going to publish the module and not consume it yourself. Let's go ahead and delete it.\n\n`$ rm -r node_modules`\n\n**Add postinstall and preuninstall scripts**\nHere is the magic: You ask to run `go-npm install` after it completes installing your package. This will pull down binaries from Github or Amazon S3 and install in NPM's `bin` directory. Binaries under bin directory are immediately available for use in your Terminal.\n\nEdit `package.json` file and add the following:\n```\n\"scripts\": {\n    \"postinstall\": \"go-npm install\",\n    \"preuninstall\": \"go-npm uninstall\",\n}\n```\n\n`go-npm uninstall` simply deletes the binary from `bin` directory before NPM uninstalls your package.\n\n**Configure your binary path**\n\nYou need to tell `go-npm` where to download the binaries from, and where to install them. Edit `package.json` file and add the following configuration.\n\n```\n\"goBinary\": {\n      \"name\": \"command-name\",\n      \"path\": \"./bin\",\n      \"url\": \"https://github.com/user/my-go-package/releases/download/v{{version}}/myGoPackage_{{version}}_{{platform}}_{{arch}}.tar.gz\"\n```\n\n* *name*: Name of the command users will use to run your binary.\n* *path*: Temporary path where binaries will be downloaded to\n* *url*: HTTP Web server where binaries are hosted.\n\nFollowing variables are available to customize the URL:\n* `{{version}}`: Version number read from  `package.json` file. When you publish your package to NPM, it will use this version number. Ex: 0.0.1\n* `{{platform}}`: `$GOOS` value for the platform\n* `{{arch}}`: `$GOARCH` value for the architecture\n* `{{win_ext}}`: optional `.exe` extension for windows assets.\n\nIf you use `goreleaser` to publish your modules, it will automatically set the right architecture & platform in your URL.\n\n**Publish to NPM**\n\nAll that's left now is publish to NPM. As I promised before, just one command\n\n`$ npm publish`\n\n### 3. Distribute to users\n\nTo install:\n\n`npm install -g your-app-name`\n\nTo Update:\n\n`npm update -g your-app-name`\n\n\n---\n\nWith ❤️ to the community by [Sanath Kumar Ramesh](http://twitter.com/sanathkr_)","users":{}}