Initial public release of Warp.
Repo-Sync-Origin: warpdotdev/warp-internal@12af1d983b
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
use anyhow::Result;
|
||||
use channel_versions::{overrides, ChannelVersion, ChannelVersions};
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(about)]
|
||||
struct Args {
|
||||
/// Name of the operating system to parse the version for.
|
||||
#[arg(long, value_enum)]
|
||||
target_os: channel_versions::overrides::TargetOS,
|
||||
|
||||
/// The file containing a JSON-serialied [`ChannelVersions`] struct to
|
||||
/// apply overrides for.
|
||||
file: PathBuf,
|
||||
}
|
||||
|
||||
/// Reads in a JSON-serialized [`ChannelVersions`] from a file, applies any
|
||||
/// defined overrides that match a given target OS, and prints out the updated
|
||||
/// JSON (omitting changelogs).
|
||||
fn main() -> Result<()> {
|
||||
let args = Args::parse();
|
||||
|
||||
let contents = fs::read_to_string(&args.file)?;
|
||||
|
||||
// Deserialize the JSON data into the expected format.
|
||||
let versions: ChannelVersions = serde_json::from_str(contents.as_str())?;
|
||||
|
||||
let context = overrides::Context {
|
||||
target_os: Some(args.target_os),
|
||||
};
|
||||
|
||||
let dev_version_info = versions.dev.version_info_for_execution_context(&context);
|
||||
let preview_version_info = versions
|
||||
.preview
|
||||
.version_info_for_execution_context(&context);
|
||||
let stable_version_info = versions.stable.version_info_for_execution_context(&context);
|
||||
|
||||
let transformed_versions = ChannelVersions {
|
||||
dev: ChannelVersion::new(dev_version_info),
|
||||
preview: ChannelVersion::new(preview_version_info),
|
||||
stable: ChannelVersion::new(stable_version_info),
|
||||
changelogs: None,
|
||||
};
|
||||
|
||||
// Print out the transformed version info.
|
||||
println!("{}", serde_json::to_string_pretty(&transformed_versions)?);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
use std::process::exit;
|
||||
|
||||
use anyhow::Result;
|
||||
use channel_versions::ParsedVersion;
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(about)]
|
||||
struct Args {
|
||||
#[arg(long)]
|
||||
version_to_roll_out: String,
|
||||
|
||||
#[arg(long)]
|
||||
current_version: String,
|
||||
}
|
||||
|
||||
/// Compares two versions and exits with a non-zero exit code if the version to rollout is older than the current version.
|
||||
/// Used within the `channel-versions` repo to ensure that we always specify the `is_rollback` field when rolling back.
|
||||
fn main() -> Result<()> {
|
||||
let args = Args::parse();
|
||||
|
||||
let version_to_roll_out = args.version_to_roll_out;
|
||||
let current_version = args.current_version;
|
||||
|
||||
let parsed_version_to_roll_out = ParsedVersion::try_from(version_to_roll_out.as_str())?;
|
||||
let parsed_current_version = ParsedVersion::try_from(current_version.as_str())?;
|
||||
|
||||
match parsed_version_to_roll_out.cmp(&parsed_current_version) {
|
||||
std::cmp::Ordering::Less => {
|
||||
println!("Current version ({current_version}) is newer than the version to roll out ({version_to_roll_out})");
|
||||
exit(1);
|
||||
}
|
||||
std::cmp::Ordering::Equal => {
|
||||
println!("Version to rollout ({version_to_roll_out}) is equal to the current version ({current_version})");
|
||||
}
|
||||
std::cmp::Ordering::Greater => {
|
||||
println!("Version to rollout ({version_to_roll_out}) is newer than the current version ({current_version})");
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user