-
-
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.
- Loading branch information
0 parents
commit 408fad1
Showing
14 changed files
with
9,769 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
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,67 @@ | ||
name: build | ||
on: | ||
push: | ||
branches: | ||
- "**" | ||
jobs: | ||
cancel-existing: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: rokroskar/workflow-run-cleanup-action@v0.2.2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
test: | ||
needs: cancel-existing | ||
strategy: | ||
matrix: | ||
os: | ||
- macos-latest | ||
- windows-latest | ||
- ubuntu-latest | ||
node: | ||
- 10 | ||
- 12 | ||
exclude: | ||
- os: macos-latest | ||
node: 10 | ||
- os: windows-latest | ||
node: 10 | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
- run: git config --global user.email "actions@github.com" | ||
- run: git config --global user.name "GitHub Actions" | ||
- run: yarn --frozen-lockfile | ||
- run: yarn test | ||
- name: Push changed files | ||
run: yarn dw-ci push-changed-files | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }} | ||
- name: Coveralls | ||
run: yarn dw-ci coveralls | ||
env: | ||
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
COVERALLS_SERVICE_NAME: github | ||
COVERALLS_GIT_COMMIT: ${{ github.sha }} | ||
COVERALLS_GIT_BRANCH: ${{ github.ref }} | ||
release: | ||
needs: test | ||
if: github.ref == 'refs/heads/master' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12 | ||
- run: yarn --frozen-lockfile | ||
- name: Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: yarn semantic-release |
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,13 @@ | ||
.DS_Store | ||
/.babelrc.json | ||
/.cz.json | ||
/.editorconfig | ||
/.env.json | ||
/.eslintrc.json | ||
/.nyc_output | ||
/.releaserc.json | ||
/.test.env.json | ||
/.vscode | ||
/coverage | ||
/dist | ||
/node_modules |
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,3 @@ | ||
FROM gitpod/workspace-full | ||
|
||
RUN sudo apt-get update && sudo apt-get install -y libgtk-3-0 libx11-xcb1 libnss3 libxss1 libasound2 |
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,10 @@ | ||
image: | ||
file: .gitpod.Dockerfile | ||
|
||
tasks: | ||
- init: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >>~/.npmrc | ||
- init: yarn --frozen-lockfile | ||
|
||
vscode: | ||
extensions: | ||
- karlito40.fix-irregular-whitespace@0.0.3:8jjyZYuYF6yW6nwsAiulrg== |
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,26 @@ | ||
{ | ||
"extends": [ | ||
":semanticCommits" | ||
], | ||
"packageRules": [ | ||
{ | ||
"packagePatterns": [ | ||
"*" | ||
], | ||
"semanticCommitType": "chore" | ||
}, | ||
{ | ||
"depTypeList": [ | ||
"dependencies", | ||
"devDependencies", | ||
"peerDependencies", | ||
"optionalDependencies" | ||
], | ||
"semanticCommitType": "fix" | ||
} | ||
], | ||
"lockFileMaintenance": { | ||
"enabled": true, | ||
"schedule": "at any time" | ||
} | ||
} |
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,19 @@ | ||
# License | ||
|
||
Unless stated otherwise all works are: | ||
|
||
Copyright © Sebastian Landwehr <info@dword-design.de> | ||
|
||
and licensed under: | ||
|
||
[MIT License](https://opensource.org/licenses/MIT) | ||
|
||
## MIT License | ||
|
||
MIT License Copyright (c) <year> <copyright holders> | ||
|
||
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 (including the next paragraph) 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. |
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,42 @@ | ||
<!-- TITLE/ --> | ||
# @dword-design/github-extension-utils | ||
<!-- /TITLE --> | ||
|
||
<!-- BADGES/ --> | ||
[![NPM version](https://img.shields.io/npm/v/@dword-design/github-extension-utils.svg)](https://npmjs.org/package/@dword-design/github-extension-utils) | ||
![Linux macOS Windows compatible](https://img.shields.io/badge/os-linux%20%7C%C2%A0macos%20%7C%C2%A0windows-blue) | ||
[![Build status](https://img.shields.io/github/workflow/status/dword-design/github-extension-utils/build)](https://github.com/dword-design/github-extension-utils/actions) | ||
[![Coverage status](https://img.shields.io/coveralls/dword-design/github-extension-utils)](https://coveralls.io/github/dword-design/github-extension-utils) | ||
[![Dependency status](https://img.shields.io/david/dword-design/github-extension-utils)](https://david-dm.org/dword-design/github-extension-utils) | ||
![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen) | ||
|
||
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/dword-design/github-extension-utils) | ||
<!-- /BADGES --> | ||
|
||
<!-- DESCRIPTION/ --> | ||
|
||
<!-- /DESCRIPTION --> | ||
|
||
<!-- INSTALL/ --> | ||
## Install | ||
|
||
```bash | ||
# NPM | ||
$ npm install @dword-design/github-extension-utils | ||
|
||
# Yarn | ||
$ yarn add @dword-design/github-extension-utils | ||
``` | ||
<!-- /INSTALL --> | ||
|
||
<!-- LICENSE/ --> | ||
## License | ||
|
||
Unless stated otherwise all works are: | ||
|
||
Copyright © Sebastian Landwehr <info@dword-design.de> | ||
|
||
and licensed under: | ||
|
||
[MIT License](https://opensource.org/licenses/MIT) | ||
<!-- /LICENSE --> |
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,28 @@ | ||
{ | ||
"name": "@dword-design/github-extension-utils", | ||
"version": "1.0.0", | ||
"description": "", | ||
"repository": "dword-design/github-extension-utils", | ||
"license": "MIT", | ||
"author": "Sebastian Landwehr <info@dword-design.de>", | ||
"main": "dist/index.js", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"commit": "base commit", | ||
"dev": "base dev", | ||
"prepare": "base prepare", | ||
"prepublishOnly": "base prepublishOnly", | ||
"test": "base test" | ||
}, | ||
"dependencies": { | ||
"@dword-design/functions": "^1.1.2" | ||
}, | ||
"devDependencies": { | ||
"@dword-design/base": "^6.15.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
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,127 @@ | ||
import { endent } from '@dword-design/functions' | ||
import showDialog from './show-dialog' | ||
|
||
const accessTokenUrl = '/settings/tokens/new?scopes=repo' | ||
|
||
const getTokenMessage = error => { | ||
switch (error.response?.status) { | ||
case 401: | ||
return 'The access token is not valid.' | ||
case 403: | ||
if (error.response.headers['x-ratelimit-remaining'] === '0') { | ||
return 'API rate limit exceeded. Please create an access token.' | ||
} | ||
return 'You are not allowed to access GitHub API. Please create an access token.' | ||
default: | ||
return undefined | ||
} | ||
} | ||
|
||
export default (error, options = {}) => { | ||
if (!options.tokenKey) { | ||
throw new Error('Missing token key') | ||
} | ||
const tokenMessage = getTokenMessage(error) | ||
if (tokenMessage) { | ||
let $flash = document.querySelector('.github-repository-list-badges-flash') | ||
if ($flash) { | ||
$flash.remove() | ||
} | ||
$flash = document.createElement('div') | ||
$flash.classList.add( | ||
'github-repository-list-badges-flash', | ||
'flash', | ||
'flash-error', | ||
'position-fixed', | ||
'box-shadow-medium' | ||
) | ||
$flash.style.bottom = '16px' | ||
$flash.style.right = '16px' | ||
$flash.style.maxWidth = 'calc(100% - 32px)' | ||
$flash.style.zIndex = 33 | ||
$flash.style.padding = 0 | ||
$flash.innerHTML = endent` | ||
<button | ||
class="close-button js-flash-close position-absolute text-orange" | ||
style="right: 16px; top: 50%; transform: translateY(-50%)" | ||
type="button" | ||
> | ||
<!-- <%= octicon "x", :"aria-label" => "Close" %> --> | ||
<svg width="12" height="16" viewBox="0 0 12 16" class="octicon octicon-x" aria-label="Close" role="img"> | ||
<path | ||
fill-rule="evenodd" | ||
d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z" | ||
/> | ||
</svg> | ||
</button> | ||
<svg | ||
class="octicon octicon-alert position-absolute" | ||
style="left: 16px; top: 50%; transform: translateY(-50%)" | ||
pxmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 16 16" | ||
width="16" | ||
height="16" | ||
aria-hidden="true" | ||
> | ||
<path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 000 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 00.01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></path> | ||
</svg> | ||
` | ||
const $flashButton = document.createElement('button') | ||
$flashButton.type = 'button' | ||
$flashButton.style.padding = '16px 40px' | ||
$flashButton.style.whiteSpace = 'normal' | ||
$flashButton.style.textAlign = 'left' | ||
$flashButton.classList.add('btn-link', 'text-orange', 'bg-red-light') | ||
$flashButton.innerText = `GitHub Repository List Badges: ${tokenMessage}` | ||
$flash.append($flashButton) | ||
$flashButton.onclick = () => { | ||
const $dialog = showDialog() | ||
|
||
const $token = document.createElement('input') | ||
$token.classList.add('form-control', 'input-block') | ||
$token.type = 'text' | ||
$token.placeholder = 'Access token' | ||
$token.setAttribute('aria-label', 'Access token') | ||
$token.required = true | ||
|
||
const $form = document.createElement('form') | ||
$form.onsubmit = event => { | ||
event.preventDefault() | ||
localStorage.setItem(options.tokenKey, $token.value) | ||
window.location.reload() | ||
} | ||
$dialog.append($form) | ||
|
||
const $body = document.createElement('div') | ||
$body.classList.add('Box-body') | ||
$form.append($body) | ||
|
||
const $message = document.createElement('p') | ||
$message.innerHTML = `GitHub API requests are limited to 60 per hour per IP address. By providing a <a href="${accessTokenUrl}" target="_blank">GitHub access token</a>, you can increase the limit to <strong>5.000</strong> requests per hour.` | ||
$body.append($message) | ||
|
||
$body.append($token) | ||
|
||
const $footer = document.createElement('div') | ||
$footer.classList.add('Box-footer', 'text-right') | ||
$form.append($footer) | ||
|
||
const $cancel = document.createElement('button') | ||
$cancel.type = 'button' | ||
$cancel.classList.add('btn', 'mr-2') | ||
$cancel.innerText = 'Cancel' | ||
$cancel.onclick = () => $dialog.remove() | ||
$footer.append($cancel) | ||
|
||
const $save = document.createElement('button') | ||
$save.classList.add('btn', 'btn-primary') | ||
$save.type = 'submit' | ||
$save.innerText = 'Save' | ||
$footer.append($save) | ||
} | ||
|
||
document.body.prepend($flash) | ||
} else { | ||
console.error(error) | ||
} | ||
} |
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,5 @@ | ||
import handleError from './handle-error' | ||
|
||
export default { | ||
'missing token key': () => expect(handleError).toThrow('Missing token key'), | ||
} |
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,3 @@ | ||
import handleError from './handle-error' | ||
|
||
export { handleError } |
Oops, something went wrong.