diff --git a/.github/workflows/always.yml b/.github/workflows/always.yml index 5ed426f..9625cd4 100644 --- a/.github/workflows/always.yml +++ b/.github/workflows/always.yml @@ -12,6 +12,9 @@ jobs: go-version: 1.19.1 id: go + - name: deps + run: npm i -g standard + - name: Check out code into the Go module directory uses: actions/checkout@v1 with: diff --git a/Makefile b/Makefile index 00f3b1a..69998a5 100755 --- a/Makefile +++ b/Makefile @@ -1,26 +1,29 @@ FLAGS := -ldflags "-s -w" -trimpath NOCGO := CGO_ENABLED=0 -build: +build:: go vet && go fmt ${NOCGO} go build ${FLAGS} -o gossa -install: +install:: sudo cp gossa /usr/local/bin -run: +run:: ./gossa -verb=true test-fixture -run-ro: +run-ro:: ./gossa -verb=true -ro=true test-fixture -run-extra: +run-extra:: ./gossa -verb=true -prefix="/fancy-path/" -k=false -symlinks=true test-fixture -ci: build-all test +lint-js:: + standard + +ci:: build-all test lint-js echo "done" -test: +test:: -@cd test-fixture && ln -s ../support .; true go test -cover -c -tags testrunmain @@ -43,19 +46,19 @@ test: # go tool cover -html all.out # go tool cover -func=all.out | grep main | grep '9.\..\%' -watch: +watch:: ls gossa.go gossa_test.go ui/* | entr -rc make build run -watch-extra: +watch-extra:: ls gossa.go gossa_test.go ui/* | entr -rc make build run-extra -watch-ro: +watch-ro:: ls gossa.go gossa_test.go ui/* | entr -rc make build run-ro -watch-test: +watch-test:: ls gossa.go gossa_test.go ui/* | entr -rc make test -build-all: build +build-all:: build ${NOCGO} GOOS=linux GOARCH=amd64 go build ${FLAGS} -o builds/gossa-linux-x64 ${NOCGO} GOOS=linux GOARCH=arm go build ${FLAGS} -o builds/gossa-linux-arm ${NOCGO} GOOS=linux GOARCH=arm64 go build ${FLAGS} -o builds/gossa-linux-arm64 @@ -64,8 +67,7 @@ build-all: build ${NOCGO} GOOS=windows GOARCH=amd64 go build ${FLAGS} -o builds/gossa-windows.exe sha256sum builds/* -.PHONY: clean -clean: +clean:: rm -f gossa rm -f gossa-linux64 rm -f gossa-linux-arm diff --git a/ui/script.js b/ui/script.js index 669fac5..965052e 100755 --- a/ui/script.js +++ b/ui/script.js @@ -39,9 +39,9 @@ const getArrowSelected = () => document.querySelector('.arrow-selected') const getASelected = () => !getArrowSelected() ? false : getArrowSelected().parentElement.parentElement.querySelectorAll('a')[0] const prependPath = a => a.startsWith('/') ? a : decodeURI(location.pathname) + a const prevent = e => e.preventDefault() -const flicker = w => w.classList.remove('runFade') || void w.offsetWidth || w.classList.add('runFade') +const flicker = w => w.classList.remove('runFade') || void w.offsetWidth || w.classList.add('runFade') // eslint-disable-line -const encodeURIHash = e => encodeURI(e).replaceAll("#", "%23") +const encodeURIHash = e => encodeURI(e).replaceAll('#', '%23') // Manual upload manualUpload.addEventListener('change', () => Array.from(manualUpload.files).forEach(f => isDupe(f.name) || postFile(f, '/' + f.name)), false) @@ -103,7 +103,7 @@ window.onClickLink = e => { videoOn(a.href) return false // let html be displayed naturally - } else if (a.innerText.endsWith(".html")) { + } else if (a.innerText.endsWith('.html')) { return true } @@ -286,7 +286,7 @@ document.ondrop = e => { cancelDefault(e) upGrid.style.display = 'none' - let t = getLink().firstChild + const t = getLink().firstChild // move to a folder if (draggingSrc && t) { @@ -339,7 +339,7 @@ async function padOn (a) { fileEdited = a.innerHTML const f = await fetch(a.href, { credentials: 'include', - headers: new Headers({ 'pragma': 'no-cache', 'cache-control': 'no-cache' }) + headers: new Headers({ pragma: 'no-cache', 'cache-control': 'no-cache' }) }) editor.value = await f.text() } catch (error) { @@ -605,7 +605,7 @@ function videosOff () { return true } -window.videodl = function() { +window.videodl = function () { dl(getASelected()) } @@ -628,7 +628,7 @@ function helpOff () { } // Paste handler -let cuts = [] +const cuts = [] function onPaste () { if (!cuts.length) { return refresh() } const a = getASelected() @@ -669,7 +669,7 @@ let typedPath = '' let typedToken = null function cpPath () { - var t = document.createElement('textarea') + const t = document.createElement('textarea') t.value = getASelected().href document.body.appendChild(t) t.select()