https://github.com/optum/semver-sort
Deno module and cli tool for semantically sorting a set of version strings.
https://github.com/optum/semver-sort
Last synced: about 1 month ago
JSON representation
Deno module and cli tool for semantically sorting a set of version strings.
- Host: GitHub
- URL: https://github.com/optum/semver-sort
- Owner: Optum
- License: apache-2.0
- Created: 2022-09-16T17:28:15.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-11T14:24:08.000Z (about 3 years ago)
- Last Synced: 2024-05-02T04:27:20.708Z (about 2 years ago)
- Language: TypeScript
- Size: 31.3 KB
- Stars: 1
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# `semver-sort` 🦕
Sorts a set of version strings semantically
## Usage
`semver-sort` can be used from code or from the cli directly.
### api
```ts
import * as semver from "https://deno.land/std@0.155.0/semver/mod.ts";
import { semverSort } from "https://deno.land/x/semver_sort@0.1.3/mod.ts";
const sorted: { version: string; semver: SemVer }[] = semverSort(
"1.12.0",
"1.7",
"2",
"1.13.0",
);
// 2, 1.13.0, 1.12.0, 1.7
```
### cli
Pass line delimited version strings as stdin to have them sorted.
```sh
cat test.txt | deno run "https://deno.land/x/semver_sort@0.1.3/main.ts"
```
##### install
```sh
deno install "https://deno.land/x/semver_sort@0.1.3/main.ts" -n semver-sort
cat test.txt | semver-sort
```
##### get the latest version
```sh
cat test.txt | semver-sort | head -n 1
```
##### get all versions except the latest
```sh
cat test.txt | semver-sort | tail -n +2
```
## Contributing
- [License](./LICENSE)
- [Code of Conduct](./CODE_OF_CONDUCT.md)
- [Individual Contributor License](./INDIVIDUAL_CONTRIBUTOR_LICENSE.md)
- [Contributing](./CONTRIBUTING.md)
## License
Distributed under the Apache 2.0 License. See [`LICENSE`](./LICENSE) for more
information.
## Maintainers
- Justin Chase
- GitHub: [justinmchase](https://github.com/justinmchase)
- Email: justin.chase@optum.com