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

feat: support toolchain export #526

Open
wants to merge 59 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
5d36096
feat: support toolchain export
Halimao Nov 23, 2023
e28f87b
add exported success print
Halimao Nov 23, 2023
0ec6b72
chore: code fmt
Halimao Dec 4, 2023
7d2a2bc
Merge branch 'FuelLabs:master' into feat/export-toolchain
Halimao Dec 4, 2023
8d0b943
Merge branch 'feat/export-toolchain' of github.com:Halimao/fuelup int…
Halimao Dec 4, 2023
be6ccdb
refactor: add some suggestion change
Halimao Dec 4, 2023
bf083af
chore: code fmt
Halimao Dec 4, 2023
374fc8d
refactor: check channel validation
Halimao Dec 5, 2023
323a41e
add tests
Halimao Dec 5, 2023
1ebd698
valid channel by Channel::from_str to
Halimao Dec 5, 2023
16a7bb1
fmt code
Halimao Dec 5, 2023
3ebf111
Update src/commands/toolchain.rs
Halimao Dec 9, 2023
d37b2f8
Update src/commands/toolchain.rs
Halimao Dec 9, 2023
022f904
refactor: move valid channel to a const
Halimao Dec 9, 2023
b915d8e
add --channel option
Halimao Dec 9, 2023
735e821
fix: fix --channel option register
Halimao Dec 9, 2023
595f8a0
Update src/ops/fuelup_toolchain/export.rs
Halimao Dec 13, 2023
95c3829
Update src/ops/fuelup_toolchain/export.rs
Halimao Dec 13, 2023
a9e684e
Update src/ops/fuelup_toolchain/export.rs
Halimao Dec 13, 2023
7cca4d0
Update src/ops/fuelup_toolchain/export.rs
Halimao Dec 13, 2023
f54e4f0
Update src/ops/fuelup_toolchain/export.rs
Halimao Dec 13, 2023
4365095
Update src/ops/fuelup_toolchain/export.rs
Halimao Dec 13, 2023
359cb0c
update for suggestion changes
Halimao Dec 13, 2023
17c16a6
Merge branch 'master' into feat/export-toolchain
Halimao Dec 13, 2023
4ef6def
sort dependencies
Halimao Dec 13, 2023
fef14f8
fix: ci test
Halimao Dec 13, 2023
08c59c5
fix: ci test
Halimao Dec 13, 2023
92d8f37
fix ci test
Halimao Dec 13, 2023
801f313
Merge branch 'feat/export-toolchain' of github.com:Halimao/fuelup int…
Halimao Dec 13, 2023
f218a3d
removing the unwraps and bail with a message to user
Halimao Dec 19, 2023
45641c6
refactor: using bail! instead of panic!
Halimao Dec 19, 2023
fdcd0a7
Merge branch 'master' into feat/export-toolchain
Halimao Dec 19, 2023
ed60651
using BufReader::new(stdin()) instead of stdin().lock()
Halimao Dec 20, 2023
8ad7550
rename s to channel
Halimao Dec 20, 2023
52bc84b
Merge branch 'master' into feat/export-toolchain
Halimao Jan 3, 2024
9c90e2e
Update src/ops/fuelup_toolchain/export.rs
Halimao Jan 10, 2024
7b05958
Update src/ops/fuelup_toolchain/export.rs
Halimao Jan 10, 2024
78a9915
Update src/ops/fuelup_toolchain/export.rs
Halimao Jan 10, 2024
fe6d1b1
Update src/ops/fuelup_toolchain/export.rs
Halimao Jan 10, 2024
99e6f52
Update src/ops/fuelup_toolchain/export.rs
Halimao Jan 10, 2024
aad52fa
Update src/ops/fuelup_toolchain/export.rs
Halimao Jan 10, 2024
a83e6f7
Update src/ops/fuelup_toolchain/export.rs
Halimao Jan 10, 2024
e14be95
Update src/ops/fuelup_toolchain/export.rs
Halimao Jan 10, 2024
89d5183
address suggestion changes
Halimao Jan 10, 2024
3d08cc6
fix: fix ci test fail
Halimao Jan 10, 2024
0df6763
refactor: rename test func name
Halimao Jan 10, 2024
324da7c
addressed part of suggestion changes
Halimao Jan 11, 2024
931588f
move the message asking for input onto a new line
Halimao Jan 11, 2024
0b056b8
Merge branch 'master' into feat/export-toolchain
Halimao Jan 13, 2024
f67390b
update cargo.lock
Halimao Jan 13, 2024
452df0a
refactor: clearer failures in tests
Halimao Jan 19, 2024
0ae91e4
refactor: sort and split tests
Halimao Jan 19, 2024
cf92052
using `asert_eq!` instead of `matches!`
Halimao Jan 20, 2024
11fc203
Merge branch 'master' into feat/export-toolchain
sdankel Jan 29, 2024
002c787
Fix toml formatting and tests
sdankel Jan 30, 2024
7a3e4fd
Merge branch 'master' into feat/export-toolchain
Halimao Feb 9, 2024
12811c8
refactor: using `DistToolchainDescription::from_str` to parse out cha…
Halimao Feb 9, 2024
d94ac60
Merge branch 'master' into feat/export-toolchain
Halimao Mar 6, 2024
0441023
Merge branch 'master' into feat/export-toolchain
sdankel Mar 19, 2024
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
199 changes: 198 additions & 1 deletion Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ clap_complete = "4.2"
component = { path = "component" }
dirs = "4"
flate2 = "1"
forc-tracing = "0.47.0"
indicatif = "0.17.7"
semver = { version = "1", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }
Expand All @@ -43,4 +44,5 @@ ureq = "2.4"
members = ["component", "ci/build-channel", "ci/compare-versions"]

