1
Fork 0
npm2git/README.md

29 lines
1.7 KiB
Markdown
Raw Normal View History

2018-10-04 01:49:03 +00:00
# npm2git
2018-10-04 14:21:24 +00:00
2018-10-07 01:31:13 +00:00
Use Git as an npm registry
2018-10-04 14:21:24 +00:00
## Why
2018-10-07 01:31:13 +00:00
Managing npm registries sucks. (And arguably, depending on a central privately-controlled npm registry also sucks.) If you're thinking you want or need to run one, then you almost certainly already have a Git server available with all the appropriate users and permissions and everything. npm supports resolving semver ranges against Git tags, so there's no longer a good reason not to abuse Git to deliver built assets.
2018-10-04 14:21:24 +00:00
## How
2018-10-07 01:31:13 +00:00
This shell script creates and tags an orphaned commit that includes only the files that would be included by `npm publish`. Before doing so, it also removes the `prepare` script from `package.json`, if present. When npm installs from a Git repository with a `prepare` script, it will also temporarily install `devDependencies` and run the `prepare` script, which generally would build the project. What they're getting is already the built files, so we don't want that to happen.
2018-10-04 14:21:24 +00:00
## Usage
2018-10-07 01:31:13 +00:00
1. Make sure you're ready to go. The `version` field in your `package.json` should already be incremented, and the `files` field should point to everything you want to publish.
2018-10-04 15:01:32 +00:00
1. Run `npm2git.sh`. This creates the orphaned commit and tags it `vX.X.X`, but does not push it. Inspect the tag to make sure all seems well.
2018-10-04 14:21:24 +00:00
1. Push the tag.
2018-11-10 17:34:06 +00:00
1. Optionally, also push the `vX.X.X-src` tag, which points to the original source that the `vX.X.X` tag was built from.
2018-10-04 14:21:24 +00:00
## Installing from Git
2018-10-07 01:31:13 +00:00
See [the npm docs on `npm install`](https://docs.npmjs.com/cli/install) for more on how to install from Git repositories. Specify a version either by tag (`#vX.X.X`) or by semver specification (`#semver:*`).
2018-10-04 14:21:24 +00:00
## License
Copyright (c) 2018 Conduitry
- [MIT](LICENSE)