Compare commits

..

10 Commits

6 changed files with 45 additions and 10 deletions

3
.gitignore vendored
View File

@ -10,8 +10,9 @@ js/*.min.js
cache cache
bin bin
ambiance/*.mp3 ambiance
*.yml *.yml
public/ public/
node_modules/ node_modules/
src/node_modules

View File

@ -2,10 +2,8 @@
# docker run -it -v $(pwd)/public:/app/public dndmusicbot-js-build # docker run -it -v $(pwd)/public:/app/public dndmusicbot-js-build
FROM node:19-alpine3.16 FROM node:19-alpine3.16
RUN mkdir /public && chmod 777 /public
WORKDIR /app WORKDIR /app
COPY . /app ENTRYPOINT ["yarn"]
RUN yarn
ENTRYPOINT ["yarn", "build"]

36
Makefile Normal file
View File

@ -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)

View File

@ -1,6 +1,6 @@
{ {
"scripts": { "scripts": {
"build": "esbuild js/script.js --bundle --outdir=public/" "build": "esbuild script.js --bundle --outdir=/public/"
}, },
"dependencies": { "dependencies": {
"esbuild": "^0.15.14", "esbuild": "^0.15.14",

View File

@ -157,11 +157,11 @@ window.onload = function () {
addInteractHandler(document.querySelector("#addambiance"), (e, isTouch) => { addInteractHandler(document.querySelector("#addambiance"), (e, isTouch) => {
isTouch && e.preventDefault() isTouch && e.preventDefault()
output.innerText = "" //output.innerText = ""
var title = document.querySelector("#inputambiance > input[name='title']") var title = document.querySelector("#inputambiance > input[name='title']")
var url = document.querySelector("#inputambiance > input[name='url']") var url = document.querySelector("#inputambiance > input[name='url']")
if (title.value == "" || url.value == "") { if (title.value == "" || url.value == "") {
output.innerText = "Title or Url is empty!" console.log("Title or Url is empty!")
return return
} }
@ -177,7 +177,7 @@ window.onload = function () {
addInteractHandler(submit, (e, isTouch) => { addInteractHandler(submit, (e, isTouch) => {
isTouch && e.preventDefault() isTouch && e.preventDefault()
output.innerText = "" //output.innerText = ""
var title = document.querySelector("#inputplaylist > input[name='title']") var title = document.querySelector("#inputplaylist > input[name='title']")
var url = document.querySelector("#inputplaylist > input[name='url']") var url = document.querySelector("#inputplaylist > input[name='url']")
if (title.value == "" || url.value == "") { if (title.value == "" || url.value == "") {