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
This commit is contained in:
Evan Mattiza 2024-06-28 16:39:40 -05:00 committed by GitHub
parent 4425b333d7
commit e0281868c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 41 additions and 13 deletions

View File

@ -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": {

View File

@ -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

View File

@ -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![],
}
}

View File

@ -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()
}
}