Skip to content

Commit

Permalink
internal: More changes to support Rust. (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Aug 11, 2023
1 parent b0b7f6c commit 86f6e98
Show file tree
Hide file tree
Showing 15 changed files with 223 additions and 167 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
with:
components: rustfmt
- run: cargo fmt --all --check
Expand All @@ -31,7 +31,7 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
with:
components: clippy
- run: cargo clippy --workspace --all-targets
Expand All @@ -44,7 +44,7 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
with:
bins: cargo-wasi, cargo-nextest
cache: false
Expand All @@ -70,7 +70,7 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
with:
bins: cargo-wasi
cache: false
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
with:
cache: false
- name: Install cargo-dist
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
with:
cache: false
- name: Install cargo-dist
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
- [Node.js (and package managers)](https://github.com/moonrepo/node-plugin) and [Rust](https://github.com/moonrepo/rust-plugin) are now powered by WASM plugins, and have been removed from core.
- Please report any issues you encounter or discrepancies from the previous release!
- Yarn 2+ is now installed using `@yarnpkg/cli-dist`. We no longer downgrade to the latest v1.
- Improved version detection and requirement resolution.
- WASM API
- Renamed host function `trace` to `host_log`.
- Added `host_log!` and `exec_command!` macros for working with host functions.
- Added `default_version` field to `ToolMetadataOutput`.
- Added `home_dir` field to `LocateBinsInput`.
- Added `globals_prefix` field to `LocateBinsOutput`.
- Updated `exec_command` with stream/inherit support.
- Updated `bin_path` in `LocateBinsOutput` and `ShimConfig` to a `PathBuf`.

Expand Down
1 change: 1 addition & 0 deletions crates/cli/src/commands/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub async fn global(tool_id: String, version: AliasOrVersion) -> SystemResult {
tool.manifest.save()?;

debug!(
version = version.to_string(),
manifest = ?tool.manifest.path,
"Wrote the global version",
);
Expand Down
8 changes: 4 additions & 4 deletions crates/cli/src/commands/list_global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub async fn list_global(tool_id: String) -> SystemResult {
debug!(globals_dir = ?globals_dir, "Finding global packages");

let mut bins = vec![];
let globals_prefix = tool.get_globals_prefix();

if globals_dir.exists() {
for file in fs::read_dir(globals_dir)? {
Expand All @@ -27,11 +28,10 @@ pub async fn list_global(tool_id: String) -> SystemResult {
let file_path = file.path();
let mut file_name = fs::file_name(&file_path);

if tool_id == "rust" {
if let Some(cargo_bin) = file_name.strip_prefix("cargo-") {
file_name = cargo_bin.to_owned();
if let Some(prefix) = globals_prefix {
if let Some(prefixless) = file_name.strip_prefix(prefix) {
file_name = prefixless.to_owned();
} else {
// Non-cargo binaries are in this directory
continue;
}
}
Expand Down
6 changes: 5 additions & 1 deletion crates/cli/src/commands/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ pub async fn local(tool_id: String, version: AliasOrVersion) -> SystemResult {
config.tools.insert(tool_id, version.clone());
config.save()?;

debug!(config = ?config.path, "Wrote the local version");
debug!(
version = version.to_string(),
config = ?config.path,
"Wrote the local version",
);

info!(
"Set the local {} version to {}",
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/commands/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub async fn plugins(json: bool) -> SystemResult {

items.push(PluginItem {
id,
name: tool.get_name(),
name: tool.get_name().to_owned(),
// version: String::new(),
locator,
});
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub async fn run(
if !tool.is_setup(&version).await? {
if !user_config.auto_install {
return Err(ProtoError::MissingToolForRun {
tool: tool.get_name(),
tool: tool.get_name().to_owned(),
version: version.to_string(),
command: format!("proto install {} {}", tool.id, tool.get_resolved_version()),
}
Expand Down
4 changes: 4 additions & 0 deletions crates/core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ pub enum ProtoError {
#[error("{0}")]
Message(String),

#[diagnostic(code(proto::tool::invalid_dir))]
#[error("Tool inventory directory has been overridden but is not an absolute path. Only absolute paths are supported.")]
AbsoluteInventoryDir,

#[diagnostic(
code(proto::download::missing),
help = "Please refer to the tool's official documentation."
Expand Down
Loading

0 comments on commit 86f6e98

Please sign in to comment.