-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Add forc check command
#2026
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
Merged
Merged
Add forc check command
#2026
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
751bee0
wip
JoshuaBatty 28b42b0
moving back to PC computer
JoshuaBatty 485337b
adding check function to forc pkg
JoshuaBatty f71fb48
have ast returning from forc pkg
JoshuaBatty 704394e
can now successfully parse all sway examples
JoshuaBatty d6476ae
fmt
JoshuaBatty 2bb6117
added forc check
JoshuaBatty 600ff1a
tidy up lsp tests
JoshuaBatty 0ea5848
add forc check command
JoshuaBatty 6ecbbc1
forc ops doesnt need to be public
JoshuaBatty c1c7ffd
tidy up lsp tests
JoshuaBatty dd0c5aa
remove non relevant code
JoshuaBatty 3f353a8
add forc check to mdbook
JoshuaBatty d52e31a
adds a load_from_manifest contructor to BuildPlan
JoshuaBatty fe428ef
rebase onto master
JoshuaBatty 5b15d68
cargo clippy
JoshuaBatty 480f487
fix merge conflicts
JoshuaBatty 5fae80b
add Cargo.lock file
JoshuaBatty e568f04
compile ast also returns an optional namespace
JoshuaBatty 20925ba
handle optional namespace in check fn
JoshuaBatty 3c8cf2a
changed error msg in check fn
JoshuaBatty 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 @@ | ||
| # forc check |
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
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,30 @@ | ||
| use crate::ops::forc_check; | ||
| use anyhow::Result; | ||
| use clap::Parser; | ||
|
|
||
| /// Check the current or target project and all of its dependencies for errors. | ||
| /// | ||
| /// This will essentially compile the packages without performing the final step of code generation, | ||
| /// which is faster than running forc build. | ||
| #[derive(Debug, Default, Parser)] | ||
| pub struct Command { | ||
| /// Path to the project, if not specified, current working directory will be used. | ||
| #[clap(short, long)] | ||
| pub path: Option<String>, | ||
| /// Offline mode, prevents Forc from using the network when managing dependencies. | ||
| /// Meaning it will only try to use previously downloaded dependencies. | ||
| #[clap(long = "offline")] | ||
| pub offline_mode: bool, | ||
| /// Silent mode. Don't output any warnings or errors to the command line. | ||
| #[clap(long = "silent", short = 's')] | ||
| pub silent_mode: bool, | ||
| /// Requires that the Forc.lock file is up-to-date. If the lock file is missing, or it | ||
| /// needs to be updated, Forc will exit with an error | ||
| #[clap(long)] | ||
| pub locked: bool, | ||
| } | ||
|
|
||
| pub(crate) fn exec(command: Command) -> Result<()> { | ||
| forc_check::check(command)?; | ||
| Ok(()) | ||
| } |
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 |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| pub mod addr2line; | ||
| pub mod build; | ||
| pub mod check; | ||
| pub mod clean; | ||
| pub mod completions; | ||
| pub mod deploy; | ||
|
|
||
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
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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| pub mod cli; | ||
| mod ops; | ||
| mod utils; | ||
| pub mod utils; | ||
|
|
||
| #[cfg(feature = "test")] | ||
| pub mod test { | ||
|
|
||
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
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,23 @@ | ||
| use crate::{cli::CheckCommand, utils::SWAY_GIT_TAG}; | ||
| use anyhow::Result; | ||
| use forc_pkg::{self as pkg, ManifestFile}; | ||
| use std::path::PathBuf; | ||
|
|
||
| pub fn check(command: CheckCommand) -> Result<sway_core::CompileAstResult> { | ||
| let CheckCommand { | ||
| path, | ||
| offline_mode: offline, | ||
| silent_mode, | ||
| locked, | ||
| } = command; | ||
|
|
||
| let this_dir = if let Some(ref path) = path { | ||
| PathBuf::from(path) | ||
| } else { | ||
| std::env::current_dir()? | ||
| }; | ||
| let manifest = ManifestFile::from_dir(&this_dir, SWAY_GIT_TAG)?; | ||
| let plan = pkg::BuildPlan::load_from_manifest(&manifest, locked, offline, SWAY_GIT_TAG)?; | ||
|
|
||
| pkg::check(&plan, silent_mode, SWAY_GIT_TAG) | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.