mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
Compare commits
5 Commits
fix/dry-ru
...
feat/resta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f4e391181 | ||
|
|
d29ff6df2c | ||
|
|
b01e5d9f09 | ||
|
|
104567e457 | ||
|
|
591e3bec1a |
@@ -615,7 +615,6 @@ fn check_matching_info_short() {
|
|||||||
sdk_version: None,
|
sdk_version: None,
|
||||||
hardware_acceleration: false,
|
hardware_acceleration: false,
|
||||||
plugins: BTreeSet::new(),
|
plugins: BTreeSet::new(),
|
||||||
satisfies: BTreeSet::new(),
|
|
||||||
},
|
},
|
||||||
icon: DataUrl::from_vec("image/png", vec![]),
|
icon: DataUrl::from_vec("image/png", vec![]),
|
||||||
dependency_metadata: BTreeMap::new(),
|
dependency_metadata: BTreeMap::new(),
|
||||||
|
|||||||
@@ -110,8 +110,6 @@ pub struct PackageMetadata {
|
|||||||
pub hardware_acceleration: bool,
|
pub hardware_acceleration: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub plugins: BTreeSet<PluginId>,
|
pub plugins: BTreeSet<PluginId>,
|
||||||
#[serde(default)]
|
|
||||||
pub satisfies: BTreeSet<VersionString>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, HasModel, TS)]
|
#[derive(Debug, Deserialize, Serialize, HasModel, TS)]
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ impl TryFrom<ManifestV1> for Manifest {
|
|||||||
Ok(Self {
|
Ok(Self {
|
||||||
id: value.id,
|
id: value.id,
|
||||||
version: version.into(),
|
version: version.into(),
|
||||||
|
satisfies: BTreeSet::new(),
|
||||||
can_migrate_from: VersionRange::any(),
|
can_migrate_from: VersionRange::any(),
|
||||||
can_migrate_to: VersionRange::none(),
|
can_migrate_to: VersionRange::none(),
|
||||||
metadata: PackageMetadata {
|
metadata: PackageMetadata {
|
||||||
@@ -218,7 +219,6 @@ impl TryFrom<ManifestV1> for Manifest {
|
|||||||
PackageProcedure::Script(_) => false,
|
PackageProcedure::Script(_) => false,
|
||||||
},
|
},
|
||||||
plugins: BTreeSet::new(),
|
plugins: BTreeSet::new(),
|
||||||
satisfies: BTreeSet::new(),
|
|
||||||
},
|
},
|
||||||
images: BTreeMap::new(),
|
images: BTreeMap::new(),
|
||||||
volumes: value
|
volumes: value
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ pub(crate) fn current_version() -> Version {
|
|||||||
pub struct Manifest {
|
pub struct Manifest {
|
||||||
pub id: PackageId,
|
pub id: PackageId,
|
||||||
pub version: VersionString,
|
pub version: VersionString,
|
||||||
|
pub satisfies: BTreeSet<VersionString>,
|
||||||
#[ts(type = "string")]
|
#[ts(type = "string")]
|
||||||
pub can_migrate_to: VersionRange,
|
pub can_migrate_to: VersionRange,
|
||||||
#[ts(type = "string")]
|
#[ts(type = "string")]
|
||||||
|
|||||||
@@ -358,7 +358,7 @@ pub async fn check_dependencies(
|
|||||||
};
|
};
|
||||||
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_metadata().as_satisfies().de()?;
|
let satisfies = manifest.as_satisfies().de()?;
|
||||||
let installed_version = Some(installed_version.clone().into());
|
let installed_version = Some(installed_version.clone().into());
|
||||||
let is_running = package
|
let is_running = package
|
||||||
.as_status_info()
|
.as_status_info()
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import type { VolumeId } from './VolumeId'
|
|||||||
export type Manifest = {
|
export type Manifest = {
|
||||||
id: PackageId
|
id: PackageId
|
||||||
version: Version
|
version: Version
|
||||||
|
satisfies: Array<Version>
|
||||||
canMigrateTo: string
|
canMigrateTo: string
|
||||||
canMigrateFrom: string
|
canMigrateFrom: string
|
||||||
images: { [key: ImageId]: ImageConfig }
|
images: { [key: ImageId]: ImageConfig }
|
||||||
@@ -36,5 +37,4 @@ export type Manifest = {
|
|||||||
sdkVersion: string | null
|
sdkVersion: string | null
|
||||||
hardwareAcceleration: boolean
|
hardwareAcceleration: boolean
|
||||||
plugins: Array<PluginId>
|
plugins: Array<PluginId>
|
||||||
satisfies: Array<Version>
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import type { MerkleArchiveCommitment } from './MerkleArchiveCommitment'
|
|||||||
import type { PackageId } from './PackageId'
|
import type { PackageId } from './PackageId'
|
||||||
import type { PluginId } from './PluginId'
|
import type { PluginId } from './PluginId'
|
||||||
import type { RegistryAsset } from './RegistryAsset'
|
import type { RegistryAsset } from './RegistryAsset'
|
||||||
import type { Version } from './Version'
|
|
||||||
|
|
||||||
export type PackageVersionInfo = {
|
export type PackageVersionInfo = {
|
||||||
icon: DataUrl
|
icon: DataUrl
|
||||||
@@ -32,5 +31,4 @@ export type PackageVersionInfo = {
|
|||||||
sdkVersion: string | null
|
sdkVersion: string | null
|
||||||
hardwareAcceleration: boolean
|
hardwareAcceleration: boolean
|
||||||
plugins: Array<PluginId>
|
plugins: Array<PluginId>
|
||||||
satisfies: Array<Version>
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import { hasCurrentDeps } from 'src/app/utils/has-deps'
|
|||||||
|
|
||||||
import { MarketplaceAlertsService } from '../services/alerts.service'
|
import { MarketplaceAlertsService } from '../services/alerts.service'
|
||||||
|
|
||||||
type KEYS = 'id' | 'version' | 'alerts' | 'flavor' | 'satisfies'
|
type KEYS = 'id' | 'version' | 'alerts' | 'flavor'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'marketplace-controls',
|
selector: 'marketplace-controls',
|
||||||
@@ -185,13 +185,9 @@ export class MarketplaceControlsComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async dryInstall(url: string | null) {
|
private async dryInstall(url: string | null) {
|
||||||
const { id, version, satisfies } = this.pkg()
|
const { id, version } = this.pkg()
|
||||||
const packages = await getAllPackages(this.patch)
|
const packages = await getAllPackages(this.patch)
|
||||||
const breakages = dryUpdate(
|
const breakages = dryUpdate({ id, version }, packages, this.exver)
|
||||||
{ id, version, satisfies: satisfies || [] },
|
|
||||||
packages,
|
|
||||||
this.exver,
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!breakages.length || (await this.alerts.alertBreakages(breakages))) {
|
if (!breakages.length || (await this.alerts.alertBreakages(breakages))) {
|
||||||
this.installOrUpload(url)
|
this.installOrUpload(url)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
TuiNotification,
|
TuiNotification,
|
||||||
} from '@taiga-ui/core'
|
} from '@taiga-ui/core'
|
||||||
import { injectContext } from '@taiga-ui/polymorpheus'
|
import { injectContext } from '@taiga-ui/polymorpheus'
|
||||||
|
import * as json from 'fast-json-patch'
|
||||||
import { compare } from 'fast-json-patch'
|
import { compare } from 'fast-json-patch'
|
||||||
import { PatchDB } from 'patch-db-client'
|
import { PatchDB } from 'patch-db-client'
|
||||||
import { catchError, EMPTY, endWith, firstValueFrom, from, map } from 'rxjs'
|
import { catchError, EMPTY, endWith, firstValueFrom, from, map } from 'rxjs'
|
||||||
@@ -190,7 +191,9 @@ export class ActionInputModal {
|
|||||||
task.actionId === this.actionId &&
|
task.actionId === this.actionId &&
|
||||||
task.when?.condition === 'input-not-matches' &&
|
task.when?.condition === 'input-not-matches' &&
|
||||||
task.input &&
|
task.input &&
|
||||||
conflicts(task.input.value, input),
|
json
|
||||||
|
.compare(input, task.input.value)
|
||||||
|
.some(op => op.op === 'add' || op.op === 'replace'),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.map(id => id)
|
.map(id => id)
|
||||||
@@ -211,26 +214,3 @@ export class ActionInputModal {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mirrors the Rust backend's `conflicts()` function in core/src/service/action.rs.
|
|
||||||
// A key in the partial that is missing from the full input is NOT a conflict.
|
|
||||||
function conflicts(left: unknown, right: unknown): boolean {
|
|
||||||
if (
|
|
||||||
typeof left === 'object' &&
|
|
||||||
left !== null &&
|
|
||||||
!Array.isArray(left) &&
|
|
||||||
typeof right === 'object' &&
|
|
||||||
right !== null &&
|
|
||||||
!Array.isArray(right)
|
|
||||||
) {
|
|
||||||
const l = left as Record<string, unknown>
|
|
||||||
const r = right as Record<string, unknown>
|
|
||||||
return Object.keys(l).some(k => (k in r ? conflicts(l[k], r[k]) : false))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(left) && Array.isArray(right)) {
|
|
||||||
return left.some(v => right.every(vr => conflicts(v, vr)))
|
|
||||||
}
|
|
||||||
|
|
||||||
return left !== right
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -459,7 +459,6 @@ export namespace Mock {
|
|||||||
gitHash: 'fakehash',
|
gitHash: 'fakehash',
|
||||||
icon: BTC_ICON,
|
icon: BTC_ICON,
|
||||||
sourceVersion: null,
|
sourceVersion: null,
|
||||||
satisfies: [],
|
|
||||||
dependencyMetadata: {},
|
dependencyMetadata: {},
|
||||||
donationUrl: null,
|
donationUrl: null,
|
||||||
alerts: {
|
alerts: {
|
||||||
@@ -502,7 +501,6 @@ export namespace Mock {
|
|||||||
gitHash: 'fakehash',
|
gitHash: 'fakehash',
|
||||||
icon: BTC_ICON,
|
icon: BTC_ICON,
|
||||||
sourceVersion: null,
|
sourceVersion: null,
|
||||||
satisfies: [],
|
|
||||||
dependencyMetadata: {},
|
dependencyMetadata: {},
|
||||||
donationUrl: null,
|
donationUrl: null,
|
||||||
alerts: {
|
alerts: {
|
||||||
@@ -555,7 +553,6 @@ export namespace Mock {
|
|||||||
gitHash: 'fakehash',
|
gitHash: 'fakehash',
|
||||||
icon: BTC_ICON,
|
icon: BTC_ICON,
|
||||||
sourceVersion: null,
|
sourceVersion: null,
|
||||||
satisfies: [],
|
|
||||||
dependencyMetadata: {},
|
dependencyMetadata: {},
|
||||||
donationUrl: null,
|
donationUrl: null,
|
||||||
alerts: {
|
alerts: {
|
||||||
@@ -598,7 +595,6 @@ export namespace Mock {
|
|||||||
gitHash: 'fakehash',
|
gitHash: 'fakehash',
|
||||||
icon: BTC_ICON,
|
icon: BTC_ICON,
|
||||||
sourceVersion: null,
|
sourceVersion: null,
|
||||||
satisfies: [],
|
|
||||||
dependencyMetadata: {},
|
dependencyMetadata: {},
|
||||||
donationUrl: null,
|
donationUrl: null,
|
||||||
alerts: {
|
alerts: {
|
||||||
@@ -653,7 +649,6 @@ export namespace Mock {
|
|||||||
gitHash: 'fakehash',
|
gitHash: 'fakehash',
|
||||||
icon: LND_ICON,
|
icon: LND_ICON,
|
||||||
sourceVersion: null,
|
sourceVersion: null,
|
||||||
satisfies: [],
|
|
||||||
dependencyMetadata: {
|
dependencyMetadata: {
|
||||||
bitcoind: BitcoinDep,
|
bitcoind: BitcoinDep,
|
||||||
'btc-rpc-proxy': ProxyDep,
|
'btc-rpc-proxy': ProxyDep,
|
||||||
@@ -709,7 +704,6 @@ export namespace Mock {
|
|||||||
gitHash: 'fakehash',
|
gitHash: 'fakehash',
|
||||||
icon: LND_ICON,
|
icon: LND_ICON,
|
||||||
sourceVersion: null,
|
sourceVersion: null,
|
||||||
satisfies: [],
|
|
||||||
dependencyMetadata: {
|
dependencyMetadata: {
|
||||||
bitcoind: BitcoinDep,
|
bitcoind: BitcoinDep,
|
||||||
'btc-rpc-proxy': ProxyDep,
|
'btc-rpc-proxy': ProxyDep,
|
||||||
@@ -769,7 +763,6 @@ export namespace Mock {
|
|||||||
gitHash: 'fakehash',
|
gitHash: 'fakehash',
|
||||||
icon: BTC_ICON,
|
icon: BTC_ICON,
|
||||||
sourceVersion: null,
|
sourceVersion: null,
|
||||||
satisfies: [],
|
|
||||||
dependencyMetadata: {},
|
dependencyMetadata: {},
|
||||||
donationUrl: null,
|
donationUrl: null,
|
||||||
alerts: {
|
alerts: {
|
||||||
@@ -812,7 +805,6 @@ export namespace Mock {
|
|||||||
gitHash: 'fakehash',
|
gitHash: 'fakehash',
|
||||||
icon: BTC_ICON,
|
icon: BTC_ICON,
|
||||||
sourceVersion: null,
|
sourceVersion: null,
|
||||||
satisfies: [],
|
|
||||||
dependencyMetadata: {},
|
dependencyMetadata: {},
|
||||||
donationUrl: null,
|
donationUrl: null,
|
||||||
alerts: {
|
alerts: {
|
||||||
@@ -865,7 +857,6 @@ export namespace Mock {
|
|||||||
gitHash: 'fakehash',
|
gitHash: 'fakehash',
|
||||||
icon: LND_ICON,
|
icon: LND_ICON,
|
||||||
sourceVersion: null,
|
sourceVersion: null,
|
||||||
satisfies: [],
|
|
||||||
dependencyMetadata: {
|
dependencyMetadata: {
|
||||||
bitcoind: BitcoinDep,
|
bitcoind: BitcoinDep,
|
||||||
'btc-rpc-proxy': ProxyDep,
|
'btc-rpc-proxy': ProxyDep,
|
||||||
@@ -921,7 +912,6 @@ export namespace Mock {
|
|||||||
gitHash: 'fakehash',
|
gitHash: 'fakehash',
|
||||||
icon: PROXY_ICON,
|
icon: PROXY_ICON,
|
||||||
sourceVersion: null,
|
sourceVersion: null,
|
||||||
satisfies: [],
|
|
||||||
dependencyMetadata: {
|
dependencyMetadata: {
|
||||||
bitcoind: BitcoinDep,
|
bitcoind: BitcoinDep,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,11 +3,7 @@ import { DataModel } from '../services/patch-db/data-model'
|
|||||||
import { getManifest } from './get-package-data'
|
import { getManifest } from './get-package-data'
|
||||||
|
|
||||||
export function dryUpdate(
|
export function dryUpdate(
|
||||||
{
|
{ id, version }: { id: string; version: string },
|
||||||
id,
|
|
||||||
version,
|
|
||||||
satisfies,
|
|
||||||
}: { id: string; version: string; satisfies: string[] },
|
|
||||||
pkgs: DataModel['packageData'],
|
pkgs: DataModel['packageData'],
|
||||||
exver: Exver,
|
exver: Exver,
|
||||||
): string[] {
|
): string[] {
|
||||||
@@ -17,24 +13,10 @@ export function dryUpdate(
|
|||||||
Object.keys(pkg.currentDependencies || {}).some(
|
Object.keys(pkg.currentDependencies || {}).some(
|
||||||
pkgId => pkgId === id,
|
pkgId => pkgId === id,
|
||||||
) &&
|
) &&
|
||||||
!versionSatisfies(
|
!exver.satisfies(
|
||||||
version,
|
version,
|
||||||
satisfies,
|
|
||||||
pkg.currentDependencies[id]?.versionRange || '',
|
pkg.currentDependencies[id]?.versionRange || '',
|
||||||
exver,
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.map(pkg => getManifest(pkg).title)
|
.map(pkg => getManifest(pkg).title)
|
||||||
}
|
}
|
||||||
|
|
||||||
function versionSatisfies(
|
|
||||||
version: string,
|
|
||||||
satisfies: string[],
|
|
||||||
range: string,
|
|
||||||
exver: Exver,
|
|
||||||
): boolean {
|
|
||||||
return (
|
|
||||||
exver.satisfies(version, range) ||
|
|
||||||
satisfies.some(v => exver.satisfies(v, range))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user