Repository: ardaku/whoami
Pull request #180: Migrate to workspace and define xtask
Author: login: cjohnson19
Created: 2025-03-10T02:52:00Z | Merged: 2025-03-15T05:48:13Z

1. Converts repo to a cargo workspace - closing #142 
2. Adds no-op xtask - closing #143 



Diff:
diff --git a/.cargo/config.toml b/.cargo/config.toml
new file mode 100644
index 0000000..35049cb
--- /dev/null
+++ b/.cargo/config.toml
@@ -0,0 +1,2 @@
+[alias]
+xtask = "run --package xtask --"
diff --git a/Cargo.lock b/Cargo.lock
index ce64be1..4d64ea7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -167,3 +167,7 @@ dependencies = [
  "wasite",
  "web-sys",
 ]
+
+[[package]]
+name = "xtask"
+version = "0.0.0"
diff --git a/Cargo.toml b/Cargo.toml
index a1e3151..1c3ca2d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,49 +1,3 @@
-[package]
-name = "whoami"
-version = "2.0.0-pre.2"
-edition = "2021"
-license = "Apache-2.0 OR BSL-1.0 OR MIT"
-documentation = "https://docs.rs/whoami"
-homepage = "https://github.com/ardaku/whoami/releases"
-repository = "https://github.com/ardaku/whoami"
-readme = "README.md"
-description = "Rust library for getting information about the current user and environment"
-keywords = ["user", "username", "whoami", "platform", "detect"]
-categories = [
-    "os",
-    "wasm",
-    "internationalization",
-    "localization",
-    "value-formatting",
-]
-include = [
-    "/LICENSE_APACHE",
-    "/LICENSE_BOOST",
-    "/LICENSE_MIT",
-    "/README.md",
-    "/src/*",
-]
-rust-version = "1.65"
-
-# Target specific dependency for redox
-[target.'cfg(all(target_os = "redox", not(target_arch = "wasm32")))'.dependencies.redox_syscall]
-version = "0.5"
-
-# Target specific dependency for wasite
-[target.'cfg(all(target_arch = "wasm32", target_os = "wasi"))'.dependencies.wasite]
-version = "0.1"
-
-# Target-specific dependency for web browser
-[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi"), not(daku)))'.dependencies.web-sys]
-version = "0.3"
-features = ["Navigator", "Document", "Window", "Location"]
-optional = true
-
-[features]
-default = ["web"]
-# Enabling this feature indicates that the wasm32-unknown-unknown target should
-# be assumed to be in a web environment where it can call DOM APIs.
-web = ["web-sys"]
-
-[lints.rust]
-unexpected_cfgs = { level = "allow", check-cfg = ['cfg(daku)'] }
+[workspace]
+resolver = "3"
+members = ["whoami", "xtask"]
diff --git a/whoami/Cargo.toml b/whoami/Cargo.toml
new file mode 100644
index 0000000..4da875d
--- /dev/null
+++ b/whoami/Cargo.toml
@@ -0,0 +1,49 @@
+[package]
+name = "whoami"
+version = "2.0.0-pre.2"
+edition = "2021"
+license = "Apache-2.0 OR BSL-1.0 OR MIT"
+documentation = "https://docs.rs/whoami"
+homepage = "https://github.com/ardaku/whoami/releases"
+repository = "https://github.com/ardaku/whoami"
+readme = "../README.md"
+description = "Rust library for getting information about the current user and environment"
+keywords = ["user", "username", "whoami", "platform", "detect"]
+categories = [
+    "os",
+    "wasm",
+    "internationalization",
+    "localization",
+    "value-formatting",
+]
+include = [
+    "../LICENSE_APACHE",
+    "../LICENSE_BOOST",
+    "../LICENSE_MIT",
+    "../README.md",
+    "/src/*",
+]
+rust-version = "1.65"
+
+# Target specific dependency for redox
+[target.'cfg(all(target_os = "redox", not(target_arch = "wasm32")))'.dependencies.redox_syscall]
+version = "0.5"
+
+# Target specific dependency for wasite
+[target.'cfg(all(target_arch = "wasm32", target_os = "wasi"))'.dependencies.wasite]
+version = "0.1"
+
+# Target-specific dependency for web browser
+[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi"), not(daku)))'.dependencies.web-sys]
+version = "0.3"
+features = ["Navigator", "Document", "Window", "Location"]
+optional = true
+
+[features]
+default = ["web"]
+# Enabling this feature indicates that the wasm32-unknown-unknown target should
+# be assumed to be in a web environment where it can call DOM APIs.
+web = ["web-sys"]
+
+[lints.rust]
+unexpected_cfgs = { level = "allow", check-cfg = ['cfg(daku)'] }
diff --git a/examples/os-strings.rs b/whoami/examples/os-strings.rs
similarity index 100%
rename from examples/os-strings.rs
rename to whoami/examples/os-strings.rs
diff --git a/examples/web/Cargo.lock b/whoami/examples/web/Cargo.lock
similarity index 100%
rename from examples/web/Cargo.lock
rename to whoami/examples/web/Cargo.lock
diff --git a/examples/web/Cargo.toml b/whoami/examples/web/Cargo.toml
similarity index 100%
rename from examples/web/Cargo.toml
rename to whoami/examples/web/Cargo.toml
diff --git a/examples/web/README.md b/whoami/examples/web/README.md
similarity index 100%
rename from examples/web/README.md
rename to whoami/examples/web/README.md
diff --git a/examples/web/index.html b/whoami/examples/web/index.html
similarity index 100%
rename from examples/web/index.html
rename to whoami/examples/web/index.html
diff --git a/examples/web/rust-toolchain b/whoami/examples/web/rust-toolchain
similarity index 100%
rename from examples/web/rust-toolchain
rename to whoami/examples/web/rust-toolchain
diff --git a/examples/web/src/lib.rs b/whoami/examples/web/src/lib.rs
similarity index 100%
rename from examples/web/src/lib.rs
rename to whoami/examples/web/src/lib.rs
diff --git a/examples/whoami-demo.rs b/whoami/examples/whoami-demo.rs
similarity index 100%
rename from examples/whoami-demo.rs
rename to whoami/examples/whoami-demo.rs
diff --git a/src/api.rs b/whoami/src/api.rs
similarity index 100%
rename from src/api.rs
rename to whoami/src/api.rs
diff --git a/src/arch.rs b/whoami/src/arch.rs
similarity index 100%
rename from src/arch.rs
rename to whoami/src/arch.rs
diff --git a/src/conversions.rs b/whoami/src/conversions.rs
similarity index 100%
rename from src/conversions.rs
rename to whoami/src/conversions.rs
diff --git a/src/desktop_env.rs b/whoami/src/desktop_env.rs
similarity index 100%
rename from src/desktop_env.rs
rename to whoami/src/desktop_env.rs
diff --git a/src/language.rs b/whoami/src/language.rs
similarity index 100%
rename from src/language.rs
rename to whoami/src/language.rs
diff --git a/src/lib.rs b/whoami/src/lib.rs
similarity index 100%
rename from src/lib.rs
rename to whoami/src/lib.rs
diff --git a/src/os.rs b/whoami/src/os.rs
similarity index 100%
rename from src/os.rs
rename to whoami/src/os.rs
diff --git a/src/os/daku.rs b/whoami/src/os/daku.rs
similarity index 100%
rename from src/os/daku.rs
rename to whoami/src/os/daku.rs
diff --git a/src/os/redox.rs b/whoami/src/os/redox.rs
similarity index 100%
rename from src/os/redox.rs
rename to whoami/src/os/redox.rs
diff --git a/src/os/target.rs b/whoami/src/os/target.rs
similarity index 100%
rename from src/os/target.rs
rename to whoami/src/os/target.rs
diff --git a/src/os/unix.rs b/whoami/src/os/unix.rs
similarity index 100%
rename from src/os/unix.rs
rename to whoami/src/os/unix.rs
diff --git a/src/os/wasi.rs b/whoami/src/os/wasi.rs
similarity index 100%
rename from src/os/wasi.rs
rename to whoami/src/os/wasi.rs
diff --git a/src/os/web.rs b/whoami/src/os/web.rs
similarity index 100%
rename from src/os/web.rs
rename to whoami/src/os/web.rs
diff --git a/src/os/windows.rs b/whoami/src/os/windows.rs
similarity index 100%
rename from src/os/windows.rs
rename to whoami/src/os/windows.rs
diff --git a/src/platform.rs b/whoami/src/platform.rs
similarity index 100%
rename from src/platform.rs
rename to whoami/src/platform.rs
diff --git a/src/result.rs b/whoami/src/result.rs
similarity index 100%
rename from src/result.rs
rename to whoami/src/result.rs
diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml
new file mode 100644
index 0000000..ccade17
--- /dev/null
+++ b/xtask/Cargo.toml
@@ -0,0 +1,5 @@
+[package]
+name = "xtask"
+edition = "2024"
+
+[dependencies]
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
new file mode 100644
index 0000000..e7a11a9
--- /dev/null
+++ b/xtask/src/main.rs
@@ -0,0 +1,3 @@
+fn main() {
+    println!("Hello, world!");
+}


Reviews:
user: login: AldaronLau
body: I think the issues in CI might not be related to this PR
state: DISMISSED
author_association: MEMBER
submitted_at: 2025-03-12T05:02:13Z
user: login: cjohnson19
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-12T20:44:09Z
user: login: cjohnson19
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-12T20:44:12Z
user: login: AldaronLau
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-14T00:12:23Z

Review comments:
diff_hunk: @@ -1,49 +1,3 @@
-[package]
-name = "whoami"
-version = "2.0.0-pre.2"
-edition = "2021"
-license = "Apache-2.0 OR BSL-1.0 OR MIT"
-documentation = "https://docs.rs/whoami"
-homepage = "https://github.com/ardaku/whoami/releases"
-repository = "https://github.com/ardaku/whoami"
-readme = "README.md"
-description = "Retrieve the current user and environment."
-keywords = ["user", "username", "whoami", "platform", "detect"]
-categories = [
-    "os",
-    "wasm",
-    "internationalization",
-    "localization",
-    "value-formatting",
-]
-include = [
-    "/LICENSE_APACHE",
-    "/LICENSE_BOOST",
-    "/LICENSE_MIT",
-    "/README.md",
-    "/src/*",
-]
-rust-version = "1.65"
-
-# Target specific dependency for redox
-[target.'cfg(all(target_os = "redox", not(target_arch = "wasm32")))'.dependencies.redox_syscall]
-version = "0.5"
-
-# Target specific dependency for wasite
-[target.'cfg(all(target_arch = "wasm32", target_os = "wasi"))'.dependencies.wasite]
-version = "0.1"
-
-# Target-specific dependency for web browser
-[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi"), not(daku)))'.dependencies.web-sys]
-version = "0.3"
-features = ["Navigator", "Document", "Window", "Location"]
-optional = true
-
-[features]
-default = ["web"]
-# Enabling this feature indicates that the wasm32-unknown-unknown target should
-# be assumed to be in a web environment where it can call DOM APIs.
-web = ["web-sys"]
-
-[lints.rust]
-unexpected_cfgs = { level = "allow", check-cfg = ['cfg(daku)'] }
+[workspace]
+resolver = "2"
path: Cargo.toml
user: login: AldaronLau
body: I think whoami could just use the default resolver.  Does this need to be specified?
created_at: 2025-03-12T04:56:25Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,6 @@
+[package]
+name = "xtask"
+version = "0.1.0"
+edition = "2021"
path: xtask/Cargo.toml
user: login: AldaronLau
body: I don't think there's a reason we can't use the 2024 edition here.  The `version` field is also unnecessary since the `xtask` crate won't be published.
created_at: 2025-03-12T04:57:35Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,49 @@
+[package]
+name = "whoami"
+version = "2.0.0-pre.2"
+edition = "2021"
+license = "Apache-2.0 OR BSL-1.0 OR MIT"
+documentation = "https://docs.rs/whoami"
+homepage = "https://github.com/ardaku/whoami/releases"
+repository = "https://github.com/ardaku/whoami"
+readme = "README.md"
+description = "Retrieve the current user and environment."
+keywords = ["user", "username", "whoami", "platform", "detect"]
+categories = [
+    "os",
+    "wasm",
+    "internationalization",
+    "localization",
+    "value-formatting",
+]
+include = [
+    "/LICENSE_APACHE",
+    "/LICENSE_BOOST",
+    "/LICENSE_MIT",
+    "/README.md",
+    "/src/*",
path: whoami/Cargo.toml
user: login: AldaronLau
body: I'm not sure, you should be able to check with `cargo package`, but this will need to change to either

```suggestion
    "/whoami/src/*",
```

or

```
    "../LICENSE_APACHE",
    "../LICENSE_BOOST",
    "../LICENSE_MIT",
    "../README.md",
    "/src/*",
```
created_at: 2025-03-12T05:00:28Z
author_association: MEMBER
diff_hunk: @@ -1,49 +1,3 @@
-[package]
-name = "whoami"
-version = "2.0.0-pre.2"
-edition = "2021"
-license = "Apache-2.0 OR BSL-1.0 OR MIT"
-documentation = "https://docs.rs/whoami"
-homepage = "https://github.com/ardaku/whoami/releases"
-repository = "https://github.com/ardaku/whoami"
-readme = "README.md"
-description = "Retrieve the current user and environment."
-keywords = ["user", "username", "whoami", "platform", "detect"]
-categories = [
-    "os",
-    "wasm",
-    "internationalization",
-    "localization",
-    "value-formatting",
-]
-include = [
-    "/LICENSE_APACHE",
-    "/LICENSE_BOOST",
-    "/LICENSE_MIT",
-    "/README.md",
-    "/src/*",
-]
-rust-version = "1.65"
-
-# Target specific dependency for redox
-[target.'cfg(all(target_os = "redox", not(target_arch = "wasm32")))'.dependencies.redox_syscall]
-version = "0.5"
-
-# Target specific dependency for wasite
-[target.'cfg(all(target_arch = "wasm32", target_os = "wasi"))'.dependencies.wasite]
-version = "0.1"
-
-# Target-specific dependency for web browser
-[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi"), not(daku)))'.dependencies.web-sys]
-version = "0.3"
-features = ["Navigator", "Document", "Window", "Location"]
-optional = true
-
-[features]
-default = ["web"]
-# Enabling this feature indicates that the wasm32-unknown-unknown target should
-# be assumed to be in a web environment where it can call DOM APIs.
-web = ["web-sys"]
-
-[lints.rust]
-unexpected_cfgs = { level = "allow", check-cfg = ['cfg(daku)'] }
+[workspace]
+resolver = "2"
path: Cargo.toml
user: login: cjohnson19
body: Using the default resolver gives us this warning on build.

```
warning: virtual workspace defaulting to `resolver = "1"` despite one or more workspace members being on edition 2024 which implies `resolver = "3"`
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
note: to use the edition 2024 resolver, specify `workspace.resolver = "3"` in the workspace root's manifest> 
note: for more details see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions
```

If we were to use edition 2021 in the `xtask` crate, it would have the same warning but with `resolver = 2`. So we can keep the resolver to the default `1` or to the recommended `3`.

v2 docs: https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html
v3 docs: https://doc.rust-lang.org/edition-guide/rust-2024/cargo-resolver.html

Let me know how you'd like to proceed :)
created_at: 2025-03-12T20:44:09Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,49 @@
+[package]
+name = "whoami"
+version = "2.0.0-pre.2"
+edition = "2021"
+license = "Apache-2.0 OR BSL-1.0 OR MIT"
+documentation = "https://docs.rs/whoami"
+homepage = "https://github.com/ardaku/whoami/releases"
+repository = "https://github.com/ardaku/whoami"
+readme = "README.md"
+description = "Retrieve the current user and environment."
+keywords = ["user", "username", "whoami", "platform", "detect"]
+categories = [
+    "os",
+    "wasm",
+    "internationalization",
+    "localization",
+    "value-formatting",
+]
+include = [
+    "/LICENSE_APACHE",
+    "/LICENSE_BOOST",
+    "/LICENSE_MIT",
+    "/README.md",
+    "/src/*",
path: whoami/Cargo.toml
user: login: cjohnson19
body: Good catch! Thank you!
created_at: 2025-03-12T20:44:12Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,49 +1,3 @@
-[package]
-name = "whoami"
-version = "2.0.0-pre.2"
-edition = "2021"
-license = "Apache-2.0 OR BSL-1.0 OR MIT"
-documentation = "https://docs.rs/whoami"
-homepage = "https://github.com/ardaku/whoami/releases"
-repository = "https://github.com/ardaku/whoami"
-readme = "README.md"
-description = "Retrieve the current user and environment."
-keywords = ["user", "username", "whoami", "platform", "detect"]
-categories = [
-    "os",
-    "wasm",
-    "internationalization",
-    "localization",
-    "value-formatting",
-]
-include = [
-    "/LICENSE_APACHE",
-    "/LICENSE_BOOST",
-    "/LICENSE_MIT",
-    "/README.md",
-    "/src/*",
-]
-rust-version = "1.65"
-
-# Target specific dependency for redox
-[target.'cfg(all(target_os = "redox", not(target_arch = "wasm32")))'.dependencies.redox_syscall]
-version = "0.5"
-
-# Target specific dependency for wasite
-[target.'cfg(all(target_arch = "wasm32", target_os = "wasi"))'.dependencies.wasite]
-version = "0.1"
-
-# Target-specific dependency for web browser
-[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi"), not(daku)))'.dependencies.web-sys]
-version = "0.3"
-features = ["Navigator", "Document", "Window", "Location"]
-optional = true
-
-[features]
-default = ["web"]
-# Enabling this feature indicates that the wasm32-unknown-unknown target should
-# be assumed to be in a web environment where it can call DOM APIs.
-web = ["web-sys"]
-
-[lints.rust]
-unexpected_cfgs = { level = "allow", check-cfg = ['cfg(daku)'] }
+[workspace]
+resolver = "2"
path: Cargo.toml
user: login: AldaronLau
body: I think having the default be the recommended `3` sounds good!
created_at: 2025-03-14T00:12:23Z
author_association: MEMBER

PR comments:
user: login: cjohnson19
created_at: 2025-03-10T16:10:51Z
body: @AldaronLau I probably should have split this into two PRs. One for the workspace and one for the xtask. For solving the errors, should I limit the build to the `whoami` package? I am guessing we will want the xtask to be ran once and for all prior to the build of `whoami` on any specific platform.
author_association: CONTRIBUTOR
user: login: AldaronLau
created_at: 2025-03-12T05:38:36Z
body: @cjohnson19 Fixed the CI issue, so once you merge or rebase, the errors should be fixed
author_association: MEMBER
user: login: AldaronLau
created_at: 2025-03-12T05:39:22Z
body: @cjohnson19 Also no worries about putting these two issues together - I think it makes sense, and thanks for the PR!
author_association: MEMBER
user: login: AldaronLau
created_at: 2025-03-14T04:31:21Z
body: @cjohnson19 Merged another fix since rustup changes broke CI again, so should be just one more rebase and I can merge :crossed_fingers: 
author_association: MEMBER