diff --git a/.prettierignore b/.prettierignore index f8d5949..2d87fc2 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,7 +5,7 @@ dist/* www/ !www/mkdocs.yml -!www/static/schema.json +!www/docs/static/schema.json template/ !template/template.json diff --git a/cmd/commands/new.go b/cmd/commands/new.go index a7be8bb..8bc51c4 100644 --- a/cmd/commands/new.go +++ b/cmd/commands/new.go @@ -102,16 +102,16 @@ var NewCmd = &cobra.Command{ var style types.CleanString var styleInfo config.TemplateStyle - if tmpl.Styles != nil && len(*tmpl.Styles) == 1 { - for s, v := range *tmpl.Styles { + if len(tmpl.Styles) == 1 { + for s, v := range tmpl.Styles { style = s styleInfo = v rootDir = filepath.Join(rootDir, v.Source.String()) break } - } else if tmpl.Styles != nil { + } else { if err := huh.NewForm(huh.NewGroup( - template.PromptForStyle(*tmpl.Styles, &style, &styleInfo), + template.PromptForStyle(tmpl.Styles, &style, &styleInfo), )).WithAccessible(options.GlobalOpts.Accessible).Run(); err != nil { return errors.ToWakuError(err) } @@ -130,12 +130,12 @@ var NewCmd = &cobra.Command{ log.Debugln("resolving prompts...") extraPrompts := map[string]config.TemplatePrompt{} if tmpl.Prompts != nil { - for _, ask := range *tmpl.Prompts { + for _, ask := range tmpl.Prompts { extraPrompts[string(ask.Key)] = ask } } if tmpl.Styles != nil && styleInfo.Prompts != nil { - for _, ask := range *styleInfo.Prompts { + for _, ask := range styleInfo.Prompts { extraPrompts[string(ask.Key)] = ask } } diff --git a/pkg/config/prompts.go b/pkg/config/prompts.go index b91245f..4ddfdd0 100644 --- a/pkg/config/prompts.go +++ b/pkg/config/prompts.go @@ -37,7 +37,7 @@ type TemplatePrompts []TemplatePrompt // They prompt keys are case sensitive // and Pacal case is recommended. type TemplatePrompt struct { - Value any + value any Format *string `json:"fmt,omitempty" yaml:"fmt,omitempty"` Separator *string `json:"sep,omitempty" yaml:"sep,omitempty"` Capture *types.RegexString `json:"capture,omitempty" yaml:"capture,omitempty"` @@ -72,7 +72,7 @@ func (t *TemplatePrompt) GetPrompt(f map[string]any) *huh.Text { return err } - f[t.Key.String()] = t.Value + f[t.Key.String()] = t.value return nil }) } @@ -86,7 +86,7 @@ func (t *TemplatePrompt) Set(s string) error { return err } - t.Value = val + t.value = val case TemplatePromptTypeArray: vals := strings.Split(s, *t.Separator) @@ -99,7 +99,7 @@ func (t *TemplatePrompt) Set(s string) error { vals[i] = val } - t.Value = vals + t.value = vals default: panic(fmt.Sprintf("unexpected prompt type while setting value: %s", t.Type)) @@ -192,6 +192,7 @@ func (t *TemplatePrompt) UnmarshalYAML(node *yaml.Node) error { return err } + *t = ss return nil } diff --git a/pkg/config/styles.go b/pkg/config/styles.go index 313bdb1..33c8093 100644 --- a/pkg/config/styles.go +++ b/pkg/config/styles.go @@ -14,9 +14,9 @@ type TemplateStyles map[types.CleanString]TemplateStyle type TemplateStyle struct { Setup *TemplateSetup `json:"setup,omitempty" yaml:"setup,omitempty"` // Paths to executable files for post-setup Ignore *TemplateIgnore `json:"ignore,omitempty" yaml:"ignore,omitempty"` // The files that should be ignored when copying - Labels *TemplateLabel `json:"labels,omitempty" yaml:"labels,omitempty"` // The repository labels - Prompts *TemplatePrompts `json:"prompts,omitempty" yaml:"prompts,omitempty"` // The additional prompts to use Source types.CleanString `json:"source" yaml:"source"` // The source template path + Labels TemplateLabel `json:"labels,omitempty" yaml:"labels,omitempty"` // The repository labels + Prompts TemplatePrompts `json:"prompts,omitempty" yaml:"prompts,omitempty"` // The additional prompts to use } func (t *TemplateStyles) Validate(root string) error { diff --git a/pkg/config/template.go b/pkg/config/template.go index 4fc3787..d080352 100644 --- a/pkg/config/template.go +++ b/pkg/config/template.go @@ -2,31 +2,20 @@ package config import ( "fmt" - - "github.com/caffeine-addictt/waku/internal/types" ) // The config file type TemplateJson struct { - Setup *TemplateSetup `json:"setup,omitempty" yaml:"setup,omitempty"` // Paths to executable files for post-setup - Ignore *TemplateIgnore `json:"ignore,omitempty" yaml:"ignore,omitempty"` // The files that should be ignored when copying - Labels *TemplateLabel `json:"labels,omitempty" yaml:"labels,omitempty"` // The repository labels - Styles *TemplateStyles `json:"styles,omitempty" yaml:"styles,omitempty"` // The name of the style mapped to the path to the directory - Prompts *TemplatePrompts `json:"prompts,omitempty" yaml:"prompts,omitempty"` // The additional prompts to use - Name types.CleanString `json:"name,omitempty" yaml:"name,omitempty"` // The name of the template + Setup *TemplateSetup `json:"setup,omitempty" yaml:"setup,omitempty"` // Paths to executable files for post-setup + Ignore *TemplateIgnore `json:"ignore,omitempty" yaml:"ignore,omitempty"` // The files that should be ignored when copying + Labels TemplateLabel `json:"labels,omitempty" yaml:"labels,omitempty"` // The repository labels + Styles TemplateStyles `json:"styles" yaml:"styles"` // The name of the style mapped to the path to the directory + Prompts TemplatePrompts `json:"prompts,omitempty" yaml:"prompts,omitempty"` // The additional prompts to use } func (t *TemplateJson) Validate(root string) error { - // Ensure that `Name` is required if `Styles` is not present or empty - // If `Styles` is present, `Name` must not be present - if t.Styles == nil || len(*t.Styles) == 0 { - if t.Name == "" { - return fmt.Errorf("'name' is required when 'styles' is not present or empty") - } - } else { - if t.Name != "" { - return fmt.Errorf("'name' must not be present when 'styles' is provided") - } + if len(t.Styles) == 0 { + return fmt.Errorf("'styles' cannot be empty") } if t.Setup != nil { diff --git a/pkg/version/version.go b/pkg/version/version.go index fb91900..5f74a78 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -1,4 +1,4 @@ package version // The current app version -const Version = "0.7.0" +const Version = "0.7.1" diff --git a/template/template.json b/template/template.json deleted file mode 100644 index 66c1fad..0000000 --- a/template/template.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "$schema": "../www/docs/static/schema.json", - "styles": { - "simple github": { - "source": "simple-github", - "prompts": [ - { - "key": "User", - "type": "str", - "ask": "Your GitHub username" - }, - { - "key": "Email", - "type": "str", - "ask": "Your email address", - "validate": "^.+@.+\\..+$" - }, - { - "key": "Repo", - "type": "str", - "ask": "Your GitHub repository name" - }, - { - "key": "Description", - "type": "str", - "ask": "A brief description of your project" - }, - { - "key": "Docs", - "type": "str", - "ask": "The documentation URL of your project (leave empty if none)", - "validate": ".*" - }, - { - "key": "Assignees", - "type": "arr", - "ask": "Additional issue assignees by GitHub username", - "capture": "^\\s*@?(.*?)\\s*$", - "validate": ".*" - } - ] - } - }, - "labels": [ - { - "name": "Type: CI", - "color": "#54b2ff", - "description": "A problem or enhancement related to continuous integration." - }, - { - "name": "Type: Breaking", - "color": "#a90000", - "description": "A problem or enhancement related to a breaking change." - }, - { - "name": "Type: Bug", - "color": "#e80c0c", - "description": "Something isn't working as expected." - }, - { - "name": "Type: Enhancement", - "color": "#54b2ff", - "description": "Suggest an improvement for an existing feature." - }, - { - "name": "Type: Feature", - "color": "#54b2ff", - "description": "Suggest a new feature." - }, - { - "name": "Type: Security", - "color": "#fbff00", - "description": "A problem or enhancement related to a security issue." - }, - { - "name": "Type: Question", - "color": "#9309ab", - "description": "Request for information." - }, - { - "name": "Type: Test", - "color": "#ce54e3", - "description": "A problem or enhancement related to a test." - }, - { - "name": "Status: Awaiting Review", - "color": "#24d15d", - "description": "Ready for review." - }, - { - "name": "Status: WIP", - "color": "#07b340", - "description": "Currently being worked on." - }, - { - "name": "Status: Waiting", - "color": "#38C968", - "description": "Waiting on something else to be ready." - }, - { - "name": "Status: Stale", - "color": "#66b38a", - "description": "Has had no activity for some time." - }, - { - "name": "Status: DO NOT MERGE", - "color": "#E80C0C", - "description": "Will not be merged." - }, - { - "name": "Duplicate", - "color": "#EB862D", - "description": "Duplicate of another issue." - }, - { - "name": "Invalid", - "color": "#faef50", - "description": "This issue doesn't seem right." - }, - { - "name": "Priority: High +", - "color": "#ff008c", - "description": "Task is considered higher-priority." - }, - { - "name": "Priority: Low -", - "color": "#690a34", - "description": "Task is considered lower-priority." - }, - { - "name": "Documentation", - "color": "#2fbceb", - "description": "An issue/change with the documentation." - }, - { - "name": "Won't fix", - "color": "#C8D9E6", - "description": "Reported issue is working as intended." - }, - { - "name": "3rd party issue", - "color": "#e88707", - "description": "This issue might be caused by a 3rd party script/package/other reasons." - }, - { - "name": "Os: Windows", - "color": "#AEB1C2", - "description": "Is Windows-specific." - }, - { - "name": "Os: Mac", - "color": "#AEB1C2", - "description": "Is Mac-specific." - }, - { - "name": "Os: Linux", - "color": "#AEB1C2", - "description": "Is Linux-specific." - }, - { - "name": "Skip-Changelog", - "color": "#AEB1C2", - "description": "Skip changelog in release tag." - }, - { - "name": "help wanted", - "color": "#008672", - "description": "Help wanted." - }, - { - "name": "good first issue", - "color": "#008672", - "description": "Good first issue." - } - ] -} diff --git a/template/waku.yml b/template/waku.yml new file mode 100644 index 0000000..d713670 --- /dev/null +++ b/template/waku.yml @@ -0,0 +1,138 @@ +# yaml-language-server: $schema=../www/docs/static/schema.json + +styles: + simple github: + source: simple-github + prompts: + - key: User + type: str + ask: Your GitHub username + + - key: Email + type: str + ask: Your email address + validate: "^.+@.+\\..+$" + + - key: Repo + type: str + ask: Your GitHub repository name + + - key: Description + type: str + ask: A brief description of your project + + - key: Docs + type: str + ask: The documentation URL of your project (leave empty if none) + validate: ".*" + + - key: Assignees + type: arr + ask: Additional issue assignees by GitHub username + capture: "^\\s*@?(.*?)\\s*$" + validate: ".*" + +labels: + - name: "Type: CI" + color: "#54b2ff" + description: "A problem or enhancement related to continuous integration." + + - name: "Type: Breaking" + color: "#a90000" + description: "A problem or enhancement related to a breaking change." + + - name: "Type: Bug" + color: "#e80c0c" + description: "Something isn't working as expected." + + - name: "Type: Enhancement" + color: "#54b2ff" + description: "Suggest an improvement for an existing feature." + + - name: "Type: Feature" + color: "#54b2ff" + description: "Suggest a new feature." + + - name: "Type: Security" + color: "#fbff00" + "description": "A problem or enhancement related to a security issue." + + - name: "Type: Question" + color: "#9309ab" + description: "Request for information." + + - name: "Type: Test" + color: "#ce54e3" + description: "A problem or enhancement related to a test." + + - name: "Status: Awaiting Review" + color: "#24d15d" + description: "Ready for review." + + - name: "Status: WIP" + color: "#07b340" + description: "Currently being worked on." + + - name: "Status: Waiting" + color: "#38C968" + description: "Waiting on something else to be ready." + + - name: "Status: Stale" + color: "#66b38a" + description: "Has had no activity for some time." + + - name: "Status: DO NOT MERGE" + color: "#E80C0C" + description: "Will not be merged." + + - name: "Duplicate" + color: "#EB862D" + description: "Duplicate of another issue." + + - name: "Invalid" + color: "#faef50" + description: "This issue doesn't seem right." + + - name: "Priority: High" + color: "#ff008c" + description: "Task is considered higher-priority." + + - name: "Priority: Low -" + color: "#690a34" + description: "Task is considered lower-priority." + + - name: "Documentation" + color: "#2fbceb" + description: "An issue/change with the documentation." + + - name: "Won't fix" + color: "#C8D9E6" + description: "Reported issue is working as intended." + + - name: "3rd party issue" + color: "#e88707" + description: "This issue might be caused by a 3rd party script/package/other reasons." + + - name: "Os: Windows" + color: "#AEB1C2" + description: "Is Windows-specific." + + - name: "Os: Mac" + color: "#AEB1C2" + description: "Is Mac-specific." + + - name: "Os: Linux" + color: "#AEB1C2" + description: "Is Linux-specific." + + - name: "Skip-Changelog" + color: "#AEB1C2" + description: "Skip changelog in release tag." + + - name: "help wanted" + color: "#008672" + description: "Help wanted." + + - name: "good first issue" + color: "#008672" + description: "Good first issue." diff --git a/www/docs/blog/posts/2024-10-08-waku-v0.6.0.md b/www/docs/blog/posts/2024-10-08-waku-v0.6.0.md index f67155b..70bda19 100644 --- a/www/docs/blog/posts/2024-10-08-waku-v0.6.0.md +++ b/www/docs/blog/posts/2024-10-08-waku-v0.6.0.md @@ -25,7 +25,7 @@ Waku has a Discord server. [Join us!](https://discord.gg/NcRFkVTcaw) ## Download You can [install](../../install.md) or upgrade Waku with your favorite package manager, -or see the full release notes [here](https://github.com/caffeine-addictt/waku/releases/tag/v0.7.0). +or see the full release notes [here](https://github.com/caffeine-addictt/waku/releases/tag/v0.6.0). ## Helping out diff --git a/www/docs/configuration/introduction.md b/www/docs/configuration/introduction.md index aa613a9..6960b00 100644 --- a/www/docs/configuration/introduction.md +++ b/www/docs/configuration/introduction.md @@ -20,10 +20,10 @@ for better editor support. https://waku.ngjx.org/static/schema.json ``` -Or you can pin a specific version like `v0.7.0`: +Or you can pin a specific version like `v0.7.1`: ```text -https://raw.githubusercontent.com/caffeine-addictt/waku/v0.7.0/www/docs/static/schema.json +https://raw.githubusercontent.com/caffeine-addictt/waku/v0.7.1/www/docs/static/schema.json ``` Simply add the `$schema` property to your `configuration` file: diff --git a/www/docs/install.md b/www/docs/install.md index 11275c2..03b0454 100644 --- a/www/docs/install.md +++ b/www/docs/install.md @@ -102,17 +102,17 @@ All artifacts are checksummed, and the checksum file is signed with [cosign][]. and `checksums.txt.sig` files from the [releases][] page. ```sh - curl -O 'https://github.com/caffeine-addictt/waku/releases/download/v0.7.0/checksums.txt' + curl -O 'https://github.com/caffeine-addictt/waku/releases/download/v0.7.1/checksums.txt' ``` 1. Verify checksums signature: ```bash cosign verify-blob \ - --certificate-identity 'https://github.com/caffeine-addictt/waku/.github/workflows/release.yml@refs/tags/v0.7.0' \ + --certificate-identity 'https://github.com/caffeine-addictt/waku/.github/workflows/release.yml@refs/tags/v0.7.1' \ --certificate-oidc-issuer 'https://token.actions.githubusercontent.com' \ - --cert 'https://github.com/caffeine-addictt/waku/releases/download/v0.7.0/checksums.txt.pem' \ - --signature 'https://github.com/caffeine-addictt/waku/releases/download/v0.7.0/checksums.txt.sig' \ + --cert 'https://github.com/caffeine-addictt/waku/releases/download/v0.7.1/checksums.txt.pem' \ + --signature 'https://github.com/caffeine-addictt/waku/releases/download/v0.7.1/checksums.txt.sig' \ ./checksums.txt ``` @@ -130,7 +130,7 @@ Verify the signature: ```sh cosign verify \ - --certificate-identity 'https://github.com/caffeine-addictt/waku/.github/workflows/release.yml@refs/tags/v0.7.0' \ + --certificate-identity 'https://github.com/caffeine-addictt/waku/.github/workflows/release.yml@refs/tags/v0.7.1' \ --certificate-oidc-issuer 'https://token.actions.githubusercontent.com' \ caffeinec/waku ``` diff --git a/www/docs/static/schema.json b/www/docs/static/schema.json index cfa9915..72674fc 100644 --- a/www/docs/static/schema.json +++ b/www/docs/static/schema.json @@ -7,11 +7,6 @@ "description": "Allows a reference to a schema, typically a relative or absolute URI.", "format": "uri-reference" }, - "name": { - "type": "string", - "description": "The name of the template. Required if 'styles' is empty.", - "minLength": 1 - }, "setup": { "$ref": "#/definitions/setup" }, @@ -55,28 +50,7 @@ } } }, - "allOf": [ - { - "if": { - "required": ["styles"] - }, - "then": { - "not": { - "required": ["name"] - } - } - }, - { - "if": { - "not": { - "required": ["styles"] - } - }, - "then": { - "required": ["name"] - } - } - ], + "required": ["styles"], "additionalProperties": false, "definitions": { "setup": {