Files
erp/test/main.ts

78 lines
2.1 KiB
TypeScript

import "load_dotenv";
import { chromium } from "playwright";
import initialSetup from "./scripts/admin/initialSetup.ts";
import login from "./scripts/login.ts";
import companySetup, { Company } from "./scripts/admin/companySetup.ts";
import path from "node:path";
import displaySetup from "./scripts/admin/displaySetup.ts";
/*
Initialisation
*/
const dolibarrAddress = Deno.env.get("DOLIBARR_ADDRESS") ||
"https://erp.arcodange.duckdns.org";
const debug = true;
const DBpassword = Deno.env.get("DOLI_DB_PASSWORD") || "undefined";
const adminCredentials = {
username: Deno.env.get("DOLI_ADMIN_LOGIN") || "undefined",
password: Deno.env.get("DOLI_ADMIN_PASSWORD") || "undefined",
};
const rootFolderPath = Deno.env.get("ROOT_FOLDER") ||
"/Users/gabrielradureau/Desktop/ARCODANGE/erp";
const imgFolderPath = Deno.env.get("IMG_FOLDER") ||
path.join(rootFolderPath, "static/img");
const configFolderPath = Deno.env.get("CONFIG_FOLDER") ||
path.join(rootFolderPath, "static/config");
const browser = await chromium.launch({
headless: false,
logger: {
isEnabled: (_name, _severity) => debug,
log: (name, severity, message, args) =>
console.warn(`${severity}| ${name} :: ${message} __ ${args}`),
},
});
const context = await browser.newContext({ locale: "fr-FR" });
const page = await context.newPage();
const globalCtx = {
dolibarrAddress,
DBpassword,
adminCredentials,
debug,
rootFolderPath,
imgFolderPath,
configFolderPath,
browser,
page,
context,
};
// if (!await initialSetup.isUpgradeLocked(globalCtx)) {
// await initialSetup.doFirstInstall(globalCtx);
// } else {
// console.log("Installation et Mises à jours bloquée par fichier .lock.");
// }
// await login.doAdminLogin(globalCtx);
// console.log(`connected as ${await login.whoAmI(globalCtx)}`);
// const company = JSON.parse(
// await Deno.readTextFile(
// path.join(globalCtx.configFolderPath, "company.json"),
// ),
// ) as Company;
// await companySetup.setupCompany(globalCtx, company);
try {
await displaySetup.setupDisplay(globalCtx);
} catch (error) {
console.error(error);
}
// await browser.close();