fix the production package cannot run issue caused by glob(path-scurry) module error - maybe the version of glob is too new, and there exists different version of glob, so download rimraf and typeorm to makes major version of glob at 7

This commit is contained in:
geekgeekrun
2024-03-21 01:24:42 +08:00
parent af92ef6718
commit 3f6a4615e3
18 changed files with 215 additions and 396 deletions

View File

@@ -0,0 +1,27 @@
import * as path from 'node:path';
import type typeormType from 'typeorm'
const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE)
const isUiDev = process.env.NODE_ENV === 'development'
export function requireTypeorm () {
let typeorm: typeof typeormType
// production
if (
isRunFromUi && !isUiDev
) {
const electron = require('electron')
const runtimeDependencies = require(
path.resolve(
electron.app.getAppPath(),
'..',
'external-node-runtime-dependencies/index.cjs'
)
)
typeorm = runtimeDependencies.typeorm
} else {
const importResult = require('typeorm')
typeorm = importResult
}
return typeorm
}