Skip to content

Commit

Permalink
config-environments: make non-experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Dec 13, 2023
1 parent 6c80436 commit 2d429e2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 24 deletions.
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Then when inside of `~/src/myproj/backend`, `node` will be `18`, `python` will b
will be `3.1`. You can check the active versions with `rtx ls --current`.

You can also have environment specific config files like `.rtx.production.toml`, see
[Config Environments](#experimental-config-environments) for more details.
[Config Environments](#config-environments) for more details.

#### `[env]` - Arbitrary Environment Variables

Expand Down Expand Up @@ -835,12 +835,12 @@ a different name.

Set to something other than `.rtx.toml` to have rtx look for `.rtx.toml` config files with a different name.

#### [experimental] `RTX_ENV`
#### `RTX_ENV`

Enables environment-specific config files such as `.rtx.development.toml`.
Use this for different env vars or different tool versions in
development/staging/production environments. See
[Config Environments](#experimental-config-environments) for more on how
[Config Environments](#config-environments) for more on how
to use this feature.

#### `RTX_USE_VERSIONS_HOST`
Expand Down Expand Up @@ -1123,10 +1123,6 @@ does not work for some reason.

## Templates

> **Warning**
>
> This functionality is experimental and may change in the future.
Templates are used in the following locations:

- `.tool-versions` files
Expand Down Expand Up @@ -1157,11 +1153,10 @@ Here's another using `exec()`:
current = "{{exec(command='node --version')}}"
```

## [experimental] Config Environments
## Config Environments

It's possible to have separate `.rtx.toml` files in the same directory for different
environments like `development` and `production`. To enable, set
`experimental = true` in `~/.config/rtx/config.toml`, then set `RTX_ENV` to an environment like
environments like `development` and `production`. To enable, set `RTX_ENV` to an environment like
`development` or `production`. rtx will then look for a `.rtx.{RTX_ENV}.toml` file in the current directory.

rtx will also look for "local" files like `.rtx.local.toml` and `.rtx.{RTX_ENV}.local.toml` in
Expand Down Expand Up @@ -1213,8 +1208,8 @@ You can see the core plugins with `rtx plugin ls --core`.
- [Ruby](./docs/ruby.md)
- [Go](./docs/go.md)
- [Java](./docs/java.md)
- [Deno (experimental)](./docs/deno.md)
- [Bun (experimental)](./docs/bun.md)
- [Deno](./docs/deno.md)
- [Bun](./docs/bun.md)

## FAQs

Expand Down
2 changes: 1 addition & 1 deletion src/cli/use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct Use {
#[clap(short, long, overrides_with_all = &["path", "env"])]
global: bool,

/// [experimental] Modify an environment-specific config file like .rtx.<env>.toml
/// Modify an environment-specific config file like .rtx.<env>.toml
#[clap(long, short, overrides_with_all = &["global", "path"])]
env: Option<String>,

Expand Down
9 changes: 3 additions & 6 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ pub struct Config {
impl Config {
pub fn load() -> Result<Self> {
let global_config = load_rtxrc()?;
let config_filenames = load_config_filenames(&BTreeMap::new());
let settings = Settings::default_builder()
.preloaded(global_config.settings()?)
.load()?;
let config_filenames = load_config_filenames(&settings, &BTreeMap::new());
let plugins = load_plugins(&settings)?;
let config_files = load_all_config_files(
&settings,
Expand Down Expand Up @@ -330,14 +330,11 @@ fn load_legacy_files(settings: &Settings, tools: &PluginMap) -> BTreeMap<String,
legacy_filenames
}

fn load_config_filenames(
settings: &Settings,
legacy_filenames: &BTreeMap<String, Vec<PluginName>>,
) -> Vec<PathBuf> {
fn load_config_filenames(legacy_filenames: &BTreeMap<String, Vec<PluginName>>) -> Vec<PathBuf> {
let mut filenames = legacy_filenames.keys().cloned().collect_vec();
filenames.push(env::RTX_DEFAULT_TOOL_VERSIONS_FILENAME.clone());
filenames.push(env::RTX_DEFAULT_CONFIG_FILENAME.clone());
if settings.experimental && *env::RTX_DEFAULT_CONFIG_FILENAME == ".rtx.toml" {
if *env::RTX_DEFAULT_CONFIG_FILENAME == ".rtx.toml" {
filenames.push(".rtx.local.toml".to_string());
if let Some(env) = &*env::RTX_ENV {
filenames.push(format!(".rtx.{}.toml", env));
Expand Down
8 changes: 3 additions & 5 deletions src/plugins/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ pub type PluginMap = BTreeMap<String, Arc<dyn Plugin>>;

pub static CORE_PLUGINS: Lazy<PluginMap> = Lazy::new(|| {
let plugins: Vec<Arc<dyn Plugin>> = vec![
Arc::new(BunPlugin::new()),
Arc::new(DenoPlugin::new()),
Arc::new(GoPlugin::new()),
Arc::new(JavaPlugin::new()),
if *RTX_NODE_BUILD == Some(true) {
Expand All @@ -56,11 +58,7 @@ pub static CORE_PLUGINS: Lazy<PluginMap> = Lazy::new(|| {
});

pub static EXPERIMENTAL_CORE_PLUGINS: Lazy<PluginMap> = Lazy::new(|| {
let plugins: Vec<Arc<dyn Plugin>> = vec![
Arc::new(BunPlugin::new()),
Arc::new(DenoPlugin::new()),
Arc::new(ErlangPlugin::new()),
];
let plugins: Vec<Arc<dyn Plugin>> = vec![Arc::new(ErlangPlugin::new())];
plugins
.into_iter()
.map(|plugin| (plugin.name().to_string(), plugin))
Expand Down

0 comments on commit 2d429e2

Please sign in to comment.