Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #3971

Merged
merged 7 commits into from
Aug 12, 2024
Merged

Add #3971

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/*"],
Comment on lines +8 to +13
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please dont change this. @moonlitgrace

}
}
}