From 052861b28dff57f727ef770e21156b712c3620a3 Mon Sep 17 00:00:00 2001 From: Jairus Tanaka Date: Fri, 11 Jul 2025 16:35:59 -0700 Subject: [PATCH 1/2] feat: add `modus run` command --- cli/src/commands/run/index.ts | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 cli/src/commands/run/index.ts diff --git a/cli/src/commands/run/index.ts b/cli/src/commands/run/index.ts new file mode 100644 index 000000000..454d8e2c3 --- /dev/null +++ b/cli/src/commands/run/index.ts @@ -0,0 +1,48 @@ +/* + * SPDX-FileCopyrightText: © Hypermode Inc. + * 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, + }), + }; + + 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.", + }), + "no-build": Flags.boolean({ + aliases: ["nobuild"], + description: "Don't build the app before running (or when watching for changes)", + default: true, + }), + watch: Flags.boolean({ + aliases: ["w"], + description: "Watch app code for changes", + default: true, + }), + }; + + static description = "Run a Modus app locally"; + + static examples = ["modus run", "modus run ./my-app", "modus run ./my-app --no-watch"]; + + async run(): Promise { + DevCommand.run(this.argv); + } +} From f7302c9024534b2812dfad0bb56983875ce74cf1 Mon Sep 17 00:00:00 2001 From: Jairus Tanaka Date: Fri, 11 Jul 2025 16:49:25 -0700 Subject: [PATCH 2/2] fix: invert flags --- cli/src/commands/run/index.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/cli/src/commands/run/index.ts b/cli/src/commands/run/index.ts index 454d8e2c3..6adf492de 100644 --- a/cli/src/commands/run/index.ts +++ b/cli/src/commands/run/index.ts @@ -26,15 +26,19 @@ export default class RunCommand extends BaseCommand { aliases: ["pre"], description: "Use a prerelease version of the Modus runtime. Not needed if specifying a runtime version.", }), - "no-build": Flags.boolean({ - aliases: ["nobuild"], - description: "Don't build the app before running (or when watching for changes)", + build: Flags.boolean({ + char: "b", + description: "Build the app before running (or when watching for changes)", default: true, }), watch: Flags.boolean({ - aliases: ["w"], + char: "w", description: "Watch app code for changes", - default: true, + default: false, + }), + delay: Flags.integer({ + description: "Delay (in milliseconds) between file change detection and rebuild", + default: 500, }), }; @@ -43,6 +47,12 @@ export default class RunCommand extends BaseCommand { static examples = ["modus run", "modus run ./my-app", "modus run ./my-app --no-watch"]; async run(): Promise { - DevCommand.run(this.argv); + 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); } }