diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c3a08e8a..f4f201b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,6 +20,8 @@ jobs: key: client-${{ hashFiles('**/package-lock.json') }} - run: npm ci + env: + SKIP_BUILD: true - run: npm run lint -- --no-fix release: @@ -36,6 +38,8 @@ jobs: steps: - uses: actions/checkout@v2 - run: npm ci + env: + SKIP_BUILD: true - id: release name: semantic-release uses: ahmadnassri/action-semantic-release@v1 @@ -95,11 +99,15 @@ jobs: - name: Cache Docker layers uses: actions/cache@v2 + env: + cache-name: cache-buildx id: cache with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }}-${{ env.cache-name }} restore-keys: | + ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }} + ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }} ${{ runner.os }}-buildx- - name: Docker Buildx (build) @@ -160,12 +168,16 @@ jobs: - name: Cache Docker layers uses: actions/cache@v2 + env: + cache-name: cache-buildx-web id: cache with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-web-buildx-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }}-${{ env.cache-name }} restore-keys: | - ${{ runner.os }}-web-buildx- + ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }} + ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }} + ${{ runner.os }}-buildx- - name: Docker Buildx (build) run: | diff --git a/.releaserc b/.releaserc index 946b62fd..dd9681c1 100644 --- a/.releaserc +++ b/.releaserc @@ -13,6 +13,7 @@ { "type": "refactor", "release": "patch" } ] }], + ["@semantic-release/release-notes-generator", { "preset": "conventionalcommits", "presetConfig": { @@ -30,6 +31,13 @@ ] } }], - "@semantic-release/github" + + ["@semantic-release/npm", { + "tarballDir": "package" + }], + + ["@semantic-release/github", { + "assets": "package/*.tgz" + }] ] } \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 8fe4376e..0b5f9acd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,5 +11,8 @@ arch: os: linux # different CPU architectures are only supported on Linux +env: + - SKIP_BUILD=true + script: - npm run build diff --git a/Dockerfile b/Dockerfile index 0eac2ff8..6983cc15 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM --platform=$BUILDPLATFORM node:current-alpine as build-stage RUN mkdir /app && chown -R node:node /app WORKDIR /app COPY --chown=node:node package*.json ./ -RUN npm ci +RUN SKIP_BUILD=true npm ci COPY --chown=node:node . . ARG VERSION @@ -18,7 +18,7 @@ WORKDIR /app RUN apk add --no-cache python make g++ USER node COPY --chown=node:node package*.json ./ -RUN npm ci --only=production +RUN SKIP_BUILD=true npm ci --only=production # production environment FROM node:current-alpine as production-stage diff --git a/Dockerfile.web b/Dockerfile.web index 61b97360..f5a66c02 100644 --- a/Dockerfile.web +++ b/Dockerfile.web @@ -3,7 +3,7 @@ FROM --platform=$BUILDPLATFORM node:current-alpine as build-stage RUN mkdir /app && chown -R node:node /app WORKDIR /app COPY --chown=node:node package*.json ./ -RUN npm ci +RUN SKIP_BUILD=true npm ci COPY --chown=node:node . . ARG SERVERS diff --git a/README.md b/README.md index ed423c6a..c45a9658 100644 --- a/README.md +++ b/README.md @@ -113,21 +113,17 @@ docker run -p 8080:8088 ttshivers/synclounge:latest You can use environment variables to change any of the [default configuration](https://github.com/ttshivers/synclounge/blob/master/config/defaults.js). #### Linux (Without Docker) -Make sure you have git, nodejs, and npm installed. Then, clone and build the repository +Make sure you have nodejs installed. ```sh -git clone https://github.com/ttshivers/synclounge.git -cd synclounge -# Install dependencies -npm ci -npm run build +sudo npm install -g synclounge ``` -Once it's build, you can run it -```sh -./server.js +Then you can run it: +``` +synclounge ``` -If you want to change any of the [default configuration](https://github.com/ttshivers/synclounge/blob/master/config/defaults.js), you can either use environment variables with the same name, use command line arguments, or edit `dist/config.json`. If you rebuild, `dist/config.json` will be overwritten, so be aware. +If you want to change any of the [default configuration](https://github.com/ttshivers/synclounge/blob/master/config/defaults.js), you can either use environment variables with the same name, use command line arguments, or use a config file and run synclounge like `synclounge --config_file /path/to/config.json` ### Older Help diff --git a/config/defaults.js b/config/defaults.js index 6a33e8f7..4ee5995c 100644 --- a/config/defaults.js +++ b/config/defaults.js @@ -56,7 +56,6 @@ const defaults = { // Sync flexibility when players are paused paused_sync_flexibility: 10, - }; module.exports = defaults; diff --git a/config/index.js b/config/index.js index e2510680..6cfc6f36 100644 --- a/config/index.js +++ b/config/index.js @@ -37,13 +37,19 @@ const get = (file, blockList = []) => { 'default_slplayer_quality', ]), - }) - .file({ file }) - .defaults(defaults); + }); + + const configFile = nconf.get('config_file') || file; + + if (configFile) { + nconf.file({ file: configFile }); + } + + nconf.defaults(defaults); // Filter out the weird stuff const { - type, $0: firstArg, _: command, modern, ...config + config_file: no, type, $0: firstArg, _: command, modern, ...config } = nconf.get(); // Remove blockList items diff --git a/package-lock.json b/package-lock.json index b470561d..24534ed7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1453,6 +1453,15 @@ "integrity": "sha512-r3fwVbVH+M8W0qYlBBZFsUwKe6NT5qvz+EmU7sr8VeN1cQ63z+3cfXyTo7WGGEMEgKiT0jboNAK3b1FZp8k9LQ==", "dev": true }, + "@delucis/if-env": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@delucis/if-env/-/if-env-1.1.2.tgz", + "integrity": "sha512-sZJF62edo927tjq0cANW9Quozwmact7o4fIbPdvmTLqDxQgXJE9xqlkspvgGAZINL3JkwUFTQiGKAan/e2sDnQ==", + "dev": true, + "requires": { + "matcher": "^1.1.1" + } + }, "@hapi/address": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/@hapi/address/-/address-2.1.4.tgz", @@ -1774,6 +1783,7 @@ "resolved": "https://registry.npmjs.org/@types/mini-css-extract-plugin/-/mini-css-extract-plugin-0.9.1.tgz", "integrity": "sha512-+mN04Oszdz9tGjUP/c1ReVwJXxSniLd7lF++sv+8dkABxVNthg6uccei+4ssKxRHGoMmPxdn7uBdJWONSJGTGQ==", "dev": true, + "optional": true, "requires": { "@types/webpack": "*" } @@ -9783,6 +9793,15 @@ "repeat-string": "^1.0.0" } }, + "matcher": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/matcher/-/matcher-1.1.1.tgz", + "integrity": "sha512-+BmqxWIubKTRKNWx/ahnCkk3mG8m7OturVlqq6HiojGJTd5hVYbgZm6WzcYPCoB+KBT4Vd6R7WSRG2OADNaCjg==", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.4" + } + }, "mathml-tag-names": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz", @@ -15212,6 +15231,7 @@ "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.0.0-beta.5.tgz", "integrity": "sha512-ciWfzNefqWlmzKznCWY9hl+fPP4KlQ0A9MtHbJ/8DpyY+dAM8gDrjufIdxwTgC4szE4EZC3A6ip/BbrqM84GqA==", "dev": true, + "optional": true, "requires": { "@types/mini-css-extract-plugin": "^0.9.1", "chalk": "^3.0.0", @@ -15226,6 +15246,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", "dev": true, + "optional": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -15235,7 +15256,8 @@ "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true + "dev": true, + "optional": true } } }, diff --git a/package.json b/package.json index 1505ed0e..f76212ea 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,20 @@ { "name": "synclounge", "version": "0.0.0-semantically-released", - "private": false, "description": "Synced playback of Plex content", "author": "samcm", + "bin": "./server.js", + "files": [ + "dist", + "config", + "server.js" + ], "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build --modern", "lint": "vue-cli-service lint", - "lint:style": "vue-cli-service lint:style" + "lint:style": "vue-cli-service lint:style", + "prepare": "if-env SKIP_BUILD=true && echo 'Skipping build' || npm run build" }, "dependencies": { "nconf": "^0.10.0", @@ -19,6 +25,7 @@ "@babel/plugin-proposal-optional-chaining": "^7.11.0", "@commitlint/cli": "^9.1.2", "@commitlint/config-conventional": "^9.1.2", + "@delucis/if-env": "^1.1.2", "@samhammer/vue-cli-plugin-stylelint": "^2.0.0", "@vue/cli-plugin-babel": "^4.5.4", "@vue/cli-plugin-eslint": "^4.5.4", @@ -67,6 +74,6 @@ "license": "MIT", "repository": { "type": "git", - "url": "git+https://github.com/ttshivers/synclounge.git" + "url": "https://github.com/ttshivers/synclounge.git" } -} \ No newline at end of file +} diff --git a/server.js b/server.js index 3ba24d04..ec7259e7 100755 --- a/server.js +++ b/server.js @@ -12,14 +12,17 @@ const handle = (signal) => { process.on('SIGINT', handle); process.on('SIGTERM', handle); -const configFile = 'dist/config.json'; const blockList = Object.keys(syncloungeSocket.defaultConfig); -const appConfig = config.get(configFile, blockList); +const appConfig = config.get(null, blockList); console.log(appConfig); -config.save(appConfig, configFile); const socketConfig = syncloungeSocket.getConfig(); -syncloungeSocket.socketServer({ +const router = syncloungeSocket.socketServer({ ...socketConfig, static_path: 'dist', }); + +// Add route for config +router.get('/config.json', (req, res) => { + res.json(appConfig); +});