parent
052fce1f3f
commit
229f06de58
18
CHANGELOG.md
18
CHANGELOG.md
|
|
@ -1,3 +1,12 @@
|
|||
## [3.9.8](https://github.com/TriPSs/conventional-changelog-action/compare/v3.9.7...v3.9.8) (2021-10-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Downgraded the conventional packages ([052fce1](https://github.com/TriPSs/conventional-changelog-action/commit/052fce1f3fc33b9194f6e7ea5793691128ee732b))
|
||||
|
||||
|
||||
|
||||
## [3.9.7](https://github.com/TriPSs/conventional-changelog-action/compare/v3.9.6...v3.9.7) (2021-10-05)
|
||||
|
||||
|
||||
|
|
@ -34,12 +43,3 @@
|
|||
|
||||
|
||||
|
||||
## [3.9.3](https://github.com/TriPSs/conventional-changelog-action/compare/v3.9.2...v3.9.3) (2021-10-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Remove node_modules and ignore folder ([3ed803a](https://github.com/TriPSs/conventional-changelog-action/commit/3ed803a60bcddc0bf9a18d441c3a1c52bdab2477))
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,87 +1,59 @@
|
|||
{
|
||||
"_from": "ansi-regex@^5.0.1",
|
||||
"_id": "ansi-regex@5.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
||||
"_location": "/ansi-regex",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "ansi-regex@^5.0.1",
|
||||
"name": "ansi-regex",
|
||||
"escapedName": "ansi-regex",
|
||||
"rawSpec": "^5.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^5.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/strip-ansi"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||
"_shasum": "082cb2c89c9fe8659a311a53bd6a4dc5301db304",
|
||||
"_spec": "ansi-regex@^5.0.1",
|
||||
"_where": "/Users/tycho/GIT/Github/conventional-changelog-action/node_modules/strip-ansi",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/chalk/ansi-regex/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Regular expression for matching ANSI escape codes",
|
||||
"devDependencies": {
|
||||
"ava": "^2.4.0",
|
||||
"tsd": "^0.9.0",
|
||||
"xo": "^0.25.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"homepage": "https://github.com/chalk/ansi-regex#readme",
|
||||
"keywords": [
|
||||
"ansi",
|
||||
"styles",
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"tty",
|
||||
"escape",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"command-line",
|
||||
"text",
|
||||
"regex",
|
||||
"regexp",
|
||||
"re",
|
||||
"match",
|
||||
"test",
|
||||
"find",
|
||||
"pattern"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "ansi-regex",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/chalk/ansi-regex.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd",
|
||||
"view-supported": "node fixtures/view-codes.js"
|
||||
},
|
||||
"version": "5.0.1"
|
||||
"name": "ansi-regex",
|
||||
"version": "5.0.1",
|
||||
"description": "Regular expression for matching ANSI escape codes",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/ansi-regex",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd",
|
||||
"view-supported": "node fixtures/view-codes.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"ansi",
|
||||
"styles",
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"tty",
|
||||
"escape",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"command-line",
|
||||
"text",
|
||||
"regex",
|
||||
"regexp",
|
||||
"re",
|
||||
"match",
|
||||
"test",
|
||||
"find",
|
||||
"pattern"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^2.4.0",
|
||||
"tsd": "^0.9.0",
|
||||
"xo": "^0.25.3"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz"
|
||||
,"_integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="
|
||||
,"_from": "ansi-regex@5.0.1"
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
'use strict';
|
||||
module.exports = function (arr, predicate, ctx) {
|
||||
if (typeof Array.prototype.findIndex === 'function') {
|
||||
return arr.findIndex(predicate, ctx);
|
||||
}
|
||||
|
||||
if (typeof predicate !== 'function') {
|
||||
throw new TypeError('predicate must be a function');
|
||||
}
|
||||
|
||||
var list = Object(arr);
|
||||
var len = list.length;
|
||||
|
||||
if (len === 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (predicate.call(ctx, list[i], i, list)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
};
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"name": "array-find-index",
|
||||
"version": "1.0.2",
|
||||
"description": "ES2015 `Array#findIndex()` ponyfill",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/array-find-index",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"es2015",
|
||||
"ponyfill",
|
||||
"polyfill",
|
||||
"shim",
|
||||
"find",
|
||||
"index",
|
||||
"findindex",
|
||||
"array"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz"
|
||||
,"_integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E="
|
||||
,"_from": "array-find-index@1.0.2"
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
# array-find-index [](https://travis-ci.org/sindresorhus/array-find-index)
|
||||
|
||||
> ES2015 [`Array#findIndex()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex) [ponyfill](https://ponyfill.com)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save array-find-index
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const arrayFindIndex = require('array-find-index');
|
||||
|
||||
arrayFindIndex(['rainbow', 'unicorn', 'pony'], x => x === 'unicorn');
|
||||
//=> 1
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
Same as `Array#findIndex()`, but with the input array as the first argument.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [7.0.4](https://www.github.com/yargs/cliui/compare/v7.0.3...v7.0.4) (2020-11-08)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deno:** import UIOptions from definitions ([#97](https://www.github.com/yargs/cliui/issues/97)) ([f04f343](https://www.github.com/yargs/cliui/commit/f04f3439bc78114c7e90f82ff56f5acf16268ea8))
|
||||
|
||||
### [7.0.3](https://www.github.com/yargs/cliui/compare/v7.0.2...v7.0.3) (2020-10-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **exports:** node 13.0 and 13.1 require the dotted object form _with_ a string fallback ([#93](https://www.github.com/yargs/cliui/issues/93)) ([eca16fc](https://www.github.com/yargs/cliui/commit/eca16fc05d26255df3280906c36d7f0e5b05c6e9))
|
||||
|
||||
### [7.0.2](https://www.github.com/yargs/cliui/compare/v7.0.1...v7.0.2) (2020-10-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **exports:** node 13.0-13.6 require a string fallback ([#91](https://www.github.com/yargs/cliui/issues/91)) ([b529d7e](https://www.github.com/yargs/cliui/commit/b529d7e432901af1af7848b23ed6cf634497d961))
|
||||
|
||||
### [7.0.1](https://www.github.com/yargs/cliui/compare/v7.0.0...v7.0.1) (2020-08-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **build:** main should be build/index.cjs ([dc29a3c](https://www.github.com/yargs/cliui/commit/dc29a3cc617a410aa850e06337b5954b04f2cb4d))
|
||||
|
||||
## [7.0.0](https://www.github.com/yargs/cliui/compare/v6.0.0...v7.0.0) (2020-08-16)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* tsc/ESM/Deno support (#82)
|
||||
* modernize deps and build (#80)
|
||||
|
||||
### Build System
|
||||
|
||||
* modernize deps and build ([#80](https://www.github.com/yargs/cliui/issues/80)) ([339d08d](https://www.github.com/yargs/cliui/commit/339d08dc71b15a3928aeab09042af94db2f43743))
|
||||
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* tsc/ESM/Deno support ([#82](https://www.github.com/yargs/cliui/issues/82)) ([4b777a5](https://www.github.com/yargs/cliui/commit/4b777a5fe01c5d8958c6708695d6aab7dbe5706c))
|
||||
|
||||
## [6.0.0](https://www.github.com/yargs/cliui/compare/v5.0.0...v6.0.0) (2019-11-10)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* update deps, drop Node 6
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* update deps, drop Node 6 ([62056df](https://www.github.com/yargs/cliui/commit/62056df))
|
||||
|
||||
## [5.0.0](https://github.com/yargs/cliui/compare/v4.1.0...v5.0.0) (2019-04-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Update wrap-ansi to fix compatibility with latest versions of chalk. ([#60](https://github.com/yargs/cliui/issues/60)) ([7bf79ae](https://github.com/yargs/cliui/commit/7bf79ae))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* Drop support for node < 6.
|
||||
|
||||
|
||||
|
||||
<a name="4.1.0"></a>
|
||||
## [4.1.0](https://github.com/yargs/cliui/compare/v4.0.0...v4.1.0) (2018-04-23)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add resetOutput method ([#57](https://github.com/yargs/cliui/issues/57)) ([7246902](https://github.com/yargs/cliui/commit/7246902))
|
||||
|
||||
|
||||
|
||||
<a name="4.0.0"></a>
|
||||
## [4.0.0](https://github.com/yargs/cliui/compare/v3.2.0...v4.0.0) (2017-12-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* downgrades strip-ansi to version 3.0.1 ([#54](https://github.com/yargs/cliui/issues/54)) ([5764c46](https://github.com/yargs/cliui/commit/5764c46))
|
||||
* set env variable FORCE_COLOR. ([#56](https://github.com/yargs/cliui/issues/56)) ([7350e36](https://github.com/yargs/cliui/commit/7350e36))
|
||||
|
||||
|
||||
### Chores
|
||||
|
||||
* drop support for node < 4 ([#53](https://github.com/yargs/cliui/issues/53)) ([b105376](https://github.com/yargs/cliui/commit/b105376))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add fallback for window width ([#45](https://github.com/yargs/cliui/issues/45)) ([d064922](https://github.com/yargs/cliui/commit/d064922))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* officially drop support for Node < 4
|
||||
|
||||
|
||||
|
||||
<a name="3.2.0"></a>
|
||||
## [3.2.0](https://github.com/yargs/cliui/compare/v3.1.2...v3.2.0) (2016-04-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* reduces tarball size ([acc6c33](https://github.com/yargs/cliui/commit/acc6c33))
|
||||
|
||||
### Features
|
||||
|
||||
* adds standard-version for release management ([ff84e32](https://github.com/yargs/cliui/commit/ff84e32))
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
Copyright (c) 2015, Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice
|
||||
appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
# cliui
|
||||
|
||||

|
||||
[](https://www.npmjs.com/package/cliui)
|
||||
[](https://conventionalcommits.org)
|
||||

|
||||
|
||||
easily create complex multi-column command-line-interfaces.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
const ui = require('cliui')()
|
||||
|
||||
ui.div('Usage: $0 [command] [options]')
|
||||
|
||||
ui.div({
|
||||
text: 'Options:',
|
||||
padding: [2, 0, 1, 0]
|
||||
})
|
||||
|
||||
ui.div(
|
||||
{
|
||||
text: "-f, --file",
|
||||
width: 20,
|
||||
padding: [0, 4, 0, 4]
|
||||
},
|
||||
{
|
||||
text: "the file to load." +
|
||||
chalk.green("(if this description is long it wraps).")
|
||||
,
|
||||
width: 20
|
||||
},
|
||||
{
|
||||
text: chalk.red("[required]"),
|
||||
align: 'right'
|
||||
}
|
||||
)
|
||||
|
||||
console.log(ui.toString())
|
||||
```
|
||||
|
||||
## Deno/ESM Support
|
||||
|
||||
As of `v7` `cliui` supports [Deno](https://github.com/denoland/deno) and
|
||||
[ESM](https://nodejs.org/api/esm.html#esm_ecmascript_modules):
|
||||
|
||||
```typescript
|
||||
import cliui from "https://deno.land/x/cliui/deno.ts";
|
||||
|
||||
const ui = cliui({})
|
||||
|
||||
ui.div('Usage: $0 [command] [options]')
|
||||
|
||||
ui.div({
|
||||
text: 'Options:',
|
||||
padding: [2, 0, 1, 0]
|
||||
})
|
||||
|
||||
ui.div({
|
||||
text: "-f, --file",
|
||||
width: 20,
|
||||
padding: [0, 4, 0, 4]
|
||||
})
|
||||
|
||||
console.log(ui.toString())
|
||||
```
|
||||
|
||||
<img width="500" src="screenshot.png">
|
||||
|
||||
## Layout DSL
|
||||
|
||||
cliui exposes a simple layout DSL:
|
||||
|
||||
If you create a single `ui.div`, passing a string rather than an
|
||||
object:
|
||||
|
||||
* `\n`: characters will be interpreted as new rows.
|
||||
* `\t`: characters will be interpreted as new columns.
|
||||
* `\s`: characters will be interpreted as padding.
|
||||
|
||||
**as an example...**
|
||||
|
||||
```js
|
||||
var ui = require('./')({
|
||||
width: 60
|
||||
})
|
||||
|
||||
ui.div(
|
||||
'Usage: node ./bin/foo.js\n' +
|
||||
' <regex>\t provide a regex\n' +
|
||||
' <glob>\t provide a glob\t [required]'
|
||||
)
|
||||
|
||||
console.log(ui.toString())
|
||||
```
|
||||
|
||||
**will output:**
|
||||
|
||||
```shell
|
||||
Usage: node ./bin/foo.js
|
||||
<regex> provide a regex
|
||||
<glob> provide a glob [required]
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
```js
|
||||
cliui = require('cliui')
|
||||
```
|
||||
|
||||
### cliui({width: integer})
|
||||
|
||||
Specify the maximum width of the UI being generated.
|
||||
If no width is provided, cliui will try to get the current window's width and use it, and if that doesn't work, width will be set to `80`.
|
||||
|
||||
### cliui({wrap: boolean})
|
||||
|
||||
Enable or disable the wrapping of text in a column.
|
||||
|
||||
### cliui.div(column, column, column)
|
||||
|
||||
Create a row with any number of columns, a column
|
||||
can either be a string, or an object with the following
|
||||
options:
|
||||
|
||||
* **text:** some text to place in the column.
|
||||
* **width:** the width of a column.
|
||||
* **align:** alignment, `right` or `center`.
|
||||
* **padding:** `[top, right, bottom, left]`.
|
||||
* **border:** should a border be placed around the div?
|
||||
|
||||
### cliui.span(column, column, column)
|
||||
|
||||
Similar to `div`, except the next row will be appended without
|
||||
a new line being created.
|
||||
|
||||
### cliui.resetOutput()
|
||||
|
||||
Resets the UI elements of the current cliui instance, maintaining the values
|
||||
set for `width` and `wrap`.
|
||||
|
|
@ -0,0 +1,302 @@
|
|||
'use strict';
|
||||
|
||||
const align = {
|
||||
right: alignRight,
|
||||
center: alignCenter
|
||||
};
|
||||
const top = 0;
|
||||
const right = 1;
|
||||
const bottom = 2;
|
||||
const left = 3;
|
||||
class UI {
|
||||
constructor(opts) {
|
||||
var _a;
|
||||
this.width = opts.width;
|
||||
this.wrap = (_a = opts.wrap) !== null && _a !== void 0 ? _a : true;
|
||||
this.rows = [];
|
||||
}
|
||||
span(...args) {
|
||||
const cols = this.div(...args);
|
||||
cols.span = true;
|
||||
}
|
||||
resetOutput() {
|
||||
this.rows = [];
|
||||
}
|
||||
div(...args) {
|
||||
if (args.length === 0) {
|
||||
this.div('');
|
||||
}
|
||||
if (this.wrap && this.shouldApplyLayoutDSL(...args) && typeof args[0] === 'string') {
|
||||
return this.applyLayoutDSL(args[0]);
|
||||
}
|
||||
const cols = args.map(arg => {
|
||||
if (typeof arg === 'string') {
|
||||
return this.colFromString(arg);
|
||||
}
|
||||
return arg;
|
||||
});
|
||||
this.rows.push(cols);
|
||||
return cols;
|
||||
}
|
||||
shouldApplyLayoutDSL(...args) {
|
||||
return args.length === 1 && typeof args[0] === 'string' &&
|
||||
/[\t\n]/.test(args[0]);
|
||||
}
|
||||
applyLayoutDSL(str) {
|
||||
const rows = str.split('\n').map(row => row.split('\t'));
|
||||
let leftColumnWidth = 0;
|
||||
// simple heuristic for layout, make sure the
|
||||
// second column lines up along the left-hand.
|
||||
// don't allow the first column to take up more
|
||||
// than 50% of the screen.
|
||||
rows.forEach(columns => {
|
||||
if (columns.length > 1 && mixin.stringWidth(columns[0]) > leftColumnWidth) {
|
||||
leftColumnWidth = Math.min(Math.floor(this.width * 0.5), mixin.stringWidth(columns[0]));
|
||||
}
|
||||
});
|
||||
// generate a table:
|
||||
// replacing ' ' with padding calculations.
|
||||
// using the algorithmically generated width.
|
||||
rows.forEach(columns => {
|
||||
this.div(...columns.map((r, i) => {
|
||||
return {
|
||||
text: r.trim(),
|
||||
padding: this.measurePadding(r),
|
||||
width: (i === 0 && columns.length > 1) ? leftColumnWidth : undefined
|
||||
};
|
||||
}));
|
||||
});
|
||||
return this.rows[this.rows.length - 1];
|
||||
}
|
||||
colFromString(text) {
|
||||
return {
|
||||
text,
|
||||
padding: this.measurePadding(text)
|
||||
};
|
||||
}
|
||||
measurePadding(str) {
|
||||
// measure padding without ansi escape codes
|
||||
const noAnsi = mixin.stripAnsi(str);
|
||||
return [0, noAnsi.match(/\s*$/)[0].length, 0, noAnsi.match(/^\s*/)[0].length];
|
||||
}
|
||||
toString() {
|
||||
const lines = [];
|
||||
this.rows.forEach(row => {
|
||||
this.rowToString(row, lines);
|
||||
});
|
||||
// don't display any lines with the
|
||||
// hidden flag set.
|
||||
return lines
|
||||
.filter(line => !line.hidden)
|
||||
.map(line => line.text)
|
||||
.join('\n');
|
||||
}
|
||||
rowToString(row, lines) {
|
||||
this.rasterize(row).forEach((rrow, r) => {
|
||||
let str = '';
|
||||
rrow.forEach((col, c) => {
|
||||
const { width } = row[c]; // the width with padding.
|
||||
const wrapWidth = this.negatePadding(row[c]); // the width without padding.
|
||||
let ts = col; // temporary string used during alignment/padding.
|
||||
if (wrapWidth > mixin.stringWidth(col)) {
|
||||
ts += ' '.repeat(wrapWidth - mixin.stringWidth(col));
|
||||
}
|
||||
// align the string within its column.
|
||||
if (row[c].align && row[c].align !== 'left' && this.wrap) {
|
||||
const fn = align[row[c].align];
|
||||
ts = fn(ts, wrapWidth);
|
||||
if (mixin.stringWidth(ts) < wrapWidth) {
|
||||
ts += ' '.repeat((width || 0) - mixin.stringWidth(ts) - 1);
|
||||
}
|
||||
}
|
||||
// apply border and padding to string.
|
||||
const padding = row[c].padding || [0, 0, 0, 0];
|
||||
if (padding[left]) {
|
||||
str += ' '.repeat(padding[left]);
|
||||
}
|
||||
str += addBorder(row[c], ts, '| ');
|
||||
str += ts;
|
||||
str += addBorder(row[c], ts, ' |');
|
||||
if (padding[right]) {
|
||||
str += ' '.repeat(padding[right]);
|
||||
}
|
||||
// if prior row is span, try to render the
|
||||
// current row on the prior line.
|
||||
if (r === 0 && lines.length > 0) {
|
||||
str = this.renderInline(str, lines[lines.length - 1]);
|
||||
}
|
||||
});
|
||||
// remove trailing whitespace.
|
||||
lines.push({
|
||||
text: str.replace(/ +$/, ''),
|
||||
span: row.span
|
||||
});
|
||||
});
|
||||
return lines;
|
||||
}
|
||||
// if the full 'source' can render in
|
||||
// the target line, do so.
|
||||
renderInline(source, previousLine) {
|
||||
const match = source.match(/^ */);
|
||||
const leadingWhitespace = match ? match[0].length : 0;
|
||||
const target = previousLine.text;
|
||||
const targetTextWidth = mixin.stringWidth(target.trimRight());
|
||||
if (!previousLine.span) {
|
||||
return source;
|
||||
}
|
||||
// if we're not applying wrapping logic,
|
||||
// just always append to the span.
|
||||
if (!this.wrap) {
|
||||
previousLine.hidden = true;
|
||||
return target + source;
|
||||
}
|
||||
if (leadingWhitespace < targetTextWidth) {
|
||||
return source;
|
||||
}
|
||||
previousLine.hidden = true;
|
||||
return target.trimRight() + ' '.repeat(leadingWhitespace - targetTextWidth) + source.trimLeft();
|
||||
}
|
||||
rasterize(row) {
|
||||
const rrows = [];
|
||||
const widths = this.columnWidths(row);
|
||||
let wrapped;
|
||||
// word wrap all columns, and create
|
||||
// a data-structure that is easy to rasterize.
|
||||
row.forEach((col, c) => {
|
||||
// leave room for left and right padding.
|
||||
col.width = widths[c];
|
||||
if (this.wrap) {
|
||||
wrapped = mixin.wrap(col.text, this.negatePadding(col), { hard: true }).split('\n');
|
||||
}
|
||||
else {
|
||||
wrapped = col.text.split('\n');
|
||||
}
|
||||
if (col.border) {
|
||||
wrapped.unshift('.' + '-'.repeat(this.negatePadding(col) + 2) + '.');
|
||||
wrapped.push("'" + '-'.repeat(this.negatePadding(col) + 2) + "'");
|
||||
}
|
||||
// add top and bottom padding.
|
||||
if (col.padding) {
|
||||
wrapped.unshift(...new Array(col.padding[top] || 0).fill(''));
|
||||
wrapped.push(...new Array(col.padding[bottom] || 0).fill(''));
|
||||
}
|
||||
wrapped.forEach((str, r) => {
|
||||
if (!rrows[r]) {
|
||||
rrows.push([]);
|
||||
}
|
||||
const rrow = rrows[r];
|
||||
for (let i = 0; i < c; i++) {
|
||||
if (rrow[i] === undefined) {
|
||||
rrow.push('');
|
||||
}
|
||||
}
|
||||
rrow.push(str);
|
||||
});
|
||||
});
|
||||
return rrows;
|
||||
}
|
||||
negatePadding(col) {
|
||||
let wrapWidth = col.width || 0;
|
||||
if (col.padding) {
|
||||
wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0);
|
||||
}
|
||||
if (col.border) {
|
||||
wrapWidth -= 4;
|
||||
}
|
||||
return wrapWidth;
|
||||
}
|
||||
columnWidths(row) {
|
||||
if (!this.wrap) {
|
||||
return row.map(col => {
|
||||
return col.width || mixin.stringWidth(col.text);
|
||||
});
|
||||
}
|
||||
let unset = row.length;
|
||||
let remainingWidth = this.width;
|
||||
// column widths can be set in config.
|
||||
const widths = row.map(col => {
|
||||
if (col.width) {
|
||||
unset--;
|
||||
remainingWidth -= col.width;
|
||||
return col.width;
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
// any unset widths should be calculated.
|
||||
const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0;
|
||||
return widths.map((w, i) => {
|
||||
if (w === undefined) {
|
||||
return Math.max(unsetWidth, _minWidth(row[i]));
|
||||
}
|
||||
return w;
|
||||
});
|
||||
}
|
||||
}
|
||||
function addBorder(col, ts, style) {
|
||||
if (col.border) {
|
||||
if (/[.']-+[.']/.test(ts)) {
|
||||
return '';
|
||||
}
|
||||
if (ts.trim().length !== 0) {
|
||||
return style;
|
||||
}
|
||||
return ' ';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
// calculates the minimum width of
|
||||
// a column, based on padding preferences.
|
||||
function _minWidth(col) {
|
||||
const padding = col.padding || [];
|
||||
const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
|
||||
if (col.border) {
|
||||
return minWidth + 4;
|
||||
}
|
||||
return minWidth;
|
||||
}
|
||||
function getWindowWidth() {
|
||||
/* istanbul ignore next: depends on terminal */
|
||||
if (typeof process === 'object' && process.stdout && process.stdout.columns) {
|
||||
return process.stdout.columns;
|
||||
}
|
||||
return 80;
|
||||
}
|
||||
function alignRight(str, width) {
|
||||
str = str.trim();
|
||||
const strWidth = mixin.stringWidth(str);
|
||||
if (strWidth < width) {
|
||||
return ' '.repeat(width - strWidth) + str;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function alignCenter(str, width) {
|
||||
str = str.trim();
|
||||
const strWidth = mixin.stringWidth(str);
|
||||
/* istanbul ignore next */
|
||||
if (strWidth >= width) {
|
||||
return str;
|
||||
}
|
||||
return ' '.repeat((width - strWidth) >> 1) + str;
|
||||
}
|
||||
let mixin;
|
||||
function cliui(opts, _mixin) {
|
||||
mixin = _mixin;
|
||||
return new UI({
|
||||
width: (opts === null || opts === void 0 ? void 0 : opts.width) || getWindowWidth(),
|
||||
wrap: opts === null || opts === void 0 ? void 0 : opts.wrap
|
||||
});
|
||||
}
|
||||
|
||||
// Bootstrap cliui with CommonJS dependencies:
|
||||
const stringWidth = require('string-width');
|
||||
const stripAnsi = require('strip-ansi');
|
||||
const wrap = require('wrap-ansi');
|
||||
function ui(opts) {
|
||||
return cliui(opts, {
|
||||
stringWidth,
|
||||
stripAnsi,
|
||||
wrap
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = ui;
|
||||
|
|
@ -0,0 +1,287 @@
|
|||
'use strict';
|
||||
const align = {
|
||||
right: alignRight,
|
||||
center: alignCenter
|
||||
};
|
||||
const top = 0;
|
||||
const right = 1;
|
||||
const bottom = 2;
|
||||
const left = 3;
|
||||
export class UI {
|
||||
constructor(opts) {
|
||||
var _a;
|
||||
this.width = opts.width;
|
||||
this.wrap = (_a = opts.wrap) !== null && _a !== void 0 ? _a : true;
|
||||
this.rows = [];
|
||||
}
|
||||
span(...args) {
|
||||
const cols = this.div(...args);
|
||||
cols.span = true;
|
||||
}
|
||||
resetOutput() {
|
||||
this.rows = [];
|
||||
}
|
||||
div(...args) {
|
||||
if (args.length === 0) {
|
||||
this.div('');
|
||||
}
|
||||
if (this.wrap && this.shouldApplyLayoutDSL(...args) && typeof args[0] === 'string') {
|
||||
return this.applyLayoutDSL(args[0]);
|
||||
}
|
||||
const cols = args.map(arg => {
|
||||
if (typeof arg === 'string') {
|
||||
return this.colFromString(arg);
|
||||
}
|
||||
return arg;
|
||||
});
|
||||
this.rows.push(cols);
|
||||
return cols;
|
||||
}
|
||||
shouldApplyLayoutDSL(...args) {
|
||||
return args.length === 1 && typeof args[0] === 'string' &&
|
||||
/[\t\n]/.test(args[0]);
|
||||
}
|
||||
applyLayoutDSL(str) {
|
||||
const rows = str.split('\n').map(row => row.split('\t'));
|
||||
let leftColumnWidth = 0;
|
||||
// simple heuristic for layout, make sure the
|
||||
// second column lines up along the left-hand.
|
||||
// don't allow the first column to take up more
|
||||
// than 50% of the screen.
|
||||
rows.forEach(columns => {
|
||||
if (columns.length > 1 && mixin.stringWidth(columns[0]) > leftColumnWidth) {
|
||||
leftColumnWidth = Math.min(Math.floor(this.width * 0.5), mixin.stringWidth(columns[0]));
|
||||
}
|
||||
});
|
||||
// generate a table:
|
||||
// replacing ' ' with padding calculations.
|
||||
// using the algorithmically generated width.
|
||||
rows.forEach(columns => {
|
||||
this.div(...columns.map((r, i) => {
|
||||
return {
|
||||
text: r.trim(),
|
||||
padding: this.measurePadding(r),
|
||||
width: (i === 0 && columns.length > 1) ? leftColumnWidth : undefined
|
||||
};
|
||||
}));
|
||||
});
|
||||
return this.rows[this.rows.length - 1];
|
||||
}
|
||||
colFromString(text) {
|
||||
return {
|
||||
text,
|
||||
padding: this.measurePadding(text)
|
||||
};
|
||||
}
|
||||
measurePadding(str) {
|
||||
// measure padding without ansi escape codes
|
||||
const noAnsi = mixin.stripAnsi(str);
|
||||
return [0, noAnsi.match(/\s*$/)[0].length, 0, noAnsi.match(/^\s*/)[0].length];
|
||||
}
|
||||
toString() {
|
||||
const lines = [];
|
||||
this.rows.forEach(row => {
|
||||
this.rowToString(row, lines);
|
||||
});
|
||||
// don't display any lines with the
|
||||
// hidden flag set.
|
||||
return lines
|
||||
.filter(line => !line.hidden)
|
||||
.map(line => line.text)
|
||||
.join('\n');
|
||||
}
|
||||
rowToString(row, lines) {
|
||||
this.rasterize(row).forEach((rrow, r) => {
|
||||
let str = '';
|
||||
rrow.forEach((col, c) => {
|
||||
const { width } = row[c]; // the width with padding.
|
||||
const wrapWidth = this.negatePadding(row[c]); // the width without padding.
|
||||
let ts = col; // temporary string used during alignment/padding.
|
||||
if (wrapWidth > mixin.stringWidth(col)) {
|
||||
ts += ' '.repeat(wrapWidth - mixin.stringWidth(col));
|
||||
}
|
||||
// align the string within its column.
|
||||
if (row[c].align && row[c].align !== 'left' && this.wrap) {
|
||||
const fn = align[row[c].align];
|
||||
ts = fn(ts, wrapWidth);
|
||||
if (mixin.stringWidth(ts) < wrapWidth) {
|
||||
ts += ' '.repeat((width || 0) - mixin.stringWidth(ts) - 1);
|
||||
}
|
||||
}
|
||||
// apply border and padding to string.
|
||||
const padding = row[c].padding || [0, 0, 0, 0];
|
||||
if (padding[left]) {
|
||||
str += ' '.repeat(padding[left]);
|
||||
}
|
||||
str += addBorder(row[c], ts, '| ');
|
||||
str += ts;
|
||||
str += addBorder(row[c], ts, ' |');
|
||||
if (padding[right]) {
|
||||
str += ' '.repeat(padding[right]);
|
||||
}
|
||||
// if prior row is span, try to render the
|
||||
// current row on the prior line.
|
||||
if (r === 0 && lines.length > 0) {
|
||||
str = this.renderInline(str, lines[lines.length - 1]);
|
||||
}
|
||||
});
|
||||
// remove trailing whitespace.
|
||||
lines.push({
|
||||
text: str.replace(/ +$/, ''),
|
||||
span: row.span
|
||||
});
|
||||
});
|
||||
return lines;
|
||||
}
|
||||
// if the full 'source' can render in
|
||||
// the target line, do so.
|
||||
renderInline(source, previousLine) {
|
||||
const match = source.match(/^ */);
|
||||
const leadingWhitespace = match ? match[0].length : 0;
|
||||
const target = previousLine.text;
|
||||
const targetTextWidth = mixin.stringWidth(target.trimRight());
|
||||
if (!previousLine.span) {
|
||||
return source;
|
||||
}
|
||||
// if we're not applying wrapping logic,
|
||||
// just always append to the span.
|
||||
if (!this.wrap) {
|
||||
previousLine.hidden = true;
|
||||
return target + source;
|
||||
}
|
||||
if (leadingWhitespace < targetTextWidth) {
|
||||
return source;
|
||||
}
|
||||
previousLine.hidden = true;
|
||||
return target.trimRight() + ' '.repeat(leadingWhitespace - targetTextWidth) + source.trimLeft();
|
||||
}
|
||||
rasterize(row) {
|
||||
const rrows = [];
|
||||
const widths = this.columnWidths(row);
|
||||
let wrapped;
|
||||
// word wrap all columns, and create
|
||||
// a data-structure that is easy to rasterize.
|
||||
row.forEach((col, c) => {
|
||||
// leave room for left and right padding.
|
||||
col.width = widths[c];
|
||||
if (this.wrap) {
|
||||
wrapped = mixin.wrap(col.text, this.negatePadding(col), { hard: true }).split('\n');
|
||||
}
|
||||
else {
|
||||
wrapped = col.text.split('\n');
|
||||
}
|
||||
if (col.border) {
|
||||
wrapped.unshift('.' + '-'.repeat(this.negatePadding(col) + 2) + '.');
|
||||
wrapped.push("'" + '-'.repeat(this.negatePadding(col) + 2) + "'");
|
||||
}
|
||||
// add top and bottom padding.
|
||||
if (col.padding) {
|
||||
wrapped.unshift(...new Array(col.padding[top] || 0).fill(''));
|
||||
wrapped.push(...new Array(col.padding[bottom] || 0).fill(''));
|
||||
}
|
||||
wrapped.forEach((str, r) => {
|
||||
if (!rrows[r]) {
|
||||
rrows.push([]);
|
||||
}
|
||||
const rrow = rrows[r];
|
||||
for (let i = 0; i < c; i++) {
|
||||
if (rrow[i] === undefined) {
|
||||
rrow.push('');
|
||||
}
|
||||
}
|
||||
rrow.push(str);
|
||||
});
|
||||
});
|
||||
return rrows;
|
||||
}
|
||||
negatePadding(col) {
|
||||
let wrapWidth = col.width || 0;
|
||||
if (col.padding) {
|
||||
wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0);
|
||||
}
|
||||
if (col.border) {
|
||||
wrapWidth -= 4;
|
||||
}
|
||||
return wrapWidth;
|
||||
}
|
||||
columnWidths(row) {
|
||||
if (!this.wrap) {
|
||||
return row.map(col => {
|
||||
return col.width || mixin.stringWidth(col.text);
|
||||
});
|
||||
}
|
||||
let unset = row.length;
|
||||
let remainingWidth = this.width;
|
||||
// column widths can be set in config.
|
||||
const widths = row.map(col => {
|
||||
if (col.width) {
|
||||
unset--;
|
||||
remainingWidth -= col.width;
|
||||
return col.width;
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
// any unset widths should be calculated.
|
||||
const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0;
|
||||
return widths.map((w, i) => {
|
||||
if (w === undefined) {
|
||||
return Math.max(unsetWidth, _minWidth(row[i]));
|
||||
}
|
||||
return w;
|
||||
});
|
||||
}
|
||||
}
|
||||
function addBorder(col, ts, style) {
|
||||
if (col.border) {
|
||||
if (/[.']-+[.']/.test(ts)) {
|
||||
return '';
|
||||
}
|
||||
if (ts.trim().length !== 0) {
|
||||
return style;
|
||||
}
|
||||
return ' ';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
// calculates the minimum width of
|
||||
// a column, based on padding preferences.
|
||||
function _minWidth(col) {
|
||||
const padding = col.padding || [];
|
||||
const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
|
||||
if (col.border) {
|
||||
return minWidth + 4;
|
||||
}
|
||||
return minWidth;
|
||||
}
|
||||
function getWindowWidth() {
|
||||
/* istanbul ignore next: depends on terminal */
|
||||
if (typeof process === 'object' && process.stdout && process.stdout.columns) {
|
||||
return process.stdout.columns;
|
||||
}
|
||||
return 80;
|
||||
}
|
||||
function alignRight(str, width) {
|
||||
str = str.trim();
|
||||
const strWidth = mixin.stringWidth(str);
|
||||
if (strWidth < width) {
|
||||
return ' '.repeat(width - strWidth) + str;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function alignCenter(str, width) {
|
||||
str = str.trim();
|
||||
const strWidth = mixin.stringWidth(str);
|
||||
/* istanbul ignore next */
|
||||
if (strWidth >= width) {
|
||||
return str;
|
||||
}
|
||||
return ' '.repeat((width - strWidth) >> 1) + str;
|
||||
}
|
||||
let mixin;
|
||||
export function cliui(opts, _mixin) {
|
||||
mixin = _mixin;
|
||||
return new UI({
|
||||
width: (opts === null || opts === void 0 ? void 0 : opts.width) || getWindowWidth(),
|
||||
wrap: opts === null || opts === void 0 ? void 0 : opts.wrap
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// Minimal replacement for ansi string helpers "wrap-ansi" and "strip-ansi".
|
||||
// to facilitate ESM and Deno modules.
|
||||
// TODO: look at porting https://www.npmjs.com/package/wrap-ansi to ESM.
|
||||
// The npm application
|
||||
// Copyright (c) npm, Inc. and Contributors
|
||||
// Licensed on the terms of The Artistic License 2.0
|
||||
// See: https://github.com/npm/cli/blob/4c65cd952bc8627811735bea76b9b110cc4fc80e/lib/utils/ansi-trim.js
|
||||
const ansi = new RegExp('\x1b(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|' +
|
||||
'\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)', 'g');
|
||||
export function stripAnsi(str) {
|
||||
return str.replace(ansi, '');
|
||||
}
|
||||
export function wrap(str, width) {
|
||||
const [start, end] = str.match(ansi) || ['', ''];
|
||||
str = stripAnsi(str);
|
||||
let wrapped = '';
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
if (i !== 0 && (i % width) === 0) {
|
||||
wrapped += '\n';
|
||||
}
|
||||
wrapped += str.charAt(i);
|
||||
}
|
||||
if (start && end) {
|
||||
wrapped = `${start}${wrapped}${end}`;
|
||||
}
|
||||
return wrapped;
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
// Bootstrap cliui with CommonJS dependencies:
|
||||
import { cliui } from './build/lib/index.js'
|
||||
import { wrap, stripAnsi } from './build/lib/string-utils.js'
|
||||
|
||||
export default function ui (opts) {
|
||||
return cliui(opts, {
|
||||
stringWidth: (str) => {
|
||||
return [...str].length
|
||||
},
|
||||
stripAnsi,
|
||||
wrap
|
||||
})
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
{
|
||||
"name": "cliui",
|
||||
"version": "7.0.4",
|
||||
"description": "easily create complex multi-column command-line-interfaces",
|
||||
"main": "build/index.cjs",
|
||||
"exports": {
|
||||
".": [
|
||||
{
|
||||
"import": "./index.mjs",
|
||||
"require": "./build/index.cjs"
|
||||
},
|
||||
"./build/index.cjs"
|
||||
]
|
||||
},
|
||||
"type": "module",
|
||||
"module": "./index.mjs",
|
||||
"scripts": {
|
||||
"check": "standardx '**/*.ts' && standardx '**/*.js' && standardx '**/*.cjs'",
|
||||
"fix": "standardx --fix '**/*.ts' && standardx --fix '**/*.js' && standardx --fix '**/*.cjs'",
|
||||
"pretest": "rimraf build && tsc -p tsconfig.test.json && cross-env NODE_ENV=test npm run build:cjs",
|
||||
"test": "c8 mocha ./test/*.cjs",
|
||||
"test:esm": "c8 mocha ./test/esm/cliui-test.mjs",
|
||||
"postest": "check",
|
||||
"coverage": "c8 report --check-coverage",
|
||||
"precompile": "rimraf build",
|
||||
"compile": "tsc",
|
||||
"postcompile": "npm run build:cjs",
|
||||
"build:cjs": "rollup -c",
|
||||
"prepare": "npm run compile"
|
||||
},
|
||||
"repository": "yargs/cliui",
|
||||
"standard": {
|
||||
"ignore": [
|
||||
"**/example/**"
|
||||
],
|
||||
"globals": [
|
||||
"it"
|
||||
]
|
||||
},
|
||||
"keywords": [
|
||||
"cli",
|
||||
"command-line",
|
||||
"layout",
|
||||
"design",
|
||||
"console",
|
||||
"wrap",
|
||||
"table"
|
||||
],
|
||||
"author": "Ben Coe <ben@npmjs.com>",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"string-width": "^4.2.0",
|
||||
"strip-ansi": "^6.0.0",
|
||||
"wrap-ansi": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.0.27",
|
||||
"@typescript-eslint/eslint-plugin": "^4.0.0",
|
||||
"@typescript-eslint/parser": "^4.0.0",
|
||||
"@wessberg/rollup-plugin-ts": "^1.3.2",
|
||||
"c8": "^7.3.0",
|
||||
"chai": "^4.2.0",
|
||||
"chalk": "^4.1.0",
|
||||
"cross-env": "^7.0.2",
|
||||
"eslint": "^7.6.0",
|
||||
"eslint-plugin-import": "^2.22.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"gts": "^3.0.0",
|
||||
"mocha": "^8.1.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.23.1",
|
||||
"standardx": "^7.0.0",
|
||||
"typescript": "^4.0.0"
|
||||
},
|
||||
"files": [
|
||||
"build",
|
||||
"index.mjs",
|
||||
"!*.d.ts"
|
||||
],
|
||||
"engine": {
|
||||
"node": ">=10"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz"
|
||||
,"_integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ=="
|
||||
,"_from": "cliui@7.0.4"
|
||||
}
|
||||
|
|
@ -1,31 +1,24 @@
|
|||
{
|
||||
"_from": "conventional-changelog@3.1.23",
|
||||
"_id": "conventional-changelog@3.1.23",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-sScUu2NHusjRC1dPc5p8/b3kT78OYr95/Bx7Vl8CPB8tF2mG1xei5iylDTRjONV5hTlzt+Cn/tBWrKdd299b7A==",
|
||||
"_location": "/conventional-changelog",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "conventional-changelog@3.1.23",
|
||||
"name": "conventional-changelog",
|
||||
"escapedName": "conventional-changelog",
|
||||
"rawSpec": "3.1.23",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "3.1.23"
|
||||
"name": "conventional-changelog",
|
||||
"version": "3.1.23",
|
||||
"description": "Generate a changelog from git metadata",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/conventional-changelog/conventional-changelog.git"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
"keywords": [
|
||||
"conventional-changelog",
|
||||
"conventional",
|
||||
"changelog",
|
||||
"log"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-3.1.23.tgz",
|
||||
"_shasum": "d696408021b579a3814aba79b38729ed86478aea",
|
||||
"_spec": "conventional-changelog@3.1.23",
|
||||
"_where": "/Users/tycho/GIT/Github/conventional-changelog-action",
|
||||
"bugs": {
|
||||
"url": "https://github.com/conventional-changelog/conventional-changelog/issues"
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Brian Ford"
|
||||
|
|
@ -37,6 +30,10 @@
|
|||
"name": "Andrew Joslin"
|
||||
}
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/conventional-changelog/conventional-changelog/issues"
|
||||
},
|
||||
"homepage": "https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog#readme",
|
||||
"dependencies": {
|
||||
"conventional-changelog-angular": "^5.0.11",
|
||||
"conventional-changelog-atom": "^2.0.7",
|
||||
|
|
@ -50,30 +47,12 @@
|
|||
"conventional-changelog-jshint": "^2.0.8",
|
||||
"conventional-changelog-preset-loader": "^2.3.4"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Generate a changelog from git metadata",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "be1246c68f5dc4e6f28996129951a75bbf1cf307",
|
||||
"homepage": "https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog#readme",
|
||||
"keywords": [
|
||||
"conventional-changelog",
|
||||
"conventional",
|
||||
"changelog",
|
||||
"log"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "conventional-changelog",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/conventional-changelog/conventional-changelog.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test-windows": "mocha --timeout 30000"
|
||||
},
|
||||
"version": "3.1.23"
|
||||
"gitHead": "be1246c68f5dc4e6f28996129951a75bbf1cf307"
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-3.1.23.tgz"
|
||||
,"_integrity": "sha512-sScUu2NHusjRC1dPc5p8/b3kT78OYr95/Bx7Vl8CPB8tF2mG1xei5iylDTRjONV5hTlzt+Cn/tBWrKdd299b7A=="
|
||||
,"_from": "conventional-changelog@3.1.23"
|
||||
}
|
||||
1
node_modules/conventional-recommended-bump/node_modules/.bin/git-raw-commits
generated
vendored
120000
1
node_modules/conventional-recommended-bump/node_modules/.bin/git-raw-commits
generated
vendored
120000
|
|
@ -0,0 +1 @@
|
|||
../git-raw-commits/cli.js
|
||||
|
|
@ -0,0 +1 @@
|
|||
../semver/bin/semver
|
||||
41
node_modules/conventional-recommended-bump/node_modules/camelcase-keys/index.js
generated
vendored
100644
41
node_modules/conventional-recommended-bump/node_modules/camelcase-keys/index.js
generated
vendored
100644
|
|
@ -0,0 +1,41 @@
|
|||
'use strict';
|
||||
const mapObj = require('map-obj');
|
||||
const camelCase = require('camelcase');
|
||||
const QuickLru = require('quick-lru');
|
||||
|
||||
const has = (arr, key) => arr.some(x => typeof x === 'string' ? x === key : x.test(key));
|
||||
const cache = new QuickLru({maxSize: 100000});
|
||||
|
||||
const camelCaseConvert = (input, opts) => {
|
||||
opts = Object.assign({
|
||||
deep: false
|
||||
}, opts);
|
||||
|
||||
const exclude = opts.exclude;
|
||||
|
||||
return mapObj(input, (key, val) => {
|
||||
if (!(exclude && has(exclude, key))) {
|
||||
if (cache.has(key)) {
|
||||
key = cache.get(key);
|
||||
} else {
|
||||
const ret = camelCase(key);
|
||||
|
||||
if (key.length < 100) { // Prevent abuse
|
||||
cache.set(key, ret);
|
||||
}
|
||||
|
||||
key = ret;
|
||||
}
|
||||
}
|
||||
|
||||
return [key, val];
|
||||
}, {deep: opts.deep});
|
||||
};
|
||||
|
||||
module.exports = (input, opts) => {
|
||||
if (Array.isArray(input)) {
|
||||
return Object.keys(input).map(key => camelCaseConvert(input[key], opts));
|
||||
}
|
||||
return camelCaseConvert(input, opts);
|
||||
};
|
||||
|
||||
21
node_modules/conventional-recommended-bump/node_modules/camelcase-keys/license
generated
vendored
100644
21
node_modules/conventional-recommended-bump/node_modules/camelcase-keys/license
generated
vendored
100644
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
72
node_modules/conventional-recommended-bump/node_modules/camelcase-keys/package.json
generated
vendored
100644
72
node_modules/conventional-recommended-bump/node_modules/camelcase-keys/package.json
generated
vendored
100644
|
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"name": "camelcase-keys",
|
||||
"version": "4.2.0",
|
||||
"description": "Convert object keys to camelCase",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/camelcase-keys",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava",
|
||||
"bench": "matcha bench/bench.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"map",
|
||||
"obj",
|
||||
"object",
|
||||
"key",
|
||||
"keys",
|
||||
"value",
|
||||
"values",
|
||||
"val",
|
||||
"iterate",
|
||||
"camelcase",
|
||||
"camel-case",
|
||||
"camel",
|
||||
"case",
|
||||
"dash",
|
||||
"hyphen",
|
||||
"dot",
|
||||
"underscore",
|
||||
"separator",
|
||||
"string",
|
||||
"text",
|
||||
"convert",
|
||||
"deep",
|
||||
"recurse",
|
||||
"recursive"
|
||||
],
|
||||
"dependencies": {
|
||||
"camelcase": "^4.1.0",
|
||||
"map-obj": "^2.0.0",
|
||||
"quick-lru": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"matcha": "^0.7.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"overrides": [
|
||||
{
|
||||
"files": "bench/bench.js",
|
||||
"rules": {
|
||||
"import/no-unresolved": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-4.2.0.tgz"
|
||||
,"_integrity": "sha1-oqpfsa9oh1glnDLBQUJteJI7m3c="
|
||||
,"_from": "camelcase-keys@4.2.0"
|
||||
}
|
||||
72
node_modules/conventional-recommended-bump/node_modules/camelcase-keys/readme.md
generated
vendored
100644
72
node_modules/conventional-recommended-bump/node_modules/camelcase-keys/readme.md
generated
vendored
100644
|
|
@ -0,0 +1,72 @@
|
|||
# camelcase-keys [](https://travis-ci.org/sindresorhus/camelcase-keys)
|
||||
|
||||
> Convert object keys to camelCase using [`camelcase`](https://github.com/sindresorhus/camelcase)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save camelcase-keys
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const camelcaseKeys = require('camelcase-keys');
|
||||
|
||||
// Convert an object
|
||||
camelcaseKeys({'foo-bar': true});
|
||||
//=> {fooBar: true}
|
||||
|
||||
// Convert an array of objects
|
||||
camelcaseKeys([{'foo-bar': true}, {'bar-foo': false}]);
|
||||
//=> [{fooBar: true}, {barFoo: false}]
|
||||
|
||||
camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true});
|
||||
//=> {fooBar: true, nested: {unicornRainbow: true}}
|
||||
```
|
||||
|
||||
```js
|
||||
const camelcaseKeys = require('camelcase-keys');
|
||||
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
//=> {_: [], 'foo-bar': true}
|
||||
|
||||
camelcaseKeys(argv);
|
||||
//=> {_: [], fooBar: true}
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### camelcaseKeys(input, [options])
|
||||
|
||||
#### input
|
||||
|
||||
Type: `Object` `Object[]`
|
||||
|
||||
Object or array of objects to camelCase.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### exclude
|
||||
|
||||
Type: `string[]` `RegExp[]`<br>
|
||||
Default: `[]`
|
||||
|
||||
Exclude keys from being camelCased.
|
||||
|
||||
##### deep
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Recurse nested objects and objects in arrays.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
64
node_modules/conventional-recommended-bump/node_modules/camelcase/index.js
generated
vendored
100644
64
node_modules/conventional-recommended-bump/node_modules/camelcase/index.js
generated
vendored
100644
|
|
@ -0,0 +1,64 @@
|
|||
'use strict';
|
||||
|
||||
function preserveCamelCase(str) {
|
||||
let isLastCharLower = false;
|
||||
let isLastCharUpper = false;
|
||||
let isLastLastCharUpper = false;
|
||||
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
const c = str[i];
|
||||
|
||||
if (isLastCharLower && /[a-zA-Z]/.test(c) && c.toUpperCase() === c) {
|
||||
str = str.substr(0, i) + '-' + str.substr(i);
|
||||
isLastCharLower = false;
|
||||
isLastLastCharUpper = isLastCharUpper;
|
||||
isLastCharUpper = true;
|
||||
i++;
|
||||
} else if (isLastCharUpper && isLastLastCharUpper && /[a-zA-Z]/.test(c) && c.toLowerCase() === c) {
|
||||
str = str.substr(0, i - 1) + '-' + str.substr(i - 1);
|
||||
isLastLastCharUpper = isLastCharUpper;
|
||||
isLastCharUpper = false;
|
||||
isLastCharLower = true;
|
||||
} else {
|
||||
isLastCharLower = c.toLowerCase() === c;
|
||||
isLastLastCharUpper = isLastCharUpper;
|
||||
isLastCharUpper = c.toUpperCase() === c;
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
module.exports = function (str) {
|
||||
if (arguments.length > 1) {
|
||||
str = Array.from(arguments)
|
||||
.map(x => x.trim())
|
||||
.filter(x => x.length)
|
||||
.join('-');
|
||||
} else {
|
||||
str = str.trim();
|
||||
}
|
||||
|
||||
if (str.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (str.length === 1) {
|
||||
return str.toLowerCase();
|
||||
}
|
||||
|
||||
if (/^[a-z0-9]+$/.test(str)) {
|
||||
return str;
|
||||
}
|
||||
|
||||
const hasUpperCase = str !== str.toLowerCase();
|
||||
|
||||
if (hasUpperCase) {
|
||||
str = preserveCamelCase(str);
|
||||
}
|
||||
|
||||
return str
|
||||
.replace(/^[_.\- ]+/, '')
|
||||
.toLowerCase()
|
||||
.replace(/[_.\- ]+(\w|$)/g, (m, p1) => p1.toUpperCase());
|
||||
};
|
||||
21
node_modules/conventional-recommended-bump/node_modules/camelcase/license
generated
vendored
100644
21
node_modules/conventional-recommended-bump/node_modules/camelcase/license
generated
vendored
100644
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
46
node_modules/conventional-recommended-bump/node_modules/camelcase/package.json
generated
vendored
100644
46
node_modules/conventional-recommended-bump/node_modules/camelcase/package.json
generated
vendored
100644
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "camelcase",
|
||||
"version": "4.1.0",
|
||||
"description": "Convert a dash/dot/underscore/space separated string to camelCase: foo-bar → fooBar",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/camelcase",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"camelcase",
|
||||
"camel-case",
|
||||
"camel",
|
||||
"case",
|
||||
"dash",
|
||||
"hyphen",
|
||||
"dot",
|
||||
"underscore",
|
||||
"separator",
|
||||
"string",
|
||||
"text",
|
||||
"convert"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz"
|
||||
,"_integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0="
|
||||
,"_from": "camelcase@4.1.0"
|
||||
}
|
||||
57
node_modules/conventional-recommended-bump/node_modules/camelcase/readme.md
generated
vendored
100644
57
node_modules/conventional-recommended-bump/node_modules/camelcase/readme.md
generated
vendored
100644
|
|
@ -0,0 +1,57 @@
|
|||
# camelcase [](https://travis-ci.org/sindresorhus/camelcase)
|
||||
|
||||
> Convert a dash/dot/underscore/space separated string to camelCase: `foo-bar` → `fooBar`
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save camelcase
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const camelCase = require('camelcase');
|
||||
|
||||
camelCase('foo-bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('foo_bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('Foo-Bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('--foo.bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('__foo__bar__');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('foo bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
console.log(process.argv[3]);
|
||||
//=> '--foo-bar'
|
||||
camelCase(process.argv[3]);
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('foo', 'bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('__foo__', '--bar');
|
||||
//=> 'fooBar'
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module
|
||||
- [uppercamelcase](https://github.com/SamVerschueren/uppercamelcase) - Like this module, but to PascalCase instead of camelCase
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
'use strict';
|
||||
var numberIsNan = require('number-is-nan');
|
||||
|
||||
function createArg(key, val, separator) {
|
||||
key = key.replace(/[A-Z]/g, '-$&').toLowerCase();
|
||||
return '--' + key + (val ? separator + val : '');
|
||||
}
|
||||
|
||||
function match(arr, val) {
|
||||
return arr.some(function (x) {
|
||||
return x instanceof RegExp ? x.test(val) : x === val;
|
||||
});
|
||||
}
|
||||
|
||||
function createAliasArg(key, val) {
|
||||
return '-' + key + (val ? ' ' + val : '');
|
||||
}
|
||||
|
||||
module.exports = function (input, opts) {
|
||||
var args = [];
|
||||
var extraArgs = [];
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
var separator = opts.useEquals === false ? ' ' : '=';
|
||||
|
||||
Object.keys(input).forEach(function (key) {
|
||||
var val = input[key];
|
||||
var argFn = createArg;
|
||||
|
||||
if (Array.isArray(opts.excludes) && match(opts.excludes, key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(opts.includes) && !match(opts.includes, key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof opts.aliases === 'object' && opts.aliases[key]) {
|
||||
key = opts.aliases[key];
|
||||
argFn = createAliasArg;
|
||||
}
|
||||
|
||||
if (key === '_') {
|
||||
if (!Array.isArray(val)) {
|
||||
throw new TypeError('Expected key \'_\' to be an array, but found ' + (typeof val));
|
||||
}
|
||||
|
||||
extraArgs = val;
|
||||
return;
|
||||
}
|
||||
|
||||
if (val === true) {
|
||||
args.push(argFn(key, ''));
|
||||
}
|
||||
|
||||
if (val === false && !opts.ignoreFalse) {
|
||||
args.push(argFn('no-' + key));
|
||||
}
|
||||
|
||||
if (typeof val === 'string') {
|
||||
args.push(argFn(key, val, separator));
|
||||
}
|
||||
|
||||
if (typeof val === 'number' && !numberIsNan(val)) {
|
||||
args.push(argFn(key, String(val), separator));
|
||||
}
|
||||
|
||||
if (Array.isArray(val)) {
|
||||
val.forEach(function (arrVal) {
|
||||
args.push(argFn(key, arrVal, separator));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
extraArgs.forEach(function (extraArgVal) {
|
||||
args.push(String(extraArgVal));
|
||||
});
|
||||
|
||||
return args;
|
||||
};
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
55
node_modules/conventional-recommended-bump/node_modules/dargs/package.json
generated
vendored
100644
55
node_modules/conventional-recommended-bump/node_modules/dargs/package.json
generated
vendored
100644
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"name": "dargs",
|
||||
"version": "4.1.0",
|
||||
"description": "Reverse minimist. Convert an object of options into an array of command-line arguments.",
|
||||
"repository": "sindresorhus/dargs",
|
||||
"keywords": [
|
||||
"options",
|
||||
"arguments",
|
||||
"args",
|
||||
"flags",
|
||||
"cli",
|
||||
"nopt",
|
||||
"minimist",
|
||||
"bin",
|
||||
"binary",
|
||||
"command",
|
||||
"cmd",
|
||||
"reverse",
|
||||
"inverse",
|
||||
"opposite",
|
||||
"invert",
|
||||
"switch",
|
||||
"construct",
|
||||
"parse",
|
||||
"parser",
|
||||
"argv"
|
||||
],
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"dependencies": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"array-equal": "^1.0.0",
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
]
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/dargs/-/dargs-4.1.0.tgz"
|
||||
,"_integrity": "sha1-A6nbtLXC8Tm/FK5T8LiipqhvThc="
|
||||
,"_from": "dargs@4.1.0"
|
||||
}
|
||||
148
node_modules/conventional-recommended-bump/node_modules/dargs/readme.md
generated
vendored
100644
148
node_modules/conventional-recommended-bump/node_modules/dargs/readme.md
generated
vendored
100644
|
|
@ -0,0 +1,148 @@
|
|||
# dargs [](https://travis-ci.org/sindresorhus/dargs)
|
||||
|
||||
> Reverse [`minimist`](https://github.com/substack/minimist). Convert an object of options into an array of command-line arguments.
|
||||
|
||||
Useful when spawning command-line tools.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save dargs
|
||||
```
|
||||
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
const dargs = require('dargs');
|
||||
|
||||
const input = {
|
||||
_: ['some', 'option'], // values in '_' will be appended to the end of the generated argument list
|
||||
foo: 'bar',
|
||||
hello: true, // results in only the key being used
|
||||
cake: false, // prepends `no-` before the key
|
||||
camelCase: 5, // camelCase is slugged to `camel-case`
|
||||
multiple: ['value', 'value2'], // converted to multiple arguments
|
||||
pieKind: 'cherry',
|
||||
sad: ':('
|
||||
};
|
||||
|
||||
const excludes = ['sad', /.*Kind$/]; // excludes and includes accept regular expressions
|
||||
const includes = ['camelCase', 'multiple', 'sad', /^pie.*/];
|
||||
const aliases = {file: 'f'};
|
||||
|
||||
console.log(dargs(input, {excludes: excludes}));
|
||||
/*
|
||||
[
|
||||
'--foo=bar',
|
||||
'--hello',
|
||||
'--no-cake',
|
||||
'--camel-case=5',
|
||||
'--multiple=value',
|
||||
'--multiple=value2',
|
||||
'some',
|
||||
'option'
|
||||
]
|
||||
*/
|
||||
|
||||
console.log(dargs(input, {
|
||||
excludes: excludes,
|
||||
includes: includes
|
||||
}));
|
||||
/*
|
||||
[
|
||||
'--camel-case=5',
|
||||
'--multiple=value',
|
||||
'--multiple=value2'
|
||||
]
|
||||
*/
|
||||
|
||||
|
||||
console.log(dargs(input, {includes: includes}));
|
||||
/*
|
||||
[
|
||||
'--camel-case=5',
|
||||
'--multiple=value',
|
||||
'--multiple=value2',
|
||||
'--pie-kind=cherry',
|
||||
'--sad=:('
|
||||
]
|
||||
*/
|
||||
|
||||
|
||||
console.log(dargs({
|
||||
foo: 'bar',
|
||||
hello: true,
|
||||
file: 'baz'
|
||||
}, {
|
||||
aliases: aliases
|
||||
}));
|
||||
/*
|
||||
[
|
||||
'--foo=bar',
|
||||
'--hello',
|
||||
'-f baz'
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### dargs(input, [options])
|
||||
|
||||
#### input
|
||||
|
||||
Type: `object`
|
||||
|
||||
Object to convert to command-line arguments.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### excludes
|
||||
|
||||
Type: `array`
|
||||
|
||||
Keys or regex of keys to exclude. Takes precedence over `includes`.
|
||||
|
||||
##### includes
|
||||
|
||||
Type: `array`
|
||||
|
||||
Keys or regex of keys to include.
|
||||
|
||||
##### aliases
|
||||
|
||||
Type: `object`
|
||||
|
||||
Maps keys in `input` to an aliased name. Matching keys are converted to options with a single dash ("-") in front of the aliased name and a space separating the aliased name from the value. Keys are still affected by `includes` and `excludes`.
|
||||
|
||||
##### useEquals
|
||||
|
||||
Type: `boolean`
|
||||
Default: `true`
|
||||
|
||||
Setting to `false` switches the separator in generated commands from an equals sign `=` to a single space ` `. For example:
|
||||
|
||||
```js
|
||||
console.log(dargs({foo: 'bar'}, {useEquals: false}));
|
||||
/*
|
||||
[
|
||||
'--foo bar'
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
##### ignoreFalse
|
||||
|
||||
Type: `boolean`
|
||||
Default: `false`
|
||||
|
||||
Don't include `false` values. This is mostly useful when dealing with strict argument parsers that would throw on unknown arguments like `--no-foo`.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
||||
108
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/CHANGELOG.md
generated
vendored
100644
108
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/CHANGELOG.md
generated
vendored
100644
|
|
@ -0,0 +1,108 @@
|
|||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
<a name="2.0.0"></a>
|
||||
# [2.0.0](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@1.3.6...git-raw-commits@2.0.0) (2018-05-29)
|
||||
|
||||
|
||||
### Chores
|
||||
|
||||
* **package:** set Node requirement to oldest supported LTS ([#329](https://github.com/conventional-changelog/conventional-changelog/issues/329)) ([cae2fe0](https://github.com/conventional-changelog/conventional-changelog/commit/cae2fe0))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* **package:** Set the package's minimum required Node version to be the oldest LTS
|
||||
currently supported by the Node Release working group. At this time,
|
||||
that is Node 6 (which is in its Maintenance LTS phase).
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="1.3.6"></a>
|
||||
## [1.3.6](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@1.3.5...git-raw-commits@1.3.6) (2018-03-27)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package git-raw-commits
|
||||
|
||||
<a name="1.3.5"></a>
|
||||
## [1.3.5](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@1.3.4...git-raw-commits@1.3.5) (2018-03-22)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package git-raw-commits
|
||||
|
||||
<a name="1.3.4"></a>
|
||||
## [1.3.4](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@1.3.3...git-raw-commits@1.3.4) (2018-02-24)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package git-raw-commits
|
||||
|
||||
<a name="1.3.3"></a>
|
||||
## [1.3.3](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@1.3.2...git-raw-commits@1.3.3) (2018-02-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package git-raw-commits
|
||||
|
||||
<a name="1.3.2"></a>
|
||||
## [1.3.2](https://github.com/conventional-changelog/git-raw-commits/compare/git-raw-commits@1.3.1...git-raw-commits@1.3.2) (2018-02-13)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package git-raw-commits
|
||||
|
||||
<a name="1.3.1"></a>
|
||||
## [1.3.1](https://github.com/conventional-changelog/git-raw-commits/compare/git-raw-commits@1.3.0...git-raw-commits@1.3.1) (2018-02-13)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package git-raw-commits
|
||||
|
||||
<a name="1.3.0"></a>
|
||||
# [1.3.0](https://github.com/conventional-changelog/git-raw-commits/compare/git-raw-commits@1.2.0...git-raw-commits@1.3.0) (2017-11-13)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **git-raw-commits:** add execOpts.cwd ([2631213](https://github.com/conventional-changelog/git-raw-commits/commit/2631213))
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="1.2.0"></a>
|
||||
# [1.2.0](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@1.1.2...v1.2.0) (2017-03-10)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* allow raw commits to be filtered by path ([#172](https://github.com/conventional-changelog/conventional-changelog/issues/172)) ([ec0a25d](https://github.com/conventional-changelog/conventional-changelog/commit/ec0a25d))
|
||||
* migrate repo to lerna mono-repo ([793e823](https://github.com/conventional-changelog/conventional-changelog/commit/793e823))
|
||||
|
||||
<a name="1.1.2"></a>
|
||||
## [1.1.2](https://github.com/conventional-changelog/git-raw-commits/compare/v1.1.1...v1.1.2) (2016-06-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **windows:** use execFile for executing git ([9ae06df](https://github.com/conventional-changelog/git-raw-commits/commit/9ae06df)), closes [#11](https://github.com/conventional-changelog/git-raw-commits/issues/11)
|
||||
|
||||
|
||||
|
||||
<a name="1.1.1"></a>
|
||||
## [1.1.1](https://github.com/conventional-changelog/git-raw-commits/compare/v1.1.0...v1.1.1) (2016-06-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **windows:** escape command percent signs ([005b559](https://github.com/conventional-changelog/git-raw-commits/commit/005b559)), closes [#10](https://github.com/conventional-changelog/git-raw-commits/issues/10)
|
||||
21
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/LICENSE.md
generated
vendored
100644
21
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/LICENSE.md
generated
vendored
100644
|
|
@ -0,0 +1,21 @@
|
|||
### MIT License
|
||||
|
||||
Copyright © [conventional-changelog team](https://github.com/conventional-changelog)
|
||||
|
||||
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.
|
||||
101
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/README.md
generated
vendored
100644
101
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/README.md
generated
vendored
100644
|
|
@ -0,0 +1,101 @@
|
|||
# [![NPM version][npm-image]][npm-url] [![Build Status: Linux][travis-image]][travis-url] [![Build Status: Windows][appveyor-image]][appveyor-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coveralls-image]][coveralls-url]
|
||||
|
||||
> Get raw git commits out of your repository using git-log(1)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install --save git-raw-commits
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var gitRawCommits = require('git-raw-commits');
|
||||
|
||||
gitRawCommits(options)
|
||||
.pipe(...);
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### gitRawCommits(gitOpts, [execOpts])
|
||||
|
||||
Returns a readable stream. Stream is split to break on each commit.
|
||||
|
||||
#### gitOpts
|
||||
|
||||
Type: `object`
|
||||
|
||||
Please check the available options at http://git-scm.com/docs/git-log.
|
||||
**NOTE:** Single dash arguments are not supported because of https://github.com/sindresorhus/dargs/blob/master/index.js#L5.
|
||||
|
||||
*NOTE*: for `<revision range>` we can also use `<from>..<to>` pattern, and this module has the following extra options for shortcut of this pattern:
|
||||
|
||||
##### gitOpts.from
|
||||
|
||||
Type: `string` Default: `''`
|
||||
|
||||
##### gitOpts.to
|
||||
|
||||
Type: `string` Default: `'HEAD'`
|
||||
|
||||
This module also have the following additions:
|
||||
|
||||
##### gitOpts.format
|
||||
|
||||
Type: `string` Default: `'%B'`
|
||||
|
||||
Please check http://git-scm.com/docs/git-log for format options.
|
||||
|
||||
##### gitOpts.debug
|
||||
|
||||
Type: `function`
|
||||
|
||||
A function to get debug information.
|
||||
|
||||
##### gitOpts.path
|
||||
|
||||
Type: `string`
|
||||
|
||||
Filter commits to the path provided.
|
||||
|
||||
##### execOpts
|
||||
|
||||
Options to pass to `git` `childProcess`
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### execOpts.cwd
|
||||
|
||||
Type: `string`
|
||||
|
||||
Current working directory to execute git in
|
||||
|
||||
|
||||
## CLI
|
||||
|
||||
```sh
|
||||
$ npm install --global git-raw-commits
|
||||
$ git-raw-commits --help # for more details
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Steve Mao](https://github.com/stevemao)
|
||||
|
||||
|
||||
[npm-image]: https://badge.fury.io/js/git-raw-commits.svg
|
||||
[npm-url]: https://npmjs.org/package/git-raw-commits
|
||||
[travis-image]: https://travis-ci.org/conventional-changelog/git-raw-commits.svg?branch=master
|
||||
[travis-url]: https://travis-ci.org/conventional-changelog/git-raw-commits
|
||||
[appveyor-image]: https://ci.appveyor.com/api/projects/status/4qm3bjmg41k3dsbv/branch/master?svg=true
|
||||
[appveyor-url]: https://ci.appveyor.com/project/stevemao/git-raw-commits/branch/master
|
||||
[daviddm-image]: https://david-dm.org/conventional-changelog/git-raw-commits.svg?theme=shields.io
|
||||
[daviddm-url]: https://david-dm.org/conventional-changelog/git-raw-commits
|
||||
[coveralls-image]: https://coveralls.io/repos/conventional-changelog/git-raw-commits/badge.svg
|
||||
[coveralls-url]: https://coveralls.io/r/conventional-changelog/git-raw-commits
|
||||
19
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/cli.js
generated
vendored
100755
19
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/cli.js
generated
vendored
100755
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env node
|
||||
'use strict'
|
||||
var meow = require('meow')
|
||||
var gitRawCommits = require('./')
|
||||
|
||||
var cli = meow(`
|
||||
Usage
|
||||
git-raw-commits [<git-log(1)-options>]
|
||||
|
||||
Example
|
||||
git-raw-commits --from HEAD~2 --to HEAD^`
|
||||
)
|
||||
|
||||
gitRawCommits(cli.flags)
|
||||
.on('error', function (err) {
|
||||
process.stderr.write(err)
|
||||
process.exit(1)
|
||||
})
|
||||
.pipe(process.stdout)
|
||||
90
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/index.js
generated
vendored
100644
90
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/index.js
generated
vendored
100644
|
|
@ -0,0 +1,90 @@
|
|||
'use strict'
|
||||
|
||||
var dargs = require('dargs')
|
||||
var execFile = require('child_process').execFile
|
||||
var split = require('split2')
|
||||
var stream = require('stream')
|
||||
var template = require('lodash.template')
|
||||
var through = require('through2')
|
||||
|
||||
var DELIMITER = '------------------------ >8 ------------------------'
|
||||
|
||||
function normalizeExecOpts (execOpts) {
|
||||
execOpts = execOpts || {}
|
||||
execOpts.cwd = execOpts.cwd || process.cwd()
|
||||
return execOpts
|
||||
}
|
||||
|
||||
function normalizeGitOpts (gitOpts) {
|
||||
gitOpts = gitOpts || {}
|
||||
gitOpts.format = gitOpts.format || '%B'
|
||||
gitOpts.from = gitOpts.from || ''
|
||||
gitOpts.to = gitOpts.to || 'HEAD'
|
||||
return gitOpts
|
||||
}
|
||||
|
||||
function getGitArgs (gitOpts) {
|
||||
var gitFormat = template('--format=<%= format %>%n' + DELIMITER)(gitOpts)
|
||||
var gitFromTo = [gitOpts.from, gitOpts.to].filter(Boolean).join('..')
|
||||
|
||||
var gitArgs = ['log', gitFormat, gitFromTo]
|
||||
|
||||
// allow commits to focus on a single directory
|
||||
// this is useful for monorepos.
|
||||
if (gitOpts.path) {
|
||||
gitArgs.push('--', gitOpts.path)
|
||||
}
|
||||
|
||||
return gitArgs.concat(dargs(gitOpts, {
|
||||
excludes: ['debug', 'from', 'to', 'format', 'path']
|
||||
}))
|
||||
}
|
||||
|
||||
function gitRawCommits (rawGitOpts, rawExecOpts) {
|
||||
var readable = new stream.Readable()
|
||||
readable._read = function () {}
|
||||
|
||||
var gitOpts = normalizeGitOpts(rawGitOpts)
|
||||
var execOpts = normalizeExecOpts(rawExecOpts)
|
||||
var args = getGitArgs(gitOpts)
|
||||
|
||||
if (gitOpts.debug) {
|
||||
gitOpts.debug('Your git-log command is:\ngit ' + args.join(' '))
|
||||
}
|
||||
|
||||
var isError = false
|
||||
|
||||
var child = execFile('git', args, {
|
||||
cwd: execOpts.cwd,
|
||||
maxBuffer: Infinity
|
||||
})
|
||||
|
||||
child.stdout
|
||||
.pipe(split(DELIMITER + '\n'))
|
||||
.pipe(through(function (chunk, enc, cb) {
|
||||
readable.push(chunk)
|
||||
isError = false
|
||||
|
||||
cb()
|
||||
}, function (cb) {
|
||||
setImmediate(function () {
|
||||
if (!isError) {
|
||||
readable.push(null)
|
||||
readable.emit('close')
|
||||
}
|
||||
|
||||
cb()
|
||||
})
|
||||
}))
|
||||
|
||||
child.stderr
|
||||
.pipe(through.obj(function (chunk) {
|
||||
isError = true
|
||||
readable.emit('error', new Error(chunk))
|
||||
readable.emit('close')
|
||||
}))
|
||||
|
||||
return readable
|
||||
}
|
||||
|
||||
module.exports = gitRawCommits
|
||||
96
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/node_modules/meow/index.js
generated
vendored
100644
96
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/node_modules/meow/index.js
generated
vendored
100644
|
|
@ -0,0 +1,96 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const buildMinimistOptions = require('minimist-options');
|
||||
const minimist = require('minimist');
|
||||
const camelcaseKeys = require('camelcase-keys');
|
||||
const decamelizeKeys = require('decamelize-keys');
|
||||
const trimNewlines = require('trim-newlines');
|
||||
const redent = require('redent');
|
||||
const readPkgUp = require('read-pkg-up');
|
||||
const loudRejection = require('loud-rejection');
|
||||
const normalizePackageData = require('normalize-package-data');
|
||||
|
||||
// Prevent caching of this module so module.parent is always accurate
|
||||
delete require.cache[__filename];
|
||||
const parentDir = path.dirname(module.parent.filename);
|
||||
|
||||
module.exports = (helpMessage, opts) => {
|
||||
loudRejection();
|
||||
|
||||
if (typeof helpMessage === 'object' && !Array.isArray(helpMessage)) {
|
||||
opts = helpMessage;
|
||||
helpMessage = '';
|
||||
}
|
||||
|
||||
opts = Object.assign({
|
||||
pkg: readPkgUp.sync({
|
||||
cwd: parentDir,
|
||||
normalize: false
|
||||
}).pkg || {},
|
||||
argv: process.argv.slice(2),
|
||||
inferType: false,
|
||||
input: 'string',
|
||||
help: helpMessage,
|
||||
autoHelp: true,
|
||||
autoVersion: true
|
||||
}, opts);
|
||||
|
||||
let minimistOpts = Object.assign({
|
||||
arguments: opts.input
|
||||
}, opts.flags);
|
||||
|
||||
minimistOpts = decamelizeKeys(minimistOpts, '-', {exclude: ['stopEarly', '--']});
|
||||
|
||||
if (opts.inferType) {
|
||||
delete minimistOpts.arguments;
|
||||
}
|
||||
|
||||
minimistOpts = buildMinimistOptions(minimistOpts);
|
||||
|
||||
const pkg = opts.pkg;
|
||||
const argv = minimist(opts.argv, minimistOpts);
|
||||
let help = redent(trimNewlines((opts.help || '').replace(/\t+\n*$/, '')), 2);
|
||||
|
||||
normalizePackageData(pkg);
|
||||
|
||||
process.title = pkg.bin ? Object.keys(pkg.bin)[0] : pkg.name;
|
||||
|
||||
let description = opts.description;
|
||||
if (!description && description !== false) {
|
||||
description = pkg.description;
|
||||
}
|
||||
|
||||
help = (description ? `\n ${description}\n` : '') + (help ? `\n${help}\n` : '\n');
|
||||
|
||||
const showHelp = code => {
|
||||
console.log(help);
|
||||
process.exit(typeof code === 'number' ? code : 2);
|
||||
};
|
||||
|
||||
const showVersion = () => {
|
||||
console.log(typeof opts.version === 'string' ? opts.version : pkg.version);
|
||||
process.exit();
|
||||
};
|
||||
|
||||
if (argv.version && opts.autoVersion) {
|
||||
showVersion();
|
||||
}
|
||||
|
||||
if (argv.help && opts.autoHelp) {
|
||||
showHelp(0);
|
||||
}
|
||||
|
||||
const input = argv._;
|
||||
delete argv._;
|
||||
|
||||
const flags = camelcaseKeys(argv, {exclude: ['--', /^\w$/]});
|
||||
|
||||
return {
|
||||
input,
|
||||
flags,
|
||||
pkg,
|
||||
help,
|
||||
showHelp,
|
||||
showVersion
|
||||
};
|
||||
};
|
||||
9
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/node_modules/meow/license
generated
vendored
100644
9
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/node_modules/meow/license
generated
vendored
100644
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
66
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/node_modules/meow/package.json
generated
vendored
100644
66
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/node_modules/meow/package.json
generated
vendored
100644
|
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
"name": "meow",
|
||||
"version": "4.0.1",
|
||||
"description": "CLI app helper",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/meow",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"cli",
|
||||
"bin",
|
||||
"util",
|
||||
"utility",
|
||||
"helper",
|
||||
"argv",
|
||||
"command",
|
||||
"line",
|
||||
"meow",
|
||||
"cat",
|
||||
"kitten",
|
||||
"parser",
|
||||
"option",
|
||||
"flags",
|
||||
"input",
|
||||
"cmd",
|
||||
"console"
|
||||
],
|
||||
"dependencies": {
|
||||
"camelcase-keys": "^4.0.0",
|
||||
"decamelize-keys": "^1.0.0",
|
||||
"loud-rejection": "^1.0.0",
|
||||
"minimist": "^1.1.3",
|
||||
"minimist-options": "^3.0.1",
|
||||
"normalize-package-data": "^2.3.4",
|
||||
"read-pkg-up": "^3.0.0",
|
||||
"redent": "^2.0.0",
|
||||
"trim-newlines": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"execa": "^0.8.0",
|
||||
"indent-string": "^3.0.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"rules": {
|
||||
"unicorn/no-process-exit": "off"
|
||||
}
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/meow/-/meow-4.0.1.tgz"
|
||||
,"_integrity": "sha512-xcSBHD5Z86zaOc+781KrupuHAzeGXSLtiAOmBsiLDiPSaYSB6hdew2ng9EBAnZ62jagG9MHAOdxpDi/lWBFJ/A=="
|
||||
,"_from": "meow@4.0.1"
|
||||
}
|
||||
197
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/node_modules/meow/readme.md
generated
vendored
100644
197
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/node_modules/meow/readme.md
generated
vendored
100644
|
|
@ -0,0 +1,197 @@
|
|||
# meow [](https://travis-ci.org/sindresorhus/meow)
|
||||
|
||||
> CLI app helper
|
||||
|
||||

|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- Parses arguments
|
||||
- Converts flags to [camelCase](https://github.com/sindresorhus/camelcase)
|
||||
- Outputs version when `--version`
|
||||
- Outputs description and supplied help text when `--help`
|
||||
- Makes unhandled rejected promises [fail loudly](https://github.com/sindresorhus/loud-rejection) instead of the default silent fail
|
||||
- Sets the process title to the binary name defined in package.json
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install meow
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
$ ./foo-app.js unicorns --rainbow
|
||||
```
|
||||
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
const meow = require('meow');
|
||||
const foo = require('.');
|
||||
|
||||
const cli = meow(`
|
||||
Usage
|
||||
$ foo <input>
|
||||
|
||||
Options
|
||||
--rainbow, -r Include a rainbow
|
||||
|
||||
Examples
|
||||
$ foo unicorns --rainbow
|
||||
🌈 unicorns 🌈
|
||||
`, {
|
||||
flags: {
|
||||
rainbow: {
|
||||
type: 'boolean',
|
||||
alias: 'r'
|
||||
}
|
||||
}
|
||||
});
|
||||
/*
|
||||
{
|
||||
input: ['unicorns'],
|
||||
flags: {rainbow: true},
|
||||
...
|
||||
}
|
||||
*/
|
||||
|
||||
foo(cli.input[0], cli.flags);
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### meow(options, [minimistOptions])
|
||||
|
||||
Returns an `Object` with:
|
||||
|
||||
- `input` *(Array)* - Non-flag arguments
|
||||
- `flags` *(Object)* - Flags converted to camelCase
|
||||
- `pkg` *(Object)* - The `package.json` object
|
||||
- `help` *(string)* - The help text used with `--help`
|
||||
- `showHelp([code=2])` *(Function)* - Show the help text and exit with `code`
|
||||
- `showVersion()` *(Function)* - Show the version text and exit
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object` `Array` `string`
|
||||
|
||||
Can either be a string/array that is the `help` or an options object.
|
||||
|
||||
##### flags
|
||||
|
||||
Type: `Object`
|
||||
|
||||
Define argument flags.
|
||||
|
||||
The key is the flag name and the value is an object with any of:
|
||||
|
||||
- `type`: Type of value. (Possible values: `string` `boolean`)
|
||||
- `alias`: Usually used to define a short flag alias.
|
||||
- `default`: Default value when the flag is not specified.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
flags: {
|
||||
unicorn: {
|
||||
type: 'string',
|
||||
alias: 'u',
|
||||
default: 'rainbow'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
##### description
|
||||
|
||||
Type: `string` `boolean`<br>
|
||||
Default: The package.json `"description"` property
|
||||
|
||||
Description to show above the help text.
|
||||
|
||||
Set it to `false` to disable it altogether.
|
||||
|
||||
##### help
|
||||
|
||||
Type: `string` `boolean`
|
||||
|
||||
The help text you want shown.
|
||||
|
||||
The input is reindented and starting/ending newlines are trimmed which means you can use a [template literal](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/template_strings) without having to care about using the correct amount of indent.
|
||||
|
||||
The description will be shown above your help text automatically.
|
||||
|
||||
##### version
|
||||
|
||||
Type: `string` `boolean`<br>
|
||||
Default: The package.json `"version"` property
|
||||
|
||||
Set a custom version output.
|
||||
|
||||
##### autoHelp
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Automatically show the help text when the `--help` flag is present. Useful to set this value to `false` when a CLI manages child CLIs with their own help text.
|
||||
|
||||
##### autoVersion
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Automatically show the version text when the `--version` flag is present. Useful to set this value to `false` when a CLI manages child CLIs with their own version text.
|
||||
|
||||
##### pkg
|
||||
|
||||
Type: `Object`<br>
|
||||
Default: Closest package.json upwards
|
||||
|
||||
package.json as an `Object`.
|
||||
|
||||
*You most likely don't need this option.*
|
||||
|
||||
##### argv
|
||||
|
||||
Type: `Array`<br>
|
||||
Default: `process.argv.slice(2)`
|
||||
|
||||
Custom arguments object.
|
||||
|
||||
##### inferType
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Infer the argument type.
|
||||
|
||||
By default, the argument `5` in `$ foo 5` becomes a string. Enabling this would infer it as a number.
|
||||
|
||||
|
||||
## Promises
|
||||
|
||||
Meow will make unhandled rejected promises [fail loudly](https://github.com/sindresorhus/loud-rejection) instead of the default silent fail. Meaning you don't have to manually `.catch()` promises used in your CLI.
|
||||
|
||||
|
||||
## Tips
|
||||
|
||||
See [`chalk`](https://github.com/chalk/chalk) if you want to colorize the terminal output.
|
||||
|
||||
See [`get-stdin`](https://github.com/sindresorhus/get-stdin) if you want to accept input from stdin.
|
||||
|
||||
See [`conf`](https://github.com/sindresorhus/conf) if you need to persist some data.
|
||||
|
||||
See [`update-notifier`](https://github.com/yeoman/update-notifier) if you want update notifications.
|
||||
|
||||
[More useful CLI utilities…](https://github.com/sindresorhus/awesome-nodejs#command-line-utilities)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
58
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/package.json
generated
vendored
100644
58
node_modules/conventional-recommended-bump/node_modules/git-raw-commits/package.json
generated
vendored
100644
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"name": "git-raw-commits",
|
||||
"version": "2.0.0",
|
||||
"description": "Get raw git commits out of your repository using git-log(1)",
|
||||
"bugs": {
|
||||
"url": "https://github.com/conventional-changelog/conventional-changelog/issues"
|
||||
},
|
||||
"homepage": "https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/git-raw-commits#readme",
|
||||
"author": {
|
||||
"name": "Steve Mao",
|
||||
"email": "maochenyan@gmail.com",
|
||||
"url": "https://github.com/stevemao"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/conventional-changelog/conventional-changelog.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"cli.js"
|
||||
],
|
||||
"keywords": [
|
||||
"git-raw-commits",
|
||||
"raw",
|
||||
"commit",
|
||||
"commits",
|
||||
"git",
|
||||
"log",
|
||||
"git-log"
|
||||
],
|
||||
"dependencies": {
|
||||
"dargs": "^4.0.1",
|
||||
"lodash.template": "^4.0.2",
|
||||
"meow": "^4.0.0",
|
||||
"split2": "^2.0.0",
|
||||
"through2": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mkdirp": "^0.5.1",
|
||||
"shelljs": "^0.8.0"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --fix .",
|
||||
"test": "npm run-script lint && mocha --timeout 30000",
|
||||
"test-windows": "mocha --timeout 30000"
|
||||
},
|
||||
"bin": {
|
||||
"git-raw-commits": "cli.js"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/git-raw-commits/-/git-raw-commits-2.0.0.tgz"
|
||||
,"_integrity": "sha512-w4jFEJFgKXMQJ0H0ikBk2S+4KP2VEjhCvLCNqbNRQC8BgGWgLKNCO7a9K9LI+TVT7Gfoloje502sEnctibffgg=="
|
||||
,"_from": "git-raw-commits@2.0.0"
|
||||
}
|
||||
151
node_modules/conventional-recommended-bump/node_modules/hosted-git-info/CHANGELOG.md
generated
vendored
100644
151
node_modules/conventional-recommended-bump/node_modules/hosted-git-info/CHANGELOG.md
generated
vendored
100644
|
|
@ -0,0 +1,151 @@
|
|||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
<a name="2.8.9"></a>
|
||||
## [2.8.9](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9) (2021-04-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* backport regex fix from [#76](https://github.com/npm/hosted-git-info/issues/76) ([29adfe5](https://github.com/npm/hosted-git-info/commit/29adfe5)), closes [#84](https://github.com/npm/hosted-git-info/issues/84)
|
||||
|
||||
|
||||
|
||||
<a name="2.8.8"></a>
|
||||
## [2.8.8](https://github.com/npm/hosted-git-info/compare/v2.8.7...v2.8.8) (2020-02-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#61](https://github.com/npm/hosted-git-info/issues/61) & [#65](https://github.com/npm/hosted-git-info/issues/65) addressing issues w/ url.URL implmentation which regressed node 6 support ([5038b18](https://github.com/npm/hosted-git-info/commit/5038b18)), closes [#66](https://github.com/npm/hosted-git-info/issues/66)
|
||||
|
||||
|
||||
|
||||
<a name="2.8.7"></a>
|
||||
## [2.8.7](https://github.com/npm/hosted-git-info/compare/v2.8.6...v2.8.7) (2020-02-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Do not attempt to use url.URL when unavailable ([2d0bb66](https://github.com/npm/hosted-git-info/commit/2d0bb66)), closes [#61](https://github.com/npm/hosted-git-info/issues/61) [#62](https://github.com/npm/hosted-git-info/issues/62)
|
||||
* Do not pass scp-style URLs to the WhatWG url.URL ([f2cdfcf](https://github.com/npm/hosted-git-info/commit/f2cdfcf)), closes [#60](https://github.com/npm/hosted-git-info/issues/60)
|
||||
|
||||
|
||||
|
||||
<a name="2.8.6"></a>
|
||||
## [2.8.6](https://github.com/npm/hosted-git-info/compare/v2.8.5...v2.8.6) (2020-02-25)
|
||||
|
||||
|
||||
|
||||
<a name="2.8.5"></a>
|
||||
## [2.8.5](https://github.com/npm/hosted-git-info/compare/v2.8.4...v2.8.5) (2019-10-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* updated pathmatch for gitlab ([e8325b5](https://github.com/npm/hosted-git-info/commit/e8325b5)), closes [#51](https://github.com/npm/hosted-git-info/issues/51)
|
||||
* updated pathmatch for gitlab ([ffe056f](https://github.com/npm/hosted-git-info/commit/ffe056f))
|
||||
|
||||
|
||||
|
||||
<a name="2.8.4"></a>
|
||||
## [2.8.4](https://github.com/npm/hosted-git-info/compare/v2.8.3...v2.8.4) (2019-08-12)
|
||||
|
||||
|
||||
|
||||
<a name="2.8.3"></a>
|
||||
## [2.8.3](https://github.com/npm/hosted-git-info/compare/v2.8.2...v2.8.3) (2019-08-12)
|
||||
|
||||
|
||||
|
||||
<a name="2.8.2"></a>
|
||||
## [2.8.2](https://github.com/npm/hosted-git-info/compare/v2.8.1...v2.8.2) (2019-08-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* http protocol use sshurl by default ([3b1d629](https://github.com/npm/hosted-git-info/commit/3b1d629)), closes [#48](https://github.com/npm/hosted-git-info/issues/48)
|
||||
|
||||
|
||||
|
||||
<a name="2.8.1"></a>
|
||||
## [2.8.1](https://github.com/npm/hosted-git-info/compare/v2.8.0...v2.8.1) (2019-08-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* ignore noCommittish on tarball url generation ([5d4a8d7](https://github.com/npm/hosted-git-info/commit/5d4a8d7))
|
||||
* use gist tarball url that works for anonymous gists ([1692435](https://github.com/npm/hosted-git-info/commit/1692435))
|
||||
|
||||
|
||||
|
||||
<a name="2.8.0"></a>
|
||||
# [2.8.0](https://github.com/npm/hosted-git-info/compare/v2.7.1...v2.8.0) (2019-08-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Allow slashes in gitlab project section ([bbcf7b2](https://github.com/npm/hosted-git-info/commit/bbcf7b2)), closes [#46](https://github.com/npm/hosted-git-info/issues/46) [#43](https://github.com/npm/hosted-git-info/issues/43)
|
||||
* **git-host:** disallow URI-encoded slash (%2F) in `path` ([3776fa5](https://github.com/npm/hosted-git-info/commit/3776fa5)), closes [#44](https://github.com/npm/hosted-git-info/issues/44)
|
||||
* **gitlab:** Do not URL encode slashes in project name for GitLab https URL ([cbf04f9](https://github.com/npm/hosted-git-info/commit/cbf04f9)), closes [#47](https://github.com/npm/hosted-git-info/issues/47)
|
||||
* do not allow invalid gist urls ([d5cf830](https://github.com/npm/hosted-git-info/commit/d5cf830))
|
||||
* **cache:** Switch to lru-cache to save ourselves from unlimited memory consumption ([e518222](https://github.com/npm/hosted-git-info/commit/e518222)), closes [#38](https://github.com/npm/hosted-git-info/issues/38)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* give these objects a name ([60abaea](https://github.com/npm/hosted-git-info/commit/60abaea))
|
||||
|
||||
|
||||
|
||||
<a name="2.7.1"></a>
|
||||
## [2.7.1](https://github.com/npm/hosted-git-info/compare/v2.7.0...v2.7.1) (2018-07-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **index:** Guard against non-string types ([5bc580d](https://github.com/npm/hosted-git-info/commit/5bc580d))
|
||||
* **parse:** Crash on strings that parse to having no host ([c931482](https://github.com/npm/hosted-git-info/commit/c931482)), closes [#35](https://github.com/npm/hosted-git-info/issues/35)
|
||||
|
||||
|
||||
|
||||
<a name="2.7.0"></a>
|
||||
# [2.7.0](https://github.com/npm/hosted-git-info/compare/v2.6.1...v2.7.0) (2018-07-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **github tarball:** update github tarballtemplate ([6efd582](https://github.com/npm/hosted-git-info/commit/6efd582)), closes [#34](https://github.com/npm/hosted-git-info/issues/34)
|
||||
* **gitlab docs:** switched to lowercase anchors for readmes ([701bcd1](https://github.com/npm/hosted-git-info/commit/701bcd1))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **all:** Support www. prefixes on hostnames ([3349575](https://github.com/npm/hosted-git-info/commit/3349575)), closes [#32](https://github.com/npm/hosted-git-info/issues/32)
|
||||
|
||||
|
||||
|
||||
<a name="2.6.1"></a>
|
||||
## [2.6.1](https://github.com/npm/hosted-git-info/compare/v2.6.0...v2.6.1) (2018-06-25)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **Revert:** "compat: remove Object.assign fallback ([#25](https://github.com/npm/hosted-git-info/issues/25))" ([cce5a62](https://github.com/npm/hosted-git-info/commit/cce5a62))
|
||||
* **Revert:** "git-host: fix forgotten extend()" ([a815ec9](https://github.com/npm/hosted-git-info/commit/a815ec9))
|
||||
|
||||
|
||||
|
||||
<a name="2.6.0"></a>
|
||||
# [2.6.0](https://github.com/npm/hosted-git-info/compare/v2.5.0...v2.6.0) (2018-03-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **compat:** remove Object.assign fallback ([#25](https://github.com/npm/hosted-git-info/issues/25)) ([627ab55](https://github.com/npm/hosted-git-info/commit/627ab55))
|
||||
* **git-host:** fix forgotten extend() ([eba1f7b](https://github.com/npm/hosted-git-info/commit/eba1f7b))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **browse:** fragment support for browse() ([#28](https://github.com/npm/hosted-git-info/issues/28)) ([cd5e5bb](https://github.com/npm/hosted-git-info/commit/cd5e5bb))
|
||||
13
node_modules/conventional-recommended-bump/node_modules/hosted-git-info/LICENSE
generated
vendored
100644
13
node_modules/conventional-recommended-bump/node_modules/hosted-git-info/LICENSE
generated
vendored
100644
|
|
@ -0,0 +1,13 @@
|
|||
Copyright (c) 2015, Rebecca Turner
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
133
node_modules/conventional-recommended-bump/node_modules/hosted-git-info/README.md
generated
vendored
100644
133
node_modules/conventional-recommended-bump/node_modules/hosted-git-info/README.md
generated
vendored
100644
|
|
@ -0,0 +1,133 @@
|
|||
# hosted-git-info
|
||||
|
||||
This will let you identify and transform various git hosts URLs between
|
||||
protocols. It also can tell you what the URL is for the raw path for
|
||||
particular file for direct access without git.
|
||||
|
||||
## Example
|
||||
|
||||
```javascript
|
||||
var hostedGitInfo = require("hosted-git-info")
|
||||
var info = hostedGitInfo.fromUrl("git@github.com:npm/hosted-git-info.git", opts)
|
||||
/* info looks like:
|
||||
{
|
||||
type: "github",
|
||||
domain: "github.com",
|
||||
user: "npm",
|
||||
project: "hosted-git-info"
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
If the URL can't be matched with a git host, `null` will be returned. We
|
||||
can match git, ssh and https urls. Additionally, we can match ssh connect
|
||||
strings (`git@github.com:npm/hosted-git-info`) and shortcuts (eg,
|
||||
`github:npm/hosted-git-info`). Github specifically, is detected in the case
|
||||
of a third, unprefixed, form: `npm/hosted-git-info`.
|
||||
|
||||
If it does match, the returned object has properties of:
|
||||
|
||||
* info.type -- The short name of the service
|
||||
* info.domain -- The domain for git protocol use
|
||||
* info.user -- The name of the user/org on the git host
|
||||
* info.project -- The name of the project on the git host
|
||||
|
||||
## Version Contract
|
||||
|
||||
The major version will be bumped any time…
|
||||
|
||||
* The constructor stops accepting URLs that it previously accepted.
|
||||
* A method is removed.
|
||||
* A method can no longer accept the number and type of arguments it previously accepted.
|
||||
* A method can return a different type than it currently returns.
|
||||
|
||||
Implications:
|
||||
|
||||
* I do not consider the specific format of the urls returned from, say
|
||||
`.https()` to be a part of the contract. The contract is that it will
|
||||
return a string that can be used to fetch the repo via HTTPS. But what
|
||||
that string looks like, specifically, can change.
|
||||
* Dropping support for a hosted git provider would constitute a breaking
|
||||
change.
|
||||
|
||||
## Usage
|
||||
|
||||
### var info = hostedGitInfo.fromUrl(gitSpecifier[, options])
|
||||
|
||||
* *gitSpecifer* is a URL of a git repository or a SCP-style specifier of one.
|
||||
* *options* is an optional object. It can have the following properties:
|
||||
* *noCommittish* — If true then committishes won't be included in generated URLs.
|
||||
* *noGitPlus* — If true then `git+` won't be prefixed on URLs.
|
||||
|
||||
## Methods
|
||||
|
||||
All of the methods take the same options as the `fromUrl` factory. Options
|
||||
provided to a method override those provided to the constructor.
|
||||
|
||||
* info.file(path, opts)
|
||||
|
||||
Given the path of a file relative to the repository, returns a URL for
|
||||
directly fetching it from the githost. If no committish was set then
|
||||
`master` will be used as the default.
|
||||
|
||||
For example `hostedGitInfo.fromUrl("git@github.com:npm/hosted-git-info.git#v1.0.0").file("package.json")`
|
||||
would return `https://raw.githubusercontent.com/npm/hosted-git-info/v1.0.0/package.json`
|
||||
|
||||
* info.shortcut(opts)
|
||||
|
||||
eg, `github:npm/hosted-git-info`
|
||||
|
||||
* info.browse(path, fragment, opts)
|
||||
|
||||
eg, `https://github.com/npm/hosted-git-info/tree/v1.2.0`,
|
||||
`https://github.com/npm/hosted-git-info/tree/v1.2.0/package.json`,
|
||||
`https://github.com/npm/hosted-git-info/tree/v1.2.0/REAMDE.md#supported-hosts`
|
||||
|
||||
* info.bugs(opts)
|
||||
|
||||
eg, `https://github.com/npm/hosted-git-info/issues`
|
||||
|
||||
* info.docs(opts)
|
||||
|
||||
eg, `https://github.com/npm/hosted-git-info/tree/v1.2.0#readme`
|
||||
|
||||
* info.https(opts)
|
||||
|
||||
eg, `git+https://github.com/npm/hosted-git-info.git`
|
||||
|
||||
* info.sshurl(opts)
|
||||
|
||||
eg, `git+ssh://git@github.com/npm/hosted-git-info.git`
|
||||
|
||||
* info.ssh(opts)
|
||||
|
||||
eg, `git@github.com:npm/hosted-git-info.git`
|
||||
|
||||
* info.path(opts)
|
||||
|
||||
eg, `npm/hosted-git-info`
|
||||
|
||||
* info.tarball(opts)
|
||||
|
||||
eg, `https://github.com/npm/hosted-git-info/archive/v1.2.0.tar.gz`
|
||||
|
||||
* info.getDefaultRepresentation()
|
||||
|
||||
Returns the default output type. The default output type is based on the
|
||||
string you passed in to be parsed
|
||||
|
||||
* info.toString(opts)
|
||||
|
||||
Uses the getDefaultRepresentation to call one of the other methods to get a URL for
|
||||
this resource. As such `hostedGitInfo.fromUrl(url).toString()` will give
|
||||
you a normalized version of the URL that still uses the same protocol.
|
||||
|
||||
Shortcuts will still be returned as shortcuts, but the special case github
|
||||
form of `org/project` will be normalized to `github:org/project`.
|
||||
|
||||
SSH connect strings will be normalized into `git+ssh` URLs.
|
||||
|
||||
## Supported hosts
|
||||
|
||||
Currently this supports Github, Bitbucket and Gitlab. Pull requests for
|
||||
additional hosts welcome.
|
||||
79
node_modules/conventional-recommended-bump/node_modules/hosted-git-info/git-host-info.js
generated
vendored
100644
79
node_modules/conventional-recommended-bump/node_modules/hosted-git-info/git-host-info.js
generated
vendored
100644
|
|
@ -0,0 +1,79 @@
|
|||
'use strict'
|
||||
|
||||
var gitHosts = module.exports = {
|
||||
github: {
|
||||
// First two are insecure and generally shouldn't be used any more, but
|
||||
// they are still supported.
|
||||
'protocols': [ 'git', 'http', 'git+ssh', 'git+https', 'ssh', 'https' ],
|
||||
'domain': 'github.com',
|
||||
'treepath': 'tree',
|
||||
'filetemplate': 'https://{auth@}raw.githubusercontent.com/{user}/{project}/{committish}/{path}',
|
||||
'bugstemplate': 'https://{domain}/{user}/{project}/issues',
|
||||
'gittemplate': 'git://{auth@}{domain}/{user}/{project}.git{#committish}',
|
||||
'tarballtemplate': 'https://codeload.{domain}/{user}/{project}/tar.gz/{committish}'
|
||||
},
|
||||
bitbucket: {
|
||||
'protocols': [ 'git+ssh', 'git+https', 'ssh', 'https' ],
|
||||
'domain': 'bitbucket.org',
|
||||
'treepath': 'src',
|
||||
'tarballtemplate': 'https://{domain}/{user}/{project}/get/{committish}.tar.gz'
|
||||
},
|
||||
gitlab: {
|
||||
'protocols': [ 'git+ssh', 'git+https', 'ssh', 'https' ],
|
||||
'domain': 'gitlab.com',
|
||||
'treepath': 'tree',
|
||||
'bugstemplate': 'https://{domain}/{user}/{project}/issues',
|
||||
'httpstemplate': 'git+https://{auth@}{domain}/{user}/{projectPath}.git{#committish}',
|
||||
'tarballtemplate': 'https://{domain}/{user}/{project}/repository/archive.tar.gz?ref={committish}',
|
||||
'pathmatch': /^[/]([^/]+)[/]((?!.*(\/-\/|\/repository\/archive\.tar\.gz\?=.*|\/repository\/[^/]+\/archive.tar.gz$)).*?)(?:[.]git|[/])?$/
|
||||
},
|
||||
gist: {
|
||||
'protocols': [ 'git', 'git+ssh', 'git+https', 'ssh', 'https' ],
|
||||
'domain': 'gist.github.com',
|
||||
'pathmatch': /^[/](?:([^/]+)[/])?([a-z0-9]{32,})(?:[.]git)?$/,
|
||||
'filetemplate': 'https://gist.githubusercontent.com/{user}/{project}/raw{/committish}/{path}',
|
||||
'bugstemplate': 'https://{domain}/{project}',
|
||||
'gittemplate': 'git://{domain}/{project}.git{#committish}',
|
||||
'sshtemplate': 'git@{domain}:/{project}.git{#committish}',
|
||||
'sshurltemplate': 'git+ssh://git@{domain}/{project}.git{#committish}',
|
||||
'browsetemplate': 'https://{domain}/{project}{/committish}',
|
||||
'browsefiletemplate': 'https://{domain}/{project}{/committish}{#path}',
|
||||
'docstemplate': 'https://{domain}/{project}{/committish}',
|
||||
'httpstemplate': 'git+https://{domain}/{project}.git{#committish}',
|
||||
'shortcuttemplate': '{type}:{project}{#committish}',
|
||||
'pathtemplate': '{project}{#committish}',
|
||||
'tarballtemplate': 'https://codeload.github.com/gist/{project}/tar.gz/{committish}',
|
||||
'hashformat': function (fragment) {
|
||||
return 'file-' + formatHashFragment(fragment)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var gitHostDefaults = {
|
||||
'sshtemplate': 'git@{domain}:{user}/{project}.git{#committish}',
|
||||
'sshurltemplate': 'git+ssh://git@{domain}/{user}/{project}.git{#committish}',
|
||||
'browsetemplate': 'https://{domain}/{user}/{project}{/tree/committish}',
|
||||
'browsefiletemplate': 'https://{domain}/{user}/{project}/{treepath}/{committish}/{path}{#fragment}',
|
||||
'docstemplate': 'https://{domain}/{user}/{project}{/tree/committish}#readme',
|
||||
'httpstemplate': 'git+https://{auth@}{domain}/{user}/{project}.git{#committish}',
|
||||
'filetemplate': 'https://{domain}/{user}/{project}/raw/{committish}/{path}',
|
||||
'shortcuttemplate': '{type}:{user}/{project}{#committish}',
|
||||
'pathtemplate': '{user}/{project}{#committish}',
|
||||
'pathmatch': /^[/]([^/]+)[/]([^/]+?)(?:[.]git|[/])?$/,
|
||||
'hashformat': formatHashFragment
|
||||
}
|
||||
|
||||
Object.keys(gitHosts).forEach(function (name) {
|
||||
Object.keys(gitHostDefaults).forEach(function (key) {
|
||||
if (gitHosts[name][key]) return
|
||||
gitHosts[name][key] = gitHostDefaults[key]
|
||||
})
|
||||
gitHosts[name].protocols_re = RegExp('^(' +
|
||||
gitHosts[name].protocols.map(function (protocol) {
|
||||
return protocol.replace(/([\\+*{}()[\]$^|])/g, '\\$1')
|
||||
}).join('|') + '):$')
|
||||
})
|
||||
|
||||
function formatHashFragment (fragment) {
|
||||
return fragment.toLowerCase().replace(/^\W+|\/|\W+$/g, '').replace(/\W+/g, '-')
|
||||
}
|
||||
156
node_modules/conventional-recommended-bump/node_modules/hosted-git-info/git-host.js
generated
vendored
100644
156
node_modules/conventional-recommended-bump/node_modules/hosted-git-info/git-host.js
generated
vendored
100644
|
|
@ -0,0 +1,156 @@
|
|||
'use strict'
|
||||
var gitHosts = require('./git-host-info.js')
|
||||
/* eslint-disable node/no-deprecated-api */
|
||||
|
||||
// copy-pasta util._extend from node's source, to avoid pulling
|
||||
// the whole util module into peoples' webpack bundles.
|
||||
/* istanbul ignore next */
|
||||
var extend = Object.assign || function _extend (target, source) {
|
||||
// Don't do anything if source isn't an object
|
||||
if (source === null || typeof source !== 'object') return target
|
||||
|
||||
var keys = Object.keys(source)
|
||||
var i = keys.length
|
||||
while (i--) {
|
||||
target[keys[i]] = source[keys[i]]
|
||||
}
|
||||
return target
|
||||
}
|
||||
|
||||
module.exports = GitHost
|
||||
function GitHost (type, user, auth, project, committish, defaultRepresentation, opts) {
|
||||
var gitHostInfo = this
|
||||
gitHostInfo.type = type
|
||||
Object.keys(gitHosts[type]).forEach(function (key) {
|
||||
gitHostInfo[key] = gitHosts[type][key]
|
||||
})
|
||||
gitHostInfo.user = user
|
||||
gitHostInfo.auth = auth
|
||||
gitHostInfo.project = project
|
||||
gitHostInfo.committish = committish
|
||||
gitHostInfo.default = defaultRepresentation
|
||||
gitHostInfo.opts = opts || {}
|
||||
}
|
||||
|
||||
GitHost.prototype.hash = function () {
|
||||
return this.committish ? '#' + this.committish : ''
|
||||
}
|
||||
|
||||
GitHost.prototype._fill = function (template, opts) {
|
||||
if (!template) return
|
||||
var vars = extend({}, opts)
|
||||
vars.path = vars.path ? vars.path.replace(/^[/]+/g, '') : ''
|
||||
opts = extend(extend({}, this.opts), opts)
|
||||
var self = this
|
||||
Object.keys(this).forEach(function (key) {
|
||||
if (self[key] != null && vars[key] == null) vars[key] = self[key]
|
||||
})
|
||||
var rawAuth = vars.auth
|
||||
var rawcommittish = vars.committish
|
||||
var rawFragment = vars.fragment
|
||||
var rawPath = vars.path
|
||||
var rawProject = vars.project
|
||||
Object.keys(vars).forEach(function (key) {
|
||||
var value = vars[key]
|
||||
if ((key === 'path' || key === 'project') && typeof value === 'string') {
|
||||
vars[key] = value.split('/').map(function (pathComponent) {
|
||||
return encodeURIComponent(pathComponent)
|
||||
}).join('/')
|
||||
} else {
|
||||
vars[key] = encodeURIComponent(value)
|
||||
}
|
||||
})
|
||||
vars['auth@'] = rawAuth ? rawAuth + '@' : ''
|
||||
vars['#fragment'] = rawFragment ? '#' + this.hashformat(rawFragment) : ''
|
||||
vars.fragment = vars.fragment ? vars.fragment : ''
|
||||
vars['#path'] = rawPath ? '#' + this.hashformat(rawPath) : ''
|
||||
vars['/path'] = vars.path ? '/' + vars.path : ''
|
||||
vars.projectPath = rawProject.split('/').map(encodeURIComponent).join('/')
|
||||
if (opts.noCommittish) {
|
||||
vars['#committish'] = ''
|
||||
vars['/tree/committish'] = ''
|
||||
vars['/committish'] = ''
|
||||
vars.committish = ''
|
||||
} else {
|
||||
vars['#committish'] = rawcommittish ? '#' + rawcommittish : ''
|
||||
vars['/tree/committish'] = vars.committish
|
||||
? '/' + vars.treepath + '/' + vars.committish
|
||||
: ''
|
||||
vars['/committish'] = vars.committish ? '/' + vars.committish : ''
|
||||
vars.committish = vars.committish || 'master'
|
||||
}
|
||||
var res = template
|
||||
Object.keys(vars).forEach(function (key) {
|
||||
res = res.replace(new RegExp('[{]' + key + '[}]', 'g'), vars[key])
|
||||
})
|
||||
if (opts.noGitPlus) {
|
||||
return res.replace(/^git[+]/, '')
|
||||
} else {
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
GitHost.prototype.ssh = function (opts) {
|
||||
return this._fill(this.sshtemplate, opts)
|
||||
}
|
||||
|
||||
GitHost.prototype.sshurl = function (opts) {
|
||||
return this._fill(this.sshurltemplate, opts)
|
||||
}
|
||||
|
||||
GitHost.prototype.browse = function (P, F, opts) {
|
||||
if (typeof P === 'string') {
|
||||
if (typeof F !== 'string') {
|
||||
opts = F
|
||||
F = null
|
||||
}
|
||||
return this._fill(this.browsefiletemplate, extend({
|
||||
fragment: F,
|
||||
path: P
|
||||
}, opts))
|
||||
} else {
|
||||
return this._fill(this.browsetemplate, P)
|
||||
}
|
||||
}
|
||||
|
||||
GitHost.prototype.docs = function (opts) {
|
||||
return this._fill(this.docstemplate, opts)
|
||||
}
|
||||
|
||||
GitHost.prototype.bugs = function (opts) {
|
||||
return this._fill(this.bugstemplate, opts)
|
||||
}
|
||||
|
||||
GitHost.prototype.https = function (opts) {
|
||||
return this._fill(this.httpstemplate, opts)
|
||||
}
|
||||
|
||||
GitHost.prototype.git = function (opts) {
|
||||
return this._fill(this.gittemplate, opts)
|
||||
}
|
||||
|
||||
GitHost.prototype.shortcut = function (opts) {
|
||||
return this._fill(this.shortcuttemplate, opts)
|
||||
}
|
||||
|
||||
GitHost.prototype.path = function (opts) {
|
||||
return this._fill(this.pathtemplate, opts)
|
||||
}
|
||||
|
||||
GitHost.prototype.tarball = function (opts_) {
|
||||
var opts = extend({}, opts_, { noCommittish: false })
|
||||
return this._fill(this.tarballtemplate, opts)
|
||||
}
|
||||
|
||||
GitHost.prototype.file = function (P, opts) {
|
||||
return this._fill(this.filetemplate, extend({ path: P }, opts))
|
||||
}
|
||||
|
||||
GitHost.prototype.getDefaultRepresentation = function () {
|
||||
return this.default
|
||||
}
|
||||
|
||||
GitHost.prototype.toString = function (opts) {
|
||||
if (this.default && typeof this[this.default] === 'function') return this[this.default](opts)
|
||||
return this.sshurl(opts)
|
||||
}
|
||||
148
node_modules/conventional-recommended-bump/node_modules/hosted-git-info/index.js
generated
vendored
100644
148
node_modules/conventional-recommended-bump/node_modules/hosted-git-info/index.js
generated
vendored
100644
|
|
@ -0,0 +1,148 @@
|
|||
'use strict'
|
||||
var url = require('url')
|
||||
var gitHosts = require('./git-host-info.js')
|
||||
var GitHost = module.exports = require('./git-host.js')
|
||||
|
||||
var protocolToRepresentationMap = {
|
||||
'git+ssh:': 'sshurl',
|
||||
'git+https:': 'https',
|
||||
'ssh:': 'sshurl',
|
||||
'git:': 'git'
|
||||
}
|
||||
|
||||
function protocolToRepresentation (protocol) {
|
||||
return protocolToRepresentationMap[protocol] || protocol.slice(0, -1)
|
||||
}
|
||||
|
||||
var authProtocols = {
|
||||
'git:': true,
|
||||
'https:': true,
|
||||
'git+https:': true,
|
||||
'http:': true,
|
||||
'git+http:': true
|
||||
}
|
||||
|
||||
var cache = {}
|
||||
|
||||
module.exports.fromUrl = function (giturl, opts) {
|
||||
if (typeof giturl !== 'string') return
|
||||
var key = giturl + JSON.stringify(opts || {})
|
||||
|
||||
if (!(key in cache)) {
|
||||
cache[key] = fromUrl(giturl, opts)
|
||||
}
|
||||
|
||||
return cache[key]
|
||||
}
|
||||
|
||||
function fromUrl (giturl, opts) {
|
||||
if (giturl == null || giturl === '') return
|
||||
var url = fixupUnqualifiedGist(
|
||||
isGitHubShorthand(giturl) ? 'github:' + giturl : giturl
|
||||
)
|
||||
var parsed = parseGitUrl(url)
|
||||
var shortcutMatch = url.match(/^([^:]+):(?:[^@]+@)?(?:([^/]*)\/)?([^#]+)/)
|
||||
var matches = Object.keys(gitHosts).map(function (gitHostName) {
|
||||
try {
|
||||
var gitHostInfo = gitHosts[gitHostName]
|
||||
var auth = null
|
||||
if (parsed.auth && authProtocols[parsed.protocol]) {
|
||||
auth = parsed.auth
|
||||
}
|
||||
var committish = parsed.hash ? decodeURIComponent(parsed.hash.substr(1)) : null
|
||||
var user = null
|
||||
var project = null
|
||||
var defaultRepresentation = null
|
||||
if (shortcutMatch && shortcutMatch[1] === gitHostName) {
|
||||
user = shortcutMatch[2] && decodeURIComponent(shortcutMatch[2])
|
||||
project = decodeURIComponent(shortcutMatch[3].replace(/\.git$/, ''))
|
||||
defaultRepresentation = 'shortcut'
|
||||
} else {
|
||||
if (parsed.host && parsed.host !== gitHostInfo.domain && parsed.host.replace(/^www[.]/, '') !== gitHostInfo.domain) return
|
||||
if (!gitHostInfo.protocols_re.test(parsed.protocol)) return
|
||||
if (!parsed.path) return
|
||||
var pathmatch = gitHostInfo.pathmatch
|
||||
var matched = parsed.path.match(pathmatch)
|
||||
if (!matched) return
|
||||
/* istanbul ignore else */
|
||||
if (matched[1] !== null && matched[1] !== undefined) {
|
||||
user = decodeURIComponent(matched[1].replace(/^:/, ''))
|
||||
}
|
||||
project = decodeURIComponent(matched[2])
|
||||
defaultRepresentation = protocolToRepresentation(parsed.protocol)
|
||||
}
|
||||
return new GitHost(gitHostName, user, auth, project, committish, defaultRepresentation, opts)
|
||||
} catch (ex) {
|
||||
/* istanbul ignore else */
|
||||
if (ex instanceof URIError) {
|
||||
} else throw ex
|
||||
}
|
||||
}).filter(function (gitHostInfo) { return gitHostInfo })
|
||||
if (matches.length !== 1) return
|
||||
return matches[0]
|
||||
}
|
||||
|
||||
function isGitHubShorthand (arg) {
|
||||
// Note: This does not fully test the git ref format.
|
||||
// See https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
|
||||
//
|
||||
// The only way to do this properly would be to shell out to
|
||||
// git-check-ref-format, and as this is a fast sync function,
|
||||
// we don't want to do that. Just let git fail if it turns
|
||||
// out that the commit-ish is invalid.
|
||||
// GH usernames cannot start with . or -
|
||||
return /^[^:@%/\s.-][^:@%/\s]*[/][^:@\s/%]+(?:#.*)?$/.test(arg)
|
||||
}
|
||||
|
||||
function fixupUnqualifiedGist (giturl) {
|
||||
// necessary for round-tripping gists
|
||||
var parsed = url.parse(giturl)
|
||||
if (parsed.protocol === 'gist:' && parsed.host && !parsed.path) {
|
||||
return parsed.protocol + '/' + parsed.host
|
||||
} else {
|
||||
return giturl
|
||||
}
|
||||
}
|
||||
|
||||
function parseGitUrl (giturl) {
|
||||
var matched = giturl.match(/^([^@]+)@([^:/]+):[/]?((?:[^/]+[/])?[^/]+?)(?:[.]git)?(#.*)?$/)
|
||||
if (!matched) {
|
||||
var legacy = url.parse(giturl)
|
||||
// If we don't have url.URL, then sorry, this is just not fixable.
|
||||
// This affects Node <= 6.12.
|
||||
if (legacy.auth && typeof url.URL === 'function') {
|
||||
// git urls can be in the form of scp-style/ssh-connect strings, like
|
||||
// git+ssh://user@host.com:some/path, which the legacy url parser
|
||||
// supports, but WhatWG url.URL class does not. However, the legacy
|
||||
// parser de-urlencodes the username and password, so something like
|
||||
// https://user%3An%40me:p%40ss%3Aword@x.com/ becomes
|
||||
// https://user:n@me:p@ss:word@x.com/ which is all kinds of wrong.
|
||||
// Pull off just the auth and host, so we dont' get the confusing
|
||||
// scp-style URL, then pass that to the WhatWG parser to get the
|
||||
// auth properly escaped.
|
||||
var authmatch = giturl.match(/[^@]+@[^:/]+/)
|
||||
/* istanbul ignore else - this should be impossible */
|
||||
if (authmatch) {
|
||||
var whatwg = new url.URL(authmatch[0])
|
||||
legacy.auth = whatwg.username || ''
|
||||
if (whatwg.password) legacy.auth += ':' + whatwg.password
|
||||
}
|
||||
}
|
||||
return legacy
|
||||
}
|
||||
return {
|
||||
protocol: 'git+ssh:',
|
||||
slashes: true,
|
||||
auth: matched[1],
|
||||
host: matched[2],
|
||||
port: null,
|
||||
hostname: matched[2],
|
||||
hash: matched[4],
|
||||
search: null,
|
||||
query: null,
|
||||
pathname: '/' + matched[3],
|
||||
path: '/' + matched[3],
|
||||
href: 'git+ssh://' + matched[1] + '@' + matched[2] +
|
||||
'/' + matched[3] + (matched[4] || '')
|
||||
}
|
||||
}
|
||||
44
node_modules/conventional-recommended-bump/node_modules/hosted-git-info/package.json
generated
vendored
100644
44
node_modules/conventional-recommended-bump/node_modules/hosted-git-info/package.json
generated
vendored
100644
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"name": "hosted-git-info",
|
||||
"version": "2.8.9",
|
||||
"description": "Provides metadata and conversions from repository urls for Github, Bitbucket and Gitlab",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/npm/hosted-git-info.git"
|
||||
},
|
||||
"keywords": [
|
||||
"git",
|
||||
"github",
|
||||
"bitbucket",
|
||||
"gitlab"
|
||||
],
|
||||
"author": "Rebecca Turner <me@re-becca.org> (http://re-becca.org)",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/npm/hosted-git-info/issues"
|
||||
},
|
||||
"homepage": "https://github.com/npm/hosted-git-info",
|
||||
"scripts": {
|
||||
"prerelease": "npm t",
|
||||
"postrelease": "npm publish --tag=ancient-legacy-fixes && git push --follow-tags",
|
||||
"posttest": "standard",
|
||||
"release": "standard-version -s",
|
||||
"test:coverage": "tap --coverage-report=html -J --coverage=90 --no-esm test/*.js",
|
||||
"test": "tap -J --coverage=90 --no-esm test/*.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"standard": "^11.0.1",
|
||||
"standard-version": "^4.4.0",
|
||||
"tap": "^12.7.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"git-host.js",
|
||||
"git-host-info.js"
|
||||
]
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz"
|
||||
,"_integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw=="
|
||||
,"_from": "hosted-git-info@2.8.9"
|
||||
}
|
||||
27
node_modules/conventional-recommended-bump/node_modules/indent-string/index.js
generated
vendored
100644
27
node_modules/conventional-recommended-bump/node_modules/indent-string/index.js
generated
vendored
100644
|
|
@ -0,0 +1,27 @@
|
|||
'use strict';
|
||||
module.exports = (str, count, opts) => {
|
||||
// Support older versions: use the third parameter as options.indent
|
||||
// TODO: Remove the workaround in the next major version
|
||||
const options = typeof opts === 'object' ? Object.assign({indent: ' '}, opts) : {indent: opts || ' '};
|
||||
count = count === undefined ? 1 : count;
|
||||
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof str}\``);
|
||||
}
|
||||
|
||||
if (typeof count !== 'number') {
|
||||
throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof count}\``);
|
||||
}
|
||||
|
||||
if (typeof options.indent !== 'string') {
|
||||
throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof options.indent}\``);
|
||||
}
|
||||
|
||||
if (count === 0) {
|
||||
return str;
|
||||
}
|
||||
|
||||
const regex = options.includeEmptyLines ? /^/mg : /^(?!\s*$)/mg;
|
||||
return str.replace(regex, options.indent.repeat(count));
|
||||
}
|
||||
;
|
||||
9
node_modules/conventional-recommended-bump/node_modules/indent-string/license
generated
vendored
100644
9
node_modules/conventional-recommended-bump/node_modules/indent-string/license
generated
vendored
100644
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
40
node_modules/conventional-recommended-bump/node_modules/indent-string/package.json
generated
vendored
100644
40
node_modules/conventional-recommended-bump/node_modules/indent-string/package.json
generated
vendored
100644
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"name": "indent-string",
|
||||
"version": "3.2.0",
|
||||
"description": "Indent each line in a string",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/indent-string",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"indent",
|
||||
"string",
|
||||
"str",
|
||||
"pad",
|
||||
"align",
|
||||
"line",
|
||||
"text",
|
||||
"each",
|
||||
"every"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz"
|
||||
,"_integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok="
|
||||
,"_from": "indent-string@3.2.0"
|
||||
}
|
||||
72
node_modules/conventional-recommended-bump/node_modules/indent-string/readme.md
generated
vendored
100644
72
node_modules/conventional-recommended-bump/node_modules/indent-string/readme.md
generated
vendored
100644
|
|
@ -0,0 +1,72 @@
|
|||
# indent-string [](https://travis-ci.org/sindresorhus/indent-string)
|
||||
|
||||
> Indent each line in a string
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install indent-string
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const indentString = require('indent-string');
|
||||
|
||||
indentString('Unicorns\nRainbows', 4);
|
||||
//=> ' Unicorns'
|
||||
//=> ' Rainbows'
|
||||
|
||||
indentString('Unicorns\nRainbows', 4, {indent: '♥'});
|
||||
//=> '♥♥♥♥Unicorns'
|
||||
//=> '♥♥♥♥Rainbows'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### indentString(input, [count], [options])
|
||||
|
||||
#### input
|
||||
|
||||
Type: `string`
|
||||
|
||||
String you want to indent.
|
||||
|
||||
#### count
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `1`
|
||||
|
||||
How many times you want `indent` repeated.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`<br>
|
||||
|
||||
##### indent
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `' '`
|
||||
|
||||
String to use for the indent.
|
||||
|
||||
##### includeEmptyLines
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Also indent empty lines.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [indent-string-cli](https://github.com/sindresorhus/indent-string-cli) - CLI for this module
|
||||
- [strip-indent](https://github.com/sindresorhus/strip-indent) - Strip leading whitespace from every line in a string
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
45
node_modules/conventional-recommended-bump/node_modules/map-obj/index.js
generated
vendored
100644
45
node_modules/conventional-recommended-bump/node_modules/map-obj/index.js
generated
vendored
100644
|
|
@ -0,0 +1,45 @@
|
|||
'use strict';
|
||||
|
||||
// customized for this use-case
|
||||
const isObject = x =>
|
||||
typeof x === 'object' &&
|
||||
x !== null &&
|
||||
!(x instanceof RegExp) &&
|
||||
!(x instanceof Error) &&
|
||||
!(x instanceof Date);
|
||||
|
||||
module.exports = function mapObj(obj, fn, opts, seen) {
|
||||
opts = Object.assign({
|
||||
deep: false,
|
||||
target: {}
|
||||
}, opts);
|
||||
|
||||
seen = seen || new WeakMap();
|
||||
|
||||
if (seen.has(obj)) {
|
||||
return seen.get(obj);
|
||||
}
|
||||
|
||||
seen.set(obj, opts.target);
|
||||
|
||||
const target = opts.target;
|
||||
delete opts.target;
|
||||
|
||||
for (const key of Object.keys(obj)) {
|
||||
const val = obj[key];
|
||||
const res = fn(key, val, obj);
|
||||
let newVal = res[1];
|
||||
|
||||
if (opts.deep && isObject(newVal)) {
|
||||
if (Array.isArray(newVal)) {
|
||||
newVal = newVal.map(x => isObject(x) ? mapObj(x, fn, opts, seen) : x);
|
||||
} else {
|
||||
newVal = mapObj(newVal, fn, opts, seen);
|
||||
}
|
||||
}
|
||||
|
||||
target[res[0]] = newVal;
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
21
node_modules/conventional-recommended-bump/node_modules/map-obj/license
generated
vendored
100644
21
node_modules/conventional-recommended-bump/node_modules/map-obj/license
generated
vendored
100644
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
49
node_modules/conventional-recommended-bump/node_modules/map-obj/package.json
generated
vendored
100644
49
node_modules/conventional-recommended-bump/node_modules/map-obj/package.json
generated
vendored
100644
|
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
"name": "map-obj",
|
||||
"version": "2.0.0",
|
||||
"description": "Map object keys and values into a new object",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/map-obj",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"map",
|
||||
"obj",
|
||||
"object",
|
||||
"key",
|
||||
"keys",
|
||||
"value",
|
||||
"values",
|
||||
"val",
|
||||
"iterate",
|
||||
"iterator",
|
||||
"rename",
|
||||
"modify",
|
||||
"deep",
|
||||
"recurse",
|
||||
"recursive"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/map-obj/-/map-obj-2.0.0.tgz"
|
||||
,"_integrity": "sha1-plzSkIepJZi4eRJXpSPgISIqwfk="
|
||||
,"_from": "map-obj@2.0.0"
|
||||
}
|
||||
65
node_modules/conventional-recommended-bump/node_modules/map-obj/readme.md
generated
vendored
100644
65
node_modules/conventional-recommended-bump/node_modules/map-obj/readme.md
generated
vendored
100644
|
|
@ -0,0 +1,65 @@
|
|||
# map-obj [](https://travis-ci.org/sindresorhus/map-obj)
|
||||
|
||||
> Map object keys and values into a new object
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save map-obj
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const mapObj = require('map-obj');
|
||||
|
||||
const newObject = mapObj({foo: 'bar'}, (key, value) => [value, key]);
|
||||
//=> {bar: 'foo'}
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### mapObj(source, mapper, [options])
|
||||
|
||||
#### source
|
||||
|
||||
Type: `Object`
|
||||
|
||||
Source object to copy properties from.
|
||||
|
||||
#### mapper
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Mapping function.
|
||||
|
||||
- It has signature `mapper(sourceKey, sourceValue, source)`.
|
||||
- It must return a two item array: `[targetKey, targetValue]`.
|
||||
|
||||
#### deep
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Recurse nested objects and objects in arrays.
|
||||
|
||||
#### target
|
||||
|
||||
Type: `Object`<br>
|
||||
Default: `{}`
|
||||
|
||||
Target object to map properties on to.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [filter-obj](https://github.com/sindresorhus/filter-obj) - Filter object keys and values into a new object
|
||||
- [object-assign](https://github.com/sindresorhus/object-assign) - Copy enumerable own properties from one or more source objects to a target object
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
301
node_modules/conventional-recommended-bump/node_modules/meow/index.d.ts
generated
vendored
100644
301
node_modules/conventional-recommended-bump/node_modules/meow/index.d.ts
generated
vendored
100644
|
|
@ -0,0 +1,301 @@
|
|||
import {PackageJson} from 'type-fest';
|
||||
|
||||
declare namespace meow {
|
||||
type FlagType = 'string' | 'boolean' | 'number';
|
||||
|
||||
/**
|
||||
Callback function to determine if a flag is required during runtime.
|
||||
|
||||
@param flags - Contains the flags converted to camel-case excluding aliases.
|
||||
@param input - Contains the non-flag arguments.
|
||||
|
||||
@returns True if the flag is required, otherwise false.
|
||||
*/
|
||||
type IsRequiredPredicate = (flags: Readonly<AnyFlags>, input: readonly string[]) => boolean;
|
||||
|
||||
interface Flag<Type extends FlagType, Default> {
|
||||
readonly type?: Type;
|
||||
readonly alias?: string;
|
||||
readonly default?: Default;
|
||||
readonly isRequired?: boolean | IsRequiredPredicate;
|
||||
readonly isMultiple?: boolean;
|
||||
}
|
||||
|
||||
type StringFlag = Flag<'string', string>;
|
||||
type BooleanFlag = Flag<'boolean', boolean>;
|
||||
type NumberFlag = Flag<'number', number>;
|
||||
|
||||
type AnyFlag = StringFlag | BooleanFlag | NumberFlag;
|
||||
type AnyFlags = {[key: string]: AnyFlag};
|
||||
|
||||
interface Options<Flags extends AnyFlags> {
|
||||
/**
|
||||
Define argument flags.
|
||||
|
||||
The key is the flag name and the value is an object with any of:
|
||||
|
||||
- `type`: Type of value. (Possible values: `string` `boolean` `number`)
|
||||
- `alias`: Usually used to define a short flag alias.
|
||||
- `default`: Default value when the flag is not specified.
|
||||
- `isRequired`: Determine if the flag is required.
|
||||
If it's only known at runtime whether the flag is required or not you can pass a Function instead of a boolean, which based on the given flags and other non-flag arguments should decide if the flag is required.
|
||||
- `isMultiple`: Indicates a flag can be set multiple times. Values are turned into an array. (Default: false)
|
||||
|
||||
@example
|
||||
```
|
||||
flags: {
|
||||
unicorn: {
|
||||
type: 'string',
|
||||
alias: 'u',
|
||||
default: ['rainbow', 'cat'],
|
||||
isMultiple: true,
|
||||
isRequired: (flags, input) => {
|
||||
if (flags.otherFlag) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
*/
|
||||
readonly flags?: Flags;
|
||||
|
||||
/**
|
||||
Description to show above the help text. Default: The package.json `"description"` property.
|
||||
|
||||
Set it to `false` to disable it altogether.
|
||||
*/
|
||||
readonly description?: string | false;
|
||||
|
||||
/**
|
||||
The help text you want shown.
|
||||
|
||||
The input is reindented and starting/ending newlines are trimmed which means you can use a [template literal](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/template_strings) without having to care about using the correct amount of indent.
|
||||
|
||||
The description will be shown above your help text automatically.
|
||||
|
||||
Set it to `false` to disable it altogether.
|
||||
*/
|
||||
readonly help?: string | false;
|
||||
|
||||
/**
|
||||
Set a custom version output. Default: The package.json `"version"` property.
|
||||
|
||||
Set it to `false` to disable it altogether.
|
||||
*/
|
||||
readonly version?: string | false;
|
||||
|
||||
/**
|
||||
Automatically show the help text when the `--help` flag is present. Useful to set this value to `false` when a CLI manages child CLIs with their own help text.
|
||||
|
||||
This option is only considered when there is only one argument in `process.argv`.
|
||||
*/
|
||||
readonly autoHelp?: boolean;
|
||||
|
||||
/**
|
||||
Automatically show the version text when the `--version` flag is present. Useful to set this value to `false` when a CLI manages child CLIs with their own version text.
|
||||
|
||||
This option is only considered when there is only one argument in `process.argv`.
|
||||
*/
|
||||
readonly autoVersion?: boolean;
|
||||
|
||||
/**
|
||||
`package.json` as an `Object`. Default: Closest `package.json` upwards.
|
||||
|
||||
_You most likely don't need this option._
|
||||
*/
|
||||
readonly pkg?: {[key: string]: unknown};
|
||||
|
||||
/**
|
||||
Custom arguments object.
|
||||
|
||||
@default process.argv.slice(2)
|
||||
*/
|
||||
readonly argv?: readonly string[];
|
||||
|
||||
/**
|
||||
Infer the argument type.
|
||||
|
||||
By default, the argument `5` in `$ foo 5` becomes a string. Enabling this would infer it as a number.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly inferType?: boolean;
|
||||
|
||||
/**
|
||||
Value of `boolean` flags not defined in `argv`. If set to `undefined` the flags not defined in `argv` will be excluded from the result. The `default` value set in `boolean` flags take precedence over `booleanDefault`.
|
||||
|
||||
__Caution: Explicitly specifying undefined for `booleanDefault` has different meaning from omitting key itself.__
|
||||
|
||||
@example
|
||||
```
|
||||
import meow = require('meow');
|
||||
|
||||
const cli = meow(`
|
||||
Usage
|
||||
$ foo
|
||||
|
||||
Options
|
||||
--rainbow, -r Include a rainbow
|
||||
--unicorn, -u Include a unicorn
|
||||
--no-sparkles Exclude sparkles
|
||||
|
||||
Examples
|
||||
$ foo
|
||||
🌈 unicorns✨🌈
|
||||
`, {
|
||||
booleanDefault: undefined,
|
||||
flags: {
|
||||
rainbow: {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
alias: 'r'
|
||||
},
|
||||
unicorn: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
alias: 'u'
|
||||
},
|
||||
cake: {
|
||||
type: 'boolean',
|
||||
alias: 'c'
|
||||
},
|
||||
sparkles: {
|
||||
type: 'boolean',
|
||||
default: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//{
|
||||
// flags: {
|
||||
// rainbow: true,
|
||||
// unicorn: false,
|
||||
// sparkles: true
|
||||
// },
|
||||
// unnormalizedFlags: {
|
||||
// rainbow: true,
|
||||
// r: true,
|
||||
// unicorn: false,
|
||||
// u: false,
|
||||
// sparkles: true
|
||||
// },
|
||||
// …
|
||||
//}
|
||||
```
|
||||
*/
|
||||
readonly booleanDefault?: boolean | null | undefined;
|
||||
|
||||
/**
|
||||
Whether to use [hard-rejection](https://github.com/sindresorhus/hard-rejection) or not. Disabling this can be useful if you need to handle `process.on('unhandledRejection')` yourself.
|
||||
|
||||
@default true
|
||||
*/
|
||||
readonly hardRejection?: boolean;
|
||||
}
|
||||
|
||||
type TypedFlag<Flag extends AnyFlag> =
|
||||
Flag extends {type: 'number'}
|
||||
? number
|
||||
: Flag extends {type: 'string'}
|
||||
? string
|
||||
: Flag extends {type: 'boolean'}
|
||||
? boolean
|
||||
: unknown;
|
||||
|
||||
type PossiblyOptionalFlag<Flag extends AnyFlag, FlagType> =
|
||||
Flag extends {isRequired: true}
|
||||
? FlagType
|
||||
: Flag extends {default: any}
|
||||
? FlagType
|
||||
: FlagType | undefined;
|
||||
|
||||
type TypedFlags<Flags extends AnyFlags> = {
|
||||
[F in keyof Flags]: Flags[F] extends {isMultiple: true}
|
||||
? PossiblyOptionalFlag<Flags[F], Array<TypedFlag<Flags[F]>>>
|
||||
: PossiblyOptionalFlag<Flags[F], TypedFlag<Flags[F]>>
|
||||
};
|
||||
|
||||
interface Result<Flags extends AnyFlags> {
|
||||
/**
|
||||
Non-flag arguments.
|
||||
*/
|
||||
input: string[];
|
||||
|
||||
/**
|
||||
Flags converted to camelCase excluding aliases.
|
||||
*/
|
||||
flags: TypedFlags<Flags> & {[name: string]: unknown};
|
||||
|
||||
/**
|
||||
Flags converted camelCase including aliases.
|
||||
*/
|
||||
unnormalizedFlags: TypedFlags<Flags> & {[name: string]: unknown};
|
||||
|
||||
/**
|
||||
The `package.json` object.
|
||||
*/
|
||||
pkg: PackageJson;
|
||||
|
||||
/**
|
||||
The help text used with `--help`.
|
||||
*/
|
||||
help: string;
|
||||
|
||||
/**
|
||||
Show the help text and exit with code.
|
||||
|
||||
@param exitCode - The exit code to use. Default: `2`.
|
||||
*/
|
||||
showHelp: (exitCode?: number) => void;
|
||||
|
||||
/**
|
||||
Show the version text and exit.
|
||||
*/
|
||||
showVersion: () => void;
|
||||
}
|
||||
}
|
||||
/**
|
||||
@param helpMessage - Shortcut for the `help` option.
|
||||
|
||||
@example
|
||||
```
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
import meow = require('meow');
|
||||
import foo = require('.');
|
||||
|
||||
const cli = meow(`
|
||||
Usage
|
||||
$ foo <input>
|
||||
|
||||
Options
|
||||
--rainbow, -r Include a rainbow
|
||||
|
||||
Examples
|
||||
$ foo unicorns --rainbow
|
||||
🌈 unicorns 🌈
|
||||
`, {
|
||||
flags: {
|
||||
rainbow: {
|
||||
type: 'boolean',
|
||||
alias: 'r'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//{
|
||||
// input: ['unicorns'],
|
||||
// flags: {rainbow: true},
|
||||
// ...
|
||||
//}
|
||||
|
||||
foo(cli.input[0], cli.flags);
|
||||
```
|
||||
*/
|
||||
declare function meow<Flags extends meow.AnyFlags>(helpMessage: string, options?: meow.Options<Flags>): meow.Result<Flags>;
|
||||
declare function meow<Flags extends meow.AnyFlags>(options?: meow.Options<Flags>): meow.Result<Flags>;
|
||||
|
||||
export = meow;
|
||||
|
|
@ -0,0 +1,198 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const buildParserOptions = require('minimist-options');
|
||||
const parseArguments = require('yargs-parser');
|
||||
const camelCaseKeys = require('camelcase-keys');
|
||||
const decamelizeKeys = require('decamelize-keys');
|
||||
const trimNewlines = require('trim-newlines');
|
||||
const redent = require('redent');
|
||||
const readPkgUp = require('read-pkg-up');
|
||||
const hardRejection = require('hard-rejection');
|
||||
const normalizePackageData = require('normalize-package-data');
|
||||
|
||||
// Prevent caching of this module so module.parent is always accurate
|
||||
delete require.cache[__filename];
|
||||
const parentDir = path.dirname(module.parent && module.parent.filename ? module.parent.filename : '.');
|
||||
|
||||
const isFlagMissing = (flagName, definedFlags, receivedFlags, input) => {
|
||||
const flag = definedFlags[flagName];
|
||||
let isFlagRequired = true;
|
||||
|
||||
if (typeof flag.isRequired === 'function') {
|
||||
isFlagRequired = flag.isRequired(receivedFlags, input);
|
||||
if (typeof isFlagRequired !== 'boolean') {
|
||||
throw new TypeError(`Return value for isRequired callback should be of type boolean, but ${typeof isFlagRequired} was returned.`);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof receivedFlags[flagName] === 'undefined') {
|
||||
return isFlagRequired;
|
||||
}
|
||||
|
||||
return flag.isMultiple && receivedFlags[flagName].length === 0;
|
||||
};
|
||||
|
||||
const getMissingRequiredFlags = (flags, receivedFlags, input) => {
|
||||
const missingRequiredFlags = [];
|
||||
if (typeof flags === 'undefined') {
|
||||
return [];
|
||||
}
|
||||
|
||||
for (const flagName of Object.keys(flags)) {
|
||||
if (flags[flagName].isRequired && isFlagMissing(flagName, flags, receivedFlags, input)) {
|
||||
missingRequiredFlags.push({key: flagName, ...flags[flagName]});
|
||||
}
|
||||
}
|
||||
|
||||
return missingRequiredFlags;
|
||||
};
|
||||
|
||||
const reportMissingRequiredFlags = missingRequiredFlags => {
|
||||
console.error(`Missing required flag${missingRequiredFlags.length > 1 ? 's' : ''}`);
|
||||
for (const flag of missingRequiredFlags) {
|
||||
console.error(`\t--${flag.key}${flag.alias ? `, -${flag.alias}` : ''}`);
|
||||
}
|
||||
};
|
||||
|
||||
const buildParserFlags = ({flags, booleanDefault}) =>
|
||||
Object.entries(flags).reduce((parserFlags, [flagKey, flagValue]) => {
|
||||
const flag = {...flagValue};
|
||||
|
||||
if (
|
||||
typeof booleanDefault !== 'undefined' &&
|
||||
flag.type === 'boolean' &&
|
||||
!Object.prototype.hasOwnProperty.call(flag, 'default')
|
||||
) {
|
||||
flag.default = flag.isMultiple ? [booleanDefault] : booleanDefault;
|
||||
}
|
||||
|
||||
if (flag.isMultiple) {
|
||||
flag.type = flag.type ? `${flag.type}-array` : 'array';
|
||||
delete flag.isMultiple;
|
||||
}
|
||||
|
||||
parserFlags[flagKey] = flag;
|
||||
|
||||
return parserFlags;
|
||||
}, {});
|
||||
|
||||
const validateFlags = (flags, options) => {
|
||||
for (const [flagKey, flagValue] of Object.entries(options.flags)) {
|
||||
if (flagKey !== '--' && !flagValue.isMultiple && Array.isArray(flags[flagKey])) {
|
||||
throw new Error(`The flag --${flagKey} can only be set once.`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const meow = (helpText, options) => {
|
||||
if (typeof helpText !== 'string') {
|
||||
options = helpText;
|
||||
helpText = '';
|
||||
}
|
||||
|
||||
options = {
|
||||
pkg: readPkgUp.sync({
|
||||
cwd: parentDir,
|
||||
normalize: false
|
||||
}).packageJson || {},
|
||||
argv: process.argv.slice(2),
|
||||
flags: {},
|
||||
inferType: false,
|
||||
input: 'string',
|
||||
help: helpText,
|
||||
autoHelp: true,
|
||||
autoVersion: true,
|
||||
booleanDefault: false,
|
||||
hardRejection: true,
|
||||
...options
|
||||
};
|
||||
|
||||
if (options.hardRejection) {
|
||||
hardRejection();
|
||||
}
|
||||
|
||||
let parserOptions = {
|
||||
arguments: options.input,
|
||||
...buildParserFlags(options)
|
||||
};
|
||||
|
||||
parserOptions = decamelizeKeys(parserOptions, '-', {exclude: ['stopEarly', '--']});
|
||||
|
||||
if (options.inferType) {
|
||||
delete parserOptions.arguments;
|
||||
}
|
||||
|
||||
parserOptions = buildParserOptions(parserOptions);
|
||||
|
||||
if (parserOptions['--']) {
|
||||
parserOptions.configuration = {
|
||||
...parserOptions.configuration,
|
||||
'populate--': true
|
||||
};
|
||||
}
|
||||
|
||||
const {pkg} = options;
|
||||
const argv = parseArguments(options.argv, parserOptions);
|
||||
let help = redent(trimNewlines((options.help || '').replace(/\t+\n*$/, '')), 2);
|
||||
|
||||
normalizePackageData(pkg);
|
||||
|
||||
process.title = pkg.bin ? Object.keys(pkg.bin)[0] : pkg.name;
|
||||
|
||||
let {description} = options;
|
||||
if (!description && description !== false) {
|
||||
({description} = pkg);
|
||||
}
|
||||
|
||||
help = (description ? `\n ${description}\n` : '') + (help ? `\n${help}\n` : '\n');
|
||||
|
||||
const showHelp = code => {
|
||||
console.log(help);
|
||||
process.exit(typeof code === 'number' ? code : 2);
|
||||
};
|
||||
|
||||
const showVersion = () => {
|
||||
console.log(typeof options.version === 'string' ? options.version : pkg.version);
|
||||
process.exit(0);
|
||||
};
|
||||
|
||||
if (argv._.length === 0 && options.argv.length === 1) {
|
||||
if (argv.version === true && options.autoVersion) {
|
||||
showVersion();
|
||||
}
|
||||
|
||||
if (argv.help === true && options.autoHelp) {
|
||||
showHelp(0);
|
||||
}
|
||||
}
|
||||
|
||||
const input = argv._;
|
||||
delete argv._;
|
||||
|
||||
const flags = camelCaseKeys(argv, {exclude: ['--', /^\w$/]});
|
||||
const unnormalizedFlags = {...flags};
|
||||
|
||||
validateFlags(flags, options);
|
||||
|
||||
for (const flagValue of Object.values(options.flags)) {
|
||||
delete flags[flagValue.alias];
|
||||
}
|
||||
|
||||
const missingRequiredFlags = getMissingRequiredFlags(options.flags, flags, input);
|
||||
if (missingRequiredFlags.length > 0) {
|
||||
reportMissingRequiredFlags(missingRequiredFlags);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
return {
|
||||
input,
|
||||
flags,
|
||||
unnormalizedFlags,
|
||||
pkg,
|
||||
help,
|
||||
showHelp,
|
||||
showVersion
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = meow;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
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.
|
||||
103
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase-keys/index.d.ts
generated
vendored
100644
103
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase-keys/index.d.ts
generated
vendored
100644
|
|
@ -0,0 +1,103 @@
|
|||
declare namespace camelcaseKeys {
|
||||
interface Options {
|
||||
/**
|
||||
Recurse nested objects and objects in arrays.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly deep?: boolean;
|
||||
|
||||
/**
|
||||
Exclude keys from being camel-cased.
|
||||
|
||||
@default []
|
||||
*/
|
||||
readonly exclude?: ReadonlyArray<string | RegExp>;
|
||||
|
||||
/**
|
||||
Exclude children at the given object paths in dot-notation from being camel-cased. For example, with an object like `{a: {b: '🦄'}}`, the object path to reach the unicorn is `'a.b'`.
|
||||
|
||||
@default []
|
||||
|
||||
@example
|
||||
```
|
||||
camelcaseKeys({
|
||||
a_b: 1,
|
||||
a_c: {
|
||||
c_d: 1,
|
||||
c_e: {
|
||||
e_f: 1
|
||||
}
|
||||
}
|
||||
}, {
|
||||
deep: true,
|
||||
stopPaths: [
|
||||
'a_c.c_e'
|
||||
]
|
||||
}),
|
||||
// {
|
||||
// aB: 1,
|
||||
// aC: {
|
||||
// cD: 1,
|
||||
// cE: {
|
||||
// e_f: 1
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
```
|
||||
*/
|
||||
readonly stopPaths?: ReadonlyArray<string>;
|
||||
|
||||
/**
|
||||
Uppercase the first character as in `bye-bye` → `ByeBye`.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly pascalCase?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Convert object keys to camel case using [`camelcase`](https://github.com/sindresorhus/camelcase).
|
||||
|
||||
@param input - Object or array of objects to camel-case.
|
||||
|
||||
@example
|
||||
```
|
||||
import camelcaseKeys = require('camelcase-keys');
|
||||
|
||||
// Convert an object
|
||||
camelcaseKeys({'foo-bar': true});
|
||||
//=> {fooBar: true}
|
||||
|
||||
// Convert an array of objects
|
||||
camelcaseKeys([{'foo-bar': true}, {'bar-foo': false}]);
|
||||
//=> [{fooBar: true}, {barFoo: false}]
|
||||
|
||||
camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true});
|
||||
//=> {fooBar: true, nested: {unicornRainbow: true}}
|
||||
|
||||
// Convert object keys to pascal case
|
||||
camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true, pascalCase: true});
|
||||
//=> {FooBar: true, Nested: {UnicornRainbow: true}}
|
||||
|
||||
import minimist = require('minimist');
|
||||
|
||||
const argv = minimist(process.argv.slice(2));
|
||||
//=> {_: [], 'foo-bar': true}
|
||||
|
||||
camelcaseKeys(argv);
|
||||
//=> {_: [], fooBar: true}
|
||||
```
|
||||
*/
|
||||
declare function camelcaseKeys<T extends ReadonlyArray<{[key: string]: any}>>(
|
||||
input: T,
|
||||
options?: camelcaseKeys.Options,
|
||||
): T;
|
||||
|
||||
declare function camelcaseKeys<T extends {[key: string]: any}>(
|
||||
input: T,
|
||||
options?: camelcaseKeys.Options,
|
||||
): T;
|
||||
|
||||
export = camelcaseKeys;
|
||||
77
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase-keys/index.js
generated
vendored
100644
77
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase-keys/index.js
generated
vendored
100644
|
|
@ -0,0 +1,77 @@
|
|||
'use strict';
|
||||
const mapObj = require('map-obj');
|
||||
const camelCase = require('camelcase');
|
||||
const QuickLru = require('quick-lru');
|
||||
|
||||
const has = (array, key) => array.some(x => {
|
||||
if (typeof x === 'string') {
|
||||
return x === key;
|
||||
}
|
||||
|
||||
x.lastIndex = 0;
|
||||
return x.test(key);
|
||||
});
|
||||
|
||||
const cache = new QuickLru({maxSize: 100000});
|
||||
|
||||
// Reproduces behavior from `map-obj`
|
||||
const isObject = value =>
|
||||
typeof value === 'object' &&
|
||||
value !== null &&
|
||||
!(value instanceof RegExp) &&
|
||||
!(value instanceof Error) &&
|
||||
!(value instanceof Date);
|
||||
|
||||
const camelCaseConvert = (input, options) => {
|
||||
if (!isObject(input)) {
|
||||
return input;
|
||||
}
|
||||
|
||||
options = {
|
||||
deep: false,
|
||||
pascalCase: false,
|
||||
...options
|
||||
};
|
||||
|
||||
const {exclude, pascalCase, stopPaths, deep} = options;
|
||||
|
||||
const stopPathsSet = new Set(stopPaths);
|
||||
|
||||
const makeMapper = parentPath => (key, value) => {
|
||||
if (deep && isObject(value)) {
|
||||
const path = parentPath === undefined ? key : `${parentPath}.${key}`;
|
||||
|
||||
if (!stopPathsSet.has(path)) {
|
||||
value = mapObj(value, makeMapper(path));
|
||||
}
|
||||
}
|
||||
|
||||
if (!(exclude && has(exclude, key))) {
|
||||
const cacheKey = pascalCase ? `${key}_` : key;
|
||||
|
||||
if (cache.has(cacheKey)) {
|
||||
key = cache.get(cacheKey);
|
||||
} else {
|
||||
const ret = camelCase(key, {pascalCase});
|
||||
|
||||
if (key.length < 100) { // Prevent abuse
|
||||
cache.set(cacheKey, ret);
|
||||
}
|
||||
|
||||
key = ret;
|
||||
}
|
||||
}
|
||||
|
||||
return [key, value];
|
||||
};
|
||||
|
||||
return mapObj(input, makeMapper(undefined));
|
||||
};
|
||||
|
||||
module.exports = (input, options) => {
|
||||
if (Array.isArray(input)) {
|
||||
return Object.keys(input).map(key => camelCaseConvert(input[key], options));
|
||||
}
|
||||
|
||||
return camelCaseConvert(input, options);
|
||||
};
|
||||
9
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase-keys/license
generated
vendored
100644
9
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase-keys/license
generated
vendored
100644
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
77
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase-keys/package.json
generated
vendored
100644
77
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase-keys/package.json
generated
vendored
100644
|
|
@ -0,0 +1,77 @@
|
|||
{
|
||||
"name": "camelcase-keys",
|
||||
"version": "6.2.2",
|
||||
"description": "Convert object keys to camel case",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/camelcase-keys",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd",
|
||||
"bench": "matcha bench/bench.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"map",
|
||||
"obj",
|
||||
"object",
|
||||
"key",
|
||||
"keys",
|
||||
"value",
|
||||
"values",
|
||||
"val",
|
||||
"iterate",
|
||||
"camelcase",
|
||||
"camel-case",
|
||||
"camel",
|
||||
"case",
|
||||
"dash",
|
||||
"hyphen",
|
||||
"dot",
|
||||
"underscore",
|
||||
"separator",
|
||||
"string",
|
||||
"text",
|
||||
"convert",
|
||||
"pascalcase",
|
||||
"pascal-case",
|
||||
"deep",
|
||||
"recurse",
|
||||
"recursive"
|
||||
],
|
||||
"dependencies": {
|
||||
"camelcase": "^5.3.1",
|
||||
"map-obj": "^4.0.0",
|
||||
"quick-lru": "^4.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^2.1.0",
|
||||
"matcha": "^0.7.0",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.25.3"
|
||||
},
|
||||
"xo": {
|
||||
"overrides": [
|
||||
{
|
||||
"files": "bench/bench.js",
|
||||
"rules": {
|
||||
"import/no-unresolved": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-6.2.2.tgz"
|
||||
,"_integrity": "sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg=="
|
||||
,"_from": "camelcase-keys@6.2.2"
|
||||
}
|
||||
125
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase-keys/readme.md
generated
vendored
100644
125
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase-keys/readme.md
generated
vendored
100644
|
|
@ -0,0 +1,125 @@
|
|||
# camelcase-keys [](https://travis-ci.org/sindresorhus/camelcase-keys)
|
||||
|
||||
> Convert object keys to camel case using [`camelcase`](https://github.com/sindresorhus/camelcase)
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install camelcase-keys
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const camelcaseKeys = require('camelcase-keys');
|
||||
|
||||
// Convert an object
|
||||
camelcaseKeys({'foo-bar': true});
|
||||
//=> {fooBar: true}
|
||||
|
||||
// Convert an array of objects
|
||||
camelcaseKeys([{'foo-bar': true}, {'bar-foo': false}]);
|
||||
//=> [{fooBar: true}, {barFoo: false}]
|
||||
|
||||
camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true});
|
||||
//=> {fooBar: true, nested: {unicornRainbow: true}}
|
||||
|
||||
camelcaseKeys({a_b: 1, a_c: {c_d: 1, c_e: {e_f: 1}}}, {deep: true, stopPaths: ['a_c.c_e']}),
|
||||
//=> {aB: 1, aC: {cD: 1, cE: {e_f: 1}}}
|
||||
|
||||
// Convert object keys to pascal case
|
||||
camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true, pascalCase: true});
|
||||
//=> {FooBar: true, Nested: {UnicornRainbow: true}}
|
||||
```
|
||||
|
||||
```js
|
||||
const camelcaseKeys = require('camelcase-keys');
|
||||
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
//=> {_: [], 'foo-bar': true}
|
||||
|
||||
camelcaseKeys(argv);
|
||||
//=> {_: [], fooBar: true}
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### camelcaseKeys(input, options?)
|
||||
|
||||
#### input
|
||||
|
||||
Type: `object | object[]`
|
||||
|
||||
An object or array of objects to camel-case.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### exclude
|
||||
|
||||
Type: `Array<string | RegExp>`\
|
||||
Default: `[]`
|
||||
|
||||
Exclude keys from being camel-cased.
|
||||
|
||||
##### stopPaths
|
||||
|
||||
Type: `string[]`\
|
||||
Default: `[]`
|
||||
|
||||
Exclude children at the given object paths in dot-notation from being camel-cased. For example, with an object like `{a: {b: '🦄'}}`, the object path to reach the unicorn is `'a.b'`.
|
||||
|
||||
```js
|
||||
camelcaseKeys({
|
||||
a_b: 1,
|
||||
a_c: {
|
||||
c_d: 1,
|
||||
c_e: {
|
||||
e_f: 1
|
||||
}
|
||||
}
|
||||
}, {
|
||||
deep: true,
|
||||
stopPaths: [
|
||||
'a_c.c_e'
|
||||
]
|
||||
}),
|
||||
/*
|
||||
{
|
||||
aB: 1,
|
||||
aC: {
|
||||
cD: 1,
|
||||
cE: {
|
||||
e_f: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
##### deep
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Recurse nested objects and objects in arrays.
|
||||
|
||||
##### pascalCase
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Uppercase the first character as in `bye-bye` → `ByeBye`.
|
||||
|
||||
## camelcase-keys for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of camelcase-keys and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-camelcase-keys?utm_source=npm-camelcase-keys&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
|
||||
## Related
|
||||
|
||||
- [snakecase-keys](https://github.com/bendrucker/snakecase-keys)
|
||||
- [kebabcase-keys](https://github.com/mattiloh/kebabcase-keys)
|
||||
|
||||
63
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase/index.d.ts
generated
vendored
100644
63
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase/index.d.ts
generated
vendored
100644
|
|
@ -0,0 +1,63 @@
|
|||
declare namespace camelcase {
|
||||
interface Options {
|
||||
/**
|
||||
Uppercase the first character: `foo-bar` → `FooBar`.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly pascalCase?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare const camelcase: {
|
||||
/**
|
||||
Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`.
|
||||
|
||||
@param input - String to convert to camel case.
|
||||
|
||||
@example
|
||||
```
|
||||
import camelCase = require('camelcase');
|
||||
|
||||
camelCase('foo-bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('foo_bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('Foo-Bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('Foo-Bar', {pascalCase: true});
|
||||
//=> 'FooBar'
|
||||
|
||||
camelCase('--foo.bar', {pascalCase: false});
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('foo bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
console.log(process.argv[3]);
|
||||
//=> '--foo-bar'
|
||||
camelCase(process.argv[3]);
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase(['foo', 'bar']);
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase(['__foo__', '--bar'], {pascalCase: true});
|
||||
//=> 'FooBar'
|
||||
```
|
||||
*/
|
||||
(input: string | ReadonlyArray<string>, options?: camelcase.Options): string;
|
||||
|
||||
// TODO: Remove this for the next major release, refactor the whole definition to:
|
||||
// declare function camelcase(
|
||||
// input: string | ReadonlyArray<string>,
|
||||
// options?: camelcase.Options
|
||||
// ): string;
|
||||
// export = camelcase;
|
||||
default: typeof camelcase;
|
||||
};
|
||||
|
||||
export = camelcase;
|
||||
76
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase/index.js
generated
vendored
100644
76
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase/index.js
generated
vendored
100644
|
|
@ -0,0 +1,76 @@
|
|||
'use strict';
|
||||
|
||||
const preserveCamelCase = string => {
|
||||
let isLastCharLower = false;
|
||||
let isLastCharUpper = false;
|
||||
let isLastLastCharUpper = false;
|
||||
|
||||
for (let i = 0; i < string.length; i++) {
|
||||
const character = string[i];
|
||||
|
||||
if (isLastCharLower && /[a-zA-Z]/.test(character) && character.toUpperCase() === character) {
|
||||
string = string.slice(0, i) + '-' + string.slice(i);
|
||||
isLastCharLower = false;
|
||||
isLastLastCharUpper = isLastCharUpper;
|
||||
isLastCharUpper = true;
|
||||
i++;
|
||||
} else if (isLastCharUpper && isLastLastCharUpper && /[a-zA-Z]/.test(character) && character.toLowerCase() === character) {
|
||||
string = string.slice(0, i - 1) + '-' + string.slice(i - 1);
|
||||
isLastLastCharUpper = isLastCharUpper;
|
||||
isLastCharUpper = false;
|
||||
isLastCharLower = true;
|
||||
} else {
|
||||
isLastCharLower = character.toLowerCase() === character && character.toUpperCase() !== character;
|
||||
isLastLastCharUpper = isLastCharUpper;
|
||||
isLastCharUpper = character.toUpperCase() === character && character.toLowerCase() !== character;
|
||||
}
|
||||
}
|
||||
|
||||
return string;
|
||||
};
|
||||
|
||||
const camelCase = (input, options) => {
|
||||
if (!(typeof input === 'string' || Array.isArray(input))) {
|
||||
throw new TypeError('Expected the input to be `string | string[]`');
|
||||
}
|
||||
|
||||
options = Object.assign({
|
||||
pascalCase: false
|
||||
}, options);
|
||||
|
||||
const postProcess = x => options.pascalCase ? x.charAt(0).toUpperCase() + x.slice(1) : x;
|
||||
|
||||
if (Array.isArray(input)) {
|
||||
input = input.map(x => x.trim())
|
||||
.filter(x => x.length)
|
||||
.join('-');
|
||||
} else {
|
||||
input = input.trim();
|
||||
}
|
||||
|
||||
if (input.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (input.length === 1) {
|
||||
return options.pascalCase ? input.toUpperCase() : input.toLowerCase();
|
||||
}
|
||||
|
||||
const hasUpperCase = input !== input.toLowerCase();
|
||||
|
||||
if (hasUpperCase) {
|
||||
input = preserveCamelCase(input);
|
||||
}
|
||||
|
||||
input = input
|
||||
.replace(/^[_.\- ]+/, '')
|
||||
.toLowerCase()
|
||||
.replace(/[_.\- ]+(\w|$)/g, (_, p1) => p1.toUpperCase())
|
||||
.replace(/\d+(\w|$)/g, m => m.toUpperCase());
|
||||
|
||||
return postProcess(input);
|
||||
};
|
||||
|
||||
module.exports = camelCase;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = camelCase;
|
||||
9
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase/license
generated
vendored
100644
9
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase/license
generated
vendored
100644
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
47
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase/package.json
generated
vendored
100644
47
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase/package.json
generated
vendored
100644
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"name": "camelcase",
|
||||
"version": "5.3.1",
|
||||
"description": "Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/camelcase",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"camelcase",
|
||||
"camel-case",
|
||||
"camel",
|
||||
"case",
|
||||
"dash",
|
||||
"hyphen",
|
||||
"dot",
|
||||
"underscore",
|
||||
"separator",
|
||||
"string",
|
||||
"text",
|
||||
"convert",
|
||||
"pascalcase",
|
||||
"pascal-case"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.1",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz"
|
||||
,"_integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg=="
|
||||
,"_from": "camelcase@5.3.1"
|
||||
}
|
||||
99
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase/readme.md
generated
vendored
100644
99
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/camelcase/readme.md
generated
vendored
100644
|
|
@ -0,0 +1,99 @@
|
|||
# camelcase [](https://travis-ci.org/sindresorhus/camelcase)
|
||||
|
||||
> Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-camelcase?utm_source=npm-camelcase&utm_medium=referral&utm_campaign=readme">Get professional support for 'camelcase' with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install camelcase
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const camelCase = require('camelcase');
|
||||
|
||||
camelCase('foo-bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('foo_bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('Foo-Bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('Foo-Bar', {pascalCase: true});
|
||||
//=> 'FooBar'
|
||||
|
||||
camelCase('--foo.bar', {pascalCase: false});
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('foo bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
console.log(process.argv[3]);
|
||||
//=> '--foo-bar'
|
||||
camelCase(process.argv[3]);
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase(['foo', 'bar']);
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase(['__foo__', '--bar'], {pascalCase: true});
|
||||
//=> 'FooBar'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### camelCase(input, [options])
|
||||
|
||||
#### input
|
||||
|
||||
Type: `string` `string[]`
|
||||
|
||||
String to convert to camel case.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### pascalCase
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Uppercase the first character: `foo-bar` → `FooBar`
|
||||
|
||||
|
||||
## Security
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module
|
||||
- [uppercamelcase](https://github.com/SamVerschueren/uppercamelcase) - Like this module, but to PascalCase instead of camelCase
|
||||
- [titleize](https://github.com/sindresorhus/titleize) - Capitalize every word in string
|
||||
- [humanize-string](https://github.com/sindresorhus/humanize-string) - Convert a camelized/dasherized/underscored string into a humanized one
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
42
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/indent-string/index.d.ts
generated
vendored
100644
42
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/indent-string/index.d.ts
generated
vendored
100644
|
|
@ -0,0 +1,42 @@
|
|||
declare namespace indentString {
|
||||
interface Options {
|
||||
/**
|
||||
The string to use for the indent.
|
||||
|
||||
@default ' '
|
||||
*/
|
||||
readonly indent?: string;
|
||||
|
||||
/**
|
||||
Also indent empty lines.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly includeEmptyLines?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Indent each line in a string.
|
||||
|
||||
@param string - The string to indent.
|
||||
@param count - How many times you want `options.indent` repeated. Default: `1`.
|
||||
|
||||
@example
|
||||
```
|
||||
import indentString = require('indent-string');
|
||||
|
||||
indentString('Unicorns\nRainbows', 4);
|
||||
//=> ' Unicorns\n Rainbows'
|
||||
|
||||
indentString('Unicorns\nRainbows', 4, {indent: '♥'});
|
||||
//=> '♥♥♥♥Unicorns\n♥♥♥♥Rainbows'
|
||||
```
|
||||
*/
|
||||
declare function indentString(
|
||||
string: string,
|
||||
count?: number,
|
||||
options?: indentString.Options
|
||||
): string;
|
||||
|
||||
export = indentString;
|
||||
35
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/indent-string/index.js
generated
vendored
100644
35
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/indent-string/index.js
generated
vendored
100644
|
|
@ -0,0 +1,35 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = (string, count = 1, options) => {
|
||||
options = {
|
||||
indent: ' ',
|
||||
includeEmptyLines: false,
|
||||
...options
|
||||
};
|
||||
|
||||
if (typeof string !== 'string') {
|
||||
throw new TypeError(
|
||||
`Expected \`input\` to be a \`string\`, got \`${typeof string}\``
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof count !== 'number') {
|
||||
throw new TypeError(
|
||||
`Expected \`count\` to be a \`number\`, got \`${typeof count}\``
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof options.indent !== 'string') {
|
||||
throw new TypeError(
|
||||
`Expected \`options.indent\` to be a \`string\`, got \`${typeof options.indent}\``
|
||||
);
|
||||
}
|
||||
|
||||
if (count === 0) {
|
||||
return string;
|
||||
}
|
||||
|
||||
const regex = options.includeEmptyLines ? /^/gm : /^(?!\s*$)/gm;
|
||||
|
||||
return string.replace(regex, options.indent.repeat(count));
|
||||
};
|
||||
9
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/indent-string/license
generated
vendored
100644
9
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/indent-string/license
generated
vendored
100644
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
41
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/indent-string/package.json
generated
vendored
100644
41
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/indent-string/package.json
generated
vendored
100644
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"name": "indent-string",
|
||||
"version": "4.0.0",
|
||||
"description": "Indent each line in a string",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/indent-string",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"indent",
|
||||
"string",
|
||||
"pad",
|
||||
"align",
|
||||
"line",
|
||||
"text",
|
||||
"each",
|
||||
"every"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz"
|
||||
,"_integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg=="
|
||||
,"_from": "indent-string@4.0.0"
|
||||
}
|
||||
70
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/indent-string/readme.md
generated
vendored
100644
70
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/indent-string/readme.md
generated
vendored
100644
|
|
@ -0,0 +1,70 @@
|
|||
# indent-string [](https://travis-ci.org/sindresorhus/indent-string)
|
||||
|
||||
> Indent each line in a string
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install indent-string
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const indentString = require('indent-string');
|
||||
|
||||
indentString('Unicorns\nRainbows', 4);
|
||||
//=> ' Unicorns\n Rainbows'
|
||||
|
||||
indentString('Unicorns\nRainbows', 4, {indent: '♥'});
|
||||
//=> '♥♥♥♥Unicorns\n♥♥♥♥Rainbows'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### indentString(string, [count], [options])
|
||||
|
||||
#### string
|
||||
|
||||
Type: `string`
|
||||
|
||||
The string to indent.
|
||||
|
||||
#### count
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `1`
|
||||
|
||||
How many times you want `options.indent` repeated.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### indent
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `' '`
|
||||
|
||||
The string to use for the indent.
|
||||
|
||||
##### includeEmptyLines
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Also indent empty lines.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [indent-string-cli](https://github.com/sindresorhus/indent-string-cli) - CLI for this module
|
||||
- [strip-indent](https://github.com/sindresorhus/strip-indent) - Strip leading whitespace from every line in a string
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
151
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/map-obj/index.d.ts
generated
vendored
100644
151
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/map-obj/index.d.ts
generated
vendored
100644
|
|
@ -0,0 +1,151 @@
|
|||
// Unique symbol cannot be declared in a namespace directly, so we declare it top-level
|
||||
// See: https://github.com/sindresorhus/map-obj/pull/38#discussion_r702396878
|
||||
declare const skipSymbol: unique symbol;
|
||||
|
||||
declare namespace mapObject {
|
||||
type Mapper<
|
||||
SourceObjectType extends {[key: string]: any},
|
||||
MappedObjectKeyType extends string,
|
||||
MappedObjectValueType
|
||||
> = (
|
||||
sourceKey: keyof SourceObjectType,
|
||||
sourceValue: SourceObjectType[keyof SourceObjectType],
|
||||
source: SourceObjectType
|
||||
) => [
|
||||
targetKey: MappedObjectKeyType,
|
||||
targetValue: MappedObjectValueType,
|
||||
mapperOptions?: mapObject.MapperOptions
|
||||
] | typeof mapObject.mapObjectSkip;
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
Recurse nested objects and objects in arrays.
|
||||
|
||||
@default false
|
||||
*/
|
||||
deep?: boolean;
|
||||
|
||||
/**
|
||||
Target object to map properties on to.
|
||||
|
||||
@default {}
|
||||
*/
|
||||
target?: {[key: string]: any};
|
||||
}
|
||||
|
||||
interface DeepOptions extends Options {
|
||||
deep: true;
|
||||
}
|
||||
|
||||
interface TargetOptions<TargetObjectType extends {[key: string]: any}> extends Options {
|
||||
target: TargetObjectType;
|
||||
}
|
||||
|
||||
interface MapperOptions {
|
||||
/**
|
||||
Whether `targetValue` should be recursed.
|
||||
|
||||
Requires `deep: true`.
|
||||
|
||||
@default true
|
||||
*/
|
||||
readonly shouldRecurse?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
Return this value from a `mapper` function to remove a key from an object.
|
||||
|
||||
@example
|
||||
```
|
||||
const mapObject = require('map-obj');
|
||||
|
||||
const object = {one: 1, two: 2}
|
||||
const mapper = (key, value) => value === 1 ? [key, value] : mapObject.mapObjectSkip
|
||||
const result = mapObject(object, mapper);
|
||||
|
||||
console.log(result);
|
||||
//=> {one: 1}
|
||||
```
|
||||
*/
|
||||
const mapObjectSkip: typeof skipSymbol
|
||||
}
|
||||
|
||||
/**
|
||||
Map object keys and values into a new object.
|
||||
|
||||
@param source - Source object to copy properties from.
|
||||
@param mapper - Mapping function.
|
||||
|
||||
@example
|
||||
```
|
||||
import mapObject = require('map-obj');
|
||||
|
||||
const newObject = mapObject({foo: 'bar'}, (key, value) => [value, key]);
|
||||
//=> {bar: 'foo'}
|
||||
|
||||
const newObject = mapObject({FOO: true, bAr: {bAz: true}}, (key, value) => [key.toLowerCase(), value]);
|
||||
//=> {foo: true, bar: {bAz: true}}
|
||||
|
||||
const newObject = mapObject({FOO: true, bAr: {bAz: true}}, (key, value) => [key.toLowerCase(), value], {deep: true});
|
||||
//=> {foo: true, bar: {baz: true}}
|
||||
|
||||
const newObject = mapObject({one: 1, two: 2}, (key, value) => value === 1 ? [key, value] : mapObject.mapObjectSkip);
|
||||
//=> {one: 1}
|
||||
```
|
||||
*/
|
||||
declare function mapObject<
|
||||
SourceObjectType extends object,
|
||||
TargetObjectType extends {[key: string]: any},
|
||||
MappedObjectKeyType extends string,
|
||||
MappedObjectValueType
|
||||
>(
|
||||
source: SourceObjectType,
|
||||
mapper: mapObject.Mapper<
|
||||
SourceObjectType,
|
||||
MappedObjectKeyType,
|
||||
MappedObjectValueType
|
||||
>,
|
||||
options: mapObject.DeepOptions & mapObject.TargetOptions<TargetObjectType>
|
||||
): TargetObjectType & {[key: string]: unknown};
|
||||
declare function mapObject<
|
||||
SourceObjectType extends object,
|
||||
MappedObjectKeyType extends string,
|
||||
MappedObjectValueType
|
||||
>(
|
||||
source: SourceObjectType,
|
||||
mapper: mapObject.Mapper<
|
||||
SourceObjectType,
|
||||
MappedObjectKeyType,
|
||||
MappedObjectValueType
|
||||
>,
|
||||
options: mapObject.DeepOptions
|
||||
): {[key: string]: unknown};
|
||||
declare function mapObject<
|
||||
SourceObjectType extends {[key: string]: any},
|
||||
TargetObjectType extends {[key: string]: any},
|
||||
MappedObjectKeyType extends string,
|
||||
MappedObjectValueType
|
||||
>(
|
||||
source: SourceObjectType,
|
||||
mapper: mapObject.Mapper<
|
||||
SourceObjectType,
|
||||
MappedObjectKeyType,
|
||||
MappedObjectValueType
|
||||
>,
|
||||
options: mapObject.TargetOptions<TargetObjectType>
|
||||
): TargetObjectType & {[K in MappedObjectKeyType]: MappedObjectValueType};
|
||||
declare function mapObject<
|
||||
SourceObjectType extends {[key: string]: any},
|
||||
MappedObjectKeyType extends string,
|
||||
MappedObjectValueType
|
||||
>(
|
||||
source: SourceObjectType,
|
||||
mapper: mapObject.Mapper<
|
||||
SourceObjectType,
|
||||
MappedObjectKeyType,
|
||||
MappedObjectValueType
|
||||
>,
|
||||
options?: mapObject.Options
|
||||
): {[K in MappedObjectKeyType]: MappedObjectValueType};
|
||||
|
||||
export = mapObject;
|
||||
68
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/map-obj/index.js
generated
vendored
100644
68
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/map-obj/index.js
generated
vendored
100644
|
|
@ -0,0 +1,68 @@
|
|||
'use strict';
|
||||
|
||||
const isObject = value => typeof value === 'object' && value !== null;
|
||||
const mapObjectSkip = Symbol('skip');
|
||||
|
||||
// Customized for this use-case
|
||||
const isObjectCustom = value =>
|
||||
isObject(value) &&
|
||||
!(value instanceof RegExp) &&
|
||||
!(value instanceof Error) &&
|
||||
!(value instanceof Date);
|
||||
|
||||
const mapObject = (object, mapper, options, isSeen = new WeakMap()) => {
|
||||
options = {
|
||||
deep: false,
|
||||
target: {},
|
||||
...options
|
||||
};
|
||||
|
||||
if (isSeen.has(object)) {
|
||||
return isSeen.get(object);
|
||||
}
|
||||
|
||||
isSeen.set(object, options.target);
|
||||
|
||||
const {target} = options;
|
||||
delete options.target;
|
||||
|
||||
const mapArray = array => array.map(element => isObjectCustom(element) ? mapObject(element, mapper, options, isSeen) : element);
|
||||
if (Array.isArray(object)) {
|
||||
return mapArray(object);
|
||||
}
|
||||
|
||||
for (const [key, value] of Object.entries(object)) {
|
||||
const mapResult = mapper(key, value, object);
|
||||
|
||||
if (mapResult === mapObjectSkip) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let [newKey, newValue, {shouldRecurse = true} = {}] = mapResult;
|
||||
|
||||
// Drop `__proto__` keys.
|
||||
if (newKey === '__proto__') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (options.deep && shouldRecurse && isObjectCustom(newValue)) {
|
||||
newValue = Array.isArray(newValue) ?
|
||||
mapArray(newValue) :
|
||||
mapObject(newValue, mapper, options, isSeen);
|
||||
}
|
||||
|
||||
target[newKey] = newValue;
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
module.exports = (object, mapper, options) => {
|
||||
if (!isObject(object)) {
|
||||
throw new TypeError(`Expected an object, got \`${object}\` (${typeof object})`);
|
||||
}
|
||||
|
||||
return mapObject(object, mapper, options);
|
||||
};
|
||||
|
||||
module.exports.mapObjectSkip = mapObjectSkip;
|
||||
9
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/map-obj/license
generated
vendored
100644
9
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/map-obj/license
generated
vendored
100644
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
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.
|
||||
47
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/map-obj/package.json
generated
vendored
100644
47
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/map-obj/package.json
generated
vendored
100644
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"name": "map-obj",
|
||||
"version": "4.3.0",
|
||||
"description": "Map object keys and values into a new object",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/map-obj",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"map",
|
||||
"object",
|
||||
"key",
|
||||
"keys",
|
||||
"value",
|
||||
"values",
|
||||
"iterate",
|
||||
"iterator",
|
||||
"rename",
|
||||
"modify",
|
||||
"deep",
|
||||
"recurse",
|
||||
"recursive"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^2.0.0",
|
||||
"tsd": "^0.14.0",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/map-obj/-/map-obj-4.3.0.tgz"
|
||||
,"_integrity": "sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ=="
|
||||
,"_from": "map-obj@4.3.0"
|
||||
}
|
||||
105
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/map-obj/readme.md
generated
vendored
100644
105
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/map-obj/readme.md
generated
vendored
100644
|
|
@ -0,0 +1,105 @@
|
|||
# map-obj
|
||||
|
||||
> Map object keys and values into a new object
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install map-obj
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const mapObject = require('map-obj');
|
||||
|
||||
const newObject = mapObject({foo: 'bar'}, (key, value) => [value, key]);
|
||||
//=> {bar: 'foo'}
|
||||
|
||||
const newObject = mapObject({FOO: true, bAr: {bAz: true}}, (key, value) => [key.toLowerCase(), value]);
|
||||
//=> {foo: true, bar: {bAz: true}}
|
||||
|
||||
const newObject = mapObject({FOO: true, bAr: {bAz: true}}, (key, value) => [key.toLowerCase(), value], {deep: true});
|
||||
//=> {foo: true, bar: {baz: true}}
|
||||
|
||||
const newObject = mapObject({one: 1, two: 2}, (key, value) => value === 1 ? [key, value] : mapObject.mapObjectSkip);
|
||||
//=> {one: 1}
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### mapObject(source, mapper, options?)
|
||||
|
||||
#### source
|
||||
|
||||
Type: `object`
|
||||
|
||||
Source object to copy properties from.
|
||||
|
||||
#### mapper
|
||||
|
||||
Type: `(sourceKey, sourceValue, source) => [targetKey, targetValue, mapperOptions?] | mapObject.mapObjectSkip`
|
||||
|
||||
Mapping function.
|
||||
|
||||
##### mapperOptions
|
||||
|
||||
Type: `object`
|
||||
|
||||
###### shouldRecurse
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Whether `targetValue` should be recursed.
|
||||
|
||||
Requires `deep: true`.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### deep
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Recurse nested objects and objects in arrays.
|
||||
|
||||
##### target
|
||||
|
||||
Type: `object`\
|
||||
Default: `{}`
|
||||
|
||||
Target object to map properties on to.
|
||||
|
||||
### mapObject.mapObjectSkip
|
||||
|
||||
Return this value from a `mapper` function to exclude the key from the new object.
|
||||
|
||||
```js
|
||||
const mapObject = require('map-obj');
|
||||
|
||||
const object = {one: 1, two: 2}
|
||||
const mapper = (key, value) => value === 1 ? [key, value] : mapObject.mapObjectSkip
|
||||
const result = mapObject(object, mapper);
|
||||
|
||||
console.log(result);
|
||||
//=> {one: 1}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [filter-obj](https://github.com/sindresorhus/filter-obj) - Filter object keys and values into a new object
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-map-obj?utm_source=npm-map-obj&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
55
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/minimist-options/index.d.ts
generated
vendored
100644
55
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/minimist-options/index.d.ts
generated
vendored
100644
|
|
@ -0,0 +1,55 @@
|
|||
import {Opts as MinimistOptions} from 'minimist';
|
||||
|
||||
export type OptionType = 'string' | 'boolean' | 'number' | 'array' | 'string-array' | 'boolean-array' | 'number-array';
|
||||
|
||||
export interface BaseOption<
|
||||
TypeOptionType extends OptionType,
|
||||
DefaultOptionType
|
||||
> {
|
||||
/**
|
||||
* The data type the option should be parsed to.
|
||||
*/
|
||||
readonly type?: TypeOptionType;
|
||||
|
||||
/**
|
||||
* An alias/list of aliases for the option.
|
||||
*/
|
||||
readonly alias?: string | ReadonlyArray<string>;
|
||||
|
||||
/**
|
||||
* The default value for the option.
|
||||
*/
|
||||
readonly default?: DefaultOptionType;
|
||||
}
|
||||
|
||||
export type StringOption = BaseOption<'string', string>;
|
||||
export type BooleanOption = BaseOption<'boolean', boolean>;
|
||||
export type NumberOption = BaseOption<'number', number>;
|
||||
export type DefaultArrayOption = BaseOption<'array', ReadonlyArray<string>>;
|
||||
export type StringArrayOption = BaseOption<'string-array', ReadonlyArray<string>>;
|
||||
export type BooleanArrayOption = BaseOption<'boolean-array', ReadonlyArray<boolean>>;
|
||||
export type NumberArrayOption = BaseOption<'number-array', ReadonlyArray<number>>;
|
||||
|
||||
type MinimistOption = NonNullable<
|
||||
| MinimistOptions['stopEarly']
|
||||
| MinimistOptions['unknown']
|
||||
| MinimistOptions['--']
|
||||
>;
|
||||
|
||||
export type Options = {
|
||||
[key: string]:
|
||||
| OptionType
|
||||
| StringOption
|
||||
| BooleanOption
|
||||
| NumberOption
|
||||
| DefaultArrayOption
|
||||
| StringArrayOption
|
||||
| BooleanArrayOption
|
||||
| NumberArrayOption
|
||||
| MinimistOption; // Workaround for https://github.com/microsoft/TypeScript/issues/17867
|
||||
};
|
||||
|
||||
/**
|
||||
* Write options for [minimist](https://npmjs.org/package/minimist) in a comfortable way. Support string, boolean, number and array options.
|
||||
*/
|
||||
export default function buildOptions(options?: Options): MinimistOptions;
|
||||
117
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/minimist-options/index.js
generated
vendored
100644
117
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/minimist-options/index.js
generated
vendored
100644
|
|
@ -0,0 +1,117 @@
|
|||
'use strict';
|
||||
|
||||
const isPlainObject = require('is-plain-obj');
|
||||
const arrify = require('arrify');
|
||||
const kindOf = require('kind-of');
|
||||
|
||||
const push = (obj, prop, value) => {
|
||||
if (!obj[prop]) {
|
||||
obj[prop] = [];
|
||||
}
|
||||
|
||||
obj[prop].push(value);
|
||||
};
|
||||
|
||||
const insert = (obj, prop, key, value) => {
|
||||
if (!obj[prop]) {
|
||||
obj[prop] = {};
|
||||
}
|
||||
|
||||
obj[prop][key] = value;
|
||||
};
|
||||
|
||||
const prettyPrint = output => {
|
||||
return Array.isArray(output) ?
|
||||
`[${output.map(prettyPrint).join(', ')}]` :
|
||||
kindOf(output) === 'string' ? JSON.stringify(output) : output;
|
||||
};
|
||||
|
||||
const resolveType = value => {
|
||||
if (Array.isArray(value) && value.length > 0) {
|
||||
const [element] = value;
|
||||
return `${kindOf(element)}-array`;
|
||||
}
|
||||
|
||||
return kindOf(value);
|
||||
};
|
||||
|
||||
const normalizeExpectedType = (type, defaultValue) => {
|
||||
const inferredType = type === 'array' ? 'string-array' : type;
|
||||
|
||||
if (arrayTypes.includes(inferredType) && Array.isArray(defaultValue) && defaultValue.length === 0) {
|
||||
return 'array';
|
||||
}
|
||||
|
||||
return inferredType;
|
||||
};
|
||||
|
||||
const passthroughOptions = ['stopEarly', 'unknown', '--'];
|
||||
const primitiveTypes = ['string', 'boolean', 'number'];
|
||||
const arrayTypes = primitiveTypes.map(t => `${t}-array`);
|
||||
const availableTypes = [...primitiveTypes, 'array', ...arrayTypes];
|
||||
|
||||
const buildOptions = options => {
|
||||
options = options || {};
|
||||
|
||||
const result = {};
|
||||
|
||||
passthroughOptions.forEach(key => {
|
||||
if (options[key]) {
|
||||
result[key] = options[key];
|
||||
}
|
||||
});
|
||||
|
||||
Object.keys(options).forEach(key => {
|
||||
let value = options[key];
|
||||
|
||||
if (key === 'arguments') {
|
||||
key = '_';
|
||||
}
|
||||
|
||||
// If short form is used
|
||||
// convert it to long form
|
||||
// e.g. { 'name': 'string' }
|
||||
if (typeof value === 'string') {
|
||||
value = {type: value};
|
||||
}
|
||||
|
||||
if (isPlainObject(value)) {
|
||||
const props = value;
|
||||
const {type} = props;
|
||||
|
||||
if (type) {
|
||||
if (!availableTypes.includes(type)) {
|
||||
throw new TypeError(`Expected type of "${key}" to be one of ${prettyPrint(availableTypes)}, got ${prettyPrint(type)}`);
|
||||
}
|
||||
|
||||
if (arrayTypes.includes(type)) {
|
||||
const [elementType] = type.split('-');
|
||||
push(result, 'array', {key, [elementType]: true});
|
||||
} else {
|
||||
push(result, type, key);
|
||||
}
|
||||
}
|
||||
|
||||
if ({}.hasOwnProperty.call(props, 'default')) {
|
||||
const {default: defaultValue} = props;
|
||||
const defaultType = resolveType(defaultValue);
|
||||
const expectedType = normalizeExpectedType(type, defaultValue);
|
||||
|
||||
if (expectedType && expectedType !== defaultType) {
|
||||
throw new TypeError(`Expected "${key}" default value to be of type "${expectedType}", got ${prettyPrint(defaultType)}`);
|
||||
}
|
||||
|
||||
insert(result, 'default', key, defaultValue);
|
||||
}
|
||||
|
||||
arrify(props.alias).forEach(alias => {
|
||||
insert(result, 'alias', alias, key);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = buildOptions;
|
||||
module.exports.default = buildOptions;
|
||||
21
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/minimist-options/license
generated
vendored
100644
21
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/minimist-options/license
generated
vendored
100644
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Vadim Demedes <vdemedes@gmail.com> (vadimdemedes.com)
|
||||
|
||||
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.
|
||||
38
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/minimist-options/package.json
generated
vendored
100644
38
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/minimist-options/package.json
generated
vendored
100644
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"name": "minimist-options",
|
||||
"version": "4.1.0",
|
||||
"description": "Pretty options for minimist",
|
||||
"repository": "vadimdemedes/minimist-options",
|
||||
"author": "Vadim Demedes <vdemedes@gmail.com>",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"minimist",
|
||||
"argv",
|
||||
"args"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd-check"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"dependencies": {
|
||||
"arrify": "^1.0.1",
|
||||
"is-plain-obj": "^1.1.0",
|
||||
"kind-of": "^6.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/minimist": "^1.2.0",
|
||||
"ava": "^1.0.1",
|
||||
"tsd-check": "^0.3.0",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/minimist-options/-/minimist-options-4.1.0.tgz"
|
||||
,"_integrity": "sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A=="
|
||||
,"_from": "minimist-options@4.1.0"
|
||||
}
|
||||
112
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/minimist-options/readme.md
generated
vendored
100644
112
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/minimist-options/readme.md
generated
vendored
100644
|
|
@ -0,0 +1,112 @@
|
|||
# minimist-options 
|
||||
|
||||
> Write options for [minimist](https://npmjs.org/package/minimist) and [yargs](https://npmjs.org/package/yargs) in a comfortable way.
|
||||
> Supports string, boolean, number and array options.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
$ npm install --save minimist-options
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const buildOptions = require('minimist-options');
|
||||
const minimist = require('minimist');
|
||||
|
||||
const options = buildOptions({
|
||||
name: {
|
||||
type: 'string',
|
||||
alias: 'n',
|
||||
default: 'john'
|
||||
},
|
||||
|
||||
force: {
|
||||
type: 'boolean',
|
||||
alias: ['f', 'o'],
|
||||
default: false
|
||||
},
|
||||
|
||||
score: {
|
||||
type: 'number',
|
||||
alias: 's',
|
||||
default: 0
|
||||
},
|
||||
|
||||
arr: {
|
||||
type: 'array',
|
||||
alias: 'a',
|
||||
default: []
|
||||
},
|
||||
|
||||
strings: {
|
||||
type: 'string-array',
|
||||
alias: 's',
|
||||
default: ['a', 'b']
|
||||
},
|
||||
|
||||
booleans: {
|
||||
type: 'boolean-array',
|
||||
alias: 'b',
|
||||
default: [true, false]
|
||||
},
|
||||
|
||||
numbers: {
|
||||
type: 'number-array',
|
||||
alias: 'n',
|
||||
default: [0, 1]
|
||||
},
|
||||
|
||||
published: 'boolean',
|
||||
|
||||
// Special option for positional arguments (`_` in minimist)
|
||||
arguments: 'string'
|
||||
});
|
||||
|
||||
const args = minimist(process.argv.slice(2), options);
|
||||
```
|
||||
|
||||
instead of:
|
||||
|
||||
```js
|
||||
const minimist = require('minimist');
|
||||
|
||||
const options = {
|
||||
string: ['name', '_'],
|
||||
number: ['score'],
|
||||
array: [
|
||||
'arr',
|
||||
{key: 'strings', string: true},
|
||||
{key: 'booleans', boolean: true},
|
||||
{key: 'numbers', number: true}
|
||||
],
|
||||
boolean: ['force', 'published'],
|
||||
alias: {
|
||||
n: 'name',
|
||||
f: 'force',
|
||||
s: 'score',
|
||||
a: 'arr'
|
||||
},
|
||||
default: {
|
||||
name: 'john',
|
||||
f: false,
|
||||
score: 0,
|
||||
arr: []
|
||||
}
|
||||
};
|
||||
|
||||
const args = minimist(process.argv.slice(2), options);
|
||||
```
|
||||
|
||||
## Array options
|
||||
|
||||
The `array` types are only supported by [yargs](https://npmjs.org/package/yargs).
|
||||
|
||||
[minimist](https://npmjs.org/package/minimist) does _not_ explicitly support array type options. If you set an option multiple times, it will indeed yield an array of values. However, if you only set it once, it will simply give the value as is, without wrapping it in an array. Thus, effectively ignoring `{type: 'array'}`.
|
||||
|
||||
`{type: 'array'}` is shorthand for `{type: 'string-array'}`. To have values coerced to `boolean` or `number`, use `boolean-array` or `number-array`, respectively.
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Vadim Demedes](https://vadimdemedes.com)
|
||||
90
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/quick-lru/index.d.ts
generated
vendored
100644
90
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/quick-lru/index.d.ts
generated
vendored
100644
|
|
@ -0,0 +1,90 @@
|
|||
declare namespace QuickLRU {
|
||||
interface Options {
|
||||
/**
|
||||
The maximum number of items before evicting the least recently used items.
|
||||
*/
|
||||
readonly maxSize: number;
|
||||
}
|
||||
}
|
||||
|
||||
declare class QuickLRU<KeyType extends unknown, ValueType extends unknown>
|
||||
implements Iterable<[KeyType, ValueType]> {
|
||||
/**
|
||||
The stored item count.
|
||||
*/
|
||||
readonly size: number;
|
||||
|
||||
/**
|
||||
Simple ["Least Recently Used" (LRU) cache](https://en.m.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_.28LRU.29).
|
||||
|
||||
The instance is [`iterable`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Iteration_protocols) so you can use it directly in a [`for…of`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/for...of) loop.
|
||||
|
||||
@example
|
||||
```
|
||||
import QuickLRU = require('quick-lru');
|
||||
|
||||
const lru = new QuickLRU({maxSize: 1000});
|
||||
|
||||
lru.set('🦄', '🌈');
|
||||
|
||||
lru.has('🦄');
|
||||
//=> true
|
||||
|
||||
lru.get('🦄');
|
||||
//=> '🌈'
|
||||
```
|
||||
*/
|
||||
constructor(options: QuickLRU.Options);
|
||||
|
||||
[Symbol.iterator](): IterableIterator<[KeyType, ValueType]>;
|
||||
|
||||
/**
|
||||
Set an item.
|
||||
|
||||
@returns The list instance.
|
||||
*/
|
||||
set(key: KeyType, value: ValueType): this;
|
||||
|
||||
/**
|
||||
Get an item.
|
||||
|
||||
@returns The stored item or `undefined`.
|
||||
*/
|
||||
get(key: KeyType): ValueType | undefined;
|
||||
|
||||
/**
|
||||
Check if an item exists.
|
||||
*/
|
||||
has(key: KeyType): boolean;
|
||||
|
||||
/**
|
||||
Get an item without marking it as recently used.
|
||||
|
||||
@returns The stored item or `undefined`.
|
||||
*/
|
||||
peek(key: KeyType): ValueType | undefined;
|
||||
|
||||
/**
|
||||
Delete an item.
|
||||
|
||||
@returns `true` if the item is removed or `false` if the item doesn't exist.
|
||||
*/
|
||||
delete(key: KeyType): boolean;
|
||||
|
||||
/**
|
||||
Delete all items.
|
||||
*/
|
||||
clear(): void;
|
||||
|
||||
/**
|
||||
Iterable for all the keys.
|
||||
*/
|
||||
keys(): IterableIterator<KeyType>;
|
||||
|
||||
/**
|
||||
Iterable for all the values.
|
||||
*/
|
||||
values(): IterableIterator<ValueType>;
|
||||
}
|
||||
|
||||
export = QuickLRU;
|
||||
115
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/quick-lru/index.js
generated
vendored
100644
115
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/quick-lru/index.js
generated
vendored
100644
|
|
@ -0,0 +1,115 @@
|
|||
'use strict';
|
||||
|
||||
class QuickLRU {
|
||||
constructor(options = {}) {
|
||||
if (!(options.maxSize && options.maxSize > 0)) {
|
||||
throw new TypeError('`maxSize` must be a number greater than 0');
|
||||
}
|
||||
|
||||
this.maxSize = options.maxSize;
|
||||
this.cache = new Map();
|
||||
this.oldCache = new Map();
|
||||
this._size = 0;
|
||||
}
|
||||
|
||||
_set(key, value) {
|
||||
this.cache.set(key, value);
|
||||
this._size++;
|
||||
|
||||
if (this._size >= this.maxSize) {
|
||||
this._size = 0;
|
||||
this.oldCache = this.cache;
|
||||
this.cache = new Map();
|
||||
}
|
||||
}
|
||||
|
||||
get(key) {
|
||||
if (this.cache.has(key)) {
|
||||
return this.cache.get(key);
|
||||
}
|
||||
|
||||
if (this.oldCache.has(key)) {
|
||||
const value = this.oldCache.get(key);
|
||||
this.oldCache.delete(key);
|
||||
this._set(key, value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
set(key, value) {
|
||||
if (this.cache.has(key)) {
|
||||
this.cache.set(key, value);
|
||||
} else {
|
||||
this._set(key, value);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
has(key) {
|
||||
return this.cache.has(key) || this.oldCache.has(key);
|
||||
}
|
||||
|
||||
peek(key) {
|
||||
if (this.cache.has(key)) {
|
||||
return this.cache.get(key);
|
||||
}
|
||||
|
||||
if (this.oldCache.has(key)) {
|
||||
return this.oldCache.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
delete(key) {
|
||||
const deleted = this.cache.delete(key);
|
||||
if (deleted) {
|
||||
this._size--;
|
||||
}
|
||||
|
||||
return this.oldCache.delete(key) || deleted;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.cache.clear();
|
||||
this.oldCache.clear();
|
||||
this._size = 0;
|
||||
}
|
||||
|
||||
* keys() {
|
||||
for (const [key] of this) {
|
||||
yield key;
|
||||
}
|
||||
}
|
||||
|
||||
* values() {
|
||||
for (const [, value] of this) {
|
||||
yield value;
|
||||
}
|
||||
}
|
||||
|
||||
* [Symbol.iterator]() {
|
||||
for (const item of this.cache) {
|
||||
yield item;
|
||||
}
|
||||
|
||||
for (const item of this.oldCache) {
|
||||
const [key] = item;
|
||||
if (!this.cache.has(key)) {
|
||||
yield item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get size() {
|
||||
let oldCacheSize = 0;
|
||||
for (const key of this.oldCache.keys()) {
|
||||
if (!this.cache.has(key)) {
|
||||
oldCacheSize++;
|
||||
}
|
||||
}
|
||||
|
||||
return this._size + oldCacheSize;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = QuickLRU;
|
||||
9
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/quick-lru/license
generated
vendored
100644
9
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/quick-lru/license
generated
vendored
100644
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
46
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/quick-lru/package.json
generated
vendored
100644
46
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/quick-lru/package.json
generated
vendored
100644
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "quick-lru",
|
||||
"version": "4.0.1",
|
||||
"description": "Simple \"Least Recently Used\" (LRU) cache",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/quick-lru",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"lru",
|
||||
"quick",
|
||||
"cache",
|
||||
"caching",
|
||||
"least",
|
||||
"recently",
|
||||
"used",
|
||||
"fast",
|
||||
"map",
|
||||
"hash",
|
||||
"buffer"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"coveralls": "^3.0.3",
|
||||
"nyc": "^14.1.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-4.0.1.tgz"
|
||||
,"_integrity": "sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g=="
|
||||
,"_from": "quick-lru@4.0.1"
|
||||
}
|
||||
93
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/quick-lru/readme.md
generated
vendored
100644
93
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/quick-lru/readme.md
generated
vendored
100644
|
|
@ -0,0 +1,93 @@
|
|||
# quick-lru [](https://travis-ci.org/sindresorhus/quick-lru) [](https://coveralls.io/github/sindresorhus/quick-lru?branch=master)
|
||||
|
||||
> Simple ["Least Recently Used" (LRU) cache](https://en.m.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_.28LRU.29)
|
||||
|
||||
Useful when you need to cache something and limit memory usage.
|
||||
|
||||
Inspired by the [`hashlru` algorithm](https://github.com/dominictarr/hashlru#algorithm), but instead uses [`Map`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Map) to support keys of any type, not just strings, and values can be `undefined`.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install quick-lru
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const QuickLRU = require('quick-lru');
|
||||
|
||||
const lru = new QuickLRU({maxSize: 1000});
|
||||
|
||||
lru.set('🦄', '🌈');
|
||||
|
||||
lru.has('🦄');
|
||||
//=> true
|
||||
|
||||
lru.get('🦄');
|
||||
//=> '🌈'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### new QuickLRU(options?)
|
||||
|
||||
Returns a new instance.
|
||||
|
||||
### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
#### maxSize
|
||||
|
||||
*Required*<br>
|
||||
Type: `number`
|
||||
|
||||
The maximum number of items before evicting the least recently used items.
|
||||
|
||||
### Instance
|
||||
|
||||
The instance is [`iterable`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Iteration_protocols) so you can use it directly in a [`for…of`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/for...of) loop.
|
||||
|
||||
Both `key` and `value` can be of any type.
|
||||
|
||||
#### .set(key, value)
|
||||
|
||||
Set an item. Returns the instance.
|
||||
|
||||
#### .get(key)
|
||||
|
||||
Get an item.
|
||||
|
||||
#### .has(key)
|
||||
|
||||
Check if an item exists.
|
||||
|
||||
#### .peek(key)
|
||||
|
||||
Get an item without marking it as recently used.
|
||||
|
||||
#### .delete(key)
|
||||
|
||||
Delete an item.
|
||||
|
||||
Returns `true` if the item is removed or `false` if the item doesn't exist.
|
||||
|
||||
#### .clear()
|
||||
|
||||
Delete all items.
|
||||
|
||||
#### .keys()
|
||||
|
||||
Iterable for all the keys.
|
||||
|
||||
#### .values()
|
||||
|
||||
Iterable for all the values.
|
||||
|
||||
#### .size
|
||||
|
||||
The stored item count.
|
||||
87
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/read-pkg-up/index.d.ts
generated
vendored
100644
87
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/read-pkg-up/index.d.ts
generated
vendored
100644
|
|
@ -0,0 +1,87 @@
|
|||
import {Except} from 'type-fest';
|
||||
import readPkg = require('read-pkg');
|
||||
|
||||
declare namespace readPkgUp {
|
||||
type Options = {
|
||||
/**
|
||||
Directory to start looking for a package.json file.
|
||||
|
||||
@default process.cwd()
|
||||
*/
|
||||
cwd?: string;
|
||||
} & Except<readPkg.Options, 'cwd'>;
|
||||
|
||||
type NormalizeOptions = {
|
||||
/**
|
||||
Directory to start looking for a package.json file.
|
||||
|
||||
@default process.cwd()
|
||||
*/
|
||||
cwd?: string;
|
||||
} & Except<readPkg.NormalizeOptions, 'cwd'>;
|
||||
|
||||
type PackageJson = readPkg.PackageJson;
|
||||
type NormalizedPackageJson = readPkg.NormalizedPackageJson;
|
||||
|
||||
interface ReadResult {
|
||||
packageJson: PackageJson;
|
||||
path: string;
|
||||
}
|
||||
|
||||
interface NormalizedReadResult {
|
||||
packageJson: NormalizedPackageJson;
|
||||
path: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare const readPkgUp: {
|
||||
/**
|
||||
Read the closest `package.json` file.
|
||||
|
||||
@example
|
||||
```
|
||||
import readPkgUp = require('read-pkg-up');
|
||||
|
||||
(async () => {
|
||||
console.log(await readPkgUp());
|
||||
// {
|
||||
// packageJson: {
|
||||
// name: 'awesome-package',
|
||||
// version: '1.0.0',
|
||||
// …
|
||||
// },
|
||||
// path: '/Users/sindresorhus/dev/awesome-package/package.json'
|
||||
// }
|
||||
})();
|
||||
```
|
||||
*/
|
||||
(options?: readPkgUp.NormalizeOptions): Promise<
|
||||
readPkgUp.NormalizedReadResult | undefined
|
||||
>;
|
||||
(options: readPkgUp.Options): Promise<readPkgUp.ReadResult | undefined>;
|
||||
|
||||
/**
|
||||
Synchronously read the closest `package.json` file.
|
||||
|
||||
@example
|
||||
```
|
||||
import readPkgUp = require('read-pkg-up');
|
||||
|
||||
console.log(readPkgUp.sync());
|
||||
// {
|
||||
// packageJson: {
|
||||
// name: 'awesome-package',
|
||||
// version: '1.0.0',
|
||||
// …
|
||||
// },
|
||||
// path: '/Users/sindresorhus/dev/awesome-package/package.json'
|
||||
// }
|
||||
```
|
||||
*/
|
||||
sync(
|
||||
options?: readPkgUp.NormalizeOptions
|
||||
): readPkgUp.NormalizedReadResult | undefined;
|
||||
sync(options: readPkgUp.Options): readPkgUp.ReadResult | undefined;
|
||||
};
|
||||
|
||||
export = readPkgUp;
|
||||
30
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/read-pkg-up/index.js
generated
vendored
100644
30
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/read-pkg-up/index.js
generated
vendored
100644
|
|
@ -0,0 +1,30 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const findUp = require('find-up');
|
||||
const readPkg = require('read-pkg');
|
||||
|
||||
module.exports = async options => {
|
||||
const filePath = await findUp('package.json', options);
|
||||
|
||||
if (!filePath) {
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
packageJson: await readPkg({...options, cwd: path.dirname(filePath)}),
|
||||
path: filePath
|
||||
};
|
||||
};
|
||||
|
||||
module.exports.sync = options => {
|
||||
const filePath = findUp.sync('package.json', options);
|
||||
|
||||
if (!filePath) {
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
packageJson: readPkg.sync({...options, cwd: path.dirname(filePath)}),
|
||||
path: filePath
|
||||
};
|
||||
};
|
||||
9
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/read-pkg-up/license
generated
vendored
100644
9
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/read-pkg-up/license
generated
vendored
100644
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Basic
|
||||
export * from './source/basic';
|
||||
|
||||
// Utilities
|
||||
export {Except} from './source/except';
|
||||
export {Mutable} from './source/mutable';
|
||||
export {Merge} from './source/merge';
|
||||
export {MergeExclusive} from './source/merge-exclusive';
|
||||
export {RequireAtLeastOne} from './source/require-at-least-one';
|
||||
export {RequireExactlyOne} from './source/require-exactly-one';
|
||||
export {PartialDeep} from './source/partial-deep';
|
||||
export {ReadonlyDeep} from './source/readonly-deep';
|
||||
export {LiteralUnion} from './source/literal-union';
|
||||
export {Promisable} from './source/promisable';
|
||||
export {Opaque} from './source/opaque';
|
||||
export {SetOptional} from './source/set-optional';
|
||||
export {SetRequired} from './source/set-required';
|
||||
|
||||
// Miscellaneous
|
||||
export {PackageJson} from './source/package-json';
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"name": "type-fest",
|
||||
"version": "0.8.1",
|
||||
"description": "A collection of essential TypeScript types",
|
||||
"license": "(MIT OR CC0-1.0)",
|
||||
"repository": "sindresorhus/type-fest",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"source"
|
||||
],
|
||||
"keywords": [
|
||||
"typescript",
|
||||
"ts",
|
||||
"types",
|
||||
"utility",
|
||||
"util",
|
||||
"utilities",
|
||||
"omit",
|
||||
"merge",
|
||||
"json"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@sindresorhus/tsconfig": "^0.4.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.2.0",
|
||||
"@typescript-eslint/parser": "^2.2.0",
|
||||
"eslint-config-xo-typescript": "^0.18.0",
|
||||
"tsd": "^0.7.3",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"xo": {
|
||||
"extends": "xo-typescript",
|
||||
"extensions": [
|
||||
"ts"
|
||||
],
|
||||
"rules": {
|
||||
"import/no-unresolved": "off",
|
||||
"@typescript-eslint/indent": "off"
|
||||
}
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz"
|
||||
,"_integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA=="
|
||||
,"_from": "type-fest@0.8.1"
|
||||
}
|
||||
635
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/read-pkg-up/node_modules/type-fest/readme.md
generated
vendored
100644
635
node_modules/conventional-recommended-bump/node_modules/meow/node_modules/read-pkg-up/node_modules/type-fest/readme.md
generated
vendored
100644
|
|
@ -0,0 +1,635 @@
|
|||
<div align="center">
|
||||
<br>
|
||||
<br>
|
||||
<img src="media/logo.svg" alt="type-fest" height="300">
|
||||
<br>
|
||||
<br>
|
||||
<b>A collection of essential TypeScript types</b>
|
||||
<br>
|
||||
<hr>
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
[](https://travis-ci.com/sindresorhus/type-fest)
|
||||
[](https://www.youtube.com/watch?v=9auOCbH5Ns4)
|
||||
<!-- Commented out until they actually show anything
|
||||
[](https://www.npmjs.com/package/type-fest?activeTab=dependents) [](https://www.npmjs.com/package/type-fest)
|
||||
-->
|
||||
|
||||
Many of the types here should have been built-in. You can help by suggesting some of them to the [TypeScript project](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md).
|
||||
|
||||
Either add this package as a dependency or copy-paste the needed types. No credit required. 👌
|
||||
|
||||
PR welcome for additional commonly needed types and docs improvements. Read the [contributing guidelines](.github/contributing.md) first.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install type-fest
|
||||
```
|
||||
|
||||
*Requires TypeScript >=3.2*
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import {Except} from 'type-fest';
|
||||
|
||||
type Foo = {
|
||||
unicorn: string;
|
||||
rainbow: boolean;
|
||||
};
|
||||
|
||||
type FooWithoutRainbow = Except<Foo, 'rainbow'>;
|
||||
//=> {unicorn: string}
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
Click the type names for complete docs.
|
||||
|
||||
### Basic
|
||||
|
||||
- [`Primitive`](source/basic.d.ts) - Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
||||
- [`Class`](source/basic.d.ts) - Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
||||
- [`TypedArray`](source/basic.d.ts) - Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.
|
||||
- [`JsonObject`](source/basic.d.ts) - Matches a JSON object.
|
||||
- [`JsonArray`](source/basic.d.ts) - Matches a JSON array.
|
||||
- [`JsonValue`](source/basic.d.ts) - Matches any valid JSON value.
|
||||
- [`ObservableLike`](source/basic.d.ts) - Matches a value that is like an [Observable](https://github.com/tc39/proposal-observable).
|
||||
|
||||
### Utilities
|
||||
|
||||
- [`Except`](source/except.d.ts) - Create a type from an object type without certain keys. This is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type).
|
||||
- [`Mutable`](source/mutable.d.ts) - Convert an object with `readonly` keys into a mutable object. The inverse of `Readonly<T>`.
|
||||
- [`Merge`](source/merge.d.ts) - Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
||||
- [`MergeExclusive`](source/merge-exclusive.d.ts) - Create a type that has mutually exclusive keys.
|
||||
- [`RequireAtLeastOne`](source/require-at-least-one.d.ts) - Create a type that requires at least one of the given keys.
|
||||
- [`RequireExactlyOne`](source/require-one.d.ts) - Create a type that requires exactly a single key of the given keys and disallows more.
|
||||
- [`PartialDeep`](source/partial-deep.d.ts) - Create a deeply optional version of another type. Use [`Partial<T>`](https://github.com/Microsoft/TypeScript/blob/2961bc3fc0ea1117d4e53bc8e97fa76119bc33e3/src/lib/es5.d.ts#L1401-L1406) if you only need one level deep.
|
||||
- [`ReadonlyDeep`](source/readonly-deep.d.ts) - Create a deeply immutable version of an `object`/`Map`/`Set`/`Array` type. Use [`Readonly<T>`](https://github.com/Microsoft/TypeScript/blob/2961bc3fc0ea1117d4e53bc8e97fa76119bc33e3/src/lib/es5.d.ts#L1415-L1420) if you only need one level deep.
|
||||
- [`LiteralUnion`](source/literal-union.d.ts) - Create a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union. Workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729).
|
||||
- [`Promisable`](source/promisable.d.ts) - Create a type that represents either the value or the value wrapped in `PromiseLike`.
|
||||
- [`Opaque`](source/opaque.d.ts) - Create an [opaque type](https://codemix.com/opaque-types-in-javascript/).
|
||||
- [`SetOptional`](source/set-optional.d.ts) - Create a type that makes the given keys optional.
|
||||
- [`SetRequired`](source/set-required.d.ts) - Create a type that makes the given keys required.
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
- [`PackageJson`](source/package-json.d.ts) - Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file).
|
||||
|
||||
|
||||
## Declined types
|
||||
|
||||
*If we decline a type addition, we will make sure to document the better solution here.*
|
||||
|
||||
- [`Diff` and `Spread`](https://github.com/sindresorhus/type-fest/pull/7) - The PR author didn't provide any real-world use-cases and the PR went stale. If you think this type is useful, provide some real-world use-cases and we might reconsider.
|
||||
- [`Dictionary`](https://github.com/sindresorhus/type-fest/issues/33) - You only save a few characters (`Dictionary<number>` vs `Record<string, number>`) from [`Record`](https://github.com/Microsoft/TypeScript/blob/2961bc3fc0ea1117d4e53bc8e97fa76119bc33e3/src/lib/es5.d.ts#L1429-L1434), which is more flexible and well-known. Also, you shouldn't use an object as a dictionary. We have `Map` in JavaScript now.
|
||||
|
||||
|
||||
## Tips
|
||||
|
||||
### Built-in types
|
||||
|
||||
There are many advanced types most users don't know about.
|
||||
|
||||
- [`Partial<T>`](https://github.com/Microsoft/TypeScript/blob/2961bc3fc0ea1117d4e53bc8e97fa76119bc33e3/src/lib/es5.d.ts#L1401-L1406) - Make all properties in `T` optional.
|
||||
<details>
|
||||
<summary>
|
||||
Example
|
||||
</summary>
|
||||
|
||||
[Playground](https://typescript-play.js.org/?target=6#code/KYOwrgtgBAMg9gcxsAbsANlA3gKClAeQDMiAaPKAEWACMwFz8BRAJxbhcagDEBDAF17ocAXxw4AliH7AWRXgGNgUAHJwAJsADCcEEQkJsFXgAcTK3hGAAuKAGd+LKQgDcFEx363wEGrLf46IjIaOi28EioGG5iOArovHZ2qhrAAIJmAEJgEuiaLEb4Jk4oAsoKuvoIYCwCErq2apo6egZQALyF+FCm5pY2UABETelmg1xFnrYAzAAM8xNQQZGh4cFR6AB0xEQUIm4UFa0IABRHVbYACrws-BJCADwjLVUAfACUXfhEHFBnug4oABrYAATygcCIhBoACtgAp+JsQaC7P9ju9Prhut0joCwCZ1GUAGpCMDKTrnAwAbWRPWSyMhKWalQMAF0Dtj8BIoSd8YSZCT0GSOu1OmAQJp9CBgOpPkc7uBgBzOfwABYSOybSnVWp3XQ0sF04FgxnPFkIVkdKB84mkpUUfCxbEsYD8GogKBqjUBKBiWIAen9UGut3u6CeqReBlePXQQQA7skwMl+HAoMU4CgJJoISB0ODeOmbvwIVC1cAcIGmdpzVApDI5IpgJscNL49WMiZsrl8id3lrzScsD0zBYrLZBgAVOCUOCdwa+95uIA)
|
||||
|
||||
```ts
|
||||
interface NodeConfig {
|
||||
appName: string;
|
||||
port: number;
|
||||
}
|
||||
|
||||
class NodeAppBuilder {
|
||||
private configuration: NodeConfig = {
|
||||
appName: 'NodeApp',
|
||||
port: 3000
|
||||
};
|
||||
|
||||
config(config: Partial<NodeConfig>) {
|
||||
type NodeConfigKey = keyof NodeConfig;
|
||||
|
||||
for (const key of Object.keys(config) as NodeConfigKey[]) {
|
||||
const updateValue = config[key];
|
||||
|
||||
if (updateValue === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.configuration[key] = updateValue;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
// `Partial<NodeConfig>`` allows us to provide only a part of the
|
||||
// NodeConfig interface.
|
||||
new NodeAppBuilder().config({appName: 'ToDoApp'});
|
||||
```
|
||||
</details>
|
||||
|
||||
- [`Required<T>`](https://github.com/Microsoft/TypeScript/blob/2961bc3fc0ea1117d4e53bc8e97fa76119bc33e3/src/lib/es5.d.ts#L1408-L1413) - Make all properties in `T` required.
|
||||
<details>
|
||||
<summary>
|
||||
Example
|
||||
</summary>
|
||||
|
||||
[Playground](https://typescript-play.js.org/?target=6#code/AQ4SwOwFwUwJwGYEMDGNgGED21VQGJZwC2wA3gFCjXAzFJgA2A-AFzADOUckA5gNxUaIYjA4ckvGG07c+g6gF8KQkAgCuEFFDA5O6gEbEwUbLm2ESwABQIixACJIoSdgCUYAR3Vg4MACYAPGYuFvYAfACU5Ko0APRxwADKMBD+wFAAFuh2Vv7OSBlYGdmc8ABu8LHKsRyGxqY4oQT21pTCIHQMjOwA5DAAHgACxAAOjDAAdChYxL0ANLHUouKSMH0AEmAAhJhY6ozpAJ77GTCMjMCiV0ToSAb7UJPPC9WRgrEJwAAqR6MwSRQPFGUFocDgRHYxnEfGAowh-zgUCOwF6KwkUl6tXqJhCeEsxDaS1AXSYfUGI3GUxmc0WSneQA)
|
||||
|
||||
```ts
|
||||
interface ContactForm {
|
||||
email?: string;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
function submitContactForm(formData: Required<ContactForm>) {
|
||||
// Send the form data to the server.
|
||||
}
|
||||
|
||||
submitContactForm({
|
||||
email: 'ex@mple.com',
|
||||
message: 'Hi! Could you tell me more about…',
|
||||
});
|
||||
|
||||
// TypeScript error: missing property 'message'
|
||||
submitContactForm({
|
||||
email: 'ex@mple.com',
|
||||
});
|
||||
```
|
||||
</details>
|
||||
|
||||
- [`Readonly<T>`](https://github.com/Microsoft/TypeScript/blob/2961bc3fc0ea1117d4e53bc8e97fa76119bc33e3/src/lib/es5.d.ts#L1415-L1420) - Make all properties in `T` readonly.
|
||||
<details>
|
||||
<summary>
|
||||
Example
|
||||
</summary>
|
||||
|
||||
[Playground](https://typescript-play.js.org/?target=6#code/AQ4UwOwVwW2AZA9gc3mAbmANsA3gKFCOAHkAzMgGkOJABEwAjKZa2kAUQCcvEu32AMQCGAF2FYBIAL4BufDRABLCKLBcywgMZgEKZOoDCiCGSXI8i4hGEwwALmABnUVxXJ57YFgzZHSVF8sT1BpBSItLGEnJz1kAy5LLy0TM2RHACUwYQATEywATwAeAITjU3MAPnkrCJMXLigtUT4AClxgGztKbyDgaX99I1TzAEokr1BRAAslJwA6FIqLAF48TtswHp9MHDla9hJGACswZvmyLjAwAC8wVpm5xZHkUZDaMKIwqyWXYCW0oN4sNlsA1h0ug5gAByACyBQAggAHJHQ7ZBIFoXbzBjMCz7OoQP5YIaJNYQMAAdziCVaALGNSIAHomcAACoFJFgADKWjcSNEwG4vC4ji0wggEEQguiTnMEGALWAV1yAFp8gVgEjeFyuKICvMrCTgVxnst5jtsGC4ljsPNhXxGaAWcAAOq6YRXYDCRg+RWIcA5JSC+kWdCepQ+v3RYCU3RInzRMCGwlpC19NYBW1Ye08R1AA)
|
||||
|
||||
```ts
|
||||
enum LogLevel {
|
||||
Off,
|
||||
Debug,
|
||||
Error,
|
||||
Fatal
|
||||
};
|
||||
|
||||
interface LoggerConfig {
|
||||
name: string;
|
||||
level: LogLevel;
|
||||
}
|
||||
|
||||
class Logger {
|
||||
config: Readonly<LoggerConfig>;
|
||||
|
||||
constructor({name, level}: LoggerConfig) {
|
||||
this.config = {name, level};
|
||||
Object.freeze(this.config);
|
||||
}
|
||||
}
|
||||
|
||||
const config: LoggerConfig = {
|
||||
name: 'MyApp',
|
||||
level: LogLevel.Debug
|
||||
};
|
||||
|
||||
const logger = new Logger(config);
|
||||
|
||||
// TypeScript Error: cannot assign to read-only property.
|
||||
logger.config.level = LogLevel.Error;
|
||||
|
||||
// We are able to edit config variable as we please.
|
||||
config.level = LogLevel.Error;
|
||||
```
|
||||
</details>
|
||||
|
||||
- [`Pick<T, K>`](https://github.com/Microsoft/TypeScript/blob/2961bc3fc0ea1117d4e53bc8e97fa76119bc33e3/src/lib/es5.d.ts#L1422-L1427) - From `T`, pick a set of properties whose keys are in the union `K`.
|
||||
<details>
|
||||
<summary>
|
||||
Example
|
||||
</summary>
|
||||
|
||||
[Playground](https://typescript-play.js.org/?target=6#code/AQ4SwOwFwUwJwGYEMDGNgEE5TCgNugN4BQoZwOUBAXMAM5RyQDmA3KeSFABYCuAtgCMISMHloMmENh04oA9tBjQJjFuzIBfYrOAB6PcADCcGElh1gEGAHcKATwAO6ebyjB5CTNlwFwSxFR0BX5HeToYABNgBDh5fm8cfBg6AHIKG3ldA2BHOOcfFNpUygJ0pAhokr4hETFUgDpswywkggAFUwA3MFtgAF5gQgowKhhVKTYKGuFRcXo1aVZgbTIoJ3RW3xhOmB6+wfbcAGsAHi3kgBpgEtGy4AAfG54BWfqAPnZm4AAlZUj4MAkMA8GAGB4vEgfMlLLw6CwPBA8PYRmMgZVgAC6CgmI4cIommQELwICh8RBgKZKvALh1ur0bHQABR5PYMui0Wk7em2ADaAF0AJS0AASABUALIAGQAogR+Mp3CROCAFBBwVC2ikBpj5CgBIqGjizLA5TAFdAmalImAuqlBRoVQh5HBgEy1eDWfs7J5cjzGYKhroVfpDEhHM4MV6GRR5NN0JrtnRg6BVirTFBeHAKYmYY6QNpdB73LmCJZBlSAXAubtvczeSmQMNSuMbmKNgBlHFgPEUNwusBIPAAQlS1xetTmxT0SDoESgdD0C4aACtHMwxytLrohawgA)
|
||||
|
||||
```ts
|
||||
interface Article {
|
||||
title: string;
|
||||
thumbnail: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
// Creates new type out of the `Article` interface composed
|
||||
// from the Articles' two properties: `title` and `thumbnail`.
|
||||
// `ArticlePreview = {title: string; thumbnail: string}`
|
||||
type ArticlePreview = Pick<Article, 'title' | 'thumbnail'>;
|
||||
|
||||
// Render a list of articles using only title and description.
|
||||
function renderArticlePreviews(previews: ArticlePreview[]): HTMLElement {
|
||||
const articles = document.createElement('div');
|
||||
|
||||
for (const preview of previews) {
|
||||
// Append preview to the articles.
|
||||
}
|
||||
|
||||
return articles;
|
||||
}
|
||||
|
||||
const articles = renderArticlePreviews([
|
||||
{
|
||||
title: 'TypeScript tutorial!',
|
||||
thumbnail: '/assets/ts.jpg'
|
||||
}
|
||||
]);
|
||||
```
|
||||
</details>
|
||||
|
||||
- [`Record<K, T>`](https://github.com/Microsoft/TypeScript/blob/2961bc3fc0ea1117d4e53bc8e97fa76119bc33e3/src/lib/es5.d.ts#L1429-L1434) - Construct a type with a set of properties `K` of type `T`.
|
||||
<details>
|
||||
<summary>
|
||||
Example
|
||||
</summary>
|
||||
|
||||
[Playground](https://typescript-play.js.org/?target=6#code/AQ4ejYAUHsGcCWAXBMB2dgwGbAKYC2ADgDYwCeeemCaWArgE7ADGMxAhmuQHQBQoYEnJE8wALKEARnkaxEKdMAC8wAOS0kstGuAAfdQBM8ANzxlRjXQbVaWACwC0JPB0NqA3HwGgIwAJJoWozYHCxixnAsjAhStADmwESMMJYo1Fi4HMCIaPEu+MRklHj8gpqyoeHAAKJFFFTAAN4+giDYCIxwSAByHAR4AFw5SDF5Xm2gJBzdfQPD3WPxE5PAlBxdAPLYNQAelgh4aOHDaPQEMowrIAC+3oJ+AMKMrlrAXFhSAFZ4LEhC9g4-0BmA4JBISXgiCkBQABpILrJ5MhUGhYcATGD6Bk4Hh-jNgABrPDkOBlXyQAAq9ngYmJpOAAHcEOCRjAXqwYODfoo6DhakUSph+Uh7GI4P0xER4Cj0OSQGwMP8tP1hgAlX7swwAHgRl2RvIANALSA08ABtAC6AD4VM1Wm0Kow0MMrYaHYJjGYLLJXZb3at1HYnC43Go-QHQDcvA6-JsmEJXARgCDgMYWAhjIYhDAU+YiMAAFIwex0ZmilMITCGF79TLAGRsAgJYAAZRwSEZGzEABFTOZUrJ5Yn+jwnWgeER6HB7AAKJrADpdXqS4ZqYultTG6azVfqHswPBbtauLY7fayQ7HIbAAAMwBuAEoYw9IBq2Ixs9h2eFMOQYPQObALQKJgggABeYhghCIpikkKRpOQRIknAsZUiIeCttECBEP8NSMCkjDDAARMGziuIYxHwYOjDCMBmDNnAuTxA6irdCOBB1Lh5Dqpqn66tISIykawBnOCtqqC0gbjqc9DgpGkxegOliyfJDrRkAA)
|
||||
|
||||
```ts
|
||||
// Positions of employees in our company.
|
||||
type MemberPosition = 'intern' | 'developer' | 'tech-lead';
|
||||
|
||||
// Interface describing properties of a single employee.
|
||||
interface Employee {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
yearsOfExperience: number;
|
||||
}
|
||||
|
||||
// Create an object that has all possible `MemberPosition` values set as keys.
|
||||
// Those keys will store a collection of Employees of the same position.
|
||||
const team: Record<MemberPosition, Employee[]> = {
|
||||
intern: [],
|
||||
developer: [],
|
||||
'tech-lead': [],
|
||||
};
|
||||
|
||||
// Our team has decided to help John with his dream of becoming Software Developer.
|
||||
team.intern.push({
|
||||
firstName: 'John',
|
||||
lastName: 'Doe',
|
||||
yearsOfExperience: 0
|
||||
});
|
||||
|
||||
// `Record` forces you to initialize all of the property keys.
|
||||
// TypeScript Error: "tech-lead" property is missing
|
||||
const teamEmpty: Record<MemberPosition, null> = {
|
||||
intern: null,
|
||||
developer: null,
|
||||
};
|
||||
```
|
||||
</details>
|
||||
|
||||
- [`Exclude<T, U>`](https://github.com/Microsoft/TypeScript/blob/2961bc3fc0ea1117d4e53bc8e97fa76119bc33e3/src/lib/es5.d.ts#L1436-L1439) - Exclude from `T` those types that are assignable to `U`.
|
||||
<details>
|
||||
<summary>
|
||||
Example
|
||||
</summary>
|
||||
|
||||
[Playground](https://typescript-play.js.org/?target=6#code/JYOwLgpgTgZghgYwgAgMrQG7QMIHsQzADmyA3gFDLIAOuUYAXMiAK4A2byAPsgM5hRQJHqwC2AI2gBucgF9y5MAE9qKAEoQAjiwj8AEnBAATNtGQBeZAAooWphu26wAGmS3e93bRC8IASgsAPmRDJRlyAHoI5ABRAA8ENhYjFFYOZGVVZBgoXFFkAAM0zh5+QRBhZhYJaAKAOkjogEkQZAQ4X2QAdwALCFbaemRgXmQtFjhOMFwq9K6ULuB0lk6U+HYwZAxJnQaYFhAEMGB8ZCIIMAAFOjAANR2IK0HGWISklIAedCgsKDwCYgAbQA5M9gQBdVzFQJ+JhiSRQMiUYYwayZCC4VHPCzmSzAspCYEBWxgFhQAZwKC+FpgJ43VwARgADH4ZFQSWSBjcZPJyPtDsdTvxKWBvr8rD1DCZoJ5HPopaYoK4EPhCEQmGKcKriLCtrhgEYkVQVT5Nr4fmZLLZtMBbFZgT0wGBqES6ghbHBIJqoBKFdBWQpjfh+DQbhY2tqiHVsbjLMVkAB+ZAAZiZaeQTHOVxu9ySjxNaujNwDVHNvzqbBGkBAdPoAfkQA)
|
||||
|
||||
```ts
|
||||
interface ServerConfig {
|
||||
port: null | string | number;
|
||||
}
|
||||
|
||||
type RequestHandler = (request: Request, response: Response) => void;
|
||||
|
||||
// Exclude `null` type from `null | string | number`.
|
||||
// In case the port is equal to `null`, we will use default value.
|
||||
function getPortValue(port: Exclude<ServerConfig['port'], null>): number {
|
||||
if (typeof port === 'string') {
|
||||
return parseInt(port, 10);
|
||||
}
|
||||
|
||||
return port;
|
||||
}
|
||||
|
||||
function startServer(handler: RequestHandler, config: ServerConfig): void {
|
||||
const server = require('http').createServer(handler);
|
||||
|
||||
const port = config.port === null ? 3000 : getPortValue(config.port);
|
||||
server.listen(port);
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
- [`Extract<T, U>`](https://github.com/Microsoft/TypeScript/blob/2961bc3fc0ea1117d4e53bc8e97fa76119bc33e3/src/lib/es5.d.ts#L1441-L1444) - Extract from `T` those types that are assignable to `U`.
|
||||
<details>
|
||||
<summary>
|
||||
Example
|
||||
</summary>
|
||||
|
||||
[Playground](https://typescript-play.js.org/?target=6#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXzSwEdkQBJYACgEoAueVZAWwCMQYBuAKDDwGcM8MgBF4AXngBlAJ6scESgHIRi6ty5ZUGdoihgEABXZ888AN5d48ANoiAuvUat23K6ihMQ9ATE0BzV3goPy8GZjZOLgBfLi4Aejj4AEEICBwAdz54MAALKFQQ+BxEeAAHY1NgKAwoIKy0grr4DByEUpgccpgMaXgAaxBerCzi+B9-ZulygDouFHRsU1z8kKMYE1RhaqgAHkt4AHkWACt4EAAPbVRgLLWNgBp9gGlBs8uQa6yAUUuYPQwdgNpKM7nh7mMML4CgA+R5WABqUAgpDeVxuhxO1he0jsXGh8EoOBO9COx3BQPo2PBADckaR6IjkSA6PBqTgsMBzPsicdrEC7OJWXSQNwYvFEgAVTS9JLXODpeDpKBZFg4GCoWa8VACIJykAKiQWKy2YQOAioYikCg0OEMDyhRSy4DyxS24KhAAMjyi6gS8AAwjh5OD0iBFHAkJoEOksC1mnkMJq8gUQKDNttKPlnfrwYp3J5XfBHXqoKpfYkAOI4ansTxaeDADmoRSCCBYAbxhC6TDx6rwYHIRX5bScjA4bLJwoDmDwDkfbA9JMrVMVdM1TN69LgkTgwgkchUahqIA)
|
||||
|
||||
```ts
|
||||
declare function uniqueId(): number;
|
||||
|
||||
const ID = Symbol('ID');
|
||||
|
||||
interface Person {
|
||||
[ID]: number;
|
||||
name: string;
|
||||
age: number;
|
||||
}
|
||||
|
||||
// Allows changing the person data as long as the property key is of string type.
|
||||
function changePersonData<
|
||||
Obj extends Person,
|
||||
Key extends Extract<keyof Person, string>,
|
||||
Value extends Obj[Key]
|
||||
> (obj: Obj, key: Key, value: Value): void {
|
||||
obj[key] = value;
|
||||
}
|
||||
|
||||
// Tiny Andrew was born.
|
||||
const andrew = {
|
||||
[ID]: uniqueId(),
|
||||
name: 'Andrew',
|
||||
age: 0,
|
||||
};
|
||||
|
||||
// Cool, we're fine with that.
|
||||
changePersonData(andrew, 'name', 'Pony');
|
||||
|
||||
// Goverment didn't like the fact that you wanted to change your identity.
|
||||
changePersonData(andrew, ID, uniqueId());
|
||||
```
|
||||
</details>
|
||||
|
||||
- [`NonNullable<T>`](https://github.com/Microsoft/TypeScript/blob/2961bc3fc0ea1117d4e53bc8e97fa76119bc33e3/src/lib/es5.d.ts#L1446-L1449) - Exclude `null` and `undefined` from `T`.
|
||||
<details>
|
||||
<summary>
|
||||
Example
|
||||
</summary>
|
||||
Works with <code>strictNullChecks</code> set to <code>true</code>. (Read more <a href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html">here</a>)
|
||||
|
||||
[Playground](https://typescript-play.js.org/?target=6#code/C4TwDgpgBACg9gJ2AOQK4FsBGEFQLxQDOwCAlgHYDmUAPlORtrnQwDasDcAUFwPQBU-WAEMkUOADMowqAGNWwwoSgATCBIqlgpOOSjAAFsOBRSy1IQgr9cKJlSlW1mZYQA3HFH68u8xcoBlHA8EACEHJ08Aby4oKDBUTFZSWXjEFEYcAEIALihkXTR2YSSIAB54JDQsHAA+blj4xOTUsHSACkMzPKD3HHDHNQQAGjSkPMqMmoQASh7g-oihqBi4uNIpdraxPAI2VhmVxrX9AzMAOm2ppnwoAA4ABifuE4BfKAhWSyOTuK7CS7pao3AhXF5rV48E4ICDAVAIPT-cGQyG+XTEIgLMJLTx7CAAdygvRCA0iCHaMwarhJOIQjUBSHaACJHk8mYdeLwxtdcVAAOSsh58+lXdr7Dlcq7A3n3J4PEUdADMcspUE53OluAIUGVTx46oAKuAIAFZGQwCYAKIIBCILjUxaDHAMnla+iodjcIA)
|
||||
|
||||
```ts
|
||||
type PortNumber = string | number | null;
|
||||
|
||||
/** Part of a class definition that is used to build a server */
|
||||
class ServerBuilder {
|
||||
portNumber!: NonNullable<PortNumber>;
|
||||
|
||||
port(this: ServerBuilder, port: PortNumber): ServerBuilder {
|
||||
if (port == null) {
|
||||
this.portNumber = 8000;
|
||||
} else {
|
||||
this.portNumber = port;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
const serverBuilder = new ServerBuilder();
|
||||
|
||||
serverBuilder
|
||||
.port('8000') // portNumber = '8000'
|
||||
.port(null) // portNumber = 8000
|
||||
.port(3000); // portNumber = 3000
|
||||
|
||||
// TypeScript error
|
||||
serverBuilder.portNumber = null;
|
||||
```
|
||||
</details>
|
||||
|
||||
- [`Parameters<T>`](https://github.com/Microsoft/TypeScript/blob/2961bc3fc0ea1117d4e53bc8e97fa76119bc33e3/src/lib/es5.d.ts#L1451-L1454) - Obtain the parameters of a function type in a tuple.
|
||||
<details>
|
||||
<summary>
|
||||
Example
|
||||
</summary>
|
||||
|
||||
[Playground](https://typescript-play.js.org/?target=6#code/GYVwdgxgLglg9mABAZwBYmMANgUwBQxgAOIUAXIgIZgCeA2gLoCUFAbnDACaIDeAUIkQB6IYgCypSlBxUATrMo1ECsJzgBbLEoipqAc0J7EMKMgDkiHLnU4wp46pwAPHMgB0fAL58+oSLARECEosLAA5ABUYG2QAHgAxJGdpVWREPDdMylk9ZApqemZEAF4APipacrw-CApEgBogkKwAYThwckQwEHUAIxxZJl4BYVEImiIZKF0oZRwiWVdbeygJmThgOYgcGFYcbhqApCJsyhtpWXcR1cnEePBoeDAABVPzgbTixFeFd8uEsClADcIxGiygIFkSEOT3SmTc2VydQeRx+ZxwF2QQ34gkEwDgsnSuFmMBKiAADEDjIhYk1Qm0OlSYABqZnYka4xA1DJZHJYkGc7yCbyeRA+CAIZCzNAYbA4CIAdxg2zJwVCkWirjwMswuEaACYmCCgA)
|
||||
|
||||
```ts
|
||||
function shuffle(input: any[]): void {
|
||||
// Mutate array randomly changing its' elements indexes.
|
||||
}
|
||||
|
||||
function callNTimes<Fn extends (...args: any[]) => any> (func: Fn, callCount: number) {
|
||||
// Type that represents the type of the received function parameters.
|
||||
type FunctionParameters = Parameters<Fn>;
|
||||
|
||||
return function (...args: FunctionParameters) {
|
||||
for (let i = 0; i < callCount; i++) {
|
||||
func(...args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const shuffleTwice = callNTimes(shuffle, 2);
|
||||
```
|
||||
</details>
|
||||
|
||||
- [`ConstructorParameters<T>`](https://github.com/Microsoft/TypeScript/blob/2961bc3fc0ea1117d4e53bc8e97fa76119bc33e3/src/lib/es5.d.ts#L1456-L1459) - Obtain the parameters of a constructor function type in a tuple.
|
||||
<details>
|
||||
<summary>
|
||||
Example
|
||||
</summary>
|
||||
|
||||
[Playground](https://typescript-play.js.org/?target=6#code/MYGwhgzhAECCBOAXAlqApgWQPYBM0mgG8AoaaFRENALmgkXmQDsBzAblOmCycTV4D8teo1YdO3JiICuwRFngAKClWENmLAJRFOZRAAtkEAHQq00ALzlklNBzIBfYk+KhIMAJJTEYJsDQAwmDA+mgAPAAq0GgAHnxMODCKTGgA7tCKxllg8CwQtL4AngDaALraFgB80EWa1SRkAA6MAG5gfNAB4FABPDJyCrQR9tDNyG0dwMGhtBhgjWEiGgA00F70vv4RhY3hEZXVVinpc42KmuJkkv3y8Bly8EPaDWTkhiZd7r3e8LK3llwGCMXGQWGhEOsfH5zJlsrl8p0+gw-goAAo5MAAW3BaHgEEilU0tEhmzQ212BJ0ry4SOg+kg+gBBiMximIGA0nAfAQLGk2N4EAAEgzYcYcnkLsRdDTvNEYkYUKwSdCme9WdM0MYwYhFPSIPpJdTkAAzDKxBUaZX+aAAQgsVmkCTQxuYaBw2ng4Ok8CYcotSu8pMur09iG9vuObxZnx6SN+AyUWTF8MN0CcZE4Ywm5jZHK5aB5fP4iCFIqT4oRRTKRLo6lYVNeAHpG50wOzOe1zHr9NLQ+HoABybsD4HOKXXRA1JCoKhBELmI5pNaB6Fz0KKBAodDYPAgSUTmqYsAALx4m5nC6nW9nGq14KtaEUA9gR9PvuNCjQ9BgACNvcwNBtAcLiAA)
|
||||
|
||||
```ts
|
||||
class ArticleModel {
|
||||
title: string;
|
||||
content?: string;
|
||||
|
||||
constructor(title: string) {
|
||||
this.title = title;
|
||||
}
|
||||
}
|
||||
|
||||
class InstanceCache<T extends (new (...args: any[]) => any)> {
|
||||
private ClassConstructor: T;
|
||||
private cache: Map<string, InstanceType<T>> = new Map();
|
||||
|
||||
constructor (ctr: T) {
|
||||
this.ClassConstructor = ctr;
|
||||
}
|
||||
|
||||
getInstance (...args: ConstructorParameters<T>): InstanceType<T> {
|
||||
const hash = this.calculateArgumentsHash(...args);
|
||||
|
||||
const existingInstance = this.cache.get(hash);
|
||||
if (existingInstance !== undefined) {
|
||||
return existingInstance;
|
||||
}
|
||||
|
||||
return new this.ClassConstructor(...args);
|
||||
}
|
||||
|
||||
private calculateArgumentsHash(...args: any[]): string {
|
||||
// Calculate hash.
|
||||
return 'hash';
|
||||
}
|
||||
}
|
||||
|
||||
const articleCache = new InstanceCache(ArticleModel);
|
||||
const amazonArticle = articleCache.getInstance('Amazon forests burining!');
|
||||
```
|
||||
</details>
|
||||
|
||||
- [`ReturnType<T>`](https://github.com/Microsoft/TypeScript/blob/2961bc3fc0ea1117d4e53bc8e97fa76119bc33e3/src/lib/es5.d.ts#L1461-L1464) – Obtain the return type of a function type.
|
||||
<details>
|
||||
<summary>
|
||||
Example
|
||||
</summary>
|
||||
|
||||
[Playground](https://typescript-play.js.org/?target=6#code/MYGwhgzhAECSAmICmBlJAnAbgS2E6A3gFDTTwD2AcuQC4AW2AdgOYAUAlAFzSbnbyEAvkWFFQkGJSQB3GMVI1sNZNwg10TZgG4S0YOUY0kh1es07d+xmvQBXYDXLpWi5UlMaWAGj0GjJ6BtNdkJdBQYIADpXZGgAXmgYpB1ScOwoq38aeN9DYxoU6GFRKzVoJjUwRjwAYXJbPPRuAFkwAAcAHgAxBodsAx9GWwBbACMMAD4cxhloVraOCyYjdAAzMDxoOut1e0d0UNIZ6WhWSPOwdGYIbiqATwBtAF0uaHudUQB6ACpv6ABpJBINqJdAbADW0Do5BOw3u5R2VTwMHIq2gAANtjZ0bkbHsnFCwJh8ONjHp0EgwEZ4JFoN9PkRVr1FAZoMwkDRYIjqkgOrosepoEgAB7+eAwAV2BxOLy6ACCVxgIrFEoMeOl6AACpcwMMORgIB1JRMiBNWKVdhruJKfOdIpdrtwFddXlzKjyACp3Nq842HaDIbL6BrZBIVGhIpB1EMYSLsmjmtWW-YhAA+qegAAYLKQLQj3ZsEsdccmnGcLor2Dn8xGedHGpEIBzEzspfsfMHDNAANTQACMVaIljV5GQkRA5DYmIpVKQAgAJARO9le33BDXIyi0YuLW2nJFGLqkOvxFB0YPdBSaLZ0IwNzyPkO8-xkGgsLh8Al427a3hWAhXwwHA8EHT5PmgAB1bAQBAANJ24adKWpft72RaBUTgRBUCAj89HAM8xCTaBjggABRQx0DuHJv25P9dCkWRZVIAAiBjoFImpmjlFBgA0NpsjadByDacgIDAEAIAAQmYpjoGYgAZSBsmGPw6DtZiiFA8CoJguDmAQmoZ2QvtUKQLdoAYmBTwgdEiCAA)
|
||||
|
||||
```ts
|
||||
/** Provides every element of the iterable `iter` into the `callback` function and stores the results in an array. */
|
||||
function mapIter<
|
||||
Elem,
|
||||
Func extends (elem: Elem) => any,
|
||||
Ret extends ReturnType<Func>
|
||||
>(iter: Iterable<Elem>, callback: Func): Ret[] {
|
||||
const mapped: Ret[] = [];
|
||||
|
||||
for (const elem of iter) {
|
||||
mapped.push(callback(elem));
|
||||
}
|
||||
|
||||
return mapped;
|
||||
}
|
||||
|
||||
const setObject: Set<string> = new Set();
|
||||
const mapObject: Map<number, string> = new Map();
|
||||
|
||||
mapIter(setObject, (value: string) => value.indexOf('Foo')); // number[]
|
||||
|
||||
mapIter(mapObject, ([key, value]: [number, string]) => {
|
||||
return key % 2 === 0 ? value : 'Odd';
|
||||
}); // string[]
|
||||
```
|
||||
</details>
|
||||
|
||||
- [`InstanceType<T>`](https://github.com/Microsoft/TypeScript/blob/2961bc3fc0ea1117d4e53bc8e97fa76119bc33e3/src/lib/es5.d.ts#L1466-L1469) – Obtain the instance type of a constructor function type.
|
||||
<details>
|
||||
<summary>
|
||||
Example
|
||||
</summary>
|
||||
|
||||
[Playground](https://typescript-play.js.org/?target=6#code/MYGwhgzhAECSAmICmBlJAnAbgS2E6A3gFDTTwD2AcuQC4AW2AdgOYAUAlAFzSbnbyEAvkWFFQkGJSQB3GMVI1sNZNwg10TZgG4S0YOUY0kh1es07d+xmvQBXYDXLpWi5UlMaWAGj0GjJ6BtNdkJdBQYIADpXZGgAXmgYpB1ScOwoq38aeN9DYxoU6GFRKzVoJjUwRjwAYXJbPPRuAFkwAAcAHgAxBodsAx9GWwBbACMMAD4cxhloVraOCyYjdAAzMDxoOut1e0d0UNIZ6WhWSPOwdGYIbiqATwBtAF0uaHudUQB6ACpv6ABpJBINqJdAbADW0Do5BOw3u5R2VTwMHIq2gAANtjZ0bkbHsnFCwJh8ONjHp0EgwEZ4JFoN9PkRVr1FAZoMwkDRYIjqkgOrosepoEgAB7+eAwAV2BxOLy6ACCVxgIrFEoMeOl6AACpcwMMORgIB1JRMiBNWKVdhruJKfOdIpdrtwFddXlzKjyACp3Nq842HaDIbL6BrZBIVGhIpB1EMYSLsmjmtWW-YhAA+qegAAYLKQLQj3ZsEsdccmnGcLor2Dn8xGedHGpEIBzEzspfsfMHDNAANTQACMVaIljV5GQkRA5DYmIpVKQAgAJARO9le33BDXIyi0YuLW2nJFGLqkOvxFB0YPdBSaLZ0IwNzyPkO8-xkGgsLh8Al427a3hWAhXwwHA8EHT5PmgAB1bAQBAANJ24adKWpft72RaBUTgRBUCAj89HAM8xCTaBjggABRQx0DuHJv25P9dCkWRZVIAAiBjoFImpmjlFBgA0NpsjadByDacgIDAEAIAAQmYpjoGYgAZSBsmGPw6DtZiiFA8CoJguDmAQmoZ2QvtUKQLdoAYmBTwgdEiCAA)
|
||||
|
||||
```ts
|
||||
class IdleService {
|
||||
doNothing (): void {}
|
||||
}
|
||||
|
||||
class News {
|
||||
title: string;
|
||||
content: string;
|
||||
|
||||
constructor(title: string, content: string) {
|
||||
this.title = title;
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
|
||||
const instanceCounter: Map<Function, number> = new Map();
|
||||
|
||||
interface Constructor {
|
||||
new(...args: any[]): any;
|
||||
}
|
||||
|
||||
// Keep track how many instances of `Constr` constructor have been created.
|
||||
function getInstance<
|
||||
Constr extends Constructor,
|
||||
Args extends ConstructorParameters<Constr>
|
||||
>(constructor: Constr, ...args: Args): InstanceType<Constr> {
|
||||
let count = instanceCounter.get(constructor) || 0;
|
||||
|
||||
const instance = new constructor(...args);
|
||||
|
||||
instanceCounter.set(constructor, count + 1);
|
||||
|
||||
console.log(`Created ${count + 1} instances of ${Constr.name} class`);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
const idleService = getInstance(IdleService);
|
||||
// Will log: `Created 1 instances of IdleService class`
|
||||
const newsEntry = getInstance(News, 'New ECMAScript proposals!', 'Last month...');
|
||||
// Will log: `Created 1 instances of News class`
|
||||
```
|
||||
</details>
|
||||
|
||||
- [`Omit<T, K>`](https://github.com/microsoft/TypeScript/blob/71af02f7459dc812e85ac31365bfe23daf14b4e4/src/lib/es5.d.ts#L1446) – Constructs a type by picking all properties from T and then removing K.
|
||||
<details>
|
||||
<summary>
|
||||
Example
|
||||
</summary>
|
||||
|
||||
[Playground](https://typescript-play.js.org/?target=6#code/JYOwLgpgTgZghgYwgAgIImAWzgG2QbwChlks4BzCAVShwC5kBnMKUcgbmKYAcIFgIjBs1YgOXMpSFMWbANoBdTiW5woFddwAW0kfKWEAvoUIB6U8gDCUCHEiNkICAHdkYAJ69kz4GC3JcPG4oAHteKDABBxCYNAxsPFBIWEQUCAAPJG4wZABySUFcgJAAEzMLXNV1ck0dIuCw6EjBADpy5AB1FAQ4EGQAV0YUP2AHDy8wEOQbUugmBLwtEIA3OcmQnEjuZBgQqE7gAGtgZAhwKHdkHFGwNvGUdDIcAGUliIBJEF3kAF5kAHlML4ADyPBIAGjyBUYRQAPnkqho4NoYQA+TiEGD9EAISIhPozErQMG4AASK2gn2+AApek9pCSXm8wFSQooAJQMUkAFQAsgAZACiOAgmDOOSIJAQ+OYyGl4DgoDmf2QJRCCH6YvALQQNjsEGFovF1NyJWAy1y7OUyHMyE+yRAuFImG4Iq1YDswHxbRINjA-SgfXlHqVUE4xiAA)
|
||||
|
||||
```ts
|
||||
interface Animal {
|
||||
imageUrl: string;
|
||||
species: string;
|
||||
images: string[];
|
||||
paragraphs: string[];
|
||||
}
|
||||
|
||||
// Creates new type with all properties of the `Animal` interface
|
||||
// except 'images' and 'paragraphs' properties. We can use this
|
||||
// type to render small hover tooltip for a wiki entry list.
|
||||
type AnimalShortInfo = Omit<Animal, 'images' | 'paragraphs'>;
|
||||
|
||||
function renderAnimalHoverInfo (animals: AnimalShortInfo[]): HTMLElement {
|
||||
const container = document.createElement('div');
|
||||
// Internal implementation.
|
||||
return container;
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
You can find some examples in the [TypeScript docs](https://www.typescriptlang.org/docs/handbook/advanced-types.html#predefined-conditional-types).
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Jarek Radosz](https://github.com/CvX)
|
||||
- [Dimitri Benin](https://github.com/BendingBender)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
(MIT OR CC0-1.0)
|
||||
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-type-fest?utm_source=npm-type-fest&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/// <reference lib="esnext"/>
|
||||
|
||||
// TODO: This can just be `export type Primitive = not object` when the `not` keyword is out.
|
||||
/**
|
||||
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
||||
*/
|
||||
export type Primitive =
|
||||
| null
|
||||
| undefined
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| symbol
|
||||
| bigint;
|
||||
|
||||
// TODO: Remove the `= unknown` sometime in the future when most users are on TS 3.5 as it's now the default
|
||||
/**
|
||||
Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
||||
*/
|
||||
export type Class<T = unknown, Arguments extends any[] = any[]> = new(...arguments_: Arguments) => T;
|
||||
|
||||
/**
|
||||
Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.
|
||||
*/
|
||||
export type TypedArray =
|
||||
| Int8Array
|
||||
| Uint8Array
|
||||
| Uint8ClampedArray
|
||||
| Int16Array
|
||||
| Uint16Array
|
||||
| Int32Array
|
||||
| Uint32Array
|
||||
| Float32Array
|
||||
| Float64Array
|
||||
| BigInt64Array
|
||||
| BigUint64Array;
|
||||
|
||||
/**
|
||||
Matches a JSON object.
|
||||
|
||||
This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`.
|
||||
*/
|
||||
export type JsonObject = {[key: string]: JsonValue};
|
||||
|
||||
/**
|
||||
Matches a JSON array.
|
||||
*/
|
||||
export interface JsonArray extends Array<JsonValue> {}
|
||||
|
||||
/**
|
||||
Matches any valid JSON value.
|
||||
*/
|
||||
export type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
|
||||
|
||||
declare global {
|
||||
interface SymbolConstructor {
|
||||
readonly observable: symbol;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Matches a value that is like an [Observable](https://github.com/tc39/proposal-observable).
|
||||
*/
|
||||
export interface ObservableLike {
|
||||
subscribe(observer: (value: unknown) => void): void;
|
||||
[Symbol.observable](): ObservableLike;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
Create a type from an object type without certain keys.
|
||||
|
||||
This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
|
||||
|
||||
Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/30825) if you want to have the stricter version as a built-in in TypeScript.
|
||||
|
||||
@example
|
||||
```
|
||||
import {Except} from 'type-fest';
|
||||
|
||||
type Foo = {
|
||||
a: number;
|
||||
b: string;
|
||||
c: boolean;
|
||||
};
|
||||
|
||||
type FooWithoutA = Except<Foo, 'a' | 'c'>;
|
||||
//=> {b: string};
|
||||
```
|
||||
*/
|
||||
export type Except<ObjectType, KeysType extends keyof ObjectType> = Pick<ObjectType, Exclude<keyof ObjectType, KeysType>>;
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
import {Primitive} from './basic';
|
||||
|
||||
/**
|
||||
Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
|
||||
|
||||
Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
|
||||
|
||||
This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
|
||||
|
||||
@example
|
||||
```
|
||||
import {LiteralUnion} from 'type-fest';
|
||||
|
||||
// Before
|
||||
|
||||
type Pet = 'dog' | 'cat' | string;
|
||||
|
||||
const pet: Pet = '';
|
||||
// Start typing in your TypeScript-enabled IDE.
|
||||
// You **will not** get auto-completion for `dog` and `cat` literals.
|
||||
|
||||
// After
|
||||
|
||||
type Pet2 = LiteralUnion<'dog' | 'cat', string>;
|
||||
|
||||
const pet: Pet2 = '';
|
||||
// You **will** get auto-completion for `dog` and `cat` literals.
|
||||
```
|
||||
*/
|
||||
export type LiteralUnion<
|
||||
LiteralType extends BaseType,
|
||||
BaseType extends Primitive
|
||||
> = LiteralType | (BaseType & {_?: never});
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// Helper type. Not useful on its own.
|
||||
type Without<FirstType, SecondType> = {[KeyType in Exclude<keyof FirstType, keyof SecondType>]?: never};
|
||||
|
||||
/**
|
||||
Create a type that has mutually exclusive keys.
|
||||
|
||||
This type was inspired by [this comment](https://github.com/Microsoft/TypeScript/issues/14094#issuecomment-373782604).
|
||||
|
||||
This type works with a helper type, called `Without`. `Without<FirstType, SecondType>` produces a type that has only keys from `FirstType` which are not present on `SecondType` and sets the value type for these keys to `never`. This helper type is then used in `MergeExclusive` to remove keys from either `FirstType` or `SecondType`.
|
||||
|
||||
@example
|
||||
```
|
||||
import {MergeExclusive} from 'type-fest';
|
||||
|
||||
interface ExclusiveVariation1 {
|
||||
exclusive1: boolean;
|
||||
}
|
||||
|
||||
interface ExclusiveVariation2 {
|
||||
exclusive2: string;
|
||||
}
|
||||
|
||||
type ExclusiveOptions = MergeExclusive<ExclusiveVariation1, ExclusiveVariation2>;
|
||||
|
||||
let exclusiveOptions: ExclusiveOptions;
|
||||
|
||||
exclusiveOptions = {exclusive1: true};
|
||||
//=> Works
|
||||
exclusiveOptions = {exclusive2: 'hi'};
|
||||
//=> Works
|
||||
exclusiveOptions = {exclusive1: true, exclusive2: 'hi'};
|
||||
//=> Error
|
||||
```
|
||||
*/
|
||||
export type MergeExclusive<FirstType, SecondType> =
|
||||
(FirstType | SecondType) extends object ?
|
||||
(Without<FirstType, SecondType> & SecondType) | (Without<SecondType, FirstType> & FirstType) :
|
||||
FirstType | SecondType;
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
import {Except} from './except';
|
||||
|
||||
/**
|
||||
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
||||
|
||||
@example
|
||||
```
|
||||
import {Merge} from 'type-fest';
|
||||
|
||||
type Foo = {
|
||||
a: number;
|
||||
b: string;
|
||||
};
|
||||
|
||||
type Bar = {
|
||||
b: number;
|
||||
};
|
||||
|
||||
const ab: Merge<Foo, Bar> = {a: 1, b: 2};
|
||||
```
|
||||
*/
|
||||
export type Merge<FirstType, SecondType> = Except<FirstType, Extract<keyof FirstType, keyof SecondType>> & SecondType;
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
Convert an object with `readonly` keys into a mutable object. Inverse of `Readonly<T>`.
|
||||
|
||||
This can be used to [store and mutate options within a class](https://github.com/sindresorhus/pageres/blob/4a5d05fca19a5fbd2f53842cbf3eb7b1b63bddd2/source/index.ts#L72), [edit `readonly` objects within tests](https://stackoverflow.com/questions/50703834), and [construct a `readonly` object within a function](https://github.com/Microsoft/TypeScript/issues/24509).
|
||||
|
||||
@example
|
||||
```
|
||||
import {Mutable} from 'type-fest';
|
||||
|
||||
type Foo = {
|
||||
readonly a: number;
|
||||
readonly b: string;
|
||||
};
|
||||
|
||||
const mutableFoo: Mutable<Foo> = {a: 1, b: '2'};
|
||||
mutableFoo.a = 3;
|
||||
```
|
||||
*/
|
||||
export type Mutable<ObjectType> = {
|
||||
// For each `Key` in the keys of `ObjectType`, make a mapped type by removing the `readonly` modifier from the key.
|
||||
-readonly [KeyType in keyof ObjectType]: ObjectType[KeyType];
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue