-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip * moving back to PC computer * adding check function to forc pkg * have ast returning from forc pkg * can now successfully parse all sway examples * fmt * added forc check * tidy up lsp tests * add forc check command * forc ops doesnt need to be public * tidy up lsp tests * remove non relevant code * rebase on master * add Cargo.lock file * add forc check to mdbook
- Loading branch information
1 parent
44a16af
commit bdfb744
Showing
14 changed files
with
231 additions
and
125 deletions.
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 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 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 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 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 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 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 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 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 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 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.