86 lines
2.2 KiB
JavaScript
86 lines
2.2 KiB
JavaScript
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
const srcDir = path.join(rootDir, "src");
|
|
const distDir = path.join(rootDir, "dist");
|
|
const contentScript = await readFile(path.join(srcDir, "content.js"), "utf8");
|
|
const backgroundScript = await readFile(path.join(srcDir, "background.js"), "utf8");
|
|
const checkOnly = process.argv.includes("--check");
|
|
|
|
const baseManifest = {
|
|
manifest_version: 3,
|
|
name: "Opportunities Extension",
|
|
description: "Adiciona um atalho de Opportunities Extension nas paginas Oracle Fusion permitidas.",
|
|
version: "1.0.0",
|
|
permissions: [
|
|
"cookies"
|
|
],
|
|
host_permissions: [
|
|
"https://eeho.fa.us2.oraclecloud.com/*"
|
|
],
|
|
content_scripts: [
|
|
{
|
|
matches: [
|
|
"https://eeho.fa.us2.oraclecloud.com/hcmUI/faces/FuseWelcome*",
|
|
"https://eeho.fa.us2.oraclecloud.com/fscmUI/faces/FuseWelcome*"
|
|
],
|
|
js: ["content.js"],
|
|
all_frames: true,
|
|
run_at: "document_idle"
|
|
}
|
|
]
|
|
};
|
|
|
|
const targets = [
|
|
{
|
|
name: "chromium",
|
|
manifest: {
|
|
...baseManifest,
|
|
background: {
|
|
service_worker: "background.js"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
name: "firefox",
|
|
manifest: {
|
|
...baseManifest,
|
|
background: {
|
|
scripts: ["background.js"]
|
|
},
|
|
browser_specific_settings: {
|
|
gecko: {
|
|
id: "opportunities-extension@local.dev"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
];
|
|
|
|
if (!checkOnly) {
|
|
await rm(distDir, { recursive: true, force: true });
|
|
}
|
|
|
|
for (const target of targets) {
|
|
const manifestJson = `${JSON.stringify(target.manifest, null, 2)}\n`;
|
|
JSON.parse(manifestJson);
|
|
|
|
if (checkOnly) {
|
|
continue;
|
|
}
|
|
|
|
const outputDir = path.join(distDir, target.name);
|
|
await mkdir(outputDir, { recursive: true });
|
|
await writeFile(path.join(outputDir, "manifest.json"), manifestJson);
|
|
await writeFile(path.join(outputDir, "content.js"), contentScript);
|
|
await writeFile(path.join(outputDir, "background.js"), backgroundScript);
|
|
}
|
|
|
|
if (!checkOnly) {
|
|
console.log("Build gerado em dist/chromium e dist/firefox.");
|
|
} else {
|
|
console.log("Build check ok.");
|
|
}
|