* fix: reduce the number of api call Signed-off-by: James <james@jan.ai> * fix: download progress Signed-off-by: James <james@jan.ai> * chore: save blob * fix: server boot up * fix: download state not updating Signed-off-by: James <james@jan.ai> * fix: copy assets * Add Dockerfile CPU for Jan Server and Jan Web * Add Dockerfile GPU for Jan Server and Jan Web * feat: S3 adapter * Update check find count from ./pre-install and correct copy:asserts command * server add bundleDependencies @janhq/core * server add bundleDependencies @janhq/core * fix: update success/failed download state (#1945) * fix: update success/failed download state Signed-off-by: James <james@jan.ai> * fix: download model progress and state handling for both Desktop and Web --------- Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai> Co-authored-by: Louis <louis@jan.ai> * chore: refactor * fix: load models empty first time open * Add Docker compose * fix: assistants onUpdate --------- Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai> Co-authored-by: Hien To <tominhhien97@gmail.com> Co-authored-by: NamH <NamNh0122@gmail.com>
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import { join, extname } from "path";
|
|
import { existsSync, readdirSync, writeFileSync, mkdirSync } from "fs";
|
|
import { init, installExtensions } from "@janhq/core/node";
|
|
|
|
export async function setup() {
|
|
/**
|
|
* Setup Jan Data Directory
|
|
*/
|
|
const appDir = process.env.JAN_DATA_DIRECTORY ?? join(__dirname, "..", "jan");
|
|
|
|
console.debug(`Create app data directory at ${appDir}...`);
|
|
if (!existsSync(appDir)) mkdirSync(appDir);
|
|
//@ts-ignore
|
|
global.core = {
|
|
// Define appPath function for app to retrieve app path globaly
|
|
appPath: () => appDir,
|
|
};
|
|
init({
|
|
extensionsPath: join(appDir, "extensions"),
|
|
});
|
|
|
|
/**
|
|
* Write app configurations. See #1619
|
|
*/
|
|
console.debug("Writing config file...");
|
|
writeFileSync(
|
|
join(appDir, "settings.json"),
|
|
JSON.stringify({
|
|
data_folder: appDir,
|
|
}),
|
|
"utf-8"
|
|
);
|
|
|
|
/**
|
|
* Install extensions
|
|
*/
|
|
|
|
console.debug("Installing extensions...");
|
|
|
|
const baseExtensionPath = join(__dirname, "../../..", "pre-install");
|
|
const extensions = readdirSync(baseExtensionPath)
|
|
.filter((file) => extname(file) === ".tgz")
|
|
.map((file) => join(baseExtensionPath, file));
|
|
|
|
await installExtensions(extensions);
|
|
console.debug("Extensions installed");
|
|
}
|