keep-a-changelog 0.10.3 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -185
- package/LICENSE +1 -1
- package/README.md +93 -63
- package/esm/_dnt.shims.js +62 -0
- package/esm/bin.js +114 -0
- package/esm/deps/deno_land/std_0.120.0/_util/assert.js +13 -0
- package/esm/deps/deno_land/std_0.120.0/_util/os.js +15 -0
- package/esm/deps/deno_land/std_0.120.0/flags/mod.js +255 -0
- package/esm/deps/deno_land/std_0.120.0/path/_constants.js +45 -0
- package/esm/deps/deno_land/std_0.120.0/path/_interface.js +3 -0
- package/esm/deps/deno_land/std_0.120.0/path/_util.js +114 -0
- package/esm/deps/deno_land/std_0.120.0/path/common.js +36 -0
- package/esm/deps/deno_land/std_0.120.0/path/glob.js +361 -0
- package/esm/deps/deno_land/std_0.120.0/path/mod.js +14 -0
- package/esm/deps/deno_land/std_0.120.0/path/posix.js +493 -0
- package/esm/deps/deno_land/std_0.120.0/path/separator.js +5 -0
- package/esm/deps/deno_land/std_0.120.0/path/win32.js +963 -0
- package/esm/deps/deno_land/std_0.51.0/fs/eol.js +29 -0
- package/esm/deps/deno_land/x/ini_v2.1.0/ini.js +226 -0
- package/esm/deps/deno_land/x/ini_v2.1.0/mod.js +1 -0
- package/esm/deps/deno_land/x/semver_v1.4.0/mod.js +1527 -0
- package/esm/mod.js +5 -0
- package/esm/package.json +3 -0
- package/esm/src/Change.js +48 -0
- package/esm/src/Changelog.js +137 -0
- package/esm/src/Release.js +204 -0
- package/esm/src/deps.js +1 -0
- package/esm/src/parser.js +159 -0
- package/esm/test/changelog.custom.type.md +24 -0
- package/esm/test/changelog.expected.md +169 -0
- package/esm/test/changelog.md +200 -0
- package/esm/test/empty.expected.md +6 -0
- package/package.json +26 -24
- package/types/_dnt.shims.d.ts +9 -0
- package/types/bin.d.ts +2 -0
- package/types/deps/deno_land/std_0.120.0/_util/assert.d.ts +5 -0
- package/types/deps/deno_land/std_0.120.0/_util/os.d.ts +3 -0
- package/types/deps/deno_land/std_0.120.0/flags/mod.d.ts +50 -0
- package/types/deps/deno_land/std_0.120.0/path/_constants.d.ts +39 -0
- package/types/deps/deno_land/std_0.120.0/path/_interface.d.ts +26 -0
- package/types/deps/deno_land/std_0.120.0/path/_util.d.ts +8 -0
- package/types/deps/deno_land/std_0.120.0/path/common.d.ts +13 -0
- package/types/deps/deno_land/std_0.120.0/path/glob.d.ts +78 -0
- package/types/deps/deno_land/std_0.120.0/path/mod.d.ts +9 -0
- package/types/deps/deno_land/std_0.120.0/path/posix.d.ts +80 -0
- package/types/deps/deno_land/std_0.120.0/path/separator.d.ts +2 -0
- package/types/deps/deno_land/std_0.120.0/path/win32.d.ts +87 -0
- package/types/deps/deno_land/std_0.51.0/fs/eol.d.ts +12 -0
- package/types/deps/deno_land/x/ini_v2.1.0/ini.d.ts +53 -0
- package/types/deps/deno_land/x/ini_v2.1.0/mod.d.ts +1 -0
- package/types/deps/deno_land/x/semver_v1.4.0/mod.d.ts +116 -0
- package/types/mod.d.ts +5 -0
- package/types/src/Change.d.ts +8 -0
- package/types/src/Changelog.d.ts +18 -0
- package/types/src/Release.d.ts +25 -0
- package/types/src/deps.d.ts +1 -0
- package/types/src/parser.d.ts +11 -0
- package/umd/_dnt.shims.js +76 -0
- package/umd/bin.js +145 -0
- package/umd/deps/deno_land/std_0.120.0/_util/assert.js +28 -0
- package/umd/deps/deno_land/std_0.120.0/_util/os.js +47 -0
- package/umd/deps/deno_land/std_0.120.0/flags/mod.js +269 -0
- package/umd/deps/deno_land/std_0.120.0/path/_constants.js +58 -0
- package/umd/deps/deno_land/std_0.120.0/path/_interface.js +14 -0
- package/umd/deps/deno_land/std_0.120.0/path/_util.js +134 -0
- package/umd/deps/deno_land/std_0.120.0/path/common.js +50 -0
- package/umd/deps/deno_land/std_0.120.0/path/glob.js +397 -0
- package/umd/deps/deno_land/std_0.120.0/path/mod.js +51 -0
- package/umd/deps/deno_land/std_0.120.0/path/posix.js +538 -0
- package/umd/deps/deno_land/std_0.120.0/path/separator.js +18 -0
- package/umd/deps/deno_land/std_0.120.0/path/win32.js +1008 -0
- package/umd/deps/deno_land/std_0.51.0/fs/eol.js +44 -0
- package/umd/deps/deno_land/x/ini_v2.1.0/ini.js +262 -0
- package/umd/deps/deno_land/x/ini_v2.1.0/mod.js +23 -0
- package/umd/deps/deno_land/x/semver_v1.4.0/mod.js +1578 -0
- package/umd/mod.js +24 -0
- package/umd/package.json +3 -0
- package/umd/src/Change.js +61 -0
- package/umd/src/Changelog.js +150 -0
- package/umd/src/Release.js +220 -0
- package/umd/src/deps.js +19 -0
- package/umd/src/parser.js +175 -0
- package/umd/test/changelog.custom.type.md +24 -0
- package/umd/test/changelog.expected.md +169 -0
- package/umd/test/changelog.md +200 -0
- package/umd/test/empty.expected.md +6 -0
- package/bin.js +0 -114
- package/src/Change.js +0 -40
- package/src/Changelog.js +0 -121
- package/src/Release.js +0 -220
- package/src/index.js +0 -6
- package/src/parser.js +0 -182
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Copyright the Browserify authors. MIT License.
|
|
2
|
+
// Ported from https://github.com/browserify/path-browserify/
|
|
3
|
+
// This module is browser compatible.
|
|
4
|
+
(function (factory) {
|
|
5
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
6
|
+
var v = factory(require, exports);
|
|
7
|
+
if (v !== undefined) module.exports = v;
|
|
8
|
+
}
|
|
9
|
+
else if (typeof define === "function" && define.amd) {
|
|
10
|
+
define(["require", "exports", "./_constants.js"], factory);
|
|
11
|
+
}
|
|
12
|
+
})(function (require, exports) {
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.encodeWhitespace = exports._format = exports.normalizeString = exports.isWindowsDeviceRoot = exports.isPathSeparator = exports.isPosixPathSeparator = exports.assertPath = void 0;
|
|
16
|
+
const _constants_js_1 = require("./_constants.js");
|
|
17
|
+
function assertPath(path) {
|
|
18
|
+
if (typeof path !== "string") {
|
|
19
|
+
throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.assertPath = assertPath;
|
|
23
|
+
function isPosixPathSeparator(code) {
|
|
24
|
+
return code === _constants_js_1.CHAR_FORWARD_SLASH;
|
|
25
|
+
}
|
|
26
|
+
exports.isPosixPathSeparator = isPosixPathSeparator;
|
|
27
|
+
function isPathSeparator(code) {
|
|
28
|
+
return isPosixPathSeparator(code) || code === _constants_js_1.CHAR_BACKWARD_SLASH;
|
|
29
|
+
}
|
|
30
|
+
exports.isPathSeparator = isPathSeparator;
|
|
31
|
+
function isWindowsDeviceRoot(code) {
|
|
32
|
+
return ((code >= _constants_js_1.CHAR_LOWERCASE_A && code <= _constants_js_1.CHAR_LOWERCASE_Z) ||
|
|
33
|
+
(code >= _constants_js_1.CHAR_UPPERCASE_A && code <= _constants_js_1.CHAR_UPPERCASE_Z));
|
|
34
|
+
}
|
|
35
|
+
exports.isWindowsDeviceRoot = isWindowsDeviceRoot;
|
|
36
|
+
// Resolves . and .. elements in a path with directory names
|
|
37
|
+
function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
|
|
38
|
+
let res = "";
|
|
39
|
+
let lastSegmentLength = 0;
|
|
40
|
+
let lastSlash = -1;
|
|
41
|
+
let dots = 0;
|
|
42
|
+
let code;
|
|
43
|
+
for (let i = 0, len = path.length; i <= len; ++i) {
|
|
44
|
+
if (i < len)
|
|
45
|
+
code = path.charCodeAt(i);
|
|
46
|
+
else if (isPathSeparator(code))
|
|
47
|
+
break;
|
|
48
|
+
else
|
|
49
|
+
code = _constants_js_1.CHAR_FORWARD_SLASH;
|
|
50
|
+
if (isPathSeparator(code)) {
|
|
51
|
+
if (lastSlash === i - 1 || dots === 1) {
|
|
52
|
+
// NOOP
|
|
53
|
+
}
|
|
54
|
+
else if (lastSlash !== i - 1 && dots === 2) {
|
|
55
|
+
if (res.length < 2 ||
|
|
56
|
+
lastSegmentLength !== 2 ||
|
|
57
|
+
res.charCodeAt(res.length - 1) !== _constants_js_1.CHAR_DOT ||
|
|
58
|
+
res.charCodeAt(res.length - 2) !== _constants_js_1.CHAR_DOT) {
|
|
59
|
+
if (res.length > 2) {
|
|
60
|
+
const lastSlashIndex = res.lastIndexOf(separator);
|
|
61
|
+
if (lastSlashIndex === -1) {
|
|
62
|
+
res = "";
|
|
63
|
+
lastSegmentLength = 0;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
res = res.slice(0, lastSlashIndex);
|
|
67
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
|
|
68
|
+
}
|
|
69
|
+
lastSlash = i;
|
|
70
|
+
dots = 0;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
else if (res.length === 2 || res.length === 1) {
|
|
74
|
+
res = "";
|
|
75
|
+
lastSegmentLength = 0;
|
|
76
|
+
lastSlash = i;
|
|
77
|
+
dots = 0;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (allowAboveRoot) {
|
|
82
|
+
if (res.length > 0)
|
|
83
|
+
res += `${separator}..`;
|
|
84
|
+
else
|
|
85
|
+
res = "..";
|
|
86
|
+
lastSegmentLength = 2;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
if (res.length > 0)
|
|
91
|
+
res += separator + path.slice(lastSlash + 1, i);
|
|
92
|
+
else
|
|
93
|
+
res = path.slice(lastSlash + 1, i);
|
|
94
|
+
lastSegmentLength = i - lastSlash - 1;
|
|
95
|
+
}
|
|
96
|
+
lastSlash = i;
|
|
97
|
+
dots = 0;
|
|
98
|
+
}
|
|
99
|
+
else if (code === _constants_js_1.CHAR_DOT && dots !== -1) {
|
|
100
|
+
++dots;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
dots = -1;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return res;
|
|
107
|
+
}
|
|
108
|
+
exports.normalizeString = normalizeString;
|
|
109
|
+
function _format(sep, pathObject) {
|
|
110
|
+
const dir = pathObject.dir || pathObject.root;
|
|
111
|
+
const base = pathObject.base ||
|
|
112
|
+
(pathObject.name || "") + (pathObject.ext || "");
|
|
113
|
+
if (!dir)
|
|
114
|
+
return base;
|
|
115
|
+
if (dir === pathObject.root)
|
|
116
|
+
return dir + base;
|
|
117
|
+
return dir + sep + base;
|
|
118
|
+
}
|
|
119
|
+
exports._format = _format;
|
|
120
|
+
const WHITESPACE_ENCODINGS = {
|
|
121
|
+
"\u0009": "%09",
|
|
122
|
+
"\u000A": "%0A",
|
|
123
|
+
"\u000B": "%0B",
|
|
124
|
+
"\u000C": "%0C",
|
|
125
|
+
"\u000D": "%0D",
|
|
126
|
+
"\u0020": "%20",
|
|
127
|
+
};
|
|
128
|
+
function encodeWhitespace(string) {
|
|
129
|
+
return string.replaceAll(/[\s]/g, (c) => {
|
|
130
|
+
return WHITESPACE_ENCODINGS[c] ?? c;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
exports.encodeWhitespace = encodeWhitespace;
|
|
134
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
(function (factory) {
|
|
4
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
5
|
+
var v = factory(require, exports);
|
|
6
|
+
if (v !== undefined) module.exports = v;
|
|
7
|
+
}
|
|
8
|
+
else if (typeof define === "function" && define.amd) {
|
|
9
|
+
define(["require", "exports", "./separator.js"], factory);
|
|
10
|
+
}
|
|
11
|
+
})(function (require, exports) {
|
|
12
|
+
"use strict";
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.common = void 0;
|
|
15
|
+
const separator_js_1 = require("./separator.js");
|
|
16
|
+
/** Determines the common path from a set of paths, using an optional separator,
|
|
17
|
+
* which defaults to the OS default separator.
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { common } from "https://deno.land/std@$STD_VERSION/path/mod.ts";
|
|
21
|
+
* const p = common([
|
|
22
|
+
* "./deno/std/path/mod.ts",
|
|
23
|
+
* "./deno/std/fs/mod.ts",
|
|
24
|
+
* ]);
|
|
25
|
+
* console.log(p); // "./deno/std/"
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function common(paths, sep = separator_js_1.SEP) {
|
|
29
|
+
const [first = "", ...remaining] = paths;
|
|
30
|
+
if (first === "" || remaining.length === 0) {
|
|
31
|
+
return first.substring(0, first.lastIndexOf(sep) + 1);
|
|
32
|
+
}
|
|
33
|
+
const parts = first.split(sep);
|
|
34
|
+
let endOfPrefix = parts.length;
|
|
35
|
+
for (const path of remaining) {
|
|
36
|
+
const compare = path.split(sep);
|
|
37
|
+
for (let i = 0; i < endOfPrefix; i++) {
|
|
38
|
+
if (compare[i] !== parts[i]) {
|
|
39
|
+
endOfPrefix = i;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (endOfPrefix === 0) {
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const prefix = parts.slice(0, endOfPrefix).join(sep);
|
|
47
|
+
return prefix.endsWith(sep) ? prefix : `${prefix}${sep}`;
|
|
48
|
+
}
|
|
49
|
+
exports.common = common;
|
|
50
|
+
});
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
6
|
+
}) : (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
o[k2] = m[k];
|
|
9
|
+
}));
|
|
10
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
11
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
12
|
+
}) : function(o, v) {
|
|
13
|
+
o["default"] = v;
|
|
14
|
+
});
|
|
15
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
16
|
+
if (mod && mod.__esModule) return mod;
|
|
17
|
+
var result = {};
|
|
18
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
19
|
+
__setModuleDefault(result, mod);
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
(function (factory) {
|
|
23
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
24
|
+
var v = factory(require, exports);
|
|
25
|
+
if (v !== undefined) module.exports = v;
|
|
26
|
+
}
|
|
27
|
+
else if (typeof define === "function" && define.amd) {
|
|
28
|
+
define(["require", "exports", "../_util/os.js", "./separator.js", "./win32.js", "./posix.js"], factory);
|
|
29
|
+
}
|
|
30
|
+
})(function (require, exports) {
|
|
31
|
+
"use strict";
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.joinGlobs = exports.normalizeGlob = exports.isGlob = exports.globToRegExp = void 0;
|
|
34
|
+
const os_js_1 = require("../_util/os.js");
|
|
35
|
+
const separator_js_1 = require("./separator.js");
|
|
36
|
+
const _win32 = __importStar(require("./win32.js"));
|
|
37
|
+
const _posix = __importStar(require("./posix.js"));
|
|
38
|
+
const path = os_js_1.isWindows ? _win32 : _posix;
|
|
39
|
+
const { join, normalize } = path;
|
|
40
|
+
const regExpEscapeChars = [
|
|
41
|
+
"!",
|
|
42
|
+
"$",
|
|
43
|
+
"(",
|
|
44
|
+
")",
|
|
45
|
+
"*",
|
|
46
|
+
"+",
|
|
47
|
+
".",
|
|
48
|
+
"=",
|
|
49
|
+
"?",
|
|
50
|
+
"[",
|
|
51
|
+
"\\",
|
|
52
|
+
"^",
|
|
53
|
+
"{",
|
|
54
|
+
"|",
|
|
55
|
+
];
|
|
56
|
+
const rangeEscapeChars = ["-", "\\", "]"];
|
|
57
|
+
/** Convert a glob string to a regular expression.
|
|
58
|
+
*
|
|
59
|
+
* Tries to match bash glob expansion as closely as possible.
|
|
60
|
+
*
|
|
61
|
+
* Basic glob syntax:
|
|
62
|
+
* - `*` - Matches everything without leaving the path segment.
|
|
63
|
+
* - `?` - Matches any single character.
|
|
64
|
+
* - `{foo,bar}` - Matches `foo` or `bar`.
|
|
65
|
+
* - `[abcd]` - Matches `a`, `b`, `c` or `d`.
|
|
66
|
+
* - `[a-d]` - Matches `a`, `b`, `c` or `d`.
|
|
67
|
+
* - `[!abcd]` - Matches any single character besides `a`, `b`, `c` or `d`.
|
|
68
|
+
* - `[[:<class>:]]` - Matches any character belonging to `<class>`.
|
|
69
|
+
* - `[[:alnum:]]` - Matches any digit or letter.
|
|
70
|
+
* - `[[:digit:]abc]` - Matches any digit, `a`, `b` or `c`.
|
|
71
|
+
* - See https://facelessuser.github.io/wcmatch/glob/#posix-character-classes
|
|
72
|
+
* for a complete list of supported character classes.
|
|
73
|
+
* - `\` - Escapes the next character for an `os` other than `"windows"`.
|
|
74
|
+
* - \` - Escapes the next character for `os` set to `"windows"`.
|
|
75
|
+
* - `/` - Path separator.
|
|
76
|
+
* - `\` - Additional path separator only for `os` set to `"windows"`.
|
|
77
|
+
*
|
|
78
|
+
* Extended syntax:
|
|
79
|
+
* - Requires `{ extended: true }`.
|
|
80
|
+
* - `?(foo|bar)` - Matches 0 or 1 instance of `{foo,bar}`.
|
|
81
|
+
* - `@(foo|bar)` - Matches 1 instance of `{foo,bar}`. They behave the same.
|
|
82
|
+
* - `*(foo|bar)` - Matches _n_ instances of `{foo,bar}`.
|
|
83
|
+
* - `+(foo|bar)` - Matches _n > 0_ instances of `{foo,bar}`.
|
|
84
|
+
* - `!(foo|bar)` - Matches anything other than `{foo,bar}`.
|
|
85
|
+
* - See https://www.linuxjournal.com/content/bash-extended-globbing.
|
|
86
|
+
*
|
|
87
|
+
* Globstar syntax:
|
|
88
|
+
* - Requires `{ globstar: true }`.
|
|
89
|
+
* - `**` - Matches any number of any path segments.
|
|
90
|
+
* - Must comprise its entire path segment in the provided glob.
|
|
91
|
+
* - See https://www.linuxjournal.com/content/globstar-new-bash-globbing-option.
|
|
92
|
+
*
|
|
93
|
+
* Note the following properties:
|
|
94
|
+
* - The generated `RegExp` is anchored at both start and end.
|
|
95
|
+
* - Repeating and trailing separators are tolerated. Trailing separators in the
|
|
96
|
+
* provided glob have no meaning and are discarded.
|
|
97
|
+
* - Absolute globs will only match absolute paths, etc.
|
|
98
|
+
* - Empty globs will match nothing.
|
|
99
|
+
* - Any special glob syntax must be contained to one path segment. For example,
|
|
100
|
+
* `?(foo|bar/baz)` is invalid. The separator will take precedence and the
|
|
101
|
+
* first segment ends with an unclosed group.
|
|
102
|
+
* - If a path segment ends with unclosed groups or a dangling escape prefix, a
|
|
103
|
+
* parse error has occurred. Every character for that segment is taken
|
|
104
|
+
* literally in this event.
|
|
105
|
+
*
|
|
106
|
+
* Limitations:
|
|
107
|
+
* - A negative group like `!(foo|bar)` will wrongly be converted to a negative
|
|
108
|
+
* look-ahead followed by a wildcard. This means that `!(foo).js` will wrongly
|
|
109
|
+
* fail to match `foobar.js`, even though `foobar` is not `foo`. Effectively,
|
|
110
|
+
* `!(foo|bar)` is treated like `!(@(foo|bar)*)`. This will work correctly if
|
|
111
|
+
* the group occurs not nested at the end of the segment. */
|
|
112
|
+
function globToRegExp(glob, { extended = true, globstar: globstarOption = true, os = os_js_1.osType, caseInsensitive = false, } = {}) {
|
|
113
|
+
if (glob == "") {
|
|
114
|
+
return /(?!)/;
|
|
115
|
+
}
|
|
116
|
+
const sep = os == "windows" ? "(?:\\\\|/)+" : "/+";
|
|
117
|
+
const sepMaybe = os == "windows" ? "(?:\\\\|/)*" : "/*";
|
|
118
|
+
const seps = os == "windows" ? ["\\", "/"] : ["/"];
|
|
119
|
+
const globstar = os == "windows"
|
|
120
|
+
? "(?:[^\\\\/]*(?:\\\\|/|$)+)*"
|
|
121
|
+
: "(?:[^/]*(?:/|$)+)*";
|
|
122
|
+
const wildcard = os == "windows" ? "[^\\\\/]*" : "[^/]*";
|
|
123
|
+
const escapePrefix = os == "windows" ? "`" : "\\";
|
|
124
|
+
// Remove trailing separators.
|
|
125
|
+
let newLength = glob.length;
|
|
126
|
+
for (; newLength > 1 && seps.includes(glob[newLength - 1]); newLength--)
|
|
127
|
+
;
|
|
128
|
+
glob = glob.slice(0, newLength);
|
|
129
|
+
let regExpString = "";
|
|
130
|
+
// Terminates correctly. Trust that `j` is incremented every iteration.
|
|
131
|
+
for (let j = 0; j < glob.length;) {
|
|
132
|
+
let segment = "";
|
|
133
|
+
const groupStack = [];
|
|
134
|
+
let inRange = false;
|
|
135
|
+
let inEscape = false;
|
|
136
|
+
let endsWithSep = false;
|
|
137
|
+
let i = j;
|
|
138
|
+
// Terminates with `i` at the non-inclusive end of the current segment.
|
|
139
|
+
for (; i < glob.length && !seps.includes(glob[i]); i++) {
|
|
140
|
+
if (inEscape) {
|
|
141
|
+
inEscape = false;
|
|
142
|
+
const escapeChars = inRange ? rangeEscapeChars : regExpEscapeChars;
|
|
143
|
+
segment += escapeChars.includes(glob[i]) ? `\\${glob[i]}` : glob[i];
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (glob[i] == escapePrefix) {
|
|
147
|
+
inEscape = true;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (glob[i] == "[") {
|
|
151
|
+
if (!inRange) {
|
|
152
|
+
inRange = true;
|
|
153
|
+
segment += "[";
|
|
154
|
+
if (glob[i + 1] == "!") {
|
|
155
|
+
i++;
|
|
156
|
+
segment += "^";
|
|
157
|
+
}
|
|
158
|
+
else if (glob[i + 1] == "^") {
|
|
159
|
+
i++;
|
|
160
|
+
segment += "\\^";
|
|
161
|
+
}
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
else if (glob[i + 1] == ":") {
|
|
165
|
+
let k = i + 1;
|
|
166
|
+
let value = "";
|
|
167
|
+
while (glob[k + 1] != null && glob[k + 1] != ":") {
|
|
168
|
+
value += glob[k + 1];
|
|
169
|
+
k++;
|
|
170
|
+
}
|
|
171
|
+
if (glob[k + 1] == ":" && glob[k + 2] == "]") {
|
|
172
|
+
i = k + 2;
|
|
173
|
+
if (value == "alnum")
|
|
174
|
+
segment += "\\dA-Za-z";
|
|
175
|
+
else if (value == "alpha")
|
|
176
|
+
segment += "A-Za-z";
|
|
177
|
+
else if (value == "ascii")
|
|
178
|
+
segment += "\x00-\x7F";
|
|
179
|
+
else if (value == "blank")
|
|
180
|
+
segment += "\t ";
|
|
181
|
+
else if (value == "cntrl")
|
|
182
|
+
segment += "\x00-\x1F\x7F";
|
|
183
|
+
else if (value == "digit")
|
|
184
|
+
segment += "\\d";
|
|
185
|
+
else if (value == "graph")
|
|
186
|
+
segment += "\x21-\x7E";
|
|
187
|
+
else if (value == "lower")
|
|
188
|
+
segment += "a-z";
|
|
189
|
+
else if (value == "print")
|
|
190
|
+
segment += "\x20-\x7E";
|
|
191
|
+
else if (value == "punct") {
|
|
192
|
+
segment += "!\"#$%&'()*+,\\-./:;<=>?@[\\\\\\]^_‘{|}~";
|
|
193
|
+
}
|
|
194
|
+
else if (value == "space")
|
|
195
|
+
segment += "\\s\v";
|
|
196
|
+
else if (value == "upper")
|
|
197
|
+
segment += "A-Z";
|
|
198
|
+
else if (value == "word")
|
|
199
|
+
segment += "\\w";
|
|
200
|
+
else if (value == "xdigit")
|
|
201
|
+
segment += "\\dA-Fa-f";
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (glob[i] == "]" && inRange) {
|
|
207
|
+
inRange = false;
|
|
208
|
+
segment += "]";
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if (inRange) {
|
|
212
|
+
if (glob[i] == "\\") {
|
|
213
|
+
segment += `\\\\`;
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
segment += glob[i];
|
|
217
|
+
}
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
if (glob[i] == ")" && groupStack.length > 0 &&
|
|
221
|
+
groupStack[groupStack.length - 1] != "BRACE") {
|
|
222
|
+
segment += ")";
|
|
223
|
+
const type = groupStack.pop();
|
|
224
|
+
if (type == "!") {
|
|
225
|
+
segment += wildcard;
|
|
226
|
+
}
|
|
227
|
+
else if (type != "@") {
|
|
228
|
+
segment += type;
|
|
229
|
+
}
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
if (glob[i] == "|" && groupStack.length > 0 &&
|
|
233
|
+
groupStack[groupStack.length - 1] != "BRACE") {
|
|
234
|
+
segment += "|";
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (glob[i] == "+" && extended && glob[i + 1] == "(") {
|
|
238
|
+
i++;
|
|
239
|
+
groupStack.push("+");
|
|
240
|
+
segment += "(?:";
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
if (glob[i] == "@" && extended && glob[i + 1] == "(") {
|
|
244
|
+
i++;
|
|
245
|
+
groupStack.push("@");
|
|
246
|
+
segment += "(?:";
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (glob[i] == "?") {
|
|
250
|
+
if (extended && glob[i + 1] == "(") {
|
|
251
|
+
i++;
|
|
252
|
+
groupStack.push("?");
|
|
253
|
+
segment += "(?:";
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
segment += ".";
|
|
257
|
+
}
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
if (glob[i] == "!" && extended && glob[i + 1] == "(") {
|
|
261
|
+
i++;
|
|
262
|
+
groupStack.push("!");
|
|
263
|
+
segment += "(?!";
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (glob[i] == "{") {
|
|
267
|
+
groupStack.push("BRACE");
|
|
268
|
+
segment += "(?:";
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
if (glob[i] == "}" && groupStack[groupStack.length - 1] == "BRACE") {
|
|
272
|
+
groupStack.pop();
|
|
273
|
+
segment += ")";
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
if (glob[i] == "," && groupStack[groupStack.length - 1] == "BRACE") {
|
|
277
|
+
segment += "|";
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
if (glob[i] == "*") {
|
|
281
|
+
if (extended && glob[i + 1] == "(") {
|
|
282
|
+
i++;
|
|
283
|
+
groupStack.push("*");
|
|
284
|
+
segment += "(?:";
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
const prevChar = glob[i - 1];
|
|
288
|
+
let numStars = 1;
|
|
289
|
+
while (glob[i + 1] == "*") {
|
|
290
|
+
i++;
|
|
291
|
+
numStars++;
|
|
292
|
+
}
|
|
293
|
+
const nextChar = glob[i + 1];
|
|
294
|
+
if (globstarOption && numStars == 2 &&
|
|
295
|
+
[...seps, undefined].includes(prevChar) &&
|
|
296
|
+
[...seps, undefined].includes(nextChar)) {
|
|
297
|
+
segment += globstar;
|
|
298
|
+
endsWithSep = true;
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
segment += wildcard;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
segment += regExpEscapeChars.includes(glob[i]) ? `\\${glob[i]}` : glob[i];
|
|
307
|
+
}
|
|
308
|
+
// Check for unclosed groups or a dangling backslash.
|
|
309
|
+
if (groupStack.length > 0 || inRange || inEscape) {
|
|
310
|
+
// Parse failure. Take all characters from this segment literally.
|
|
311
|
+
segment = "";
|
|
312
|
+
for (const c of glob.slice(j, i)) {
|
|
313
|
+
segment += regExpEscapeChars.includes(c) ? `\\${c}` : c;
|
|
314
|
+
endsWithSep = false;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
regExpString += segment;
|
|
318
|
+
if (!endsWithSep) {
|
|
319
|
+
regExpString += i < glob.length ? sep : sepMaybe;
|
|
320
|
+
endsWithSep = true;
|
|
321
|
+
}
|
|
322
|
+
// Terminates with `i` at the start of the next segment.
|
|
323
|
+
while (seps.includes(glob[i]))
|
|
324
|
+
i++;
|
|
325
|
+
// Check that the next value of `j` is indeed higher than the current value.
|
|
326
|
+
if (!(i > j)) {
|
|
327
|
+
throw new Error("Assertion failure: i > j (potential infinite loop)");
|
|
328
|
+
}
|
|
329
|
+
j = i;
|
|
330
|
+
}
|
|
331
|
+
regExpString = `^${regExpString}$`;
|
|
332
|
+
return new RegExp(regExpString, caseInsensitive ? "i" : "");
|
|
333
|
+
}
|
|
334
|
+
exports.globToRegExp = globToRegExp;
|
|
335
|
+
/** Test whether the given string is a glob */
|
|
336
|
+
function isGlob(str) {
|
|
337
|
+
const chars = { "{": "}", "(": ")", "[": "]" };
|
|
338
|
+
const regex = /\\(.)|(^!|\*|\?|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/;
|
|
339
|
+
if (str === "") {
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
let match;
|
|
343
|
+
while ((match = regex.exec(str))) {
|
|
344
|
+
if (match[2])
|
|
345
|
+
return true;
|
|
346
|
+
let idx = match.index + match[0].length;
|
|
347
|
+
// if an open bracket/brace/paren is escaped,
|
|
348
|
+
// set the index to the next closing character
|
|
349
|
+
const open = match[1];
|
|
350
|
+
const close = open ? chars[open] : null;
|
|
351
|
+
if (open && close) {
|
|
352
|
+
const n = str.indexOf(close, idx);
|
|
353
|
+
if (n !== -1) {
|
|
354
|
+
idx = n + 1;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
str = str.slice(idx);
|
|
358
|
+
}
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
exports.isGlob = isGlob;
|
|
362
|
+
/** Like normalize(), but doesn't collapse "**\/.." when `globstar` is true. */
|
|
363
|
+
function normalizeGlob(glob, { globstar = false } = {}) {
|
|
364
|
+
if (glob.match(/\0/g)) {
|
|
365
|
+
throw new Error(`Glob contains invalid characters: "${glob}"`);
|
|
366
|
+
}
|
|
367
|
+
if (!globstar) {
|
|
368
|
+
return normalize(glob);
|
|
369
|
+
}
|
|
370
|
+
const s = separator_js_1.SEP_PATTERN.source;
|
|
371
|
+
const badParentPattern = new RegExp(`(?<=(${s}|^)\\*\\*${s})\\.\\.(?=${s}|$)`, "g");
|
|
372
|
+
return normalize(glob.replace(badParentPattern, "\0")).replace(/\0/g, "..");
|
|
373
|
+
}
|
|
374
|
+
exports.normalizeGlob = normalizeGlob;
|
|
375
|
+
/** Like join(), but doesn't collapse "**\/.." when `globstar` is true. */
|
|
376
|
+
function joinGlobs(globs, { extended = true, globstar = false } = {}) {
|
|
377
|
+
if (!globstar || globs.length == 0) {
|
|
378
|
+
return join(...globs);
|
|
379
|
+
}
|
|
380
|
+
if (globs.length === 0)
|
|
381
|
+
return ".";
|
|
382
|
+
let joined;
|
|
383
|
+
for (const glob of globs) {
|
|
384
|
+
const path = glob;
|
|
385
|
+
if (path.length > 0) {
|
|
386
|
+
if (!joined)
|
|
387
|
+
joined = path;
|
|
388
|
+
else
|
|
389
|
+
joined += `${separator_js_1.SEP}${path}`;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (!joined)
|
|
393
|
+
return ".";
|
|
394
|
+
return normalizeGlob(joined, { extended, globstar });
|
|
395
|
+
}
|
|
396
|
+
exports.joinGlobs = joinGlobs;
|
|
397
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Copyright the Browserify authors. MIT License.
|
|
2
|
+
// Ported mostly from https://github.com/browserify/path-browserify/
|
|
3
|
+
// This module is browser compatible.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
7
|
+
}) : (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
o[k2] = m[k];
|
|
10
|
+
}));
|
|
11
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
12
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
13
|
+
}) : function(o, v) {
|
|
14
|
+
o["default"] = v;
|
|
15
|
+
});
|
|
16
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
17
|
+
if (mod && mod.__esModule) return mod;
|
|
18
|
+
var result = {};
|
|
19
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
20
|
+
__setModuleDefault(result, mod);
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
24
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
25
|
+
};
|
|
26
|
+
(function (factory) {
|
|
27
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
28
|
+
var v = factory(require, exports);
|
|
29
|
+
if (v !== undefined) module.exports = v;
|
|
30
|
+
}
|
|
31
|
+
else if (typeof define === "function" && define.amd) {
|
|
32
|
+
define(["require", "exports", "../_util/os.js", "./win32.js", "./posix.js", "./common.js", "./separator.js", "./_interface.js", "./glob.js"], factory);
|
|
33
|
+
}
|
|
34
|
+
})(function (require, exports) {
|
|
35
|
+
"use strict";
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.SEP_PATTERN = exports.SEP = exports.toNamespacedPath = exports.toFileUrl = exports.sep = exports.resolve = exports.relative = exports.parse = exports.normalize = exports.join = exports.isAbsolute = exports.fromFileUrl = exports.format = exports.extname = exports.dirname = exports.delimiter = exports.basename = exports.posix = exports.win32 = void 0;
|
|
38
|
+
const os_js_1 = require("../_util/os.js");
|
|
39
|
+
const _win32 = __importStar(require("./win32.js"));
|
|
40
|
+
const _posix = __importStar(require("./posix.js"));
|
|
41
|
+
const path = os_js_1.isWindows ? _win32 : _posix;
|
|
42
|
+
exports.win32 = _win32;
|
|
43
|
+
exports.posix = _posix;
|
|
44
|
+
exports.basename = path.basename, exports.delimiter = path.delimiter, exports.dirname = path.dirname, exports.extname = path.extname, exports.format = path.format, exports.fromFileUrl = path.fromFileUrl, exports.isAbsolute = path.isAbsolute, exports.join = path.join, exports.normalize = path.normalize, exports.parse = path.parse, exports.relative = path.relative, exports.resolve = path.resolve, exports.sep = path.sep, exports.toFileUrl = path.toFileUrl, exports.toNamespacedPath = path.toNamespacedPath;
|
|
45
|
+
__exportStar(require("./common.js"), exports);
|
|
46
|
+
var separator_js_1 = require("./separator.js");
|
|
47
|
+
Object.defineProperty(exports, "SEP", { enumerable: true, get: function () { return separator_js_1.SEP; } });
|
|
48
|
+
Object.defineProperty(exports, "SEP_PATTERN", { enumerable: true, get: function () { return separator_js_1.SEP_PATTERN; } });
|
|
49
|
+
__exportStar(require("./_interface.js"), exports);
|
|
50
|
+
__exportStar(require("./glob.js"), exports);
|
|
51
|
+
});
|