676: [CLI, PM] Inputs are now published with source code r=collinc97 a=damirka

Fixes #637 

- now inputs are published to Aleo PM
- error json message is printed to user

## Motivation

We're unable to publish packages to PM, this PR fixes that.

## Test Plan

TBD: CI for publishing

Co-authored-by: damirka <damirka.ru@gmail.com>
This commit is contained in:
bors[bot] 2021-02-18 06:07:11 +00:00 committed by GitHub
commit 077d0f76f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 13 deletions

View File

@ -119,14 +119,17 @@ impl Command for Publish {
.send();
// Get a response result
let result = match response {
Ok(json_result) => match json_result.json::<ResponseJson>() {
let result: ResponseJson = match response {
Ok(json_result) => {
let text = json_result.text()?;
match serde_json::from_str(&text) {
Ok(json) => json,
Err(error) => {
tracing::warn!("{:?}", error);
return Err(anyhow!("Package not published"));
Err(_) => {
return Err(anyhow!("Package not published: {}", text));
}
}
}
},
Err(error) => {
tracing::warn!("{:?}", error);
return Err(anyhow!("Connection unavailable"));

View File

@ -19,7 +19,7 @@
use crate::{
errors::ZipFileError,
imports::IMPORTS_DIRECTORY_NAME,
inputs::{INPUTS_DIRECTORY_NAME, INPUT_FILE_EXTENSION},
inputs::{INPUTS_DIRECTORY_NAME, INPUT_FILE_EXTENSION, STATE_FILE_EXTENSION},
outputs::{
CHECKSUM_FILE_EXTENSION,
CIRCUIT_FILE_EXTENSION,
@ -151,9 +151,8 @@ impl ZipFile {
/// Check if the file path should be included in the package zip file.
fn is_included(path: &Path) -> bool {
// excluded directories: `input`, `output`, `imports`
if path.ends_with(INPUTS_DIRECTORY_NAME.trim_end_matches('/'))
| path.ends_with(OUTPUTS_DIRECTORY_NAME.trim_end_matches('/'))
// excluded directories: `output`, `imports`
if path.ends_with(OUTPUTS_DIRECTORY_NAME.trim_end_matches('/'))
| path.ends_with(IMPORTS_DIRECTORY_NAME.trim_end_matches('/'))
{
return false;
@ -161,8 +160,7 @@ fn is_included(path: &Path) -> bool {
// excluded extensions: `.in`, `.bytes`, `lpk`, `lvk`, `.proof`, `.sum`, `.zip`, `.bytes`
if let Some(true) = path.extension().map(|ext| {
ext.eq(INPUT_FILE_EXTENSION.trim_start_matches('.'))
| ext.eq(ZIP_FILE_EXTENSION.trim_start_matches('.'))
ext.eq(ZIP_FILE_EXTENSION.trim_start_matches('.'))
| ext.eq(PROVING_KEY_FILE_EXTENSION.trim_start_matches('.'))
| ext.eq(VERIFICATION_KEY_FILE_EXTENSION.trim_start_matches('.'))
| ext.eq(PROOF_FILE_EXTENSION.trim_start_matches('.'))
@ -173,6 +171,18 @@ fn is_included(path: &Path) -> bool {
return false;
}
// Allow `inputs` folder
if path.ends_with(INPUTS_DIRECTORY_NAME.trim_end_matches('/')) {
return true;
}
// Allow `.state` and `.in` files
if let Some(true) = path.extension().map(|ext| {
ext.eq(INPUT_FILE_EXTENSION.trim_start_matches('.')) | ext.eq(STATE_FILE_EXTENSION.trim_start_matches('.'))
}) {
return true;
}
// Allow the README.md and Leo.toml files in the root directory
if (path.ends_with(README_FILENAME) | path.ends_with(MANIFEST_FILENAME)) & (path.parent() == Some(Path::new(""))) {
return true;