Skip to content

Commit

Permalink
build: check for minimal supported built-in Talk version
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <[email protected]>
  • Loading branch information
ShGKme committed Aug 11, 2023
1 parent 8b1ff55 commit 4c4675c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
41 changes: 41 additions & 0 deletions forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,53 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

const path = require('node:path')
const fs = require('node:fs')
const semver = require('semver')
const { MIN_REQUIRED_BUILT_IN_TALK_VERSION } = require('./src/constants.js')

require('dotenv').config()

const TALK_PATH = path.resolve(__dirname, process.env.TALK_PATH ?? 'spreed')
let talkPackageJson

module.exports = {
packagerConfig: {
icon: './img/icons/icon',
},

hooks: {
generateAssets() {
if (!fs.existsSync(process.env.TALK_PATH)) {
throw new Error(`Path does not exist TALK_PATH=${TALK_PATH}`)
}

try {
talkPackageJson = require(path.join(TALK_PATH, 'package.json'))
} catch {
throw new Error(`No Nextcloud Talk (spreed repository) has been found in TALK_PATH=${TALK_PATH}`)
}

if (talkPackageJson.name !== 'talk') {
throw new Error(`No Nextcloud Talk (spreed repository) but "${talkPackageJson.name}" has been found in TALK_PATH=${TALK_PATH}`)
}

if (semver.lte(talkPackageJson.version, MIN_REQUIRED_BUILT_IN_TALK_VERSION)) {
throw new Error(`The minimum supported version of built-in Nextcloud Talk is ${MIN_REQUIRED_BUILT_IN_TALK_VERSION}, but ${talkPackageJson.version} has been found in TALK_PATH=${TALK_PATH}`)
}
},

postStart() {
console.log(`Started with built-in Nextcloud Talk v${talkPackageJson.version} on path: ${TALK_PATH}`)
},

postPackage() {
console.log(`Packaged with built-in Nextcloud Talk v${talkPackageJson.version} on path: ${TALK_PATH}`)
},
},

rebuildConfig: {},

makers: [
// {
// name: '@electron-forge/maker-squirrel',
Expand All @@ -44,6 +84,7 @@ module.exports = {
// config: {},
// },
],

plugins: [
{
name: '@electron-forge/plugin-webpack',
Expand Down
5 changes: 0 additions & 5 deletions webpack.renderer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@
require('dotenv').config()

const path = require('node:path')
const fs = require('node:fs')
const webpack = require('webpack')
const { mergeWithRules } = require('webpack-merge')

const TALK_PATH = path.resolve(__dirname, process.env.TALK_PATH ?? 'spreed')
if (!fs.existsSync(process.env.TALK_PATH)) {
throw new Error(`TALK_PATH path is not correct: ${path.resolve(TALK_PATH)}`)
}
console.log(`Using Nextcloud Talk on path: ${path.resolve(TALK_PATH)}`)

/**
* appName and appVersion constants are set by process.env.npm_package_* in @nextcloud/webpack-vue-config.
Expand Down

0 comments on commit 4c4675c

Please sign in to comment.