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-imports",
"leo-input", "leo-input",
"leo-package", "leo-package",
"leo-parser",
"leo-state", "leo-state",
"leo-synthesizer", "leo-synthesizer",
"notify", "notify",

View File

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

View File

@ -20,6 +20,7 @@ use leo_package::{
outputs::OutputsDirectory, outputs::OutputsDirectory,
root::{ZipFile, AUTHOR_PLACEHOLDER}, root::{ZipFile, AUTHOR_PLACEHOLDER},
}; };
use leo_parser::KEYWORD_TOKENS;
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use structopt::StructOpt; use structopt::StructOpt;
@ -47,6 +48,10 @@ impl Command for Publish {
let manifest = context.manifest()?; let manifest = context.manifest()?;
let package_name = manifest.get_package_name(); 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(); let package_version = manifest.get_package_version();
match ( match (

View File

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

View File

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