Skip to content

Commit

Permalink
Bump amp-common and amp-client version, optimize amp dev command
Browse files Browse the repository at this point in the history
  • Loading branch information
wangeguo committed Oct 11, 2023
1 parent 8a72a27 commit fe0d626
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 31 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "amp"
description = "Amphitheatre's official command line tool"
version = "0.2.27"
version = "0.2.28"
edition = "2021"
license = "Apache-2.0"
homepage = "https://amphitheatre.app"
Expand All @@ -11,8 +11,8 @@ readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
amp-client = { git = "https://github.com/amphitheatre-app/amp-client-rust", tag = "v0.3.2" }
amp-common = { git = "https://github.com/amphitheatre-app/common", tag = "v0.5.1" }
amp-client = { git = "https://github.com/amphitheatre-app/amp-client-rust", tag = "v0.3.3" }
amp-common = { git = "https://github.com/amphitheatre-app/common", tag = "v0.5.2" }
anyhow = "1.0.75"
clap = { version = "4.4.6", features = ["derive", "env"] }
clap-verbosity-flag = "2.0.1"
Expand Down
8 changes: 5 additions & 3 deletions src/ops/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ pub async fn dev(ctx: Arc<Context>) -> Result<()> {
let workspace = path.parent().unwrap();
let manifest = utils::read_manifest(&path)?;

let mut character = CharacterSpec::from(manifest.clone());
character.live = true;

let payload = PlaybookPayload {
title: "Untitled".to_string(),
description: "".to_string(),
preface: Preface::manifest(&CharacterSpec::from(manifest.clone())),
live: true,
preface: Preface::manifest(&character),
};
debug!("{:#?}", payload);

Expand All @@ -55,7 +57,7 @@ pub async fn dev(ctx: Arc<Context>) -> Result<()> {
info!("The playbook was created and deployed successfully!");
debug!("{:#?}", playbook);

// Continuous Synchornize file changes.
// Continuous Synchronize file changes.
// first time, we need to sync all files.
// and then, we need to sync only changed files.
let actors = client.actors();
Expand Down
26 changes: 6 additions & 20 deletions src/ops/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::path::Path;
use std::sync::Arc;

use amp_client::client::Client;
Expand All @@ -31,10 +32,11 @@ pub async fn run(ctx: Arc<Context>, options: &crate::cmd::run::Cli) -> Result<()
payload = create_playbook_from_git(repository)?;
} else if let Some(name) = &options.name {
payload = create_playbook_from_cluster(name)?;
} else if let Some(filename) = &options.filename {
payload = create_playbook_from_manifest(filename)?;
} else if let Some(path) = &options.filename {
payload = create_playbook_from_manifest(path)?;
} else {
payload = create_playbook_from_localy()?;
let path = Finder::new().find().map_err(Errors::NotFoundManifest)?;
payload = create_playbook_from_manifest(path)?;
}
debug!("{:#?}", payload);

Expand All @@ -57,7 +59,6 @@ fn create_playbook_from_cluster(name: &str) -> Result<PlaybookPayload> {
title: "Untitled".to_string(),
description: "".to_string(),
preface: Preface::registry(name, "hub", "latest"),
live: false,
})
}

Expand All @@ -67,31 +68,16 @@ fn create_playbook_from_git(repository: &str) -> Result<PlaybookPayload> {
title: "Untitled".to_string(),
description: "".to_string(),
preface: Preface::repository(repository),
live: false,
})
}

/// Create playbook from manifest file
fn create_playbook_from_manifest(filename: &str) -> Result<PlaybookPayload> {
let manifest = utils::read_manifest(filename)?;

Ok(PlaybookPayload {
title: "Untitled".to_string(),
description: "".to_string(),
preface: Preface::manifest(&CharacterSpec::from(manifest)),
live: false,
})
}

/// Create playbook from localy
fn create_playbook_from_localy() -> Result<PlaybookPayload> {
let path = Finder::new().find().map_err(Errors::NotFoundManifest)?;
fn create_playbook_from_manifest<P: AsRef<Path>>(path: P) -> Result<PlaybookPayload> {
let manifest = utils::read_manifest(path)?;

Ok(PlaybookPayload {
title: "Untitled".to_string(),
description: "".to_string(),
preface: Preface::manifest(&CharacterSpec::from(manifest)),
live: false,
})
}

0 comments on commit fe0d626

Please sign in to comment.