feat(project): add always_enabled and project type

This commit is contained in:
Jan De Dobbeleer 2022-12-27 14:49:46 +01:00 committed by Jan De Dobbeleer
parent 8aca8a2d84
commit 07206e5aae
3 changed files with 21 additions and 17 deletions

View file

@ -20,18 +20,12 @@ type ProjectItem struct {
}
type ProjectData struct {
Type string
Version string
Name string
Target string
}
func (p *ProjectData) enabled() bool {
if p == nil {
return false
}
return len(p.Version) > 0 || len(p.Name) > 0 || len(p.Target) > 0
}
// Rust Cargo package
type CargoTOML struct {
Package ProjectData
@ -72,10 +66,11 @@ func (n *Project) Enabled() bool {
continue
}
n.ProjectData = *data
return n.enabled()
n.ProjectData.Type = item.Name
return true
}
}
return false
return n.props.GetBool(properties.AlwaysEnabled, false)
}
func (n *Project) Template() string {

View file

@ -155,19 +155,21 @@ func TestPackage(t *testing.T) {
},
{
Case: "Empty project package node.js",
ExpectedEnabled: false,
ExpectedEnabled: true,
Name: "node",
File: "package.json",
PackageContents: "{}",
},
{
Case: "Empty project package cargo",
ExpectedEnabled: true,
Name: "cargo",
File: "Cargo.toml",
PackageContents: "",
},
{
Case: "Empty project package poetry",
ExpectedEnabled: true,
Name: "poetry",
File: "pyproject.toml",
PackageContents: "",
@ -263,7 +265,7 @@ func TestNuspecPackage(t *testing.T) {
Case: "no info in file",
FileName: "../test/empty.nuspec",
HasFiles: true,
ExpectedEnabled: false,
ExpectedEnabled: true,
},
{
Case: "no files",

View file

@ -18,6 +18,12 @@ Supports:
- .NET project (`*.csproj`, `*.vbproj` or `*.fsproj`, first file match info is displayed)
- Julia project (`JuliaProject.toml`, `Project.toml`)
## Properties
| Name | Type | Description |
| ---------------- | --------- | --------------------------------------------- |
| `always_enabled` | `boolean` | always show the segment - defaults to `false` |
## Sample Configuration
```json
@ -44,7 +50,8 @@ Supports:
### Properties
| Name | Type | Description |
| ---------- | -------- | ------------------------------------------------------ |
| ---------- | -------- | ------------------------------------------------------------------------------------- |
| `.Type` | `string` | The type of project (`node`, `cargo`, `poetry`, `php`, `nuspec`, `dotnet` or `julia`) |
| `.Version` | `string` | The version of your project |
| `.Target` | `string` | The target framwork/language version of your project |
| `.Name` | `string` | The name of your project |