-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Eveble/develop
feat: add helpers
- Loading branch information
Showing
62 changed files
with
2,192 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
6 changes: 1 addition & 5 deletions
6
...b/ISSUE_TEMPLATE/pull_request_template.md → .github/pull_request_template.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
This PR CHANGES. | ||
|
||
## Todos | ||
|
||
- [ ] Todo | ||
This PR changes. | ||
|
||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: "Update Pull Request" | ||
name: 'Update Pull Request' | ||
|
||
on: | ||
pull_request: | ||
|
@@ -14,62 +14,36 @@ jobs: | |
CONFIGURATION_PATH: .github/pr-labeler.yml # optional, .github/pr-labeler.yml is the default value | ||
format_fix_pr_information: | ||
runs-on: ubuntu-latest | ||
name: Format fix pull request | ||
name: Format fix Pull request | ||
if: ${{ contains(github.event.pull_request.title, 'fix') }} | ||
needs: [assign_labels] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Read 'fix' body template | ||
id: pull_request_body | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: ./.github/ISSUE_TEMPLATE/fix_template.md | ||
- name: Update Pull Request | ||
uses: tzkhan/[email protected] | ||
with: | ||
repo-token: "${{ secrets.GITHUB_TOKEN }}" | ||
branch-regex: ${{ secrets.PROJECT_KEY_PATTERN }} # [a-zA-Z0-9_]{3}-[\d]+ | ||
lowercase-branch: true | ||
title-template: '[%branch%]' | ||
replace-title: false | ||
title-prefix-space: true | ||
uppercase-title: false | ||
body-template: | | ||
[Link to %branch%](${{ secrets.TICKET_URL }}%branch%) | ||
--- | ||
${{ steps.pull_request_body.outputs.content }} | ||
replace-body: false | ||
body-prefix-newline-count: 2 | ||
uppercase-body: true | ||
- uses: actions/checkout@v2 | ||
- name: Read 'fix' body template | ||
id: pull_request_body | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: ./.github/PULL_REQUEST_TEMPLATE/bug_fix.md | ||
- name: Update Pull Request | ||
uses: AsasInnab/pr-body-action@v1 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
body: ${{ steps.pull_request_body.outputs.content }} | ||
format_default_pr_information: | ||
runs-on: ubuntu-latest | ||
name: Format default pull request | ||
name: Format default Pull request | ||
if: > | ||
github.actor != 'github-actions[bot]' && (! contains(github.event.pull_request.labels.*.name, 'bug') && ! contains(github.event.pull_request.labels.*.name, 'fix')) | ||
needs: [assign_labels] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Read 'default' body template | ||
id: pull_request_body | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: ./.github/ISSUE_TEMPLATE/pull_request_template.md | ||
- name: Update Pull Request | ||
uses: tzkhan/[email protected] | ||
with: | ||
repo-token: "${{ secrets.GITHUB_TOKEN }}" | ||
branch-regex: ${{ secrets.PROJECT_KEY_PATTERN }} # [a-zA-Z0-9_]{3}-[\d]+ | ||
lowercase-branch: true | ||
title-template: '[%branch%]' | ||
replace-title: false | ||
title-prefix-space: true | ||
uppercase-title: false | ||
body-template: | | ||
[Link to %branch%](${{ secrets.TICKET_URL }}%branch%) | ||
--- | ||
${{ steps.pull_request_body.outputs.content }} | ||
replace-body: false | ||
body-prefix-newline-count: 2 | ||
uppercase-body: true | ||
- uses: actions/checkout@v2 | ||
- name: Read 'default' body template | ||
id: pull_request_body | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: ./.github/pull_request_template.md | ||
- name: Update Pull Request | ||
uses: AsasInnab/pr-body-action@v1 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
body: ${{ steps.pull_request_body.outputs.content }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: 'Update tracked Pull Request' | ||
|
||
on: | ||
pull_request: | ||
types: [opened] | ||
|
||
jobs: | ||
format: | ||
name: Format tracked Pull Request | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Initialize workflow variables | ||
id: vars | ||
shell: bash | ||
run: | | ||
PROJECT_KEY=$PROJECT_KEY | ||
echo ::set-output name=PROJECT_KEY::${PROJECT_KEY} | ||
unset HAS_PROJECT_KEY | ||
if [ -n $PROJECT_KEY ]; then HAS_PROJECT_KEY='true' ; fi | ||
echo set-output name=HAS_PROJECT_KEY::${HAS_PROJECT_KEY} | ||
echo ::set-output name=HAS_PROJECT_KEY::${HAS_PROJECT_KEY} | ||
env: | ||
PROJECT_KEY: '${{ secrets.PROJECT_KEY }}' | ||
- name: Update Pull Request | ||
if: ${{ steps.vars.outputs.HAS_PROJECT_KEY && contains(github.event.pull_request.title, steps.vars.outputs.PROJECT_KEY ) }} | ||
uses: tzkhan/[email protected] | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
branch-regex: ${{ secrets.PROJECT_KEY_PATTERN }} # [a-zA-Z0-9_]{3}-[\d]+ | ||
lowercase-branch: true | ||
title-template: '[%branch%]' | ||
replace-title: false | ||
title-prefix-space: true | ||
uppercase-title: false | ||
body-template: | | ||
[Link to %branch%](${{ secrets.TICKET_URL }}%branch%) | ||
--- | ||
replace-body: false | ||
body-prefix-newline-count: 2 | ||
uppercase-body: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Adam Desivi <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export const NATIVE_ERROR_CLASSES = [ | ||
Error, | ||
EvalError, | ||
RangeError, | ||
ReferenceError, | ||
SyntaxError, | ||
TypeError, | ||
URIError, | ||
]; | ||
|
||
export const NATIVE_TYPES = { | ||
// Order is important! | ||
string: String, | ||
boolean: Boolean, | ||
date: Date, | ||
number: Number, | ||
regexp: RegExp, | ||
array: Array, | ||
symbol: Symbol, | ||
map: Map, | ||
function: Function, | ||
object: Object, | ||
}; | ||
|
||
export const NATIVE_CONSTRUCTOR_NAMES = [ | ||
'String', | ||
'Boolean', | ||
'Date', | ||
'Number', | ||
'RegExp', | ||
'Array', | ||
'Symbol', | ||
'Map', | ||
'Function', | ||
'Object', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const TYPE_NAME_KEY = Symbol('eveble:typeName'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Constants | ||
import * as LITERAL from './constants/literal'; | ||
import * as METADATA_KEYS from './constants/metadata-keys'; | ||
// Types | ||
import { types } from './types'; | ||
// Testing | ||
import { isMocha } from './testing/is-mocha'; | ||
import { isMochaInWatchMode } from './testing/is-mocha-in-watch-mode'; | ||
import { isSinonClockDate } from './testing/is-sinon-clock-date'; | ||
// Types | ||
import { getNativeType } from './types/get-native-type'; | ||
import { getScalarType } from './types/get-scalar-type'; | ||
import { getTypeName } from './types/get-type-name'; | ||
import { hasTypeName } from './types/has-type-name'; | ||
import { setTypeName } from './types/set-type-name'; | ||
import { isClassInstance } from './types/is-class-instance'; | ||
import { isClass } from './types/is-class'; | ||
import { isConstructor } from './types/is-constructor'; | ||
import { isErrorClass } from './types/is-error-class'; | ||
import { isErrorInstance } from './types/is-error-instance'; | ||
import { isMultidimensionalArray } from './types/is-multidimensional-array'; | ||
import { isNativeType } from './types/is-native-type'; | ||
import { isNativeTypeInstance } from './types/is-native-type-instance'; | ||
import { isScalarType } from './types/is-scalar-type'; | ||
import { isSubclassOf } from './types/is-subclass-of'; | ||
import { superClass } from './types/super-class'; | ||
import { superPrototype } from './types/super-prototype'; | ||
|
||
export { | ||
// Constants | ||
LITERAL, | ||
METADATA_KEYS, | ||
// Types | ||
types, | ||
// Testing | ||
isMocha, | ||
isMochaInWatchMode, | ||
isSinonClockDate, | ||
// Types | ||
getNativeType, | ||
getScalarType, | ||
getTypeName, | ||
hasTypeName, | ||
setTypeName, | ||
isClassInstance, | ||
isClass, | ||
isConstructor, | ||
isErrorClass, | ||
isErrorInstance, | ||
isMultidimensionalArray, | ||
isNativeType, | ||
isNativeTypeInstance, | ||
isScalarType, | ||
isSubclassOf, | ||
superClass, | ||
superPrototype, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Evaluates if Mocha is running in watch('--watch') mode. | ||
* @param nodeProcess - Instance of `NodeJS.Process`. | ||
* @returns Returns true if Mocha is running in watch mode, else false. | ||
*/ | ||
export function isMochaInWatchMode(nodeProcess: NodeJS.Process): boolean { | ||
return nodeProcess.argv.slice(2).includes('--watch'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Evaluates if Mocha is running on context(global/window) i.e. testing environment is present. | ||
* @param context - Global context which is evaluated. | ||
* @returns Returns true if Mocha is running on context, else false. | ||
*/ | ||
export function isMocha(context: any): boolean { | ||
return ['afterEach', 'after', 'beforeEach', 'before', 'describe', 'it'].every( | ||
(fnName) => { | ||
return context[fnName] instanceof Function; | ||
} | ||
); | ||
} |
Oops, something went wrong.