Skip to content

Commit

Permalink
new output styles, new versioning system
Browse files Browse the repository at this point in the history
  • Loading branch information
costaluu committed Sep 27, 2024
1 parent b1ca6d8 commit 3abc47e
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 40 deletions.
27 changes: 23 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ jobs:
with:
go-version: 1.23

- name: Retrieve current version
id: get_version
run: |
VERSION=$(echo "${{ secrets.CURRENT_VERSION }}" | cut -d 'v' -f 2)
MAJOR=$(echo $VERSION | cut -d '.' -f 1)
MINOR=$(echo $VERSION | cut -d '.' -f 2)
PATCH=$(echo $VERSION | cut -d '.' -f 3)
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="v$MAJOR.$MINOR.$NEW_PATCH"
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Build for Linux, macOS, and Windows
run: |
GIT_WORKSPACE="${{ github.workspace }}"
Expand All @@ -32,13 +43,13 @@ jobs:
cd $GIT_WORKSPACE/src # Change to the src directory
# Build for Linux
GOOS=linux GOARCH=amd64 go build -trimpath -o $OUTPUT_DIR/linux/$BINARY_NAME
GOOS=linux GOARCH=amd64 go build -ldflags="-X main.VERSION=${{ env.NEW_VERSION }}" -trimpath -o $OUTPUT_DIR/linux/$BINARY_NAME
# Build for macOS
GOOS=darwin GOARCH=amd64 go build -trimpath -o $OUTPUT_DIR/macos/$BINARY_NAME
GOOS=darwin GOARCH=amd64 go build -ldflags="-X main.VERSION=${{ env.NEW_VERSION }}" -trimpath -o $OUTPUT_DIR/macos/$BINARY_NAME
# Build for Windows
GOOS=windows GOARCH=amd64 go build -trimpath -o $OUTPUT_DIR/windows/$BINARY_NAME.exe
GOOS=windows GOARCH=amd64 go build -ldflags="-X main.VERSION=${{ env.NEW_VERSION }}" -trimpath -o $OUTPUT_DIR/windows/$BINARY_NAME.exe
# Zip only the linux, macos, and windows folders without the full path
cd $OUTPUT_DIR
Expand All @@ -60,7 +71,7 @@ jobs:

- name: Set Release Version
id: set_version
run: echo "RELEASE_VERSION=$(date +'%Y%m%d.%H%M%S')" >> $GITHUB_ENV
run: echo "RELEASE_VERSION=${{ env.NEW_VERSION }}" >> $GITHUB_ENV

- name: Create Release
id: create_release
Expand Down Expand Up @@ -102,3 +113,11 @@ jobs:
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update Version Secret
run: |
curl -X PATCH \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/actions/secrets/CURRENT_VERSION \
-d '{"encrypted_value":"v$MAJOR.$MINOR.$NEW_PATCH"}'
5 changes: 3 additions & 2 deletions src/commands/delimeter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/costaluu/flag/constants"
"github.com/costaluu/flag/core"
"github.com/costaluu/flag/logger"
"github.com/costaluu/flag/utils"
"github.com/urfave/cli/v2"
)

Expand Down Expand Up @@ -38,7 +39,7 @@ var DelimeterSetCommand *cli.Command = &cli.Command{

core.SetDelimeter(extension, args[1], args[2])

logger.Success[string](fmt.Sprintf("delimeter for file extension %s seted", extension))
logger.Success[string](fmt.Sprintf("delimeter for file extension %s seted", utils.AccentTextUnderLine(extension)))

return nil
},
Expand Down Expand Up @@ -67,7 +68,7 @@ var DelimeterDeleteCommand *cli.Command = &cli.Command{

core.DeleteDelimeter(extension)

logger.Success[string](fmt.Sprintf("delimeter for file extension %s deleted", extension))
logger.Success[string](fmt.Sprintf("delimeter for file extension %s deleted", utils.AccentTextUnderLine(extension)))

return nil
},
Expand Down
1 change: 0 additions & 1 deletion src/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "github.com/charmbracelet/lipgloss"
var (
APP_NAME = "flag"
COMMAND = "flag"
VERSION = "v0.0.7"
MIN_FEATURE_CHARACTERS = 5
ID_LENGTH = 25
)
Expand Down
18 changes: 4 additions & 14 deletions src/core/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,7 @@ func ListBlocksFromPath(path string) []types.BlockFeature {
}

func BlockDetails(path string) {
var style =
lipgloss.
NewStyle().
SetString(path).
Foreground(lipgloss.Color(constants.AccentColor)).
Underline(true).
Bold(true)


fmt.Printf("%s\n", style.Render())
fmt.Printf("%s\n", utils.AccentTextUnderLine(path))

blocks := ListBlocksFromPath(path)

Expand Down Expand Up @@ -578,7 +569,7 @@ func ToggleBlockFeature(featureName string, state string) {
}
}

logger.Success[string](fmt.Sprintf("feature %s toggled %s", featureName, state))
logger.Success[string](fmt.Sprintf("feature %s toggled %s", utils.AccentTextUnderLine(featureName), state))
}

