Skip to content

Commit

Permalink
feat: remove nanoid, remove prints
Browse files Browse the repository at this point in the history
  • Loading branch information
costaluu committed Sep 20, 2024
1 parent ef6aed1 commit ade1de4
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .features/blocks/testte/0425d93af137876a700909982.block
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "0425d93af137876a700909982",
"name": "myFeature",
"state": "DEV",
"synced": true,
"swapContent": ""
}
7 changes: 7 additions & 0 deletions .features/blocks/testte/d86c5b75ada871b079894a3ac.block
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "d86c5b75ada871b079894a3ac",
"name": "myFeature",
"state": "DEV",
"synced": true,
"swapContent": ""
}
34 changes: 34 additions & 0 deletions .features/delimeters
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
".cc": {
"start": "// ",
"end": " //"
},
".cpp": {
"start": "// ",
"end": " //"
},
".go": {
"start": "// ",
"end": " //"
},
".html": {
"start": "\u003c!-- ",
"end": " --\u003e"
},
".py": {
"start": "# ",
"end": " #"
},
".xml": {
"start": "\u003c!-- ",
"end": " --\u003e"
},
".xqy": {
"start": "(:~ ",
"end": " ~:)"
},
"default": {
"start": "// ",
"end": " //"
}
}
5 changes: 0 additions & 5 deletions src/bubbletea/components/fileiterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func (m IteratorModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// Everything's been installed. We're done!
m.done = true

fmt.Println("finalizou terminou")
return m, tea.Sequence(
tea.Printf("%s %s", constants.CheckMark.Render(), path.Path), // print the last success message
tea.Quit, // exit the program
Expand Down Expand Up @@ -114,11 +113,7 @@ func FileIterator(list []types.FilePathCategory, run func (parameter types.FileP

model := newIteratorModel(list, runner)

fmt.Println("file operator comecou")

if _, err := tea.NewProgram(model).Run(); err != nil {
logger.Fatal[error](err)
}

fmt.Println("file operator terminou")
}
9 changes: 2 additions & 7 deletions src/core/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/costaluu/flag/table"
"github.com/costaluu/flag/types"
"github.com/costaluu/flag/utils"
gonanoid "github.com/matoous/go-nanoid/v2"
)

func ExtractMatchDataFromFile(path string) []types.Match {
Expand Down Expand Up @@ -44,13 +43,9 @@ func ExtractMatchDataFromFile(path string) []types.Match {
foundId = true
id = match[3]
} else {
nanoId, err := gonanoid.New(16)

if err != nil {
logger.Fatal[error](err)
}
salt := utils.GetCurrentUnixTimestampInMs()

id = utils.GenerateId(path, feature, nanoId)
id = utils.GenerateId(path, feature, salt)
}

var featureContent string
Expand Down
4 changes: 0 additions & 4 deletions src/core/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,5 @@ func Sync() {
}
}

fmt.Println("sync comecou")

components.FileIterator(arrayFile, runner)

fmt.Println("sync terminou")
}
10 changes: 10 additions & 0 deletions src/utils/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
"encoding/json"
"os"
"path/filepath"
"strconv"
"strings"
"time"

"github.com/costaluu/flag/constants"
filesystem "github.com/costaluu/flag/fs"
Expand Down Expand Up @@ -47,6 +49,14 @@ func GenerateCheckSumFromString(str string) string {
return hex.EncodeToString(hash.Sum(nil))
}

func GetCurrentUnixTimestampInMs() string {
// Get the current time and convert it to milliseconds
timestampMs := time.Now().UnixNano() / int64(time.Millisecond)

// Convert the timestamp to a string
return strconv.FormatInt(timestampMs, 10)
}

func GenerateId(seeds ...string) string {
hash := sha256.Sum256([]byte(strings.Join(seeds, "")))
hexHash := hex.EncodeToString(hash[:])
Expand Down
11 changes: 11 additions & 0 deletions testte
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @feature(myFeature) 0425d93af137876a700909982 //
teste
// @default(myFeature) 0425d93af137876a700909982 //
teste
// !feature //

// @feature(myFeature) d86c5b75ada871b079894a3ac //
teste
// @default(myFeature) d86c5b75ada871b079894a3ac //
teste
// !feature //

0 comments on commit ade1de4

Please sign in to comment.