-
Notifications
You must be signed in to change notification settings - Fork 21
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
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}), | ||
}; | ||
|
||
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, | ||
}), | ||
JairusSW marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
static description = "Run a Modus app locally"; | ||
|
||
static examples = ["modus run", "modus run ./my-app", "modus run ./my-app --no-watch"]; | ||
JairusSW marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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:
build
folder exists under the given path, use the wasm, json, and env files from there.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.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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:
package-lock.json
in the current directory.../
) for apackage-lock.json
.Alternatively, you could extract the SDK version directly from the
.wasm
file metadataThoughts?