Skip to content

feat: add modus run command #943

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

Closed
wants to merge 2 commits into from
Closed
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
58 changes: 58 additions & 0 deletions cli/src/commands/run/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* SPDX-FileCopyrightText: © Hypermode Inc. <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/

import { Args, Flags } from "@oclif/core";
import { BaseCommand } from "../../baseCommand.js";
import DevCommand from "../dev/index.js";

export default class RunCommand extends BaseCommand {
static args = {
path: Args.directory({
description: "Path to app directory",
default: ".",
exists: true,
}),
Comment on lines +12 to +16
Copy link
Member

Choose a reason for hiding this comment

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

Please validate that this will work if the app path is to the source code OR to the build folder. The logic should be:

  • If a build folder exists under the given path, use the wasm, json, and env files from there.
  • If not, then expect them to exist directly at the given path.

This will allow for both running locally and for copying the build folder elsewhere and running directly.

You may need to adjust stuff in the DevCommand, or copy it here.

Copy link
Contributor Author

@JairusSW JairusSW Jul 12, 2025

Choose a reason for hiding this comment

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

That's easy enough. The main limitation here is finding the SDK version.
I suppose the order of operations for determining the SDK version might be:

  • Look for a package-lock.json in the current directory.
  • If not found, check the parent directory (../) for a package-lock.json.
  • If neither exists, fall back to using the latest version.

Alternatively, you could extract the SDK version directly from the .wasm file metadata

Thoughts?

};

static flags = {
runtime: Flags.string({
char: "r",
description: "Modus runtime version to use. If not provided, the latest runtime compatible with the app will be used.",
}),
prerelease: Flags.boolean({
char: "p",
aliases: ["pre"],
description: "Use a prerelease version of the Modus runtime. Not needed if specifying a runtime version.",
}),
build: Flags.boolean({
char: "b",
description: "Build the app before running (or when watching for changes)",
default: true,
}),
watch: Flags.boolean({
char: "w",
description: "Watch app code for changes",
default: false,
}),
delay: Flags.integer({
description: "Delay (in milliseconds) between file change detection and rebuild",
default: 500,
}),
};

static description = "Run a Modus app locally";

static examples = ["modus run", "modus run ./my-app", "modus run ./my-app --no-watch"];

async run(): Promise<void> {
const { flags } = await this.parse(RunCommand);
const argv = this.argv.filter((arg) => arg != "--watch" && arg != "-w" && arg != "--build" && arg != "-b");

if (!flags.watch) argv.push("--no-watch");
if (!flags.build) argv.push("--no-build");

await DevCommand.run(argv);
}
}