{"_id":"@ayoisaiah/go-npm","_rev":"1-0ff15278a88c99adc7a4485568fbf1dc","name":"@ayoisaiah/go-npm","dist-tags":{"latest":"0.1.13"},"versions":{"0.1.13":{"name":"@ayoisaiah/go-npm","version":"0.1.13","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":"Sanath Kumar Ramesh","email":"dayanandasaraswati@gmail.com"},"license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/ayoisaiah/go-npm.git"},"homepage":"https://github.com/ayoisaiah/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":"0c1e81f47170e2b6432955e014b1b9f5093b523e","bugs":{"url":"https://github.com/ayoisaiah/go-npm/issues"},"_id":"@ayoisaiah/go-npm@0.1.13","_nodeVersion":"16.14.0","_npmVersion":"8.3.1","dist":{"integrity":"sha512-vw3ZlF+EM9077B7IKhXDkpy8yHG7ZzMq8sZIY9rSfXF1dohBpd/ygcEuu1/+IbDppKmNzlg/0zGDbyu2kLDLbA==","shasum":"68505359997d6c10339610c3d42e918bc05c6f75","tarball":"https://registry.npmjs.org/@ayoisaiah/go-npm/-/go-npm-0.1.13.tgz","fileCount":5,"unpackedSize":1328185,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiFHuUACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqNAxAAh6soTKJsiS9pnb7xBM6wpWTyEhUVA+Z7CLbQaQHHqGObNIsj\r\ndAn6uS/ZecQYEC4SfO0VAh1XFLiobtVYQIIG8n4tnyd7JVpTpPMvpxPTINsC\r\nlt14ElgmH0+HXii9FVNtc/oAkW8A31iu93XC/KwWsV0Y+7DMyH7qrqbdBmz+\r\npW2GdO9VeuS+6BVrwut9UQofHoJUcDssMesgv/DUYQcaB+M2iTuNqJd3578L\r\n6hb12No1alypyfGbxWtvvU6q5vzYCcLqK7ne3hLvJvVv4T/YyzEsgTqbf9Kz\r\nv+OgdDVINH+fDrGlZmfI7GRDzaJhVKnhsffAbfvSNo3DKA3yUbDIBFU23GU8\r\n4pz+gun4tGSo+zSF+j0MXzkbJzkT62E9nGQLhwhKa/0aBr/hecVBmfxGyv3n\r\n1w9saIe/TR44pV/O10RyFRBWD5IMxni1Ugee1OSQqOigWhhayySvXMOdFW8O\r\nkIZdN44RlKqwaKaXegteLqQp6iSFFt99bLdW1vILAWXYhB9g0aMkr4PKCpHo\r\ngio5XNv0cGWXZShHlY1kpT2iOdr9fEzEkuPCAHMR7TOVP9gUn941AFdFdWtd\r\nnBYtbhYW0VE6EeMFTqM7PXHj7DcSQuzVEmQ9dsjfpkAHHnbWxwcz3dQuhP4w\r\nYdWR7TpQdQEbAaDAn3NnwJZBG9Gr9ut1aFM=\r\n=yzv3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDPvr5ZWhbpMqqd6RQ7I5MUeeWrZg9yWI+XfoGqMLV87gIgSLhlnneTcgNGr+GM63wnPk0dE+0G1CgNbGof3dWo9oo="}]},"_npmUser":{"name":"finallyayo","email":"ayo@freshman.tech"},"directories":{},"maintainers":[{"name":"finallyayo","email":"ayo@freshman.tech"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/go-npm_0.1.13_1645509524208_0.018408528929150014"},"_hasShrinkwrap":false}},"time":{"created":"2022-02-22T05:58:44.148Z","0.1.13":"2022-02-22T05:58:44.445Z","modified":"2022-04-04T17:14:52.847Z"},"maintainers":[{"name":"finallyayo","email":"ayo@freshman.tech"}],"description":"Distribute and install Go binaries via NPM","homepage":"https://github.com/ayoisaiah/go-npm","repository":{"type":"git","url":"git+https://github.com/ayoisaiah/go-npm.git"},"author":{"name":"Sanath Kumar Ramesh","email":"dayanandasaraswati@gmail.com"},"bugs":{"url":"https://github.com/ayoisaiah/go-npm/issues"},"license":"Apache-2.0","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 (`@guidhof/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 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_)\n","readmeFilename":"README.md"}