2023-09-23 09:19:03 +00:00
|
|
|
From 8295005701c85955551b7493922b41085843fbe6 Mon Sep 17 00:00:00 2001
|
2023-06-01 07:31:56 +00:00
|
|
|
From: Alyxia Sother <alyxia@riseup.net>
|
2023-09-23 09:19:03 +00:00
|
|
|
Date: Sat, 23 Sep 2023 11:16:37 +0200
|
2023-06-01 07:31:56 +00:00
|
|
|
Subject: [PATCH] web: build local extensions as well
|
|
|
|
|
|
|
|
---
|
2023-09-23 09:19:03 +00:00
|
|
|
web/buildExtension.js | 44 +++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
1 file changed, 44 insertions(+)
|
2023-06-01 07:31:56 +00:00
|
|
|
|
|
|
|
diff --git a/web/buildExtension.js b/web/buildExtension.js
|
2023-09-23 09:19:03 +00:00
|
|
|
index 206408c..8ed3312 100644
|
2023-06-01 07:31:56 +00:00
|
|
|
--- a/web/buildExtension.js
|
|
|
|
+++ b/web/buildExtension.js
|
2023-09-23 09:19:03 +00:00
|
|
|
@@ -1,7 +1,46 @@
|
2023-06-01 07:31:56 +00:00
|
|
|
+const fs = require("fs");
|
|
|
|
+const os = require("os");
|
|
|
|
+const path = require("path");
|
|
|
|
const webpack = require("webpack");
|
|
|
|
process.env.BUILD_TYPE = "extension";
|
|
|
|
const config = require("./webpack.config.js");
|
|
|
|
|
2023-09-23 09:19:03 +00:00
|
|
|
+const platform = os.platform();
|
|
|
|
+let dataDir;
|
|
|
|
+switch (platform) {
|
|
|
|
+ case "linux":
|
|
|
|
+ dataDir = path.join(os.homedir(), ".config/hh3");
|
|
|
|
+ break;
|
|
|
|
+ case "darwin":
|
|
|
|
+ dataDir = path.join(os.homedir(), "Library/ApplicationSupport/hh3");
|
|
|
|
+ break;
|
|
|
|
+}
|
|
|
|
+if (!dataDir) throw new Error("No dataDir could be inferred! Aborting!");
|
|
|
|
+
|
|
|
|
+const PATH_TO_EXTS = path.join(dataDir, "ext");
|
2023-06-01 07:31:56 +00:00
|
|
|
+const HH_EXT_DIR = path.join(__dirname, "../ext");
|
|
|
|
+let exts = fs.readdirSync(PATH_TO_EXTS);
|
|
|
|
+exts = exts.filter((e) => e !== ".git");
|
|
|
|
+
|
|
|
|
+function deleteF(path) {
|
|
|
|
+ const isDir = fs.lstatSync(path).isDirectory();
|
|
|
|
+ if (isDir) fs.rmSync(path, {recursive: true});
|
|
|
|
+ else fs.unlinkSync(path);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+for (const ext of exts) {
|
|
|
|
+ if (fs.existsSync(path.join(HH_EXT_DIR, ext)))
|
|
|
|
+ deleteF(path.join(HH_EXT_DIR, ext));
|
|
|
|
+
|
|
|
|
+ const source = path.join(PATH_TO_EXTS, ext);
|
|
|
|
+ const dest = path.join(HH_EXT_DIR, ext);
|
|
|
|
+
|
|
|
|
+ fs.cpSync(source, dest, {
|
|
|
|
+ recursive: true,
|
|
|
|
+ });
|
|
|
|
+ console.log(`${source} -> ${dest}`);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
webpack.webpack(config, (err, stats) => {
|
|
|
|
if (!stats?.compilation) {
|
|
|
|
console.log(err);
|
2023-09-23 09:19:03 +00:00
|
|
|
@@ -21,5 +60,10 @@ webpack.webpack(config, (err, stats) => {
|
2023-06-01 07:31:56 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
+ for (let ext of exts) {
|
|
|
|
+ ext = path.join(HH_EXT_DIR, ext);
|
|
|
|
+ deleteF(ext);
|
|
|
|
+ console.log(`✕ ${ext}`);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
});
|
|
|
|
--
|
2023-09-23 09:19:03 +00:00
|
|
|
2.42.0
|
2023-06-01 07:31:56 +00:00
|
|
|
|