[dev-dependencies]
serial_test = "*"
strip-ansi-escapes = "0.2.0"
37 changes: 37 additions & 0 deletions src/commands/toolchain.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
use anyhow::{bail, Result};
use clap::Parser;
use serde::Deserialize;
use std::io::{stdin, BufReader};
use std::str::FromStr;

use crate::constants::VALID_CHANNEL_STR;
use crate::ops::fuelup_toolchain::export::export;
use crate::ops::fuelup_toolchain::install::install;
use crate::ops::fuelup_toolchain::list_revisions::list_revisions;
use crate::ops::fuelup_toolchain::new::new;
use crate::ops::fuelup_toolchain::uninstall::uninstall;
use crate::target_triple::TargetTriple;
use crate::toolchain::RESERVED_TOOLCHAIN_NAMES;
use crate::toolchain_override;

#[derive(Debug, Parser)]
pub enum ToolchainCommand {
Expand All @@ -18,6 +24,8 @@ pub enum ToolchainCommand {
Uninstall(UninstallCommand),
/// Fetch the list of published `latest` toolchains, starting from the most recent
ListRevisions(ListRevisionsCommand),
/// Export the toolchain info into fuel-toolchain.toml
Export(ExportCommand),
}

#[derive(Debug, Parser)]
Expand All @@ -42,6 +50,20 @@ pub struct UninstallCommand {
#[derive(Debug, Parser)]
pub struct ListRevisionsCommand {}

#[derive(Debug, Deserialize, Parser)]
pub struct ExportCommand {
/// Toolchain to export, [possible values: latest, beta-1, beta-2, beta-3, beta-4, nightly].
/// The default toolchain will be exported if name isn't specified
pub name: Option<String>,
Halimao marked this conversation as resolved.
Show resolved Hide resolved
/// Channel to export, [possible values: latest-YYYY-MM-DD, nightly-YYYY-MM-DD, beta-1, beta-2, beta-3, beta-4].
Halimao marked this conversation as resolved.
Show resolved Hide resolved
#[clap(value_parser = channel_allowed)]
Halimao marked this conversation as resolved.
Show resolved Hide resolved
#[arg(short, long)]
pub channel: Option<String>,
/// Forces exporting the toolchain, replacing any existing toolchain override file
#[arg(short, long)]
pub force: bool,
}

fn name_allowed(s: &str) -> Result<String> {
let name = match s.split_once('-') {
Some((prefix, target_triple)) => {
Expand All @@ -64,12 +86,27 @@ fn name_allowed(s: &str) -> Result<String> {
}
}

fn channel_allowed(channel: &str) -> Result<String> {
if channel.is_empty() {
return Ok(channel.to_string());
}
if toolchain_override::Channel::from_str(channel).is_err() {
bail!(
"Invalid channel '{}', expected one of {}.",
channel,
VALID_CHANNEL_STR,
);
}
Ok(channel.to_string())
}

pub fn exec(command: ToolchainCommand) -> Result<()> {
match command {
ToolchainCommand::Install(command) => install(command)?,
ToolchainCommand::New(command) => new(command)?,
ToolchainCommand::Uninstall(command) => uninstall(command)?,
ToolchainCommand::ListRevisions(command) => list_revisions(command)?,
ToolchainCommand::Export(command) => export(command, BufReader::new(stdin()))?,
};

Ok(())
Expand Down
2 changes: 2 additions & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ pub const CHANNEL_BETA_4_FILE_NAME: &str = "channel-fuel-beta-4.toml";

pub const DATE_FORMAT: &[FormatItem] = format_description!("[year]-[month]-[day]");
pub const DATE_FORMAT_URL_FRIENDLY: &[FormatItem] = format_description!("[year]/[month]/[day]");
pub const VALID_CHANNEL_STR: &str =
"<latest-YYYY-MM-DD|nightly-YYYY-MM-DD|beta-1|beta-2|beta-3|beta-4>";
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ pub mod store;
pub mod target_triple;
pub mod toolchain;
pub mod toolchain_override;
pub mod util;
Loading
Loading