Skip to content

Commit 3145656

Browse files
committed
chore: init
0 parents  commit 3145656

File tree

12 files changed

+4616
-0
lines changed

12 files changed

+4616
-0
lines changed

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@antfu"
3+
}

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [antfu]

.github/workflows/release.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Install pnpm
17+
uses: pnpm/action-setup@v2
18+
19+
- name: Set node
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: 16.x
23+
24+
- run: npx changelogithub
25+
env:
26+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.cache
2+
.DS_Store
3+
.idea
4+
*.log
5+
*.tgz
6+
coverage
7+
dist
8+
lib-cov
9+
logs
10+
node_modules
11+
temp

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ignore-workspace-root-check=true

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Please refer to https://github.com/antfu/contribute

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Anthony Fu <https://github.com/antfu>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Open in Codeflow
2+
3+
Enhances the GitHub to add a button to open the repo/issue/PR in Codeflow.
4+
5+
<!-- [Install on Greasyfork](https://greasyfork.org/en/scripts/461320-open-in-codeflow) -->
6+
7+
## Sponsors
8+
9+
<p align="center">
10+
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
11+
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
12+
</a>
13+
</p>
14+
15+
## License
16+
17+
[MIT](./LICENSE) License © 2023 [Anthony Fu](https://github.com/antfu)

bump.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import fs from 'node:fs/promises'
2+
3+
const { version } = JSON.parse(await fs.readFile('package.json', 'utf8'))
4+
const content = await fs.readFile('index.js', 'utf8')
5+
const newContent = content.replace(/\/\/ @version\s+.*$/m, `// @version ${version}`)
6+
await fs.writeFile('index.js', newContent, 'utf8')

index.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// ==UserScript==
2+
// @name Open in Codeflow
3+
// @namespace http://tampermonkey.net/
4+
// @homepageURL https://github.com/antfu/open-in-codeflow
5+
// @supportURL https://github.com/antfu/open-in-codeflow
6+
// @namespace https://greasyfork.org/en/scripts/
7+
// @version 0.1
8+
// @description try to take over the world!
9+
// @author Anthony Fu
10+
// @license MIT
11+
// @match https://github.com/**
12+
// @icon https://www.google.com/s2/favicons?sz=64&domain=pr.new
13+
// @grant none
14+
// ==/UserScript==
15+
16+
(function () {
17+
'use strict'
18+
19+
const id = 'open-in-codeflow'
20+
21+
function createButton() {
22+
const a = document.createElement('a')
23+
a.href = location.href.replace('https://github.com/', 'https://pr.new/')
24+
a.target = '_blank'
25+
a.classList.add('btn')
26+
a.classList.add('btn-sm')
27+
a.innerText = ' Codeflow '
28+
a.id = id
29+
const icon = document.createElement('img')
30+
// TODO: update the logo?
31+
icon.src = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIwLjdlbSIgaGVpZ2h0PSIxZW0iIHZpZXdCb3g9IjAgMCAyNTYgMzY4Ij48cGF0aCBmaWxsPSIjNDlBMkY4IiBkPSJNMTA5LjU4NiAyMTcuMDEzSDBMMjAwLjM0IDBsLTUzLjkyNiAxNTAuMjMzSDI1Nkw1NS42NDUgMzY3LjI0Nmw1My45MjctMTUwLjIzM3oiLz48L3N2Zz4='
32+
icon.classList.add('octicon')
33+
a.prepend(icon)
34+
return a
35+
}
36+
37+
function run() {
38+
if (document.querySelector(`#${id}`))
39+
return
40+
41+
const repoActions = document.querySelector('#repository-details-container ul')
42+
if (repoActions) {
43+
const li = document.createElement('li')
44+
li.appendChild(createButton())
45+
repoActions.prepend(li)
46+
return
47+
}
48+
49+
const prActions = document.querySelector('.gh-header-actions')
50+
if (prActions)
51+
prActions.prepend(createButton())
52+
}
53+
54+
run()
55+
56+
// listen to github page loaded event
57+
document.addEventListener('pjax:end', () => run())
58+
document.addEventListener('turbo:render', () => run())
59+
})()

package.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "open-in-codeflow",
3+
"type": "module",
4+
"version": "0.0.0",
5+
"private": true,
6+
"packageManager": "pnpm@8.2.0",
7+
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
8+
"license": "MIT",
9+
"funding": "https://github.com/sponsors/antfu",
10+
"homepage": "https://github.com/antfu/open-in-codeflow#readme",
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/antfu/open-in-codeflow.git"
14+
},
15+
"bugs": "https://github.com/antfu/open-in-codeflow/issues",
16+
"scripts": {
17+
"lint": "eslint .",
18+
"release": "bumpp -x \"node bump.js\" --all"
19+
},
20+
"devDependencies": {
21+
"@antfu/eslint-config": "^0.38.4",
22+
"@antfu/ni": "^0.21.3",
23+
"@antfu/utils": "^0.7.2",
24+
"@types/node": "^18.15.11",
25+
"bumpp": "^9.1.0",
26+
"eslint": "^8.38.0",
27+
"esno": "^0.16.3",
28+
"lint-staged": "^13.2.1",
29+
"pnpm": "^8.2.0",
30+
"rimraf": "^5.0.0",
31+
"simple-git-hooks": "^2.8.1",
32+
"typescript": "^5.0.4",
33+
"unbuild": "^1.2.1",
34+
"vite": "^4.2.1"
35+
},
36+
"simple-git-hooks": {
37+
"pre-commit": "pnpm lint-staged"
38+
},
39+
"lint-staged": {
40+
"*": "eslint --fix"
41+
}
42+
}

0 commit comments

Comments
 (0)