semver
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ author: OpportunityLiu
|
||||
inputs:
|
||||
xmake-version:
|
||||
required: true
|
||||
default: master
|
||||
default: latest
|
||||
description: The version to use.
|
||||
outputs:
|
||||
time: # id of output
|
||||
|
||||
@@ -1,17 +1,71 @@
|
||||
const core = require('@actions/core')
|
||||
const { exec, execSync } = require('child_process')
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
const child_process = require('child_process')
|
||||
const fetch = require('node-fetch')
|
||||
const fs = require('fs')
|
||||
const git = require('simple-git/promise')
|
||||
const semver = require('semver')
|
||||
const octokit = require('@octokit/rest')
|
||||
|
||||
const xmakeRepo = { owner: 'xmake-io', repo: 'xmake' }
|
||||
|
||||
async function fetchVersions() {
|
||||
const api = new octokit()
|
||||
const tags = await api.repos.listTags({ ...xmakeRepo, per_page: 100 })
|
||||
/**
|
||||
* @type {Object.<string, string>}
|
||||
*/
|
||||
const versions = {}
|
||||
tags.data.forEach(tag => {
|
||||
const ver = semver.valid(tag.name)
|
||||
if (ver) {
|
||||
versions[ver] = tag.commit.sha
|
||||
}
|
||||
})
|
||||
return versions
|
||||
}
|
||||
|
||||
async function download(sha) {
|
||||
const folder = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'xmake'))
|
||||
console.log(folder)
|
||||
const repo = git(folder)
|
||||
await repo.init()
|
||||
await repo.addRemote('origin', 'https://gitee.com/tboox/xmake.git');
|
||||
await repo.fetch()
|
||||
await repo.checkout(sha)
|
||||
await repo.submoduleUpdate(['--init', '--recursive'])
|
||||
return folder
|
||||
}
|
||||
|
||||
async function getSha() {
|
||||
let version = core.getInput('xmake-version') || 'latest'
|
||||
if (version.toLowerCase() === 'latest') version = ''
|
||||
version = semver.validRange(version)
|
||||
if (!version) throw new Error(`Invalid input xmake-version: ${core.getInput('xmake-version')}`)
|
||||
|
||||
const versions = await fetchVersions()
|
||||
const ver = semver.maxSatisfying(Object.keys(versions), version)
|
||||
if (!ver) throw new Error(`No matched releases of xmake-version: ${version}`)
|
||||
return versions[ver]
|
||||
}
|
||||
|
||||
function exec(command) {
|
||||
return new Promise((resolve, reject) =>
|
||||
child_process.exec(command, {}, (error, stdout, stderr) => {
|
||||
if (error) reject(error)
|
||||
resolve({ stdout, stderr })
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const version = core.getInput('xmake-version')
|
||||
|
||||
const data = fetch('https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.sh')
|
||||
await fs.promises.mkdir('/tmp/xmake')
|
||||
await fs.promises.writeFile(`/tmp/xmake/get.sh`, await (await data).buffer())
|
||||
execSync(`bash /tmp/xmake/get.sh`)
|
||||
|
||||
const folder = await core.group("download xmake", async () => await download(await getSha()))
|
||||
await core.group("install xmake", async () => {
|
||||
await exec(`make -C ${folder} build`)
|
||||
await exec(`make -C ${folder} install prefix=/home/runner/.local`)
|
||||
})
|
||||
core.addPath("/home/runner/.local/bin")
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
|
||||
+2
-2
@@ -6,10 +6,10 @@ case `uname` in
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../semver/bin/semver" "$@"
|
||||
"$basedir/node" "$basedir/../semver/bin/semver.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../semver/bin/semver" "$@"
|
||||
node "$basedir/../semver/bin/semver.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ IF EXIST "%dp0%\node.exe" (
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\semver\bin\semver" %*
|
||||
"%_prog%" "%dp0%\..\semver\bin\semver.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
|
||||
+2
-2
@@ -9,10 +9,10 @@ if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
& "$basedir/node$exe" "$basedir/../semver/bin/semver" $args
|
||||
& "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../semver/bin/semver" $args
|
||||
& "node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
|
||||
+9
-7
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"_from": "@octokit/rest@^16.15.0",
|
||||
"_from": "@octokit/rest",
|
||||
"_id": "@octokit/rest@16.30.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-1n2QzTbbaBXNLpx7WHlcsSMdJvxSdKmerXQm+bMYlKDbQM19uq446ZpGs7Ynq5SsdLj1usIfgJ9gJf4LtcWkDw==",
|
||||
@@ -8,23 +8,25 @@
|
||||
"os-name": "3.1.0"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "@octokit/rest@^16.15.0",
|
||||
"raw": "@octokit/rest",
|
||||
"name": "@octokit/rest",
|
||||
"escapedName": "@octokit%2frest",
|
||||
"scope": "@octokit",
|
||||
"rawSpec": "^16.15.0",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^16.15.0"
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/",
|
||||
"/@actions/github"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-16.30.1.tgz",
|
||||
"_shasum": "03e6dfb93e9a9cd2b3bacb95c49a8c7923f42ad0",
|
||||
"_spec": "@octokit/rest@^16.15.0",
|
||||
"_where": "C:\\Users\\lzy\\Documents\\Source\\OpportunityLiu\\github-action-setup-xmake\\node_modules\\@actions\\github",
|
||||
"_spec": "@octokit/rest",
|
||||
"_where": "C:\\Users\\lzy\\Documents\\Source\\OpportunityLiu\\github-action-setup-xmake",
|
||||
"author": {
|
||||
"name": "Gregor Martynus",
|
||||
"url": "https://github.com/gr2m"
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../semver/bin/semver" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../semver/bin/semver" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\semver\bin\semver" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
& "$basedir/node$exe" "$basedir/../semver/bin/semver" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../semver/bin/semver" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
# changes log
|
||||
|
||||
## 5.7
|
||||
|
||||
* Add `minVersion` method
|
||||
|
||||
## 5.6
|
||||
|
||||
* Move boolean `loose` param to an options object, with
|
||||
backwards-compatibility protection.
|
||||
* Add ability to opt out of special prerelease version handling with
|
||||
the `includePrerelease` option flag.
|
||||
|
||||
## 5.5
|
||||
|
||||
* Add version coercion capabilities
|
||||
|
||||
## 5.4
|
||||
|
||||
* Add intersection checking
|
||||
|
||||
## 5.3
|
||||
|
||||
* Add `minSatisfying` method
|
||||
|
||||
## 5.2
|
||||
|
||||
* Add `prerelease(v)` that returns prerelease components
|
||||
|
||||
## 5.1
|
||||
|
||||
* Add Backus-Naur for ranges
|
||||
* Remove excessively cute inspection methods
|
||||
|
||||
## 5.0
|
||||
|
||||
* Remove AMD/Browserified build artifacts
|
||||
* Fix ltr and gtr when using the `*` range
|
||||
* Fix for range `*` with a prerelease identifier
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and 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.
|
||||
+412
@@ -0,0 +1,412 @@
|
||||
semver(1) -- The semantic versioner for npm
|
||||
===========================================
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm install --save semver
|
||||
````
|
||||
|
||||
## Usage
|
||||
|
||||
As a node module:
|
||||
|
||||
```js
|
||||
const semver = require('semver')
|
||||
|
||||
semver.valid('1.2.3') // '1.2.3'
|
||||
semver.valid('a.b.c') // null
|
||||
semver.clean(' =v1.2.3 ') // '1.2.3'
|
||||
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
|
||||
semver.gt('1.2.3', '9.8.7') // false
|
||||
semver.lt('1.2.3', '9.8.7') // true
|
||||
semver.minVersion('>=1.0.0') // '1.0.0'
|
||||
semver.valid(semver.coerce('v2')) // '2.0.0'
|
||||
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
|
||||
```
|
||||
|
||||
As a command-line utility:
|
||||
|
||||
```
|
||||
$ semver -h
|
||||
|
||||
A JavaScript implementation of the https://semver.org/ specification
|
||||
Copyright Isaac Z. Schlueter
|
||||
|
||||
Usage: semver [options] <version> [<version> [...]]
|
||||
Prints valid versions sorted by SemVer precedence
|
||||
|
||||
Options:
|
||||
-r --range <range>
|
||||
Print versions that match the specified range.
|
||||
|
||||
-i --increment [<level>]
|
||||
Increment a version by the specified level. Level can
|
||||
be one of: major, minor, patch, premajor, preminor,
|
||||
prepatch, or prerelease. Default level is 'patch'.
|
||||
Only one version may be specified.
|
||||
|
||||
--preid <identifier>
|
||||
Identifier to be used to prefix premajor, preminor,
|
||||
prepatch or prerelease version increments.
|
||||
|
||||
-l --loose
|
||||
Interpret versions and ranges loosely
|
||||
|
||||
-p --include-prerelease
|
||||
Always include prerelease versions in range matching
|
||||
|
||||
-c --coerce
|
||||
Coerce a string into SemVer if possible
|
||||
(does not imply --loose)
|
||||
|
||||
Program exits successfully if any valid version satisfies
|
||||
all supplied ranges, and prints all satisfying versions.
|
||||
|
||||
If no satisfying versions are found, then exits failure.
|
||||
|
||||
Versions are printed in ascending order, so supplying
|
||||
multiple versions to the utility will just sort them.
|
||||
```
|
||||
|
||||
## Versions
|
||||
|
||||
A "version" is described by the `v2.0.0` specification found at
|
||||
<https://semver.org/>.
|
||||
|
||||
A leading `"="` or `"v"` character is stripped off and ignored.
|
||||
|
||||
## Ranges
|
||||
|
||||
A `version range` is a set of `comparators` which specify versions
|
||||
that satisfy the range.
|
||||
|
||||
A `comparator` is composed of an `operator` and a `version`. The set
|
||||
of primitive `operators` is:
|
||||
|
||||
* `<` Less than
|
||||
* `<=` Less than or equal to
|
||||
* `>` Greater than
|
||||
* `>=` Greater than or equal to
|
||||
* `=` Equal. If no operator is specified, then equality is assumed,
|
||||
so this operator is optional, but MAY be included.
|
||||
|
||||
For example, the comparator `>=1.2.7` would match the versions
|
||||
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
|
||||
or `1.1.0`.
|
||||
|
||||
Comparators can be joined by whitespace to form a `comparator set`,
|
||||
which is satisfied by the **intersection** of all of the comparators
|
||||
it includes.
|
||||
|
||||
A range is composed of one or more comparator sets, joined by `||`. A
|
||||
version matches a range if and only if every comparator in at least
|
||||
one of the `||`-separated comparator sets is satisfied by the version.
|
||||
|
||||
For example, the range `>=1.2.7 <1.3.0` would match the versions
|
||||
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
|
||||
or `1.1.0`.
|
||||
|
||||
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
|
||||
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
|
||||
|
||||
### Prerelease Tags
|
||||
|
||||
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
|
||||
it will only be allowed to satisfy comparator sets if at least one
|
||||
comparator with the same `[major, minor, patch]` tuple also has a
|
||||
prerelease tag.
|
||||
|
||||
For example, the range `>1.2.3-alpha.3` would be allowed to match the
|
||||
version `1.2.3-alpha.7`, but it would *not* be satisfied by
|
||||
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
|
||||
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
|
||||
range only accepts prerelease tags on the `1.2.3` version. The
|
||||
version `3.4.5` *would* satisfy the range, because it does not have a
|
||||
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
|
||||
|
||||
The purpose for this behavior is twofold. First, prerelease versions
|
||||
frequently are updated very quickly, and contain many breaking changes
|
||||
that are (by the author's design) not yet fit for public consumption.
|
||||
Therefore, by default, they are excluded from range matching
|
||||
semantics.
|
||||
|
||||
Second, a user who has opted into using a prerelease version has
|
||||
clearly indicated the intent to use *that specific* set of
|
||||
alpha/beta/rc versions. By including a prerelease tag in the range,
|
||||
the user is indicating that they are aware of the risk. However, it
|
||||
is still not appropriate to assume that they have opted into taking a
|
||||
similar risk on the *next* set of prerelease versions.
|
||||
|
||||
Note that this behavior can be suppressed (treating all prerelease
|
||||
versions as if they were normal versions, for the purpose of range
|
||||
matching) by setting the `includePrerelease` flag on the options
|
||||
object to any
|
||||
[functions](https://github.com/npm/node-semver#functions) that do
|
||||
range matching.
|
||||
|
||||
#### Prerelease Identifiers
|
||||
|
||||
The method `.inc` takes an additional `identifier` string argument that
|
||||
will append the value of the string as a prerelease identifier:
|
||||
|
||||
```javascript
|
||||
semver.inc('1.2.3', 'prerelease', 'beta')
|
||||
// '1.2.4-beta.0'
|
||||
```
|
||||
|
||||
command-line example:
|
||||
|
||||
```bash
|
||||
$ semver 1.2.3 -i prerelease --preid beta
|
||||
1.2.4-beta.0
|
||||
```
|
||||
|
||||
Which then can be used to increment further:
|
||||
|
||||
```bash
|
||||
$ semver 1.2.4-beta.0 -i prerelease
|
||||
1.2.4-beta.1
|
||||
```
|
||||
|
||||
### Advanced Range Syntax
|
||||
|
||||
Advanced range syntax desugars to primitive comparators in
|
||||
deterministic ways.
|
||||
|
||||
Advanced ranges may be combined in the same way as primitive
|
||||
comparators using white space or `||`.
|
||||
|
||||
#### Hyphen Ranges `X.Y.Z - A.B.C`
|
||||
|
||||
Specifies an inclusive set.
|
||||
|
||||
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
|
||||
|
||||
If a partial version is provided as the first version in the inclusive
|
||||
range, then the missing pieces are replaced with zeroes.
|
||||
|
||||
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
|
||||
|
||||
If a partial version is provided as the second version in the
|
||||
inclusive range, then all versions that start with the supplied parts
|
||||
of the tuple are accepted, but nothing that would be greater than the
|
||||
provided tuple parts.
|
||||
|
||||
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
|
||||
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
|
||||
|
||||
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
|
||||
|
||||
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
|
||||
numeric values in the `[major, minor, patch]` tuple.
|
||||
|
||||
* `*` := `>=0.0.0` (Any version satisfies)
|
||||
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
|
||||
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
|
||||
|
||||
A partial version range is treated as an X-Range, so the special
|
||||
character is in fact optional.
|
||||
|
||||
* `""` (empty string) := `*` := `>=0.0.0`
|
||||
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
|
||||
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
|
||||
|
||||
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
|
||||
|
||||
Allows patch-level changes if a minor version is specified on the
|
||||
comparator. Allows minor-level changes if not.
|
||||
|
||||
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
|
||||
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
|
||||
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
|
||||
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
|
||||
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
|
||||
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
|
||||
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
|
||||
the `1.2.3` version will be allowed, if they are greater than or
|
||||
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
||||
`1.2.4-beta.2` would not, because it is a prerelease of a
|
||||
different `[major, minor, patch]` tuple.
|
||||
|
||||
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
|
||||
|
||||
Allows changes that do not modify the left-most non-zero digit in the
|
||||
`[major, minor, patch]` tuple. In other words, this allows patch and
|
||||
minor updates for versions `1.0.0` and above, patch updates for
|
||||
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
|
||||
|
||||
Many authors treat a `0.x` version as if the `x` were the major
|
||||
"breaking-change" indicator.
|
||||
|
||||
Caret ranges are ideal when an author may make breaking changes
|
||||
between `0.2.4` and `0.3.0` releases, which is a common practice.
|
||||
However, it presumes that there will *not* be breaking changes between
|
||||
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
|
||||
additive (but non-breaking), according to commonly observed practices.
|
||||
|
||||
* `^1.2.3` := `>=1.2.3 <2.0.0`
|
||||
* `^0.2.3` := `>=0.2.3 <0.3.0`
|
||||
* `^0.0.3` := `>=0.0.3 <0.0.4`
|
||||
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
|
||||
the `1.2.3` version will be allowed, if they are greater than or
|
||||
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
||||
`1.2.4-beta.2` would not, because it is a prerelease of a
|
||||
different `[major, minor, patch]` tuple.
|
||||
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
|
||||
`0.0.3` version *only* will be allowed, if they are greater than or
|
||||
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
|
||||
|
||||
When parsing caret ranges, a missing `patch` value desugars to the
|
||||
number `0`, but will allow flexibility within that value, even if the
|
||||
major and minor versions are both `0`.
|
||||
|
||||
* `^1.2.x` := `>=1.2.0 <2.0.0`
|
||||
* `^0.0.x` := `>=0.0.0 <0.1.0`
|
||||
* `^0.0` := `>=0.0.0 <0.1.0`
|
||||
|
||||
A missing `minor` and `patch` values will desugar to zero, but also
|
||||
allow flexibility within those values, even if the major version is
|
||||
zero.
|
||||
|
||||
* `^1.x` := `>=1.0.0 <2.0.0`
|
||||
* `^0.x` := `>=0.0.0 <1.0.0`
|
||||
|
||||
### Range Grammar
|
||||
|
||||
Putting all this together, here is a Backus-Naur grammar for ranges,
|
||||
for the benefit of parser authors:
|
||||
|
||||
```bnf
|
||||
range-set ::= range ( logical-or range ) *
|
||||
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
|
||||
range ::= hyphen | simple ( ' ' simple ) * | ''
|
||||
hyphen ::= partial ' - ' partial
|
||||
simple ::= primitive | partial | tilde | caret
|
||||
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
|
||||
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
|
||||
xr ::= 'x' | 'X' | '*' | nr
|
||||
nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
|
||||
tilde ::= '~' partial
|
||||
caret ::= '^' partial
|
||||
qualifier ::= ( '-' pre )? ( '+' build )?
|
||||
pre ::= parts
|
||||
build ::= parts
|
||||
parts ::= part ( '.' part ) *
|
||||
part ::= nr | [-0-9A-Za-z]+
|
||||
```
|
||||
|
||||
## Functions
|
||||
|
||||
All methods and classes take a final `options` object argument. All
|
||||
options in this object are `false` by default. The options supported
|
||||
are:
|
||||
|
||||
- `loose` Be more forgiving about not-quite-valid semver strings.
|
||||
(Any resulting output will always be 100% strict compliant, of
|
||||
course.) For backwards compatibility reasons, if the `options`
|
||||
argument is a boolean value instead of an object, it is interpreted
|
||||
to be the `loose` param.
|
||||
- `includePrerelease` Set to suppress the [default
|
||||
behavior](https://github.com/npm/node-semver#prerelease-tags) of
|
||||
excluding prerelease tagged versions from ranges unless they are
|
||||
explicitly opted into.
|
||||
|
||||
Strict-mode Comparators and Ranges will be strict about the SemVer
|
||||
strings that they parse.
|
||||
|
||||
* `valid(v)`: Return the parsed version, or null if it's not valid.
|
||||
* `inc(v, release)`: Return the version incremented by the release
|
||||
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
|
||||
`prepatch`, or `prerelease`), or null if it's not valid
|
||||
* `premajor` in one call will bump the version up to the next major
|
||||
version and down to a prerelease of that major version.
|
||||
`preminor`, and `prepatch` work the same way.
|
||||
* If called from a non-prerelease version, the `prerelease` will work the
|
||||
same as `prepatch`. It increments the patch version, then makes a
|
||||
prerelease. If the input version is already a prerelease it simply
|
||||
increments it.
|
||||
* `prerelease(v)`: Returns an array of prerelease components, or null
|
||||
if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]`
|
||||
* `major(v)`: Return the major version number.
|
||||
* `minor(v)`: Return the minor version number.
|
||||
* `patch(v)`: Return the patch version number.
|
||||
* `intersects(r1, r2, loose)`: Return true if the two supplied ranges
|
||||
or comparators intersect.
|
||||
* `parse(v)`: Attempt to parse a string as a semantic version, returning either
|
||||
a `SemVer` object or `null`.
|
||||
|
||||
### Comparison
|
||||
|
||||
* `gt(v1, v2)`: `v1 > v2`
|
||||
* `gte(v1, v2)`: `v1 >= v2`
|
||||
* `lt(v1, v2)`: `v1 < v2`
|
||||
* `lte(v1, v2)`: `v1 <= v2`
|
||||
* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
|
||||
even if they're not the exact same string. You already know how to
|
||||
compare strings.
|
||||
* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
|
||||
* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
|
||||
the corresponding function above. `"==="` and `"!=="` do simple
|
||||
string comparison, but are included for completeness. Throws if an
|
||||
invalid comparison string is provided.
|
||||
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
|
||||
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
||||
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
|
||||
in descending order when passed to `Array.sort()`.
|
||||
* `diff(v1, v2)`: Returns difference between two versions by the release type
|
||||
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
|
||||
or null if the versions are the same.
|
||||
|
||||
### Comparators
|
||||
|
||||
* `intersects(comparator)`: Return true if the comparators intersect
|
||||
|
||||
### Ranges
|
||||
|
||||
* `validRange(range)`: Return the valid range or null if it's not valid
|
||||
* `satisfies(version, range)`: Return true if the version satisfies the
|
||||
range.
|
||||
* `maxSatisfying(versions, range)`: Return the highest version in the list
|
||||
that satisfies the range, or `null` if none of them do.
|
||||
* `minSatisfying(versions, range)`: Return the lowest version in the list
|
||||
that satisfies the range, or `null` if none of them do.
|
||||
* `minVersion(range)`: Return the lowest version that can possibly match
|
||||
the given range.
|
||||
* `gtr(version, range)`: Return `true` if version is greater than all the
|
||||
versions possible in the range.
|
||||
* `ltr(version, range)`: Return `true` if version is less than all the
|
||||
versions possible in the range.
|
||||
* `outside(version, range, hilo)`: Return true if the version is outside
|
||||
the bounds of the range in either the high or low direction. The
|
||||
`hilo` argument must be either the string `'>'` or `'<'`. (This is
|
||||
the function called by `gtr` and `ltr`.)
|
||||
* `intersects(range)`: Return true if any of the ranges comparators intersect
|
||||
|
||||
Note that, since ranges may be non-contiguous, a version might not be
|
||||
greater than a range, less than a range, *or* satisfy a range! For
|
||||
example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
|
||||
until `2.0.0`, so the version `1.2.10` would not be greater than the
|
||||
range (because `2.0.1` satisfies, which is higher), nor less than the
|
||||
range (since `1.2.8` satisfies, which is lower), and it also does not
|
||||
satisfy the range.
|
||||
|
||||
If you want to know if a version satisfies or does not satisfy a
|
||||
range, use the `satisfies(version, range)` function.
|
||||
|
||||
### Coercion
|
||||
|
||||
* `coerce(version)`: Coerces a string to semver if possible
|
||||
|
||||
This aims to provide a very forgiving translation of a non-semver string to
|
||||
semver. It looks for the first digit in a string, and consumes all
|
||||
remaining characters which satisfy at least a partial semver (e.g., `1`,
|
||||
`1.2`, `1.2.3`) up to the max permitted length (256 characters). Longer
|
||||
versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). All
|
||||
surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes
|
||||
`3.4.0`). Only text which lacks digits will fail coercion (`version one`
|
||||
is not valid). The maximum length for any semver component considered for
|
||||
coercion is 16 characters; longer components will be ignored
|
||||
(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any
|
||||
semver component is `Number.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
|
||||
components are invalid (`9999999999999999.4.7.4` is likely invalid).
|
||||
Generated
Vendored
+60
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"_from": "semver@^5.5.0",
|
||||
"_id": "semver@5.7.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
|
||||
"_location": "/cross-spawn/semver",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "semver@^5.5.0",
|
||||
"name": "semver",
|
||||
"escapedName": "semver",
|
||||
"rawSpec": "^5.5.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^5.5.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/cross-spawn"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
|
||||
"_shasum": "a954f931aeba508d307bbf069eff0c01c96116f7",
|
||||
"_spec": "semver@^5.5.0",
|
||||
"_where": "C:\\Users\\lzy\\Documents\\Source\\OpportunityLiu\\github-action-setup-xmake\\node_modules\\cross-spawn",
|
||||
"bin": {
|
||||
"semver": "./bin/semver"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/npm/node-semver/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "The semantic version parser used by npm.",
|
||||
"devDependencies": {
|
||||
"tap": "^13.0.0-rc.18"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"range.bnf",
|
||||
"semver.js"
|
||||
],
|
||||
"homepage": "https://github.com/npm/node-semver#readme",
|
||||
"license": "ISC",
|
||||
"main": "semver.js",
|
||||
"name": "semver",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/npm/node-semver.git"
|
||||
},
|
||||
"scripts": {
|
||||
"postpublish": "git push origin --all; git push origin --tags",
|
||||
"postversion": "npm publish",
|
||||
"preversion": "npm test",
|
||||
"test": "tap"
|
||||
},
|
||||
"tap": {
|
||||
"check-coverage": true
|
||||
},
|
||||
"version": "5.7.1"
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
range-set ::= range ( logical-or range ) *
|
||||
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
|
||||
range ::= hyphen | simple ( ' ' simple ) * | ''
|
||||
hyphen ::= partial ' - ' partial
|
||||
simple ::= primitive | partial | tilde | caret
|
||||
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
|
||||
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
|
||||
xr ::= 'x' | 'X' | '*' | nr
|
||||
nr ::= '0' | [1-9] ( [0-9] ) *
|
||||
tilde ::= '~' partial
|
||||
caret ::= '^' partial
|
||||
qualifier ::= ( '-' pre )? ( '+' build )?
|
||||
pre ::= parts
|
||||
build ::= parts
|
||||
parts ::= part ( '.' part ) *
|
||||
part ::= nr | [-0-9A-Za-z]+
|
||||
+1483
File diff suppressed because it is too large
Load Diff
+395
@@ -0,0 +1,395 @@
|
||||
|
||||
3.1.0 / 2017-09-26
|
||||
==================
|
||||
|
||||
* Add `DEBUG_HIDE_DATE` env var (#486)
|
||||
* Remove ReDoS regexp in %o formatter (#504)
|
||||
* Remove "component" from package.json
|
||||
* Remove `component.json`
|
||||
* Ignore package-lock.json
|
||||
* Examples: fix colors printout
|
||||
* Fix: browser detection
|
||||
* Fix: spelling mistake (#496, @EdwardBetts)
|
||||
|
||||
3.0.1 / 2017-08-24
|
||||
==================
|
||||
|
||||
* Fix: Disable colors in Edge and Internet Explorer (#489)
|
||||
|
||||
3.0.0 / 2017-08-08
|
||||
==================
|
||||
|
||||
* Breaking: Remove DEBUG_FD (#406)
|
||||
* Breaking: Use `Date#toISOString()` instead to `Date#toUTCString()` when output is not a TTY (#418)
|
||||
* Breaking: Make millisecond timer namespace specific and allow 'always enabled' output (#408)
|
||||
* Addition: document `enabled` flag (#465)
|
||||
* Addition: add 256 colors mode (#481)
|
||||
* Addition: `enabled()` updates existing debug instances, add `destroy()` function (#440)
|
||||
* Update: component: update "ms" to v2.0.0
|
||||
* Update: separate the Node and Browser tests in Travis-CI
|
||||
* Update: refactor Readme, fixed documentation, added "Namespace Colors" section, redid screenshots
|
||||
* Update: separate Node.js and web browser examples for organization
|
||||
* Update: update "browserify" to v14.4.0
|
||||
* Fix: fix Readme typo (#473)
|
||||
|
||||
2.6.9 / 2017-09-22
|
||||
==================
|
||||
|
||||
* remove ReDoS regexp in %o formatter (#504)
|
||||
|
||||
2.6.8 / 2017-05-18
|
||||
==================
|
||||
|
||||
* Fix: Check for undefined on browser globals (#462, @marbemac)
|
||||
|
||||
2.6.7 / 2017-05-16
|
||||
==================
|
||||
|
||||
* Fix: Update ms to 2.0.0 to fix regular expression denial of service vulnerability (#458, @hubdotcom)
|
||||
* Fix: Inline extend function in node implementation (#452, @dougwilson)
|
||||
* Docs: Fix typo (#455, @msasad)
|
||||
|
||||
2.6.5 / 2017-04-27
|
||||
==================
|
||||
|
||||
* Fix: null reference check on window.documentElement.style.WebkitAppearance (#447, @thebigredgeek)
|
||||
* Misc: clean up browser reference checks (#447, @thebigredgeek)
|
||||
* Misc: add npm-debug.log to .gitignore (@thebigredgeek)
|
||||
|
||||
|
||||
2.6.4 / 2017-04-20
|
||||
==================
|
||||
|
||||
* Fix: bug that would occur if process.env.DEBUG is a non-string value. (#444, @LucianBuzzo)
|
||||
* Chore: ignore bower.json in npm installations. (#437, @joaovieira)
|
||||
* Misc: update "ms" to v0.7.3 (@tootallnate)
|
||||
|
||||
2.6.3 / 2017-03-13
|
||||
==================
|
||||
|
||||
* Fix: Electron reference to `process.env.DEBUG` (#431, @paulcbetts)
|
||||
* Docs: Changelog fix (@thebigredgeek)
|
||||
|
||||
2.6.2 / 2017-03-10
|
||||
==================
|
||||
|
||||
* Fix: DEBUG_MAX_ARRAY_LENGTH (#420, @slavaGanzin)
|
||||
* Docs: Add backers and sponsors from Open Collective (#422, @piamancini)
|
||||
* Docs: Add Slackin invite badge (@tootallnate)
|
||||
|
||||
2.6.1 / 2017-02-10
|
||||
==================
|
||||
|
||||
* Fix: Module's `export default` syntax fix for IE8 `Expected identifier` error
|
||||
* Fix: Whitelist DEBUG_FD for values 1 and 2 only (#415, @pi0)
|
||||
* Fix: IE8 "Expected identifier" error (#414, @vgoma)
|
||||
* Fix: Namespaces would not disable once enabled (#409, @musikov)
|
||||
|
||||
2.6.0 / 2016-12-28
|
||||
==================
|
||||
|
||||
* Fix: added better null pointer checks for browser useColors (@thebigredgeek)
|
||||
* Improvement: removed explicit `window.debug` export (#404, @tootallnate)
|
||||
* Improvement: deprecated `DEBUG_FD` environment variable (#405, @tootallnate)
|
||||
|
||||
2.5.2 / 2016-12-25
|
||||
==================
|
||||
|
||||
* Fix: reference error on window within webworkers (#393, @KlausTrainer)
|
||||
* Docs: fixed README typo (#391, @lurch)
|
||||
* Docs: added notice about v3 api discussion (@thebigredgeek)
|
||||
|
||||
2.5.1 / 2016-12-20
|
||||
==================
|
||||
|
||||
* Fix: babel-core compatibility
|
||||
|
||||
2.5.0 / 2016-12-20
|
||||
==================
|
||||
|
||||
* Fix: wrong reference in bower file (@thebigredgeek)
|
||||
* Fix: webworker compatibility (@thebigredgeek)
|
||||
* Fix: output formatting issue (#388, @kribblo)
|
||||
* Fix: babel-loader compatibility (#383, @escwald)
|
||||
* Misc: removed built asset from repo and publications (@thebigredgeek)
|
||||
* Misc: moved source files to /src (#378, @yamikuronue)
|
||||
* Test: added karma integration and replaced babel with browserify for browser tests (#378, @yamikuronue)
|
||||
* Test: coveralls integration (#378, @yamikuronue)
|
||||
* Docs: simplified language in the opening paragraph (#373, @yamikuronue)
|
||||
|
||||
2.4.5 / 2016-12-17
|
||||
==================
|
||||
|
||||
* Fix: `navigator` undefined in Rhino (#376, @jochenberger)
|
||||
* Fix: custom log function (#379, @hsiliev)
|
||||
* Improvement: bit of cleanup + linting fixes (@thebigredgeek)
|
||||
* Improvement: rm non-maintainted `dist/` dir (#375, @freewil)
|
||||
* Docs: simplified language in the opening paragraph. (#373, @yamikuronue)
|
||||
|
||||
2.4.4 / 2016-12-14
|
||||
==================
|
||||
|
||||
* Fix: work around debug being loaded in preload scripts for electron (#368, @paulcbetts)
|
||||
|
||||
2.4.3 / 2016-12-14
|
||||
==================
|
||||
|
||||
* Fix: navigation.userAgent error for react native (#364, @escwald)
|
||||
|
||||
2.4.2 / 2016-12-14
|
||||
==================
|
||||
|
||||
* Fix: browser colors (#367, @tootallnate)
|
||||
* Misc: travis ci integration (@thebigredgeek)
|
||||
* Misc: added linting and testing boilerplate with sanity check (@thebigredgeek)
|
||||
|
||||
2.4.1 / 2016-12-13
|
||||
==================
|
||||
|
||||
* Fix: typo that broke the package (#356)
|
||||
|
||||
2.4.0 / 2016-12-13
|
||||
==================
|
||||
|
||||
* Fix: bower.json references unbuilt src entry point (#342, @justmatt)
|
||||
* Fix: revert "handle regex special characters" (@tootallnate)
|
||||
* Feature: configurable util.inspect()`options for NodeJS (#327, @tootallnate)
|
||||
* Feature: %O`(big O) pretty-prints objects (#322, @tootallnate)
|
||||
* Improvement: allow colors in workers (#335, @botverse)
|
||||
* Improvement: use same color for same namespace. (#338, @lchenay)
|
||||
|
||||
2.3.3 / 2016-11-09
|
||||
==================
|
||||
|
||||
* Fix: Catch `JSON.stringify()` errors (#195, Jovan Alleyne)
|
||||
* Fix: Returning `localStorage` saved values (#331, Levi Thomason)
|
||||
* Improvement: Don't create an empty object when no `process` (Nathan Rajlich)
|
||||
|
||||
2.3.2 / 2016-11-09
|
||||
==================
|
||||
|
||||
* Fix: be super-safe in index.js as well (@TooTallNate)
|
||||
* Fix: should check whether process exists (Tom Newby)
|
||||
|
||||
2.3.1 / 2016-11-09
|
||||
==================
|
||||
|
||||
* Fix: Added electron compatibility (#324, @paulcbetts)
|
||||
* Improvement: Added performance optimizations (@tootallnate)
|
||||
* Readme: Corrected PowerShell environment variable example (#252, @gimre)
|
||||
* Misc: Removed yarn lock file from source control (#321, @fengmk2)
|
||||
|
||||
2.3.0 / 2016-11-07
|
||||
==================
|
||||
|
||||
* Fix: Consistent placement of ms diff at end of output (#215, @gorangajic)
|
||||
* Fix: Escaping of regex special characters in namespace strings (#250, @zacronos)
|
||||
* Fix: Fixed bug causing crash on react-native (#282, @vkarpov15)
|
||||
* Feature: Enabled ES6+ compatible import via default export (#212 @bucaran)
|
||||
* Feature: Added %O formatter to reflect Chrome's console.log capability (#279, @oncletom)
|
||||
* Package: Update "ms" to 0.7.2 (#315, @DevSide)
|
||||
* Package: removed superfluous version property from bower.json (#207 @kkirsche)
|
||||
* Readme: fix USE_COLORS to DEBUG_COLORS
|
||||
* Readme: Doc fixes for format string sugar (#269, @mlucool)
|
||||
* Readme: Updated docs for DEBUG_FD and DEBUG_COLORS environment variables (#232, @mattlyons0)
|
||||
* Readme: doc fixes for PowerShell (#271 #243, @exoticknight @unreadable)
|
||||
* Readme: better docs for browser support (#224, @matthewmueller)
|
||||
* Tooling: Added yarn integration for development (#317, @thebigredgeek)
|
||||
* Misc: Renamed History.md to CHANGELOG.md (@thebigredgeek)
|
||||
* Misc: Added license file (#226 #274, @CantemoInternal @sdaitzman)
|
||||
* Misc: Updated contributors (@thebigredgeek)
|
||||
|
||||
2.2.0 / 2015-05-09
|
||||
==================
|
||||
|
||||
* package: update "ms" to v0.7.1 (#202, @dougwilson)
|
||||
* README: add logging to file example (#193, @DanielOchoa)
|
||||
* README: fixed a typo (#191, @amir-s)
|
||||
* browser: expose `storage` (#190, @stephenmathieson)
|
||||
* Makefile: add a `distclean` target (#189, @stephenmathieson)
|
||||
|
||||
2.1.3 / 2015-03-13
|
||||
==================
|
||||
|
||||
* Updated stdout/stderr example (#186)
|
||||
* Updated example/stdout.js to match debug current behaviour
|
||||
* Renamed example/stderr.js to stdout.js
|
||||
* Update Readme.md (#184)
|
||||
* replace high intensity foreground color for bold (#182, #183)
|
||||
|
||||
2.1.2 / 2015-03-01
|
||||
==================
|
||||
|
||||
* dist: recompile
|
||||
* update "ms" to v0.7.0
|
||||
* package: update "browserify" to v9.0.3
|
||||
* component: fix "ms.js" repo location
|
||||
* changed bower package name
|
||||
* updated documentation about using debug in a browser
|
||||
* fix: security error on safari (#167, #168, @yields)
|
||||
|
||||
2.1.1 / 2014-12-29
|
||||
==================
|
||||
|
||||
* browser: use `typeof` to check for `console` existence
|
||||
* browser: check for `console.log` truthiness (fix IE 8/9)
|
||||
* browser: add support for Chrome apps
|
||||
* Readme: added Windows usage remarks
|
||||
* Add `bower.json` to properly support bower install
|
||||
|
||||
2.1.0 / 2014-10-15
|
||||
==================
|
||||
|
||||
* node: implement `DEBUG_FD` env variable support
|
||||
* package: update "browserify" to v6.1.0
|
||||
* package: add "license" field to package.json (#135, @panuhorsmalahti)
|
||||
|
||||
2.0.0 / 2014-09-01
|
||||
==================
|
||||
|
||||
* package: update "browserify" to v5.11.0
|
||||
* node: use stderr rather than stdout for logging (#29, @stephenmathieson)
|
||||
|
||||
1.0.4 / 2014-07-15
|
||||
==================
|
||||
|
||||
* dist: recompile
|
||||
* example: remove `console.info()` log usage
|
||||
* example: add "Content-Type" UTF-8 header to browser example
|
||||
* browser: place %c marker after the space character
|
||||
* browser: reset the "content" color via `color: inherit`
|
||||
* browser: add colors support for Firefox >= v31
|
||||
* debug: prefer an instance `log()` function over the global one (#119)
|
||||
* Readme: update documentation about styled console logs for FF v31 (#116, @wryk)
|
||||
|
||||
1.0.3 / 2014-07-09
|
||||
==================
|
||||
|
||||
* Add support for multiple wildcards in namespaces (#122, @seegno)
|
||||
* browser: fix lint
|
||||
|
||||
1.0.2 / 2014-06-10
|
||||
==================
|
||||
|
||||
* browser: update color palette (#113, @gscottolson)
|
||||
* common: make console logging function configurable (#108, @timoxley)
|
||||
* node: fix %o colors on old node <= 0.8.x
|
||||
* Makefile: find node path using shell/which (#109, @timoxley)
|
||||
|
||||
1.0.1 / 2014-06-06
|
||||
==================
|
||||
|
||||
* browser: use `removeItem()` to clear localStorage
|
||||
* browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777)
|
||||
* package: add "contributors" section
|
||||
* node: fix comment typo
|
||||
* README: list authors
|
||||
|
||||
1.0.0 / 2014-06-04
|
||||
==================
|
||||
|
||||
* make ms diff be global, not be scope
|
||||
* debug: ignore empty strings in enable()
|
||||
* node: make DEBUG_COLORS able to disable coloring
|
||||
* *: export the `colors` array
|
||||
* npmignore: don't publish the `dist` dir
|
||||
* Makefile: refactor to use browserify
|
||||
* package: add "browserify" as a dev dependency
|
||||
* Readme: add Web Inspector Colors section
|
||||
* node: reset terminal color for the debug content
|
||||
* node: map "%o" to `util.inspect()`
|
||||
* browser: map "%j" to `JSON.stringify()`
|
||||
* debug: add custom "formatters"
|
||||
* debug: use "ms" module for humanizing the diff
|
||||
* Readme: add "bash" syntax highlighting
|
||||
* browser: add Firebug color support
|
||||
* browser: add colors for WebKit browsers
|
||||
* node: apply log to `console`
|
||||
* rewrite: abstract common logic for Node & browsers
|
||||
* add .jshintrc file
|
||||
|
||||
0.8.1 / 2014-04-14
|
||||
==================
|
||||
|
||||
* package: re-add the "component" section
|
||||
|
||||
0.8.0 / 2014-03-30
|
||||
==================
|
||||
|
||||
* add `enable()` method for nodejs. Closes #27
|
||||
* change from stderr to stdout
|
||||
* remove unnecessary index.js file
|
||||
|
||||
0.7.4 / 2013-11-13
|
||||
==================
|
||||
|
||||
* remove "browserify" key from package.json (fixes something in browserify)
|
||||
|
||||
0.7.3 / 2013-10-30
|
||||
==================
|
||||
|
||||
* fix: catch localStorage security error when cookies are blocked (Chrome)
|
||||
* add debug(err) support. Closes #46
|
||||
* add .browser prop to package.json. Closes #42
|
||||
|
||||
0.7.2 / 2013-02-06
|
||||
==================
|
||||
|
||||
* fix package.json
|
||||
* fix: Mobile Safari (private mode) is broken with debug
|
||||
* fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript
|
||||
|
||||
0.7.1 / 2013-02-05
|
||||
==================
|
||||
|
||||
* add repository URL to package.json
|
||||
* add DEBUG_COLORED to force colored output
|
||||
* add browserify support
|
||||
* fix component. Closes #24
|
||||
|
||||
0.7.0 / 2012-05-04
|
||||
==================
|
||||
|
||||
* Added .component to package.json
|
||||
* Added debug.component.js build
|
||||
|
||||
0.6.0 / 2012-03-16
|
||||
==================
|
||||
|
||||
* Added support for "-" prefix in DEBUG [Vinay Pulim]
|
||||
* Added `.enabled` flag to the node version [TooTallNate]
|
||||
|
||||
0.5.0 / 2012-02-02
|
||||
==================
|
||||
|
||||
* Added: humanize diffs. Closes #8
|
||||
* Added `debug.disable()` to the CS variant
|
||||
* Removed padding. Closes #10
|
||||
* Fixed: persist client-side variant again. Closes #9
|
||||
|
||||
0.4.0 / 2012-02-01
|
||||
==================
|
||||
|
||||
* Added browser variant support for older browsers [TooTallNate]
|
||||
* Added `debug.enable('project:*')` to browser variant [TooTallNate]
|
||||
* Added padding to diff (moved it to the right)
|
||||
|
||||
0.3.0 / 2012-01-26
|
||||
==================
|
||||
|
||||
* Added millisecond diff when isatty, otherwise UTC string
|
||||
|
||||
0.2.0 / 2012-01-22
|
||||
==================
|
||||
|
||||
* Added wildcard support
|
||||
|
||||
0.1.0 / 2011-12-02
|
||||
==================
|
||||
|
||||
* Added: remove colors unless stderr isatty [TooTallNate]
|
||||
|
||||
0.0.1 / 2010-01-03
|
||||
==================
|
||||
|
||||
* Initial release
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
||||
|
||||
+455
@@ -0,0 +1,455 @@
|
||||
# debug
|
||||
[](https://travis-ci.org/visionmedia/debug) [](https://coveralls.io/github/visionmedia/debug?branch=master) [](https://visionmedia-community-slackin.now.sh/) [](#backers)
|
||||
[](#sponsors)
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
||||
|
||||
A tiny JavaScript debugging utility modelled after Node.js core's debugging
|
||||
technique. Works in Node.js and web browsers.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install debug
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole.
|
||||
|
||||
Example [_app.js_](./examples/node/app.js):
|
||||
|
||||
```js
|
||||
var debug = require('debug')('http')
|
||||
, http = require('http')
|
||||
, name = 'My App';
|
||||
|
||||
// fake app
|
||||
|
||||
debug('booting %o', name);
|
||||
|
||||
http.createServer(function(req, res){
|
||||
debug(req.method + ' ' + req.url);
|
||||
res.end('hello\n');
|
||||
}).listen(3000, function(){
|
||||
debug('listening');
|
||||
});
|
||||
|
||||
// fake worker of some kind
|
||||
|
||||
require('./worker');
|
||||
```
|
||||
|
||||
Example [_worker.js_](./examples/node/worker.js):
|
||||
|
||||
```js
|
||||
var a = require('debug')('worker:a')
|
||||
, b = require('debug')('worker:b');
|
||||
|
||||
function work() {
|
||||
a('doing lots of uninteresting work');
|
||||
setTimeout(work, Math.random() * 1000);
|
||||
}
|
||||
|
||||
work();
|
||||
|
||||
function workb() {
|
||||
b('doing some work');
|
||||
setTimeout(workb, Math.random() * 2000);
|
||||
}
|
||||
|
||||
workb();
|
||||
```
|
||||
|
||||
The `DEBUG` environment variable is then used to enable these based on space or
|
||||
comma-delimited names.
|
||||
|
||||
Here are some examples:
|
||||
|
||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 04 pm" src="https://user-images.githubusercontent.com/71256/29091703-a6302cdc-7c38-11e7-8304-7c0b3bc600cd.png">
|
||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 38 pm" src="https://user-images.githubusercontent.com/71256/29091700-a62a6888-7c38-11e7-800b-db911291ca2b.png">
|
||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 25 pm" src="https://user-images.githubusercontent.com/71256/29091701-a62ea114-7c38-11e7-826a-2692bedca740.png">
|
||||
|
||||
#### Windows command prompt notes
|
||||
|
||||
##### CMD
|
||||
|
||||
On Windows the environment variable is set using the `set` command.
|
||||
|
||||
```cmd
|
||||
set DEBUG=*,-not_this
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```cmd
|
||||
set DEBUG=* & node app.js
|
||||
```
|
||||
|
||||
##### PowerShell (VS Code default)
|
||||
|
||||
PowerShell uses different syntax to set environment variables.
|
||||
|
||||
```cmd
|
||||
$env:DEBUG = "*,-not_this"
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```cmd
|
||||
$env:DEBUG='app';node app.js
|
||||
```
|
||||
|
||||
Then, run the program to be debugged as usual.
|
||||
|
||||
npm script example:
|
||||
```js
|
||||
"windowsDebug": "@powershell -Command $env:DEBUG='*';node app.js",
|
||||
```
|
||||
|
||||
## Namespace Colors
|
||||
|
||||
Every debug instance has a color generated for it based on its namespace name.
|
||||
This helps when visually parsing the debug output to identify which debug instance
|
||||
a debug line belongs to.
|
||||
|
||||
#### Node.js
|
||||
|
||||
In Node.js, colors are enabled when stderr is a TTY. You also _should_ install
|
||||
the [`supports-color`](https://npmjs.org/supports-color) module alongside debug,
|
||||
otherwise debug will only use a small handful of basic colors.
|
||||
|
||||
<img width="521" src="https://user-images.githubusercontent.com/71256/29092181-47f6a9e6-7c3a-11e7-9a14-1928d8a711cd.png">
|
||||
|
||||
#### Web Browser
|
||||
|
||||
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
|
||||
option. These are WebKit web inspectors, Firefox ([since version
|
||||
31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
|
||||
and the Firebug plugin for Firefox (any version).
|
||||
|
||||
<img width="524" src="https://user-images.githubusercontent.com/71256/29092033-b65f9f2e-7c39-11e7-8e32-f6f0d8e865c1.png">
|
||||
|
||||
|
||||
## Millisecond diff
|
||||
|
||||
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
||||
|
||||
When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below:
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091956-6bd78372-7c39-11e7-8c55-c948396d6edd.png">
|
||||
|
||||
|
||||
## Conventions
|
||||
|
||||
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output.
|
||||
|
||||
## Wildcards
|
||||
|
||||
The `*` character may be used as a wildcard. Suppose for example your library has
|
||||
debuggers named "connect:bodyParser", "connect:compress", "connect:session",
|
||||
instead of listing all three with
|
||||
`DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do
|
||||
`DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
|
||||
|
||||
You can also exclude specific debuggers by prefixing them with a "-" character.
|
||||
For example, `DEBUG=*,-connect:*` would include all debuggers except those
|
||||
starting with "connect:".
|
||||
|
||||
## Environment Variables
|
||||
|
||||
When running through Node.js, you can set a few environment variables that will
|
||||
change the behavior of the debug logging:
|
||||
|
||||
| Name | Purpose |
|
||||
|-----------|-------------------------------------------------|
|
||||
| `DEBUG` | Enables/disables specific debugging namespaces. |
|
||||
| `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). |
|
||||
| `DEBUG_COLORS`| Whether or not to use colors in the debug output. |
|
||||
| `DEBUG_DEPTH` | Object inspection depth. |
|
||||
| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. |
|
||||
|
||||
|
||||
__Note:__ The environment variables beginning with `DEBUG_` end up being
|
||||
converted into an Options object that gets used with `%o`/`%O` formatters.
|
||||
See the Node.js documentation for
|
||||
[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options)
|
||||
for the complete list.
|
||||
|
||||
## Formatters
|
||||
|
||||
Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting.
|
||||
Below are the officially supported formatters:
|
||||
|
||||
| Formatter | Representation |
|
||||
|-----------|----------------|
|
||||
| `%O` | Pretty-print an Object on multiple lines. |
|
||||
| `%o` | Pretty-print an Object all on a single line. |
|
||||
| `%s` | String. |
|
||||
| `%d` | Number (both integer and float). |
|
||||
| `%j` | JSON. Replaced with the string '[Circular]' if the argument contains circular references. |
|
||||
| `%%` | Single percent sign ('%'). This does not consume an argument. |
|
||||
|
||||
|
||||
### Custom formatters
|
||||
|
||||
You can add custom formatters by extending the `debug.formatters` object.
|
||||
For example, if you wanted to add support for rendering a Buffer as hex with
|
||||
`%h`, you could do something like:
|
||||
|
||||
```js
|
||||
const createDebug = require('debug')
|
||||
createDebug.formatters.h = (v) => {
|
||||
return v.toString('hex')
|
||||
}
|
||||
|
||||
// …elsewhere
|
||||
const debug = createDebug('foo')
|
||||
debug('this is hex: %h', new Buffer('hello world'))
|
||||
// foo this is hex: 68656c6c6f20776f726c6421 +0ms
|
||||
```
|
||||
|
||||
|
||||
## Browser Support
|
||||
|
||||
You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify),
|
||||
or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest),
|
||||
if you don't want to build it yourself.
|
||||
|
||||
Debug's enable state is currently persisted by `localStorage`.
|
||||
Consider the situation shown below where you have `worker:a` and `worker:b`,
|
||||
and wish to debug both. You can enable this using `localStorage.debug`:
|
||||
|
||||
```js
|
||||
localStorage.debug = 'worker:*'
|
||||
```
|
||||
|
||||
And then refresh the page.
|
||||
|
||||
```js
|
||||
a = debug('worker:a');
|
||||
b = debug('worker:b');
|
||||
|
||||
setInterval(function(){
|
||||
a('doing some work');
|
||||
}, 1000);
|
||||
|
||||
setInterval(function(){
|
||||
b('doing some work');
|
||||
}, 1200);
|
||||
```
|
||||
|
||||
|
||||
## Output streams
|
||||
|
||||
By default `debug` will log to stderr, however this can be configured per-namespace by overriding the `log` method:
|
||||
|
||||
Example [_stdout.js_](./examples/node/stdout.js):
|
||||
|
||||
```js
|
||||
var debug = require('debug');
|
||||
var error = debug('app:error');
|
||||
|
||||
// by default stderr is used
|
||||
error('goes to stderr!');
|
||||
|
||||
var log = debug('app:log');
|
||||
// set this namespace to log via console.log
|
||||
log.log = console.log.bind(console); // don't forget to bind to console!
|
||||
log('goes to stdout');
|
||||
error('still goes to stderr!');
|
||||
|
||||
// set all output to go via console.info
|
||||
// overrides all per-namespace log settings
|
||||
debug.log = console.info.bind(console);
|
||||
error('now goes to stdout via console.info');
|
||||
log('still goes to stdout, but via console.info now');
|
||||
```
|
||||
|
||||
## Extend
|
||||
You can simply extend debugger
|
||||
```js
|
||||
const log = require('debug')('auth');
|
||||
|
||||
//creates new debug instance with extended namespace
|
||||
const logSign = log.extend('sign');
|
||||
const logLogin = log.extend('login');
|
||||
|
||||
log('hello'); // auth hello
|
||||
logSign('hello'); //auth:sign hello
|
||||
logLogin('hello'); //auth:login hello
|
||||
```
|
||||
|
||||
## Set dynamically
|
||||
|
||||
You can also enable debug dynamically by calling the `enable()` method :
|
||||
|
||||
```js
|
||||
let debug = require('debug');
|
||||
|
||||
console.log(1, debug.enabled('test'));
|
||||
|
||||
debug.enable('test');
|
||||
console.log(2, debug.enabled('test'));
|
||||
|
||||
debug.disable();
|
||||
console.log(3, debug.enabled('test'));
|
||||
|
||||
```
|
||||
|
||||
print :
|
||||
```
|
||||
1 false
|
||||
2 true
|
||||
3 false
|
||||
```
|
||||
|
||||
Usage :
|
||||
`enable(namespaces)`
|
||||
`namespaces` can include modes separated by a colon and wildcards.
|
||||
|
||||
Note that calling `enable()` completely overrides previously set DEBUG variable :
|
||||
|
||||
```
|
||||
$ DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log(dbg.enabled("foo"))'
|
||||
=> false
|
||||
```
|
||||
|
||||
`disable()`
|
||||
|
||||
Will disable all namespaces. The functions returns the namespaces currently
|
||||
enabled (and skipped). This can be useful if you want to disable debugging
|
||||
temporarily without knowing what was enabled to begin with.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
let debug = require('debug');
|
||||
debug.enable('foo:*,-foo:bar');
|
||||
let namespaces = debug.disable();
|
||||
debug.enable(namespaces);
|
||||
```
|
||||
|
||||
Note: There is no guarantee that the string will be identical to the initial
|
||||
enable string, but semantically they will be identical.
|
||||
|
||||
## Checking whether a debug target is enabled
|
||||
|
||||
After you've created a debug instance, you can determine whether or not it is
|
||||
enabled by checking the `enabled` property:
|
||||
|
||||
```javascript
|
||||
const debug = require('debug')('http');
|
||||
|
||||
if (debug.enabled) {
|
||||
// do stuff...
|
||||
}
|
||||
```
|
||||
|
||||
You can also manually toggle this property to force the debug instance to be
|
||||
enabled or disabled.
|
||||
|
||||
|
||||
## Authors
|
||||
|
||||
- TJ Holowaychuk
|
||||
- Nathan Rajlich
|
||||
- Andrew Rhyne
|
||||
|
||||
## Backers
|
||||
|
||||
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)]
|
||||
|
||||
<a href="https://opencollective.com/debug/backer/0/website" target="_blank"><img src="https://opencollective.com/debug/backer/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/1/website" target="_blank"><img src="https://opencollective.com/debug/backer/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/2/website" target="_blank"><img src="https://opencollective.com/debug/backer/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/3/website" target="_blank"><img src="https://opencollective.com/debug/backer/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/4/website" target="_blank"><img src="https://opencollective.com/debug/backer/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/5/website" target="_blank"><img src="https://opencollective.com/debug/backer/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/6/website" target="_blank"><img src="https://opencollective.com/debug/backer/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/7/website" target="_blank"><img src="https://opencollective.com/debug/backer/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/8/website" target="_blank"><img src="https://opencollective.com/debug/backer/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/9/website" target="_blank"><img src="https://opencollective.com/debug/backer/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/10/website" target="_blank"><img src="https://opencollective.com/debug/backer/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/11/website" target="_blank"><img src="https://opencollective.com/debug/backer/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/12/website" target="_blank"><img src="https://opencollective.com/debug/backer/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/13/website" target="_blank"><img src="https://opencollective.com/debug/backer/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/14/website" target="_blank"><img src="https://opencollective.com/debug/backer/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/15/website" target="_blank"><img src="https://opencollective.com/debug/backer/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/16/website" target="_blank"><img src="https://opencollective.com/debug/backer/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/17/website" target="_blank"><img src="https://opencollective.com/debug/backer/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/18/website" target="_blank"><img src="https://opencollective.com/debug/backer/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/19/website" target="_blank"><img src="https://opencollective.com/debug/backer/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/20/website" target="_blank"><img src="https://opencollective.com/debug/backer/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/21/website" target="_blank"><img src="https://opencollective.com/debug/backer/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/22/website" target="_blank"><img src="https://opencollective.com/debug/backer/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/23/website" target="_blank"><img src="https://opencollective.com/debug/backer/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/24/website" target="_blank"><img src="https://opencollective.com/debug/backer/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/25/website" target="_blank"><img src="https://opencollective.com/debug/backer/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/26/website" target="_blank"><img src="https://opencollective.com/debug/backer/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/27/website" target="_blank"><img src="https://opencollective.com/debug/backer/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/28/website" target="_blank"><img src="https://opencollective.com/debug/backer/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/29/website" target="_blank"><img src="https://opencollective.com/debug/backer/29/avatar.svg"></a>
|
||||
|
||||
|
||||
## Sponsors
|
||||
|
||||
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/debug#sponsor)]
|
||||
|
||||
<a href="https://opencollective.com/debug/sponsor/0/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/1/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/2/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/3/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/4/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/5/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/6/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/7/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/8/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/9/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/10/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/11/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/12/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/13/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/14/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/15/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/16/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/17/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/18/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/19/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/20/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/21/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/22/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/23/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/24/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/25/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/26/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/27/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/28/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/29/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/29/avatar.svg"></a>
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
||||
+912
@@ -0,0 +1,912 @@
|
||||
"use strict";
|
||||
|
||||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
||||
|
||||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
||||
|
||||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
|
||||
|
||||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
|
||||
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
(function (f) {
|
||||
if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object" && typeof module !== "undefined") {
|
||||
module.exports = f();
|
||||
} else if (typeof define === "function" && define.amd) {
|
||||
define([], f);
|
||||
} else {
|
||||
var g;
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
g = window;
|
||||
} else if (typeof global !== "undefined") {
|
||||
g = global;
|
||||
} else if (typeof self !== "undefined") {
|
||||
g = self;
|
||||
} else {
|
||||
g = this;
|
||||
}
|
||||
|
||||
g.debug = f();
|
||||
}
|
||||
})(function () {
|
||||
var define, module, exports;
|
||||
return function () {
|
||||
function r(e, n, t) {
|
||||
function o(i, f) {
|
||||
if (!n[i]) {
|
||||
if (!e[i]) {
|
||||
var c = "function" == typeof require && require;
|
||||
if (!f && c) return c(i, !0);
|
||||
if (u) return u(i, !0);
|
||||
var a = new Error("Cannot find module '" + i + "'");
|
||||
throw a.code = "MODULE_NOT_FOUND", a;
|
||||
}
|
||||
|
||||
var p = n[i] = {
|
||||
exports: {}
|
||||
};
|
||||
e[i][0].call(p.exports, function (r) {
|
||||
var n = e[i][1][r];
|
||||
return o(n || r);
|
||||
}, p, p.exports, r, e, n, t);
|
||||
}
|
||||
|
||||
return n[i].exports;
|
||||
}
|
||||
|
||||
for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) {
|
||||
o(t[i]);
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
return r;
|
||||
}()({
|
||||
1: [function (require, module, exports) {
|
||||
/**
|
||||
* Helpers.
|
||||
*/
|
||||
var s = 1000;
|
||||
var m = s * 60;
|
||||
var h = m * 60;
|
||||
var d = h * 24;
|
||||
var w = d * 7;
|
||||
var y = d * 365.25;
|
||||
/**
|
||||
* Parse or format the given `val`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `long` verbose formatting [false]
|
||||
*
|
||||
* @param {String|Number} val
|
||||
* @param {Object} [options]
|
||||
* @throws {Error} throw an error if val is not a non-empty string or a number
|
||||
* @return {String|Number}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function (val, options) {
|
||||
options = options || {};
|
||||
|
||||
var type = _typeof(val);
|
||||
|
||||
if (type === 'string' && val.length > 0) {
|
||||
return parse(val);
|
||||
} else if (type === 'number' && isNaN(val) === false) {
|
||||
return options.long ? fmtLong(val) : fmtShort(val);
|
||||
}
|
||||
|
||||
throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
|
||||
};
|
||||
/**
|
||||
* Parse the given `str` and return milliseconds.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
|
||||
function parse(str) {
|
||||
str = String(str);
|
||||
|
||||
if (str.length > 100) {
|
||||
return;
|
||||
}
|
||||
|
||||
var match = /^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
||||
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
|
||||
var n = parseFloat(match[1]);
|
||||
var type = (match[2] || 'ms').toLowerCase();
|
||||
|
||||
switch (type) {
|
||||
case 'years':
|
||||
case 'year':
|
||||
case 'yrs':
|
||||
case 'yr':
|
||||
case 'y':
|
||||
return n * y;
|
||||
|
||||
case 'weeks':
|
||||
case 'week':
|
||||
case 'w':
|
||||
return n * w;
|
||||
|
||||
case 'days':
|
||||
case 'day':
|
||||
case 'd':
|
||||
return n * d;
|
||||
|
||||
case 'hours':
|
||||
case 'hour':
|
||||
case 'hrs':
|
||||
case 'hr':
|
||||
case 'h':
|
||||
return n * h;
|
||||
|
||||
case 'minutes':
|
||||
case 'minute':
|
||||
case 'mins':
|
||||
case 'min':
|
||||
case 'm':
|
||||
return n * m;
|
||||
|
||||
case 'seconds':
|
||||
case 'second':
|
||||
case 'secs':
|
||||
case 'sec':
|
||||
case 's':
|
||||
return n * s;
|
||||
|
||||
case 'milliseconds':
|
||||
case 'millisecond':
|
||||
case 'msecs':
|
||||
case 'msec':
|
||||
case 'ms':
|
||||
return n;
|
||||
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Short format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
|
||||
function fmtShort(ms) {
|
||||
var msAbs = Math.abs(ms);
|
||||
|
||||
if (msAbs >= d) {
|
||||
return Math.round(ms / d) + 'd';
|
||||
}
|
||||
|
||||
if (msAbs >= h) {
|
||||
return Math.round(ms / h) + 'h';
|
||||
}
|
||||
|
||||
if (msAbs >= m) {
|
||||
return Math.round(ms / m) + 'm';
|
||||
}
|
||||
|
||||
if (msAbs >= s) {
|
||||
return Math.round(ms / s) + 's';
|
||||
}
|
||||
|
||||
return ms + 'ms';
|
||||
}
|
||||
/**
|
||||
* Long format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
|
||||
function fmtLong(ms) {
|
||||
var msAbs = Math.abs(ms);
|
||||
|
||||
if (msAbs >= d) {
|
||||
return plural(ms, msAbs, d, 'day');
|
||||
}
|
||||
|
||||
if (msAbs >= h) {
|
||||
return plural(ms, msAbs, h, 'hour');
|
||||
}
|
||||
|
||||
if (msAbs >= m) {
|
||||
return plural(ms, msAbs, m, 'minute');
|
||||
}
|
||||
|
||||
if (msAbs >= s) {
|
||||
return plural(ms, msAbs, s, 'second');
|
||||
}
|
||||
|
||||
return ms + ' ms';
|
||||
}
|
||||
/**
|
||||
* Pluralization helper.
|
||||
*/
|
||||
|
||||
|
||||
function plural(ms, msAbs, n, name) {
|
||||
var isPlural = msAbs >= n * 1.5;
|
||||
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
||||
}
|
||||
}, {}],
|
||||
2: [function (require, module, exports) {
|
||||
// shim for using process in browser
|
||||
var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it
|
||||
// don't break things. But we need to wrap it in a try catch in case it is
|
||||
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
||||
// function because try/catches deoptimize in certain engines.
|
||||
|
||||
var cachedSetTimeout;
|
||||
var cachedClearTimeout;
|
||||
|
||||
function defaultSetTimout() {
|
||||
throw new Error('setTimeout has not been defined');
|
||||
}
|
||||
|
||||
function defaultClearTimeout() {
|
||||
throw new Error('clearTimeout has not been defined');
|
||||
}
|
||||
|
||||
(function () {
|
||||
try {
|
||||
if (typeof setTimeout === 'function') {
|
||||
cachedSetTimeout = setTimeout;
|
||||
} else {
|
||||
cachedSetTimeout = defaultSetTimout;
|
||||
}
|
||||
} catch (e) {
|
||||
cachedSetTimeout = defaultSetTimout;
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof clearTimeout === 'function') {
|
||||
cachedClearTimeout = clearTimeout;
|
||||
} else {
|
||||
cachedClearTimeout = defaultClearTimeout;
|
||||
}
|
||||
} catch (e) {
|
||||
cachedClearTimeout = defaultClearTimeout;
|
||||
}
|
||||
})();
|
||||
|
||||
function runTimeout(fun) {
|
||||
if (cachedSetTimeout === setTimeout) {
|
||||
//normal enviroments in sane situations
|
||||
return setTimeout(fun, 0);
|
||||
} // if setTimeout wasn't available but was latter defined
|
||||
|
||||
|
||||
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
||||
cachedSetTimeout = setTimeout;
|
||||
return setTimeout(fun, 0);
|
||||
}
|
||||
|
||||
try {
|
||||
// when when somebody has screwed with setTimeout but no I.E. maddness
|
||||
return cachedSetTimeout(fun, 0);
|
||||
} catch (e) {
|
||||
try {
|
||||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
||||
return cachedSetTimeout.call(null, fun, 0);
|
||||
} catch (e) {
|
||||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
||||
return cachedSetTimeout.call(this, fun, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function runClearTimeout(marker) {
|
||||
if (cachedClearTimeout === clearTimeout) {
|
||||
//normal enviroments in sane situations
|
||||
return clearTimeout(marker);
|
||||
} // if clearTimeout wasn't available but was latter defined
|
||||
|
||||
|
||||
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
||||
cachedClearTimeout = clearTimeout;
|
||||
return clearTimeout(marker);
|
||||
}
|
||||
|
||||
try {
|
||||
// when when somebody has screwed with setTimeout but no I.E. maddness
|
||||
return cachedClearTimeout(marker);
|
||||
} catch (e) {
|
||||
try {
|
||||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
||||
return cachedClearTimeout.call(null, marker);
|
||||
} catch (e) {
|
||||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
||||
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
||||
return cachedClearTimeout.call(this, marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var queue = [];
|
||||
var draining = false;
|
||||
var currentQueue;
|
||||
var queueIndex = -1;
|
||||
|
||||
function cleanUpNextTick() {
|
||||
if (!draining || !currentQueue) {
|
||||
return;
|
||||
}
|
||||
|
||||
draining = false;
|
||||
|
||||
if (currentQueue.length) {
|
||||
queue = currentQueue.concat(queue);
|
||||
} else {
|
||||
queueIndex = -1;
|
||||
}
|
||||
|
||||
if (queue.length) {
|
||||
drainQueue();
|
||||
}
|
||||
}
|
||||
|
||||
function drainQueue() {
|
||||
if (draining) {
|
||||
return;
|
||||
}
|
||||
|
||||
var timeout = runTimeout(cleanUpNextTick);
|
||||
draining = true;
|
||||
var len = queue.length;
|
||||
|
||||
while (len) {
|
||||
currentQueue = queue;
|
||||
queue = [];
|
||||
|
||||
while (++queueIndex < len) {
|
||||
if (currentQueue) {
|
||||
currentQueue[queueIndex].run();
|
||||
}
|
||||
}
|
||||
|
||||
queueIndex = -1;
|
||||
len = queue.length;
|
||||
}
|
||||
|
||||
currentQueue = null;
|
||||
draining = false;
|
||||
runClearTimeout(timeout);
|
||||
}
|
||||
|
||||
process.nextTick = function (fun) {
|
||||
var args = new Array(arguments.length - 1);
|
||||
|
||||
if (arguments.length > 1) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
args[i - 1] = arguments[i];
|
||||
}
|
||||
}
|
||||
|
||||
queue.push(new Item(fun, args));
|
||||
|
||||
if (queue.length === 1 && !draining) {
|
||||
runTimeout(drainQueue);
|
||||
}
|
||||
}; // v8 likes predictible objects
|
||||
|
||||
|
||||
function Item(fun, array) {
|
||||
this.fun = fun;
|
||||
this.array = array;
|
||||
}
|
||||
|
||||
Item.prototype.run = function () {
|
||||
this.fun.apply(null, this.array);
|
||||
};
|
||||
|
||||
process.title = 'browser';
|
||||
process.browser = true;
|
||||
process.env = {};
|
||||
process.argv = [];
|
||||
process.version = ''; // empty string to avoid regexp issues
|
||||
|
||||
process.versions = {};
|
||||
|
||||
function noop() {}
|
||||
|
||||
process.on = noop;
|
||||
process.addListener = noop;
|
||||
process.once = noop;
|
||||
process.off = noop;
|
||||
process.removeListener = noop;
|
||||
process.removeAllListeners = noop;
|
||||
process.emit = noop;
|
||||
process.prependListener = noop;
|
||||
process.prependOnceListener = noop;
|
||||
|
||||
process.listeners = function (name) {
|
||||
return [];
|
||||
};
|
||||
|
||||
process.binding = function (name) {
|
||||
throw new Error('process.binding is not supported');
|
||||
};
|
||||
|
||||
process.cwd = function () {
|
||||
return '/';
|
||||
};
|
||||
|
||||
process.chdir = function (dir) {
|
||||
throw new Error('process.chdir is not supported');
|
||||
};
|
||||
|
||||
process.umask = function () {
|
||||
return 0;
|
||||
};
|
||||
}, {}],
|
||||
3: [function (require, module, exports) {
|
||||
/**
|
||||
* This is the common logic for both the Node.js and web browser
|
||||
* implementations of `debug()`.
|
||||
*/
|
||||
function setup(env) {
|
||||
createDebug.debug = createDebug;
|
||||
createDebug.default = createDebug;
|
||||
createDebug.coerce = coerce;
|
||||
createDebug.disable = disable;
|
||||
createDebug.enable = enable;
|
||||
createDebug.enabled = enabled;
|
||||
createDebug.humanize = require('ms');
|
||||
Object.keys(env).forEach(function (key) {
|
||||
createDebug[key] = env[key];
|
||||
});
|
||||
/**
|
||||
* Active `debug` instances.
|
||||
*/
|
||||
|
||||
createDebug.instances = [];
|
||||
/**
|
||||
* The currently active debug mode names, and names to skip.
|
||||
*/
|
||||
|
||||
createDebug.names = [];
|
||||
createDebug.skips = [];
|
||||
/**
|
||||
* Map of special "%n" handling functions, for the debug "format" argument.
|
||||
*
|
||||
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
||||
*/
|
||||
|
||||
createDebug.formatters = {};
|
||||
/**
|
||||
* Selects a color for a debug namespace
|
||||
* @param {String} namespace The namespace string for the for the debug instance to be colored
|
||||
* @return {Number|String} An ANSI color code for the given namespace
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function selectColor(namespace) {
|
||||
var hash = 0;
|
||||
|
||||
for (var i = 0; i < namespace.length; i++) {
|
||||
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
||||
hash |= 0; // Convert to 32bit integer
|
||||
}
|
||||
|
||||
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
||||
}
|
||||
|
||||
createDebug.selectColor = selectColor;
|
||||
/**
|
||||
* Create a debugger with the given `namespace`.
|
||||
*
|
||||
* @param {String} namespace
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function createDebug(namespace) {
|
||||
var prevTime;
|
||||
|
||||
function debug() {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
// Disabled?
|
||||
if (!debug.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var self = debug; // Set `diff` timestamp
|
||||
|
||||
var curr = Number(new Date());
|
||||
var ms = curr - (prevTime || curr);
|
||||
self.diff = ms;
|
||||
self.prev = prevTime;
|
||||
self.curr = curr;
|
||||
prevTime = curr;
|
||||
args[0] = createDebug.coerce(args[0]);
|
||||
|
||||
if (typeof args[0] !== 'string') {
|
||||
// Anything else let's inspect with %O
|
||||
args.unshift('%O');
|
||||
} // Apply any `formatters` transformations
|
||||
|
||||
|
||||
var index = 0;
|
||||
args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
|
||||
// If we encounter an escaped % then don't increase the array index
|
||||
if (match === '%%') {
|
||||
return match;
|
||||
}
|
||||
|
||||
index++;
|
||||
var formatter = createDebug.formatters[format];
|
||||
|
||||
if (typeof formatter === 'function') {
|
||||
var val = args[index];
|
||||
match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
|
||||
|
||||
args.splice(index, 1);
|
||||
index--;
|
||||
}
|
||||
|
||||
return match;
|
||||
}); // Apply env-specific formatting (colors, etc.)
|
||||
|
||||
createDebug.formatArgs.call(self, args);
|
||||
var logFn = self.log || createDebug.log;
|
||||
logFn.apply(self, args);
|
||||
}
|
||||
|
||||
debug.namespace = namespace;
|
||||
debug.enabled = createDebug.enabled(namespace);
|
||||
debug.useColors = createDebug.useColors();
|
||||
debug.color = selectColor(namespace);
|
||||
debug.destroy = destroy;
|
||||
debug.extend = extend; // Debug.formatArgs = formatArgs;
|
||||
// debug.rawLog = rawLog;
|
||||
// env-specific initialization logic for debug instances
|
||||
|
||||
if (typeof createDebug.init === 'function') {
|
||||
createDebug.init(debug);
|
||||
}
|
||||
|
||||
createDebug.instances.push(debug);
|
||||
return debug;
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
var index = createDebug.instances.indexOf(this);
|
||||
|
||||
if (index !== -1) {
|
||||
createDebug.instances.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function extend(namespace, delimiter) {
|
||||
var newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
||||
newDebug.log = this.log;
|
||||
return newDebug;
|
||||
}
|
||||
/**
|
||||
* Enables a debug mode by namespaces. This can include modes
|
||||
* separated by a colon and wildcards.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api public
|
||||
*/
|
||||
|
||||
|
||||
function enable(namespaces) {
|
||||
createDebug.save(namespaces);
|
||||
createDebug.names = [];
|
||||
createDebug.skips = [];
|
||||
var i;
|
||||
var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
||||
var len = split.length;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!split[i]) {
|
||||
// ignore empty strings
|
||||
continue;
|
||||
}
|
||||
|
||||
namespaces = split[i].replace(/\*/g, '.*?');
|
||||
|
||||
if (namespaces[0] === '-') {
|
||||
createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
||||
} else {
|
||||
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < createDebug.instances.length; i++) {
|
||||
var instance = createDebug.instances[i];
|
||||
instance.enabled = createDebug.enabled(instance.namespace);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Disable debug output.
|
||||
*
|
||||
* @return {String} namespaces
|
||||
* @api public
|
||||
*/
|
||||
|
||||
|
||||
function disable() {
|
||||
var namespaces = [].concat(_toConsumableArray(createDebug.names.map(toNamespace)), _toConsumableArray(createDebug.skips.map(toNamespace).map(function (namespace) {
|
||||
return '-' + namespace;
|
||||
}))).join(',');
|
||||
createDebug.enable('');
|
||||
return namespaces;
|
||||
}
|
||||
/**
|
||||
* Returns true if the given mode name is enabled, false otherwise.
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
|
||||
function enabled(name) {
|
||||
if (name[name.length - 1] === '*') {
|
||||
return true;
|
||||
}
|
||||
|
||||
var i;
|
||||
var len;
|
||||
|
||||
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
||||
if (createDebug.skips[i].test(name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
||||
if (createDebug.names[i].test(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Convert regexp to namespace
|
||||
*
|
||||
* @param {RegExp} regxep
|
||||
* @return {String} namespace
|
||||
* @api private
|
||||
*/
|
||||
|
||||
|
||||
function toNamespace(regexp) {
|
||||
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*');
|
||||
}
|
||||
/**
|
||||
* Coerce `val`.
|
||||
*
|
||||
* @param {Mixed} val
|
||||
* @return {Mixed}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
|
||||
function coerce(val) {
|
||||
if (val instanceof Error) {
|
||||
return val.stack || val.message;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
createDebug.enable(createDebug.load());
|
||||
return createDebug;
|
||||
}
|
||||
|
||||
module.exports = setup;
|
||||
}, {
|
||||
"ms": 1
|
||||
}],
|
||||
4: [function (require, module, exports) {
|
||||
(function (process) {
|
||||
/* eslint-env browser */
|
||||
|
||||
/**
|
||||
* This is the web browser implementation of `debug()`.
|
||||
*/
|
||||
exports.log = log;
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
exports.storage = localstorage();
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
|
||||
/**
|
||||
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
||||
* and the Firebug extension (any Firefox version) are known
|
||||
* to support "%c" CSS customizations.
|
||||
*
|
||||
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
|
||||
function useColors() {
|
||||
// NB: In an Electron preload script, document will be defined but not fully
|
||||
// initialized. Since we know we're in Chrome, we'll just detect this case
|
||||
// explicitly
|
||||
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
||||
return true;
|
||||
} // Internet Explorer and Edge do not support colors.
|
||||
|
||||
|
||||
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
||||
return false;
|
||||
} // Is webkit? http://stackoverflow.com/a/16459606/376773
|
||||
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
||||
|
||||
|
||||
return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
||||
typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
||||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
||||
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
||||
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
||||
}
|
||||
/**
|
||||
* Colorize log arguments if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
|
||||
function formatArgs(args) {
|
||||
args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
|
||||
|
||||
if (!this.useColors) {
|
||||
return;
|
||||
}
|
||||
|
||||
var c = 'color: ' + this.color;
|
||||
args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
|
||||
// arguments passed either before or after the %c, so we need to
|
||||
// figure out the correct index to insert the CSS into
|
||||
|
||||
var index = 0;
|
||||
var lastC = 0;
|
||||
args[0].replace(/%[a-zA-Z%]/g, function (match) {
|
||||
if (match === '%%') {
|
||||
return;
|
||||
}
|
||||
|
||||
index++;
|
||||
|
||||
if (match === '%c') {
|
||||
// We only are interested in the *last* %c
|
||||
// (the user may have provided their own)
|
||||
lastC = index;
|
||||
}
|
||||
});
|
||||
args.splice(lastC, 0, c);
|
||||
}
|
||||
/**
|
||||
* Invokes `console.log()` when available.
|
||||
* No-op when `console.log` is not a "function".
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
|
||||
function log() {
|
||||
var _console;
|
||||
|
||||
// This hackery is required for IE8/9, where
|
||||
// the `console.log` function doesn't have 'apply'
|
||||
return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
|
||||
}
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
|
||||
|
||||
function save(namespaces) {
|
||||
try {
|
||||
if (namespaces) {
|
||||
exports.storage.setItem('debug', namespaces);
|
||||
} else {
|
||||
exports.storage.removeItem('debug');
|
||||
}
|
||||
} catch (error) {// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
|
||||
|
||||
function load() {
|
||||
var r;
|
||||
|
||||
try {
|
||||
r = exports.storage.getItem('debug');
|
||||
} catch (error) {} // Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
||||
|
||||
|
||||
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
||||
r = process.env.DEBUG;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
/**
|
||||
* Localstorage attempts to return the localstorage.
|
||||
*
|
||||
* This is necessary because safari throws
|
||||
* when a user disables cookies/localstorage
|
||||
* and you attempt to access it.
|
||||
*
|
||||
* @return {LocalStorage}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
|
||||
function localstorage() {
|
||||
try {
|
||||
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
||||
// The Browser also has localStorage in the global context.
|
||||
return localStorage;
|
||||
} catch (error) {// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = require('./common')(exports);
|
||||
var formatters = module.exports.formatters;
|
||||
/**
|
||||
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
||||
*/
|
||||
|
||||
formatters.j = function (v) {
|
||||
try {
|
||||
return JSON.stringify(v);
|
||||
} catch (error) {
|
||||
return '[UnexpectedJSONParseError]: ' + error.message;
|
||||
}
|
||||
};
|
||||
}).call(this, require('_process'));
|
||||
}, {
|
||||
"./common": 3,
|
||||
"_process": 2
|
||||
}]
|
||||
}, {}, [4])(4);
|
||||
});
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"_from": "debug@^4.0.1",
|
||||
"_id": "debug@4.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
||||
"_location": "/debug",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "debug@^4.0.1",
|
||||
"name": "debug",
|
||||
"escapedName": "debug",
|
||||
"rawSpec": "^4.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^4.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/simple-git"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
||||
"_shasum": "3b72260255109c6b589cee050f1d516139664791",
|
||||
"_spec": "debug@^4.0.1",
|
||||
"_where": "C:\\Users\\lzy\\Documents\\Source\\OpportunityLiu\\github-action-setup-xmake\\node_modules\\simple-git",
|
||||
"author": {
|
||||
"name": "TJ Holowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
"browser": "./src/browser.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/visionmedia/debug/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Nathan Rajlich",
|
||||
"email": "nathan@tootallnate.net",
|
||||
"url": "http://n8.io"
|
||||
},
|
||||
{
|
||||
"name": "Andrew Rhyne",
|
||||
"email": "rhyneandrew@gmail.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"ms": "^2.1.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "small debugging utility",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.0.0",
|
||||
"@babel/core": "^7.0.0",
|
||||
"@babel/preset-env": "^7.0.0",
|
||||
"browserify": "14.4.0",
|
||||
"chai": "^3.5.0",
|
||||
"concurrently": "^3.1.0",
|
||||
"coveralls": "^3.0.2",
|
||||
"istanbul": "^0.4.5",
|
||||
"karma": "^3.0.0",
|
||||
"karma-chai": "^0.1.0",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-phantomjs-launcher": "^1.0.2",
|
||||
"mocha": "^5.2.0",
|
||||
"mocha-lcov-reporter": "^1.2.0",
|
||||
"rimraf": "^2.5.4",
|
||||
"xo": "^0.23.0"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"dist/debug.js",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"homepage": "https://github.com/visionmedia/debug#readme",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"log",
|
||||
"debugger"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./src/index.js",
|
||||
"name": "debug",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/visionmedia/debug.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build:debug && npm run build:test",
|
||||
"build:debug": "babel -o dist/debug.js dist/debug.es6.js > dist/debug.js",
|
||||
"build:test": "babel -d dist test.js",
|
||||
"clean": "rimraf dist coverage",
|
||||
"lint": "xo",
|
||||
"prebuild:debug": "mkdir -p dist && browserify --standalone debug -o dist/debug.es6.js .",
|
||||
"pretest:browser": "npm run build",
|
||||
"test": "npm run test:node && npm run test:browser",
|
||||
"test:browser": "karma start --single-run",
|
||||
"test:coverage": "cat ./coverage/lcov.info | coveralls",
|
||||
"test:node": "istanbul cover _mocha -- test.js"
|
||||
},
|
||||
"unpkg": "./dist/debug.js",
|
||||
"version": "4.1.1"
|
||||
}
|
||||
+264
@@ -0,0 +1,264 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
/**
|
||||
* This is the web browser implementation of `debug()`.
|
||||
*/
|
||||
|
||||
exports.log = log;
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
exports.storage = localstorage();
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [
|
||||
'#0000CC',
|
||||
'#0000FF',
|
||||
'#0033CC',
|
||||
'#0033FF',
|
||||
'#0066CC',
|
||||
'#0066FF',
|
||||
'#0099CC',
|
||||
'#0099FF',
|
||||
'#00CC00',
|
||||
'#00CC33',
|
||||
'#00CC66',
|
||||
'#00CC99',
|
||||
'#00CCCC',
|
||||
'#00CCFF',
|
||||
'#3300CC',
|
||||
'#3300FF',
|
||||
'#3333CC',
|
||||
'#3333FF',
|
||||
'#3366CC',
|
||||
'#3366FF',
|
||||
'#3399CC',
|
||||
'#3399FF',
|
||||
'#33CC00',
|
||||
'#33CC33',
|
||||
'#33CC66',
|
||||
'#33CC99',
|
||||
'#33CCCC',
|
||||
'#33CCFF',
|
||||
'#6600CC',
|
||||
'#6600FF',
|
||||
'#6633CC',
|
||||
'#6633FF',
|
||||
'#66CC00',
|
||||
'#66CC33',
|
||||
'#9900CC',
|
||||
'#9900FF',
|
||||
'#9933CC',
|
||||
'#9933FF',
|
||||
'#99CC00',
|
||||
'#99CC33',
|
||||
'#CC0000',
|
||||
'#CC0033',
|
||||
'#CC0066',
|
||||
'#CC0099',
|
||||
'#CC00CC',
|
||||
'#CC00FF',
|
||||
'#CC3300',
|
||||
'#CC3333',
|
||||
'#CC3366',
|
||||
'#CC3399',
|
||||
'#CC33CC',
|
||||
'#CC33FF',
|
||||
'#CC6600',
|
||||
'#CC6633',
|
||||
'#CC9900',
|
||||
'#CC9933',
|
||||
'#CCCC00',
|
||||
'#CCCC33',
|
||||
'#FF0000',
|
||||
'#FF0033',
|
||||
'#FF0066',
|
||||
'#FF0099',
|
||||
'#FF00CC',
|
||||
'#FF00FF',
|
||||
'#FF3300',
|
||||
'#FF3333',
|
||||
'#FF3366',
|
||||
'#FF3399',
|
||||
'#FF33CC',
|
||||
'#FF33FF',
|
||||
'#FF6600',
|
||||
'#FF6633',
|
||||
'#FF9900',
|
||||
'#FF9933',
|
||||
'#FFCC00',
|
||||
'#FFCC33'
|
||||
];
|
||||
|
||||
/**
|
||||
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
||||
* and the Firebug extension (any Firefox version) are known
|
||||
* to support "%c" CSS customizations.
|
||||
*
|
||||
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
function useColors() {
|
||||
// NB: In an Electron preload script, document will be defined but not fully
|
||||
// initialized. Since we know we're in Chrome, we'll just detect this case
|
||||
// explicitly
|
||||
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Internet Explorer and Edge do not support colors.
|
||||
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
||||
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
||||
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
||||
// Is firebug? http://stackoverflow.com/a/398120/376773
|
||||
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
||||
// Is firefox >= v31?
|
||||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
||||
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
|
||||
// Double check webkit in userAgent just in case we are in a worker
|
||||
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
||||
}
|
||||
|
||||
/**
|
||||
* Colorize log arguments if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function formatArgs(args) {
|
||||
args[0] = (this.useColors ? '%c' : '') +
|
||||
this.namespace +
|
||||
(this.useColors ? ' %c' : ' ') +
|
||||
args[0] +
|
||||
(this.useColors ? '%c ' : ' ') +
|
||||
'+' + module.exports.humanize(this.diff);
|
||||
|
||||
if (!this.useColors) {
|
||||
return;
|
||||
}
|
||||
|
||||
const c = 'color: ' + this.color;
|
||||
args.splice(1, 0, c, 'color: inherit');
|
||||
|
||||
// The final "%c" is somewhat tricky, because there could be other
|
||||
// arguments passed either before or after the %c, so we need to
|
||||
// figure out the correct index to insert the CSS into
|
||||
let index = 0;
|
||||
let lastC = 0;
|
||||
args[0].replace(/%[a-zA-Z%]/g, match => {
|
||||
if (match === '%%') {
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
if (match === '%c') {
|
||||
// We only are interested in the *last* %c
|
||||
// (the user may have provided their own)
|
||||
lastC = index;
|
||||
}
|
||||
});
|
||||
|
||||
args.splice(lastC, 0, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `console.log()` when available.
|
||||
* No-op when `console.log` is not a "function".
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
function log(...args) {
|
||||
// This hackery is required for IE8/9, where
|
||||
// the `console.log` function doesn't have 'apply'
|
||||
return typeof console === 'object' &&
|
||||
console.log &&
|
||||
console.log(...args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
function save(namespaces) {
|
||||
try {
|
||||
if (namespaces) {
|
||||
exports.storage.setItem('debug', namespaces);
|
||||
} else {
|
||||
exports.storage.removeItem('debug');
|
||||
}
|
||||
} catch (error) {
|
||||
// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
function load() {
|
||||
let r;
|
||||
try {
|
||||
r = exports.storage.getItem('debug');
|
||||
} catch (error) {
|
||||
// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
|
||||
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
||||
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
||||
r = process.env.DEBUG;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Localstorage attempts to return the localstorage.
|
||||
*
|
||||
* This is necessary because safari throws
|
||||
* when a user disables cookies/localstorage
|
||||
* and you attempt to access it.
|
||||
*
|
||||
* @return {LocalStorage}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function localstorage() {
|
||||
try {
|
||||
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
||||
// The Browser also has localStorage in the global context.
|
||||
return localStorage;
|
||||
} catch (error) {
|
||||
// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = require('./common')(exports);
|
||||
|
||||
const {formatters} = module.exports;
|
||||
|
||||
/**
|
||||
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
||||
*/
|
||||
|
||||
formatters.j = function (v) {
|
||||
try {
|
||||
return JSON.stringify(v);
|
||||
} catch (error) {
|
||||
return '[UnexpectedJSONParseError]: ' + error.message;
|
||||
}
|
||||
};
|
||||
+266
@@ -0,0 +1,266 @@
|
||||
|
||||
/**
|
||||
* This is the common logic for both the Node.js and web browser
|
||||
* implementations of `debug()`.
|
||||
*/
|
||||
|
||||
function setup(env) {
|
||||
createDebug.debug = createDebug;
|
||||
createDebug.default = createDebug;
|
||||
createDebug.coerce = coerce;
|
||||
createDebug.disable = disable;
|
||||
createDebug.enable = enable;
|
||||
createDebug.enabled = enabled;
|
||||
createDebug.humanize = require('ms');
|
||||
|
||||
Object.keys(env).forEach(key => {
|
||||
createDebug[key] = env[key];
|
||||
});
|
||||
|
||||
/**
|
||||
* Active `debug` instances.
|
||||
*/
|
||||
createDebug.instances = [];
|
||||
|
||||
/**
|
||||
* The currently active debug mode names, and names to skip.
|
||||
*/
|
||||
|
||||
createDebug.names = [];
|
||||
createDebug.skips = [];
|
||||
|
||||
/**
|
||||
* Map of special "%n" handling functions, for the debug "format" argument.
|
||||
*
|
||||
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
||||
*/
|
||||
createDebug.formatters = {};
|
||||
|
||||
/**
|
||||
* Selects a color for a debug namespace
|
||||
* @param {String} namespace The namespace string for the for the debug instance to be colored
|
||||
* @return {Number|String} An ANSI color code for the given namespace
|
||||
* @api private
|
||||
*/
|
||||
function selectColor(namespace) {
|
||||
let hash = 0;
|
||||
|
||||
for (let i = 0; i < namespace.length; i++) {
|
||||
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
|
||||
hash |= 0; // Convert to 32bit integer
|
||||
}
|
||||
|
||||
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
||||
}
|
||||
createDebug.selectColor = selectColor;
|
||||
|
||||
/**
|
||||
* Create a debugger with the given `namespace`.
|
||||
*
|
||||
* @param {String} namespace
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
function createDebug(namespace) {
|
||||
let prevTime;
|
||||
|
||||
function debug(...args) {
|
||||
// Disabled?
|
||||
if (!debug.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const self = debug;
|
||||
|
||||
// Set `diff` timestamp
|
||||
const curr = Number(new Date());
|
||||
const ms = curr - (prevTime || curr);
|
||||
self.diff = ms;
|
||||
self.prev = prevTime;
|
||||
self.curr = curr;
|
||||
prevTime = curr;
|
||||
|
||||
args[0] = createDebug.coerce(args[0]);
|
||||
|
||||
if (typeof args[0] !== 'string') {
|
||||
// Anything else let's inspect with %O
|
||||
args.unshift('%O');
|
||||
}
|
||||
|
||||
// Apply any `formatters` transformations
|
||||
let index = 0;
|
||||
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
||||
// If we encounter an escaped % then don't increase the array index
|
||||
if (match === '%%') {
|
||||
return match;
|
||||
}
|
||||
index++;
|
||||
const formatter = createDebug.formatters[format];
|
||||
if (typeof formatter === 'function') {
|
||||
const val = args[index];
|
||||
match = formatter.call(self, val);
|
||||
|
||||
// Now we need to remove `args[index]` since it's inlined in the `format`
|
||||
args.splice(index, 1);
|
||||
index--;
|
||||
}
|
||||
return match;
|
||||
});
|
||||
|
||||
// Apply env-specific formatting (colors, etc.)
|
||||
createDebug.formatArgs.call(self, args);
|
||||
|
||||
const logFn = self.log || createDebug.log;
|
||||
logFn.apply(self, args);
|
||||
}
|
||||
|
||||
debug.namespace = namespace;
|
||||
debug.enabled = createDebug.enabled(namespace);
|
||||
debug.useColors = createDebug.useColors();
|
||||
debug.color = selectColor(namespace);
|
||||
debug.destroy = destroy;
|
||||
debug.extend = extend;
|
||||
// Debug.formatArgs = formatArgs;
|
||||
// debug.rawLog = rawLog;
|
||||
|
||||
// env-specific initialization logic for debug instances
|
||||
if (typeof createDebug.init === 'function') {
|
||||
createDebug.init(debug);
|
||||
}
|
||||
|
||||
createDebug.instances.push(debug);
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
const index = createDebug.instances.indexOf(this);
|
||||
if (index !== -1) {
|
||||
createDebug.instances.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function extend(namespace, delimiter) {
|
||||
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
||||
newDebug.log = this.log;
|
||||
return newDebug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables a debug mode by namespaces. This can include modes
|
||||
* separated by a colon and wildcards.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api public
|
||||
*/
|
||||
function enable(namespaces) {
|
||||
createDebug.save(namespaces);
|
||||
|
||||
createDebug.names = [];
|
||||
createDebug.skips = [];
|
||||
|
||||
let i;
|
||||
const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
||||
const len = split.length;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!split[i]) {
|
||||
// ignore empty strings
|
||||
continue;
|
||||
}
|
||||
|
||||
namespaces = split[i].replace(/\*/g, '.*?');
|
||||
|
||||
if (namespaces[0] === '-') {
|
||||
createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
||||
} else {
|
||||
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < createDebug.instances.length; i++) {
|
||||
const instance = createDebug.instances[i];
|
||||
instance.enabled = createDebug.enabled(instance.namespace);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable debug output.
|
||||
*
|
||||
* @return {String} namespaces
|
||||
* @api public
|
||||
*/
|
||||
function disable() {
|
||||
const namespaces = [
|
||||
...createDebug.names.map(toNamespace),
|
||||
...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
|
||||
].join(',');
|
||||
createDebug.enable('');
|
||||
return namespaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given mode name is enabled, false otherwise.
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
function enabled(name) {
|
||||
if (name[name.length - 1] === '*') {
|
||||
return true;
|
||||
}
|
||||
|
||||
let i;
|
||||
let len;
|
||||
|
||||
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
||||
if (createDebug.skips[i].test(name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
||||
if (createDebug.names[i].test(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert regexp to namespace
|
||||
*
|
||||
* @param {RegExp} regxep
|
||||
* @return {String} namespace
|
||||
* @api private
|
||||
*/
|
||||
function toNamespace(regexp) {
|
||||
return regexp.toString()
|
||||
.substring(2, regexp.toString().length - 2)
|
||||
.replace(/\.\*\?$/, '*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Coerce `val`.
|
||||
*
|
||||
* @param {Mixed} val
|
||||
* @return {Mixed}
|
||||
* @api private
|
||||
*/
|
||||
function coerce(val) {
|
||||
if (val instanceof Error) {
|
||||
return val.stack || val.message;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
createDebug.enable(createDebug.load());
|
||||
|
||||
return createDebug;
|
||||
}
|
||||
|
||||
module.exports = setup;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Detect Electron renderer / nwjs process, which is node, but we should
|
||||
* treat as a browser.
|
||||
*/
|
||||
|
||||
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
||||
module.exports = require('./browser.js');
|
||||
} else {
|
||||
module.exports = require('./node.js');
|
||||
}
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
const tty = require('tty');
|
||||
const util = require('util');
|
||||
|
||||
/**
|
||||
* This is the Node.js implementation of `debug()`.
|
||||
*/
|
||||
|
||||
exports.init = init;
|
||||
exports.log = log;
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [6, 2, 3, 4, 5, 1];
|
||||
|
||||
try {
|
||||
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
const supportsColor = require('supports-color');
|
||||
|
||||
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
||||
exports.colors = [
|
||||
20,
|
||||
21,
|
||||
26,
|
||||
27,
|
||||
32,
|
||||
33,
|
||||
38,
|
||||
39,
|
||||
40,
|
||||
41,
|
||||
42,
|
||||
43,
|
||||
44,
|
||||
45,
|
||||
56,
|
||||
57,
|
||||
62,
|
||||
63,
|
||||
68,
|
||||
69,
|
||||
74,
|
||||
75,
|
||||
76,
|
||||
77,
|
||||
78,
|
||||
79,
|
||||
80,
|
||||
81,
|
||||
92,
|
||||
93,
|
||||
98,
|
||||
99,
|
||||
112,
|
||||
113,
|
||||
128,
|
||||
129,
|
||||
134,
|
||||
135,
|
||||
148,
|
||||
149,
|
||||
160,
|
||||
161,
|
||||
162,
|
||||
163,
|
||||
164,
|
||||
165,
|
||||
166,
|
||||
167,
|
||||
168,
|
||||
169,
|
||||
170,
|
||||
171,
|
||||
172,
|
||||
173,
|
||||
178,
|
||||
179,
|
||||
184,
|
||||
185,
|
||||
196,
|
||||
197,
|
||||
198,
|
||||
199,
|
||||
200,
|
||||
201,
|
||||
202,
|
||||
203,
|
||||
204,
|
||||
205,
|
||||
206,
|
||||
207,
|
||||
208,
|
||||
209,
|
||||
214,
|
||||
215,
|
||||
220,
|
||||
221
|
||||
];
|
||||
}
|
||||
} catch (error) {
|
||||
// Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
||||
}
|
||||
|
||||
/**
|
||||
* Build up the default `inspectOpts` object from the environment variables.
|
||||
*
|
||||
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
||||
*/
|
||||
|
||||
exports.inspectOpts = Object.keys(process.env).filter(key => {
|
||||
return /^debug_/i.test(key);
|
||||
}).reduce((obj, key) => {
|
||||
// Camel-case
|
||||
const prop = key
|
||||
.substring(6)
|
||||
.toLowerCase()
|
||||
.replace(/_([a-z])/g, (_, k) => {
|
||||
return k.toUpperCase();
|
||||
});
|
||||
|
||||
// Coerce string value into JS value
|
||||
let val = process.env[key];
|
||||
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
||||
val = true;
|
||||
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
||||
val = false;
|
||||
} else if (val === 'null') {
|
||||
val = null;
|
||||
} else {
|
||||
val = Number(val);
|
||||
}
|
||||
|
||||
obj[prop] = val;
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
/**
|
||||
* Is stdout a TTY? Colored output is enabled when `true`.
|
||||
*/
|
||||
|
||||
function useColors() {
|
||||
return 'colors' in exports.inspectOpts ?
|
||||
Boolean(exports.inspectOpts.colors) :
|
||||
tty.isatty(process.stderr.fd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds ANSI color escape codes if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function formatArgs(args) {
|
||||
const {namespace: name, useColors} = this;
|
||||
|
||||
if (useColors) {
|
||||
const c = this.color;
|
||||
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
|
||||
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
||||
|
||||
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
||||
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
|
||||
} else {
|
||||
args[0] = getDate() + name + ' ' + args[0];
|
||||
}
|
||||
}
|
||||
|
||||
function getDate() {
|
||||
if (exports.inspectOpts.hideDate) {
|
||||
return '';
|
||||
}
|
||||
return new Date().toISOString() + ' ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `util.format()` with the specified arguments and writes to stderr.
|
||||
*/
|
||||
|
||||
function log(...args) {
|
||||
return process.stderr.write(util.format(...args) + '\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
function save(namespaces) {
|
||||
if (namespaces) {
|
||||
process.env.DEBUG = namespaces;
|
||||
} else {
|
||||
// If you set a process.env field to null or undefined, it gets cast to the
|
||||
// string 'null' or 'undefined'. Just delete instead.
|
||||
delete process.env.DEBUG;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function load() {
|
||||
return process.env.DEBUG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init logic for `debug` instances.
|
||||
*
|
||||
* Create a new `inspectOpts` object in case `useColors` is set
|
||||
* differently for a particular `debug` instance.
|
||||
*/
|
||||
|
||||
function init(debug) {
|
||||
debug.inspectOpts = {};
|
||||
|
||||
const keys = Object.keys(exports.inspectOpts);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = require('./common')(exports);
|
||||
|
||||
const {formatters} = module.exports;
|
||||
|
||||
/**
|
||||
* Map %o to `util.inspect()`, all on a single line.
|
||||
*/
|
||||
|
||||
formatters.o = function (v) {
|
||||
this.inspectOpts.colors = this.useColors;
|
||||
return util.inspect(v, this.inspectOpts)
|
||||
.replace(/\s*\n\s*/g, ' ');
|
||||
};
|
||||
|
||||
/**
|
||||
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
||||
*/
|
||||
|
||||
formatters.O = function (v) {
|
||||
this.inspectOpts.colors = this.useColors;
|
||||
return util.inspect(v, this.inspectOpts);
|
||||
};
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* Helpers.
|
||||
*/
|
||||
|
||||
var s = 1000;
|
||||
var m = s * 60;
|
||||
var h = m * 60;
|
||||
var d = h * 24;
|
||||
var w = d * 7;
|
||||
var y = d * 365.25;
|
||||
|
||||
/**
|
||||
* Parse or format the given `val`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `long` verbose formatting [false]
|
||||
*
|
||||
* @param {String|Number} val
|
||||
* @param {Object} [options]
|
||||
* @throws {Error} throw an error if val is not a non-empty string or a number
|
||||
* @return {String|Number}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function(val, options) {
|
||||
options = options || {};
|
||||
var type = typeof val;
|
||||
if (type === 'string' && val.length > 0) {
|
||||
return parse(val);
|
||||
} else if (type === 'number' && isFinite(val)) {
|
||||
return options.long ? fmtLong(val) : fmtShort(val);
|
||||
}
|
||||
throw new Error(
|
||||
'val is not a non-empty string or a valid number. val=' +
|
||||
JSON.stringify(val)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse the given `str` and return milliseconds.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function parse(str) {
|
||||
str = String(str);
|
||||
if (str.length > 100) {
|
||||
return;
|
||||
}
|
||||
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
||||
str
|
||||
);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
var n = parseFloat(match[1]);
|
||||
var type = (match[2] || 'ms').toLowerCase();
|
||||
switch (type) {
|
||||
case 'years':
|
||||
case 'year':
|
||||
case 'yrs':
|
||||
case 'yr':
|
||||
case 'y':
|
||||
return n * y;
|
||||
case 'weeks':
|
||||
case 'week':
|
||||
case 'w':
|
||||
return n * w;
|
||||
case 'days':
|
||||
case 'day':
|
||||
case 'd':
|
||||
return n * d;
|
||||
case 'hours':
|
||||
case 'hour':
|
||||
case 'hrs':
|
||||
case 'hr':
|
||||
case 'h':
|
||||
return n * h;
|
||||
case 'minutes':
|
||||
case 'minute':
|
||||
case 'mins':
|
||||
case 'min':
|
||||
case 'm':
|
||||
return n * m;
|
||||
case 'seconds':
|
||||
case 'second':
|
||||
case 'secs':
|
||||
case 'sec':
|
||||
case 's':
|
||||
return n * s;
|
||||
case 'milliseconds':
|
||||
case 'millisecond':
|
||||
case 'msecs':
|
||||
case 'msec':
|
||||
case 'ms':
|
||||
return n;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtShort(ms) {
|
||||
var msAbs = Math.abs(ms);
|
||||
if (msAbs >= d) {
|
||||
return Math.round(ms / d) + 'd';
|
||||
}
|
||||
if (msAbs >= h) {
|
||||
return Math.round(ms / h) + 'h';
|
||||
}
|
||||
if (msAbs >= m) {
|
||||
return Math.round(ms / m) + 'm';
|
||||
}
|
||||
if (msAbs >= s) {
|
||||
return Math.round(ms / s) + 's';
|
||||
}
|
||||
return ms + 'ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Long format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtLong(ms) {
|
||||
var msAbs = Math.abs(ms);
|
||||
if (msAbs >= d) {
|
||||
return plural(ms, msAbs, d, 'day');
|
||||
}
|
||||
if (msAbs >= h) {
|
||||
return plural(ms, msAbs, h, 'hour');
|
||||
}
|
||||
if (msAbs >= m) {
|
||||
return plural(ms, msAbs, m, 'minute');
|
||||
}
|
||||
if (msAbs >= s) {
|
||||
return plural(ms, msAbs, s, 'second');
|
||||
}
|
||||
return ms + ' ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Pluralization helper.
|
||||
*/
|
||||
|
||||
function plural(ms, msAbs, n, name) {
|
||||
var isPlural = msAbs >= n * 1.5;
|
||||
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Zeit, Inc.
|
||||
|
||||
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.
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"_from": "ms@^2.1.1",
|
||||
"_id": "ms@2.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||
"_location": "/ms",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "ms@^2.1.1",
|
||||
"name": "ms",
|
||||
"escapedName": "ms",
|
||||
"rawSpec": "^2.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/debug"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"_shasum": "d09d1f357b443f493382a8eb3ccd183872ae6009",
|
||||
"_spec": "ms@^2.1.1",
|
||||
"_where": "C:\\Users\\lzy\\Documents\\Source\\OpportunityLiu\\github-action-setup-xmake\\node_modules\\debug",
|
||||
"bugs": {
|
||||
"url": "https://github.com/zeit/ms/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Tiny millisecond conversion utility",
|
||||
"devDependencies": {
|
||||
"eslint": "4.12.1",
|
||||
"expect.js": "0.3.1",
|
||||
"husky": "0.14.3",
|
||||
"lint-staged": "5.0.0",
|
||||
"mocha": "4.0.1"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "eslint:recommended",
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/zeit/ms#readme",
|
||||
"license": "MIT",
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"npm run lint",
|
||||
"prettier --single-quote --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"main": "./index",
|
||||
"name": "ms",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/zeit/ms.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint lib/* bin/*",
|
||||
"precommit": "lint-staged",
|
||||
"test": "mocha tests.js"
|
||||
},
|
||||
"version": "2.1.2"
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
# ms
|
||||
|
||||
[](https://travis-ci.org/zeit/ms)
|
||||
[](https://spectrum.chat/zeit)
|
||||
|
||||
Use this package to easily convert various time formats to milliseconds.
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
ms('2 days') // 172800000
|
||||
ms('1d') // 86400000
|
||||
ms('10h') // 36000000
|
||||
ms('2.5 hrs') // 9000000
|
||||
ms('2h') // 7200000
|
||||
ms('1m') // 60000
|
||||
ms('5s') // 5000
|
||||
ms('1y') // 31557600000
|
||||
ms('100') // 100
|
||||
ms('-3 days') // -259200000
|
||||
ms('-1h') // -3600000
|
||||
ms('-200') // -200
|
||||
```
|
||||
|
||||
### Convert from Milliseconds
|
||||
|
||||
```js
|
||||
ms(60000) // "1m"
|
||||
ms(2 * 60000) // "2m"
|
||||
ms(-3 * 60000) // "-3m"
|
||||
ms(ms('10 hours')) // "10h"
|
||||
```
|
||||
|
||||
### Time Format Written-Out
|
||||
|
||||
```js
|
||||
ms(60000, { long: true }) // "1 minute"
|
||||
ms(2 * 60000, { long: true }) // "2 minutes"
|
||||
ms(-3 * 60000, { long: true }) // "-3 minutes"
|
||||
ms(ms('10 hours'), { long: true }) // "10 hours"
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Works both in [Node.js](https://nodejs.org) and in the browser
|
||||
- If a number is supplied to `ms`, a string with a unit is returned
|
||||
- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`)
|
||||
- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned
|
||||
|
||||
## Related Packages
|
||||
|
||||
- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time.
|
||||
|
||||
## Caught a Bug?
|
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
|
||||
2. Link the package to the global module directory: `npm link`
|
||||
3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms!
|
||||
|
||||
As always, you can run the tests using: `npm test`
|
||||
+31
@@ -1,5 +1,36 @@
|
||||
# changes log
|
||||
|
||||
## 6.2.0
|
||||
|
||||
* Coerce numbers to strings when passed to semver.coerce()
|
||||
* Add `rtl` option to coerce from right to left
|
||||
|
||||
## 6.1.3
|
||||
|
||||
* Handle X-ranges properly in includePrerelease mode
|
||||
|
||||
## 6.1.2
|
||||
|
||||
* Do not throw when testing invalid version strings
|
||||
|
||||
## 6.1.1
|
||||
|
||||
* Add options support for semver.coerce()
|
||||
* Handle undefined version passed to Range.test
|
||||
|
||||
## 6.1.0
|
||||
|
||||
* Add semver.compareBuild function
|
||||
* Support `*` in semver.intersects
|
||||
|
||||
## 6.0
|
||||
|
||||
* Fix `intersects` logic.
|
||||
|
||||
This is technically a bug fix, but since it is also a change to behavior
|
||||
that may require users updating their code, it is marked as a major
|
||||
version increment.
|
||||
|
||||
## 5.7
|
||||
|
||||
* Add `minVersion` method
|
||||
|
||||
+35
-4
@@ -4,7 +4,7 @@ semver(1) -- The semantic versioner for npm
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm install --save semver
|
||||
npm install semver
|
||||
````
|
||||
|
||||
## Usage
|
||||
@@ -60,6 +60,12 @@ Options:
|
||||
Coerce a string into SemVer if possible
|
||||
(does not imply --loose)
|
||||
|
||||
--rtl
|
||||
Coerce version strings right to left
|
||||
|
||||
--ltr
|
||||
Coerce version strings left to right (default)
|
||||
|
||||
Program exits successfully if any valid version satisfies
|
||||
all supplied ranges, and prints all satisfying versions.
|
||||
|
||||
@@ -231,7 +237,7 @@ comparator. Allows minor-level changes if not.
|
||||
|
||||
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
|
||||
|
||||
Allows changes that do not modify the left-most non-zero digit in the
|
||||
Allows changes that do not modify the left-most non-zero element in the
|
||||
`[major, minor, patch]` tuple. In other words, this allows patch and
|
||||
minor updates for versions `1.0.0` and above, patch updates for
|
||||
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
|
||||
@@ -354,6 +360,9 @@ strings that they parse.
|
||||
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
||||
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
|
||||
in descending order when passed to `Array.sort()`.
|
||||
* `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions
|
||||
are equal. Sorts in ascending order if passed to `Array.sort()`.
|
||||
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
||||
* `diff(v1, v2)`: Returns difference between two versions by the release type
|
||||
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
|
||||
or null if the versions are the same.
|
||||
@@ -396,7 +405,7 @@ range, use the `satisfies(version, range)` function.
|
||||
|
||||
### Coercion
|
||||
|
||||
* `coerce(version)`: Coerces a string to semver if possible
|
||||
* `coerce(version, options)`: Coerces a string to semver if possible
|
||||
|
||||
This aims to provide a very forgiving translation of a non-semver string to
|
||||
semver. It looks for the first digit in a string, and consumes all
|
||||
@@ -408,5 +417,27 @@ surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes
|
||||
is not valid). The maximum length for any semver component considered for
|
||||
coercion is 16 characters; longer components will be ignored
|
||||
(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any
|
||||
semver component is `Number.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
|
||||
semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
|
||||
components are invalid (`9999999999999999.4.7.4` is likely invalid).
|
||||
|
||||
If the `options.rtl` flag is set, then `coerce` will return the right-most
|
||||
coercible tuple that does not share an ending index with a longer coercible
|
||||
tuple. For example, `1.2.3.4` will return `2.3.4` in rtl mode, not
|
||||
`4.0.0`. `1.2.3/4` will return `4.0.0`, because the `4` is not a part of
|
||||
any other overlapping SemVer tuple.
|
||||
|
||||
### Clean
|
||||
|
||||
* `clean(version)`: Clean a string to be a valid semver if possible
|
||||
|
||||
This will return a cleaned and trimmed semver version. If the provided version is not valid a null will be returned. This does not work for ranges.
|
||||
|
||||
ex.
|
||||
* `s.clean(' = v 2.1.5foo')`: `null`
|
||||
* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'`
|
||||
* `s.clean(' = v 2.1.5-foo')`: `null`
|
||||
* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'`
|
||||
* `s.clean('=v2.1.5')`: `'2.1.5'`
|
||||
* `s.clean(' =v2.1.5')`: `2.1.5`
|
||||
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
|
||||
* `s.clean('~1.0.0')`: `null`
|
||||
|
||||
+174
@@ -0,0 +1,174 @@
|
||||
#!/usr/bin/env node
|
||||
// Standalone semver comparison program.
|
||||
// Exits successfully and prints matching version(s) if
|
||||
// any supplied version is valid and passes all tests.
|
||||
|
||||
var argv = process.argv.slice(2)
|
||||
|
||||
var versions = []
|
||||
|
||||
var range = []
|
||||
|
||||
var inc = null
|
||||
|
||||
var version = require('../package.json').version
|
||||
|
||||
var loose = false
|
||||
|
||||
var includePrerelease = false
|
||||
|
||||
var coerce = false
|
||||
|
||||
var rtl = false
|
||||
|
||||
var identifier
|
||||
|
||||
var semver = require('../semver')
|
||||
|
||||
var reverse = false
|
||||
|
||||
var options = {}
|
||||
|
||||
main()
|
||||
|
||||
function main () {
|
||||
if (!argv.length) return help()
|
||||
while (argv.length) {
|
||||
var a = argv.shift()
|
||||
var indexOfEqualSign = a.indexOf('=')
|
||||
if (indexOfEqualSign !== -1) {
|
||||
a = a.slice(0, indexOfEqualSign)
|
||||
argv.unshift(a.slice(indexOfEqualSign + 1))
|
||||
}
|
||||
switch (a) {
|
||||
case '-rv': case '-rev': case '--rev': case '--reverse':
|
||||
reverse = true
|
||||
break
|
||||
case '-l': case '--loose':
|
||||
loose = true
|
||||
break
|
||||
case '-p': case '--include-prerelease':
|
||||
includePrerelease = true
|
||||
break
|
||||
case '-v': case '--version':
|
||||
versions.push(argv.shift())
|
||||
break
|
||||
case '-i': case '--inc': case '--increment':
|
||||
switch (argv[0]) {
|
||||
case 'major': case 'minor': case 'patch': case 'prerelease':
|
||||
case 'premajor': case 'preminor': case 'prepatch':
|
||||
inc = argv.shift()
|
||||
break
|
||||
default:
|
||||
inc = 'patch'
|
||||
break
|
||||
}
|
||||
break
|
||||
case '--preid':
|
||||
identifier = argv.shift()
|
||||
break
|
||||
case '-r': case '--range':
|
||||
range.push(argv.shift())
|
||||
break
|
||||
case '-c': case '--coerce':
|
||||
coerce = true
|
||||
break
|
||||
case '--rtl':
|
||||
rtl = true
|
||||
break
|
||||
case '--ltr':
|
||||
rtl = false
|
||||
break
|
||||
case '-h': case '--help': case '-?':
|
||||
return help()
|
||||
default:
|
||||
versions.push(a)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
var options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl }
|
||||
|
||||
versions = versions.map(function (v) {
|
||||
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
|
||||
}).filter(function (v) {
|
||||
return semver.valid(v)
|
||||
})
|
||||
if (!versions.length) return fail()
|
||||
if (inc && (versions.length !== 1 || range.length)) { return failInc() }
|
||||
|
||||
for (var i = 0, l = range.length; i < l; i++) {
|
||||
versions = versions.filter(function (v) {
|
||||
return semver.satisfies(v, range[i], options)
|
||||
})
|
||||
if (!versions.length) return fail()
|
||||
}
|
||||
return success(versions)
|
||||
}
|
||||
|
||||
function failInc () {
|
||||
console.error('--inc can only be used on a single version with no range')
|
||||
fail()
|
||||
}
|
||||
|
||||
function fail () { process.exit(1) }
|
||||
|
||||
function success () {
|
||||
var compare = reverse ? 'rcompare' : 'compare'
|
||||
versions.sort(function (a, b) {
|
||||
return semver[compare](a, b, options)
|
||||
}).map(function (v) {
|
||||
return semver.clean(v, options)
|
||||
}).map(function (v) {
|
||||
return inc ? semver.inc(v, inc, options, identifier) : v
|
||||
}).forEach(function (v, i, _) { console.log(v) })
|
||||
}
|
||||
|
||||
function help () {
|
||||
console.log(['SemVer ' + version,
|
||||
'',
|
||||
'A JavaScript implementation of the https://semver.org/ specification',
|
||||
'Copyright Isaac Z. Schlueter',
|
||||
'',
|
||||
'Usage: semver [options] <version> [<version> [...]]',
|
||||
'Prints valid versions sorted by SemVer precedence',
|
||||
'',
|
||||
'Options:',
|
||||
'-r --range <range>',
|
||||
' Print versions that match the specified range.',
|
||||
'',
|
||||
'-i --increment [<level>]',
|
||||
' Increment a version by the specified level. Level can',
|
||||
' be one of: major, minor, patch, premajor, preminor,',
|
||||
" prepatch, or prerelease. Default level is 'patch'.",
|
||||
' Only one version may be specified.',
|
||||
'',
|
||||
'--preid <identifier>',
|
||||
' Identifier to be used to prefix premajor, preminor,',
|
||||
' prepatch or prerelease version increments.',
|
||||
'',
|
||||
'-l --loose',
|
||||
' Interpret versions and ranges loosely',
|
||||
'',
|
||||
'-p --include-prerelease',
|
||||
' Always include prerelease versions in range matching',
|
||||
'',
|
||||
'-c --coerce',
|
||||
' Coerce a string into SemVer if possible',
|
||||
' (does not imply --loose)',
|
||||
'',
|
||||
'--rtl',
|
||||
' Coerce version strings right to left',
|
||||
'',
|
||||
'--ltr',
|
||||
' Coerce version strings left to right (default)',
|
||||
'',
|
||||
'Program exits successfully if any valid version satisfies',
|
||||
'all supplied ranges, and prints all satisfying versions.',
|
||||
'',
|
||||
'If no satisfying versions are found, then exits failure.',
|
||||
'',
|
||||
'Versions are printed in ascending order, so supplying',
|
||||
'multiple versions to the utility will just sort them.'
|
||||
].join('\n'))
|
||||
}
|
||||
+17
-16
@@ -1,29 +1,30 @@
|
||||
{
|
||||
"_from": "semver@^5.5.0",
|
||||
"_id": "semver@5.7.1",
|
||||
"_from": "semver",
|
||||
"_id": "semver@6.3.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
|
||||
"_integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
|
||||
"_location": "/semver",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "semver@^5.5.0",
|
||||
"raw": "semver",
|
||||
"name": "semver",
|
||||
"escapedName": "semver",
|
||||
"rawSpec": "^5.5.0",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^5.5.0"
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/cross-spawn"
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
|
||||
"_shasum": "a954f931aeba508d307bbf069eff0c01c96116f7",
|
||||
"_spec": "semver@^5.5.0",
|
||||
"_where": "C:\\Users\\lzy\\Documents\\Source\\OpportunityLiu\\github-action-setup-xmake\\node_modules\\cross-spawn",
|
||||
"_resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||
"_shasum": "ee0a64c8af5e8ceea67687b133761e1becbd1d3d",
|
||||
"_spec": "semver",
|
||||
"_where": "C:\\Users\\lzy\\Documents\\Source\\OpportunityLiu\\github-action-setup-xmake",
|
||||
"bin": {
|
||||
"semver": "./bin/semver"
|
||||
"semver": "./bin/semver.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/npm/node-semver/issues"
|
||||
@@ -32,7 +33,7 @@
|
||||
"deprecated": false,
|
||||
"description": "The semantic version parser used by npm.",
|
||||
"devDependencies": {
|
||||
"tap": "^13.0.0-rc.18"
|
||||
"tap": "^14.3.1"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
@@ -48,7 +49,7 @@
|
||||
"url": "git+https://github.com/npm/node-semver.git"
|
||||
},
|
||||
"scripts": {
|
||||
"postpublish": "git push origin --all; git push origin --tags",
|
||||
"postpublish": "git push origin --follow-tags",
|
||||
"postversion": "npm publish",
|
||||
"preversion": "npm test",
|
||||
"test": "tap"
|
||||
@@ -56,5 +57,5 @@
|
||||
"tap": {
|
||||
"check-coverage": true
|
||||
},
|
||||
"version": "5.7.1"
|
||||
"version": "6.3.0"
|
||||
}
|
||||
|
||||
+248
-135
@@ -29,75 +29,80 @@ var MAX_SAFE_COMPONENT_LENGTH = 16
|
||||
// The actual regexps go on exports.re
|
||||
var re = exports.re = []
|
||||
var src = exports.src = []
|
||||
var t = exports.tokens = {}
|
||||
var R = 0
|
||||
|
||||
function tok (n) {
|
||||
t[n] = R++
|
||||
}
|
||||
|
||||
// The following Regular Expressions can be used for tokenizing,
|
||||
// validating, and parsing SemVer version strings.
|
||||
|
||||
// ## Numeric Identifier
|
||||
// A single `0`, or a non-zero digit followed by zero or more digits.
|
||||
|
||||
var NUMERICIDENTIFIER = R++
|
||||
src[NUMERICIDENTIFIER] = '0|[1-9]\\d*'
|
||||
var NUMERICIDENTIFIERLOOSE = R++
|
||||
src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'
|
||||
tok('NUMERICIDENTIFIER')
|
||||
src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*'
|
||||
tok('NUMERICIDENTIFIERLOOSE')
|
||||
src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+'
|
||||
|
||||
// ## Non-numeric Identifier
|
||||
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
||||
// more letters, digits, or hyphens.
|
||||
|
||||
var NONNUMERICIDENTIFIER = R++
|
||||
src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'
|
||||
tok('NONNUMERICIDENTIFIER')
|
||||
src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'
|
||||
|
||||
// ## Main Version
|
||||
// Three dot-separated numeric identifiers.
|
||||
|
||||
var MAINVERSION = R++
|
||||
src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' +
|
||||
'(' + src[NUMERICIDENTIFIER] + ')\\.' +
|
||||
'(' + src[NUMERICIDENTIFIER] + ')'
|
||||
tok('MAINVERSION')
|
||||
src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
|
||||
'(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
|
||||
'(' + src[t.NUMERICIDENTIFIER] + ')'
|
||||
|
||||
var MAINVERSIONLOOSE = R++
|
||||
src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
||||
'(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
||||
'(' + src[NUMERICIDENTIFIERLOOSE] + ')'
|
||||
tok('MAINVERSIONLOOSE')
|
||||
src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
||||
'(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
||||
'(' + src[t.NUMERICIDENTIFIERLOOSE] + ')'
|
||||
|
||||
// ## Pre-release Version Identifier
|
||||
// A numeric identifier, or a non-numeric identifier.
|
||||
|
||||
var PRERELEASEIDENTIFIER = R++
|
||||
src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] +
|
||||
'|' + src[NONNUMERICIDENTIFIER] + ')'
|
||||
tok('PRERELEASEIDENTIFIER')
|
||||
src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
|
||||
'|' + src[t.NONNUMERICIDENTIFIER] + ')'
|
||||
|
||||
var PRERELEASEIDENTIFIERLOOSE = R++
|
||||
src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] +
|
||||
'|' + src[NONNUMERICIDENTIFIER] + ')'
|
||||
tok('PRERELEASEIDENTIFIERLOOSE')
|
||||
src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
|
||||
'|' + src[t.NONNUMERICIDENTIFIER] + ')'
|
||||
|
||||
// ## Pre-release Version
|
||||
// Hyphen, followed by one or more dot-separated pre-release version
|
||||
// identifiers.
|
||||
|
||||
var PRERELEASE = R++
|
||||
src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] +
|
||||
'(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))'
|
||||
tok('PRERELEASE')
|
||||
src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
|
||||
'(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))'
|
||||
|
||||
var PRERELEASELOOSE = R++
|
||||
src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] +
|
||||
'(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'
|
||||
tok('PRERELEASELOOSE')
|
||||
src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
|
||||
'(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))'
|
||||
|
||||
// ## Build Metadata Identifier
|
||||
// Any combination of digits, letters, or hyphens.
|
||||
|
||||
var BUILDIDENTIFIER = R++
|
||||
src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'
|
||||
tok('BUILDIDENTIFIER')
|
||||
src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+'
|
||||
|
||||
// ## Build Metadata
|
||||
// Plus sign, followed by one or more period-separated build metadata
|
||||
// identifiers.
|
||||
|
||||
var BUILD = R++
|
||||
src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] +
|
||||
'(?:\\.' + src[BUILDIDENTIFIER] + ')*))'
|
||||
tok('BUILD')
|
||||
src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
|
||||
'(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))'
|
||||
|
||||
// ## Full Version String
|
||||
// A main version, followed optionally by a pre-release version and
|
||||
@@ -108,129 +113,133 @@ src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] +
|
||||
// capturing group, because it should not ever be used in version
|
||||
// comparison.
|
||||
|
||||
var FULL = R++
|
||||
var FULLPLAIN = 'v?' + src[MAINVERSION] +
|
||||
src[PRERELEASE] + '?' +
|
||||
src[BUILD] + '?'
|
||||
tok('FULL')
|
||||
tok('FULLPLAIN')
|
||||
src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
|
||||
src[t.PRERELEASE] + '?' +
|
||||
src[t.BUILD] + '?'
|
||||
|
||||
src[FULL] = '^' + FULLPLAIN + '$'
|
||||
src[t.FULL] = '^' + src[t.FULLPLAIN] + '$'
|
||||
|
||||
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
||||
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
||||
// common in the npm registry.
|
||||
var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] +
|
||||
src[PRERELEASELOOSE] + '?' +
|
||||
src[BUILD] + '?'
|
||||
tok('LOOSEPLAIN')
|
||||
src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
|
||||
src[t.PRERELEASELOOSE] + '?' +
|
||||
src[t.BUILD] + '?'
|
||||
|
||||
var LOOSE = R++
|
||||
src[LOOSE] = '^' + LOOSEPLAIN + '$'
|
||||
tok('LOOSE')
|
||||
src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$'
|
||||
|
||||
var GTLT = R++
|
||||
src[GTLT] = '((?:<|>)?=?)'
|
||||
tok('GTLT')
|
||||
src[t.GTLT] = '((?:<|>)?=?)'
|
||||
|
||||
// Something like "2.*" or "1.2.x".
|
||||
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
||||
// Only the first item is strictly required.
|
||||
var XRANGEIDENTIFIERLOOSE = R++
|
||||
src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'
|
||||
var XRANGEIDENTIFIER = R++
|
||||
src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*'
|
||||
tok('XRANGEIDENTIFIERLOOSE')
|
||||
src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'
|
||||
tok('XRANGEIDENTIFIER')
|
||||
src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*'
|
||||
|
||||
var XRANGEPLAIN = R++
|
||||
src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' +
|
||||
'(?:\\.(' + src[XRANGEIDENTIFIER] + ')' +
|
||||
'(?:\\.(' + src[XRANGEIDENTIFIER] + ')' +
|
||||
'(?:' + src[PRERELEASE] + ')?' +
|
||||
src[BUILD] + '?' +
|
||||
tok('XRANGEPLAIN')
|
||||
src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
|
||||
'(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
|
||||
'(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
|
||||
'(?:' + src[t.PRERELEASE] + ')?' +
|
||||
src[t.BUILD] + '?' +
|
||||
')?)?'
|
||||
|
||||
var XRANGEPLAINLOOSE = R++
|
||||
src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
|
||||
'(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
|
||||
'(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
|
||||
'(?:' + src[PRERELEASELOOSE] + ')?' +
|
||||
src[BUILD] + '?' +
|
||||
tok('XRANGEPLAINLOOSE')
|
||||
src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
|
||||
'(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
|
||||
'(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
|
||||
'(?:' + src[t.PRERELEASELOOSE] + ')?' +
|
||||
src[t.BUILD] + '?' +
|
||||
')?)?'
|
||||
|
||||
var XRANGE = R++
|
||||
src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$'
|
||||
var XRANGELOOSE = R++
|
||||
src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'
|
||||
tok('XRANGE')
|
||||
src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$'
|
||||
tok('XRANGELOOSE')
|
||||
src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$'
|
||||
|
||||
// Coercion.
|
||||
// Extract anything that could conceivably be a part of a valid semver
|
||||
var COERCE = R++
|
||||
src[COERCE] = '(?:^|[^\\d])' +
|
||||
tok('COERCE')
|
||||
src[t.COERCE] = '(^|[^\\d])' +
|
||||
'(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
|
||||
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
||||
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
||||
'(?:$|[^\\d])'
|
||||
tok('COERCERTL')
|
||||
re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g')
|
||||
|
||||
// Tilde ranges.
|
||||
// Meaning is "reasonably at or greater than"
|
||||
var LONETILDE = R++
|
||||
src[LONETILDE] = '(?:~>?)'
|
||||
tok('LONETILDE')
|
||||
src[t.LONETILDE] = '(?:~>?)'
|
||||
|
||||
var TILDETRIM = R++
|
||||
src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+'
|
||||
re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g')
|
||||
tok('TILDETRIM')
|
||||
src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+'
|
||||
re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g')
|
||||
var tildeTrimReplace = '$1~'
|
||||
|
||||
var TILDE = R++
|
||||
src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$'
|
||||
var TILDELOOSE = R++
|
||||
src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'
|
||||
tok('TILDE')
|
||||
src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$'
|
||||
tok('TILDELOOSE')
|
||||
src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$'
|
||||
|
||||
// Caret ranges.
|
||||
// Meaning is "at least and backwards compatible with"
|
||||
var LONECARET = R++
|
||||
src[LONECARET] = '(?:\\^)'
|
||||
tok('LONECARET')
|
||||
src[t.LONECARET] = '(?:\\^)'
|
||||
|
||||
var CARETTRIM = R++
|
||||
src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+'
|
||||
re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g')
|
||||
tok('CARETTRIM')
|
||||
src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+'
|
||||
re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g')
|
||||
var caretTrimReplace = '$1^'
|
||||
|
||||
var CARET = R++
|
||||
src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$'
|
||||
var CARETLOOSE = R++
|
||||
src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'
|
||||
tok('CARET')
|
||||
src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$'
|
||||
tok('CARETLOOSE')
|
||||
src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$'
|
||||
|
||||
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
||||
var COMPARATORLOOSE = R++
|
||||
src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$'
|
||||
var COMPARATOR = R++
|
||||
src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'
|
||||
tok('COMPARATORLOOSE')
|
||||
src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$'
|
||||
tok('COMPARATOR')
|
||||
src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$'
|
||||
|
||||
// An expression to strip any whitespace between the gtlt and the thing
|
||||
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
||||
var COMPARATORTRIM = R++
|
||||
src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] +
|
||||
'\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'
|
||||
tok('COMPARATORTRIM')
|
||||
src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
|
||||
'\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')'
|
||||
|
||||
// this one has to use the /g flag
|
||||
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g')
|
||||
re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g')
|
||||
var comparatorTrimReplace = '$1$2$3'
|
||||
|
||||
// Something like `1.2.3 - 1.2.4`
|
||||
// Note that these all use the loose form, because they'll be
|
||||
// checked against either the strict or loose comparator form
|
||||
// later.
|
||||
var HYPHENRANGE = R++
|
||||
src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' +
|
||||
tok('HYPHENRANGE')
|
||||
src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
|
||||
'\\s+-\\s+' +
|
||||
'(' + src[XRANGEPLAIN] + ')' +
|
||||
'(' + src[t.XRANGEPLAIN] + ')' +
|
||||
'\\s*$'
|
||||
|
||||
var HYPHENRANGELOOSE = R++
|
||||
src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' +
|
||||
tok('HYPHENRANGELOOSE')
|
||||
src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
|
||||
'\\s+-\\s+' +
|
||||
'(' + src[XRANGEPLAINLOOSE] + ')' +
|
||||
'(' + src[t.XRANGEPLAINLOOSE] + ')' +
|
||||
'\\s*$'
|
||||
|
||||
// Star ranges basically just allow anything at all.
|
||||
var STAR = R++
|
||||
src[STAR] = '(<|>)?=?\\s*\\*'
|
||||
tok('STAR')
|
||||
src[t.STAR] = '(<|>)?=?\\s*\\*'
|
||||
|
||||
// Compile to actual regexp objects.
|
||||
// All are flag-free, unless they were created above with a flag.
|
||||
@@ -262,7 +271,7 @@ function parse (version, options) {
|
||||
return null
|
||||
}
|
||||
|
||||
var r = options.loose ? re[LOOSE] : re[FULL]
|
||||
var r = options.loose ? re[t.LOOSE] : re[t.FULL]
|
||||
if (!r.test(version)) {
|
||||
return null
|
||||
}
|
||||
@@ -317,7 +326,7 @@ function SemVer (version, options) {
|
||||
this.options = options
|
||||
this.loose = !!options.loose
|
||||
|
||||
var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL])
|
||||
var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])
|
||||
|
||||
if (!m) {
|
||||
throw new TypeError('Invalid Version: ' + version)
|
||||
@@ -425,6 +434,30 @@ SemVer.prototype.comparePre = function (other) {
|
||||
} while (++i)
|
||||
}
|
||||
|
||||
SemVer.prototype.compareBuild = function (other) {
|
||||
if (!(other instanceof SemVer)) {
|
||||
other = new SemVer(other, this.options)
|
||||
}
|
||||
|
||||
var i = 0
|
||||
do {
|
||||
var a = this.build[i]
|
||||
var b = other.build[i]
|
||||
debug('prerelease compare', i, a, b)
|
||||
if (a === undefined && b === undefined) {
|
||||
return 0
|
||||
} else if (b === undefined) {
|
||||
return 1
|
||||
} else if (a === undefined) {
|
||||
return -1
|
||||
} else if (a === b) {
|
||||
continue
|
||||
} else {
|
||||
return compareIdentifiers(a, b)
|
||||
}
|
||||
} while (++i)
|
||||
}
|
||||
|
||||
// preminor will bump the version up to the next minor release, and immediately
|
||||
// down to pre-release. premajor and prepatch work the same way.
|
||||
SemVer.prototype.inc = function (release, identifier) {
|
||||
@@ -619,6 +652,13 @@ function compareLoose (a, b) {
|
||||
return compare(a, b, true)
|
||||
}
|
||||
|
||||
exports.compareBuild = compareBuild
|
||||
function compareBuild (a, b, loose) {
|
||||
var versionA = new SemVer(a, loose)
|
||||
var versionB = new SemVer(b, loose)
|
||||
return versionA.compare(versionB) || versionA.compareBuild(versionB)
|
||||
}
|
||||
|
||||
exports.rcompare = rcompare
|
||||
function rcompare (a, b, loose) {
|
||||
return compare(b, a, loose)
|
||||
@@ -627,14 +667,14 @@ function rcompare (a, b, loose) {
|
||||
exports.sort = sort
|
||||
function sort (list, loose) {
|
||||
return list.sort(function (a, b) {
|
||||
return exports.compare(a, b, loose)
|
||||
return exports.compareBuild(a, b, loose)
|
||||
})
|
||||
}
|
||||
|
||||
exports.rsort = rsort
|
||||
function rsort (list, loose) {
|
||||
return list.sort(function (a, b) {
|
||||
return exports.rcompare(a, b, loose)
|
||||
return exports.compareBuild(b, a, loose)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -747,14 +787,14 @@ function Comparator (comp, options) {
|
||||
|
||||
var ANY = {}
|
||||
Comparator.prototype.parse = function (comp) {
|
||||
var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
|
||||
var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
|
||||
var m = comp.match(r)
|
||||
|
||||
if (!m) {
|
||||
throw new TypeError('Invalid comparator: ' + comp)
|
||||
}
|
||||
|
||||
this.operator = m[1]
|
||||
this.operator = m[1] !== undefined ? m[1] : ''
|
||||
if (this.operator === '=') {
|
||||
this.operator = ''
|
||||
}
|
||||
@@ -774,12 +814,16 @@ Comparator.prototype.toString = function () {
|
||||
Comparator.prototype.test = function (version) {
|
||||
debug('Comparator.test', version, this.options.loose)
|
||||
|
||||
if (this.semver === ANY) {
|
||||
if (this.semver === ANY || version === ANY) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (typeof version === 'string') {
|
||||
version = new SemVer(version, this.options)
|
||||
try {
|
||||
version = new SemVer(version, this.options)
|
||||
} catch (er) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return cmp(version, this.operator, this.semver, this.options)
|
||||
@@ -800,9 +844,15 @@ Comparator.prototype.intersects = function (comp, options) {
|
||||
var rangeTmp
|
||||
|
||||
if (this.operator === '') {
|
||||
if (this.value === '') {
|
||||
return true
|
||||
}
|
||||
rangeTmp = new Range(comp.value, options)
|
||||
return satisfies(this.value, rangeTmp, options)
|
||||
} else if (comp.operator === '') {
|
||||
if (comp.value === '') {
|
||||
return true
|
||||
}
|
||||
rangeTmp = new Range(this.value, options)
|
||||
return satisfies(comp.semver, rangeTmp, options)
|
||||
}
|
||||
@@ -892,18 +942,18 @@ Range.prototype.parseRange = function (range) {
|
||||
var loose = this.options.loose
|
||||
range = range.trim()
|
||||
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
||||
var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE]
|
||||
var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
|
||||
range = range.replace(hr, hyphenReplace)
|
||||
debug('hyphen replace', range)
|
||||
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
||||
range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace)
|
||||
debug('comparator trim', range, re[COMPARATORTRIM])
|
||||
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
|
||||
debug('comparator trim', range, re[t.COMPARATORTRIM])
|
||||
|
||||
// `~ 1.2.3` => `~1.2.3`
|
||||
range = range.replace(re[TILDETRIM], tildeTrimReplace)
|
||||
range = range.replace(re[t.TILDETRIM], tildeTrimReplace)
|
||||
|
||||
// `^ 1.2.3` => `^1.2.3`
|
||||
range = range.replace(re[CARETTRIM], caretTrimReplace)
|
||||
range = range.replace(re[t.CARETTRIM], caretTrimReplace)
|
||||
|
||||
// normalize spaces
|
||||
range = range.split(/\s+/).join(' ')
|
||||
@@ -911,7 +961,7 @@ Range.prototype.parseRange = function (range) {
|
||||
// At this point, the range is completely trimmed and
|
||||
// ready to be split into comparators.
|
||||
|
||||
var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
|
||||
var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
|
||||
var set = range.split(' ').map(function (comp) {
|
||||
return parseComparator(comp, this.options)
|
||||
}, this).join(' ').split(/\s+/)
|
||||
@@ -934,16 +984,40 @@ Range.prototype.intersects = function (range, options) {
|
||||
}
|
||||
|
||||
return this.set.some(function (thisComparators) {
|
||||
return thisComparators.every(function (thisComparator) {
|
||||
return range.set.some(function (rangeComparators) {
|
||||
return rangeComparators.every(function (rangeComparator) {
|
||||
return thisComparator.intersects(rangeComparator, options)
|
||||
})
|
||||
return (
|
||||
isSatisfiable(thisComparators, options) &&
|
||||
range.set.some(function (rangeComparators) {
|
||||
return (
|
||||
isSatisfiable(rangeComparators, options) &&
|
||||
thisComparators.every(function (thisComparator) {
|
||||
return rangeComparators.every(function (rangeComparator) {
|
||||
return thisComparator.intersects(rangeComparator, options)
|
||||
})
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// take a set of comparators and determine whether there
|
||||
// exists a version which can satisfy it
|
||||
function isSatisfiable (comparators, options) {
|
||||
var result = true
|
||||
var remainingComparators = comparators.slice()
|
||||
var testComparator = remainingComparators.pop()
|
||||
|
||||
while (result && remainingComparators.length) {
|
||||
result = remainingComparators.every(function (otherComparator) {
|
||||
return testComparator.intersects(otherComparator, options)
|
||||
})
|
||||
|
||||
testComparator = remainingComparators.pop()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// Mostly just for testing and legacy API reasons
|
||||
exports.toComparators = toComparators
|
||||
function toComparators (range, options) {
|
||||
@@ -987,7 +1061,7 @@ function replaceTildes (comp, options) {
|
||||
}
|
||||
|
||||
function replaceTilde (comp, options) {
|
||||
var r = options.loose ? re[TILDELOOSE] : re[TILDE]
|
||||
var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
|
||||
return comp.replace(r, function (_, M, m, p, pr) {
|
||||
debug('tilde', comp, _, M, m, p, pr)
|
||||
var ret
|
||||
@@ -1028,7 +1102,7 @@ function replaceCarets (comp, options) {
|
||||
|
||||
function replaceCaret (comp, options) {
|
||||
debug('caret', comp, options)
|
||||
var r = options.loose ? re[CARETLOOSE] : re[CARET]
|
||||
var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]
|
||||
return comp.replace(r, function (_, M, m, p, pr) {
|
||||
debug('caret', comp, _, M, m, p, pr)
|
||||
var ret
|
||||
@@ -1087,7 +1161,7 @@ function replaceXRanges (comp, options) {
|
||||
|
||||
function replaceXRange (comp, options) {
|
||||
comp = comp.trim()
|
||||
var r = options.loose ? re[XRANGELOOSE] : re[XRANGE]
|
||||
var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]
|
||||
return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
|
||||
debug('xRange', comp, ret, gtlt, M, m, p, pr)
|
||||
var xM = isX(M)
|
||||
@@ -1099,10 +1173,14 @@ function replaceXRange (comp, options) {
|
||||
gtlt = ''
|
||||
}
|
||||
|
||||
// if we're including prereleases in the match, then we need
|
||||
// to fix this to -0, the lowest possible prerelease value
|
||||
pr = options.includePrerelease ? '-0' : ''
|
||||
|
||||
if (xM) {
|
||||
if (gtlt === '>' || gtlt === '<') {
|
||||
// nothing is allowed
|
||||
ret = '<0.0.0'
|
||||
ret = '<0.0.0-0'
|
||||
} else {
|
||||
// nothing is forbidden
|
||||
ret = '*'
|
||||
@@ -1139,11 +1217,12 @@ function replaceXRange (comp, options) {
|
||||
}
|
||||
}
|
||||
|
||||
ret = gtlt + M + '.' + m + '.' + p
|
||||
ret = gtlt + M + '.' + m + '.' + p + pr
|
||||
} else if (xm) {
|
||||
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
||||
ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr
|
||||
} else if (xp) {
|
||||
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
||||
ret = '>=' + M + '.' + m + '.0' + pr +
|
||||
' <' + M + '.' + (+m + 1) + '.0' + pr
|
||||
}
|
||||
|
||||
debug('xRange return', ret)
|
||||
@@ -1157,10 +1236,10 @@ function replaceXRange (comp, options) {
|
||||
function replaceStars (comp, options) {
|
||||
debug('replaceStars', comp, options)
|
||||
// Looseness is ignored here. star is always as loose as it gets!
|
||||
return comp.trim().replace(re[STAR], '')
|
||||
return comp.trim().replace(re[t.STAR], '')
|
||||
}
|
||||
|
||||
// This function is passed to string.replace(re[HYPHENRANGE])
|
||||
// This function is passed to string.replace(re[t.HYPHENRANGE])
|
||||
// M, m, patch, prerelease, build
|
||||
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
||||
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
|
||||
@@ -1200,7 +1279,11 @@ Range.prototype.test = function (version) {
|
||||
}
|
||||
|
||||
if (typeof version === 'string') {
|
||||
version = new SemVer(version, this.options)
|
||||
try {
|
||||
version = new SemVer(version, this.options)
|
||||
} catch (er) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < this.set.length; i++) {
|
||||
@@ -1462,22 +1545,52 @@ function intersects (r1, r2, options) {
|
||||
}
|
||||
|
||||
exports.coerce = coerce
|
||||
function coerce (version) {
|
||||
function coerce (version, options) {
|
||||
if (version instanceof SemVer) {
|
||||
return version
|
||||
}
|
||||
|
||||
if (typeof version === 'number') {
|
||||
version = String(version)
|
||||
}
|
||||
|
||||
if (typeof version !== 'string') {
|
||||
return null
|
||||
}
|
||||
|
||||
var match = version.match(re[COERCE])
|
||||
options = options || {}
|
||||
|
||||
if (match == null) {
|
||||
var match = null
|
||||
if (!options.rtl) {
|
||||
match = version.match(re[t.COERCE])
|
||||
} else {
|
||||
// Find the right-most coercible string that does not share
|
||||
// a terminus with a more left-ward coercible string.
|
||||
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
|
||||
//
|
||||
// Walk through the string checking with a /g regexp
|
||||
// Manually set the index so as to pick up overlapping matches.
|
||||
// Stop when we get a match that ends at the string end, since no
|
||||
// coercible string can be more right-ward without the same terminus.
|
||||
var next
|
||||
while ((next = re[t.COERCERTL].exec(version)) &&
|
||||
(!match || match.index + match[0].length !== version.length)
|
||||
) {
|
||||
if (!match ||
|
||||
next.index + next[0].length !== match.index + match[0].length) {
|
||||
match = next
|
||||
}
|
||||
re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length
|
||||
}
|
||||
// leave it in a clean state
|
||||
re[t.COERCERTL].lastIndex = -1
|
||||
}
|
||||
|
||||
if (match === null) {
|
||||
return null
|
||||
}
|
||||
|
||||
return parse(match[1] +
|
||||
'.' + (match[2] || '0') +
|
||||
'.' + (match[3] || '0'))
|
||||
return parse(match[2] +
|
||||
'.' + (match[3] || '0') +
|
||||
'.' + (match[4] || '0'), options)
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Steve King
|
||||
|
||||
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.
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"_from": "simple-git",
|
||||
"_id": "simple-git@1.126.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-47mqHxgZnN8XRa9HbpWprzUv3Ooqz9RY/LSZgvA7jCkW8jcwLahMz7LKugY91KZehfG0sCVPtgXiU72hd6b1Bw==",
|
||||
"_location": "/simple-git",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "simple-git",
|
||||
"name": "simple-git",
|
||||
"escapedName": "simple-git",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/simple-git/-/simple-git-1.126.0.tgz",
|
||||
"_shasum": "0c345372275139c8433b8277f4b3e155092aa434",
|
||||
"_spec": "simple-git",
|
||||
"_where": "C:\\Users\\lzy\\Documents\\Source\\OpportunityLiu\\github-action-setup-xmake",
|
||||
"author": {
|
||||
"name": "Steve King",
|
||||
"email": "steve@mydev.co"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/steveukx/git-js/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Steve King",
|
||||
"email": "steve@mydev.co"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"debug": "^4.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Simple GIT interface for node.js",
|
||||
"devDependencies": {
|
||||
"@kwsites/test-runner": "^0.1.1",
|
||||
"sinon": "^7.3.2"
|
||||
},
|
||||
"files": [
|
||||
"promise.*",
|
||||
"src/",
|
||||
"typings/"
|
||||
],
|
||||
"homepage": "https://github.com/steveukx/git-js#readme",
|
||||
"keywords": [
|
||||
"git",
|
||||
"source control",
|
||||
"vcs"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./src/index.js",
|
||||
"name": "simple-git",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/steveukx/git-js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"postversion": "npm publish && git push && git push --tags",
|
||||
"preversion": "yarn test",
|
||||
"test": "runner test/**/test*.js ",
|
||||
"test:integration": "runner test/integration/test*.js",
|
||||
"test:unit": "runner test/unit/test*.js"
|
||||
},
|
||||
"version": "1.126.0"
|
||||
}
|
||||
+576
@@ -0,0 +1,576 @@
|
||||
import * as resp from "./typings/response";
|
||||
|
||||
declare function simplegit(basePath?: string): simplegit.SimpleGit;
|
||||
|
||||
declare namespace simplegit {
|
||||
|
||||
interface SimpleGit {
|
||||
/**
|
||||
* Adds one or more files to source control
|
||||
*
|
||||
* @param {string|string[]} files
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
add(files: string | string[]): Promise<void>;
|
||||
|
||||
/**
|
||||
* Add an annotated tag to the head of the current branch
|
||||
*
|
||||
* @param {string} tagName
|
||||
* @param {string} tagMessage
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
addAnnotatedTag(tagName: string, tagMessage: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Add config to local git instance
|
||||
*
|
||||
* @param {string} key configuration key (e.g user.name)
|
||||
* @param {string} value for the given key (e.g your name)
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
addConfig(key: string, value: string): Promise<string>;
|
||||
|
||||
/**
|
||||
* Adds a remote to the list of remotes.
|
||||
*
|
||||
* @param {string} remoteName Name of the repository - eg "upstream"
|
||||
* @param {string} remoteRepo Fully qualified SSH or HTTP(S) path to the remote repo
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
addRemote(remoteName: string, remoteRepo: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Add a lightweight tag to the head of the current branch
|
||||
*
|
||||
* @param {string} name
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
addTag(name: string): Promise<string>;
|
||||
|
||||
/**
|
||||
* Equivalent to `catFile` but will return the native `Buffer` of content from the git command's stdout.
|
||||
*
|
||||
* @param {string[]} options
|
||||
*/
|
||||
binaryCatFile(options: string[]): Promise<any>;
|
||||
|
||||
/**
|
||||
* List all branches
|
||||
*
|
||||
* @param {Object | string[]} [options]
|
||||
* @returns {Promise<BranchSummary>}
|
||||
*/
|
||||
branch(options: Options | string[]): Promise<BranchSummary>;
|
||||
|
||||
/**
|
||||
* List of local branches
|
||||
*
|
||||
* @returns {Promise<BranchSummary>}
|
||||
*/
|
||||
branchLocal(): Promise<BranchSummary>;
|
||||
|
||||
/**
|
||||
* Returns a list of objects in a tree based on commit hash.
|
||||
* Passing in an object hash returns the object's content, size, and type.
|
||||
*
|
||||
* Passing "-p" will instruct cat-file to determine the object type, and display its formatted contents.
|
||||
*
|
||||
* @param {string[]} [options]
|
||||
* @returns {Promise<string>}
|
||||
*
|
||||
* @see https://git-scm.com/docs/git-cat-file
|
||||
*/
|
||||
catFile(options: string[]): Promise<string>;
|
||||
|
||||
/**
|
||||
* Check if a pathname or pathnames are excluded by .gitignore
|
||||
*
|
||||
* @param {string|string[]} pathnames
|
||||
*/
|
||||
checkIgnore(pathnames: string[]): Promise<string[]>;
|
||||
|
||||
checkIgnore(path: string): Promise<string[]>;
|
||||
|
||||
/**
|
||||
* Validates that the current repo is a Git repo.
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
checkIsRepo(): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Checkout a tag or revision, any number of additional arguments can be passed to the `git* checkout` command
|
||||
by supplying either a string or array of strings as the `what` parameter.
|
||||
*
|
||||
* @param {(string | string[])} what one or more commands to pass to `git checkout`.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
checkout(what: string | string[]): Promise<void>;
|
||||
|
||||
/**
|
||||
* Checkout a remote branch.
|
||||
*
|
||||
* @param {string} branchName name of branch.
|
||||
* @param {string} startPoint (e.g origin/development).
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
checkoutBranch(branchName: string, startPoint: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Internally uses pull and tags to get the list of tags then checks out the latest tag.
|
||||
*/
|
||||
checkoutLatestTag(branchName: string, startPoint: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Checkout a local branch
|
||||
*
|
||||
* @param {string} branchName name of branch.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
checkoutLocalBranch(branchName: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* @param {string} mode Required parameter "n" or "f"
|
||||
* @param {string[]} options
|
||||
*/
|
||||
clean(
|
||||
mode: 'd' | 'f' | 'i' | 'n' | 'q' | 'x' | 'X',
|
||||
options?: string[]
|
||||
): Promise<string>;
|
||||
|
||||
/**
|
||||
* Clears the queue of pending commands and returns the wrapper instance for chaining.
|
||||
*/
|
||||
clearQueue(): this;
|
||||
|
||||
/**
|
||||
* Clone a repository into a new directory.
|
||||
*
|
||||
* @param {string} repoPath repository url to clone e.g. https://github.com/steveukx/git-js.git
|
||||
* @param {string} localPath local folder path to clone to.
|
||||
* @param {string[]} [options] options supported by [git](https://git-scm.com/docs/git-clone).
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
clone(repoPath: string, localPath: string, options?: Options | string[]): Promise<string>;
|
||||
clone(repoPath: string, options?: Options | string[]): Promise<string>;
|
||||
|
||||
/**
|
||||
* Commits changes in the current working directory - when specific file paths are supplied, only changes on those
|
||||
* files will be committed.
|
||||
*
|
||||
* @param {string|string[]} message
|
||||
* @param {string|string[]} [files]
|
||||
* @param {Object} [options]
|
||||
*/
|
||||
commit(
|
||||
message: string | string[],
|
||||
files?: string | string[],
|
||||
options?: Options
|
||||
): Promise<resp.CommitSummary>;
|
||||
|
||||
/**
|
||||
* Sets the path to a custom git binary, should either be `git` when there is an installation of git available on
|
||||
* the system path, or a fully qualified path to the executable.
|
||||
*
|
||||
* @param {string} command
|
||||
*/
|
||||
customBinary(command: string): this;
|
||||
|
||||
/**
|
||||
* Sets the working directory of the subsequent commands.
|
||||
*
|
||||
* @param {string} workingDirectory
|
||||
*/
|
||||
cwd<path extends string>(workingDirectory: path): Promise<path>;
|
||||
|
||||
/**
|
||||
* Delete a local branch
|
||||
*
|
||||
* @param {string} branchName name of branch
|
||||
*/
|
||||
deleteLocalBranch(branchName: string):
|
||||
Promise<resp.BranchDeletionSummary>;
|
||||
|
||||
/**
|
||||
* Get the diff of the current repo compared to the last commit with a set of options supplied as a string.
|
||||
*
|
||||
* @param {string[]} [options] options supported by [git](https://git-scm.com/docs/git-diff).
|
||||
* @returns {Promise<string>} raw string result.
|
||||
*/
|
||||
diff(options?: string[]): Promise<string>;
|
||||
|
||||
/**
|
||||
* Gets a summary of the diff for files in the repo, uses the `git diff --stat` format to calculate changes.
|
||||
*
|
||||
* in order to get staged (only): `--cached` or `--staged`.
|
||||
*
|
||||
* @param {string[]} [options] options supported by [git](https://git-scm.com/docs/git-diff).
|
||||
* @returns {Promise<DiffResult>} Parsed diff summary result.
|
||||
*/
|
||||
diffSummary(options?: string[]): Promise<DiffResult>;
|
||||
|
||||
/**
|
||||
* Sets an environment variable for the spawned child process, either supply both a name and value as strings or
|
||||
* a single object to entirely replace the current environment variables.
|
||||
*
|
||||
* @param {string|Object} name
|
||||
* @param {string} [value]
|
||||
*/
|
||||
env(name: string, value: string): this;
|
||||
|
||||
env(env: object): this;
|
||||
|
||||
/**
|
||||
* Updates the local working copy database with changes from the default remote repo and branch.
|
||||
*
|
||||
* @param {string | string[]} [remote] remote to fetch from.
|
||||
* @param {string} [branch] branch to fetch from.
|
||||
* @param {string[]} [options] options supported by [git](https://git-scm.com/docs/git-fetch).
|
||||
* @returns {Promise<FetchResult>} Parsed fetch result.
|
||||
*/
|
||||
fetch(remote?: string | string[], branch?: string, options?: Options): Promise<FetchResult>;
|
||||
|
||||
/**
|
||||
* Gets the currently available remotes, setting the optional verbose argument to true includes additional
|
||||
* detail on the remotes themselves.
|
||||
*
|
||||
* @param {boolean} [verbose=false]
|
||||
*/
|
||||
getRemotes(verbose: false | undefined): Promise<resp.RemoteWithoutRefs[]>;
|
||||
|
||||
getRemotes(verbose: true): Promise<resp.RemoteWithRefs[]>;
|
||||
|
||||
/**
|
||||
* Initialize a git repo
|
||||
*
|
||||
* @param {Boolean} [bare=false]
|
||||
*/
|
||||
init(bare?: boolean): Promise<void>;
|
||||
|
||||
/**
|
||||
* List remote
|
||||
*
|
||||
* @param {string[]} [args]
|
||||
*/
|
||||
listRemote(args: string[]): Promise<string>;
|
||||
|
||||
/**
|
||||
* Show commit logs from `HEAD` to the first commit.
|
||||
* If provided between `options.from` and `options.to` tags or branch.
|
||||
*
|
||||
* You can provide `options.file`, which is the path to a file in your repository. Then only this file will be considered.
|
||||
*
|
||||
* To use a custom splitter in the log format, set `options.splitter` to be the string the log should be split on.
|
||||
*
|
||||
* By default the following fields will be part of the result:
|
||||
* `hash`: full commit hash
|
||||
* `date`: author date, ISO 8601-like format
|
||||
* `message`: subject + ref names, like the --decorate option of git-log
|
||||
* `author_name`: author name
|
||||
* `author_email`: author mail
|
||||
* You can specify `options.format` to be an mapping from key to a format option like `%H` (for commit hash).
|
||||
* The fields specified in `options.format` will be the fields in the result.
|
||||
*
|
||||
* Options can also be supplied as a standard options object for adding custom properties supported by the git log command.
|
||||
* For any other set of options, supply options as an array of strings to be appended to the git log command.
|
||||
*
|
||||
* @param {LogOptions} [options]
|
||||
*
|
||||
* @returns Promise<ListLogSummary>
|
||||
*
|
||||
* @see https://git-scm.com/docs/git-log
|
||||
*/
|
||||
log<T = resp.DefaultLogFields>(options?: LogOptions<T>): Promise<resp.ListLogSummary<T>>;
|
||||
|
||||
/**
|
||||
* Runs a merge, `options` can be either an array of arguments
|
||||
* supported by the [`git merge`](https://git-scm.com/docs/git-merge)
|
||||
* or an options object.
|
||||
*
|
||||
* Conflicts during the merge result in an error response,
|
||||
* the response type whether it was an error or success will be a MergeSummary instance.
|
||||
* When successful, the MergeSummary has all detail from a the PullSummary
|
||||
*
|
||||
* @param {Options | string[]} [options] options supported by [git](https://git-scm.com/docs/git-merge).
|
||||
* @returns {Promise<any>}
|
||||
*
|
||||
* @see https://github.com/steveukx/git-js/blob/master/src/responses/MergeSummary.js
|
||||
* @see https://github.com/steveukx/git-js/blob/master/src/responses/PullSummary.js
|
||||
*/
|
||||
merge(options: Options | string[]): Promise<any>;
|
||||
|
||||
/**
|
||||
* Merges from one branch to another, equivalent to running `git merge ${from} $[to}`, the `options` argument can
|
||||
* either be an array of additional parameters to pass to the command or null / omitted to be ignored.
|
||||
*
|
||||
* @param {string} from branch to merge from.
|
||||
* @param {string} to branch to merge to.
|
||||
* @param {string[]} [options] options supported by [git](https://git-scm.com/docs/git-merge).
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
mergeFromTo(from: string, to: string, options?: string[]): Promise<string>;
|
||||
|
||||
/**
|
||||
* Mirror a git repo
|
||||
*
|
||||
* @param {string} repoPath
|
||||
* @param {string} localPath
|
||||
*/
|
||||
mirror(repoPath: string, localPath: string): Promise<string>;
|
||||
|
||||
/**
|
||||
* Moves one or more files to a new destination.
|
||||
*
|
||||
* @see https://git-scm.com/docs/git-mv
|
||||
*
|
||||
* @param {string|string[]} from
|
||||
* @param {string} to
|
||||
*/
|
||||
mv(from: string | string[], to: string): Promise<resp.MoveSummary>;
|
||||
|
||||
/**
|
||||
* Sets a handler function to be called whenever a new child process is created, the handler function will be called
|
||||
* with the name of the command being run and the stdout & stderr streams used by the ChildProcess.
|
||||
*
|
||||
* @example
|
||||
* require('simple-git')
|
||||
* .outputHandler(function (command, stdout, stderr) {
|
||||
* stdout.pipe(process.stdout);
|
||||
* })
|
||||
* .checkout('https://github.com/user/repo.git');
|
||||
*
|
||||
* @see http://nodejs.org/api/child_process.html#child_process_class_childprocess
|
||||
* @see http://nodejs.org/api/stream.html#stream_class_stream_readable
|
||||
* @param {Function} outputHandler
|
||||
*/
|
||||
outputHandler(handler: outputHandler | void): this;
|
||||
|
||||
/**
|
||||
* Fetch from and integrate with another repository or a local branch.
|
||||
*
|
||||
* @param {string} [remote] remote to pull from.
|
||||
* @param {string} [branch] branch to pull from.
|
||||
* @param {Options} [options] options supported by [git](https://git-scm.com/docs/git-pull).
|
||||
* @returns {Promise<PullResult>} Parsed pull result.
|
||||
*/
|
||||
pull(remote?: string, branch?: string, options?: Options): Promise<PullResult>;
|
||||
|
||||
/**
|
||||
* Update remote refs along with associated objects.
|
||||
*
|
||||
* @param {string} [remote] remote to push to.
|
||||
* @param {string} [branch] branch to push to.
|
||||
* @param {Options} [options] options supported by [git](https://git-scm.com/docs/git-push).
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
push(remote?: string, branch?: string, options?: Options): Promise<void>;
|
||||
|
||||
/**
|
||||
* Pushes the current tag changes to a remote which can be either a URL or named remote. When not specified uses the
|
||||
* default configured remote spec.
|
||||
*
|
||||
* @param {string} [remote]
|
||||
*/
|
||||
pushTags(remote?: string): Promise<string>;
|
||||
|
||||
/**
|
||||
* Executes any command against the git binary.
|
||||
*
|
||||
* @param {string[]|Object} commands
|
||||
*/
|
||||
raw(commands: string | string[]): Promise<string>;
|
||||
|
||||
/**
|
||||
* Rebases the current working copy. Options can be supplied either as an array of string parameters
|
||||
* to be sent to the `git rebase` command, or a standard options object.
|
||||
*
|
||||
* @param {Object|String[]} [options]
|
||||
*/
|
||||
rebase(options?: Options | string[]): Promise<string>;
|
||||
|
||||
/**
|
||||
* Call any `git remote` function with arguments passed as an array of strings.
|
||||
*
|
||||
* @param {string[]} options
|
||||
*/
|
||||
remote(options: string[]): Promise<void | string>;
|
||||
|
||||
/**
|
||||
* Removes an entry from the list of remotes.
|
||||
*
|
||||
* @param {string} remoteName Name of the repository - eg "upstream"
|
||||
* @returns {*}
|
||||
*/
|
||||
removeRemote(remote: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Reset a repo
|
||||
*
|
||||
* @param {string|string[]} [mode=soft] Either an array of arguments supported by the 'git reset' command, or the string value 'soft' or 'hard' to set the reset mode.
|
||||
*/
|
||||
reset(mode?: 'soft' | 'mixed' | 'hard' | 'merge' | 'keep'): Promise<null>;
|
||||
|
||||
reset(commands?: string[]): Promise<void>;
|
||||
|
||||
/**
|
||||
* Revert one or more commits in the local working copy
|
||||
*
|
||||
* @param {string} commit The commit to revert. Can be any hash, offset (eg: `HEAD~2`) or range (eg: `master~5..master~2`)
|
||||
* @param {Object} [options] Optional options object
|
||||
*/
|
||||
revert(commit: String, options?: Options): Promise<void>;
|
||||
|
||||
/**
|
||||
* Wraps `git rev-parse`. Primarily used to convert friendly commit references (ie branch names) to SHA1 hashes.
|
||||
*
|
||||
* Options should be an array of string options compatible with the `git rev-parse`
|
||||
*
|
||||
* @param {string[]} [options]
|
||||
*
|
||||
* @returns Promise<string>
|
||||
*
|
||||
* @see http://git-scm.com/docs/git-rev-parse
|
||||
*/
|
||||
revparse(options?: string[]): Promise<string>;
|
||||
|
||||
/**
|
||||
* Removes the named files from source control.
|
||||
*
|
||||
* @param {string|string[]} files
|
||||
*/
|
||||
rm(paths: string | string[]): Promise<void>;
|
||||
|
||||
/**
|
||||
* Removes the named files from source control but keeps them on disk rather than deleting them entirely. To
|
||||
* completely remove the files, use `rm`.
|
||||
*
|
||||
* @param {string|string[]} files
|
||||
*/
|
||||
rmKeepLocal(paths: string | string[]): Promise<void>;
|
||||
|
||||
/**
|
||||
* Show various types of objects, for example the file at a certain commit
|
||||
*
|
||||
* @param {string[]} [options]
|
||||
*/
|
||||
show(options?: string[]): Promise<string>;
|
||||
|
||||
/**
|
||||
* Disables/enables the use of the console for printing warnings and errors, by default messages are not shown in
|
||||
* a production environment.
|
||||
*
|
||||
* @param {boolean} silence
|
||||
* @returns {simplegit.SimpleGit}
|
||||
*/
|
||||
silent(silence?: boolean): simplegit.SimpleGit;
|
||||
|
||||
/**
|
||||
* Stash the local repo
|
||||
*
|
||||
* @param {Object|Array} [options]
|
||||
*/
|
||||
stash(options?: Options | any[]): Promise<string>;
|
||||
|
||||
/**
|
||||
* List the stash(s) of the local repo
|
||||
*
|
||||
* @param {Object|Array} [options]
|
||||
*/
|
||||
stashList(options?: Options | string[]): Promise<resp.ListLogSummary>;
|
||||
|
||||
/**
|
||||
* Show the working tree status.
|
||||
*
|
||||
* @returns {Promise<StatusResult>} Parsed status result.
|
||||
*/
|
||||
status(): Promise<StatusResult>;
|
||||
|
||||
/**
|
||||
* Call any `git submodule` function with arguments passed as an array of strings.
|
||||
*
|
||||
* @param {string[]} options
|
||||
*/
|
||||
subModule(options: string[]): Promise<string>;
|
||||
|
||||
/**
|
||||
* Add a submodule
|
||||
*
|
||||
* @param {string} repo
|
||||
* @param {string} path
|
||||
*/
|
||||
submoduleAdd(repo: string, path: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Initialize submodules
|
||||
*
|
||||
* @param {string[]} [args]
|
||||
*/
|
||||
submoduleInit(options?: string[]): Promise<string>;
|
||||
|
||||
/**
|
||||
* Update submodules
|
||||
*
|
||||
* @param {string[]} [args]
|
||||
*/
|
||||
submoduleUpdate(options?: string[]): Promise<string>;
|
||||
|
||||
/**
|
||||
* List all tags. When using git 2.7.0 or above, include an options object with `"--sort": "property-name"` to
|
||||
* sort the tags by that property instead of using the default semantic versioning sort.
|
||||
*
|
||||
* Note, supplying this option when it is not supported by your Git version will cause the operation to fail.
|
||||
*
|
||||
* @param {Object} [options]
|
||||
*/
|
||||
tag(options?: Options | string[]): Promise<string>;
|
||||
|
||||
/**
|
||||
* Gets a list of tagged versions.
|
||||
*
|
||||
* @param {Options} options
|
||||
* @returns {Promise<TagResult>} Parsed tag list.
|
||||
*/
|
||||
tags(options?: Options): Promise<TagResult>;
|
||||
|
||||
/**
|
||||
* Updates repository server info
|
||||
*/
|
||||
updateServerInfo(): Promise<string>;
|
||||
}
|
||||
|
||||
type Options = { [key: string]: null | string | any };
|
||||
|
||||
type LogOptions<T = resp.DefaultLogFields> = Options & {
|
||||
format?: T;
|
||||
file?: string;
|
||||
from?: string;
|
||||
multiLine?: boolean;
|
||||
symmetric?: boolean;
|
||||
to?: string;
|
||||
};
|
||||
|
||||
// responses
|
||||
// ---------------------
|
||||
interface BranchSummary extends resp.BranchSummary {}
|
||||
|
||||
interface CommitSummary extends resp.CommitSummary {}
|
||||
|
||||
interface PullResult extends resp.PullResult {}
|
||||
|
||||
interface FetchResult extends resp.FetchResult {}
|
||||
|
||||
interface StatusResult extends resp.StatusResult {}
|
||||
|
||||
interface DiffResult extends resp.DiffResult {}
|
||||
|
||||
interface TagResult extends resp.TagResult {}
|
||||
|
||||
type outputHandler = (
|
||||
command: string,
|
||||
stdout: NodeJS.ReadableStream,
|
||||
stderr: NodeJS.ReadableStream
|
||||
) => void
|
||||
}
|
||||
|
||||
export = simplegit;
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
'use strict';
|
||||
|
||||
if (typeof Promise === 'undefined') {
|
||||
throw new ReferenceError("Promise wrappers must be enabled to use the promise API");
|
||||
}
|
||||
|
||||
function isAsyncCall (fn) {
|
||||
return /^[^\)]+then\s*\)/.test(fn) || /\._run\(/.test(fn);
|
||||
}
|
||||
|
||||
module.exports = function (baseDir) {
|
||||
|
||||
var Git = require('./src/git');
|
||||
var gitFactory = require('./src');
|
||||
var git;
|
||||
|
||||
|
||||
var chain = Promise.resolve();
|
||||
|
||||
try {
|
||||
git = gitFactory(baseDir);
|
||||
}
|
||||
catch (e) {
|
||||
chain = Promise.reject(e);
|
||||
}
|
||||
|
||||
return Object.keys(Git.prototype).reduce(function (promiseApi, fn) {
|
||||
if (/^_|then/.test(fn)) {
|
||||
return promiseApi;
|
||||
}
|
||||
|
||||
if (isAsyncCall(Git.prototype[fn])) {
|
||||
promiseApi[fn] = git ? asyncWrapper(fn, git) : function () {
|
||||
return chain;
|
||||
};
|
||||
}
|
||||
|
||||
else {
|
||||
promiseApi[fn] = git ? syncWrapper(fn, git, promiseApi) : function () {
|
||||
return promiseApi;
|
||||
};
|
||||
}
|
||||
|
||||
return promiseApi;
|
||||
|
||||
}, {});
|
||||
|
||||
function asyncWrapper (fn, git) {
|
||||
return function () {
|
||||
var args = [].slice.call(arguments);
|
||||
|
||||
if (typeof args[args.length] === 'function') {
|
||||
throw new TypeError(
|
||||
"Promise interface requires that handlers are not supplied inline, " +
|
||||
"trailing function not allowed in call to " + fn);
|
||||
}
|
||||
|
||||
return chain.then(function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
args.push(function (err, result) {
|
||||
if (err) {
|
||||
reject(new Error(err));
|
||||
}
|
||||
else {
|
||||
resolve(result);
|
||||
}
|
||||
});
|
||||
|
||||
git[fn].apply(git, args);
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function syncWrapper (fn, git, api) {
|
||||
return function () {
|
||||
git[fn].apply(git, arguments);
|
||||
|
||||
return api;
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
+353
@@ -0,0 +1,353 @@
|
||||
# Simple Git
|
||||
[](https://www.npmjs.com/package/simple-git) [](https://travis-ci.org/steveukx/git-js)
|
||||
|
||||
A light weight interface for running git commands in any [node.js](http://nodejs.org) application.
|
||||
|
||||
# Installation
|
||||
|
||||
Easiest through [npm](http://npmjs.org): `npm install simple-git`
|
||||
|
||||
# Dependencies
|
||||
|
||||
Requires [git](http://git-scm.com/downloads) to be installed and that it can be called using the command `git`.
|
||||
|
||||
# Usage
|
||||
|
||||
Include into your app using:
|
||||
|
||||
```js
|
||||
const simpleGit = require('simple-git')(workingDirPath);
|
||||
```
|
||||
|
||||
> where the `workingDirPath` is optional, defaulting to the current directory.
|
||||
|
||||
Use `simpleGit` by chaining any of its functions together. Each function accepts an optional final argument which will
|
||||
be called when that step has been completed. When it is called it has two arguments - firstly an error object (or null
|
||||
when no error occurred) and secondly the data generated by that call.
|
||||
|
||||
| API | What it does |
|
||||
|-----|--------------|
|
||||
| `.add([fileA, ...], handlerFn)` | adds one or more files to be under source control |
|
||||
| `.addAnnotatedTag(tagName, tagMessage, handlerFn)` | adds an annotated tag to the head of the current branch |
|
||||
| `.addConfig(key, value[, handlerFn])` | add a local configuration property |
|
||||
| `.addRemote(name, repo, handlerFn)` | adds a new named remote to be tracked as `name` at the path `repo` |
|
||||
| `.addTag(name, handlerFn)` | adds a lightweight tag to the head of the current branch |
|
||||
| `.branch([options, ][handlerFn])` | gets a list of all branches, calls `handlerFn` with two arguments, an error object and [BranchSummary](src/responses/BranchSummary.js) instance. When supplied, the options can be either an array of arguments supported by the [branch](https://git-scm.com/docs/git-branch) command or a standard [options](#how-to-specify-options) object. |
|
||||
| `.branchLocal([handlerFn])` | gets a list of local branches, calls `handlerFn` with two arguments, an error object and [BranchSummary](src/responses/BranchSummary.js) instance |
|
||||
| `.catFile(options[, handlerFn])` | generate `cat-file` detail, `options` should be an array of strings as supported arguments to the [cat-file](https://git-scm.com/docs/git-cat-file) command |
|
||||
| `.checkIgnore([filepath, ...], handlerFn)` | checks if filepath excluded by .gitignore rules |
|
||||
| `.checkIsRepo(handlerFn)` | Determines whether the current working directory is part of a git repository, the handler will be called with standard error object and a boolean response. |
|
||||
| `.checkout(checkoutWhat, handlerFn)` | checks out the supplied tag, revision or branch. `checkoutWhat` can be one or more strings to be used as parameters appended to the `git checkout` command. |
|
||||
| `.checkoutBranch(branchName, startPoint, handlerFn)` | checks out a new branch from the supplied start point |
|
||||
| `.checkoutLatestTag(handlerFn)` | convenience method to pull then checkout the latest tag |
|
||||
| `.checkoutLocalBranch(branchName, handlerFn)` | checks out a new local branch |
|
||||
| `.clean(mode [, options [, handlerFn]])` | clean the working tree. Mode should be "n" - dry run or "f" - force |
|
||||
| `.clearQueue()` | immediately clears the queue of pending tasks (note: any command currently in progress will still call its completion callback) |
|
||||
| `.clone(repoPath, [localPath, [options]], [handlerFn])` | clone a remote repo at `repoPath` to a local directory at `localPath` (can be omitted to use the default of a directory with the same name as the repo name) with an optional array of additional arguments to include between `git clone` and the trailing `repo local` arguments |
|
||||
| `.commit(message, handlerFn)` | commits changes in the current working directory with the supplied message where the message can be either a single string or array of strings to be passed as separate arguments (the `git` command line interface converts these to be separated by double line breaks) |
|
||||
| `.commit(message, [fileA, ...], options, handlerFn)` | commits changes on the named files with the supplied message, when supplied, the optional options object can contain any other parameters to pass to the commit command, setting the value of the property to be a string will add `name=value` to the command string, setting any other type of value will result in just the key from the object being passed (ie: just `name`), an example of setting the author is below |
|
||||
| `.customBinary(gitPath)` | sets the command to use to reference git, allows for using a git binary not available on the path environment variable |
|
||||
| `.cwd(workingDirectory)` | Sets the current working directory for all commands after this step in the chain |
|
||||
| `.deleteLocalBranch(branchName, handlerFn)` | deletes a local branch |
|
||||
| `.diff(options, handlerFn)` | get the diff of the current repo compared to the last commit with a set of options supplied as a string |
|
||||
| `.diff(handlerFn)` | get the diff for all file in the current repo compared to the last commit |
|
||||
| `.diffSummary(handlerFn)` | gets a summary of the diff for files in the repo, uses the `git diff --stat` format to calculate changes. Handler is called with a nullable error object and an instance of the [DiffSummary](src/responses/DiffSummary.js) |
|
||||
| `.diffSummary(options, handlerFn)` | includes options in the call to `diff --stat options` and returns a [DiffSummary](src/responses/DiffSummary.js) |
|
||||
| `.env(name, value)` | Set environment variables to be passed to the spawned child processes, [see usage in detail below](#environment-variables). |
|
||||
| `.exec(handlerFn)` | calls a simple function in the current step |
|
||||
| `.fetch([options, ] handlerFn)` | update the local working copy database with changes from the default remote repo and branch, when supplied the options argument can be a standard [options object](#how-to-specify-options) either an array of string commands as supported by the [git fetch](https://git-scm.com/docs/git-fetch). On success, the returned data will be an instance of the [FetchSummary](src/responses/FetchSummary.js) |
|
||||
| `.fetch(remote, branch, handlerFn)` | update the local working copy database with changes from a remote repo |
|
||||
| `.fetch(handlerFn)` | update the local working copy database with changes from the default remote repo and branch |
|
||||
| `.getRemotes([verbose], handlerFn)` | gets a list of the named remotes, when the verbose option is supplied as true, includes the URLs and purpose of each ref |
|
||||
| `.init(bare, handlerFn)` | initialize a repository, optional `bare` parameter makes intialized repository bare |
|
||||
| `.listRemote([args], handlerFn)` | lists remote repositories - there are so many optional arguments in the underlying `git ls-remote` call, just supply any you want to use as the optional `args` array of strings eg: `git.listRemote(['--heads', '--tags'], console.log.bind(console))` |
|
||||
| `.log([options], handlerFn)` | list commits between `options.from` and `options.to` tags or branch (if not specified will show all history). Additionally you can provide `options.file`, which is the path to a file in your repository. Then only this file will be considered. `options.symmetric` allows you to specify whether you want to use [symmetric revision range](https://git-scm.com/docs/gitrevisions#_dotted_range_notations) (To be compatible, by default, its value is true). For any other set of options, supply `options` as an array of strings to be appended to the `git log` command. To use a custom splitter in the log format, set `options.splitter` to be the string the log should be split on. Set `options.multiLine` to true to include a multi-line body in the output format. Options can also be supplied as a standard [options](#how-to-specify-options) object for adding custom properties supported by the [git log](https://git-scm.com/docs/git-log) command. |
|
||||
| `.mergeFromTo(from, to, [[options,] handlerFn])` | merge from one branch to another, when supplied the options should be an array of additional parameters to pass into the [git merge](https://git-scm.com/docs/git-merge) command |
|
||||
| `.merge(options, handlerFn)` | runs a merge, `options` can be either an array of arguments supported by the [git merge](https://git-scm.com/docs/git-merge) command or an [options](#how-to-specify-options) object. Conflicts during the merge result in an error response, the response type whether it was an error or success will be a [MergeSummary](src/responses/MergeSummary.js) instance. When successful, the MergeSummary has all detail from a the [PullSummary](src/responses/PullSummary.js) |
|
||||
| `.mirror(repoPath, localPath, handlerFn])` | clone and mirror the repo to local |
|
||||
| `.mv(from, to, handlerFn])` | rename or move a single file at `from` to `to`. On success the `handlerFn` will be called with a [MoveSummary](src/responses/MoveSummary.js) |
|
||||
| `.mv(from, to, handlerFn])` | move all files in the `from` array to the `to` directory. On success the `handlerFn` will be called with a [MoveSummary](src/responses/MoveSummary.js) |
|
||||
| `.outputHandler(handlerFn)` | attaches a handler that will be called with the name of the command being run and the `stdout` and `stderr` [readable streams](http://nodejs.org/api/stream.html#stream_class_stream_readable) created by the [child process](http://nodejs.org/api/child_process.html#child_process_class_childprocess) running that command |
|
||||
| `.pull(handlerFn)` | Pulls all updates from the default tracked repo |
|
||||
| `.pull(remote, branch, handlerFn)` | pull all updates from the specified remote branch (eg 'origin'/'master') |
|
||||
| `.pull(remote, branch, options, handlerFn)` | Pulls from named remote with any necessary options |
|
||||
| `.push(remote, branch[, options] handlerFn)` | pushes to a named remote/branch, supports additional [options](#how-to-specify-options) from the [git push](https://git-scm.com/docs/git-push) command. |
|
||||
| `.pushTags(remote, handlerFn)` | pushes tags to a named remote |
|
||||
| `.raw(args[, handlerFn])` | Execute any arbitrary array of commands supported by the underlying git binary. When the git process returns a non-zero signal on exit and it printed something to `stderr`, the commmand will be treated as an error, otherwise treated as a success. |
|
||||
| `.rebase([options,] handlerFn)` | Rebases the repo, `options` should be supplied as an array of string parameters supported by the [git rebase](https://git-scm.com/docs/git-rebase) command, or an object of options (see details below for option formats). |
|
||||
| `.removeRemote(name, handlerFn)` | removes the named remote |
|
||||
| `.reset([resetMode,] handlerFn)` | resets the repository, the optional first argument can either be an array of options supported by the `git reset` command or one of the string constants `mixed`, `hard`, or `soft`, if omitted the reset will be a soft reset to head, handlerFn: (err) |
|
||||
| `.revert(commit [, options [, handlerFn]])` | reverts one or more commits in the working copy. The commit can be any regular commit-ish value (hash, name or offset such as `HEAD~2`) or a range of commits (eg: `master~5..master~2`). When supplied the [options](#how-to-specify-options) argument contain any options accepted by [git-revert](https://git-scm.com/docs/git-revert). |
|
||||
| `.revparse([options], handlerFn)` | wraps git rev-parse. Primarily used to convert friendly commit references (ie branch names) to SHA1 hashes. Options should be an array of string options compatible with the [git rev-parse](http://git-scm.com/docs/git-rev-parse) |
|
||||
| `.rm([fileA, ...], handlerFn)` | removes any number of files from source control |
|
||||
| `.rmKeepLocal([fileA, ...], handlerFn)` | removes files from source control but leaves them on disk |
|
||||
| `.silent(isSilent)` | sets whether the console should be used for logging errors (defaults to `true` when the `NODE_ENV` contains the string `prod`) |
|
||||
| `.stash([options, ][ handlerFn])` | Stash the working directory, optional first argument can be an array of string arguments or [options](#how-to-specify-options) object to pass to the [git stash](https://git-scm.com/docs/git-stash) command. |
|
||||
| `.stashList([options, ][handlerFn])` | Retrieves the stash list, optional first argument can be an object specifying `options.splitter` to override the default value of `;;;;`, alternatively options can be a set of arguments as supported by the `git stash list` command. |
|
||||
| `.subModule(args [, handlerFn])` | Run a `git submodule` command with on or more arguments passed in as an `args` array |
|
||||
| `.submoduleAdd(repo, path[, handlerFn])` | adds a new sub module |
|
||||
| `.submoduleInit([args, ][handlerFn])` | inits sub modules, args should be an array of string arguments to pass to the `git submodule init` command |
|
||||
| `.submoduleUpdate([args, ][handlerFn])` | updates sub modules, args should be an array of string arguments to pass to the `git submodule update` command |
|
||||
| `.tag(args[], handlerFn)` | Runs any supported [git tag](https://git-scm.com/docs/git-tag) commands with arguments passed as an array of strings . |
|
||||
| `.tags([options, ] handlerFn)` | list all tags, use the optional [options](#how-to-specify-options) object to set any options allows by the [git tag](https://git-scm.com/docs/git-tag) command. Tags will be sorted by semantic version number by default, for git versions 2.7 and above, use the `--sort` option to set a custom sort. |
|
||||
| `.show([options], handlerFn)` | Show various types of objects, for example the file content at a certain commit. `options` is the single value string or array of string commands you want to run |
|
||||
| `.status(handlerFn)` | gets the status of the current repo |
|
||||
|
||||
# How to Specify Options
|
||||
|
||||
For `.pull` or `.commit` options are included as an object, the keys of which will all be merged as trailing
|
||||
arguments in the command string. When the value of the property in the options object is a `string`, that name value
|
||||
pair will be included in the command string as `name=value`. For example:
|
||||
|
||||
```js
|
||||
// results in 'git pull origin master --no-rebase'
|
||||
git().pull('origin', 'master', {'--no-rebase': null})
|
||||
|
||||
// results in 'git pull origin master --rebase=true'
|
||||
git().pull('origin', 'master', {'--rebase': 'true'})
|
||||
```
|
||||
|
||||
# Release History
|
||||
|
||||
Bumped to a new major revision in the 1.x branch, now uses `ChildProcess.spawn` in place of `ChildProcess.exec` to
|
||||
add escaping to the arguments passed to each of the tasks.
|
||||
|
||||
# Deprecated APIs
|
||||
|
||||
Use of these APIs is deprecated and should be avoided as support for them will be removed in future release:
|
||||
|
||||
`.then(func)` In versions 1.72 and below, it was possible to add a regular function call to the queue of tasks to be
|
||||
run. As this name clashes with the use of Promises, in version 1.73.0 it is renamed to `.exec(fn)` and a warning will
|
||||
be logged to `stdout` if `.then` is used. From version 2.0 the library will support promises without the need to wrap
|
||||
or use the alternative require `require('simple-git/promise')`.
|
||||
|
||||
`.log([from, to], handlerFn)` list commits between `from` and `to` tags or branch, switch to supplying the revisions
|
||||
as an options object instead.
|
||||
|
||||
# Complex Requests
|
||||
|
||||
When no suitable wrapper exists in the interface for creating a request, it is possible to run a command directly
|
||||
using `git.raw([...], handler)`. The array of commands are passed directly to the `git` binary:
|
||||
|
||||
```js
|
||||
const git = require('simple-git');
|
||||
const path = '/path/to/repo';
|
||||
|
||||
git(path).raw(
|
||||
[
|
||||
'config',
|
||||
'--global',
|
||||
'advice.pushNonFastForward',
|
||||
'false'
|
||||
], (err, result) => {
|
||||
|
||||
// err is null unless this command failed
|
||||
// result is the raw output of this command
|
||||
|
||||
});
|
||||
```
|
||||
|
||||
# Authentication
|
||||
|
||||
The easiest way to supply a username / password to the remote host is to include it in the URL, for example:
|
||||
|
||||
```js
|
||||
const USER = 'something';
|
||||
const PASS = 'somewhere';
|
||||
const REPO = 'github.com/username/private-repo';
|
||||
|
||||
const git = require('simple-git/promise');
|
||||
const remote = `https://${USER}:${PASS}@${REPO}`;
|
||||
|
||||
git().silent(true)
|
||||
.clone(remote)
|
||||
.then(() => console.log('finished'))
|
||||
.catch((err) => console.error('failed: ', err));
|
||||
|
||||
```
|
||||
|
||||
Be sure to enable silent mode to prevent fatal errors from being logged to stdout.
|
||||
|
||||
# Environment Variables
|
||||
|
||||
Pass one or more environment variables to the child processes spawned by `simple-git` with the `.env` method which
|
||||
supports passing either an object of name=value pairs or setting a single variable at a time:
|
||||
|
||||
```js
|
||||
const GIT_SSH_COMMAND = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no";
|
||||
|
||||
const git = require('simple-git');
|
||||
|
||||
git()
|
||||
.env('GIT_SSH_COMMAND', GIT_SSH_COMMAND)
|
||||
.status((err, status) => { /* */ })
|
||||
|
||||
|
||||
const gitP = require('simple-git/promise');
|
||||
|
||||
gitP().env({ ...process.env, GIT_SSH_COMMAND })
|
||||
.status()
|
||||
.then(status => { })
|
||||
.catch(err => {});
|
||||
|
||||
```
|
||||
|
||||
Note - when passing environment variables into the child process, these will replace the standard `process.env`
|
||||
variables, the example above creates a new object based on `process.env` but with the `GIT_SSH_COMMAND` property
|
||||
added.
|
||||
|
||||
# TypeScript
|
||||
|
||||
To import with TypeScript:
|
||||
|
||||
```
|
||||
import * as simplegit from 'simple-git/promise';
|
||||
|
||||
const git = simplegit();
|
||||
git.status().then((status: StatusSummary) => { ... })
|
||||
|
||||
```
|
||||
|
||||
# Response Object Revisions
|
||||
|
||||
| ListLogLine | v1.110.0 | The default format expression used in `.log` splits ref data out of the `message` into a property of its own:
|
||||
`{ message: 'Some commit message (some-branch-name)' }` becomes `{ message: 'Some commit message', refs: 'some-branch-name' }` |
|
||||
| ListLogLine | v1.110.0 | The commit body content is now included in the default format expression and can be used to identify the content of merge conflicts eg:
|
||||
`{ body: '# Conflicts:\n# some-file.txt' }` |
|
||||
|
||||
# Troubleshooting
|
||||
|
||||
### Every command returns ENOENT error message
|
||||
|
||||
There are a few potential reasons:
|
||||
|
||||
- `git` isn't available as a binary for the user running the main `node` process, custom paths to the binary can be used
|
||||
with the `.customBinary(...)` api option.
|
||||
- the working directory passed in to the main `simple-git` function isn't accessible, check it is read/write accessible
|
||||
by the user running the `node` process.
|
||||
|
||||
### Log response properties are out of order
|
||||
|
||||
The properties of `git.log` are fetched using a `;` as a delimiter. If your commit messages use the `;` character,
|
||||
supply a custom `splitter` in the options, for example: `git.log({ splitter: '|||' })`
|
||||
|
||||
# Examples
|
||||
|
||||
### async await with simple-git/promise:
|
||||
|
||||
```js
|
||||
async function status (workingDir) {
|
||||
const git = require('simple-git/promise');
|
||||
|
||||
let statusSummary = null;
|
||||
try {
|
||||
statusSummary = await git(workingDir).status();
|
||||
}
|
||||
catch (e) {
|
||||
// handle the error
|
||||
}
|
||||
|
||||
return statusSummary;
|
||||
}
|
||||
|
||||
// using the async function
|
||||
status(__dirname + '/some-repo').then(status => console.log(status));
|
||||
```
|
||||
|
||||
### Initialise a git repo if necessary
|
||||
```js
|
||||
const gitP = require('simple-git/promise');
|
||||
const git = gitP(__dirname);
|
||||
|
||||
git.checkIsRepo()
|
||||
.then(isRepo => !isRepo && initialiseRepo(git))
|
||||
.then(() => git.fetch());
|
||||
|
||||
function initialiseRepo (git) {
|
||||
return git.init()
|
||||
.then(() => git.addRemote('origin', 'https://some.git.repo'))
|
||||
}
|
||||
```
|
||||
|
||||
### Update repo and get a list of tags
|
||||
```js
|
||||
require('simple-git')(__dirname + '/some-repo')
|
||||
.pull()
|
||||
.tags((err, tags) => console.log("Latest available tag: %s", tags.latest));
|
||||
|
||||
// update repo and when there are changes, restart the app
|
||||
require('simple-git')()
|
||||
.pull((err, update) => {
|
||||
if(update && update.summary.changes) {
|
||||
require('child_process').exec('npm restart');
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Starting a new repo
|
||||
```js
|
||||
require('simple-git')()
|
||||
.init()
|
||||
.add('./*')
|
||||
.commit("first commit!")
|
||||
.addRemote('origin', 'https://github.com/user/repo.git')
|
||||
.push('origin', 'master');
|
||||
```
|
||||
|
||||
### push with `-u`
|
||||
```js
|
||||
require('simple-git')()
|
||||
.add('./*')
|
||||
.commit("first commit!")
|
||||
.addRemote('origin', 'some-repo-url')
|
||||
.push(['-u', 'origin', 'master'], () => console.log('done'));
|
||||
```
|
||||
|
||||
### Piping to the console for long running tasks
|
||||
```js
|
||||
require('simple-git')()
|
||||
.outputHandler((command, stdout, stderr) => {
|
||||
stdout.pipe(process.stdout);
|
||||
stderr.pipe(process.stderr);
|
||||
})
|
||||
.checkout('https://github.com/user/repo.git');
|
||||
```
|
||||
|
||||
### Update repo and print messages when there are changes, restart the app
|
||||
```js
|
||||
require('simple-git')()
|
||||
.exec(() => console.log('Starting pull...'))
|
||||
.pull((err, update) => {
|
||||
if(update && update.summary.changes) {
|
||||
require('child_process').exec('npm restart');
|
||||
}
|
||||
})
|
||||
.exec(() => console.log('pull done.'));
|
||||
```
|
||||
|
||||
### Get a full commits list, and then only between 0.11.0 and 0.12.0 tags
|
||||
```js
|
||||
require('simple-git')()
|
||||
.log((err, log) => console.log(log))
|
||||
.log('0.11.0', '0.12.0', (err, log) => console.log(log));
|
||||
```
|
||||
|
||||
### Set the local configuration for author, then author for an individual commit
|
||||
```js
|
||||
require('simple-git')()
|
||||
.addConfig('user.name', 'Some One')
|
||||
.addConfig('user.email', 'some@one.com')
|
||||
.commit('committed as "Some One"', 'file-one')
|
||||
.commit('committed as "Another Person"', 'file-two', { '--author': '"Another Person <another@person.com>"' });
|
||||
```
|
||||
|
||||
### Get remote repositories
|
||||
```js
|
||||
require('simple-git')()
|
||||
.listRemote(['--get-url'], (err, data) => {
|
||||
if (!err) {
|
||||
console.log('Remote url for repository at ' + __dirname + ':');
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
```
|
||||
+1591
File diff suppressed because it is too large
Load Diff
+14
@@ -0,0 +1,14 @@
|
||||
|
||||
var Git = require('./git');
|
||||
|
||||
module.exports = function (baseDir) {
|
||||
|
||||
var dependencies = require('./util/dependencies');
|
||||
|
||||
if (baseDir && !dependencies.exists(baseDir, dependencies.exists.FOLDER)) {
|
||||
throw new Error("Cannot use simple-git on a directory that does not exist.");
|
||||
}
|
||||
|
||||
return new Git(baseDir || process.cwd(), dependencies.childProcess(), dependencies.buffer());
|
||||
};
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
|
||||
module.exports = BranchDeletion;
|
||||
|
||||
function BranchDeletion (branch, hash) {
|
||||
this.branch = branch;
|
||||
this.hash = hash;
|
||||
this.success = hash !== null;
|
||||
}
|
||||
|
||||
BranchDeletion.deleteSuccessRegex = /(\S+)\s+\(\S+\s([^\)]+)\)/;
|
||||
BranchDeletion.deleteErrorRegex = /^error[^']+'([^']+)'/;
|
||||
|
||||
BranchDeletion.parse = function (data, asArray) {
|
||||
var result;
|
||||
var branchDeletions = data.trim().split('\n').map(function (line) {
|
||||
if (result = BranchDeletion.deleteSuccessRegex.exec(line)) {
|
||||
return new BranchDeletion(result[1], result[2]);
|
||||
}
|
||||
else if (result = BranchDeletion.deleteErrorRegex.exec(line)) {
|
||||
return new BranchDeletion(result[1], null);
|
||||
}
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
return asArray ? branchDeletions : branchDeletions.pop();
|
||||
};
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
|
||||
module.exports = BranchSummary;
|
||||
|
||||
function BranchSummary () {
|
||||
this.detached = false;
|
||||
this.current = '';
|
||||
this.all = [];
|
||||
this.branches = {};
|
||||
}
|
||||
|
||||
BranchSummary.prototype.push = function (current, detached, name, commit, label) {
|
||||
if (current) {
|
||||
this.detached = detached;
|
||||
this.current = name;
|
||||
}
|
||||
this.all.push(name);
|
||||
this.branches[name] = {
|
||||
current: current,
|
||||
name: name,
|
||||
commit: commit,
|
||||
label: label
|
||||
};
|
||||
};
|
||||
|
||||
BranchSummary.detachedRegex = /^(\*?\s+)\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/;
|
||||
BranchSummary.branchRegex = /^(\*?\s+)(\S+)\s+([a-z0-9]+)\s(.*)$/;
|
||||
|
||||
BranchSummary.parse = function (commit) {
|
||||
var branchSummary = new BranchSummary();
|
||||
|
||||
commit.split('\n')
|
||||
.forEach(function (line) {
|
||||
var detached = true;
|
||||
var branch = BranchSummary.detachedRegex.exec(line);
|
||||
if (!branch) {
|
||||
detached = false;
|
||||
branch = BranchSummary.branchRegex.exec(line);
|
||||
}
|
||||
|
||||
if (branch) {
|
||||
branchSummary.push(
|
||||
branch[1].charAt(0) === '*',
|
||||
detached,
|
||||
branch[2],
|
||||
branch[3],
|
||||
branch[4]
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return branchSummary;
|
||||
};
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
|
||||
module.exports = CommitSummary;
|
||||
|
||||
function CommitSummary () {
|
||||
this.branch = '';
|
||||
this.commit = '';
|
||||
this.summary = {
|
||||
changes: 0,
|
||||
insertions: 0,
|
||||
deletions: 0
|
||||
};
|
||||
this.author = null;
|
||||
}
|
||||
|
||||
var COMMIT_BRANCH_MESSAGE_REGEX = /\[([^\s]+) ([^\]]+)/;
|
||||
var COMMIT_AUTHOR_MESSAGE_REGEX = /\s*Author:\s(.+)/i;
|
||||
|
||||
function setBranchFromCommit (commitSummary, commitData) {
|
||||
if (commitData) {
|
||||
commitSummary.branch = commitData[1];
|
||||
commitSummary.commit = commitData[2];
|
||||
}
|
||||
}
|
||||
|
||||
function setSummaryFromCommit (commitSummary, commitData) {
|
||||
if (commitSummary.branch && commitData) {
|
||||
commitSummary.summary.changes = commitData[1] || 0;
|
||||
commitSummary.summary.insertions = commitData[2] || 0;
|
||||
commitSummary.summary.deletions = commitData[3] || 0;
|
||||
}
|
||||
}
|
||||
|
||||
function setAuthorFromCommit (commitSummary, commitData) {
|
||||
var parts = commitData[1].split('<');
|
||||
var email = parts.pop();
|
||||
|
||||
if (email.indexOf('@') <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
commitSummary.author = {
|
||||
email: email.substr(0, email.length - 1),
|
||||
name: parts.join('<').trim()
|
||||
};
|
||||
}
|
||||
|
||||
CommitSummary.parse = function (commit) {
|
||||
var lines = commit.trim().split('\n');
|
||||
var commitSummary = new CommitSummary();
|
||||
|
||||
setBranchFromCommit(commitSummary, COMMIT_BRANCH_MESSAGE_REGEX.exec(lines.shift()));
|
||||
|
||||
if (COMMIT_AUTHOR_MESSAGE_REGEX.test(lines[0])) {
|
||||
setAuthorFromCommit(commitSummary, COMMIT_AUTHOR_MESSAGE_REGEX.exec(lines.shift()));
|
||||
}
|
||||
|
||||
setSummaryFromCommit(commitSummary, /(\d+)[^,]*(?:,\s*(\d+)[^,]*)?(?:,\s*(\d+))?/g.exec(lines.shift()));
|
||||
|
||||
return commitSummary;
|
||||
};
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
|
||||
module.exports = DiffSummary;
|
||||
|
||||
/**
|
||||
* The DiffSummary is returned as a response to getting `git().status()`
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function DiffSummary () {
|
||||
this.files = [];
|
||||
this.insertions = 0;
|
||||
this.deletions = 0;
|
||||
this.changed = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of lines added
|
||||
* @type {number}
|
||||
*/
|
||||
DiffSummary.prototype.insertions = 0;
|
||||
|
||||
/**
|
||||
* Number of lines deleted
|
||||
* @type {number}
|
||||
*/
|
||||
DiffSummary.prototype.deletions = 0;
|
||||
|
||||
/**
|
||||
* Number of files changed
|
||||
* @type {number}
|
||||
*/
|
||||
DiffSummary.prototype.changed = 0;
|
||||
|
||||
DiffSummary.parse = function (text) {
|
||||
var line, handler;
|
||||
|
||||
var lines = text.trim().split('\n');
|
||||
var status = new DiffSummary();
|
||||
|
||||
var summary = lines.pop();
|
||||
if (summary) {
|
||||
summary.trim().split(', ').forEach(function (text) {
|
||||
var summary = /(\d+)\s([a-z]+)/.exec(text);
|
||||
if (!summary) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (/files?/.test(summary[2])) {
|
||||
status.changed = parseInt(summary[1], 10);
|
||||
}
|
||||
else {
|
||||
status[summary[2].replace(/s$/, '') + 's'] = parseInt(summary[1], 10);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
while (line = lines.shift()) {
|
||||
textFileChange(line, status.files) || binaryFileChange(line, status.files);
|
||||
}
|
||||
|
||||
return status;
|
||||
};
|
||||
|
||||
function textFileChange (line, files) {
|
||||
line = line.trim().match(/^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/);
|
||||
|
||||
if (line) {
|
||||
var alterations = (line[3] || '').trim();
|
||||
files.push({
|
||||
file: line[1].trim(),
|
||||
changes: parseInt(line[2], 10),
|
||||
insertions: alterations.replace(/-/g, '').length,
|
||||
deletions: alterations.replace(/\+/g, '').length,
|
||||
binary: false
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function binaryFileChange (line, files) {
|
||||
line = line.match(/^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)$/);
|
||||
if (line) {
|
||||
files.push({
|
||||
file: line[1].trim(),
|
||||
before: +line[2],
|
||||
after: +line[3],
|
||||
binary: true
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
function FetchSummary (raw) {
|
||||
this.raw = raw;
|
||||
|
||||
this.remote = null;
|
||||
this.branches = [];
|
||||
this.tags = [];
|
||||
}
|
||||
|
||||
FetchSummary.parsers = [
|
||||
[
|
||||
/From (.+)$/, function (fetchSummary, matches) {
|
||||
fetchSummary.remote = matches[0];
|
||||
}
|
||||
],
|
||||
[
|
||||
/\* \[new branch\]\s+(\S+)\s*\-> (.+)$/, function (fetchSummary, matches) {
|
||||
fetchSummary.branches.push({
|
||||
name: matches[0],
|
||||
tracking: matches[1]
|
||||
});
|
||||
}
|
||||
],
|
||||
[
|
||||
/\* \[new tag\]\s+(\S+)\s*\-> (.+)$/, function (fetchSummary, matches) {
|
||||
fetchSummary.tags.push({
|
||||
name: matches[0],
|
||||
tracking: matches[1]
|
||||
});
|
||||
}
|
||||
]
|
||||
];
|
||||
|
||||
FetchSummary.parse = function (data) {
|
||||
var fetchSummary = new FetchSummary(data);
|
||||
|
||||
String(data)
|
||||
.trim()
|
||||
.split('\n')
|
||||
.forEach(function (line) {
|
||||
var original = line.trim();
|
||||
FetchSummary.parsers.some(function (parser) {
|
||||
var parsed = parser[0].exec(original);
|
||||
if (parsed) {
|
||||
parser[1](fetchSummary, parsed.slice(1));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return fetchSummary;
|
||||
};
|
||||
|
||||
module.exports = FetchSummary;
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
function FileStatusSummary (path, index, working_dir) {
|
||||
this.path = path;
|
||||
this.index = index;
|
||||
this.working_dir = working_dir;
|
||||
|
||||
if ('R' === index + working_dir) {
|
||||
var detail = FileStatusSummary.fromPathRegex.exec(path) || [null, path, path];
|
||||
this.from = detail[1];
|
||||
this.path = detail[2];
|
||||
}
|
||||
}
|
||||
|
||||
FileStatusSummary.fromPathRegex = /^(.+) -> (.+)$/;
|
||||
|
||||
FileStatusSummary.prototype = {
|
||||
path: '',
|
||||
from: ''
|
||||
};
|
||||
|
||||
module.exports = FileStatusSummary;
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
|
||||
module.exports = ListLogSummary;
|
||||
|
||||
var DiffSummary = require('./DiffSummary');
|
||||
|
||||
/**
|
||||
* The ListLogSummary is returned as a response to getting `git().log()` or `git().stashList()`
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function ListLogSummary (all) {
|
||||
this.all = all;
|
||||
this.latest = all.length && all[0] || null;
|
||||
this.total = all.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detail for each of the log lines
|
||||
* @type {ListLogLine[]}
|
||||
*/
|
||||
ListLogSummary.prototype.all = null;
|
||||
|
||||
/**
|
||||
* Most recent entry in the log
|
||||
* @type {ListLogLine}
|
||||
*/
|
||||
ListLogSummary.prototype.latest = null;
|
||||
|
||||
/**
|
||||
* Number of items in the log
|
||||
* @type {number}
|
||||
*/
|
||||
ListLogSummary.prototype.total = 0;
|
||||
|
||||
function ListLogLine (line, fields) {
|
||||
for (var k = 0; k < fields.length; k++) {
|
||||
this[fields[k]] = line[k] || '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When the log was generated with a summary, the `diff` property contains as much detail
|
||||
* as was provided in the log (whether generated with `--stat` or `--shortstat`.
|
||||
* @type {DiffSummary}
|
||||
*/
|
||||
ListLogLine.prototype.diff = null;
|
||||
|
||||
ListLogSummary.START_BOUNDARY = 'òòòòòò ';
|
||||
|
||||
ListLogSummary.COMMIT_BOUNDARY = ' òò';
|
||||
|
||||
ListLogSummary.SPLITTER = ' ò ';
|
||||
|
||||
ListLogSummary.parse = function (text, splitter, fields) {
|
||||
fields = fields || ['hash', 'date', 'message', 'refs', 'author_name', 'author_email'];
|
||||
return new ListLogSummary(
|
||||
text
|
||||
.trim()
|
||||
.split(ListLogSummary.START_BOUNDARY)
|
||||
.filter(function(item) { return !!item.trim(); })
|
||||
.map(function (item) {
|
||||
var lineDetail = item.trim().split(ListLogSummary.COMMIT_BOUNDARY);
|
||||
var listLogLine = new ListLogLine(lineDetail[0].trim().split(splitter), fields);
|
||||
|
||||
if (lineDetail.length > 1 && !!lineDetail[1].trim()) {
|
||||
listLogLine.diff = DiffSummary.parse(lineDetail[1]);
|
||||
}
|
||||
|
||||
return listLogLine;
|
||||
})
|
||||
);
|
||||
};
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
'use strict';
|
||||
module.exports = MergeSummary;
|
||||
|
||||
var PullSummary = require('./PullSummary');
|
||||
|
||||
function MergeConflict (reason, file) {
|
||||
this.reason = reason;
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
MergeConflict.prototype.toString = function () {
|
||||
return this.file + ':' + this.reason;
|
||||
};
|
||||
|
||||
function MergeSummary () {
|
||||
PullSummary.call(this);
|
||||
|
||||
this.conflicts = [];
|
||||
this.merges = [];
|
||||
}
|
||||
|
||||
MergeSummary.prototype = Object.create(PullSummary.prototype);
|
||||
|
||||
MergeSummary.prototype.result = 'success';
|
||||
|
||||
MergeSummary.prototype.toString = function () {
|
||||
if (this.conflicts.length) {
|
||||
return 'CONFLICTS: ' + this.conflicts.join(', ');
|
||||
}
|
||||
return 'OK';
|
||||
};
|
||||
|
||||
Object.defineProperty(MergeSummary.prototype, 'failed', {
|
||||
get: function () {
|
||||
return this.conflicts.length > 0;
|
||||
}
|
||||
});
|
||||
|
||||
MergeSummary.parsers = [
|
||||
{
|
||||
test: /^Auto-merging\s+(.+)$/,
|
||||
handle: function (result, mergeSummary) {
|
||||
mergeSummary.merges.push(result[1]);
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /^CONFLICT\s+\((.+)\).+ in (.+)$/,
|
||||
handle: function (result, mergeSummary) {
|
||||
mergeSummary.conflicts.push(new MergeConflict(result[1], result[2]));
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /^Automatic merge failed;\s+(.+)$/,
|
||||
handle: function (result, mergeSummary) {
|
||||
mergeSummary.reason = result[1];
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
MergeSummary.parse = function (output) {
|
||||
let mergeSummary = new MergeSummary();
|
||||
|
||||
output.trim().split('\n').forEach(function (line) {
|
||||
for (var i = 0, iMax = MergeSummary.parsers.length; i < iMax; i++) {
|
||||
let parser = MergeSummary.parsers[i];
|
||||
|
||||
var result = parser.test.exec(line);
|
||||
if (result) {
|
||||
parser.handle(result, mergeSummary);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let pullSummary = PullSummary.parse(output);
|
||||
if (pullSummary.summary.changes) {
|
||||
Object.assign(mergeSummary, pullSummary);
|
||||
}
|
||||
|
||||
return mergeSummary;
|
||||
};
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
|
||||
module.exports = MoveSummary;
|
||||
|
||||
/**
|
||||
* The MoveSummary is returned as a response to getting `git().status()`
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function MoveSummary () {
|
||||
this.moves = [];
|
||||
this.sources = {};
|
||||
}
|
||||
|
||||
MoveSummary.SUMMARY_REGEX = /^Renaming (.+) to (.+)$/;
|
||||
|
||||
MoveSummary.parse = function (text) {
|
||||
var lines = text.split('\n');
|
||||
var summary = new MoveSummary();
|
||||
|
||||
for (var i = 0, iMax = lines.length, line; i < iMax; i++) {
|
||||
line = MoveSummary.SUMMARY_REGEX.exec(lines[i].trim());
|
||||
|
||||
if (line) {
|
||||
summary.moves.push({
|
||||
from: line[1],
|
||||
to: line[2]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return summary;
|
||||
};
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
|
||||
module.exports = PullSummary;
|
||||
|
||||
/**
|
||||
* The PullSummary is returned as a response to getting `git().pull()`
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function PullSummary () {
|
||||
this.files = [];
|
||||
this.insertions = {};
|
||||
this.deletions = {};
|
||||
|
||||
this.summary = {
|
||||
changes: 0,
|
||||
insertions: 0,
|
||||
deletions: 0
|
||||
};
|
||||
|
||||
this.created = [];
|
||||
this.deleted = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of files that were created
|
||||
* @type {string[]}
|
||||
*/
|
||||
PullSummary.prototype.created = null;
|
||||
|
||||
/**
|
||||
* Array of files that were deleted
|
||||
* @type {string[]}
|
||||
*/
|
||||
PullSummary.prototype.deleted = null;
|
||||
|
||||
/**
|
||||
* The array of file paths/names that have been modified in any part of the pulled content
|
||||
* @type {string[]}
|
||||
*/
|
||||
PullSummary.prototype.files = null;
|
||||
|
||||
/**
|
||||
* A map of file path to number to show the number of insertions per file.
|
||||
* @type {Object}
|
||||
*/
|
||||
PullSummary.prototype.insertions = null;
|
||||
|
||||
/**
|
||||
* A map of file path to number to show the number of deletions per file.
|
||||
* @type {Object}
|
||||
*/
|
||||
PullSummary.prototype.deletions = null;
|
||||
|
||||
/**
|
||||
* Overall summary of changes/insertions/deletions and the number associated with each
|
||||
* across all content that was pulled.
|
||||
* @type {Object}
|
||||
*/
|
||||
PullSummary.prototype.summary = null;
|
||||
|
||||
PullSummary.FILE_UPDATE_REGEX = /^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/;
|
||||
PullSummary.SUMMARY_REGEX = /(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/;
|
||||
PullSummary.ACTION_REGEX = /(create|delete) mode \d+ (.+)/;
|
||||
|
||||
PullSummary.parse = function (text) {
|
||||
var pullSummary = new PullSummary;
|
||||
var lines = text.split('\n');
|
||||
|
||||
while (lines.length) {
|
||||
var line = lines.shift().trim();
|
||||
if (!line) {
|
||||
continue;
|
||||
}
|
||||
|
||||
update(pullSummary, line) || summary(pullSummary, line) || action(pullSummary, line);
|
||||
}
|
||||
|
||||
return pullSummary;
|
||||
};
|
||||
|
||||
function update (pullSummary, line) {
|
||||
|
||||
var update = PullSummary.FILE_UPDATE_REGEX.exec(line);
|
||||
if (!update) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pullSummary.files.push(update[1]);
|
||||
|
||||
var insertions = update[2].length;
|
||||
if (insertions) {
|
||||
pullSummary.insertions[update[1]] = insertions;
|
||||
}
|
||||
|
||||
var deletions = update[3].length;
|
||||
if (deletions) {
|
||||
pullSummary.deletions[update[1]] = deletions;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function summary (pullSummary, line) {
|
||||
if (!pullSummary.files.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var update = PullSummary.SUMMARY_REGEX.exec(line);
|
||||
if (!update || (update[3] === undefined && update[5] === undefined)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pullSummary.summary.changes = +update[1] || 0;
|
||||
pullSummary.summary.insertions = +update[3] || 0;
|
||||
pullSummary.summary.deletions = +update[5] || 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function action (pullSummary, line) {
|
||||
|
||||
var match = PullSummary.ACTION_REGEX.exec(line);
|
||||
if (!match) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var file = match[2];
|
||||
|
||||
if (pullSummary.files.indexOf(file) < 0) {
|
||||
pullSummary.files.push(file);
|
||||
}
|
||||
|
||||
var container = (match[1] === 'create') ? pullSummary.created : pullSummary.deleted;
|
||||
container.push(file);
|
||||
|
||||
return true;
|
||||
}
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
|
||||
|
||||
|
||||
var FileStatusSummary = require('./FileStatusSummary');
|
||||
|
||||
module.exports = StatusSummary;
|
||||
|
||||
/**
|
||||
* The StatusSummary is returned as a response to getting `git().status()`
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function StatusSummary () {
|
||||
this.not_added = [];
|
||||
this.conflicted = [];
|
||||
this.created = [];
|
||||
this.deleted = [];
|
||||
this.modified = [];
|
||||
this.renamed = [];
|
||||
this.files = [];
|
||||
this.staged = [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Number of commits ahead of the tracked branch
|
||||
* @type {number}
|
||||
*/
|
||||
StatusSummary.prototype.ahead = 0;
|
||||
|
||||
/**
|
||||
* Number of commits behind the tracked branch
|
||||
* @type {number}
|
||||
*/
|
||||
StatusSummary.prototype.behind = 0;
|
||||
|
||||
/**
|
||||
* Name of the current branch
|
||||
* @type {null}
|
||||
*/
|
||||
StatusSummary.prototype.current = null;
|
||||
|
||||
/**
|
||||
* Name of the branch being tracked
|
||||
* @type {string}
|
||||
*/
|
||||
StatusSummary.prototype.tracking = null;
|
||||
|
||||
/**
|
||||
* All files represented as an array of objects containing the `path` and status in `index` and
|
||||
* in the `working_dir`.
|
||||
*
|
||||
* @type {Array}
|
||||
*/
|
||||
StatusSummary.prototype.files = null;
|
||||
|
||||
/**
|
||||
* Gets whether this StatusSummary represents a clean working branch.
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
StatusSummary.prototype.isClean = function () {
|
||||
return 0 === Object.keys(this).filter(function (name) {
|
||||
return Array.isArray(this[name]) && this[name].length;
|
||||
}, this).length;
|
||||
};
|
||||
|
||||
StatusSummary.parsers = {
|
||||
'##': function (line, status) {
|
||||
var aheadReg = /ahead (\d+)/;
|
||||
var behindReg = /behind (\d+)/;
|
||||
var currentReg = /^(.+?(?=(?:\.{3}|\s|$)))/;
|
||||
var trackingReg = /\.{3}(\S*)/;
|
||||
var regexResult;
|
||||
|
||||
regexResult = aheadReg.exec(line);
|
||||
status.ahead = regexResult && +regexResult[1] || 0;
|
||||
|
||||
regexResult = behindReg.exec(line);
|
||||
status.behind = regexResult && +regexResult[1] || 0;
|
||||
|
||||
regexResult = currentReg.exec(line);
|
||||
status.current = regexResult && regexResult[1];
|
||||
|
||||
regexResult = trackingReg.exec(line);
|
||||
status.tracking = regexResult && regexResult[1];
|
||||
},
|
||||
|
||||
'??': function (line, status) {
|
||||
status.not_added.push(line);
|
||||
},
|
||||
|
||||
A: function (line, status) {
|
||||
status.created.push(line);
|
||||
},
|
||||
|
||||
AM: function (line, status) {
|
||||
status.created.push(line);
|
||||
},
|
||||
|
||||
D: function (line, status) {
|
||||
status.deleted.push(line);
|
||||
},
|
||||
|
||||
M: function (line, status, indexState) {
|
||||
status.modified.push(line);
|
||||
|
||||
if (indexState === 'M') {
|
||||
status.staged.push(line);
|
||||
}
|
||||
},
|
||||
|
||||
R: function (line, status) {
|
||||
var detail = /^(.+) -> (.+)$/.exec(line) || [null, line, line];
|
||||
|
||||
status.renamed.push({
|
||||
from: detail[1],
|
||||
to: detail[2]
|
||||
});
|
||||
},
|
||||
|
||||
UU: function (line, status) {
|
||||
status.conflicted.push(line);
|
||||
}
|
||||
};
|
||||
|
||||
StatusSummary.parsers.MM = StatusSummary.parsers.M;
|
||||
|
||||
StatusSummary.parse = function (text) {
|
||||
var file, linestr;
|
||||
|
||||
var lines = text.trim().split('\n');
|
||||
var status = new StatusSummary();
|
||||
|
||||
while (linestr = lines.shift()) {
|
||||
file = splitLine(linestr);
|
||||
|
||||
if (!file) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file.handler) {
|
||||
file.handler(file.path, status, file.index, file.workingDir);
|
||||
}
|
||||
|
||||
if (file.code !== '##') {
|
||||
status.files.push(new FileStatusSummary(file.path, file.index, file.workingDir));
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
};
|
||||
|
||||
|
||||
function splitLine (lineStr) {
|
||||
var line = lineStr.trim().match(/(..?)(\s+)(.*)/);
|
||||
if (!line || !line[1].trim()) {
|
||||
line = lineStr.trim().match(/(..?)\s+(.*)/);
|
||||
}
|
||||
|
||||
if (!line) {
|
||||
return;
|
||||
}
|
||||
|
||||
var code = line[1];
|
||||
if (line[2].length > 1) {
|
||||
code += ' ';
|
||||
}
|
||||
if (code.length === 1 && line[2].length === 1) {
|
||||
code = ' ' + code;
|
||||
}
|
||||
|
||||
return {
|
||||
raw: code,
|
||||
code: code.trim(),
|
||||
index: code.charAt(0),
|
||||
workingDir: code.charAt(1),
|
||||
handler: StatusSummary.parsers[code.trim()],
|
||||
path: line[3]
|
||||
};
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
|
||||
module.exports = TagList;
|
||||
|
||||
function TagList (tagList, latest) {
|
||||
this.latest = latest;
|
||||
this.all = tagList
|
||||
}
|
||||
|
||||
TagList.parse = function (data, customSort) {
|
||||
var number = function (input) {
|
||||
if (typeof input === 'string') {
|
||||
return parseInt(input.replace(/^\D+/g, ''), 10) || 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
var tags = data
|
||||
.trim()
|
||||
.split('\n')
|
||||
.map(function (item) { return item.trim(); })
|
||||
.filter(Boolean);
|
||||
|
||||
if (!customSort) {
|
||||
tags.sort(function (tagA, tagB) {
|
||||
var partsA = tagA.split('.');
|
||||
var partsB = tagB.split('.');
|
||||
|
||||
if (partsA.length === 1 || partsB.length === 1) {
|
||||
return tagA - tagB > 0 ? 1 : -1;
|
||||
}
|
||||
|
||||
for (var i = 0, l = Math.max(partsA.length, partsB.length); i < l; i++) {
|
||||
var a = number(partsA[i]);
|
||||
var b = number(partsB[i]);
|
||||
|
||||
var diff = a - b;
|
||||
if (diff) {
|
||||
return diff > 0 ? 1 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
var latest = customSort ? tags[0] : tags.filter(function (tag) { return tag.indexOf('.') >= 0; }).pop();
|
||||
|
||||
return new TagList(tags, latest);
|
||||
};
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
|
||||
module.exports = {
|
||||
BranchDeleteSummary: require('./BranchDeleteSummary'),
|
||||
BranchSummary: require('./BranchSummary'),
|
||||
CommitSummary: require('./CommitSummary'),
|
||||
DiffSummary: require('./DiffSummary'),
|
||||
FetchSummary: require('./FetchSummary'),
|
||||
FileStatusSummary: require('./FileStatusSummary'),
|
||||
ListLogSummary: require('./ListLogSummary'),
|
||||
MergeSummary: require('./MergeSummary'),
|
||||
MoveSummary: require('./MoveSummary'),
|
||||
PullSummary: require('./PullSummary'),
|
||||
StatusSummary: require('./StatusSummary'),
|
||||
TagList: require('./TagList'),
|
||||
};
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
|
||||
module.exports = function deferred () {
|
||||
var d = {};
|
||||
d.promise = new Promise(function (resolve, reject) {
|
||||
d.resolve = resolve;
|
||||
d.reject = reject
|
||||
});
|
||||
|
||||
return d;
|
||||
};
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Exports the utilities `simple-git` depends upon to allow for mocking during a test
|
||||
*/
|
||||
module.exports = {
|
||||
|
||||
buffer: function () { return require('buffer').Buffer; },
|
||||
|
||||
childProcess: function () { return require('child_process'); },
|
||||
|
||||
exists: require('./exists')
|
||||
|
||||
};
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
|
||||
var fs = require('fs');
|
||||
|
||||
function exists (path, isFile, isDirectory) {
|
||||
try {
|
||||
var matches = false;
|
||||
var stat = fs.statSync(path);
|
||||
|
||||
matches = matches || isFile && stat.isFile();
|
||||
matches = matches || isDirectory && stat.isDirectory();
|
||||
|
||||
return matches;
|
||||
}
|
||||
catch (e) {
|
||||
if (e.code === 'ENOENT') {
|
||||
return false;
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function (path, type) {
|
||||
if (!type) {
|
||||
return exists(path, true, true);
|
||||
}
|
||||
|
||||
return exists(path, type & 1, type & 2);
|
||||
};
|
||||
|
||||
module.exports.FILE = 1;
|
||||
|
||||
module.exports.FOLDER = 2;
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
|
||||
export interface BranchDeletionSummary {
|
||||
branch: string;
|
||||
hash: any;
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
export interface BranchSummary {
|
||||
detached: boolean;
|
||||
current: string;
|
||||
all: string[];
|
||||
branches: {[key: string]: {
|
||||
current: string,
|
||||
name: string,
|
||||
commit: string,
|
||||
label: string
|
||||
}};
|
||||
}
|
||||
|
||||
export interface CommitSummary {
|
||||
author: null | {
|
||||
email: string;
|
||||
name: string;
|
||||
};
|
||||
branch: string;
|
||||
commit: string;
|
||||
summary: {
|
||||
changes: number;
|
||||
insertions: number;
|
||||
deletions: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface DiffResultTextFile {
|
||||
file: string;
|
||||
changes: number,
|
||||
insertions: number;
|
||||
deletions: number;
|
||||
binary: boolean;
|
||||
}
|
||||
|
||||
export interface DiffResultBinaryFile {
|
||||
file: string;
|
||||
before: number;
|
||||
after: number;
|
||||
binary: boolean;
|
||||
}
|
||||
|
||||
export interface DiffResult {
|
||||
/** The total number of files changed as reported in the summary line */
|
||||
changed: number;
|
||||
|
||||
/** When present in the diff, lists the details of each file changed */
|
||||
files: Array<DiffResultTextFile | DiffResultBinaryFile>;
|
||||
|
||||
/** The number of files changed with insertions */
|
||||
insertions: number;
|
||||
|
||||
/** The number of files changed with deletions */
|
||||
deletions: number;
|
||||
}
|
||||
|
||||
export interface FetchResult {
|
||||
raw: string;
|
||||
remote: string | null;
|
||||
branches: {
|
||||
name: string;
|
||||
tracking: string;
|
||||
}[];
|
||||
tags: {
|
||||
name: string;
|
||||
tracking: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface MoveSummary {
|
||||
moves: any[];
|
||||
}
|
||||
|
||||
export interface PullResult {
|
||||
|
||||
/** Array of all files that are referenced in the pull */
|
||||
files: string[];
|
||||
|
||||
/** Map of file names to the number of insertions in that file */
|
||||
insertions: {[key: string]: number};
|
||||
|
||||
/** Map of file names to the number of deletions in that file */
|
||||
deletions: any;
|
||||
|
||||
summary: {
|
||||
changes: number;
|
||||
insertions: number;
|
||||
deletions: number;
|
||||
};
|
||||
|
||||
/** Array of file names that have been created */
|
||||
created: string[];
|
||||
|
||||
/** Array of file names that have been deleted */
|
||||
deleted: string[];
|
||||
}
|
||||
|
||||
export interface RemoteWithoutRefs {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface RemoteWithRefs extends RemoteWithoutRefs {
|
||||
refs: {
|
||||
fetch: string;
|
||||
push: string;
|
||||
}
|
||||
}
|
||||
|
||||
export interface StatusResultRenamed {
|
||||
from: string;
|
||||
to: string;
|
||||
}
|
||||
|
||||
export interface StatusResult {
|
||||
not_added: string[];
|
||||
conflicted: string[];
|
||||
created: string[];
|
||||
deleted: string[];
|
||||
modified: string[];
|
||||
renamed: StatusResultRenamed[];
|
||||
staged: string[];
|
||||
files: {
|
||||
path: string;
|
||||
index: string;
|
||||
working_dir: string;
|
||||
}[];
|
||||
ahead: number;
|
||||
behind: number;
|
||||
current: string;
|
||||
tracking: string;
|
||||
|
||||
/**
|
||||
* Gets whether this represents a clean working branch.
|
||||
*/
|
||||
isClean(): boolean;
|
||||
}
|
||||
|
||||
export interface TagResult {
|
||||
all: string[];
|
||||
latest: string;
|
||||
}
|
||||
|
||||
export interface DefaultLogFields {
|
||||
hash: string;
|
||||
date: string;
|
||||
message: string;
|
||||
refs: string;
|
||||
body: string;
|
||||
author_name: string;
|
||||
author_email: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ListLogLine represents a single entry in the `git.log`, the properties on the object
|
||||
* are mixed in depending on the names used in the format (see `DefaultLogFields`), but some
|
||||
* properties are dependent on the command used.
|
||||
*/
|
||||
export interface ListLogLine {
|
||||
|
||||
/**
|
||||
* When using a `--stat=4096` or `--shortstat` options in the `git.log` or `git.stashList`,
|
||||
* each entry in the `ListLogSummary` will also have a `diff` property representing as much
|
||||
* detail as was given in the response.
|
||||
*/
|
||||
diff?: DiffResult;
|
||||
}
|
||||
|
||||
export interface ListLogSummary<T = DefaultLogFields> {
|
||||
all: ReadonlyArray<T & ListLogLine>;
|
||||
total: number;
|
||||
latest: T & ListLogLine;
|
||||
}
|
||||
Generated
+31
-3
@@ -133,6 +133,21 @@
|
||||
"semver": "^5.5.0",
|
||||
"shebang-command": "^1.2.0",
|
||||
"which": "^1.2.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"semver": {
|
||||
"version": "5.7.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
|
||||
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
||||
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"deprecation": {
|
||||
@@ -213,6 +228,11 @@
|
||||
"resolved": "https://registry.npmjs.org/macos-release/-/macos-release-2.3.0.tgz",
|
||||
"integrity": "sha512-OHhSbtcviqMPt7yfw5ef5aghS2jzFVKEFyCJndQt2YpSQ9qRVSEv2axSJI1paVThEu+FFGs584h/1YhxjVqajA=="
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"nice-try": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",
|
||||
@@ -273,9 +293,9 @@
|
||||
}
|
||||
},
|
||||
"semver": {
|
||||
"version": "5.7.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
|
||||
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ=="
|
||||
"version": "6.3.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
|
||||
},
|
||||
"shebang-command": {
|
||||
"version": "1.2.0",
|
||||
@@ -295,6 +315,14 @@
|
||||
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
|
||||
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0="
|
||||
},
|
||||
"simple-git": {
|
||||
"version": "1.126.0",
|
||||
"resolved": "https://registry.npmjs.org/simple-git/-/simple-git-1.126.0.tgz",
|
||||
"integrity": "sha512-47mqHxgZnN8XRa9HbpWprzUv3Ooqz9RY/LSZgvA7jCkW8jcwLahMz7LKugY91KZehfG0sCVPtgXiU72hd6b1Bw==",
|
||||
"requires": {
|
||||
"debug": "^4.0.1"
|
||||
}
|
||||
},
|
||||
"strip-eof": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
|
||||
|
||||
+4
-1
@@ -11,6 +11,9 @@
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.1.1",
|
||||
"@actions/github": "^1.1.0",
|
||||
"node-fetch": "^2.6.0"
|
||||
"@octokit/rest": "^16.30.1",
|
||||
"node-fetch": "^2.6.0",
|
||||
"semver": "^6.3.0",
|
||||
"simple-git": "^1.126.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user