mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-25 19:14:50 -08:00
feat(segments): add Vite segment
This commit is contained in:
parent
4d06374007
commit
4d2b4c7292
|
@ -213,6 +213,8 @@ const (
|
||||||
UPGRADE SegmentType = "upgrade"
|
UPGRADE SegmentType = "upgrade"
|
||||||
// VALA writes the active vala version
|
// VALA writes the active vala version
|
||||||
VALA SegmentType = "vala"
|
VALA SegmentType = "vala"
|
||||||
|
// VUE writes the current vite version
|
||||||
|
VITE SegmentType = "vite"
|
||||||
// WAKATIME writes tracked time spend in dev editors
|
// WAKATIME writes tracked time spend in dev editors
|
||||||
WAKATIME SegmentType = "wakatime"
|
WAKATIME SegmentType = "wakatime"
|
||||||
// WINREG queries the Windows registry.
|
// WINREG queries the Windows registry.
|
||||||
|
@ -324,6 +326,7 @@ var Segments = map[SegmentType]func() SegmentWriter{
|
||||||
UNITY: func() SegmentWriter { return &segments.Unity{} },
|
UNITY: func() SegmentWriter { return &segments.Unity{} },
|
||||||
UPGRADE: func() SegmentWriter { return &segments.Upgrade{} },
|
UPGRADE: func() SegmentWriter { return &segments.Upgrade{} },
|
||||||
VALA: func() SegmentWriter { return &segments.Vala{} },
|
VALA: func() SegmentWriter { return &segments.Vala{} },
|
||||||
|
VITE: func() SegmentWriter { return &segments.Vite{} },
|
||||||
WAKATIME: func() SegmentWriter { return &segments.Wakatime{} },
|
WAKATIME: func() SegmentWriter { return &segments.Wakatime{} },
|
||||||
WINREG: func() SegmentWriter { return &segments.WindowsRegistry{} },
|
WINREG: func() SegmentWriter { return &segments.WindowsRegistry{} },
|
||||||
WITHINGS: func() SegmentWriter { return &segments.Withings{} },
|
WITHINGS: func() SegmentWriter { return &segments.Withings{} },
|
||||||
|
|
26
src/segments/vite.go
Normal file
26
src/segments/vite.go
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package segments
|
||||||
|
|
||||||
|
type Vite struct {
|
||||||
|
language
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *Vite) Template() string {
|
||||||
|
return languageTemplate
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *Vite) Enabled() bool {
|
||||||
|
v.extensions = []string{"vite.config.*"}
|
||||||
|
v.commands = []*cmd{
|
||||||
|
{
|
||||||
|
regex: `(?:(?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+))))`,
|
||||||
|
getVersion: v.getVersion,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
v.versionURLTemplate = "https://github.com/vitejs/vite/releases/tag/{{.Full}}"
|
||||||
|
|
||||||
|
return v.language.Enabled()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *Vite) getVersion() (string, error) {
|
||||||
|
return v.nodePackageVersion("vite")
|
||||||
|
}
|
|
@ -399,6 +399,7 @@
|
||||||
"unity",
|
"unity",
|
||||||
"upgrade",
|
"upgrade",
|
||||||
"vala",
|
"vala",
|
||||||
|
"vite",
|
||||||
"wakatime",
|
"wakatime",
|
||||||
"winreg",
|
"winreg",
|
||||||
"withings",
|
"withings",
|
||||||
|
@ -5019,6 +5020,54 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"const": "vite"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"title": "Vite Segment",
|
||||||
|
"description": "https://ohmyposh.dev/docs/segments/cli/vite",
|
||||||
|
"properties": {
|
||||||
|
"properties": {
|
||||||
|
"properties": {
|
||||||
|
"home_enabled": {
|
||||||
|
"$ref": "#/definitions/home_enabled"
|
||||||
|
},
|
||||||
|
"fetch_version": {
|
||||||
|
"$ref": "#/definitions/fetch_version"
|
||||||
|
},
|
||||||
|
"missing_command_text": {
|
||||||
|
"$ref": "#/definitions/missing_command_text"
|
||||||
|
},
|
||||||
|
"display_mode": {
|
||||||
|
"$ref": "#/definitions/display_mode"
|
||||||
|
},
|
||||||
|
"version_url_template": {
|
||||||
|
"$ref": "#/definitions/version_url_template"
|
||||||
|
},
|
||||||
|
"extensions": {
|
||||||
|
"type": "array",
|
||||||
|
"title": "Extensions",
|
||||||
|
"description": "The extensions to look for when determining if the current directory is an Vite project",
|
||||||
|
"default": [
|
||||||
|
"vite.config.*"
|
||||||
|
],
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"folders": {
|
||||||
|
"$ref": "#/definitions/folders"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
63
website/docs/segments/cli/vite.mdx
Normal file
63
website/docs/segments/cli/vite.mdx
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
---
|
||||||
|
id: vite
|
||||||
|
title: Vite
|
||||||
|
sidebar_label: Vite
|
||||||
|
---
|
||||||
|
|
||||||
|
## What
|
||||||
|
|
||||||
|
Display the currently active [Vite][vite] version.
|
||||||
|
|
||||||
|
## Sample Configuration
|
||||||
|
|
||||||
|
import Config from "@site/src/components/Config.js";
|
||||||
|
|
||||||
|
<Config
|
||||||
|
data={{
|
||||||
|
type: "vite",
|
||||||
|
style: "powerline",
|
||||||
|
powerline_symbol: "\uE0B0",
|
||||||
|
foreground: "#ffbd15",
|
||||||
|
background: "#a257fe",
|
||||||
|
template: " \uE8D7 {{ .Full }} ",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Name | Type | Default | Description |
|
||||||
|
| ---------------------- | :--------: | :------------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
|
| `home_enabled` | `boolean` | `false` | display the segment in the HOME folder or not |
|
||||||
|
| `fetch_version` | `boolean` | `true` | fetch the vite version |
|
||||||
|
| `cache_duration` | `string` | `24h` | the duration for which the version will be cached. The duration is a string in the format `1h2m3s` and is parsed using the [time.ParseDuration] function from the Go standard library. To disable the cache, use `none` |
|
||||||
|
| `missing_command_text` | `string` | | text to display when the command is missing |
|
||||||
|
| `display_mode` | `string` | `context` | <ul><li>`always`: the segment is always displayed</li><li>`files`: the segment is only displayed when file `extensions` listed are present</li><li>`context`: displays the segment when the environment or files is active</li></ul> |
|
||||||
|
| `version_url_template` | `string` | | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes |
|
||||||
|
| `extensions` | `[]string` | `vite.config.*` | allows to override the default list of file extensions to validate |
|
||||||
|
| `folders` | `[]string` | | allows to override the list of folder names to validate |
|
||||||
|
|
||||||
|
## Template ([info][templates])
|
||||||
|
|
||||||
|
:::note default template
|
||||||
|
|
||||||
|
```template
|
||||||
|
{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}
|
||||||
|
```
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### Properties
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| -------- | -------- | -------------------------------------------------- |
|
||||||
|
| `.Full` | `string` | the full version |
|
||||||
|
| `.Major` | `string` | major number |
|
||||||
|
| `.Minor` | `string` | minor number |
|
||||||
|
| `.Patch` | `string` | patch number |
|
||||||
|
| `.URL` | `string` | URL of the version info / release notes |
|
||||||
|
| `.Error` | `string` | error encountered when fetching the version string |
|
||||||
|
|
||||||
|
[go-text-template]: https://golang.org/pkg/text/template/
|
||||||
|
[templates]: /docs/configuration/templates
|
||||||
|
[vite]: https://vite.dev/
|
||||||
|
[time.ParseDuration]: https://golang.org/pkg/time/#ParseDuration
|
|
@ -89,6 +89,7 @@ module.exports = {
|
||||||
"segments/cli/ui5tooling",
|
"segments/cli/ui5tooling",
|
||||||
"segments/cli/umbraco",
|
"segments/cli/umbraco",
|
||||||
"segments/cli/unity",
|
"segments/cli/unity",
|
||||||
|
"segments/cli/vite",
|
||||||
"segments/cli/xmake",
|
"segments/cli/xmake",
|
||||||
"segments/cli/yarn",
|
"segments/cli/yarn",
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue