This commit is contained in:
2019-09-17 13:20:42 -04:00
parent d211d1dc34
commit bef10ce4c9
8352 changed files with 568242 additions and 51 deletions
+26
View File
@@ -0,0 +1,26 @@
# .editorconfig <https://github.com/tunnckoCore/dotfiles>
#
# Copyright (c) 2015 Charlike Mike Reagent, contributors.
# Released under the MIT license.
#
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
[*.js]
insert_final_newline = true
trim_trailing_whitespace = true
[*.php]
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
+56
View File
@@ -0,0 +1,56 @@
# .gitignore <https://github.com/tunnckoCore/dotfiles>
#
# Copyright (c) 2015 Charlike Mike Reagent, contributors.
# Released under the MIT license.
#
# Always-ignore dirs #
# ####################
_gh_pages
node_modules
bower_components
components
vendor
build
dest
dist
src
lib-cov
coverage
nbproject
cache
temp
tmp
parse-semver
# Packages #
# ##########
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# OS, Logs and databases #
# #########################
*.pid
*.dat
*.log
*.sql
*.sqlite
*~
~*
# Another files #
# ###############
Icon?
.DS_Store*
Thumbs.db
ehthumbs.db
Desktop.ini
npm-debug.log
.directory
._*
+25
View File
@@ -0,0 +1,25 @@
language: "node_js"
sudo: false
node_js:
- "0.10"
- "0.12"
- "1"
- "2"
notifications:
email:
on_success: never
on_failure: never
before_script:
- npm install standard
- standard
script:
- npm install istanbul-harmony
- node --harmony node_modules/.bin/istanbul cover test.js
after_success:
- npm install coveralls
- cat ./coverage/lcov.info | coveralls
+27
View File
@@ -0,0 +1,27 @@
## 1.1.1 / 2016-02-23
- Release v1.1.1 / npm@v1.1.1
- update license year
- update semver to `^5.1.0`
- add support for scoped shorthands e.g. `@user/package@~2.2.5` (PR [#2](https://github.com/tunnckoCore/parse-semver/pull/2 "Support scoped packages"))
## 1.1.0 / 2015-07-19
- Release v1.1.0 / npm@v1.1.0
- add related section
- update docs
- bump `semver@5`
- update
## 1.0.1 / 2015-04-17
- Release v1.0.1 / npm@v1.0.1
- bump `semver@~4.3.3`
## 1.0.0 / 2015-03-26
- Release v1.0.0 / npm@v1.0.0
- run keywords(1)
- run docks(1)
- **update** deps, polyfill
## 0.0.0 / 2015-03-26
- first commits / npm@v0.0.0
+32
View File
@@ -0,0 +1,32 @@
# Contributing Guidelines
Contributions are always welcome!
**Before spending lots of time on something, ask for feedback on your idea first!**
Please search issues and pull requests before adding something new to avoid duplicating efforts and conversations.
## Installing
Fork and clone the repo, then `npm install` to install all dependencies and `npm test` to ensure all is okey before you start anything.
## Testing
Tests are run with `npm test`. Please ensure all tests are passing before submitting a pull request (unless you're creating a failing test to increase test coverage or show a problem).
## Code Style
[![standard][standard-image]][standard-url]
This repository uses [`standard`][standard-url] to maintain code style and consistency, and to avoid style arguments. You are encouraged to install it globally. `npm test` runs `standard` so you don't have to!
```
npm i standard -g
```
It is intentional to don't have `standard`, `istanbul` and `coveralls` in the devDependencies. Travis will handle all that stuffs. That approach will save bandwidth also installing and development time.
[standard-image]: https://cdn.rawgit.com/feross/standard/master/badge.svg
[standard-url]: https://github.com/feross/standard
+21
View File
@@ -0,0 +1,21 @@
# The MIT License
Copyright (c) 2015-2016 [Charlike Make Reagent](http://j.mp/1stW47C)
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
+104
View File
@@ -0,0 +1,104 @@
# [parse-semver][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url]
> Parse, normalize and validate given semver shorthand (e.g. gulp@v3.8.10) to object.
[![code climate][codeclimate-img]][codeclimate-url] [![standard code style][standard-img]][standard-url] [![travis build status][travis-img]][travis-url] [![coverage status][coveralls-img]][coveralls-url] [![dependency status][david-img]][david-url]
## Install
```
npm i parse-semver --save
npm test
```
## API
> For more use-cases see the [tests](./test.js)
### [parseSemver](./index.js#L40)
> It returns object with `original` version given, expanded semver `range`, and `version`
which is valid [semver](http://npm.im/semver) version.
- `<shorthand>` **{String}** the shorthand to parse, like `docks@v2.2.0`
- `return` **{Object}** object with few properties
**Example**
```js
var parseSemver = require('parse-semver')
parseSemver('docks@~3.4.5')
//=> {name: 'docks', original: '~3.4.5', range: '>=3.4.5 <3.5.0', version: '3.4.5'}
parseSemver('docks@v1.2.3')
//=> {name: 'docks', original: 'v1.2.3', range: '1.2.3', version: '1.2.3'}
parseSemver('docks@^2.2.2')
//=> {name: 'docks', original: '^2.2.2', range: '>=2.2.2 <3.0.0', version: '2.2.2'}
parseSemver('docks')
//=> {name: 'docks', original: '', range: '*', version: 'latest'}
```
## Related
- [benz](https://github.com/tunnckocore/benz): Compose your control flow with absolute elegance. Support async/await, callbacks, thunks, generators,… [more](https://github.com/tunnckocore/benz)
- [parse-git-log](https://github.com/tunnckoCore/parse-git-log): Parse default `git log` style to array of objects from git repository… [more](https://github.com/tunnckoCore/parse-git-log)
- [parse-github-url](https://github.com/jonschlinkert/parse-github-url): Parse a github URL into an object.
- [parse-git-config](https://github.com/jonschlinkert/parse-git-config): Parse `.git/config` into a JavaScript object. sync or async.
- [vez](https://github.com/tunnckocore/vez): Middleware composition at new level. Ultimate alternative to `ware`, `plugins`, `koa-compose` and… [more](https://github.com/tunnckocore/vez)
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/tunnckoCore/parse-semver/issues/new).
But before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines.
## [Charlike Make Reagent](http://j.mp/1stW47C) [![new message to charlike][new-message-img]][new-message-url] [![freenode #charlike][freenode-img]][freenode-url]
[![tunnckocore.tk][author-www-img]][author-www-url] [![keybase tunnckocore][keybase-img]][keybase-url] [![tunnckoCore npm][author-npm-img]][author-npm-url] [![tunnckoCore twitter][author-twitter-img]][author-twitter-url] [![tunnckoCore github][author-github-img]][author-github-url]
[npmjs-url]: https://www.npmjs.com/package/parse-semver
[npmjs-img]: https://img.shields.io/npm/v/parse-semver.svg?label=parse-semver
[license-url]: https://github.com/tunnckoCore/parse-semver/blob/master/LICENSE.md
[license-img]: https://img.shields.io/badge/license-MIT-blue.svg
[codeclimate-url]: https://codeclimate.com/github/tunnckoCore/parse-semver
[codeclimate-img]: https://img.shields.io/codeclimate/github/tunnckoCore/parse-semver.svg
[travis-url]: https://travis-ci.org/tunnckoCore/parse-semver
[travis-img]: https://img.shields.io/travis/tunnckoCore/parse-semver.svg
[coveralls-url]: https://coveralls.io/r/tunnckoCore/parse-semver
[coveralls-img]: https://img.shields.io/coveralls/tunnckoCore/parse-semver.svg
[david-url]: https://david-dm.org/tunnckoCore/parse-semver
[david-img]: https://img.shields.io/david/tunnckoCore/parse-semver.svg
[standard-url]: https://github.com/feross/standard
[standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
[author-www-url]: http://www.tunnckocore.tk
[author-www-img]: https://img.shields.io/badge/www-tunnckocore.tk-fe7d37.svg
[keybase-url]: https://keybase.io/tunnckocore
[keybase-img]: https://img.shields.io/badge/keybase-tunnckocore-8a7967.svg
[author-npm-url]: https://www.npmjs.com/~tunnckocore
[author-npm-img]: https://img.shields.io/badge/npm-~tunnckocore-cb3837.svg
[author-twitter-url]: https://twitter.com/tunnckoCore
[author-twitter-img]: https://img.shields.io/badge/twitter-@tunnckoCore-55acee.svg
[author-github-url]: https://github.com/tunnckoCore
[author-github-img]: https://img.shields.io/badge/github-@tunnckoCore-4183c4.svg
[freenode-url]: http://webchat.freenode.net/?channels=charlike
[freenode-img]: https://img.shields.io/badge/freenode-%23charlike-5654a4.svg
[new-message-url]: https://github.com/tunnckoCore/messages
[new-message-img]: https://img.shields.io/badge/send%20me-message-green.svg
+67
View File
@@ -0,0 +1,67 @@
/*!
* parse-semver <https://github.com/tunnckoCore/parse-semver>
*
* Copyright (c) 2015-2016 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)
* Released under the MIT license.
*/
'use strict'
var semver = require('semver')
/**
* It returns object with `original` version given, expanded semver `range`,
* and `version` which is valid [semver] version.
*
* **Example**
*
* ```js
* var parseSemver = require('parse-semver')
*
* parseSemver('docks@~3.4.5')
* //=> {name: 'docks', original: '~3.4.5', range: '>=3.4.5 <3.5.0', version: '3.4.5'}
*
* parseSemver('docks@v1.2.3')
* //=> {name: 'docks', original: 'v1.2.3', range: '1.2.3', version: '1.2.3'}
*
* parseSemver('docks@^2.2.2')
* //=> {name: 'docks', original: '^2.2.2', range: '>=2.2.2 <3.0.0', version: '2.2.2'}
*
* parseSemver('docks')
* //=> {name: 'docks', original: '', range: '*', version: 'latest'}
* ```
*
* @name parseSemver
* @param {String} `<shorthand>` the shorthand to parse, like `mocha@v2.2.0`
* @return {Object} object with `name` and `version` properties
* @api public
*/
module.exports = function parseSemver (shorthand) {
if (typeof shorthand !== 'string') {
throw new TypeError('parse-semver: expect `shorthand` to be string')
}
shorthand = shorthand.split('@')
if (shorthand[0] === '') {
shorthand.shift()
shorthand[0] = '@' + shorthand[0]
}
var name = shorthand[0]
var version = shorthand[1] || ''
var range = semver.validRange(version) || ''
if (version.length && range.length === 0) {
throw new Error('parse-semver: not valid semver range/version given')
}
var ver = version.replace(/^[^0-9]+/, '')
return {
name: name,
range: range,
version: ver.length === 0 ? 'latest' : ver,
original: version
}
}
+1
View File
@@ -0,0 +1 @@
../../../semver/bin/semver
+37
View File
@@ -0,0 +1,37 @@
{
"name": "parse-semver",
"version": "1.1.1",
"description": "Parse, normalize and validate given semver shorthand (e.g. gulp@v3.8.10) to object.",
"repository": "tunnckoCore/parse-semver",
"author": "Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)",
"main": "index.js",
"license": "MIT",
"scripts": {
"test": "standard && node test.js"
},
"dependencies": {
"semver": "^5.1.0"
},
"devDependencies": {
"assertit": "^0.1.0"
},
"keywords": [
"equal",
"helper",
"is",
"kindof",
"normalize",
"npm",
"object",
"parse",
"parser",
"range",
"semver",
"shallow",
"short",
"shorthand",
"utils",
"validate",
"version"
]
}
+112
View File
@@ -0,0 +1,112 @@
/*!
* parse-semver <https://github.com/tunnckoCore/parse-semver>
*
* Copyright (c) 2015-2016 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)
* Released under the MIT license.
*/
/* jshint asi:true */
'use strict'
var test = require('assertit')
var parseSemver = require('./index')
test('parse-semver:', function () {
test('should throw', function () {
test('TypeError when no arguments', function (done) {
function fixture () {
parseSemver()
}
test.throws(fixture, TypeError)
test.throws(fixture, /parse-semver: expect `shorthand` to be string/)
done()
})
test('TypeError when no string given', function (done) {
function fixture () {
parseSemver({foo: 'bar'})
}
test.throws(fixture, TypeError)
test.throws(fixture, /parse-semver: expect `shorthand` to be string/)
done()
})
test('Error when invalid version given', function (done) {
function invalidOne () {
parseSemver('docks@~~>1.2.3')
}
function invalidTwo () {
parseSemver('docks@invalid')
}
test.throws(invalidOne, Error)
test.throws(invalidTwo, Error)
test.throws(invalidOne, /parse-semver: not valid semver/)
test.throws(invalidTwo, /parse-semver: not valid semver/)
done()
})
})
test('should parse and return object', function () {
test('with empty `version` property and non-empty `name` property', function (done) {
var actual = parseSemver('docks')
var expected = {name: 'docks', range: '*', version: 'latest', original: ''}
test.deepEqual(actual, expected)
done()
})
test('with non-empty `name` and `version` properties', function (done) {
var actual = parseSemver('docks@v7.8.9')
var expected = {name: 'docks', range: '7.8.9', version: '7.8.9', original: 'v7.8.9'}
test.deepEqual(actual, expected)
done()
})
test('with scoped package name', function (done) {
var actual = parseSemver('@me/docks@7.8.9')
var expected = {name: '@me/docks', range: '7.8.9', version: '7.8.9', original: '7.8.9'}
test.deepEqual(actual, expected)
done()
})
test('with scoped package name and empty `version`', function (done) {
var actual = parseSemver('@me/docks')
var expected = {name: '@me/docks', range: '*', version: 'latest', original: ''}
test.deepEqual(actual, expected)
done()
})
})
test('should parse, validate and normalize', function () {
test('given `v1.2.3` version to `1.2.3`', function (done) {
var actual = parseSemver('docks@v1.2.3')
var expected = {name: 'docks', original: 'v1.2.3', range: '1.2.3', version: '1.2.3'}
test.deepEqual(actual, expected)
done()
})
test('given `4.5.6` version to `4.5.6`', function (done) {
var actual = parseSemver('docks@4.5.6')
var expected = {name: 'docks', original: '4.5.6', range: '4.5.6', version: '4.5.6'}
test.deepEqual(actual, expected)
done()
})
})
test('should work with different semver ranges', function () {
test('work properly with `^0.5.3`', function (done) {
var actual = parseSemver('docks@^0.5.3')
var expected = {name: 'docks', original: '^0.5.3', range: '>=0.5.3 <0.6.0', version: '0.5.3'}
test.deepEqual(actual, expected)
done()
})
test('work properly with `~3.4.5`', function (done) {
var actual = parseSemver('docks@~3.4.5')
var expected = {name: 'docks', original: '~3.4.5', range: '>=3.4.5 <3.5.0', version: '3.4.5'}
test.deepEqual(actual, expected)
done()
})
})
})