Skip to content

Commit 42fee43

Browse files
authoredApr 3, 2025··
fix: Templating failing (#209)
Signed-off-by: AlexNg <[email protected]>
1 parent eb61bf7 commit 42fee43

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed
 

Diff for: ‎cmd/commands/new.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ var NewCmd = &cobra.Command{
219219
}
220220
log.Debugf("final template data: %v\n", finalTemplateData)
221221

222-
return WriteFiles(tmpDir, projectRootDir, filePathsToWrite, licenseText, finalTemplateData, licenseTmpl)
222+
return WriteFiles(rootDir, projectRootDir, filePathsToWrite, licenseText, finalTemplateData, licenseTmpl)
223223
})
224224
if err != nil {
225225
return errors.NewWakuErrorf("failed to write files: %s\n", err)

Diff for: ‎internal/template/resource.go

+14-12
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func GetStyleResources(c *config.TemplateJson, s *config.TemplateStyle, configPa
4949
ignoreRules = ResolveGlobs(ignoreRules, types.NewSet(".git/"))
5050
log.Debugf("ignore rules: %v\n", ignoreRules)
5151

52-
includePaths := make(map[string]string, len(s.Includes)) // includePath: dir
52+
includePaths := make(map[string]*config.TemplateInclude, len(s.Includes)) // includePath: dir
5353
if s.Includes != nil {
5454
for _, includePath := range s.Includes {
5555
log.Infof("include path: %s\n", includePath.Source.String())
@@ -60,11 +60,7 @@ func GetStyleResources(c *config.TemplateJson, s *config.TemplateStyle, configPa
6060

6161
log.Debugf("resolved include paths: %v\n", inPths)
6262
for p := range inPths {
63-
if includePath.Directory == nil {
64-
includePaths[filepath.Join(includePath.Source.String(), p)] = ""
65-
} else {
66-
includePaths[filepath.Join(includePath.Source.String(), p)] = includePath.Directory.String()
67-
}
63+
includePaths[filepath.Join(includePath.Source.String(), p)] = &includePath
6864
}
6965
}
7066
}
@@ -87,19 +83,25 @@ func GetStyleResources(c *config.TemplateJson, s *config.TemplateStyle, configPa
8783

8884
resources := make([]types.StyleResource, 0, len(filteredPaths))
8985
for v := range filteredPaths {
90-
parts := strings.Split(v, "/")
91-
projPath := strings.Join(parts[min(len(parts), 1):], "/")
86+
var projPath string
9287

93-
if dirPrepend, ok := includePaths[v]; ok {
94-
projPath = filepath.Join(dirPrepend, projPath)
88+
if include, ok := includePaths[v]; ok {
89+
projPath = strings.TrimPrefix(v, include.Source.String()+"/")
90+
if include.Directory != nil {
91+
projPath = filepath.Join(include.Directory.String(), projPath)
92+
}
9593

9694
// skip if found in style list
97-
searchPath := filepath.Join(s.Source.String(), projPath)
98-
if stylePaths.Contains(searchPath) {
95+
expectedStyleRelPath := filepath.Join(s.Source.String(), projPath)
96+
if stylePaths.Contains(expectedStyleRelPath) {
9997
continue
10098
}
10199
}
102100

101+
if projPath == "" {
102+
projPath = strings.TrimPrefix(v, s.Source.String()+"/")
103+
}
104+
103105
resources = append(resources, types.StyleResource{
104106
TemplateResourceRelPath: v,
105107
TemplatedProjectRelPath: projPath,

Diff for: ‎pkg/version/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
package version
22

33
// The current app version
4-
const Version = "0.9.0-alpha1"
4+
const Version = "0.9.0-alpha2"

Diff for: ‎scripts/version_bump.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
VERSION=$1
44
VERSION_FILES="README.md pkg/version/version.go"
55
VERSION_DIRS="www/docs scripts"
6-
CURRENT_VERSION=$(grep -oP 'const Version = "\K[\d\.]+' 'pkg/version/version.go' | head -n 1)
6+
CURRENT_VERSION=$(grep -oP 'const Version = "\K[\d\w\-\.]+' 'pkg/version/version.go' | head -n 1)
77
SEMVER_REGEX=$(grep -oP "MustCompile\(\`\K.+(?=\`\))" "pkg/version/version_test.go" | head -n 1)
88

99
if [[ -z "$VERSION" ]]; then

0 commit comments

Comments
 (0)
Please sign in to comment.