Front version (#6181)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-07-30 12:49:50 +05:00 committed by Andrey Sobolev
parent 8a45a3fdde
commit 51ae72b5cb
No known key found for this signature in database
GPG Key ID: BD80F68D68D8F7F2
17 changed files with 101 additions and 26 deletions

View File

@ -0,0 +1,31 @@
//
// Copyright © 2024 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
const exec = require('child_process').exec
exec('git describe --tags --abbrev=0', (err, stdout, stderr) => {
if (err !== null) {
console.log('"0.6.0"')
}
const rawVersion = stdout.trim().replace('v', '').split('.')
if (rawVersion.length === 3) {
const version = {
major: parseInt(rawVersion[0]),
minor: parseInt(rawVersion[1]),
patch: parseInt(rawVersion[2])
}
console.log(`"${version.major}.${version.minor}.${version.patch}"`)
}
})

View File

@ -7,10 +7,10 @@
"scripts": {
"_phase:package": "rushx package",
"package": "rushx bump && rm -rf ./dist && cp -r ../desktop/dist . && cp ../desktop/.env ./dist && echo 'done'",
"dist": "cross-env CSC_IDENTITY_AUTO_DISCOVERY=false NODE_ENV=production MODEL_VERSION=$(node ../common/scripts/show_version.js) electron-builder build -p onTag",
"dist-local": "cross-env CSC_IDENTITY_AUTO_DISCOVERY=false NODE_ENV=production MODEL_VERSION=$(node ../common/scripts/show_version.js) electron-builder build",
"dist-signed": "cross-env CSC_IDENTITY_AUTO_DISCOVERY=true NODE_ENV=production MODEL_VERSION=$(node ../common/scripts/show_version.js) electron-builder build -c.afterSign=scripts/notarize.js -p onTag",
"dist-mac-win": "cross-env CSC_IDENTITY_AUTO_DISCOVERY=false NODE_ENV=production MODEL_VERSION=$(node ../common/scripts/show_version.js) electron-builder build --windows --x64",
"dist": "cross-env CSC_IDENTITY_AUTO_DISCOVERY=false NODE_ENV=production VERSION=$(node ../common/scripts/show_tag.js) MODEL_VERSION=$(node ../common/scripts/show_version.js) electron-builder build -p onTag",
"dist-local": "cross-env CSC_IDENTITY_AUTO_DISCOVERY=false NODE_ENV=production VERSION=$(node ../common/scripts/show_tag.js) MODEL_VERSION=$(node ../common/scripts/show_version.js) electron-builder build",
"dist-signed": "cross-env CSC_IDENTITY_AUTO_DISCOVERY=true NODE_ENV=production VERSION=$(node ../common/scripts/show_tag.js) MODEL_VERSION=$(node ../common/scripts/show_version.js) electron-builder build -c.afterSign=scripts/notarize.js -p onTag",
"dist-mac-win": "cross-env CSC_IDENTITY_AUTO_DISCOVERY=false NODE_ENV=production VERSION=$(node ../common/scripts/show_tag.js) MODEL_VERSION=$(node ../common/scripts/show_version.js) electron-builder build --windows --x64",
"format": "echo done",
"bump": "bump-package-version"
},

View File

@ -1,7 +1,7 @@
#!/bin/bash
endpoint=https://47fadbaa4ecbea9f3e8b7043a4584e27.r2.cloudflarestorage.com
bucket=desktop-distro
rawVersion=$(node common/scripts/show_version.js)
rawVersion=$(node common/scripts/show_tag.js)
version=${rawVersion:1:${#rawVersion}-2}
cd desktop-package/deploy

View File

@ -8,12 +8,12 @@
"build:watch": "tsc",
"_phase:package": "rushx package",
"_phase:validate": "compile validate",
"package": "rushx bump && cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) NODE_ENV=production webpack --stats-error-details && echo 'done'",
"webpack": "cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) NODE_ENV=development webpack --stats-error-details --progress -w",
"devp": "cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) NODE_ENV=production CLIENT_TYPE=dev webpack --progress -w",
"dev": "cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) NODE_ENV=development webpack --progress -w",
"start": "cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) NODE_ENV=production electron .",
"start-dev": "cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) NODE_ENV=development electron .",
"package": "rushx bump && cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) VERSION=$(node ../common/scripts/show_tag.js) NODE_ENV=production webpack --stats-error-details && echo 'done'",
"webpack": "cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) VERSION=$(node ../common/scripts/show_tag.js) NODE_ENV=development webpack --stats-error-details --progress -w",
"devp": "cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) VERSION=$(node ../common/scripts/show_tag.js) NODE_ENV=production CLIENT_TYPE=dev webpack --progress -w",
"dev": "cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) VERSION=$(node ../common/scripts/show_tag.js) NODE_ENV=development webpack --progress -w",
"start": "cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) VERSION=$(node ../common/scripts/show_tag.js) NODE_ENV=production electron .",
"start-dev": "cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) VERSION=$(node ../common/scripts/show_tag.js) NODE_ENV=development electron .",
"format": "format",
"bump": "bump-package-version"
},

View File

@ -73,7 +73,7 @@ if (require('electron-squirrel-startup') === true) {
app.quit()
}
console.log('Running Huly', process.env.MODEL_VERSION, isMac, isDev, process.env.NODE_ENV)
console.log('Running Huly', process.env.MODEL_VERSION, process.env.VERSION, isMac, isDev, process.env.NODE_ENV)
function hookOpenWindow (window: BrowserWindow): void {
window.webContents.setWindowOpenHandler(({ url }) => {
@ -226,7 +226,8 @@ ipcMain.handle('get-main-config', (event, path) => {
CONFIG_URL: process.env.CONFIG_URL ?? '',
FRONT_URL,
INITIAL_URL: process.env.INITIAL_URL ?? '',
MODEL_VERSION: process.env.MODEL_VERSION ?? ''
MODEL_VERSION: process.env.MODEL_VERSION ?? '',
VERSION: process.env.VERSION ?? '',
}
return cfg
})

View File

@ -211,7 +211,11 @@ export async function configurePlatform (): Promise<void> {
if (config.MODEL_VERSION != null) {
console.log('Minimal Model version requirement', config.MODEL_VERSION)
setMetadata(presentation.metadata.RequiredVersion, config.MODEL_VERSION)
setMetadata(presentation.metadata.ModelVersion, config.MODEL_VERSION)
}
if (config.VERSION != null) {
console.log('Minimal version requirement', config.VERSION)
setMetadata(presentation.metadata.FrontVersion, config.VERSION)
}
setMetadata(telegram.metadata.TelegramURL, config.TELEGRAM_URL ?? 'http://localhost:8086')
setMetadata(gmail.metadata.GmailURL, config.GMAIL_URL ?? 'http://localhost:8087')

View File

@ -47,7 +47,8 @@ const expose: IPCMainExposed = {
...mainConfig,
INITIAL_URL: openArg ?? '',
UPLOAD_URL: concatLink(mainConfig.FRONT_URL, serverConfig.UPLOAD_URL),
MODEL_VERSION: mainConfig.MODEL_VERSION
MODEL_VERSION: mainConfig.MODEL_VERSION,
VERSION: mainConfig.VERSION
}
ipcRenderer.send('set-combined-config', combinedConfig)

View File

@ -10,6 +10,7 @@ export interface Config {
FRONT_URL: string
UPLOAD_URL: string
MODEL_VERSION?: string
VERSION?: string
TELEGRAM_URL: string
GMAIL_URL: string
CALENDAR_URL: string

View File

@ -67,7 +67,8 @@ module.exports = [
...(doValidate ? [new ForkTsCheckerWebpackPlugin()] : []),
new Dotenv({ path: prod ? '.env' : '.env-dev' }),
new DefinePlugin({
'process.env.MODEL_VERSION': JSON.stringify(process.env.MODEL_VERSION)
'process.env.MODEL_VERSION': JSON.stringify(process.env.MODEL_VERSION),
'process.env.VERSION': JSON.stringify(process.env.VERSION)
})
],
module: {

View File

@ -3,7 +3,6 @@
"COLLABORATOR_URL": "ws://localhost:3078",
"COLLABORATOR_API_URL": "http://localhost:3078",
"UPLOAD_URL":"/files",
"MODEL_VERSION": null,
"TELEGRAM_URL": "http://localhost:8086",
"GMAIL_URL": "http://localhost:8088",
"CALENDAR_URL": "http://localhost:8095",
@ -15,5 +14,7 @@
"PRINT_URL": "http://localhost:4005",
"SIGN_URL": "http://localhost:4006",
"ANALYTICS_COLLECTOR_URL": "http://localhost:4077",
"BRANDING_URL": "/branding.json"
"BRANDING_URL": "/branding.json",
"VERSION": "0.6.266",
"MODEL_VERSION": "0.6.266"
}

View File

@ -120,6 +120,7 @@ export interface Config {
ACCOUNTS_URL: string
UPLOAD_URL: string
MODEL_VERSION: string
VERSION: string
COLLABORATOR_URL: string
COLLABORATOR_API_URL: string
REKONI_URL: string
@ -291,7 +292,11 @@ export async function configurePlatform() {
if (config.MODEL_VERSION != null) {
console.log('Minimal Model version requirement', config.MODEL_VERSION)
setMetadata(presentation.metadata.RequiredVersion, config.MODEL_VERSION)
setMetadata(presentation.metadata.ModelVersion, config.MODEL_VERSION)
}
if (config.VERSION != null) {
console.log('Minimal version requirement', config.VERSION)
setMetadata(presentation.metadata.FrontVersion, config.VERSION)
}
setMetadata(telegram.metadata.TelegramURL, config.TELEGRAM_URL ?? 'http://localhost:8086')
setMetadata(gmail.metadata.GmailURL, config.GMAIL_URL ?? 'http://localhost:8087')

View File

@ -126,7 +126,8 @@ export default plugin(presentationId, {
FilePreviewExtension: '' as ComponentExtensionId
},
metadata: {
RequiredVersion: '' as Metadata<string>,
ModelVersion: '' as Metadata<string>,
FrontVersion: '' as Metadata<string>,
Draft: '' as Metadata<Record<string, any>>,
UploadURL: '' as Metadata<string>,
CollaboratorUrl: '' as Metadata<string>,

View File

@ -2,6 +2,7 @@ import { Analytics } from '@hcengineering/analytics'
import client from '@hcengineering/client'
import core, {
ClientConnectEvent,
concatLink,
setCurrentAccount,
versionToString,
type AccountClient,
@ -105,6 +106,15 @@ export async function connect (title: string): Promise<Client | undefined> {
}
versionError.set(`${currentVersionStr} => ${reconnectVersionStr}`)
}
const frontUrl = getMetadata(presentation.metadata.FrontUrl) ?? ''
const currentFrontVersion = getMetadata(presentation.metadata.FrontVersion)
if (currentFrontVersion !== undefined) {
const frontConfig = await (await fetch(concatLink(frontUrl, '/config.json'))).json()
if (frontConfig?.version !== undefined && frontConfig.version !== currentFrontVersion) {
location.reload()
}
}
}
})()
} catch (err) {
@ -127,7 +137,7 @@ export async function connect (title: string): Promise<Client | undefined> {
version = await _client.findOne<Version>(core.class.Version, {})
console.log('Model version', version)
const requiredVersion = getMetadata(presentation.metadata.RequiredVersion)
const requiredVersion = getMetadata(presentation.metadata.ModelVersion)
if (requiredVersion !== undefined && version !== undefined) {
console.log('checking min model version', requiredVersion)
const versionStr = versionToString(version)
@ -140,7 +150,7 @@ export async function connect (title: string): Promise<Client | undefined> {
} catch (err: any) {
Analytics.handleError(err)
console.error(err)
const requirdVersion = getMetadata(presentation.metadata.RequiredVersion)
const requirdVersion = getMetadata(presentation.metadata.ModelVersion)
console.log('checking min model version', requirdVersion)
if (requirdVersion !== undefined) {
versionError.set(`'unknown' => ${requirdVersion}`)

View File

@ -2,6 +2,7 @@ import { Analytics } from '@hcengineering/analytics'
import client from '@hcengineering/client'
import core, {
ClientConnectEvent,
concatLink,
getCurrentAccount,
MeasureMetricsContext,
metricsToString,
@ -211,6 +212,15 @@ export async function connect (title: string): Promise<Client | undefined> {
}
versionError.set(`${currentVersionStr} != ${reconnectVersionStr}`)
}
const frontUrl = getMetadata(presentation.metadata.FrontUrl) ?? ''
const currentFrontVersion = getMetadata(presentation.metadata.FrontVersion)
if (currentFrontVersion !== undefined) {
const frontConfig = await (await fetch(concatLink(frontUrl, '/config.json'))).json()
if (frontConfig?.version !== undefined && frontConfig.version !== currentFrontVersion) {
location.reload()
}
}
}
})()
} catch (err) {
@ -265,7 +275,7 @@ export async function connect (title: string): Promise<Client | undefined> {
)
console.log('Model version', version)
const requiredVersion = getMetadata(presentation.metadata.RequiredVersion)
const requiredVersion = getMetadata(presentation.metadata.ModelVersion)
if (requiredVersion !== undefined && version !== undefined && requiredVersion !== '') {
console.log('checking min model version', requiredVersion)
const versionStr = versionToString(version)
@ -278,7 +288,7 @@ export async function connect (title: string): Promise<Client | undefined> {
} catch (err: any) {
console.error(err)
Analytics.handleError(err)
const requiredVersion = getMetadata(presentation.metadata.RequiredVersion)
const requiredVersion = getMetadata(presentation.metadata.ModelVersion)
console.log('checking min model version', requiredVersion)
if (requiredVersion !== undefined) {
versionError.set(`'unknown' => ${requiredVersion}`)

View File

@ -14,14 +14,14 @@
"_phase:package": "rushx package",
"_phase:docker-build": "rushx docker:build",
"_phase:docker-staging": "rushx docker:staging",
"bundle": "mkdir -p bundle && esbuild src/__start.ts --keep-names --define:process.env.MODEL_VERSION=$(node ../../common/scripts/show_version.js) --bundle --minify --platform=node --external:sharp --outfile=bundle/bundle.js --log-level=error --sourcemap=external",
"bundle": "mkdir -p bundle && esbuild src/__start.ts --keep-names --define:process.env.MODEL_VERSION=$(node ../../common/scripts/show_version.js) --define:process.env.VERSION=$(node ../../common/scripts/show_tag.js) --bundle --minify --platform=node --external:sharp --outfile=bundle/bundle.js --log-level=error --sourcemap=external",
"package": "rm -rf ./dist && cp -r ../../dev/prod/dist . && cp -r ../../dev/prod/public/* ./dist/ && rm ./dist/config.json",
"docker:build": "../../common/scripts/docker_build.sh hardcoreeng/front",
"docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/front staging",
"docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/front",
"docker:tbuild": "docker build -t hardcoreeng/front . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/front",
"format": "format src",
"run-local": "cross-env MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost SERVER_SECRET='secret' ACCOUNTS_URL=http://localhost:3000 UPLOAD_URL=/files ELASTIC_URL=http://localhost:9200 MODEL_VERSION=$(node ../../common/scripts/show_version.js) PUBLIC_DIR='.' ts-node ./src/__start.ts",
"run-local": "cross-env MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost SERVER_SECRET='secret' ACCOUNTS_URL=http://localhost:3000 UPLOAD_URL=/files ELASTIC_URL=http://localhost:9200 MODEL_VERSION=$(node ../../common/scripts/show_version.js) VERSION=$(node ../../common/scripts/show_tag.js) PUBLIC_DIR='.' ts-node ./src/__start.ts",
"test": "jest --passWithNoTests --silent --forceExit",
"_phase:build": "compile transpile src",
"_phase:test": "jest --passWithNoTests --silent --forceExit",

View File

@ -241,6 +241,7 @@ export function start (
accountsUrl: string
uploadUrl: string
modelVersion: string
version: string
rekoniUrl: string
telegramUrl: string
gmailUrl: string
@ -290,6 +291,7 @@ export function start (
ACCOUNTS_URL: config.accountsUrl,
UPLOAD_URL: config.uploadUrl,
MODEL_VERSION: config.modelVersion,
VERSION: config.version,
REKONI_URL: config.rekoniUrl,
TELEGRAM_URL: config.telegramUrl,
GMAIL_URL: config.gmailUrl,

View File

@ -93,6 +93,12 @@ export function startFront (ctx: MeasureContext, extraConfig?: Record<string, st
process.exit(1)
}
const version = process.env.VERSION
if (version === undefined) {
console.error('please provide version requirement')
process.exit(1)
}
const serverSecret = process.env.SERVER_SECRET
if (serverSecret === undefined) {
console.log('Please provide server secret')
@ -118,6 +124,7 @@ export function startFront (ctx: MeasureContext, extraConfig?: Record<string, st
accountsUrl,
uploadUrl,
modelVersion,
version,
gmailUrl,
telegramUrl,
rekoniUrl,