Skip to content

Commit

Permalink
Add (#3971)
Browse files Browse the repository at this point in the history
* Add

* Add

* Phase 1

* Add

* Add
  • Loading branch information
baseplate-admin authored Aug 12, 2024
1 parent 9a83d60 commit 221bf64
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 15 deletions.
8 changes: 5 additions & 3 deletions seeder/electron.vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ export default defineConfig({
},
resolve: {
alias: {
"@main": resolve(__dirname, "./src/main"),
"@constants": resolve(__dirname, "./src/main/constants"),
"@interfaces": resolve(__dirname, "./src/main/interfaces")
$constants: resolve(__dirname, "./src/main/constants"),
$interfaces: resolve(__dirname, "./src/main/interfaces"),
$backend: resolve(__dirname, "./src/main/backend"),
$worker: resolve(__dirname, "./src/main/workers"),
$utils: resolve(__dirname, "./src/main/utils")
}
}
},
Expand Down
8 changes: 3 additions & 5 deletions seeder/src/main/constants/os.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const IS_MAC = process.platform === "darwin";
const IS_WINDOWS = process.platform === "win32";
const IS_LINUX = process.platform === "linux";

export { IS_MAC, IS_WINDOWS, IS_LINUX };
export const IS_MAC = process.platform === "darwin";
export const IS_WINDOWS = process.platform === "win32";
export const IS_LINUX = process.platform === "linux";
6 changes: 3 additions & 3 deletions seeder/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { app, shell, BrowserWindow, ipcMain } from "electron";
import { join } from "path";
import { electronApp, optimizer, is } from "@electron-toolkit/utils";
import icon from "../../resources/icon.png?asset";
import { Shiinobi as _Shiinobi } from "@interfaces/shiinobi";
import { get_free_port } from "./utils/port";
import ExpressWorder from "./worker/express_worker?nodeWorker";
import { Shiinobi as _Shiinobi } from "$interfaces/shiinobi";
import { get_free_port } from "$utils/port";
import ExpressWorder from "$worker/express_worker?nodeWorker";

const Shiinobi = new _Shiinobi();

Expand Down
2 changes: 1 addition & 1 deletion seeder/src/main/interfaces/shiinobi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { spawn } from "child_process";
import { IS_LINUX, IS_MAC, IS_WINDOWS } from "@constants/os";
import { IS_LINUX, IS_MAC, IS_WINDOWS } from "$constants/os";
import { join } from "path";

type _COMMANDS =
Expand Down
16 changes: 16 additions & 0 deletions seeder/src/main/workers/express_worker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { parentPort, workerData } from "node:worker_threads";
import { app } from "$backend/index";

const port = parentPort;
if (!port) throw new Error("IllegalState");

port.on("message", () => {
const _port = workerData.port;
try {
app.listen(_port, () => {
port.postMessage(`Listening on ${_port}`);
});
} catch (err) {
port.postMessage(`Couldnot launch express.js, reason ${err}`);
}
});
9 changes: 6 additions & 3 deletions seeder/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
"composite": true,
"types": ["electron-vite/node"],
"paths": {
"@main/*": ["./src/main/*"],
"@constants/*": ["./src/main/constants/*"],
"@interfaces/*": ["./src/main/interfaces/*"],
"$main/*": ["./src/main/*"],
"$constants/*": ["./src/main/constants/*"],
"$interfaces/*": ["./src/main/interfaces/*"],
"$workers/*":["./src/main/workers/*"],
"$backend/*":["./src/main/backend/*"],
"$utils/*":["./src/main/utils/*"],
}
}
}

0 comments on commit 221bf64

Please sign in to comment.