feat: docker compose maybe
This commit is contained in:
271
node_modules/globrex/index.js
generated
vendored
Normal file
271
node_modules/globrex/index.js
generated
vendored
Normal file
@ -0,0 +1,271 @@
|
||||
const isWin = process.platform === 'win32';
|
||||
const SEP = isWin ? `\\\\+` : `\\/`;
|
||||
const SEP_ESC = isWin ? `\\\\` : `/`;
|
||||
const GLOBSTAR = `((?:[^/]*(?:/|$))*)`;
|
||||
const WILDCARD = `([^/]*)`;
|
||||
const GLOBSTAR_SEGMENT = `((?:[^${SEP_ESC}]*(?:${SEP_ESC}|$))*)`;
|
||||
const WILDCARD_SEGMENT = `([^${SEP_ESC}]*)`;
|
||||
|
||||
/**
|
||||
* Convert any glob pattern to a JavaScript Regexp object
|
||||
* @param {String} glob Glob pattern to convert
|
||||
* @param {Object} opts Configuration object
|
||||
* @param {Boolean} [opts.extended=false] Support advanced ext globbing
|
||||
* @param {Boolean} [opts.globstar=false] Support globstar
|
||||
* @param {Boolean} [opts.strict=true] be laissez faire about mutiple slashes
|
||||
* @param {Boolean} [opts.filepath=''] Parse as filepath for extra path related features
|
||||
* @param {String} [opts.flags=''] RegExp globs
|
||||
* @returns {Object} converted object with string, segments and RegExp object
|
||||
*/
|
||||
function globrex(glob, {extended = false, globstar = false, strict = false, filepath = false, flags = ''} = {}) {
|
||||
let regex = '';
|
||||
let segment = '';
|
||||
let path = { regex: '', segments: [] };
|
||||
|
||||
// If we are doing extended matching, this boolean is true when we are inside
|
||||
// a group (eg {*.html,*.js}), and false otherwise.
|
||||
let inGroup = false;
|
||||
let inRange = false;
|
||||
|
||||
// extglob stack. Keep track of scope
|
||||
const ext = [];
|
||||
|
||||
// Helper function to build string and segments
|
||||
function add(str, {split, last, only}={}) {
|
||||
if (only !== 'path') regex += str;
|
||||
if (filepath && only !== 'regex') {
|
||||
path.regex += (str === '\\/' ? SEP : str);
|
||||
if (split) {
|
||||
if (last) segment += str;
|
||||
if (segment !== '') {
|
||||
if (!flags.includes('g')) segment = `^${segment}$`; // change it 'includes'
|
||||
path.segments.push(new RegExp(segment, flags));
|
||||
}
|
||||
segment = '';
|
||||
} else {
|
||||
segment += str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let c, n;
|
||||
for (let i = 0; i < glob.length; i++) {
|
||||
c = glob[i];
|
||||
n = glob[i + 1];
|
||||
|
||||
if (['\\', '$', '^', '.', '='].includes(c)) {
|
||||
add(`\\${c}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c === '/') {
|
||||
add(`\\${c}`, {split: true});
|
||||
if (n === '/' && !strict) regex += '?';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c === '(') {
|
||||
if (ext.length) {
|
||||
add(c);
|
||||
continue;
|
||||
}
|
||||
add(`\\${c}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c === ')') {
|
||||
if (ext.length) {
|
||||
add(c);
|
||||
let type = ext.pop();
|
||||
if (type === '@') {
|
||||
add('{1}');
|
||||
} else if (type === '!') {
|
||||
add('([^\/]*)');
|
||||
} else {
|
||||
add(type);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
add(`\\${c}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c === '|') {
|
||||
if (ext.length) {
|
||||
add(c);
|
||||
continue;
|
||||
}
|
||||
add(`\\${c}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c === '+') {
|
||||
if (n === '(' && extended) {
|
||||
ext.push(c);
|
||||
continue;
|
||||
}
|
||||
add(`\\${c}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c === '@' && extended) {
|
||||
if (n === '(') {
|
||||
ext.push(c);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (c === '!') {
|
||||
if (extended) {
|
||||
if (inRange) {
|
||||
add('^');
|
||||
continue
|
||||
}
|
||||
if (n === '(') {
|
||||
ext.push(c);
|
||||
add('(?!');
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
add(`\\${c}`);
|
||||
continue;
|
||||
}
|
||||
add(`\\${c}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c === '?') {
|
||||
if (extended) {
|
||||
if (n === '(') {
|
||||
ext.push(c);
|
||||
} else {
|
||||
add('.');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
add(`\\${c}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c === '[') {
|
||||
if (inRange && n === ':') {
|
||||
i++; // skip [
|
||||
let value = '';
|
||||
while(glob[++i] !== ':') value += glob[i];
|
||||
if (value === 'alnum') add('(\\w|\\d)');
|
||||
else if (value === 'space') add('\\s');
|
||||
else if (value === 'digit') add('\\d');
|
||||
i++; // skip last ]
|
||||
continue;
|
||||
}
|
||||
if (extended) {
|
||||
inRange = true;
|
||||
add(c);
|
||||
continue;
|
||||
}
|
||||
add(`\\${c}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c === ']') {
|
||||
if (extended) {
|
||||
inRange = false;
|
||||
add(c);
|
||||
continue;
|
||||
}
|
||||
add(`\\${c}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c === '{') {
|
||||
if (extended) {
|
||||
inGroup = true;
|
||||
add('(');
|
||||
continue;
|
||||
}
|
||||
add(`\\${c}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c === '}') {
|
||||
if (extended) {
|
||||
inGroup = false;
|
||||
add(')');
|
||||
continue;
|
||||
}
|
||||
add(`\\${c}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c === ',') {
|
||||
if (inGroup) {
|
||||
add('|');
|
||||
continue;
|
||||
}
|
||||
add(`\\${c}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c === '*') {
|
||||
if (n === '(' && extended) {
|
||||
ext.push(c);
|
||||
continue;
|
||||
}
|
||||
// Move over all consecutive "*"'s.
|
||||
// Also store the previous and next characters
|
||||
let prevChar = glob[i - 1];
|
||||
let starCount = 1;
|
||||
while (glob[i + 1] === '*') {
|
||||
starCount++;
|
||||
i++;
|
||||
}
|
||||
let nextChar = glob[i + 1];
|
||||
if (!globstar) {
|
||||
// globstar is disabled, so treat any number of "*" as one
|
||||
add('.*');
|
||||
} else {
|
||||
// globstar is enabled, so determine if this is a globstar segment
|
||||
let isGlobstar =
|
||||
starCount > 1 && // multiple "*"'s
|
||||
(prevChar === '/' || prevChar === undefined) && // from the start of the segment
|
||||
(nextChar === '/' || nextChar === undefined); // to the end of the segment
|
||||
if (isGlobstar) {
|
||||
// it's a globstar, so match zero or more path segments
|
||||
add(GLOBSTAR, {only:'regex'});
|
||||
add(GLOBSTAR_SEGMENT, {only:'path', last:true, split:true});
|
||||
i++; // move over the "/"
|
||||
} else {
|
||||
// it's not a globstar, so only match one path segment
|
||||
add(WILDCARD, {only:'regex'});
|
||||
add(WILDCARD_SEGMENT, {only:'path'});
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
add(c);
|
||||
}
|
||||
|
||||
|
||||
// When regexp 'g' flag is specified don't
|
||||
// constrain the regular expression with ^ & $
|
||||
if (!flags.includes('g')) {
|
||||
regex = `^${regex}$`;
|
||||
segment = `^${segment}$`;
|
||||
if (filepath) path.regex = `^${path.regex}$`;
|
||||
}
|
||||
|
||||
const result = {regex: new RegExp(regex, flags)};
|
||||
|
||||
// Push the last segment
|
||||
if (filepath) {
|
||||
path.segments.push(new RegExp(segment, flags));
|
||||
path.regex = new RegExp(path.regex, flags);
|
||||
path.globstar = new RegExp(!flags.includes('g') ? `^${GLOBSTAR_SEGMENT}$` : GLOBSTAR_SEGMENT, flags);
|
||||
result.path = path;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = globrex;
|
21
node_modules/globrex/license
generated
vendored
Normal file
21
node_modules/globrex/license
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Terkel Gjervig Nielsen
|
||||
|
||||
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.
|
30
node_modules/globrex/package.json
generated
vendored
Normal file
30
node_modules/globrex/package.json
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "globrex",
|
||||
"version": "0.1.2",
|
||||
"description": "Glob to regular expression with support for extended globs",
|
||||
"main": "index.js",
|
||||
"author": "Terkel Gjervig",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/terkelg/globrex"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"glob",
|
||||
"regex",
|
||||
"regexp",
|
||||
"parser",
|
||||
"glob2regx",
|
||||
"compiler"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "tape test/*.js | tap-spec"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tap-spec": "^4.1.1",
|
||||
"tape": "^4.8.0"
|
||||
}
|
||||
}
|
178
node_modules/globrex/readme.md
generated
vendored
Normal file
178
node_modules/globrex/readme.md
generated
vendored
Normal file
@ -0,0 +1,178 @@
|
||||
<div align="center">
|
||||
<img src="https://github.com/terkelg/globrex/raw/master/globrex.png" alt="globrex" width="500" />
|
||||
</div>
|
||||
|
||||
<h1 align="center">globrex</h1>
|
||||
|
||||
<div align="center">
|
||||
<a href="https://npmjs.org/package/globrex">
|
||||
<img src="https://img.shields.io/npm/v/globrex.svg" alt="version" />
|
||||
</a>
|
||||
<a href="https://travis-ci.org/terkelg/globrex">
|
||||
<img src="https://img.shields.io/travis/terkelg/globrex.svg" alt="travis" />
|
||||
</a>
|
||||
<a href="https://ci.appveyor.com/project/terkelg/globrex">
|
||||
<img src="https://ci.appveyor.com/api/projects/status/ecbnb3whibj5iqcj?svg=true" alt="appveyor" />
|
||||
</a>
|
||||
<a href="https://npmjs.org/package/globrex">
|
||||
<img src="https://img.shields.io/npm/dm/globrex.svg" alt="downloads" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div align="center">Simple but powerful glob to regular expression compiler.</div>
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
npm install globrex --save
|
||||
```
|
||||
|
||||
|
||||
## Core Features
|
||||
|
||||
- 💪 **extended globbing:** transform advance `ExtGlob` features
|
||||
- 📦 **simple**: no dependencies
|
||||
- 🛣️ **paths**: split paths into multiple `RegExp` segments
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const globrex = require('globrex');
|
||||
|
||||
const result = globrex('p*uck')
|
||||
// => { regex: /^p.*uck$/, string: '^p.*uck$', segments: [ /^p.*uck$/ ] }
|
||||
|
||||
result.regex.test('pluck'); // true
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### globrex(glob, options)
|
||||
|
||||
Type: `function`<br>
|
||||
Returns: `Object`
|
||||
|
||||
Transform globs intp regular expressions.
|
||||
Returns object with the following properties:
|
||||
|
||||
|
||||
#### regex
|
||||
|
||||
Type: `RegExp`
|
||||
|
||||
JavaScript `RegExp` instance.
|
||||
|
||||
> **Note**: Read more about how to use [RegExp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) on MDN.
|
||||
|
||||
|
||||
#### path
|
||||
|
||||
This property only exists if the option `filepath` is true.
|
||||
|
||||
> **Note:** `filepath` is `false` by default
|
||||
|
||||
#### path.segments
|
||||
|
||||
Type: `Array`
|
||||
|
||||
Array of `RegExp` instances seperated by `/`.
|
||||
This can be usable when working with file paths or urls.
|
||||
|
||||
Example array could be:
|
||||
```js
|
||||
[ /^foo$/, /^bar$/, /^([^\/]*)$/, '^baz\\.(md|js|txt)$' ]
|
||||
```
|
||||
|
||||
|
||||
#### path.regex
|
||||
|
||||
Type: `RegExp`
|
||||
|
||||
JavaScript `RegExp` instance build for testign against paths.
|
||||
The regex have different path seperators depending on host OS.
|
||||
|
||||
|
||||
### glob
|
||||
|
||||
Type: `String`
|
||||
|
||||
Glob string to transform.
|
||||
|
||||
|
||||
### options.extended
|
||||
|
||||
Type: `Boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Enable all advanced features from `extglob`.
|
||||
|
||||
Matching so called "extended" globs pattern like single character matching, matching ranges of characters, group matching, etc.
|
||||
|
||||
> **Note**: Interprets `[a-d]` as `[abcd]`. To match a literal `-`, include it as first or last character.
|
||||
|
||||
|
||||
### options.globstar
|
||||
|
||||
Type: `Boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
When globstar is `false` globs like `'/foo/*'` are transformed to the following
|
||||
`'^\/foo\/.*$'` which will match any string beginning with `'/foo/'`.
|
||||
|
||||
When the globstar option is `true`, the same `'/foo/*'` glob is transformed to
|
||||
`'^\/foo\/[^/]*$'` which will match any string beginning with `'/foo/'` that **does not have** a `'/'` to the right of it. `'/foo/*'` will match: `'/foo/bar'`, `'/foo/bar.txt'` but not `'/foo/bar/baz'` or `'/foo/bar/baz.txt'`.
|
||||
|
||||
> **Note**: When globstar is `true`, `'/foo/**'` is equivelant to `'/foo/*'` when globstar is `false`.
|
||||
|
||||
|
||||
### options.strict
|
||||
|
||||
Type: `Boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Be forgiving about mutiple slashes, like `///` and make everything after the first `/` optional. This is how bash glob works.
|
||||
|
||||
|
||||
### options.flags
|
||||
|
||||
Type: `String`<br>
|
||||
Default: `''`
|
||||
|
||||
RegExp flags (e.g. `'i'` ) to pass to the RegExp constructor.
|
||||
|
||||
|
||||
### options.filepath
|
||||
|
||||
Type: `Boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Parse input strings as it was a file path for special path related features. This feature only makes sense if the input is a POSIX path like `/foo/bar/hello.js` or URLs.
|
||||
|
||||
When `true` the returned object will have an additional `path` object.
|
||||
|
||||
- `segment`: Array containing a `RegExp` object for each path segment.
|
||||
- `regex`: OS specific file path `RegExp`. Path seperator used is based on the operating system.
|
||||
- `globstar`: Regex string used to test for globstars.
|
||||
|
||||
> **Note: Please only use forward-slashes in file path glob expressions**
|
||||
> Though windows uses either `/` or `\` as its path separator, only `/`
|
||||
> characters are used by this glob implementation. You must use
|
||||
> forward-slashes **only** in glob expressions. Back-slashes will always
|
||||
> be interpreted as escape characters, not path separators.
|
||||
|
||||
|
||||
## References
|
||||
|
||||
Learn more about advanced globbing here
|
||||
- [mywiki.wooledge.org/glob](http://mywiki.wooledge.org/glob)
|
||||
- [linuxjournal](http://www.linuxjournal.com/content/bash-extended-globbing)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Terkel Gjervig](https://terkel.com)
|
Reference in New Issue
Block a user