From a58216fa52e319eed3cbc720ebbd9d0ab496474c Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Mon, 22 Jul 2024 16:07:32 -0700 Subject: [PATCH] new: Support env vars for `proto setup`. (#556) --- CHANGELOG.md | 1 + Cargo.lock | 96 ++++++++++++++-------------- Cargo.toml | 2 +- crates/cli/src/commands/clean.rs | 2 +- crates/cli/src/commands/setup.rs | 20 +++++- crates/cli/src/commands/uninstall.rs | 2 +- package/src/api-types.ts | 10 ++- 7 files changed, 78 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ea62f6f1..665203f1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Added a new setting to `.prototools`, `settings.builtin-plugins`, that can be used to disable all built-in plugins, or only allow a few select plugins. - Supports a boolean or list of plugin names. - All are enabled by default for backwards compatibility. +- Added `PROTO_NO_MODIFY_PROFILE` and `PROTO_NO_MODIFY_PATH` environment variables to `proto setup` (for automated workflows). - Updated `github://` plugin locators to support monorepos. Append the project name (that tags are prefixed with) to the path: `github://moonrepo/tools/node_tool` - Merged `proto use` and `proto install` commands. If no arguments are provided to `proto install`, it will install all configured tools. diff --git a/Cargo.lock b/Cargo.lock index 44f904987..ac8e47313 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,7 +161,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -452,7 +452,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -768,9 +768,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ "darling_core", "darling_macro", @@ -778,27 +778,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] name = "darling_macro" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -818,7 +818,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -926,7 +926,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -1035,7 +1035,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -1072,7 +1072,7 @@ checksum = "3a024b0f20295098d1d19ad443fad077c1d8c1d81d09a2c20f0618ebd201517e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -1221,7 +1221,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -1278,9 +1278,9 @@ dependencies = [ [[package]] name = "garde" -version = "0.19.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29a44029f2f9359712d0c34cb78dc36266e9949ffbfcc13f5f737f6e6f1a7226" +checksum = "0a3233677ea1554a48235d81bb59d2a41654969a8e29a1316c48105fd1701693" dependencies = [ "compact_str", "garde_derive", @@ -1291,14 +1291,14 @@ dependencies = [ [[package]] name = "garde_derive" -version = "0.19.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5e2e952fbf2bcd9dae6854d7ebcbfb05f261656d1131f4f1f4fac9da450adec" +checksum = "8796f322e43105351a7ec35148807b32b5b6058a539656dafe4a5b456d5ca41f" dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -1837,7 +1837,7 @@ dependencies = [ "manyhow-macros", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -1853,9 +1853,9 @@ dependencies = [ [[package]] name = "markdown" -version = "1.0.0-alpha.17" +version = "1.0.0-alpha.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e27d6220ce21f80ce5c4201f23a37c6f1ad037c72c9d1ff215c2919605a5d6" +checksum = "4e61c5c85b392273c4d4ea546e6399ace3e3db172ab01b6de8f3d398d1dbd2ec" dependencies = [ "unicode-id", ] @@ -1927,7 +1927,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -2154,7 +2154,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -2296,7 +2296,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -2867,9 +2867,9 @@ dependencies = [ [[package]] name = "schematic" -version = "0.16.5" +version = "0.16.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5186a0ee6296b0bec9f35d0e926e1cb736f14b557875a52847dbfb757385f50c" +checksum = "39662af6f427584874872ecc0e42888bccd0c42510d32d519c4ac9319f4c52f3" dependencies = [ "garde", "indexmap 2.2.6", @@ -2889,22 +2889,22 @@ dependencies = [ [[package]] name = "schematic_macros" -version = "0.16.5" +version = "0.16.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbba5ab97b490c225145d5beba9d565c49049a4c3798227d9ef1dba23f6fcb0f" +checksum = "9747db30b2549f7a3d5c5c61e00a4da45d6fe7f4a413594ffc5e598f5ced1330" dependencies = [ "convert_case", "darling", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] name = "schematic_types" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e23da8bf72241430f0a710266256139667125e51d11283e60147df0015da4758" +checksum = "6196a0b23e5b4ee02e3894a937606fc49ccc9211e1650a9bef759062cfff3d58" dependencies = [ "indexmap 2.2.6", "semver", @@ -2968,7 +2968,7 @@ checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -3203,7 +3203,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -3297,7 +3297,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -3340,9 +3340,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.68" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -3479,7 +3479,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -3535,7 +3535,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -3663,7 +3663,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -3982,7 +3982,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", "wasm-bindgen-shared", ] @@ -4016,7 +4016,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4175,7 +4175,7 @@ dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", "wasmtime-component-util", "wasmtime-wit-bindgen", "wit-parser", @@ -4302,7 +4302,7 @@ checksum = "d4cedc5bfef3db2a85522ee38564b47ef3b7fc7c92e94cacbce99808e63cdd47" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -4425,7 +4425,7 @@ dependencies = [ "proc-macro2", "quote", "shellexpand", - "syn 2.0.68", + "syn 2.0.72", "witx", ] @@ -4437,7 +4437,7 @@ checksum = "0b47d2b4442ce93106dba5d1a9c59d5f85b5732878bb3d0598d3c93c0d01b16b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", "wiggle-generate", ] @@ -4758,7 +4758,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 547a0aef2..d6ca31cd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ reqwest = { version = "0.12.5", default-features = false, features = [ "macos-system-configuration", ] } rustc-hash = "2.0.0" -schematic = { version = "0.16.5", default-features = false } +schematic = { version = "0.16.6", default-features = false } semver = { version = "1.0.23", features = ["serde"] } serde = { version = "1.0.204", features = ["derive"] } serde_json = "1.0.120" diff --git a/crates/cli/src/commands/clean.rs b/crates/cli/src/commands/clean.rs index b85d55eeb..f67c24f8e 100644 --- a/crates/cli/src/commands/clean.rs +++ b/crates/cli/src/commands/clean.rs @@ -36,7 +36,7 @@ pub struct CleanArgs { )] pub purge_plugins: bool, - #[arg(long, help = "Avoid and force confirm prompts")] + #[arg(long, help = "Avoid and force confirm prompts", env = "PROTO_YES")] pub yes: bool, } diff --git a/crates/cli/src/commands/setup.rs b/crates/cli/src/commands/setup.rs index 5c5c42366..b52f19b73 100644 --- a/crates/cli/src/commands/setup.rs +++ b/crates/cli/src/commands/setup.rs @@ -22,13 +22,27 @@ pub struct SetupArgs { #[arg(long, help = "Shell to setup for")] shell: Option, - #[arg(long, help = "Don't update a shell profile", alias = "no-profile")] + #[arg( + long, + help = "Don't update a shell profile", + alias = "no-profile", + env = "PROTO_NO_MODIFY_PROFILE" + )] no_modify_profile: bool, - #[arg(long, help = "Don't update the system path")] + #[arg( + long, + help = "Don't update the system path", + env = "PROTO_NO_MODIFY_PATH" + )] no_modify_path: bool, - #[arg(long, short = 'y', help = "Avoid interactive prompts and use defaults")] + #[arg( + long, + short = 'y', + help = "Avoid interactive prompts and use defaults", + env = "PROTO_YES" + )] yes: bool, } diff --git a/crates/cli/src/commands/uninstall.rs b/crates/cli/src/commands/uninstall.rs index 7f509ca73..709146d1c 100644 --- a/crates/cli/src/commands/uninstall.rs +++ b/crates/cli/src/commands/uninstall.rs @@ -16,7 +16,7 @@ pub struct UninstallArgs { #[arg(help = "Version or alias of tool")] spec: Option, - #[arg(long, help = "Avoid and force confirm prompts")] + #[arg(long, help = "Avoid and force confirm prompts", env = "PROTO_YES")] yes: bool, } diff --git a/package/src/api-types.ts b/package/src/api-types.ts index f2537faa4..81e7b7168 100644 --- a/package/src/api-types.ts +++ b/package/src/api-types.ts @@ -22,6 +22,7 @@ export type HostLogTarget = 'stderr' | 'stdout' | 'tracing'; export interface HostLogInput { data?: Record; message: string; + /** @type {'stderr' | 'stdout' | 'tracing'} */ target?: HostLogTarget; } @@ -53,9 +54,12 @@ export interface ExecCommandOutput { /** Information about the host environment (the current runtime). */ export interface HostEnvironment { + /** @type {'x86' | 'x64' | 'arm' | 'arm64' | 'longarm64' | 'm68k' | 'mips' | 'mips64' | 'powerpc' | 'powerpc64' | 'riscv64' | 's390x' | 'sparc64'} */ arch: SystemArch; homeDir: VirtualPath; + /** @type {'gnu' | 'musl' | 'unknown'} */ libc: SystemLibc; + /** @type {'android' | 'dragonfly' | 'freebsd' | 'ios' | 'linux' | 'macos' | 'netbsd' | 'openbsd' | 'solaris' | 'windows'} */ os: SystemOS; } @@ -114,7 +118,11 @@ export interface ToolMetadataOutput { * and should be blocked from happening. */ selfUpgradeCommands?: string[]; - /** Type of the tool. */ + /** + * Type of the tool. + * + * @type {'language' | 'dependency-manager' | 'cli'} + */ type: PluginType; }