diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..3f24d03
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,3 @@
+legacy/
+node_modules/
+.next/
diff --git a/.github/workflows/push.yml b/.github/workflows/main.yml
similarity index 87%
rename from .github/workflows/push.yml
rename to .github/workflows/main.yml
index 5dbe19c..cc3082f 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/main.yml
@@ -1,5 +1,8 @@
-on: push
-name: Build on push
+name: main
+on:
+ push:
+ branches:
+ - main
jobs:
build:
name: Docker build, tag, and push
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644
index 0000000..6347631
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -0,0 +1,15 @@
+name: tests
+on: [push]
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Use Node.js 14
+ uses: actions/setup-node@v1
+ with:
+ node-version: 14
+ - run: npm i -g yarn@1
+ - run: yarn
+ - run: yarn lint
+ - run: yarn build
diff --git a/src/components/ErrorPage.tsx b/legacy/ErrorPage.tsx
similarity index 100%
rename from src/components/ErrorPage.tsx
rename to legacy/ErrorPage.tsx
diff --git a/src/components/ProgressBar.tsx b/legacy/ProgressBar.tsx
similarity index 61%
rename from src/components/ProgressBar.tsx
rename to legacy/ProgressBar.tsx
index 8a70d72..b122fa3 100644
--- a/src/components/ProgressBar.tsx
+++ b/legacy/ProgressBar.tsx
@@ -1,21 +1,21 @@
-import React from "react";
-import classnames from "classnames";
+import React from 'react'
+import classnames from 'classnames'
function formatProgress(dec) {
- return `${(dec * 100).toPrecision(3) }%`
+ return `${(dec * 100).toPrecision(3)}%`
}
export default class ProgressBar extends React.Component {
render() {
const failed = this.props.value < 0
const inProgress = this.props.value < 1 && this.props.value >= 0
- const classes = classnames("progress-bar", {
- "progress-bar-failed": failed,
- "progress-bar-in-progress": inProgress,
- "progress-bar-small": this.props.small,
- });
+ const classes = classnames('progress-bar', {
+ 'progress-bar-failed': failed,
+ 'progress-bar-in-progress': inProgress,
+ 'progress-bar-small': this.props.small,
+ })
- const formatted = formatProgress(this.props.value);
+ const formatted = formatProgress(this.props.value)
return (
@@ -26,17 +26,18 @@ export default class ProgressBar extends React.Component {
{formatted}
) : (
- : Delivered
}
-
- );
+ Delivered
+ )}
+
+ )
}
}
ProgressBar.propTypes = {
value: React.PropTypes.number.isRequired,
small: React.PropTypes.bool,
-};
+}
ProgressBar.defaultProps = {
small: false,
-};
+}
diff --git a/src/components/Spinner.tsx b/legacy/Spinner.tsx
similarity index 50%
rename from src/components/Spinner.tsx
rename to legacy/Spinner.tsx
index 052831a..8ecb8ae 100644
--- a/src/components/Spinner.tsx
+++ b/legacy/Spinner.tsx
@@ -1,12 +1,12 @@
-import React from "react";
-import classnames from "classnames";
-import { formatSize } from "../util";
+import React from 'react'
+import classnames from 'classnames'
+import { formatSize } from '../util'
export default class Spinner extends React.Component {
render() {
- const classes = classnames("spinner", {
- "spinner-animated": this.props.animated,
- });
+ const classes = classnames('spinner', {
+ 'spinner-animated': this.props.animated,
+ })
return (
@@ -16,26 +16,26 @@ export default class Spinner extends React.Component {
className="spinner-image"
/>
- {this.props.name === null ? null
- :
{this.props.name}
+ {this.props.name === null ? null : (
+
{this.props.name}
)}
- {this.props.size === null ? null
- :
{formatSize(this.props.size)}
+ {this.props.size === null ? null : (
+
{formatSize(this.props.size)}
)}
- );
+ )
}
}
Spinner.propTypes = {
- dir: React.PropTypes.oneOf(["up", "down"]).isRequired,
+ dir: React.PropTypes.oneOf(['up', 'down']).isRequired,
name: React.PropTypes.string,
size: React.PropTypes.number,
animated: React.PropTypes.bool,
-};
+}
Spinner.defaultProps = {
name: null,
size: null,
animated: false,
-};
+}
diff --git a/src/components/Tempalink.tsx b/legacy/Tempalink.tsx
similarity index 100%
rename from src/components/Tempalink.tsx
rename to legacy/Tempalink.tsx
diff --git a/package.json b/package.json
index 7cc13b1..e58b6d1 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,8 @@
"scripts": {
"dev": "next",
"build": "next build",
- "start": "next start"
+ "start": "next start",
+ "lint": "eslint 'src/**/*.ts[x]'"
},
"repository": {
"type": "git",
diff --git a/src/components/ChromeNotice.tsx b/src/components/ChromeNotice.tsx
deleted file mode 100644
index 4bd03ab..0000000
--- a/src/components/ChromeNotice.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import React from 'react'
-import DownloadStore from '../stores/DownloadStore'
-import SupportStore from '../stores/SupportStore'
-
-function getState() {
- return {
- active: SupportStore.getState().isChrome && DownloadStore.getState().fileSize >= 500000000
- }
-}
-
-export default class ChromeNotice extends React.Component {
-
- constructor() {
- super()
- this.state = getState()
-
- this._onChange = () => {
- this.setState(getState())
- }
- }
-
- componentDidMount() {
- DownloadStore.listen(this._onChange)
- SupportStore.listen(this._onChange)
- }
-
- componentWillUnmount() {
- DownloadStore.unlisten(this._onChange)
- SupportStore.unlisten(this._onChange)
- }
-
- render() {
- if (this.state.active) {
- return Chrome has issues downloading files > 500 MB. Try using Firefox instead.
- } else {
- return null
- }
- }
-
-}
diff --git a/src/fs.ts b/src/fs.ts
index 5402fb1..cb81d8f 100644
--- a/src/fs.ts
+++ b/src/fs.ts
@@ -1,6 +1,8 @@
+import { UploadedFile } from './types'
+
const getAsFile = (entry: any): Promise =>
new Promise((resolve, reject) => {
- entry.file((file: File) => {
+ entry.file((file: UploadedFile) => {
file.fullPath = entry.fullPath
resolve(file)
}, reject)
diff --git a/src/zip-stream.ts b/src/zip-stream.ts
index 86464af..ec502cc 100644
--- a/src/zip-stream.ts
+++ b/src/zip-stream.ts
@@ -1,4 +1,10 @@
// Based on https://github.com/jimmywarting/StreamSaver.js/blob/master/examples/zip-stream.js
+//
+// Disabling typechecking for now since this was originally JavaScript, should
+// find some time to add types later.
+//
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-nocheck
class Crc32 {
crc: number
@@ -54,7 +60,9 @@ const pump = (zipObj) =>
zipObj.ctrl.enqueue(outputData)
})
-export function createZipStream(underlyingSource) {
+export function createZipStream(
+ underlyingSource: UnderlyingSource,
+): ReadableStream {
const files = Object.create(null)
const filenames = []
const encoder = new TextEncoder()
diff --git a/tsconfig.json b/tsconfig.json
index ebd39cf..b6024b8 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -16,13 +16,14 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
+ "downlevelIteration": true,
"jsx": "preserve"
},
"include": [
"next-env.d.ts",
- "**/*.js",
- "**/*.ts",
- "**/*.tsx"
+ "src/**/*.js",
+ "src/**/*.ts",
+ "src/**/*.tsx"
],
"exclude": [
"node_modules"