Skip to content

Commit

Permalink
preliminary run script
Browse files Browse the repository at this point in the history
  • Loading branch information
d-roak committed Jul 15, 2024
1 parent dec8e10 commit 4f0e7c9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 37 deletions.
4 changes: 1 addition & 3 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@
"scripts": {
"build": "tsc -b",
"clean": "rm -rf dist/ node_modules/",
"cli": "tsx ./src/index.ts",
"node": "tsx ./src/run_node.ts",
"cli": "tsx ./src/run.ts",
"prebuild": "node -p \"'export const VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
"prepack": "tsc -b",
"relay": "tsx ./src/run_relay.ts",
"test": "vitest"
},
"devDependencies": {
Expand Down
17 changes: 9 additions & 8 deletions packages/node/src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Command } from "commander";
import { VERSION } from "../version";
import { Command, Option } from "commander";
import { VERSION } from "../version.js";

export const program = new Command();

program.version(VERSION);
program.command("start").action(async () => {
// const { start } = await import("./run_node");
// await start();
console.log("start");
});

program.addOption(new Option("-c, --config <file>", "config file"));
program.addOption(
new Option("-m, --mode <mode>", "mode to run in")
.default("node")
.choices(["node", "relay"]),
);
18 changes: 17 additions & 1 deletion packages/node/src/run.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import { program } from "./cli";
import { TopologyNode } from ".";
import { createRelayNode } from "@topology-foundation/network";

export async function start() {
async function startNode() {
const node = new TopologyNode();
node.start();
}

async function startRelay() {
const node = await createRelayNode();
console.log("peer_id:", node.peerId.toString());
for (let ma of node.getMultiaddrs()) {
console.log(ma);
}
}

program.parse(process.argv);
const opts = program.opts();

if (opts.mode === "node") {
startNode();
} else if (opts.mode === "relay") {
startRelay();
}
9 changes: 0 additions & 9 deletions packages/node/src/run_node.ts

This file was deleted.

16 changes: 0 additions & 16 deletions packages/node/src/run_relay.ts

This file was deleted.

0 comments on commit 4f0e7c9

Please sign in to comment.