validate that a package being published doesn't conflict with keywords

This commit is contained in:
gluax 2021-07-01 13:59:56 -07:00
parent bcb50ae27f
commit a0d9047faf
5 changed files with 12 additions and 0 deletions

1
Cargo.lock generated
View File

@ -1222,6 +1222,7 @@ dependencies = [
"leo-imports",
"leo-input",
"leo-package",
"leo-parser",
"leo-state",
"leo-synthesizer",
"notify",

View File

@ -61,6 +61,10 @@ version = "1.5.2"
path = "./package"
version = "1.5.2"
[dependencies.leo-parser]
path = "./parser"
version = "1.5.2"
[dependencies.leo-state]
path = "./state"
version = "1.5.2"

View File

@ -20,6 +20,7 @@ use leo_package::{
outputs::OutputsDirectory,
root::{ZipFile, AUTHOR_PLACEHOLDER},
};
use leo_parser::KEYWORD_TOKENS;
use anyhow::{anyhow, Result};
use structopt::StructOpt;
@ -47,6 +48,10 @@ impl Command for Publish {
let manifest = context.manifest()?;
let package_name = manifest.get_package_name();
if KEYWORD_TOKENS.iter().any(|keyword| keyword.to_string() == package_name) {
return Err(anyhow!("Cannot name a package after a keyword"));
}
let package_version = manifest.get_package_version();
match (

View File

@ -25,6 +25,7 @@
extern crate thiserror;
pub(crate) mod tokenizer;
pub use tokenizer::KEYWORD_TOKENS;
pub(crate) use tokenizer::*;
pub mod errors;

View File

@ -22,6 +22,7 @@
pub(crate) mod token;
use std::sync::Arc;
pub use self::token::KEYWORD_TOKENS;
pub(crate) use self::token::*;
pub(crate) mod lexer;