diff --git a/.gitignore b/.gitignore index f4dac66..b8cbb8a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,9 @@ js/*.min.js cache bin -ambiance/*.mp3 +ambiance *.yml public/ node_modules/ +src/node_modules diff --git a/Dockerfile b/Dockerfile index 28d6007..3c3bb5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,10 +2,8 @@ # docker run -it -v $(pwd)/public:/app/public dndmusicbot-js-build FROM node:19-alpine3.16 +RUN mkdir /public && chmod 777 /public + WORKDIR /app -COPY . /app - -RUN yarn - -ENTRYPOINT ["yarn", "build"] +ENTRYPOINT ["yarn"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9319431 --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +.DEFAULT_GOAL := build +APPLICATION_NAME ?= dndmusicbot +CURRENT_UID := $(shell id -u) +BIN := src/node_modules/.bin +YARN = docker run --rm --user $(CURRENT_UID) -v $(CURDIR)/src:/app -v $(CURDIR)/public:/public dndmusicbot-js-build + +PHONY: js image build clean + +js: image public/script.js + +image: .jsimage + +.jsimage: Dockerfile + @docker build -t dndmusicbot-js-build . + @touch .jsimage + +src/node_modules: + mkdir -p $@ + +public: + mkdir -p $@ + +src/yarn.lock: public src/node_modules src/package.json + $(YARN) + @touch -mr $(shell ls -Atd $? | head -1) $@ + +public/script.js: src/script.js src/yarn.lock + $(YARN) build + +$(APPLICATION_NAME): *.go ffmpeg/*.go speaker/*.go + @go build + +build: image js $(APPLICATION_NAME) + +clean: + rm -r public/* src/node_modules .jsimage $(APPLICATION_NAME) diff --git a/package.json b/src/package.json similarity index 69% rename from package.json rename to src/package.json index b509036..5e65b04 100644 --- a/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "scripts": { - "build": "esbuild js/script.js --bundle --outdir=public/" + "build": "esbuild script.js --bundle --outdir=/public/" }, "dependencies": { "esbuild": "^0.15.14", diff --git a/js/script.js b/src/script.js similarity index 98% rename from js/script.js rename to src/script.js index 5908bcf..1b44733 100644 --- a/js/script.js +++ b/src/script.js @@ -157,11 +157,11 @@ window.onload = function () { addInteractHandler(document.querySelector("#addambiance"), (e, isTouch) => { isTouch && e.preventDefault() - output.innerText = "" + //output.innerText = "" var title = document.querySelector("#inputambiance > input[name='title']") var url = document.querySelector("#inputambiance > input[name='url']") if (title.value == "" || url.value == "") { - output.innerText = "Title or Url is empty!" + console.log("Title or Url is empty!") return } @@ -177,7 +177,7 @@ window.onload = function () { addInteractHandler(submit, (e, isTouch) => { isTouch && e.preventDefault() - output.innerText = "" + //output.innerText = "" var title = document.querySelector("#inputplaylist > input[name='title']") var url = document.querySelector("#inputplaylist > input[name='url']") if (title.value == "" || url.value == "") { diff --git a/yarn.lock b/src/yarn.lock similarity index 100% rename from yarn.lock rename to src/yarn.lock