-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82efa27
commit 0da9c40
Showing
14 changed files
with
240 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Checks | ||
|
||
on: | ||
pull_request: | ||
branches: [ main ] | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@master | ||
- uses: uhg-actions/[email protected] | ||
with: | ||
deno-version: v1.x | ||
- run: deno --version | ||
- run: deno fmt --check | ||
- run: deno lint | ||
- run: deno test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
<Insert Project Name Here> | ||
semver-sort | ||
|
||
Copyright 2022 Optum | ||
|
||
Project Description: | ||
==================== | ||
<Short description of your project> | ||
Deno module and cli tool for semantically sorting a set of version strings. | ||
|
||
Author(s): | ||
<List the names and GitHub IDs of the original project authors> | ||
Justin Chase (@justinmchase) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,229 +1,70 @@ | ||
<div id="top"></div> | ||
|
||
<!-- NOTES --> | ||
<!-- | ||
*** Individual sections below can be removed if not needed | ||
--> | ||
|
||
<!-- PROJECT SHIELDS --> | ||
<!-- | ||
*** We are using markdown "reference style" links for readability. | ||
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ). | ||
*** See the bottom of this document for the declaration of the reference variables | ||
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use. | ||
*** https://www.markdownguide.org/basic-syntax/#reference-style-links | ||
--> | ||
[![Contributors][contributors-shield]][contributors-url] | ||
[![Forks][forks-shield]][forks-url] | ||
[![Stargazers][stars-shield]][stars-url] | ||
[![Issues][issues-shield]][issues-url] | ||
[![MIT License][license-shield]][license-url] | ||
[![LinkedIn][linkedin-shield]][linkedin-url] | ||
|
||
|
||
|
||
<!-- PROJECT LOGO --> | ||
<br /> | ||
<div align="center"> | ||
<a href="https://github.com/github_username/repo_name"> | ||
<img src="images/logo.png" alt="Logo" width="80" height="80"> | ||
</a> | ||
|
||
<h3 align="center">project_title</h3> | ||
|
||
<p align="center"> | ||
project_description | ||
<br /> | ||
<a href="https://github.com/github_username/repo_name"><strong>Explore the docs »</strong></a> | ||
<br /> | ||
<br /> | ||
<a href="https://github.com/github_username/repo_name">View Demo</a> | ||
· | ||
<a href="https://github.com/github_username/repo_name/issues">Report Bug</a> | ||
· | ||
<a href="https://github.com/github_username/repo_name/issues">Request Feature</a> | ||
</p> | ||
</div> | ||
|
||
|
||
|
||
<!-- TABLE OF CONTENTS --> | ||
<details> | ||
<summary>Table of Contents</summary> | ||
<ol> | ||
<li> | ||
<a href="#about-the-project">About The Project</a> | ||
<ul> | ||
<li><a href="#built-with">Built With</a></li> | ||
</ul> | ||
</li> | ||
<li> | ||
<a href="#getting-started">Getting Started</a> | ||
<ul> | ||
<li><a href="#prerequisites">Prerequisites</a></li> | ||
<li><a href="#installation">Installation</a></li> | ||
</ul> | ||
</li> | ||
<li><a href="#usage">Usage</a></li> | ||
<li><a href="#roadmap">Roadmap</a></li> | ||
<li><a href="#contributing">Contributing</a></li> | ||
<li><a href="#license">License</a></li> | ||
<li><a href="#contact">Contact</a></li> | ||
<li><a href="#acknowledgments">Acknowledgments</a></li> | ||
</ol> | ||
</details> | ||
|
||
|
||
|
||
<!-- ABOUT THE PROJECT --> | ||
## About The Project | ||
|
||
[![Product Name Screen Shot][product-screenshot]](https://example.com) | ||
|
||
Here's a blank template to get started: To avoid retyping too much info. Do a search and replace with your text editor for the following: `github_username`, `repo_name`, `twitter_handle`, `linkedin_username`, `email`, `email_client`, `project_title`, `project_description` | ||
|
||
<p align="right">(<a href="#top">back to top</a>)</p> | ||
|
||
|
||
|
||
### Built With | ||
|
||
* [Next.js](https://nextjs.org/) | ||
* [React.js](https://reactjs.org/) | ||
* [Vue.js](https://vuejs.org/) | ||
* [Angular](https://angular.io/) | ||
* [Svelte](https://svelte.dev/) | ||
* [Laravel](https://laravel.com) | ||
* [Bootstrap](https://getbootstrap.com) | ||
* [JQuery](https://jquery.com) | ||
|
||
<p align="right">(<a href="#top">back to top</a>)</p> | ||
|
||
|
||
|
||
<!-- GETTING STARTED --> | ||
## Getting Started | ||
|
||
This is an example of how you may give instructions on setting up your project locally. | ||
To get a local copy up and running follow these simple example steps. | ||
|
||
### Prerequisites | ||
|
||
This is an example of how to list things you need to use the software and how to install them. | ||
* npm | ||
```sh | ||
npm install npm@latest -g | ||
``` | ||
# `semver-sort` 🦕 | ||
|
||
### Installation | ||
Sorts a set of version strings semantically | ||
|
||
1. Get a free API Key at [https://example.com](https://example.com) | ||
2. Clone the repo | ||
```sh | ||
git clone https://github.com/github_username/repo_name.git | ||
``` | ||
3. Install NPM packages | ||
```sh | ||
npm install | ||
``` | ||
4. Enter your API in `config.js` | ||
```js | ||
const API_KEY = 'ENTER YOUR API'; | ||
``` | ||
|
||
<p align="right">(<a href="#top">back to top</a>)</p> | ||
|
||
|
||
|
||
<!-- USAGE EXAMPLES --> | ||
## Usage | ||
|
||
Use this space to show useful examples of how a project can be used. Additional screenshots, code examples and demos work well in this space. You may also link to more resources. | ||
|
||
_For more examples, please refer to the [Documentation](https://example.com)_ | ||
`semver-sort` can be used from code or from the cli directly. | ||
|
||
<p align="right">(<a href="#top">back to top</a>)</p> | ||
### api | ||
|
||
```ts | ||
import * as semver from "https://deno.land/[email protected]/semver/mod.ts"; | ||
import { semverSort } from "https://deno.land/x/[email protected]/mod.ts"; | ||
|
||
const sorted: { version: string; semver: SemVer }[] = semverSort( | ||
"1.12.0", | ||
"1.7", | ||
"2", | ||
"1.13.0", | ||
); | ||
|
||
<!-- ROADMAP --> | ||
## Roadmap | ||
// 2, 1.13.0, 1.12.0, 1.7 | ||
``` | ||
|
||
- [] Feature 1 | ||
- [] Feature 2 | ||
- [] Feature 3 | ||
- [] Nested Feature | ||
### cli | ||
|
||
See the [open issues](https://github.com/github_username/repo_name/issues) for a full list of proposed features (and known issues). | ||
Pass line delimited version strings as stdin to have them sorted. | ||
|
||
<p align="right">(<a href="#top">back to top</a>)</p> | ||
```sh | ||
cat test.txt | deno run "https://deno.land/x/[email protected]/main.ts" | ||
``` | ||
|
||
##### install | ||
|
||
```sh | ||
deno install "https://deno.land/x/[email protected]/main.ts" -n semver-sort | ||
cat test.txt | semver-sort | ||
``` | ||
|
||
<!-- CONTRIBUTING --> | ||
## Contributing | ||
##### get the latest version | ||
|
||
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. | ||
```sh | ||
cat test.txt | semver-sort | head -n 1 | ||
``` | ||
|
||
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". | ||
Don't forget to give the project a star! Thanks again! | ||
##### get all versions except the latest | ||
|
||
1. Fork the Project | ||
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) | ||
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) | ||
4. Push to the Branch (`git push origin feature/AmazingFeature`) | ||
5. Open a Pull Request | ||
|
||
<p align="right">(<a href="#top">back to top</a>)</p> | ||
```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 --> | ||
## License | ||
|
||
Distributed under the Apache 2.0 License. See `LICENSE.txt` for more information. | ||
|
||
<p align="right">(<a href="#top">back to top</a>)</p> | ||
|
||
|
||
Distributed under the Apache 2.0 License. See [`LICENSE`](./LICENSE) for more | ||
information. | ||
|
||
<!-- MAINTAINERS --> | ||
## Maintainers | ||
|
||
- Full Name 1 | ||
- GitHub Enterprise: [github_username](https://github.com/username1) | ||
- Email: [email protected] | ||
- Full Name 2 | ||
- GitHub Enterprise: [github_username](https://github.com/username2) | ||
- Email: [email protected] | ||
|
||
<p align="right">(<a href="#top">back to top</a>)</p> | ||
|
||
|
||
|
||
<!-- ACKNOWLEDGMENTS --> | ||
## Acknowledgments | ||
|
||
* []() | ||
* []() | ||
* []() | ||
|
||
<p align="right">(<a href="#top">back to top</a>)</p> | ||
|
||
|
||
## Maintainers | ||
|
||
<!-- MARKDOWN LINKS & IMAGES --> | ||
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --> | ||
[contributors-shield]: https://img.shields.io/github/contributors/github_username/repo_name.svg?style=for-the-badge | ||
[contributors-url]: https://github.com/github_username/repo_name/graphs/contributors | ||
[forks-shield]: https://img.shields.io/github/forks/github_username/repo_name.svg?style=for-the-badge | ||
[forks-url]: https://github.com/github_username/repo_name/network/members | ||
[stars-shield]: https://img.shields.io/github/stars/github_username/repo_name.svg?style=for-the-badge | ||
[stars-url]: https://github.com/github_username/repo_name/stargazers | ||
[issues-shield]: https://img.shields.io/github/issues/github_username/repo_name.svg?style=for-the-badge | ||
[issues-url]: https://github.com/github_username/repo_name/issues | ||
[license-shield]: https://img.shields.io/github/license/github_username/repo_name.svg?style=for-the-badge | ||
[license-url]: https://github.com/github_username/repo_name/blob/master/LICENSE.txt | ||
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555 | ||
[linkedin-url]: https://linkedin.com/in/linkedin_username | ||
[product-screenshot]: images/screenshot.png | ||
- Justin Chase | ||
- GitHub: [justinmchase](https://github.com/justinmchase) | ||
- Email: [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "./std.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export * as semver from "https://deno.land/[email protected]/semver/mod.ts"; | ||
export type { SemVer } from "https://deno.land/[email protected]/semver/mod.ts"; | ||
|
||
export { readAll } from "https://deno.land/[email protected]/streams/conversion.ts"; | ||
|
||
export { | ||
assertEquals, | ||
assertObjectMatch, | ||
assertThrows, | ||
} from "https://deno.land/[email protected]/testing/asserts.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { readAll } from "./deps/std.ts"; | ||
import { semverSort } from "./src/mod.ts"; | ||
|
||
const input = await readAll(Deno.stdin); | ||
const lines = await new TextDecoder().decode(input); | ||
const versions = lines | ||
.split(/\r\n|\n|\s|,/) | ||
.map((l) => l.trim()) | ||
.filter((l) => l); | ||
|
||
for (const { version } of semverSort(...versions)) { | ||
console.log(version); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./src/mod.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from "./parse.ts"; | ||
export * from "./sort.ts"; | ||
export * from "./version.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { assertEquals, assertThrows, semver } from "../deps/std.ts"; | ||
import { parse } from "./parse.ts"; | ||
|
||
Deno.test({ | ||
name: "PARSE00", | ||
fn: () => { | ||
const v = parse("1"); | ||
assertEquals(v.toString(), "1.0.0"); | ||
}, | ||
}); | ||
Deno.test({ | ||
name: "PARSE01", | ||
fn: () => { | ||
const v = parse("1.0"); | ||
assertEquals(v.toString(), "1.0.0"); | ||
}, | ||
}); | ||
Deno.test({ | ||
name: "PARSE02", | ||
fn: () => { | ||
const v = parse("1.0.0"); | ||
assertEquals(v.toString(), "1.0.0"); | ||
}, | ||
}); | ||
Deno.test({ | ||
name: "PARSE03", | ||
fn: () => { | ||
const v = parse("1.0.0-tst.0"); | ||
assertEquals(v.toString(), "1.0.0-tst.0"); | ||
}, | ||
}); | ||
Deno.test({ | ||
name: "PARSE04", | ||
fn: () => { | ||
assertThrows(() => parse("abc")); | ||
}, | ||
}); | ||
Deno.test({ | ||
name: "PARSE05", | ||
fn: () => { | ||
const v = new semver.SemVer("1.2.3"); | ||
assertEquals(parse(v), v); | ||
}, | ||
}); |
Oops, something went wrong.