first commit
This commit is contained in:
21
node_modules/issue-parser/LICENSE
generated
vendored
Normal file
21
node_modules/issue-parser/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Pierre Vanduynslager
|
||||
|
||||
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.
|
||||
447
node_modules/issue-parser/README.md
generated
vendored
Normal file
447
node_modules/issue-parser/README.md
generated
vendored
Normal file
@@ -0,0 +1,447 @@
|
||||
# issue-parser
|
||||
|
||||
Parser for [Github](https://github.com), [GitLab](https://gitlab.com) and [Bitbucket](https://bitbucket.org) issues actions, references and mentions
|
||||
|
||||
<!--status-badges start -->
|
||||
|
||||
[![Node CI Workflow Status][github-actions-ci-badge]][github-actions-ci-link]
|
||||
|
||||
<!--status-badges end -->
|
||||
|
||||
The parser can identify:
|
||||
- GitHub [closing keywords](https://help.github.com/articles/closing-issues-using-keywords), [duplicate keyword](https://help.github.com/articles/about-duplicate-issues-and-pull-requests), [issue references](https://guides.github.com/features/issues/#notifications) and [user mentions](https://guides.github.com/features/issues/#notifications)
|
||||
- GitLab [closing keywords](https://docs.gitlab.com/ee/user/project/issues/automatic_issue_closing.html), [duplicate keyword](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12845), [issue references](https://about.gitlab.com/2016/03/08/gitlab-tutorial-its-all-connected) and [user mentions](https://about.gitlab.com/2016/03/08/gitlab-tutorial-its-all-connected)
|
||||
- Bitbucket [closing keywords](https://confluence.atlassian.com/bitbucket/resolve-issues-automatically-when-users-push-code-221451126.html), [issue references](https://confluence.atlassian.com/bitbucket/mark-up-comments-issues-and-commit-messages-321859781.html) and [user mentions](https://confluence.atlassian.com/bitbucket/mark-up-comments-issues-and-commit-messages-321859781.html)
|
||||
- [Custom](#custom-format) or [additional](#extend-existing-format) keywords
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
$ npm install --save issue-parser
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### GitHub format
|
||||
|
||||
```js
|
||||
const issueParser = require('issue-parser');
|
||||
const parse = issueParser('github');
|
||||
|
||||
parse('Issue description, ref user/package#1, Fix #2, Duplicate of #3 /cc @user');
|
||||
/*
|
||||
{
|
||||
refs: [{raw: 'user/package#1', slug: 'user/package', prefix: '#', issue: '1'}],
|
||||
actions: {
|
||||
close: [{raw: 'Fix #2', action: 'Fix', prefix: '#', issue: '2'}],
|
||||
duplicate: [{raw: 'Duplicate of #3', action: 'Duplicate of', prefix: '#', issue: '3'}],
|
||||
},
|
||||
mentions: [{raw: '@user', prefix: '@', user: 'user'}],
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
### GitLab format
|
||||
|
||||
```js
|
||||
const issueParser = require('issue-parser');
|
||||
const parse = issueParser('gitlab');
|
||||
|
||||
parse('Issue description, ref group/user/package#1, !2, implement #3, /duplicate #4 /cc @user');
|
||||
/*
|
||||
{
|
||||
refs: [
|
||||
{raw: 'group/user/package#1', slug: 'group/user/package', prefix: '#', issue: '1'},
|
||||
{raw: '!2', slug: 'group/user/package', prefix: '!', issue: '2'},
|
||||
],
|
||||
actions: {
|
||||
close: [{raw: 'implement #3', action: 'Implement', prefix: '#', issue: '4'}],
|
||||
duplicate: [{raw: 'Duplicate of #4', action: 'Duplicate of', prefix: '#', issue: '4'}],
|
||||
},
|
||||
mentions: [{raw: '@user', prefix: '@', user: 'user'}],
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
### Bitbucket format
|
||||
|
||||
```js
|
||||
const issueParser = require('issue-parser');
|
||||
const parse = issueParser('bitbucket');
|
||||
|
||||
parse('Issue description, ref user/package#1, fixing #2. /cc @user');
|
||||
/*
|
||||
{
|
||||
refs: [{raw: 'user/package#1', slug: 'user/package', prefix: '#', issue: '1'}],
|
||||
actions: {
|
||||
close: [{raw: 'fixing #2', action: 'Fixing', prefix: '#', issue: '2'}],
|
||||
},
|
||||
mentions: [{raw: '@user', prefix: '@', user: 'user'}],
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
### Custom format
|
||||
|
||||
```js
|
||||
const issueParser = require('issue-parser');
|
||||
const parse = issueParser({actions: {fix: ['complete'], hold: ['holds up']}, issuePrefixes: ['🐛']});
|
||||
|
||||
parse('Issue description, related to user/package🐛1, Complete 🐛2, holds up 🐛3');
|
||||
/*
|
||||
{
|
||||
refs: [{raw: 'user/package🐛1', slug: 'user/package', prefix: '🐛', issue: '1'}],
|
||||
actions: {
|
||||
fix: [{raw: 'Complete 🐛2', action: 'Complete', prefix: '🐛', issue: '2'}],
|
||||
hold: [{raw: 'holds up 🐛3', action: 'Holds up', prefix: '🐛', issue: '3'}],
|
||||
},
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
### Extend existing format
|
||||
|
||||
```js
|
||||
const issueParser = require('issue-parser');
|
||||
const parse = issueParser('github', {actions: {parent: ['parent of'], related: ['related to']}});
|
||||
|
||||
parse('Issue description, ref user/package#1, Fix #2, Parent of #3, related to #4 /cc @user');
|
||||
/*
|
||||
{
|
||||
refs: [{raw: 'user/package#1', slug: 'user/package', prefix: '#', issue: '1'}],
|
||||
actions: {
|
||||
close: [{raw: 'Fix #2', action: 'Fix', prefix: '#', issue: '2'}],
|
||||
parent: [{raw: 'Parent of #3', action: 'Parent of', prefix: '#', issue: '3'}],
|
||||
related: [{raw: 'related to #4', action: 'Related to', prefix: '#', issue: '4'}],
|
||||
},
|
||||
mentions: [{raw: '@user', prefix: '@', user: 'user'}],
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
### Parse references
|
||||
|
||||
```text
|
||||
#1
|
||||
```
|
||||
```js
|
||||
{refs: [{raw: '#1', slug: undefined, prefix: '#', issue: '1'}]}
|
||||
```
|
||||
|
||||
### Parse repository slug
|
||||
|
||||
```text
|
||||
owner/repo#1
|
||||
```
|
||||
```js
|
||||
{refs: [{raw: 'owner/repo#1', slug: 'owner/repo', prefix: '#', issue: '1'}]}
|
||||
```
|
||||
|
||||
### Parse closing keywords
|
||||
|
||||
```text
|
||||
Fix #1
|
||||
```
|
||||
```js
|
||||
{actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]}}
|
||||
```
|
||||
|
||||
### Parse duplicate keywords
|
||||
|
||||
```text
|
||||
Duplicate of #1
|
||||
```
|
||||
```js
|
||||
{actions: {duplicate: [{raw: 'Duplicate of #1', action: 'Duplicate of', slug: undefined, prefix: '#', issue: '1'}]}}
|
||||
```
|
||||
|
||||
### Parse user mentions
|
||||
|
||||
```text
|
||||
@user
|
||||
```
|
||||
```js
|
||||
{mentions: [{raw: '@user', prefix: '@', user: 'user'}]}
|
||||
```
|
||||
|
||||
### Parse references with full issue URL
|
||||
|
||||
```text
|
||||
https://github.com/owner/repo/pull/1
|
||||
|
||||
Fix https://github.com/owner/repo/issues/2
|
||||
```
|
||||
```js
|
||||
{
|
||||
refs: [{raw: 'https://github.com/owner/repo/pull/1', slug: 'owner/repo', prefix: undefined, issue: '1'},]
|
||||
actions: {
|
||||
close: [
|
||||
{raw: 'Fix https://github.com/owner/repo/issues/2', action: 'Fix', slug: 'owner/repo', prefix: undefined, issue: '2'}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Ignore keywords case
|
||||
|
||||
```text
|
||||
FIX #1
|
||||
```
|
||||
```js
|
||||
{actions: {close: [{raw: 'FIX #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]}}
|
||||
```
|
||||
|
||||
### Support delimiters between action keyword and issue
|
||||
|
||||
```text
|
||||
Fix: #1
|
||||
```
|
||||
```js
|
||||
{actions: {close: [{raw: 'Fix: #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]}}
|
||||
```
|
||||
|
||||
### Ignore references in back-tick quotes
|
||||
|
||||
```text
|
||||
Fix #1 `Fix #2` @user1 `@user2`
|
||||
```
|
||||
```js
|
||||
{
|
||||
actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]},
|
||||
mentions: [{raw: '@user1', prefix: '@', user: 'user1'}]
|
||||
}
|
||||
```
|
||||
|
||||
### Include references in escaped back-tick quotes
|
||||
|
||||
```text
|
||||
\`Fix #1\` \`@user\`
|
||||
```
|
||||
```js
|
||||
{
|
||||
actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]},
|
||||
mentions: [{raw: '@user1', prefix: '@', user: 'user1'}]
|
||||
}
|
||||
```
|
||||
|
||||
### Ignore references in fenced blocks
|
||||
|
||||
````text
|
||||
Fix #1
|
||||
|
||||
```js
|
||||
console.log('Fix #2');
|
||||
```
|
||||
|
||||
@user1
|
||||
|
||||
```js
|
||||
console.log('@user2');
|
||||
```
|
||||
````
|
||||
```js
|
||||
{
|
||||
actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]},
|
||||
mentions: [{raw: '@user1', prefix: '@', user: 'user1'}]
|
||||
}
|
||||
```
|
||||
|
||||
### Include references in escaped fenced blocks
|
||||
|
||||
```text
|
||||
\`\`\`
|
||||
Fix #1
|
||||
\`\`\`
|
||||
|
||||
\`\`\`
|
||||
@user
|
||||
\`\`\`
|
||||
```
|
||||
```js
|
||||
{
|
||||
actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]},
|
||||
mentions: [{raw: '@user', prefix: '@', user: 'user'}]
|
||||
}
|
||||
```
|
||||
|
||||
### Ignore references in <code> tags
|
||||
|
||||
```text
|
||||
Fix #1
|
||||
<code>Fix #2</code>
|
||||
<code><code>Fix #3</code></code>
|
||||
@user1
|
||||
<code>@user2</code>
|
||||
```
|
||||
```js
|
||||
{
|
||||
actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]},
|
||||
mentions: [{raw: '@user1', prefix: '@', user: 'user1'}]
|
||||
}
|
||||
```
|
||||
|
||||
### Include references in escaped <code> tags
|
||||
|
||||
```text
|
||||
`<code>`Fix #1`</code>`
|
||||
`<code>`@user`</code>`
|
||||
```
|
||||
```js
|
||||
{
|
||||
actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]},
|
||||
mentions: [{raw: '@user', prefix: '@', user: 'user'}]
|
||||
}
|
||||
```
|
||||
|
||||
### Ignore malformed references
|
||||
|
||||
```text
|
||||
Fix #1 Fix #2a Fix a#3
|
||||
```
|
||||
```js
|
||||
{actions: {close: [{raw: 'Fix #1', action: 'Fix', slug: undefined, prefix: '#', issue: '1'}]}}
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### issueParser([options], [overrides]) => parse
|
||||
|
||||
Create a [parser](#parsetext--result).
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object` `String`<br>
|
||||
Parser options. Can be `github`, `gitlab` or `bitbucket` for predefined options, or an object for custom options.
|
||||
|
||||
##### actions
|
||||
|
||||
Type: `Object`<br>
|
||||
Default:
|
||||
`{close: ['close', 'closes', 'closed', 'closing', 'fix', 'fixes', 'fixed', 'fixing', 'resolve', 'resolves', 'resolved', 'resolving', 'implement', 'implements', 'implemented', 'implementing'],
|
||||
duplicate: ['Duplicate of', '/duplicate']}`
|
||||
|
||||
Object with type of action as key and array of keywords as value.
|
||||
|
||||
Each keyword match will be placed in the corresponding property of the [`result`](#result) `action` object. For example the with the configuration `{actions: fix: ['fixed', 'fixing']}` each action matching `fixed` or `fixing` will be under `result.actions.fix`.
|
||||
|
||||
##### delimiters
|
||||
|
||||
Type: `Array<String>` `String`<br>
|
||||
Default: `[':']`
|
||||
|
||||
List of delimiter characters allowed between an action keywords and the issue reference. The characters space (` `) and tab (` `) are always allowed.
|
||||
|
||||
##### mentionsPrefixes
|
||||
|
||||
Type: `Array<String>` `String`<br>
|
||||
Default: `['@']`
|
||||
|
||||
List of keywords used to identify user mentions.
|
||||
|
||||
##### issuePrefixes
|
||||
|
||||
Type: `Array<String>` `String`<br>
|
||||
Default: `['#', 'gh-']`
|
||||
|
||||
List of keywords used to identify issues and pull requests.
|
||||
|
||||
##### hosts
|
||||
|
||||
Type: `Array<String>` `String`<br>
|
||||
Default: `['https://github.com', 'https://gitlab.com']`
|
||||
|
||||
List of base URL used to identify issues and pull requests with [full URL](#parse-references-with-full-issue-url).
|
||||
|
||||
##### issueURLSegments
|
||||
|
||||
Type: `Array<String>` `String`<br>
|
||||
Default: `['issues', 'pull', 'merge_requests']`
|
||||
|
||||
List of URL segment used to identify issues and pull requests with [full URL](#parse-references-with-full-issue-url).
|
||||
|
||||
#### overrides
|
||||
|
||||
Type: `Object`<br>
|
||||
Option overrides. Useful when using predefined [`options`](#options) (such as `github`, `gitlab` or `bitbucket`). The `overrides` object can define the same properties as [`options`](#options).
|
||||
|
||||
For example, the following will use all the `github` predefined options but with a different `hosts` option:
|
||||
```js
|
||||
const issueParser = require('issue-parser');
|
||||
const parse = issueParser('github', {hosts: ['https://custom-url.com']});
|
||||
```
|
||||
|
||||
### parse(text) => Result
|
||||
|
||||
Parse an issue description and returns a [Result](#result) object.
|
||||
|
||||
#### text
|
||||
|
||||
Type: `String`
|
||||
|
||||
Issue text to parse.
|
||||
|
||||
### Result
|
||||
|
||||
#### actions
|
||||
|
||||
Type: `Object`
|
||||
|
||||
List of matching actions by type.<br>
|
||||
Each type of action is an array of objects with the following properties:
|
||||
|
||||
| Name | Type | Description |
|
||||
|--------|----------|---------------------------------------------------------------------------------------|
|
||||
| raw | `String` | The raw value parsed, for example `Fix #1`. |
|
||||
| action | `String` | The keyword used to identify the action, capitalized. |
|
||||
| slug | `String` | The repository owner and name, for issue referred as `<owner>/<repo>#<issue number>`. |
|
||||
| prefix | `String` | The prefix used to identify the issue. |
|
||||
| issue | `String` | The issue number. |
|
||||
|
||||
#### refs
|
||||
|
||||
Type: `Array<Object>`
|
||||
|
||||
List of issues and pull requests referenced, but not matched with an action.<br>
|
||||
Each reference has the following properties:
|
||||
|
||||
| Name | Type | Description |
|
||||
|--------|----------|---------------------------------------------------------------------------------------|
|
||||
| raw | `String` | The raw value parsed, for example `#1`. |
|
||||
| slug | `String` | The repository owner and name, for issue referred as `<owner>/<repo>#<issue number>`. |
|
||||
| prefix | `String` | The prefix used to identify the issue. |
|
||||
| issue | `String` | The issue number. |
|
||||
|
||||
#### mentions
|
||||
|
||||
Type: `Array<Object>`
|
||||
|
||||
List of users mentioned.<br>
|
||||
Each mention has the following properties:
|
||||
|
||||
| Name | Type | Description |
|
||||
|--------|----------|---------------------------------------------|
|
||||
| raw | `String` | The raw value parsed, for example `@user`. |
|
||||
| prefix | `String` | The prefix used to identify the mention. |
|
||||
| user | `String` | The user name |
|
||||
|
||||
#### allRefs
|
||||
|
||||
Type: `Array<Object>`
|
||||
|
||||
List of all issues and pull requests [referenced](#refs) or matching an [action](#actions-1).<br>
|
||||
Each reference has the following properties:
|
||||
|
||||
| Name | Type | Description |
|
||||
|--------|----------|------------------------------------------------------------------------------------------------------|
|
||||
| raw | `String` | The raw value parsed, for example `Fix #1`. |
|
||||
| action | `String` | The keyword used to identify the action or the duplicate, capitalized. Only if matched by an action. |
|
||||
| slug | `String` | The repository owner and name, for issue referred as `<owner>/<repo>#<issue number>`. |
|
||||
| prefix | `String` | The prefix used to identify the issue. |
|
||||
| issue | `String` | The issue number. |
|
||||
|
||||
|
||||
[github-actions-ci-link]: https://github.com/semantic-release/issue-parser/actions/workflows/test.yml
|
||||
|
||||
[github-actions-ci-badge]: https://github.com/semantic-release/issue-parser/actions/workflows/test.yml/badge.svg
|
||||
197
node_modules/issue-parser/index.js
generated
vendored
Normal file
197
node_modules/issue-parser/index.js
generated
vendored
Normal file
@@ -0,0 +1,197 @@
|
||||
const escapeRegExp = require('lodash.escaperegexp');
|
||||
const capitalize = require('lodash.capitalize');
|
||||
const isString = require('lodash.isstring');
|
||||
const isPlainObject = require('lodash.isplainobject');
|
||||
const uniqBy = require('lodash.uniqby');
|
||||
const hostConfig = require('./lib/hosts-config');
|
||||
|
||||
const {hasOwnProperty} = Object.prototype;
|
||||
|
||||
/* eslint prefer-named-capture-group: "off" */
|
||||
|
||||
const FENCE_BLOCK_REGEXP = /^(([ \t]*`{3,4})([^\n]*)([\s\S]+?)(^[ \t]*\2))/gm;
|
||||
const CODE_BLOCK_REGEXP = /(`(?!\\))((?:.(?!\1(?!\\)))*.?)\1/g;
|
||||
const HTML_CODE_BLOCK_REGEXP = /(<code)+?((?!(<code|<\/code>)+?)[\S\s])*(<\/code>)+?/gim;
|
||||
const LEADING_TRAILING_SLASH_REGEXP = /^\/?([^/]+(?:\/[^/]+)*)\/?$/;
|
||||
const TRAILING_SLASH_REGEXP = /\/?$/;
|
||||
|
||||
function inverse(string) {
|
||||
return string
|
||||
.split('')
|
||||
.reverse()
|
||||
.join('');
|
||||
}
|
||||
|
||||
function join(keywords) {
|
||||
return keywords
|
||||
.filter(Boolean)
|
||||
.map(escapeRegExp)
|
||||
.join('|');
|
||||
}
|
||||
|
||||
function addLeadingAndTrailingSlash(value) {
|
||||
return value.replace(LEADING_TRAILING_SLASH_REGEXP, '/$1/');
|
||||
}
|
||||
|
||||
function addTrailingSlash(value) {
|
||||
return value.replace(TRAILING_SLASH_REGEXP, '/');
|
||||
}
|
||||
|
||||
function includesIgnoreCase(array, value) {
|
||||
return array.findIndex(arrayValue => arrayValue.toUpperCase() === value.toUpperCase()) > -1;
|
||||
}
|
||||
|
||||
function buildMentionsRegexp({mentionsPrefixes}) {
|
||||
return `((?:(?:[^\\w\\n\\v\\r]|^)+(?:${join(mentionsPrefixes)})[\\w-\\.]+[^\\W])+)`;
|
||||
}
|
||||
|
||||
function buildRefRegexp({actions, delimiters, issuePrefixes, issueURLSegments, hosts}) {
|
||||
return `(?:(?:[^\\w\\n\\v\\r]|^)+(${join(
|
||||
Object.keys(actions).flatMap(key => actions[key])
|
||||
)}))?(?:[^\\w\\n\\v\\r]|^|(?: |\\t)*(?:${join([' ', '\t', ...delimiters])})(?: |\\t)*)${
|
||||
hosts.length > 0 ? `(?:${join(hosts)})?` : ''
|
||||
}((?:(?:[\\w-\\.]+)\\/)+(?:[\\w-\\.]+))?(${join([...issuePrefixes, ...issueURLSegments])})(\\d+)(?!\\w)`;
|
||||
}
|
||||
|
||||
function buildRegexp(options) {
|
||||
return new RegExp(
|
||||
options.mentionsPrefixes.length > 0
|
||||
? `(?:${buildRefRegexp(options)}|${buildMentionsRegexp(options)})`
|
||||
: buildMentionsRegexp(options),
|
||||
'gim'
|
||||
);
|
||||
}
|
||||
|
||||
function buildMentionRegexp({mentionsPrefixes}) {
|
||||
return new RegExp(`(${join(mentionsPrefixes)})([\\w-\\.]+)`, 'gim');
|
||||
}
|
||||
|
||||
function parse(text, regexp, mentionRegexp, {actions, issuePrefixes, hosts}) {
|
||||
let parsed;
|
||||
const results = {
|
||||
actions: Object.keys(actions).reduce(
|
||||
(result, key) => (actions[key].length > 0 ? Object.assign(result, {[key]: []}) : result),
|
||||
{}
|
||||
),
|
||||
refs: [],
|
||||
mentions: [],
|
||||
};
|
||||
let noCodeBlock = inverse(inverse(text.replace(FENCE_BLOCK_REGEXP, '')).replace(CODE_BLOCK_REGEXP, ''));
|
||||
|
||||
while (regexp.test(noCodeBlock)) {
|
||||
noCodeBlock = noCodeBlock.replace(HTML_CODE_BLOCK_REGEXP, '');
|
||||
}
|
||||
|
||||
while ((parsed = regexp.exec(noCodeBlock)) !== null) {
|
||||
let [raw, action, slug, prefix, issue, mentions] = parsed;
|
||||
prefix =
|
||||
prefix && issuePrefixes.some(issuePrefix => issuePrefix.toUpperCase() === prefix.toUpperCase())
|
||||
? prefix
|
||||
: undefined;
|
||||
raw = parsed[0].slice(
|
||||
parsed[0].indexOf(
|
||||
parsed[1] || hosts.find(host => parsed[0].toUpperCase().includes(host.toUpperCase())) || parsed[2] || parsed[3]
|
||||
)
|
||||
);
|
||||
action = capitalize(parsed[1]);
|
||||
|
||||
const actionTypes = Object.keys(actions).filter(key => includesIgnoreCase(actions[key], action));
|
||||
|
||||
if (actionTypes.length > 0) {
|
||||
for (const actionType of actionTypes) {
|
||||
results.actions[actionType].push({raw, action, slug, prefix, issue});
|
||||
}
|
||||
} else if (issue) {
|
||||
results.refs.push({raw, slug, prefix, issue});
|
||||
} else if (mentions) {
|
||||
let parsedMention;
|
||||
while ((parsedMention = mentionRegexp.exec(mentions)) !== null) {
|
||||
const [rawMention, prefixMention, user] = parsedMention;
|
||||
|
||||
results.mentions.push({raw: rawMention.trim(), prefix: prefixMention, user});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function typeError(parentOpt, opt) {
|
||||
return new TypeError(
|
||||
`The ${[parentOpt, opt].filter(Boolean).join('.')} property must be a String or an array of Strings`
|
||||
);
|
||||
}
|
||||
|
||||
function normalize(options, parentOpt) {
|
||||
for (const opt of Object.keys(options)) {
|
||||
if (!parentOpt && opt === 'actions') {
|
||||
normalize(options[opt], opt);
|
||||
} else {
|
||||
if (!options[opt]) {
|
||||
options[opt] = [];
|
||||
} else if (isString(options[opt])) {
|
||||
options[opt] = [options[opt]];
|
||||
} else if (!Array.isArray(options[opt])) {
|
||||
throw typeError(parentOpt, opt);
|
||||
}
|
||||
|
||||
if (options[opt].length !== 0 && !options[opt].every(opt => isString(opt))) {
|
||||
throw typeError(parentOpt, opt);
|
||||
}
|
||||
|
||||
options[opt] = options[opt].filter(Boolean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (options = 'default', overrides = {}) => {
|
||||
if (!isString(options) && !isPlainObject(options)) {
|
||||
throw new TypeError('The options argument must be a String or an Object');
|
||||
}
|
||||
|
||||
if (isPlainObject(options) && hasOwnProperty.call(options, 'actions') && !isPlainObject(options.actions)) {
|
||||
throw new TypeError('The options.actions property must be an Object');
|
||||
}
|
||||
|
||||
if (isString(options) && !includesIgnoreCase(Object.keys(hostConfig), options)) {
|
||||
throw new TypeError(`The supported configuration are [${Object.keys(hostConfig).join(', ')}], got '${options}'`);
|
||||
}
|
||||
|
||||
if (!isPlainObject(overrides)) {
|
||||
throw new TypeError('The overrides argument must be an Object');
|
||||
} else if (hasOwnProperty.call(overrides, 'actions') && !isPlainObject(overrides.actions)) {
|
||||
throw new TypeError('The overrides.actions property must be an Object');
|
||||
}
|
||||
|
||||
options = isString(options) ? hostConfig[options.toLowerCase()] : options;
|
||||
|
||||
const mergedOptions = {
|
||||
...hostConfig.default,
|
||||
...options,
|
||||
...overrides,
|
||||
actions: {...hostConfig.default.actions, ...options.actions, ...overrides.actions},
|
||||
};
|
||||
|
||||
normalize(mergedOptions);
|
||||
|
||||
mergedOptions.hosts = mergedOptions.hosts.map(addTrailingSlash);
|
||||
mergedOptions.issueURLSegments = mergedOptions.issueURLSegments.map(addLeadingAndTrailingSlash);
|
||||
|
||||
const regexp = buildRegexp(mergedOptions);
|
||||
const mentionRegexp = buildMentionRegexp(mergedOptions);
|
||||
|
||||
return text => {
|
||||
if (!isString(text)) {
|
||||
throw new TypeError('The issue text must be a String');
|
||||
}
|
||||
|
||||
const results = parse(text, regexp, mentionRegexp, mergedOptions);
|
||||
|
||||
Reflect.defineProperty(results, 'allRefs', {
|
||||
get() {
|
||||
return uniqBy(this.refs.concat(...Object.keys(this.actions).map(key => this.actions[key])), 'raw');
|
||||
},
|
||||
});
|
||||
return results;
|
||||
};
|
||||
};
|
||||
115
node_modules/issue-parser/lib/hosts-config.js
generated
vendored
Normal file
115
node_modules/issue-parser/lib/hosts-config.js
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
module.exports = {
|
||||
github: {
|
||||
actions: {
|
||||
// https://help.github.com/articles/closing-issues-using-keywords
|
||||
close: ['close', 'closes', 'closed', 'fix', 'fixes', 'fixed', 'resolve', 'resolves', 'resolved'],
|
||||
block: [],
|
||||
require: [],
|
||||
parentOf: [],
|
||||
childOf: [],
|
||||
// https://help.github.com/articles/about-duplicate-issues-and-pull-requests
|
||||
duplicate: ['Duplicate of'],
|
||||
},
|
||||
delimiters: [':'],
|
||||
// https://guides.github.com/features/issues/#notifications
|
||||
mentionsPrefixes: ['@'],
|
||||
issuePrefixes: ['#', 'gh-'],
|
||||
hosts: ['https://github.com'],
|
||||
issueURLSegments: ['issues', 'pull'],
|
||||
},
|
||||
bitbucket: {
|
||||
actions: {
|
||||
// https://confluence.atlassian.com/bitbucket/resolve-issues-automatically-when-users-push-code-221451126.html
|
||||
close: [
|
||||
'close',
|
||||
'closes',
|
||||
'closed',
|
||||
'closing',
|
||||
'fix',
|
||||
'fixes',
|
||||
'fixed',
|
||||
'fixing',
|
||||
'resolve',
|
||||
'resolves',
|
||||
'resolved',
|
||||
'resolving',
|
||||
],
|
||||
block: [],
|
||||
require: [],
|
||||
parentOf: [],
|
||||
childOf: [],
|
||||
duplicate: [],
|
||||
},
|
||||
delimiters: [],
|
||||
// https://confluence.atlassian.com/bitbucket/mark-up-comments-issues-and-commit-messages-321859781.html
|
||||
mentionsPrefixes: ['@'],
|
||||
// https://confluence.atlassian.com/bitbucket/mark-up-comments-issues-and-commit-messages-321859781.html
|
||||
issuePrefixes: ['#'],
|
||||
hosts: [],
|
||||
issueURLSegments: [],
|
||||
},
|
||||
gitlab: {
|
||||
actions: {
|
||||
// https://docs.gitlab.com/ee/user/project/issues/automatic_issue_closing.html
|
||||
close: [
|
||||
'close',
|
||||
'closes',
|
||||
'closed',
|
||||
'closing',
|
||||
'fix',
|
||||
'fixes',
|
||||
'fixed',
|
||||
'fixing',
|
||||
'resolve',
|
||||
'resolves',
|
||||
'resolved',
|
||||
'resolving',
|
||||
'implement',
|
||||
'implements',
|
||||
'implemented',
|
||||
'implementing',
|
||||
],
|
||||
block: [],
|
||||
require: [],
|
||||
parentOf: [],
|
||||
childOf: [],
|
||||
// https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12845
|
||||
duplicate: ['/duplicate'],
|
||||
},
|
||||
delimiters: [],
|
||||
// https://about.gitlab.com/2016/03/08/gitlab-tutorial-its-all-connected
|
||||
mentionsPrefixes: ['@'],
|
||||
// https://about.gitlab.com/2016/03/08/gitlab-tutorial-its-all-connected
|
||||
issuePrefixes: ['#', '!'],
|
||||
hosts: ['https://gitlab.com'],
|
||||
issueURLSegments: ['issues', 'merge_requests'],
|
||||
},
|
||||
default: {
|
||||
actions: {
|
||||
close: [
|
||||
'close',
|
||||
'closes',
|
||||
'closed',
|
||||
'closing',
|
||||
'fix',
|
||||
'fixes',
|
||||
'fixed',
|
||||
'fixing',
|
||||
'resolve',
|
||||
'resolves',
|
||||
'resolved',
|
||||
'resolving',
|
||||
'implement',
|
||||
'implements',
|
||||
'implemented',
|
||||
'implementing',
|
||||
],
|
||||
duplicate: ['Duplicate of', '/duplicate'],
|
||||
},
|
||||
delimiters: [':'],
|
||||
mentionsPrefixes: ['@'],
|
||||
issuePrefixes: ['#', 'gh-'],
|
||||
hosts: ['https://github.com', 'https://gitlab.com'],
|
||||
issueURLSegments: ['issues', 'pull', 'merge_requests'],
|
||||
},
|
||||
};
|
||||
108
node_modules/issue-parser/package.json
generated
vendored
Normal file
108
node_modules/issue-parser/package.json
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"name": "issue-parser",
|
||||
"description": "Parser for Github, GitLab and Bitbucket issues actions, references and mentions",
|
||||
"version": "7.0.1",
|
||||
"author": "Pierre Vanduynslager (https://github.com/pvdlg)",
|
||||
"ava": {
|
||||
"files": [
|
||||
"test/**/*.test.js"
|
||||
]
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/semantic-release/issue-parser/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash.capitalize": "^4.2.1",
|
||||
"lodash.escaperegexp": "^4.1.2",
|
||||
"lodash.isplainobject": "^4.0.6",
|
||||
"lodash.isstring": "^4.0.1",
|
||||
"lodash.uniqby": "^4.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "6.1.3",
|
||||
"codecov": "3.8.3",
|
||||
"lockfile-lint": "4.13.2",
|
||||
"ls-engines": "0.9.1",
|
||||
"npm-run-all2": "6.2.0",
|
||||
"nyc": "15.1.0",
|
||||
"publint": "0.2.8",
|
||||
"xo": "0.28.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.17 || >=20.6.1"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/semantic-release/issue-parser#readme",
|
||||
"keywords": [
|
||||
"bitbucket",
|
||||
"close",
|
||||
"duplicate",
|
||||
"fix",
|
||||
"github",
|
||||
"gitlab",
|
||||
"issues",
|
||||
"mentions",
|
||||
"parser",
|
||||
"pr",
|
||||
"pull-request",
|
||||
"references",
|
||||
"resolve"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"nyc": {
|
||||
"include": [
|
||||
"lib/**/*.js",
|
||||
"index.js"
|
||||
],
|
||||
"reporter": [
|
||||
"json",
|
||||
"text",
|
||||
"html"
|
||||
],
|
||||
"all": true
|
||||
},
|
||||
"lockfile-lint": {
|
||||
"path": "package-lock.json",
|
||||
"type": "npm",
|
||||
"validate-https": true,
|
||||
"allowed-hosts": [
|
||||
"npm"
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"printWidth": 120,
|
||||
"trailingComma": "es5"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/semantic-release/issue-parser.git"
|
||||
},
|
||||
"scripts": {
|
||||
"codecov": "codecov -f coverage/coverage-final.json",
|
||||
"test": "npm-run-all --print-label --parallel lint:* --parallel test:*",
|
||||
"test:unit": "nyc ava -v",
|
||||
"lint:js": "xo",
|
||||
"lint:lockfile": "lockfile-lint",
|
||||
"lint:engines": "ls-engines",
|
||||
"lint:publish": "publint --strict"
|
||||
},
|
||||
"renovate": {
|
||||
"extends": [
|
||||
"github>semantic-release/.github:renovate-config"
|
||||
]
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"space": true,
|
||||
"rules": {
|
||||
"unicorn/string-content": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user