func PromoteBlockFeature(featureName string) {
Expand Down Expand Up @@ -657,8 +648,7 @@ func PromoteBlockFeature(featureName string) {
filesystem.FileDeleteFolder(filepath.Join(rootDir, ".features", "blocks", hashedPath))
}
}

logger.Success[string](fmt.Sprintf("feature %s promoted", featureName))
logger.Success[string](fmt.Sprintf("feature %s promoted", utils.AccentTextUnderLine(featureName)))
}

func DemoteBlockFeature(featureName string) {
Expand Down Expand Up @@ -738,5 +728,5 @@ func DemoteBlockFeature(featureName string) {
}
}

logger.Success[string](fmt.Sprintf("feature %s demoted", featureName))
logger.Success[string](fmt.Sprintf("feature %s demoted", utils.AccentTextUnderLine(featureName)))
}
26 changes: 8 additions & 18 deletions src/core/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func VersionUpdateBase(path string, finalMessage bool) {
BuildBaseForFile(path)

if finalMessage {
logger.Success[string](fmt.Sprintf("%s version base updated", path))
logger.Success[string](fmt.Sprintf("%s version base updated", utils.AccentTextUnderLine(path)))
}
}

Expand Down Expand Up @@ -245,7 +245,7 @@ func VersionBase(path string, skipForm bool) {

filesystem.FileCopy(filepath.Join(rootDir, path), filepath.Join(rootDir, ".features", "versions", hashedPath, "base"))

logger.Success[string](fmt.Sprintf("%s is now a version base", path))
logger.Success[string](fmt.Sprintf("%s is now a version base", utils.AccentTextUnderLine(path)))
}

func VersionNewFeature(path string, name string, skipForm bool, finalMessage bool) {
Expand Down Expand Up @@ -322,7 +322,7 @@ func VersionNewFeature(path string, name string, skipForm bool, finalMessage boo
BuildBaseForFile(path)

if finalMessage {
logger.Success[string](fmt.Sprintf("saved record for %s with feature %s", path, newFeature.Name))
logger.Success[string](fmt.Sprintf("saved record for %s with feature %s", utils.AccentTextUnderLine(path), utils.AccentTextUnderLine(newFeature.Name)))
}
}

Expand Down Expand Up @@ -451,7 +451,7 @@ func VersionSave(path string, finalMessage bool) {
BuildBaseForFile(path)

if finalMessage {
logger.Success[string](fmt.Sprintf("Saved to %s", selected.ItemTitle))
logger.Success[string](fmt.Sprintf("Saved to %s", utils.AccentTextUnderLine(selected.ItemTitle)))
}
}

Expand Down Expand Up @@ -553,7 +553,7 @@ func VersionDelete(path string, finalMessage bool) {
BuildBaseForFile(path)

if finalMessage {
logger.Success[string](fmt.Sprintf("deleted feature %s on %s", selectedStringName, path))
logger.Success[string](fmt.Sprintf("deleted feature %s on %s", utils.AccentTextUnderLine(selectedStringName), utils.AccentTextUnderLine(path)))
}
}

Expand Down Expand Up @@ -800,7 +800,7 @@ func RebaseFile(path string, finalMessage bool) {
BuildBaseForFile(path)

if finalMessage {
logger.Success[string](fmt.Sprintf("%s rebased", path))
logger.Success[string](fmt.Sprintf("%s rebased", utils.AccentTextUnderLine(path)))
}
}

Expand Down Expand Up @@ -830,11 +830,10 @@ func AllVersionFeatureDetails() {
lipgloss.
NewStyle().
Padding(0, 1).
SetString("VersionsFeature report").
SetString("Versions report").
Background(lipgloss.Color(constants.AccentColor)).
Foreground(lipgloss.Color("255")).
Bold(true)


fmt.Printf("\n\n%s\n\n", titleStyle.Render())

Expand Down Expand Up @@ -930,16 +929,7 @@ func VersionFeatureDetailsFromPath(path string) {
return len(data[i][0]) > len(data[j][0])
})

var style =
lipgloss.
NewStyle().
SetString(path).
Foreground(lipgloss.Color(constants.AccentColor)).
Underline(true).
Bold(true)


fmt.Printf("%s\n", style.Render())
fmt.Printf("%s\n", utils.AccentTextUnderLine(path))

table.RenderTable(headers, data)
}
Expand Down
4 changes: 3 additions & 1 deletion src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import (
"github.com/costaluu/flag/constants"
"github.com/urfave/cli/v2"
)

var VERSION = "dev"

func main() {
app := &cli.App{
Name: constants.APP_NAME,
Version: constants.VERSION,
Version: VERSION,
Authors: []*cli.Author{
&cli.Author{
Name: "costaluu",
Expand Down
16 changes: 16 additions & 0 deletions src/utils/styles.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package utils

import (
"github.com/charmbracelet/lipgloss"
"github.com/costaluu/flag/constants"
)

func AccentTextUnderLine(message string) string {
return lipgloss.
NewStyle().
Padding(0, 1).
SetString(message).
Background(lipgloss.Color(constants.AccentColor)).
Foreground(lipgloss.Color("255")).
Bold(true).Render()
}

0 comments on commit 3abc47e

Please sign in to comment.