mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 14:29:45 +00:00
bump sdk version
This commit is contained in:
@@ -4,8 +4,10 @@ use std::str::FromStr;
|
|||||||
|
|
||||||
use clap::builder::ValueParserFactory;
|
use clap::builder::ValueParserFactory;
|
||||||
use exver::VersionRange;
|
use exver::VersionRange;
|
||||||
|
use imbl::OrdMap;
|
||||||
|
use imbl_value::InternedString;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use models::{HealthCheckId, PackageId, VolumeId};
|
use models::{HealthCheckId, PackageId, VersionString, VolumeId};
|
||||||
use patch_db::json_ptr::JsonPointer;
|
use patch_db::json_ptr::JsonPointer;
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
|
|
||||||
@@ -316,12 +318,16 @@ pub struct CheckDependenciesParam {
|
|||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
pub struct CheckDependenciesResult {
|
pub struct CheckDependenciesResult {
|
||||||
package_id: PackageId,
|
package_id: PackageId,
|
||||||
is_installed: bool,
|
#[ts(type = "string | null")]
|
||||||
|
title: Option<InternedString>,
|
||||||
|
#[ts(type = "string | null")]
|
||||||
|
installed_version: Option<exver::ExtendedVersion>,
|
||||||
|
#[ts(type = "string[]")]
|
||||||
|
satisfies: BTreeSet<VersionString>,
|
||||||
is_running: bool,
|
is_running: bool,
|
||||||
config_satisfied: bool,
|
config_satisfied: bool,
|
||||||
health_checks: BTreeMap<HealthCheckId, NamedHealthCheckResult>,
|
#[ts(as = "BTreeMap::<HealthCheckId, NamedHealthCheckResult>")]
|
||||||
#[ts(type = "string | null")]
|
health_checks: OrdMap<HealthCheckId, NamedHealthCheckResult>,
|
||||||
version: Option<exver::ExtendedVersion>,
|
|
||||||
}
|
}
|
||||||
pub async fn check_dependencies(
|
pub async fn check_dependencies(
|
||||||
context: EffectContext,
|
context: EffectContext,
|
||||||
@@ -347,36 +353,23 @@ pub async fn check_dependencies(
|
|||||||
let mut results = Vec::with_capacity(package_ids.len());
|
let mut results = Vec::with_capacity(package_ids.len());
|
||||||
|
|
||||||
for (package_id, dependency_info) in package_ids {
|
for (package_id, dependency_info) in package_ids {
|
||||||
|
let title = dependency_info.title.clone();
|
||||||
let Some(package) = db.as_public().as_package_data().as_idx(&package_id) else {
|
let Some(package) = db.as_public().as_package_data().as_idx(&package_id) else {
|
||||||
results.push(CheckDependenciesResult {
|
results.push(CheckDependenciesResult {
|
||||||
package_id,
|
package_id,
|
||||||
is_installed: false,
|
title,
|
||||||
|
installed_version: None,
|
||||||
|
satisfies: BTreeSet::new(),
|
||||||
is_running: false,
|
is_running: false,
|
||||||
config_satisfied: false,
|
config_satisfied: false,
|
||||||
health_checks: Default::default(),
|
health_checks: Default::default(),
|
||||||
version: None,
|
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let manifest = package.as_state_info().as_manifest(ManifestPreference::New);
|
let manifest = package.as_state_info().as_manifest(ManifestPreference::New);
|
||||||
let installed_version = manifest.as_version().de()?.into_version();
|
let installed_version = manifest.as_version().de()?.into_version();
|
||||||
let satisfies = manifest.as_satisfies().de()?;
|
let satisfies = manifest.as_satisfies().de()?;
|
||||||
let version = Some(installed_version.clone());
|
let installed_version = Some(installed_version.clone());
|
||||||
if ![installed_version]
|
|
||||||
.into_iter()
|
|
||||||
.chain(satisfies.into_iter().map(|v| v.into_version()))
|
|
||||||
.any(|v| v.satisfies(&dependency_info.version_range))
|
|
||||||
{
|
|
||||||
results.push(CheckDependenciesResult {
|
|
||||||
package_id,
|
|
||||||
is_installed: false,
|
|
||||||
is_running: false,
|
|
||||||
config_satisfied: false,
|
|
||||||
health_checks: Default::default(),
|
|
||||||
version,
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
let is_installed = true;
|
let is_installed = true;
|
||||||
let status = package.as_status().as_main().de()?;
|
let status = package.as_status().as_main().de()?;
|
||||||
let is_running = if is_installed {
|
let is_running = if is_installed {
|
||||||
@@ -384,25 +377,15 @@ pub async fn check_dependencies(
|
|||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
let health_checks =
|
let health_checks = status.health().cloned().unwrap_or_default();
|
||||||
if let CurrentDependencyKind::Running { health_checks } = &dependency_info.kind {
|
|
||||||
status
|
|
||||||
.health()
|
|
||||||
.cloned()
|
|
||||||
.unwrap_or_default()
|
|
||||||
.into_iter()
|
|
||||||
.filter(|(id, _)| health_checks.contains(id))
|
|
||||||
.collect()
|
|
||||||
} else {
|
|
||||||
Default::default()
|
|
||||||
};
|
|
||||||
results.push(CheckDependenciesResult {
|
results.push(CheckDependenciesResult {
|
||||||
package_id,
|
package_id,
|
||||||
is_installed,
|
title,
|
||||||
|
installed_version,
|
||||||
|
satisfies,
|
||||||
is_running,
|
is_running,
|
||||||
config_satisfied: dependency_info.config_satisfied,
|
config_satisfied: dependency_info.config_satisfied,
|
||||||
health_checks,
|
health_checks,
|
||||||
version,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Ok(results)
|
Ok(results)
|
||||||
|
|||||||
4
sdk/package-lock.json
generated
4
sdk/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@start9labs/start-sdk",
|
"name": "@start9labs/start-sdk",
|
||||||
"version": "0.3.6-alpha5",
|
"version": "0.3.6-alpha7",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@start9labs/start-sdk",
|
"name": "@start9labs/start-sdk",
|
||||||
"version": "0.3.6-alpha5",
|
"version": "0.3.6-alpha7",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@iarna/toml": "^2.2.5",
|
"@iarna/toml": "^2.2.5",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@start9labs/start-sdk",
|
"name": "@start9labs/start-sdk",
|
||||||
"version": "0.3.6-alpha6",
|
"version": "0.3.6-alpha7",
|
||||||
"description": "Software development kit to facilitate packaging services for StartOS",
|
"description": "Software development kit to facilitate packaging services for StartOS",
|
||||||
"main": "./cjs/lib/index.js",
|
"main": "./cjs/lib/index.js",
|
||||||
"types": "./cjs/lib/index.d.ts",
|
"types": "./cjs/lib/index.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user