From e0281868c9d7801fc25f64f86ab8312d2a5a1794 Mon Sep 17 00:00:00 2001 From: Evan Mattiza Date: Fri, 28 Jun 2024 16:39:40 -0500 Subject: [PATCH] feat(purescript): add support for spago-next configuration files (#6036) * update: add purescript spago-next configuration files in upcoming spago projects, the configuration file is changing from spago.dhall -> spago.yaml and spago.lock. This will detect both styles for the time being * fix typo did not update test. spago.yaml -> spago.lock in the spago lock file test case --- .github/config-schema.json | 8 ++++++-- docs/config/README.md | 22 ++++++++++++---------- src/configs/purescript.rs | 2 +- src/modules/purescript.rs | 22 ++++++++++++++++++++++ 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/.github/config-schema.json b/.github/config-schema.json index 4ec65c32..37144b21 100644 --- a/.github/config-schema.json +++ b/.github/config-schema.json @@ -1376,7 +1376,9 @@ "purs" ], "detect_files": [ - "spago.dhall" + "spago.dhall", + "spago.yaml", + "spago.lock" ], "detect_folders": [], "disabled": false, @@ -5156,7 +5158,9 @@ }, "detect_files": { "default": [ - "spago.dhall" + "spago.dhall", + "spago.yaml", + "spago.lock" ], "type": "array", "items": { diff --git a/docs/config/README.md b/docs/config/README.md index cfaf04d6..ccc3ea15 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -3593,20 +3593,22 @@ The `purescript` module shows the currently installed version of [PureScript](ht By default the module will be shown if any of the following conditions are met: - The current directory contains a `spago.dhall` file +- The current directory contains a `spago.yaml` file +- The current directory contains a `spago.lock` file - The current directory contains a file with the `.purs` extension ### Options -| Option | Default | Description | -| ------------------- | ------------------------------------ | ------------------------------------------------------------------------- | -| `format` | `'via [$symbol($version )]($style)'` | The format for the module. | -| `version_format` | `'v${raw}'` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` | -| `symbol` | `'<=> '` | The symbol used before displaying the version of PureScript. | -| `detect_extensions` | `['purs']` | Which extensions should trigger this module. | -| `detect_files` | `['spago.dhall']` | Which filenames should trigger this module. | -| `detect_folders` | `[]` | Which folders should trigger this module. | -| `style` | `'bold white'` | The style for the module. | -| `disabled` | `false` | Disables the `purescript` module. | +| Option | Default | Description | +| ------------------- | --------------------------------------------- | ------------------------------------------------------------------------- | +| `format` | `'via [$symbol($version )]($style)'` | The format for the module. | +| `version_format` | `'v${raw}'` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` | +| `symbol` | `'<=> '` | The symbol used before displaying the version of PureScript. | +| `detect_extensions` | `['purs']` | Which extensions should trigger this module. | +| `detect_files` | `['spago.dhall', 'spago.yaml', 'spago.lock']` | Which filenames should trigger this module. | +| `detect_folders` | `[]` | Which folders should trigger this module. | +| `style` | `'bold white'` | The style for the module. | +| `disabled` | `false` | Disables the `purescript` module. | ### Variables diff --git a/src/configs/purescript.rs b/src/configs/purescript.rs index a172d52b..2e452aa9 100644 --- a/src/configs/purescript.rs +++ b/src/configs/purescript.rs @@ -27,7 +27,7 @@ impl<'a> Default for PureScriptConfig<'a> { style: "bold white", disabled: false, detect_extensions: vec!["purs"], - detect_files: vec!["spago.dhall"], + detect_files: vec!["spago.dhall", "spago.yaml", "spago.lock"], detect_folders: vec![], } } diff --git a/src/modules/purescript.rs b/src/modules/purescript.rs index b46ba573..577706dc 100644 --- a/src/modules/purescript.rs +++ b/src/modules/purescript.rs @@ -92,4 +92,26 @@ mod tests { assert_eq!(expected, actual); dir.close() } + + #[test] + fn folder_with_spago_yaml_file() -> io::Result<()> { + let dir = tempfile::tempdir()?; + File::create(dir.path().join("spago.yaml"))?.sync_all()?; + + let actual = ModuleRenderer::new("purescript").path(dir.path()).collect(); + let expected = Some(format!("via {}", Color::White.bold().paint("<=> v0.13.5 "))); + assert_eq!(expected, actual); + dir.close() + } + + #[test] + fn folder_with_spago_lock_file() -> io::Result<()> { + let dir = tempfile::tempdir()?; + File::create(dir.path().join("spago.lock"))?.sync_all()?; + + let actual = ModuleRenderer::new("purescript").path(dir.path()).collect(); + let expected = Some(format!("via {}", Color::White.bold().paint("<=> v0.13.5 "))); + assert_eq!(expected, actual); + dir.close() + } }