MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / main

Function main

utils/scripts/dev.js:499–558  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

497// ─── main ────────────────────────────────────────────────────────────────────
498
499async function main() {
500 const args = process.argv.slice(2);
501 const platform =
502 args.find((a) => /^(android|ios|browser)$/i.test(a)) || "android";
503 const target =
504 args.find((a) => a.startsWith("--target="))?.split("=")[1] || null;
505 const emulator = args.includes("--emulator") || args.includes("-e");
506
507 console.log("\n ⚡ Acode Dev Mode\n");
508
509 const host = getLocalIP();
510 const port = await getFreePort();
511
512 log("info", `Local IP: ${host}`);
513 log("info", `Port: ${port}`);
514
515 // 1. Ensure cordova files are in www/ for the dev server
516 ensureCordovaFiles();
517
518 // 2. Start HTTPS (or HTTP fallback) + WebSocket server
519 const { server, broadcast, protocol } = await createServer(port);
520 const origin = `${protocol}://${host}:${port}`;
521 log("info", `Dev Origin: ${origin}`);
522 server.listen(port, () => {
523 log("ok", "Dev server started");
524 });
525
526 // 3. Start rspack --watch
527 let appLaunched = false;
528
529 startRspackWatch(host, port, protocol, () => {
530 broadcast("reload");
531
532 if (!appLaunched) {
533 appLaunched = true;
534 setTimeout(async () => {
535 try {
536 await launchApp(target, platform, emulator);
537 } catch (err) {
538 log("warn", `Launch failed: ${err.message}`);
539 }
540 }, 3000); // give APK install time
541 }
542 });
543
544 // 4. Start plugin file watcher
545 startPluginWatcher(platform);
546
547 // Graceful shutdown
548 process.on("SIGINT", () => {
549 log("info", "Shutting down...");
550 server.close();
551 process.exit(0);
552 });
553
554 process.on("SIGTERM", () => {
555 server.close();
556 process.exit(0);

Callers 1

dev.jsFile · 0.70

Calls 13

getLocalIPFunction · 0.85
getFreePortFunction · 0.85
ensureCordovaFilesFunction · 0.85
createServerFunction · 0.85
startRspackWatchFunction · 0.85
broadcastFunction · 0.85
launchAppFunction · 0.85
startPluginWatcherFunction · 0.85
logMethod · 0.80
exitMethod · 0.80
logFunction · 0.70
closeMethod · 0.65

Tested by

no test coverage detected