fix: broken jan build - add log trace (jan.log) (#3336)

This commit is contained in:
Louis 2024-08-10 15:33:11 +07:00 committed by GitHub
parent 6e4b6b09ae
commit 77422c3a7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 13 deletions

View File

@ -18,7 +18,7 @@ import { handleAppIPCs } from './handlers/native'
* Utils
**/
import { setupMenu } from './utils/menu'
import { createUserSpace, getAppConfigurations } from './utils/path'
import { createUserSpace, getJanDataFolderPath } from './utils/path'
import { migrate } from './utils/migration'
import { cleanUpAndQuit } from './utils/clean'
import { setupCore } from './utils/setup'
@ -34,8 +34,6 @@ const mainPath = join(rendererPath, 'index.html')
const mainUrl = 'http://localhost:3000'
import { dependencies } from './package.json'
const gotTheLock = app.requestSingleInstanceLock()
if (process.defaultApp) {
@ -65,7 +63,11 @@ const host = '127.0.0.1'
app
.whenReady()
.then(() => setupCore(dependencies['cortexso'] ?? 'Not found'))
.then(() => {
const dataFolderPath = join(getJanDataFolderPath(), 'jan.log')
log.transports.file.resolvePathFn = () => dataFolderPath
})
.then(() => setupCore())
.then(() => {
if (!gotTheLock) {
app.quit()
@ -87,13 +89,11 @@ app
)
}
})
.then(() => killProcessesOnPort(cortexCppPort))
.then(() => killProcessesOnPort(cortexJsPort))
.then(() => {
const appConfiguration = getAppConfigurations()
const janDataFolder = appConfiguration.dataFolderPath
start('jan', host, cortexJsPort, cortexCppPort, janDataFolder)
start('jan', host, cortexJsPort, cortexCppPort, getJanDataFolderPath())
})
.then(createUserSpace)
.then(migrate)

View File

@ -35,7 +35,8 @@
"docs",
"scripts",
"icons",
"themes"
"themes",
"package.json"
],
"publish": [
{

View File

@ -1,16 +1,26 @@
import { app } from 'electron'
import Store from 'electron-store'
import { existsSync, readFileSync } from 'original-fs'
import { appResourcePath } from './path'
import { join } from 'path'
const DEFAULT_WIDTH = 1000
const DEFAULT_HEIGHT = 800
const storage = new Store()
export const setupCore = async (cortexsoVersion: string) => {
export const setupCore = async () => {
let cortexVersion = 'N/A'
// Read package.json
const pkgPath = join(await appResourcePath(), 'package.json')
if(existsSync(pkgPath)) {
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
cortexVersion = pkg.dependencies['cortexso']
}
// Setup core api for main process
global.core = {
// Define appPath function for app to retrieve app path globally
appPath: () => app.getPath('userData'),
cortexVersion: () => cortexsoVersion,
cortexVersion: () => cortexVersion,
}
}

View File

@ -1,7 +1,6 @@
import { useCallback } from 'react'
import { Assistant } from '@janhq/core'
import log from 'electron-log/renderer'
import { useSetAtom } from 'jotai'
@ -49,7 +48,6 @@ const useThreads = () => {
assistant.instructions = instructions
}
const thread = await createThread(assistant)
log.info('Create new thread result', thread)
setThreads((threads) => [thread, ...threads])
setActiveThread(thread.id)
return thread