Add support version patch and restore support for all platforms
This commit is contained in:
commit
d480b87de1
@ -88,7 +88,9 @@
|
|||||||
"version-restore:darwin": "jq --arg ver $(cat .version.bak) '.version = $ver' package.json > package.tmp && mv package.tmp package.json && rm .version.bak",
|
"version-restore:darwin": "jq --arg ver $(cat .version.bak) '.version = $ver' package.json > package.tmp && mv package.tmp package.json && rm .version.bak",
|
||||||
"version-restore:linux": "jq --arg ver $(cat .version.bak) '.version = $ver' package.json > package.tmp && mv package.tmp package.json && rm .version.bak",
|
"version-restore:linux": "jq --arg ver $(cat .version.bak) '.version = $ver' package.json > package.tmp && mv package.tmp package.json && rm .version.bak",
|
||||||
"version-restore:win32": "node -e \"const fs=require('fs');const pkg=require('./package.json');const bak=fs.readFileSync('.version.bak','utf8');pkg.version=bak;fs.writeFileSync('package.json',JSON.stringify(pkg,null,2));\"",
|
"version-restore:win32": "node -e \"const fs=require('fs');const pkg=require('./package.json');const bak=fs.readFileSync('.version.bak','utf8');pkg.version=bak;fs.writeFileSync('package.json',JSON.stringify(pkg,null,2));\"",
|
||||||
"dev": "yarn copy:assets && tsc -p . && yarn version-patch && electron . && yarn version-restore",
|
"dev:darwin:linux": "yarn copy:assets && tsc -p . && yarn version-patch && electron . && yarn version-restore",
|
||||||
|
"dev:windows": "yarn copy:assets && tsc -p . && electron .",
|
||||||
|
"dev": "run-script-os",
|
||||||
"compile": "tsc -p .",
|
"compile": "tsc -p .",
|
||||||
"start": "electron .",
|
"start": "electron .",
|
||||||
"build": "yarn copy:assets && run-script-os",
|
"build": "yarn copy:assets && run-script-os",
|
||||||
@ -135,6 +137,7 @@
|
|||||||
"electron-playwright-helpers": "^1.6.0",
|
"electron-playwright-helpers": "^1.6.0",
|
||||||
"eslint": "8.57.0",
|
"eslint": "8.57.0",
|
||||||
"eslint-plugin-react": "^7.34.0",
|
"eslint-plugin-react": "^7.34.0",
|
||||||
|
"jq": "^1.7.2",
|
||||||
"rimraf": "^5.0.5",
|
"rimraf": "^5.0.5",
|
||||||
"run-script-os": "^1.1.6",
|
"run-script-os": "^1.1.6",
|
||||||
"typescript": "^5.3.3",
|
"typescript": "^5.3.3",
|
||||||
|
|||||||
@ -10,7 +10,10 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"build": "rolldown -c rolldown.config.mjs",
|
"build": "rolldown -c rolldown.config.mjs",
|
||||||
"build:publish": "rimraf *.tgz --glob || true && yarn build && ../../.github/scripts/auto-sign.sh && npm pack && cpx *.tgz ../../pre-install"
|
"codesign:darwin": "../../.github/scripts/auto-sign.sh",
|
||||||
|
"codesign:win32:linux": "echo 'No codesigning required'",
|
||||||
|
"codesign": "run-script-os",
|
||||||
|
"build:publish": "rimraf *.tgz --glob || true && yarn build && yarn codesign && npm pack && cpx *.tgz ../../pre-install"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./dist/index.js",
|
".": "./dist/index.js",
|
||||||
@ -20,6 +23,7 @@
|
|||||||
"cpx": "^1.5.0",
|
"cpx": "^1.5.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rolldown": "^1.0.0-beta.1",
|
"rolldown": "^1.0.0-beta.1",
|
||||||
|
"run-script-os": "^1.1.6",
|
||||||
"ts-loader": "^9.5.0",
|
"ts-loader": "^9.5.0",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { getJanDataFolderPath, log, SystemInformation } from '@janhq/core/node'
|
import { appResourcePath, getJanDataFolderPath, log, SystemInformation } from '@janhq/core/node'
|
||||||
import { ProcessWatchdog } from './watchdog'
|
import { ProcessWatchdog } from './watchdog'
|
||||||
|
import { readdir, symlink } from 'fs/promises'
|
||||||
|
|
||||||
// The HOST address to use for the Nitro subprocess
|
// The HOST address to use for the Nitro subprocess
|
||||||
const LOCAL_PORT = '39291'
|
const LOCAL_PORT = '39291'
|
||||||
@ -17,7 +18,13 @@ function run(systemInfo?: SystemInformation): Promise<any> {
|
|||||||
let gpuVisibleDevices = systemInfo?.gpuSetting?.gpus_in_use.join(',') ?? ''
|
let gpuVisibleDevices = systemInfo?.gpuSetting?.gpus_in_use.join(',') ?? ''
|
||||||
let binaryName = `cortex-server${process.platform === 'win32' ? '.exe' : ''}`
|
let binaryName = `cortex-server${process.platform === 'win32' ? '.exe' : ''}`
|
||||||
const binPath = path.join(__dirname, '..', 'bin')
|
const binPath = path.join(__dirname, '..', 'bin')
|
||||||
|
await createEngineSymlinks(binPath)
|
||||||
|
|
||||||
const executablePath = path.join(binPath, binaryName)
|
const executablePath = path.join(binPath, binaryName)
|
||||||
|
const sharedPath = path.join(
|
||||||
|
appResourcePath(),
|
||||||
|
'shared'
|
||||||
|
)
|
||||||
// Execute the binary
|
// Execute the binary
|
||||||
log(`[CORTEX]:: Spawn cortex at path: ${executablePath}`)
|
log(`[CORTEX]:: Spawn cortex at path: ${executablePath}`)
|
||||||
|
|
||||||
@ -46,6 +53,7 @@ function run(systemInfo?: SystemInformation): Promise<any> {
|
|||||||
GGML_VK_VISIBLE_DEVICES: gpuVisibleDevices,
|
GGML_VK_VISIBLE_DEVICES: gpuVisibleDevices,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
cwd: sharedPath,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
watchdog.start()
|
watchdog.start()
|
||||||
@ -53,6 +61,23 @@ function run(systemInfo?: SystemInformation): Promise<any> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create symlinks for the engine shared libraries
|
||||||
|
* @param binPath
|
||||||
|
*/
|
||||||
|
async function createEngineSymlinks(binPath: string) {
|
||||||
|
const sharedPath = path.join(appResourcePath(), 'shared')
|
||||||
|
const sharedLibFiles = await readdir(sharedPath)
|
||||||
|
for (const sharedLibFile of sharedLibFiles) {
|
||||||
|
if (sharedLibFile.endsWith('.dll') || sharedLibFile.endsWith('.so')) {
|
||||||
|
const targetDllPath = path.join(sharedPath, sharedLibFile)
|
||||||
|
const symlinkDllPath = path.join(binPath, sharedLibFile)
|
||||||
|
await symlink(targetDllPath, symlinkDllPath).catch(console.error)
|
||||||
|
console.log(`Symlink created: ${targetDllPath} -> ${symlinkDllPath}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Every module should have a dispose function
|
* Every module should have a dispose function
|
||||||
* This will be called when the extension is unloaded and should clean up any resources
|
* This will be called when the extension is unloaded and should clean up any resources
|
||||||
|
|||||||
@ -41,7 +41,6 @@
|
|||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"jest-environment-jsdom": "^29.7.0",
|
"jest-environment-jsdom": "^29.7.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"run-script-os": "^1.1.6",
|
|
||||||
"wait-on": "^7.0.1"
|
"wait-on": "^7.0.1"
|
||||||
},
|
},
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user