Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename [package] to [component] in manifest file #214

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/cli/src/commands/components/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ pub async fn run(_opts: Options) -> anyhow::Result<()> {
};
let manifest = Manifest::load(&manifest_path).map_err(|err| anyhow::anyhow!(err))?;

tracing::info!("Running: {}", manifest.package.build.command);
tracing::info!("Running: {}", manifest.component.build.command);
let mut cmd = Command::new("sh");
cmd.arg("-c").arg(manifest.package.build.command);
cmd.arg("-c").arg(manifest.component.build.command);
let status = cmd.status()?;

if status.success() {
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/commands/components/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub async fn run(_opts: Options) -> anyhow::Result<()> {

let manifest = Manifest::load(&manifest_path)?;
let component_path = manifest
.package
.component
.build
.output_path
.to_str()
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/commands/components/init.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::components::{
boilerplate::{CATEGORY_OPTIONS, LANGUAGE_OPTIONS, SUBCATEGORY_OPTIONS},
manifest::{self, Build, Manifest, Package},
manifest::{self, Build, Component, Manifest},
};

#[derive(Debug, clap::Parser)]
Expand Down Expand Up @@ -48,7 +48,7 @@ pub async fn run(_opts: Options) -> anyhow::Result<()> {

Manifest {
manifest_version: manifest::MANIFEST_VERSION,
package: Package {
component: Component {
name: component_name,
version: "0.1.0".to_string(),
wit_world_version: "0.4.0".to_string(),
Expand Down
24 changes: 12 additions & 12 deletions crates/cli/src/commands/components/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub async fn run(opts: Options) -> anyhow::Result<()> {
.api_context("Could not get user organization")?
.into_inner(),
};
let component_slug = slug::slugify(&manifest.package.name);
let component_slug = slug::slugify(&manifest.component.name);
match client
.get_component_by_slug()
.org_slug(&organization.slug)
Expand Down Expand Up @@ -75,21 +75,21 @@ pub async fn run(opts: Options) -> anyhow::Result<()> {
.body(
api_types::ComponentCreateInput::builder()
.organization_id(organization.id.clone())
.name(&manifest.package.name)
.name(&manifest.component.name)
.slug(component_slug.clone())
.description(manifest.package.description.clone())
.category(manifest.package.category)
.subcategory(manifest.package.subcategory)
.description(manifest.component.description.clone())
.category(manifest.component.category)
.subcategory(manifest.component.subcategory)
.documentation_link(
manifest
.package
.component
.documentation
.as_ref()
.map(|url| url.to_string()),
)
.repo_link(
manifest
.package
.component
.repository
.as_ref()
.map(|url| url.to_string()),
Expand Down Expand Up @@ -123,7 +123,7 @@ pub async fn run(opts: Options) -> anyhow::Result<()> {

tracing::info!("Uploading WASM file...");
let asset_url = client
.upload_file(&manifest.package.build.output_path)
.upload_file(&manifest.component.build.output_path)
.await
.expect("Could not upload component");

Expand All @@ -134,8 +134,8 @@ pub async fn run(opts: Options) -> anyhow::Result<()> {
.component_slug(&component_slug)
.body(
api_types::ComponentVersionCreateInput::builder()
.version(&manifest.package.version)
.wit_world_version(&manifest.package.wit_world_version)
.version(&manifest.component.version)
.wit_world_version(&manifest.component.wit_world_version)
.wasm_url(asset_url)
.dynamic_fields(convert_manifest_config_fields(&manifest))
.changelog(changelog),
Expand All @@ -147,15 +147,15 @@ pub async fn run(opts: Options) -> anyhow::Result<()> {
tracing::info!(
"{} {} pushed successfully!",
component_slug,
manifest.package.version
manifest.component.version,
);

Ok(())
}

fn convert_manifest_config_fields(manifest: &Manifest) -> Vec<api_types::ConfigurationField> {
manifest
.package
.component
.settings
.iter()
.map(|(name, field)| api_types::ConfigurationField {
Expand Down
6 changes: 3 additions & 3 deletions crates/cli/src/commands/components/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async fn test_data_collection_component(opts: Options) -> anyhow::Result<()> {

let manifest = Manifest::load(&manifest_path)?;
let component_path = manifest
.package
.component
.build
.output_path
.into_os_string()
Expand Down Expand Up @@ -89,14 +89,14 @@ async fn test_data_collection_component(opts: Options) -> anyhow::Result<()> {
}

// check that all required settings are provided
for (name, setting) in &manifest.package.settings {
for (name, setting) in &manifest.component.settings {
if setting.required && !settings_map.contains_key(name) {
return Err(anyhow::anyhow!("missing required setting {}", name));
}
}

for name in settings_map.keys() {
if !manifest.package.settings.contains_key(name) {
if !manifest.component.settings.contains_key(name) {
return Err(anyhow::anyhow!("unknown setting {}", name));
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/components/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ pub const MANIFEST_FILENAME: &str = "edgee-component.toml";
#[serde(rename_all = "kebab-case")]
pub struct Manifest {
pub manifest_version: u8,
pub package: Package,
pub component: Component,
}

#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub struct Package {
pub struct Component {
pub name: String,
pub version: String,
#[serde(with = "Category")]
Expand Down