Skip to content

Commit

Permalink
first mvp
Browse files Browse the repository at this point in the history
  • Loading branch information
costaluu committed Sep 14, 2024
1 parent 5a4e8c5 commit b90bb62
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/core/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@ func PromoteBlockFeature(featureName string) {

for path, blockList := range blocksSet {
featuresMatch := ExtractMatchDataFromFile(filepath.Join(rootDir, path))

normalizedPath := utils.HashFilePath(path)

for _, block := range blockList {
if block.State == constants.STATE_DEV || block.State == constants.STATE_ON {
var foundFeatureById *types.Match = nil
Expand Down Expand Up @@ -611,10 +612,15 @@ func PromoteBlockFeature(featureName string) {

ReplaceStringInFile(filepath.Join(rootDir, path), oldString, newString)
}

normalizedPath := utils.HashFilePath(path)

filesystem.RemoveFile(filepath.Join(rootDir, ".features", "blocks", normalizedPath, fmt.Sprintf("%s.block", block.Id)))
}

blocks := ListBlocksFromPath(path)

if len(blocks) == 0 {
filesystem.FileDeleteFolder(filepath.Join(rootDir, ".features", "blocks", normalizedPath))
}
}

logger.Success[string](fmt.Sprintf("feature %s promoted", featureName))
Expand Down Expand Up @@ -646,6 +652,7 @@ func DemoteBlockFeature(featureName string) {

for path, blockList := range blocksSet {
featuresMatch := ExtractMatchDataFromFile(filepath.Join(rootDir, path))
normalizedPath := utils.HashFilePath(path)

for _, block := range blockList {
if block.State == constants.STATE_DEV || block.State == constants.STATE_OFF {
Expand Down Expand Up @@ -686,9 +693,14 @@ func DemoteBlockFeature(featureName string) {
ReplaceStringInFile(filepath.Join(rootDir, path), oldString, newString)
}

normalizedPath := utils.HashFilePath(path)
filesystem.RemoveFile(filepath.Join(rootDir, ".features", "blocks", normalizedPath, fmt.Sprintf("%s.block", block.Id)))
}

blocks := ListBlocksFromPath(path)

if len(blocks) == 0 {
filesystem.FileDeleteFolder(filepath.Join(rootDir, ".features", "blocks", normalizedPath))
}
}

logger.Success[string](fmt.Sprintf("feature %s demoted", featureName))
Expand Down

0 comments on commit b90bb62

Please sign in to comment.