build(npm): add npm package deployment

* build(npm): add config to allow synclounge to be published as a package

* build(npm): add npm publish logic

* docs(linux): change installation to use npm registry

* ci(travis-ci): skip build on install
This commit is contained in:
Travis Shivers 2020-08-31 17:55:14 -05:00 committed by GitHub
parent 91357d81af
commit f86e7de364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 87 additions and 31 deletions

View File

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

View File

@ -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"
}]
]
}

View File

@ -11,5 +11,8 @@ arch:
os: linux # different CPU architectures are only supported on Linux
env:
- SKIP_BUILD=true
script:
- npm run build

View File

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

View File

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

View File

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

View File

@ -56,7 +56,6 @@ const defaults = {
// Sync flexibility when players are paused
paused_sync_flexibility: 10,
};
module.exports = defaults;

View File

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

24
package-lock.json generated
View File

@ -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
}
}
},

View File

@ -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"
}
}

View File

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