Skip to content

Commit 896e7c7

Browse files
authored
Merge pull request #1 from OmegaRelay/develop
0.1.1 Release
2 parents c46bd49 + 6d2e6eb commit 896e7c7

File tree

6 files changed

+68
-54
lines changed

6 files changed

+68
-54
lines changed

CHANGELOG.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
# Changelog
22

3-
## [0.1.0]
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [unreleased]
9+
10+
## [0.1.1] - 2025-08-23
11+
12+
### Changed
13+
- Updated Go to v1.23.0
14+
15+
### Fixed
16+
- Improved error messages with non-zero exit value on exit due to error
17+
- Fixed changelog not following standard
18+
- Moved west manifest back into the app directory fixing issue with west init
19+
20+
## [0.1.0] - 2025-06-05
421

522
### Added
623
- Workflows to auto create github releases
@@ -9,15 +26,21 @@
926
- Replaced template directory's custom filenames as paths with a proper filesystem that is plainly copied to output
1027
- Made initial west manifest minimal and set Zephyr version to v3.7.0 as it's the LTS stable release
1128

12-
## [0.0.2]
29+
## [0.0.2] - 2025-02-25
1330

1431
### Added
1532
- Ascii art header when running the binary
1633

1734
### Changed
1835
- Replaced flag with pflag package for better long flag handling
1936

20-
## [0.0.1]
37+
## [0.0.1] - 2025-08-09
2138

2239
### Added
2340
- Copying embedded template directory
41+
42+
[unreleased]: https://github.com/OmegaRelay/west-project-init/compare/v0.1.1...develop
43+
[0.1.1]: https://github.com/OmegaRelay/west-project-init/releases/tag/v0.1.1
44+
[0.1.0]: https://github.com/OmegaRelay/west-project-init/releases/tag/v0.1.0
45+
[0.0.2]: https://github.com/OmegaRelay/west-project-init/releases/tag/v0.0.2
46+
[0.0.1]: https://github.com/OmegaRelay/west-project-init/commit/175b965ada1c6a1e97ba410307f15939beea6e26

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.0
1+
0.1.1

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module github.com/OmegaRelay/west-project-init
22

3-
go 1.20
3+
go 1.23.0
4+
5+
toolchain go1.24.6
46

57
require github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
1-
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
2-
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
3-
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
4-
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
5-
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
6-
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
71
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
82
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
9-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
10-
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

main.go

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -65,41 +65,41 @@ func main() {
6565
args := flag.Args()
6666

6767
if len(args) == 0 {
68-
fmt.Println("Error, must provide project name")
69-
return
68+
fmt.Println("Error: must provide project name")
69+
os.Exit(1)
7070
}
7171

7272
// the first positional argument is the directory to initialise
7373
projectPath := args[0]
7474

75-
initDir(projectPath)
75+
err := initDir(projectPath)
76+
if err != nil {
77+
fmt.Printf("Error: could not init directory: %s", err)
78+
os.Exit(1)
79+
}
7680
}
7781

78-
func initDir(dirPath string) {
82+
func initDir(dirPath string) error {
7983
if dirPath == "" {
80-
fmt.Println("Error: must provide project name")
81-
return
84+
return fmt.Errorf("must provide project name")
8285
}
8386

8487
fmt.Printf("%s%s", kHeader, kDivider)
8588
err := os.Mkdir(dirPath, mkdirPerms)
8689
if err != nil {
8790
if e, ok := err.(*os.PathError); ok && e.Err != syscall.EEXIST {
88-
fmt.Println(err)
89-
return
91+
return err
9092
}
9193
}
9294

9395
err = os.Chdir(dirPath)
9496
if err != nil {
95-
fmt.Println(err)
96-
return
97+
return err
9798
}
9899

99100
templateContents, err := templateFs.ReadDir("template")
100101
if err != nil {
101-
fmt.Println(err)
102-
return
102+
return err
103103
}
104104

105105
fmt.Printf("Copying template directory...\n")
@@ -108,55 +108,33 @@ func initDir(dirPath string) {
108108

109109
err = runCmd("git", "init")
110110
if err != nil {
111-
fmt.Println(err)
112-
return
111+
return err
113112
}
114113

115114
err = runCmd("python3", "-m", "venv", ".venv")
116115
if err != nil {
117-
fmt.Println(err)
118-
return
116+
return err
119117
}
120118

121119
pipExe := ".venv/bin/pip"
122120
for _, requirement := range pythonRequirements {
123121
err = runCmd(pipExe, "install", requirement)
124122
if err != nil {
125-
fmt.Println(err)
126-
return
123+
return err
127124
}
128125
}
129126

130-
err = runCmd(".venv/bin/west", "init", "-l", "zephyr")
127+
err = runCmd(".venv/bin/west", "init", "-l", "app")
131128
if err != nil {
132-
fmt.Println(err)
133-
return
129+
return err
134130
}
135131

136132
fmt.Printf("%s", kDivider)
137133
fmt.Printf("Project setup complete!\n\n")
138-
fmt.Printf("Add required third party projects through zephyr/west.yml\n")
134+
fmt.Printf("Add required third party projects through app/west.yml\n")
139135
fmt.Printf("Run `source .venv/bin/activate` to set the project's virtual environment\n")
140136
fmt.Printf("Run `west update` to update the project\n")
141-
}
142-
143-
// Keywords within @@ symbols are replaced with dynamic components
144-
func replaceKeyWords(b []byte) (ret []byte, err error) {
145-
array := bytes.Split(b, []byte("@"))
146-
147-
for index, val := range array {
148-
if index%2 != 1 {
149-
continue
150-
}
151-
switch string(val) {
152-
case "PROJECT_NAME":
153-
array[index] = []byte(path.Base(projectPath))
154-
default:
155-
continue
156-
}
157-
}
158-
ret = bytes.Join(array, nil)
159-
return
137+
return nil
160138
}
161139

162140
func copyTemplateContents(path string, entries []fs.DirEntry) {
@@ -192,6 +170,25 @@ func copyTemplateContents(path string, entries []fs.DirEntry) {
192170
}
193171
}
194172

173+
// Keywords within @@ symbols are replaced with dynamic components
174+
func replaceKeyWords(b []byte) (ret []byte, err error) {
175+
array := bytes.Split(b, []byte("@"))
176+
177+
for index, val := range array {
178+
if index%2 != 1 {
179+
continue
180+
}
181+
switch string(val) {
182+
case "PROJECT_NAME":
183+
array[index] = []byte(path.Base(projectPath))
184+
default:
185+
continue
186+
}
187+
}
188+
ret = bytes.Join(array, nil)
189+
return
190+
}
191+
195192
// Wrapper around exec.Command to start, attach and print output of the command
196193
func runCmd(command string, arg ...string) error {
197194
cmd := exec.Command(command, arg...)
File renamed without changes.

0 commit comments

Comments
 (0)