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:
parent
91357d81af
commit
f86e7de364
|
@ -20,6 +20,8 @@ jobs:
|
||||||
key: client-${{ hashFiles('**/package-lock.json') }}
|
key: client-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
|
env:
|
||||||
|
SKIP_BUILD: true
|
||||||
- run: npm run lint -- --no-fix
|
- run: npm run lint -- --no-fix
|
||||||
|
|
||||||
release:
|
release:
|
||||||
|
@ -36,6 +38,8 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
|
env:
|
||||||
|
SKIP_BUILD: true
|
||||||
- id: release
|
- id: release
|
||||||
name: semantic-release
|
name: semantic-release
|
||||||
uses: ahmadnassri/action-semantic-release@v1
|
uses: ahmadnassri/action-semantic-release@v1
|
||||||
|
@ -95,11 +99,15 @@ jobs:
|
||||||
-
|
-
|
||||||
name: Cache Docker layers
|
name: Cache Docker layers
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
|
env:
|
||||||
|
cache-name: cache-buildx
|
||||||
id: cache
|
id: cache
|
||||||
with:
|
with:
|
||||||
path: /tmp/.buildx-cache
|
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: |
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }}
|
||||||
|
${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }}
|
||||||
${{ runner.os }}-buildx-
|
${{ runner.os }}-buildx-
|
||||||
-
|
-
|
||||||
name: Docker Buildx (build)
|
name: Docker Buildx (build)
|
||||||
|
@ -160,12 +168,16 @@ jobs:
|
||||||
-
|
-
|
||||||
name: Cache Docker layers
|
name: Cache Docker layers
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
|
env:
|
||||||
|
cache-name: cache-buildx-web
|
||||||
id: cache
|
id: cache
|
||||||
with:
|
with:
|
||||||
path: /tmp/.buildx-cache
|
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: |
|
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)
|
name: Docker Buildx (build)
|
||||||
run: |
|
run: |
|
||||||
|
|
10
.releaserc
10
.releaserc
|
@ -13,6 +13,7 @@
|
||||||
{ "type": "refactor", "release": "patch" }
|
{ "type": "refactor", "release": "patch" }
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
|
|
||||||
["@semantic-release/release-notes-generator", {
|
["@semantic-release/release-notes-generator", {
|
||||||
"preset": "conventionalcommits",
|
"preset": "conventionalcommits",
|
||||||
"presetConfig": {
|
"presetConfig": {
|
||||||
|
@ -30,6 +31,13 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
"@semantic-release/github"
|
|
||||||
|
["@semantic-release/npm", {
|
||||||
|
"tarballDir": "package"
|
||||||
|
}],
|
||||||
|
|
||||||
|
["@semantic-release/github", {
|
||||||
|
"assets": "package/*.tgz"
|
||||||
|
}]
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -11,5 +11,8 @@ arch:
|
||||||
|
|
||||||
os: linux # different CPU architectures are only supported on Linux
|
os: linux # different CPU architectures are only supported on Linux
|
||||||
|
|
||||||
|
env:
|
||||||
|
- SKIP_BUILD=true
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- npm run build
|
- npm run build
|
||||||
|
|
|
@ -3,7 +3,7 @@ FROM --platform=$BUILDPLATFORM node:current-alpine as build-stage
|
||||||
RUN mkdir /app && chown -R node:node /app
|
RUN mkdir /app && chown -R node:node /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --chown=node:node package*.json ./
|
COPY --chown=node:node package*.json ./
|
||||||
RUN npm ci
|
RUN SKIP_BUILD=true npm ci
|
||||||
COPY --chown=node:node . .
|
COPY --chown=node:node . .
|
||||||
|
|
||||||
ARG VERSION
|
ARG VERSION
|
||||||
|
@ -18,7 +18,7 @@ WORKDIR /app
|
||||||
RUN apk add --no-cache python make g++
|
RUN apk add --no-cache python make g++
|
||||||
USER node
|
USER node
|
||||||
COPY --chown=node:node package*.json ./
|
COPY --chown=node:node package*.json ./
|
||||||
RUN npm ci --only=production
|
RUN SKIP_BUILD=true npm ci --only=production
|
||||||
|
|
||||||
# production environment
|
# production environment
|
||||||
FROM node:current-alpine as production-stage
|
FROM node:current-alpine as production-stage
|
||||||
|
|
|
@ -3,7 +3,7 @@ FROM --platform=$BUILDPLATFORM node:current-alpine as build-stage
|
||||||
RUN mkdir /app && chown -R node:node /app
|
RUN mkdir /app && chown -R node:node /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --chown=node:node package*.json ./
|
COPY --chown=node:node package*.json ./
|
||||||
RUN npm ci
|
RUN SKIP_BUILD=true npm ci
|
||||||
COPY --chown=node:node . .
|
COPY --chown=node:node . .
|
||||||
|
|
||||||
ARG SERVERS
|
ARG SERVERS
|
||||||
|
|
16
README.md
16
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).
|
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)
|
#### 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
|
```sh
|
||||||
git clone https://github.com/ttshivers/synclounge.git
|
sudo npm install -g synclounge
|
||||||
cd synclounge
|
|
||||||
# Install dependencies
|
|
||||||
npm ci
|
|
||||||
npm run build
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Once it's build, you can run it
|
Then you can run it:
|
||||||
```sh
|
```
|
||||||
./server.js
|
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
|
### Older Help
|
||||||
|
|
|
@ -56,7 +56,6 @@ const defaults = {
|
||||||
|
|
||||||
// Sync flexibility when players are paused
|
// Sync flexibility when players are paused
|
||||||
paused_sync_flexibility: 10,
|
paused_sync_flexibility: 10,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = defaults;
|
module.exports = defaults;
|
||||||
|
|
|
@ -37,13 +37,19 @@ const get = (file, blockList = []) => {
|
||||||
|
|
||||||
'default_slplayer_quality',
|
'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
|
// Filter out the weird stuff
|
||||||
const {
|
const {
|
||||||
type, $0: firstArg, _: command, modern, ...config
|
config_file: no, type, $0: firstArg, _: command, modern, ...config
|
||||||
} = nconf.get();
|
} = nconf.get();
|
||||||
|
|
||||||
// Remove blockList items
|
// Remove blockList items
|
||||||
|
|
|
@ -1453,6 +1453,15 @@
|
||||||
"integrity": "sha512-r3fwVbVH+M8W0qYlBBZFsUwKe6NT5qvz+EmU7sr8VeN1cQ63z+3cfXyTo7WGGEMEgKiT0jboNAK3b1FZp8k9LQ==",
|
"integrity": "sha512-r3fwVbVH+M8W0qYlBBZFsUwKe6NT5qvz+EmU7sr8VeN1cQ63z+3cfXyTo7WGGEMEgKiT0jboNAK3b1FZp8k9LQ==",
|
||||||
"dev": true
|
"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": {
|
"@hapi/address": {
|
||||||
"version": "2.1.4",
|
"version": "2.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/@hapi/address/-/address-2.1.4.tgz",
|
"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",
|
"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==",
|
"integrity": "sha512-+mN04Oszdz9tGjUP/c1ReVwJXxSniLd7lF++sv+8dkABxVNthg6uccei+4ssKxRHGoMmPxdn7uBdJWONSJGTGQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/webpack": "*"
|
"@types/webpack": "*"
|
||||||
}
|
}
|
||||||
|
@ -9783,6 +9793,15 @@
|
||||||
"repeat-string": "^1.0.0"
|
"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": {
|
"mathml-tag-names": {
|
||||||
"version": "2.1.3",
|
"version": "2.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz",
|
"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",
|
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.0.0-beta.5.tgz",
|
||||||
"integrity": "sha512-ciWfzNefqWlmzKznCWY9hl+fPP4KlQ0A9MtHbJ/8DpyY+dAM8gDrjufIdxwTgC4szE4EZC3A6ip/BbrqM84GqA==",
|
"integrity": "sha512-ciWfzNefqWlmzKznCWY9hl+fPP4KlQ0A9MtHbJ/8DpyY+dAM8gDrjufIdxwTgC4szE4EZC3A6ip/BbrqM84GqA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/mini-css-extract-plugin": "^0.9.1",
|
"@types/mini-css-extract-plugin": "^0.9.1",
|
||||||
"chalk": "^3.0.0",
|
"chalk": "^3.0.0",
|
||||||
|
@ -15226,6 +15246,7 @@
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz",
|
||||||
"integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==",
|
"integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"ansi-styles": "^4.1.0",
|
"ansi-styles": "^4.1.0",
|
||||||
"supports-color": "^7.1.0"
|
"supports-color": "^7.1.0"
|
||||||
|
@ -15235,7 +15256,8 @@
|
||||||
"version": "0.6.1",
|
"version": "0.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
13
package.json
13
package.json
|
@ -1,14 +1,20 @@
|
||||||
{
|
{
|
||||||
"name": "synclounge",
|
"name": "synclounge",
|
||||||
"version": "0.0.0-semantically-released",
|
"version": "0.0.0-semantically-released",
|
||||||
"private": false,
|
|
||||||
"description": "Synced playback of Plex content",
|
"description": "Synced playback of Plex content",
|
||||||
"author": "samcm",
|
"author": "samcm",
|
||||||
|
"bin": "./server.js",
|
||||||
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"config",
|
||||||
|
"server.js"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
"build": "vue-cli-service build --modern",
|
"build": "vue-cli-service build --modern",
|
||||||
"lint": "vue-cli-service lint",
|
"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": {
|
"dependencies": {
|
||||||
"nconf": "^0.10.0",
|
"nconf": "^0.10.0",
|
||||||
|
@ -19,6 +25,7 @@
|
||||||
"@babel/plugin-proposal-optional-chaining": "^7.11.0",
|
"@babel/plugin-proposal-optional-chaining": "^7.11.0",
|
||||||
"@commitlint/cli": "^9.1.2",
|
"@commitlint/cli": "^9.1.2",
|
||||||
"@commitlint/config-conventional": "^9.1.2",
|
"@commitlint/config-conventional": "^9.1.2",
|
||||||
|
"@delucis/if-env": "^1.1.2",
|
||||||
"@samhammer/vue-cli-plugin-stylelint": "^2.0.0",
|
"@samhammer/vue-cli-plugin-stylelint": "^2.0.0",
|
||||||
"@vue/cli-plugin-babel": "^4.5.4",
|
"@vue/cli-plugin-babel": "^4.5.4",
|
||||||
"@vue/cli-plugin-eslint": "^4.5.4",
|
"@vue/cli-plugin-eslint": "^4.5.4",
|
||||||
|
@ -67,6 +74,6 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/ttshivers/synclounge.git"
|
"url": "https://github.com/ttshivers/synclounge.git"
|
||||||
}
|
}
|
||||||
}
|
}
|
11
server.js
11
server.js
|
@ -12,14 +12,17 @@ const handle = (signal) => {
|
||||||
process.on('SIGINT', handle);
|
process.on('SIGINT', handle);
|
||||||
process.on('SIGTERM', handle);
|
process.on('SIGTERM', handle);
|
||||||
|
|
||||||
const configFile = 'dist/config.json';
|
|
||||||
const blockList = Object.keys(syncloungeSocket.defaultConfig);
|
const blockList = Object.keys(syncloungeSocket.defaultConfig);
|
||||||
const appConfig = config.get(configFile, blockList);
|
const appConfig = config.get(null, blockList);
|
||||||
console.log(appConfig);
|
console.log(appConfig);
|
||||||
config.save(appConfig, configFile);
|
|
||||||
|
|
||||||
const socketConfig = syncloungeSocket.getConfig();
|
const socketConfig = syncloungeSocket.getConfig();
|
||||||
syncloungeSocket.socketServer({
|
const router = syncloungeSocket.socketServer({
|
||||||
...socketConfig,
|
...socketConfig,
|
||||||
static_path: 'dist',
|
static_path: 'dist',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add route for config
|
||||||
|
router.get('/config.json', (req, res) => {
|
||||||
|
res.json(appConfig);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue