startmeow 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/StartMeow +0 -0
- package/debug.log +3 -0
- package/go.mod +28 -0
- package/go.sum +44 -0
- package/internal/README.md +1 -0
- package/internal/generator.go +99 -0
- package/internal/projbuilder.go +188 -0
- package/internal/prompts.go +138 -0
- package/internal/queue.go +57 -0
- package/internal/states.go +88 -0
- package/internal/tui/debug.log +5 -0
- package/internal/tui/go.sum +44 -0
- package/internal/tui/models/app.go +260 -0
- package/internal/tui/models/help.go +54 -0
- package/internal/tui/models/question.go +34 -0
- package/internal/tui/styles/style.go +82 -0
- package/internal/types.go +78 -0
- package/internal/userinterface_string.go +26 -0
- package/main.go +60 -0
- package/manifest.json +5 -0
- package/manifests/manifest.json +7 -0
- package/package.json +28 -0
- package/templates/backend/README.md +1 -0
- package/templates/backend/express/README.md.tmpl +9 -0
- package/templates/backend/express/index.js.tmpl +13 -0
- package/templates/backend/express/package.json.tmpl +11 -0
- package/templates/frontend/README.md +1 -0
- package/templates/ui/README.md +1 -0
- package/templates/ui/blog/home.tsx.tmpl +53 -0
- package/templates/ui/blog/index.html +48 -0
- package/templates/ui/blog/page.tsx +45 -0
- package/templates/ui/blog/page.tsx.tmpl +45 -0
- package/templates/ui/download/home.tsx.tmpl +53 -0
- package/templates/ui/download/index.html +51 -0
- package/templates/ui/download/manifest.json +5 -0
- package/templates/ui/download/page.tsx +49 -0
- package/templates/ui/download/page.tsx.tmpl +49 -0
- package/templates/ui/landing/home.tsx.tmpl +55 -0
- package/templates/ui/landing/index.html +53 -0
- package/templates/ui/landing/page.tsx +51 -0
- package/templates/ui/landing/page.tsx.tmpl +51 -0
- package/templates/ui/store/home.tsx.tmpl +49 -0
- package/templates/ui/store/index.html +47 -0
- package/templates/ui/store/page.tsx +45 -0
- package/templates/ui/store/page.tsx.tmpl +45 -0
- package/test-project/README.md +36 -0
- package/test-project/app/favicon.ico +0 -0
- package/test-project/app/globals.css +26 -0
- package/test-project/app/layout.tsx +34 -0
- package/test-project/app/page.tsx +49 -0
- package/test-project/eslint.config.mjs +18 -0
- package/test-project/next.config.ts +7 -0
- package/test-project/package-lock.json +6593 -0
- package/test-project/package.json +26 -0
- package/test-project/postcss.config.mjs +7 -0
- package/test-project/public/file.svg +1 -0
- package/test-project/public/globe.svg +1 -0
- package/test-project/public/next.svg +1 -0
- package/test-project/public/vercel.svg +1 -0
- package/test-project/public/window.svg +1 -0
- package/test-project/tsconfig.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# StartMeow
|
package/StartMeow
ADDED
|
Binary file
|
package/debug.log
ADDED
package/go.mod
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module StartMeow
|
|
2
|
+
|
|
3
|
+
go 1.25.3
|
|
4
|
+
|
|
5
|
+
require (
|
|
6
|
+
charm.land/bubbles/v2 v2.0.0
|
|
7
|
+
charm.land/bubbletea/v2 v2.0.2
|
|
8
|
+
charm.land/lipgloss/v2 v2.0.2
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
require (
|
|
12
|
+
github.com/atotto/clipboard v0.1.4 // indirect
|
|
13
|
+
github.com/charmbracelet/colorprofile v0.4.3 // indirect
|
|
14
|
+
github.com/charmbracelet/ultraviolet v0.0.0-20260309091805-903bfd0cf188 // indirect
|
|
15
|
+
github.com/charmbracelet/x/ansi v0.11.6 // indirect
|
|
16
|
+
github.com/charmbracelet/x/term v0.2.2 // indirect
|
|
17
|
+
github.com/charmbracelet/x/termios v0.1.1 // indirect
|
|
18
|
+
github.com/charmbracelet/x/windows v0.2.2 // indirect
|
|
19
|
+
github.com/clipperhouse/displaywidth v0.11.0 // indirect
|
|
20
|
+
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
|
|
21
|
+
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
|
|
22
|
+
github.com/mattn/go-runewidth v0.0.21 // indirect
|
|
23
|
+
github.com/muesli/cancelreader v0.2.2 // indirect
|
|
24
|
+
github.com/rivo/uniseg v0.4.7 // indirect
|
|
25
|
+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
|
26
|
+
golang.org/x/sync v0.20.0 // indirect
|
|
27
|
+
golang.org/x/sys v0.42.0 // indirect
|
|
28
|
+
)
|
package/go.sum
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
charm.land/bubbles/v2 v2.0.0 h1:tE3eK/pHjmtrDiRdoC9uGNLgpopOd8fjhEe31B/ai5s=
|
|
2
|
+
charm.land/bubbles/v2 v2.0.0/go.mod h1:rCHoleP2XhU8um45NTuOWBPNVHxnkXKTiZqcclL/qOI=
|
|
3
|
+
charm.land/bubbletea/v2 v2.0.2 h1:4CRtRnuZOdFDTWSff9r8QFt/9+z6Emubz3aDMnf/dx0=
|
|
4
|
+
charm.land/bubbletea/v2 v2.0.2/go.mod h1:3LRff2U4WIYXy7MTxfbAQ+AdfM3D8Xuvz2wbsOD9OHQ=
|
|
5
|
+
charm.land/lipgloss/v2 v2.0.2 h1:xFolbF8JdpNkM2cEPTfXEcW1p6NRzOWTSamRfYEw8cs=
|
|
6
|
+
charm.land/lipgloss/v2 v2.0.2/go.mod h1:KjPle2Qd3YmvP1KL5OMHiHysGcNwq6u83MUjYkFvEkM=
|
|
7
|
+
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
|
|
8
|
+
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
|
|
9
|
+
github.com/aymanbagabas/go-udiff v0.4.1 h1:OEIrQ8maEeDBXQDoGCbbTTXYJMYRCRO1fnodZ12Gv5o=
|
|
10
|
+
github.com/aymanbagabas/go-udiff v0.4.1/go.mod h1:0L9PGwj20lrtmEMeyw4WKJ/TMyDtvAoK9bf2u/mNo3w=
|
|
11
|
+
github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q=
|
|
12
|
+
github.com/charmbracelet/colorprofile v0.4.3/go.mod h1:/zT4BhpD5aGFpqQQqw7a+VtHCzu+zrQtt1zhMt9mR4Q=
|
|
13
|
+
github.com/charmbracelet/ultraviolet v0.0.0-20260309091805-903bfd0cf188 h1:J8v4kWJYCaxv1SLhLunN74S+jMteZ1f7Dae99ioq4Bo=
|
|
14
|
+
github.com/charmbracelet/ultraviolet v0.0.0-20260309091805-903bfd0cf188/go.mod h1:FzWNAbe1jEmI+GZljSnlaSA8wJjnNIZhWBLkTsAl6eg=
|
|
15
|
+
github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8=
|
|
16
|
+
github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ=
|
|
17
|
+
github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f h1:pk6gmGpCE7F3FcjaOEKYriCvpmIN4+6OS/RD0vm4uIA=
|
|
18
|
+
github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f/go.mod h1:IfZAMTHB6XkZSeXUqriemErjAWCCzT0LwjKFYCZyw0I=
|
|
19
|
+
github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=
|
|
20
|
+
github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
|
|
21
|
+
github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY=
|
|
22
|
+
github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo=
|
|
23
|
+
github.com/charmbracelet/x/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2/jYn2GuM=
|
|
24
|
+
github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k=
|
|
25
|
+
github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8=
|
|
26
|
+
github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
|
|
27
|
+
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
|
|
28
|
+
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
|
|
29
|
+
github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag=
|
|
30
|
+
github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
|
31
|
+
github.com/mattn/go-runewidth v0.0.21 h1:jJKAZiQH+2mIinzCJIaIG9Be1+0NR+5sz/lYEEjdM8w=
|
|
32
|
+
github.com/mattn/go-runewidth v0.0.21/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
|
33
|
+
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
|
|
34
|
+
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
|
|
35
|
+
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
|
36
|
+
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
|
37
|
+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
|
38
|
+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
|
39
|
+
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
|
|
40
|
+
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
|
|
41
|
+
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
|
42
|
+
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
|
43
|
+
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
|
|
44
|
+
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Backend of StartMeow
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
package internal
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"fmt"
|
|
6
|
+
"os"
|
|
7
|
+
"path/filepath"
|
|
8
|
+
"text/template"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
type Context struct {
|
|
12
|
+
ProjectName string
|
|
13
|
+
Force bool
|
|
14
|
+
Template string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type Manifest struct {
|
|
18
|
+
Files map[string]string `json: "files"`
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Create the map from the manifest json file
|
|
22
|
+
func loadManifest(path string) (*Manifest, error) {
|
|
23
|
+
data, err := os.ReadFile(path)
|
|
24
|
+
if err != nil {
|
|
25
|
+
return nil, err
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var m Manifest
|
|
29
|
+
if err := json.Unmarshal(data, &m); err != nil {
|
|
30
|
+
return nil, err
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return &m, nil
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
func RenderTemplate(src, dest string, ctx Context) error {
|
|
37
|
+
// If the template given by user exist, load it, otherwise err and return
|
|
38
|
+
tmpl, err := template.ParseFiles(src)
|
|
39
|
+
if err != nil {
|
|
40
|
+
return err
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//
|
|
44
|
+
if err := os.MkdirAll(filepath.Dir(dest), 0755); err != nil {
|
|
45
|
+
return err
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// overwrites file if it exists, f is created file
|
|
49
|
+
f, err := os.Create(dest)
|
|
50
|
+
if err != nil {
|
|
51
|
+
return err
|
|
52
|
+
}
|
|
53
|
+
defer f.Close()
|
|
54
|
+
|
|
55
|
+
return tmpl.Execute(f, ctx)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
func GenerateProject(ctx Context) error {
|
|
59
|
+
// Load the generated Manifest file
|
|
60
|
+
manifest, err := loadManifest("manifest.json")
|
|
61
|
+
if err != nil {
|
|
62
|
+
return err
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Raise error if the project directory already exists and --force flag is not set
|
|
66
|
+
if _, err := os.Stat(ctx.ProjectName); err == nil && !ctx.Force {
|
|
67
|
+
return fmt.Errorf("directory %s already exists (use --force to overwrite)", ctx.ProjectName)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
for src, dest := range manifest.Files {
|
|
71
|
+
|
|
72
|
+
srcPath := src
|
|
73
|
+
destPath := dest
|
|
74
|
+
|
|
75
|
+
if err := RenderTemplate(srcPath, destPath, ctx); err != nil {
|
|
76
|
+
return err
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return nil
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
func GenerateManifest(fileMap map[string]string, outputPath string) error {
|
|
84
|
+
manifest := Manifest{Files: make(map[string]string)}
|
|
85
|
+
|
|
86
|
+
for src, dest := range fileMap {
|
|
87
|
+
manifest.Files[src] = dest
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Convert manifest to JSON
|
|
91
|
+
data, err := json.MarshalIndent(manifest, "", " ")
|
|
92
|
+
if err != nil {
|
|
93
|
+
return err
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Write manifest.json to the output path
|
|
97
|
+
fmt.Printf("Writing manifest to %s \n", outputPath)
|
|
98
|
+
return os.WriteFile(outputPath, data, 0644)
|
|
99
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
package internal
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"fmt"
|
|
6
|
+
"os"
|
|
7
|
+
"os/exec"
|
|
8
|
+
"strings"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
func BuildProject(proj *Project) {
|
|
12
|
+
|
|
13
|
+
switch proj.ProjType {
|
|
14
|
+
case WebApp:
|
|
15
|
+
fmt.Println("Building Web App")
|
|
16
|
+
BuildWebApp(proj)
|
|
17
|
+
case ClientServer:
|
|
18
|
+
BuildClientServer(proj)
|
|
19
|
+
case Terminal:
|
|
20
|
+
BuildTerminal(proj)
|
|
21
|
+
case Mobile:
|
|
22
|
+
BuildMobile(proj)
|
|
23
|
+
default:
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
func BuildWebApp(proj *Project) {
|
|
30
|
+
|
|
31
|
+
if proj.FrontFrame == React {
|
|
32
|
+
fmt.Println("Building React")
|
|
33
|
+
switch proj.BackFrame {
|
|
34
|
+
|
|
35
|
+
//Use npx to make, then replace page.tsx
|
|
36
|
+
case NextJS:
|
|
37
|
+
selections := MakeTemplatePaths(proj)
|
|
38
|
+
build := exec.Command("npx", "create-next-app@latest", proj.ProjName)
|
|
39
|
+
|
|
40
|
+
buffer := bytes.Buffer{}
|
|
41
|
+
buffer.Write([]byte("\n"))
|
|
42
|
+
build.Stdin = &buffer
|
|
43
|
+
|
|
44
|
+
build.Stdout = os.Stdout
|
|
45
|
+
build.Stderr = os.Stderr
|
|
46
|
+
|
|
47
|
+
err := build.Run()
|
|
48
|
+
if err != nil {
|
|
49
|
+
fmt.Fprintln(os.Stderr, err)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//FIX THIS ONCE FUNCTION IS UPDATED!
|
|
53
|
+
GenerateManifest(selections, "manifest.json")
|
|
54
|
+
|
|
55
|
+
var context = makeContext(proj)
|
|
56
|
+
|
|
57
|
+
fmt.Println("Making Project!!")
|
|
58
|
+
GenerateProject(context)
|
|
59
|
+
|
|
60
|
+
//Use npx to make, then replace page.tsx
|
|
61
|
+
case ReactRouter:
|
|
62
|
+
selections := MakeTemplatePaths(proj)
|
|
63
|
+
build := exec.Command("npx", "create-react-router@latest", "--template", "remix-run/react-router-templates/minimal", fmt.Sprint("./"+proj.ProjName))
|
|
64
|
+
|
|
65
|
+
buffer := bytes.Buffer{}
|
|
66
|
+
buffer.Write([]byte("\x1b[C\n"))
|
|
67
|
+
build.Stdin = &buffer
|
|
68
|
+
|
|
69
|
+
buffer.Reset()
|
|
70
|
+
|
|
71
|
+
buffer.Write([]byte("\n"))
|
|
72
|
+
build.Stdin = &buffer
|
|
73
|
+
|
|
74
|
+
build.Stdout = os.Stdout
|
|
75
|
+
build.Stderr = os.Stderr
|
|
76
|
+
|
|
77
|
+
err := build.Run()
|
|
78
|
+
if err != nil {
|
|
79
|
+
fmt.Fprintln(os.Stderr, err)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
GenerateManifest(selections, "manifest.json")
|
|
83
|
+
|
|
84
|
+
var context = makeContext(proj)
|
|
85
|
+
|
|
86
|
+
GenerateProject(context)
|
|
87
|
+
|
|
88
|
+
//Use npx to make react client, then make server with manifest.json
|
|
89
|
+
case ExpressJs:
|
|
90
|
+
selections := MakeTemplatePaths(proj)
|
|
91
|
+
build := exec.Command("npx", "create-react-app", "client")
|
|
92
|
+
|
|
93
|
+
build.Stdout = os.Stdout
|
|
94
|
+
build.Stderr = os.Stderr
|
|
95
|
+
|
|
96
|
+
err := build.Run()
|
|
97
|
+
if err != nil {
|
|
98
|
+
fmt.Fprintln(os.Stderr, err)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//FIX THIS ONCE FUNCTION IS UPDATED!
|
|
102
|
+
GenerateManifest(selections, "manifest.json")
|
|
103
|
+
|
|
104
|
+
var context = makeContext(proj)
|
|
105
|
+
|
|
106
|
+
GenerateProject(context)
|
|
107
|
+
|
|
108
|
+
default:
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
} else {
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
func BuildClientServer(proj *Project) {
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
func BuildTerminal(proj *Project) {
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
func BuildMobile(proj *Project) {
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
func MakeTemplatePaths(proj *Project) map[string]string {
|
|
130
|
+
fmt.Println("Building Map")
|
|
131
|
+
|
|
132
|
+
mapping := make(map[string]string)
|
|
133
|
+
|
|
134
|
+
switch proj.ProjType {
|
|
135
|
+
case WebApp:
|
|
136
|
+
if proj.FrontFrame == React {
|
|
137
|
+
|
|
138
|
+
switch proj.BackFrame {
|
|
139
|
+
|
|
140
|
+
case NextJS:
|
|
141
|
+
mapping[fmt.Sprintf("templates/ui/%s/page.tsx.tmpl", strings.ToLower(proj.Ui.String()))] = fmt.Sprintf("%s/app/page.tsx", proj.ProjName)
|
|
142
|
+
|
|
143
|
+
case ReactRouter:
|
|
144
|
+
mapping[fmt.Sprintf("templates/ui/%s/home.tsx.tmpl", strings.ToLower(proj.Ui.String()))] = fmt.Sprintf("%s/app/routes/home.tsx", proj.ProjName)
|
|
145
|
+
|
|
146
|
+
case ExpressJs:
|
|
147
|
+
mapping[fmt.Sprintf("templates/ui/%s/App.js.tmpl", strings.ToLower(proj.Ui.String()))] = fmt.Sprintf("%s/app/App.js", proj.ProjName)
|
|
148
|
+
mapping["templates/backend/express/index.js.tmpl"] = "server/index.js"
|
|
149
|
+
mapping["templates/backend/express/package.json.tmpl"] = "server/package.json"
|
|
150
|
+
|
|
151
|
+
default:
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
} else {
|
|
155
|
+
|
|
156
|
+
switch proj.BackFrame {
|
|
157
|
+
|
|
158
|
+
case NodeJS:
|
|
159
|
+
|
|
160
|
+
case ExpressJs:
|
|
161
|
+
|
|
162
|
+
default:
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
case ClientServer:
|
|
169
|
+
case Terminal:
|
|
170
|
+
case Mobile:
|
|
171
|
+
default:
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return mapping
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
func makeContext(proj *Project) (context Context) {
|
|
179
|
+
fmt.Println("Building Context")
|
|
180
|
+
|
|
181
|
+
context = Context{
|
|
182
|
+
ProjectName: proj.ProjName,
|
|
183
|
+
Force: true,
|
|
184
|
+
Template: "",
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return context
|
|
188
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
package internal
|
|
2
|
+
|
|
3
|
+
import "fmt"
|
|
4
|
+
|
|
5
|
+
func InitPrompts() Queue {
|
|
6
|
+
q := InitQueue()
|
|
7
|
+
q.Enqueue(AppType)
|
|
8
|
+
|
|
9
|
+
UpdateProjectState(WebappState)
|
|
10
|
+
// fmt.Println("Initiating the prompts proj stat: " + projectState.prompts[0].Question)
|
|
11
|
+
fmt.Println("INIT OF QEUUE")
|
|
12
|
+
fmt.Println(q)
|
|
13
|
+
return q
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
func StateRouter(promptqueue *Queue, answer Prompt) Prompt {
|
|
17
|
+
// first split decision (frontend into react or null)
|
|
18
|
+
|
|
19
|
+
// decided to compare questions because they are unique (pray to God)
|
|
20
|
+
if answer.Input == "React" && projectState.prompts[0].Question == "Pick an Application" {
|
|
21
|
+
fmt.Println("Case 1")
|
|
22
|
+
promptqueue.Enqueue(BackendFrameworkReact)
|
|
23
|
+
promptqueue.Enqueue(StartingUI)
|
|
24
|
+
promptqueue.Enqueue(WhichDB)
|
|
25
|
+
UpdateProjectState(WhichDBState)
|
|
26
|
+
fmt.Println("End of case 1")
|
|
27
|
+
//end of config section
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// the no react route
|
|
31
|
+
if answer.Input == "no" && projectState.prompts[0].Question == "Choose a backend framework" {
|
|
32
|
+
fmt.Println("Case 2")
|
|
33
|
+
promptqueue.Enqueue(BackendFramework)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// no react no backend framework
|
|
37
|
+
if answer.Input == "None" && projectState.prompts[0].Question == "Choose a language for your backend" {
|
|
38
|
+
fmt.Println("Case 3")
|
|
39
|
+
promptqueue.Enqueue(WhichLanguage)
|
|
40
|
+
promptqueue.Enqueue(StartingUI)
|
|
41
|
+
promptqueue.Enqueue(WhichDB)
|
|
42
|
+
//end of config section
|
|
43
|
+
} else {
|
|
44
|
+
fmt.Println("Case 4")
|
|
45
|
+
promptqueue.Enqueue(StartingUI)
|
|
46
|
+
promptqueue.Enqueue(WhichDB)
|
|
47
|
+
//end of config section
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
p := promptqueue.Dequeue()
|
|
51
|
+
fmt.Println(promptqueue.List)
|
|
52
|
+
return p
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// first question
|
|
56
|
+
var AppType = Prompt{
|
|
57
|
+
Question: "Pick an Application",
|
|
58
|
+
PromptType: Select,
|
|
59
|
+
Options: []string{
|
|
60
|
+
"Web app",
|
|
61
|
+
"Client/Server",
|
|
62
|
+
"Mobile",
|
|
63
|
+
"Terminal",
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// second question
|
|
68
|
+
var FrontendFrameworkType = Prompt{
|
|
69
|
+
Question: "Do you want a React frontend framework?",
|
|
70
|
+
PromptType: Select,
|
|
71
|
+
Options: []string{
|
|
72
|
+
"yes",
|
|
73
|
+
"no",
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// if it's yes queue these prompts
|
|
78
|
+
var BackendFrameworkReact = Prompt{
|
|
79
|
+
Question: "Choose a backend React framework",
|
|
80
|
+
PromptType: Select,
|
|
81
|
+
Options: []string{
|
|
82
|
+
"Nextjs",
|
|
83
|
+
"ReactRouter",
|
|
84
|
+
"Express",
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// if no, queue the non framework prompts
|
|
89
|
+
var BackendFramework = Prompt{
|
|
90
|
+
Question: "Choose a backend framework",
|
|
91
|
+
PromptType: Select,
|
|
92
|
+
Options: []string{
|
|
93
|
+
"Express",
|
|
94
|
+
"Node",
|
|
95
|
+
"None",
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// this queues if the no react backend framework option was "none"
|
|
100
|
+
var WhichLanguage = Prompt{
|
|
101
|
+
Question: "Choose a language for your backend",
|
|
102
|
+
PromptType: Select,
|
|
103
|
+
Options: []string{
|
|
104
|
+
"C",
|
|
105
|
+
"Javascript",
|
|
106
|
+
"Typescript",
|
|
107
|
+
"Go",
|
|
108
|
+
"C++",
|
|
109
|
+
"Java",
|
|
110
|
+
"Swift",
|
|
111
|
+
"Kotlin",
|
|
112
|
+
"CSharp",
|
|
113
|
+
"Jsx",
|
|
114
|
+
},
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// WhichLanguage, BackendFramework, BackendFrameworkReact all queue this prompt after
|
|
118
|
+
var StartingUI = Prompt{
|
|
119
|
+
Question: "Pick a starting UI",
|
|
120
|
+
PromptType: Select,
|
|
121
|
+
Options: []string{
|
|
122
|
+
"Store",
|
|
123
|
+
"Download",
|
|
124
|
+
"Blog",
|
|
125
|
+
"Empty",
|
|
126
|
+
},
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// this comes after starting UI prompt
|
|
130
|
+
var WhichDB = Prompt{
|
|
131
|
+
Question: "end of cycle into new section",
|
|
132
|
+
PromptType: Select,
|
|
133
|
+
Options: []string{
|
|
134
|
+
"MongoDB",
|
|
135
|
+
"SQLite",
|
|
136
|
+
"None",
|
|
137
|
+
},
|
|
138
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
package internal
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
type Queue struct {
|
|
8
|
+
List []Prompt
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
func InitQueue() Queue {
|
|
12
|
+
|
|
13
|
+
return Queue{
|
|
14
|
+
List: make([]Prompt, 0),
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
func (q *Queue) Enqueue(item Prompt) {
|
|
19
|
+
// fmt.Println("enqueue called: " + item.Question)
|
|
20
|
+
|
|
21
|
+
q.List = append(q.List, item)
|
|
22
|
+
|
|
23
|
+
fmt.Println("WHATS IN")
|
|
24
|
+
fmt.Println(q.List)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
func (q *Queue) Dequeue() Prompt {
|
|
28
|
+
fmt.Print("dequeue called: ")
|
|
29
|
+
|
|
30
|
+
if len(q.List) == 0 {
|
|
31
|
+
fmt.Println("Queue Empty")
|
|
32
|
+
return Prompt{
|
|
33
|
+
Question: "ERROR, QUEUE EMPTY",
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var item = q.List[0]
|
|
38
|
+
|
|
39
|
+
q.remove()
|
|
40
|
+
q.resize()
|
|
41
|
+
|
|
42
|
+
fmt.Println(item.Question)
|
|
43
|
+
return item
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
func (q *Queue) remove() []Prompt {
|
|
47
|
+
|
|
48
|
+
return append(q.List[:0], q.List[1:]...)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
func (q *Queue) resize() {
|
|
52
|
+
|
|
53
|
+
var new_size = len(q.List) - 1
|
|
54
|
+
var new_list = q.List[0:new_size]
|
|
55
|
+
|
|
56
|
+
q.List = new_list
|
|
57
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
package internal
|
|
2
|
+
|
|
3
|
+
type state struct {
|
|
4
|
+
answers map[string]state
|
|
5
|
+
prompts []Prompt
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
func UpdateProjectState(newState state) {
|
|
9
|
+
projectState = newState
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Comparison state
|
|
13
|
+
var projectState = state{
|
|
14
|
+
prompts: []Prompt{},
|
|
15
|
+
answers: make(map[string]state),
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
var WebappState = state{
|
|
19
|
+
prompts: []Prompt{AppType},
|
|
20
|
+
answers: map[string]state{
|
|
21
|
+
"yes": FrontendState,
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 2 options state
|
|
26
|
+
var FrontendState = state{
|
|
27
|
+
prompts: []Prompt{FrontendFrameworkType},
|
|
28
|
+
answers: map[string]state{
|
|
29
|
+
"yes": BackendFrameworkReactState,
|
|
30
|
+
"no": BackendFrameworkState,
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
var BackendFrameworkReactState = state{
|
|
35
|
+
prompts: []Prompt{BackendFrameworkReact},
|
|
36
|
+
answers: map[string]state{
|
|
37
|
+
"React": StarterUIState,
|
|
38
|
+
"Nextjs": StarterUIState,
|
|
39
|
+
"Express": StarterUIState,
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var StarterUIState = state{
|
|
44
|
+
prompts: []Prompt{StartingUI},
|
|
45
|
+
answers: map[string]state{
|
|
46
|
+
"Store": WhichDBState,
|
|
47
|
+
"Download": WhichDBState,
|
|
48
|
+
"Blog": WhichDBState,
|
|
49
|
+
"Empty": WhichDBState,
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// start of 'no' frontend framework path
|
|
54
|
+
var BackendFrameworkState = state{
|
|
55
|
+
prompts: []Prompt{WhichLanguage, StartingUI},
|
|
56
|
+
answers: map[string]state{
|
|
57
|
+
"Node": StarterUIState,
|
|
58
|
+
"Express": StarterUIState,
|
|
59
|
+
"None": WhichLanguageState,
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
var WhichLanguageState = state{
|
|
64
|
+
prompts: []Prompt{WhichLanguage},
|
|
65
|
+
answers: map[string]state{
|
|
66
|
+
"C": StarterUIState,
|
|
67
|
+
"Javascript": StarterUIState,
|
|
68
|
+
"Typescript": StarterUIState,
|
|
69
|
+
"Go": StarterUIState,
|
|
70
|
+
"C++": StarterUIState,
|
|
71
|
+
"Java": StarterUIState,
|
|
72
|
+
"Swift": StarterUIState,
|
|
73
|
+
"Kotlin": StarterUIState,
|
|
74
|
+
"CSharp": StarterUIState,
|
|
75
|
+
"Jsp": StarterUIState,
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var WhichDBState = state{
|
|
80
|
+
prompts: []Prompt{WhichDB},
|
|
81
|
+
answers: map[string]state{
|
|
82
|
+
"MongoDB": emptyState,
|
|
83
|
+
"SQLite": emptyState,
|
|
84
|
+
"None": emptyState,
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
var emptyState = state{}
|