1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
extern crate base64; #[macro_use] extern crate failure; extern crate composer; extern crate flate2; #[cfg(test)] extern crate fs_extra; extern crate futures; extern crate globset; extern crate hex; extern crate indicatif; extern crate nextcloud_appinfo; extern crate nextcloud_appsignature; extern crate nextcloud_appstore; extern crate npm_scripts; extern crate openssl; extern crate pathdiff; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate tar; #[cfg(test)] extern crate tempdir; extern crate tokio_core; extern crate toml; extern crate walkdir; extern crate xdg; pub mod commands; pub mod config; mod console; pub mod error; pub mod occ; pub mod packaging; use std::env; use std::path::{Path, PathBuf}; use failure::Error; use nextcloud_appinfo::get_appinfo; pub use nextcloud_appstore::{get_apps_and_releases, get_categories}; use occ::Occ; use tokio_core::reactor::Handle; pub fn enable_app() -> Result<(), Error> { let app_path = Path::new(".").canonicalize()?; let info = get_appinfo(&app_path)?; let occ = Occ::new("../../occ"); occ.enable_app(info.id()) } pub fn disable_app() -> Result<(), Error> { let app_path = Path::new(".").canonicalize()?; let info = get_appinfo(&app_path)?; let occ = Occ::new("../../occ"); occ.disable_app(info.id()) } fn get_home_dir() -> Result<PathBuf, Error> { env::home_dir().ok_or(format_err!("Could not resolve home dir",)) } fn get_private_key_path(app_id: &String) -> Result<PathBuf, Error> { let mut key_path = get_home_dir()?; key_path.push(".nextcloud"); key_path.push("certificates"); key_path.push(app_id.to_string() + ".key"); Ok(key_path) } fn get_package_path(app_id: &String) -> Result<PathBuf, Error> { let mut path = PathBuf::from(".").canonicalize()?; path.push("build"); path.push("artifacts"); path.push(app_id.to_string() + ".tar.gz"); Ok(path) } pub fn sign_package() -> Result<String, Error> { let app_path = Path::new(".").canonicalize()?; let appinfo = get_appinfo(&app_path)?; let app_id = appinfo.id(); let key_path = get_private_key_path(app_id)?; let package_path = get_package_path(app_id)?; if !package_path.exists() { bail!("No package found"); } let signature = nextcloud_appsignature::sign_package(&key_path, &package_path)?; Ok(signature) } pub fn publish_app( handle: &Handle, url: &String, is_nightly: bool, signature: &String, api_token: &String, ) -> Box<futures::Future<Item = (), Error = Error>> { Box::new(nextcloud_appstore::publish_app( handle, url, is_nightly, signature, api_token, )) }