-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure prettier for this project. (#24)
- Loading branch information
Showing
17 changed files
with
525 additions
and
397 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,11 @@ | ||
package.json | ||
package-lock.json | ||
build | ||
coverage | ||
dist | ||
node_modules | ||
npm-debug.log | ||
yarn-error.log | ||
yarn.lock | ||
*.log | ||
|
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,14 @@ | ||
{ | ||
"arrowParens": "always", | ||
"bracketSpacing": true, | ||
"embeddedLanguageFormatting": "auto", | ||
"endOfLine": "lf", | ||
"insertPragma": false, | ||
"proseWrap": "preserve", | ||
"requirePragma": false, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "es5", | ||
"useTabs": false, | ||
"printWidth": 100 | ||
} |
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 @@ | ||
{ | ||
"recommendations": ["esbenp.prettier-vscode"] | ||
} |
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,9 @@ | ||
{ | ||
"editor.insertSpaces": true, | ||
"editor.tabSize": 2, | ||
"editor.formatOnSave": true, | ||
"editor.defaultformatter": "esbenp.prettier-vscode", | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": 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
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 |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import { Octokit } from "https://cdn.skypack.dev/octokit?dts"; | ||
|
||
const UPLOAD_DIRECTORY = "raw"; | ||
|
||
function getBase64(file) { | ||
return new Promise((resolve, reject) => { | ||
const reader = new FileReader(); | ||
reader.readAsDataURL(file); | ||
reader.onload = () => | ||
resolve(reader.result.substring(reader.result.indexOf(",") + 1)); | ||
reader.onerror = (error) => reject(error); | ||
}); | ||
} | ||
|
||
export async function githubUpload(token, repository, file) { | ||
const octokit = new Octokit({ auth: token }); | ||
const [owner, repo] = repository.split("/"); | ||
return await octokit.request("PUT /repos/{owner}/{repo}/contents/{path}", { | ||
owner, | ||
repo, | ||
path: `${UPLOAD_DIRECTORY}/${file.name}`, | ||
message: `Upload File - ${file.name}`, | ||
content: await getBase64(file), | ||
}); | ||
} | ||
import { Octokit } from "https://cdn.skypack.dev/octokit?dts"; | ||
|
||
const UPLOAD_DIRECTORY = "raw"; | ||
|
||
function getBase64(file) { | ||
return new Promise((resolve, reject) => { | ||
const reader = new FileReader(); | ||
reader.readAsDataURL(file); | ||
reader.onload = () => | ||
resolve(reader.result.substring(reader.result.indexOf(",") + 1)); | ||
reader.onerror = (error) => reject(error); | ||
}); | ||
} | ||
|
||
export async function githubUpload(token, repository, file) { | ||
const octokit = new Octokit({ auth: token }); | ||
const [owner, repo] = repository.split("/"); | ||
return await octokit.request("PUT /repos/{owner}/{repo}/contents/{path}", { | ||
owner, | ||
repo, | ||
path: `${UPLOAD_DIRECTORY}/${file.name}`, | ||
message: `Upload File - ${file.name}`, | ||
content: await getBase64(file), | ||
}); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,75 +1,75 @@ | ||
import React, { useRef } from "react"; | ||
import { Button, Form, Modal } from "react-bootstrap"; | ||
import PropTypes from 'prop-types'; | ||
|
||
function AuthDialog({ show, setShow, setToken, setRepository }) { | ||
const tokenEl = useRef(null); | ||
const repoEl = useRef(null); | ||
|
||
return ( | ||
<Modal | ||
show={show} | ||
onHide={() => { | ||
setShow(false); | ||
}} | ||
> | ||
<Modal.Header closeButton> | ||
<Modal.Title>Authenticate with GitHub</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<Form> | ||
<Form.Group className="mb-3"> | ||
<Form.Label>GitHub Token</Form.Label> | ||
<Form.Control type="password" ref={tokenEl} autoFocus /> | ||
</Form.Group> | ||
<Form.Group className="mb-3"> | ||
<Form.Label>Repository (username/repository_name)</Form.Label> | ||
<Form.Control type="text" ref={repoEl} /> | ||
</Form.Group> | ||
</Form> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<Button | ||
variant="secondary" | ||
onClick={() => { | ||
setShow(false); | ||
}} | ||
> | ||
Close | ||
</Button> | ||
<Button | ||
variant="success" | ||
onClick={() => { | ||
let token = tokenEl.current; | ||
let repo = repoEl.current; | ||
|
||
const validRepo = | ||
/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}\/[a-zA-Z0-9_.-]+$/i; | ||
|
||
if (token.value === "") { | ||
token.focus(); | ||
return; | ||
} else if (repo.value === "" || !repo.value.match(validRepo)) { | ||
repo.focus(); | ||
return; | ||
} | ||
setToken(token.value); | ||
setRepository(repo.value); | ||
setShow(false); | ||
}} | ||
> | ||
Use Credentials | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
); | ||
} | ||
|
||
AuthDialog.propTypes = { | ||
show: PropTypes.bool, | ||
setToken: PropTypes.func, | ||
setRepository: PropTypes.func, | ||
setShow: PropTypes.func | ||
} | ||
|
||
import React, { useRef } from "react"; | ||
import { Button, Form, Modal } from "react-bootstrap"; | ||
import PropTypes from 'prop-types'; | ||
|
||
function AuthDialog({ show, setShow, setToken, setRepository }) { | ||
const tokenEl = useRef(null); | ||
const repoEl = useRef(null); | ||
|
||
return ( | ||
<Modal | ||
show={show} | ||
onHide={() => { | ||
setShow(false); | ||
}} | ||
> | ||
<Modal.Header closeButton> | ||
<Modal.Title>Authenticate with GitHub</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<Form> | ||
<Form.Group className="mb-3"> | ||
<Form.Label>GitHub Token</Form.Label> | ||
<Form.Control type="password" ref={tokenEl} autoFocus /> | ||
</Form.Group> | ||
<Form.Group className="mb-3"> | ||
<Form.Label>Repository (username/repository_name)</Form.Label> | ||
<Form.Control type="text" ref={repoEl} /> | ||
</Form.Group> | ||
</Form> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<Button | ||
variant="secondary" | ||
onClick={() => { | ||
setShow(false); | ||
}} | ||
> | ||
Close | ||
</Button> | ||
<Button | ||
variant="success" | ||
onClick={() => { | ||
let token = tokenEl.current; | ||
let repo = repoEl.current; | ||
|
||
const validRepo = | ||
/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}\/[a-zA-Z0-9_.-]+$/i; | ||
|
||
if (token.value === "") { | ||
token.focus(); | ||
return; | ||
} else if (repo.value === "" || !repo.value.match(validRepo)) { | ||
repo.focus(); | ||
return; | ||
} | ||
setToken(token.value); | ||
setRepository(repo.value); | ||
setShow(false); | ||
}} | ||
> | ||
Use Credentials | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
); | ||
} | ||
|
||
AuthDialog.propTypes = { | ||
show: PropTypes.bool, | ||
setToken: PropTypes.func, | ||
setRepository: PropTypes.func, | ||
setShow: PropTypes.func | ||
} | ||
|
||
export default AuthDialog |
Oops, something went wrong.