Skip to content

Commit

Permalink
feat: add MongoDB configuration and update version to 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tuhinexe committed Dec 17, 2024
1 parent 96d9d3d commit 02a5d61
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 31 deletions.
64 changes: 35 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="https://p82.cooltext.com/Rendered/Cool%20Text%20-%20OPTICAL%20467187224148174.png" />
<img src="/docs/images/optical-logo.png />
</p>

##
Expand All @@ -18,10 +18,10 @@
<img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/tuhinexe/optical/.github%2Fworkflows%2Fbuild.yml">
</a>


</h1>

<!--![Go Report Card](https://goreportcard.com/badge/github.com/tuhinexe/optical) -->

Optical is a CLI tool that generates a Go [Fiber](https://github.com/gofiber/fiber) project template. It is inspired by [express-generator](https://expressjs.com/en/starter/generator.html), a tool that produces a Node.js project template for the Express.js framework.

It is named Optical because it works with Fiber and combines 'fiber-optic'. Silly.
Expand All @@ -34,7 +34,6 @@ It is named Optical because it works with Fiber and combines 'fiber-optic'. Sill

If you do not have Go installed on your device, you are required to install it to run this tool.


You can install Optical CLI using Go:

```bash
Expand All @@ -58,36 +57,40 @@ optical -create
```bash

Optical CLI version 1.0.0
┃ What is the name of your project?(e.g 'my-fiber-api','./')
┃ A new folder with this name will be created.
> <your-project-name>
Enter your GitHub username.
This is required to create the go.mod file
> <your-gitub-username>
Do you have air installed?
Air is required for auto-reload
Yes
> No
┃ What is the name of your project?(e.g 'my-fiber-api','./')
┃ A new folder with this name will be created.
> <your-project-name>

Enter your GitHub username.
This is required to create the go.mod file
> <your-gitub-username>

Do you have air installed?
Air is required for auto-reload
Yes
> No

enter next
```

or

To get help and see all the flags:

```bash
optical -h
```

After creating the project run this:

```bash
cd <your-project-name>
go mod tidy
air
```

It will run your Fiber App and the output should look like this:

<p align="center">
<img src="https://github.com/user-attachments/assets/c7d06b42-bad8-46ec-9301-c4b0c1b637b9" />
</p>
Expand All @@ -99,28 +102,31 @@ To set up your project further, refer to the [Fiber Official Docs](https://docs.
## 🔷 Example

If you run a command like:

```bash
optical -create
```

```bash
Optical CLI version 1.0.0
┃ What is the name of your project?(e.g 'my-fiber-api','./')
┃ A new folder with this name will be created.
> cyber-fiber
Enter your GitHub username.
This is required to create the go.mod file
> tuhinexe
Do you have air installed ?
Air is required for auto-reload
Yes
> No
┃ What is the name of your project?(e.g 'my-fiber-api','./')
┃ A new folder with this name will be created.
> cyber-fiber

Enter your GitHub username.
This is required to create the go.mod file
> tuhinexe

Do you have air installed ?
Air is required for auto-reload
Yes
> No

enter next
```

It will create a new Optical project in a directory named `cyber-fiber` with `go.mod` like this :

```bash
module github.com/tuhinexe/cyber-fiber

Expand Down
Binary file added docs/images/optical-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func GenerateProject(name, path string, ghUsername string, hasAir bool) error {
"config/config.go": "config.go.tmpl",
"go.mod": "go.mod.tmpl",
".air.toml": ".air.toml.tmpl",
".env": "config.env.tmpl",
}

for filePath, templateName := range files {
Expand Down
1 change: 1 addition & 0 deletions lib/templates/config.env.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MONGO_URI=mongodb://mongo:27017/optical
2 changes: 1 addition & 1 deletion lib/templates/go.mod.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ require (
github.com/gofiber/fiber/v2 v2.52.5
github.com/joho/godotenv v1.5.1
github.com/lib/pq v1.10.9
go.mongodb.org/mongo-driver v1.16.1
go.mongodb.org/mongo-driver v1.17.1
)
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

var (
version = "1.0.0"
version = "1.1.0"
logo = `
_______ __ __ __
| |.-----.| |_|__|.----.---.-.| |
Expand Down

0 comments on commit 02a5d61

Please sign in to comment.