fix: update legacy path (#3328)
This commit is contained in:
parent
60587649c5
commit
5eb112142c
@ -4,6 +4,7 @@ import { join } from 'path'
|
|||||||
import { AppConfiguration } from '@janhq/core/node'
|
import { AppConfiguration } from '@janhq/core/node'
|
||||||
import os from 'os'
|
import os from 'os'
|
||||||
import { dump, load } from 'js-yaml'
|
import { dump, load } from 'js-yaml'
|
||||||
|
import { app } from 'electron'
|
||||||
|
|
||||||
const configurationFileName = '.janrc'
|
const configurationFileName = '.janrc'
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ const defaultAppConfig: AppConfiguration = {
|
|||||||
cortexCppHost: '127.0.0.1',
|
cortexCppHost: '127.0.0.1',
|
||||||
cortexCppPort: 3940,
|
cortexCppPort: 3940,
|
||||||
apiServerHost: '127.0.0.1',
|
apiServerHost: '127.0.0.1',
|
||||||
apiServerPort: 1338
|
apiServerPort: 1338,
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createUserSpace(): Promise<void> {
|
export async function createUserSpace(): Promise<void> {
|
||||||
@ -90,11 +91,8 @@ export const getAppConfigurations = (): AppConfiguration => {
|
|||||||
|
|
||||||
// Get configuration file path of the application
|
// Get configuration file path of the application
|
||||||
const getConfigurationFilePath = () => {
|
const getConfigurationFilePath = () => {
|
||||||
const homeDir = os.homedir();
|
const homeDir = os.homedir()
|
||||||
const configPath = join(
|
const configPath = join(homeDir, configurationFileName)
|
||||||
homeDir,
|
|
||||||
configurationFileName,
|
|
||||||
);
|
|
||||||
return configPath
|
return configPath
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,21 +115,23 @@ export const updateAppConfiguration = (
|
|||||||
* @returns {string} The data folder path.
|
* @returns {string} The data folder path.
|
||||||
*/
|
*/
|
||||||
export const getJanDataFolderPath = (): string => {
|
export const getJanDataFolderPath = (): string => {
|
||||||
return getAppConfigurations().dataFolderPath
|
return getAppConfigurations().dataFolderPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is to support pulling legacy configs for migration purpose
|
// This is to support pulling legacy configs for migration purpose
|
||||||
export const legacyConfigs = () => {
|
export const legacyConfigs = () => {
|
||||||
const legacyConfigFilePath = join(
|
const legacyConfigFilePath = join(app.getPath('userData'), 'settings.json')
|
||||||
process.env[process.platform == 'win32' ? 'USERPROFILE' : 'HOME'] ?? '',
|
|
||||||
'settings.json'
|
const legacyConfigs = JSON.parse(
|
||||||
)
|
readFileSync(legacyConfigFilePath, 'utf-8')
|
||||||
const legacyConfigs = JSON.parse(readFileSync(legacyConfigFilePath, 'utf-8')) as any
|
) as any
|
||||||
|
|
||||||
|
console.debug('legacyConfigs', legacyConfigs)
|
||||||
|
|
||||||
return legacyConfigs
|
return legacyConfigs
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is to support pulling legacy data path for migration purpose
|
// This is to support pulling legacy data path for migration purpose
|
||||||
export const legacyDataPath = () => {
|
export const legacyDataPath = () => {
|
||||||
return legacyConfigs().data_path
|
return legacyConfigs().data_folder
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user