diff --git a/.github/workflows/verify-all-committed.yml b/.github/workflows/verify-all-committed.yml
new file mode 100644
index 0000000..4e507c1
--- /dev/null
+++ b/.github/workflows/verify-all-committed.yml
@@ -0,0 +1,21 @@
+name: Verify template changes are committed
+on: [push]
+jobs:
+ verify:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-go@v5
+ with:
+ go-version: '1.23'
+ - name: Generate and format code
+ run: |
+ go generate ./...
+ go fmt ./...
+ - name: Check for changes
+ run: |
+ if [ -n "$(git status --porcelain)" ]; then
+ echo "Generated files are not up to date!"
+ git status
+ exit 1
+ fi
\ No newline at end of file
diff --git a/docs/README.md b/docs/README.md
index 3b8385f..b14c647 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -95,36 +95,12 @@ You need to have Go 1.16 or newer on your machine.
## How to use
-Go 1.17 and later:
+Run:
```go
go run github.com/shpota/goxygen@latest init my-app
```
-
- Older versions of Go
-
-### Go 1.16
-
-Set the `GO111MODULE` environment variable to `auto`.
-```
-export GO111MODULE=auto
-```
-Run
-```go
-go get -u github.com/shpota/goxygen
-go run github.com/shpota/goxygen init my-app
-```
-
-### Go 1.11 - 1.15
-
-Run
-```go
-go get -u github.com/shpota/goxygen
-go run github.com/shpota/goxygen init my-app
-```
-
-
This generates a project in `my-app` folder.
By default, it will use React and MongoDB. You can select
diff --git a/docs/README_by.md b/docs/README_by.md
index 86e7303..ea51d2b 100644
--- a/docs/README_by.md
+++ b/docs/README_by.md
@@ -101,9 +101,9 @@ export GO111MODULE=auto
## Выкарыстанне
```go
-go get -u github.com/shpota/goxygen
-go run github.com/shpota/goxygen init my-app
+go run github.com/shpota/goxygen@latest init my-app
```
+
У выніку будзе згенераваны праект у дырэкторыі `my-app`.
React і MongoDB выкарыстоўваецца па змаўчанню. Вы
@@ -112,7 +112,7 @@ React і MongoDB выкарыстоўваецца па змаўчанню. Вы
Напрыклад, гэтая каманда створыць праект з Vue і PostgreSQL:
```go
-go run github.com/shpota/goxygen init --frontend vue --db postgres my-app
+go run github.com/shpota/goxygen@latest init --frontend vue --db postgres my-app
```
Сцяг `--frontend` прымае `angular`, `react` або ` vue`.
diff --git a/docs/README_es.md b/docs/README_es.md
index e706910..63a0834 100644
--- a/docs/README_es.md
+++ b/docs/README_es.md
@@ -87,22 +87,12 @@ y te ofrece los archivos necesarios para que docker componga los entornos de des
-## Requirements
-Necesitas tener instalado Go 1.16 o posterior en tu equipo.
-
-The `GO111MODULE` environment variable has to be set to `auto`
-for the generation logic to work. It is a default for Go
-versions up to 1.15. For Go 1.16, you need to set it explicitly:
-```
-export GO111MODULE=auto
-```
-
## Como se usa
```go
-go get -u github.com/shpota/goxygen
-go run github.com/shpota/goxygen init my-app
+go run github.com/shpota/goxygen@latest init my-app
```
+
Este codigo genera un proyecto en el directorio ``my-app``.
By default, it will use React and MongoDB. You can select
@@ -111,7 +101,7 @@ a different front end framework and a database using
will create a project with Vue and PostgreSQL:
```go
-go run github.com/shpota/goxygen init --frontend vue --db postgres my-app
+go run github.com/shpota/goxygen@latest init --frontend vue --db postgres my-app
```
The `--frontend` flag accepts `angular`, `react` and `vue`.
diff --git a/docs/README_fr.md b/docs/README_fr.md
index 6a56039..e9b1a3f 100644
--- a/docs/README_fr.md
+++ b/docs/README_fr.md
@@ -88,21 +88,10 @@ dans des environnements de développement et de production.
-## Requirements
-Vous devez disposer de la version 1.16 ou supérieure de Go sur votre machine.
-
-The `GO111MODULE` environment variable has to be set to `auto`
-for the generation logic to work. It is a default for Go
-versions up to 1.15. For Go 1.16, you need to set it explicitly:
-```
-export GO111MODULE=auto
-```
-
## Guide d'utilisation
```go
-go get -u github.com/shpota/goxygen
-go run github.com/shpota/goxygen init my-app
+go run github.com/shpota/goxygen@latest init my-app
```
Ces commandes génèrent un projet dans le dossier `my-app`.
@@ -113,7 +102,7 @@ utilisant les flags `--frontend` et `--db`. Par exemple, cette
commande va créer un projet avec Vue et PostreSQL:
```go
-go run github.com/shpota/goxygen init --frontend vue --db postgres my-app
+go run github.com/shpota/goxygen@latest init --frontend vue --db postgres my-app
```
Le flag `--frontend` accepte les valeurs `angular`, `react` and `vue`.
diff --git a/docs/README_he.md b/docs/README_he.md
index fb93b13..08f352f 100644
--- a/docs/README_he.md
+++ b/docs/README_he.md
@@ -100,20 +100,13 @@ Goxygen מג'נרט back-end בשפת Go, מחבר אותו עם הרכיבים
## Requirements
עליכם להתקין Go 1.16 ומעלה במחשב שלכם.
-The `GO111MODULE` environment variable has to be set to `auto`
-for the generation logic to work. It is a default for Go
-versions up to 1.15. For Go 1.16, you need to set it explicitly:
-```
-export GO111MODULE=auto
-```
-
## איך להשתמש
```go
-go get -u github.com/shpota/goxygen
-go run github.com/shpota/goxygen init my-app
+go run github.com/shpota/goxygen@latest init my-app
```
+
פקודה זו תייצר פרויקט בתיקיית `my-app`.
@@ -127,7 +120,7 @@ go run github.com/shpota/goxygen init my-app
```go
-go run github.com/shpota/goxygen init --frontend vue --db postgres my-app
+go run github.com/shpota/goxygen@latest init --frontend vue --db postgres my-app
```
diff --git a/docs/README_id.md b/docs/README_id.md
index ae8ff3e..5553dae 100644
--- a/docs/README_id.md
+++ b/docs/README_id.md
@@ -94,19 +94,13 @@ dan fase produksi.
## Requirements
Anda harus mempunyai Go versi 1.16 atau yang lebih pada mesin Anda.
-The `GO111MODULE` environment variable has to be set to `auto`
-for the generation logic to work. It is a default for Go
-versions up to 1.15. For Go 1.16, you need to set it explicitly:
-```
-export GO111MODULE=auto
-```
## Cara penggunaan
```go
-go get -u github.com/shpota/goxygen
-go run github.com/shpota/goxygen init my-app
+go run github.com/shpota/goxygen@latest init my-app
```
+
Ini akan meng-generate sebuah projek di dalam `my-app` folder.
By default, it will use React and MongoDB. You can select
@@ -115,7 +109,7 @@ a different front end framework and a database using
will create a project with Vue and PostgreSQL:
```go
-go run github.com/shpota/goxygen init --frontend vue --db postgres my-app
+go run github.com/shpota/goxygen@latest init --frontend vue --db postgres my-app
```
The `--frontend` flag accepts `angular`, `react` and `vue`.
diff --git a/docs/README_jp.md b/docs/README_jp.md
index 1f05e27..35b2b0e 100644
--- a/docs/README_jp.md
+++ b/docs/README_jp.md
@@ -91,17 +91,9 @@ Goxygen は、新しいプロジェクトを始める際の時間の節約を目
## Requirements
Go 1.16 以上が必要です。
-The `GO111MODULE` environment variable has to be set to `auto`
-for the generation logic to work. It is a default for Go
-versions up to 1.15. For Go 1.16, you need to set it explicitly:
-```
-export GO111MODULE=auto
-```
-
## 使用方法
```go
-go get -u github.com/shpota/goxygen
-go run github.com/shpota/goxygen init my-app
+go run github.com/shpota/goxygen@latest init my-app
```
`my-app` プロジェクトを `my-app` フォルダに生成します。
@@ -111,7 +103,7 @@ go run github.com/shpota/goxygen init my-app
例えば、次のコマンドは Vue と PostgreSQL を含むプロジェクト作成します:
```go
-go run github.com/shpota/goxygen init --frontend vue --db postgres my-app
+go run github.com/shpota/goxygen@latest init --frontend vue --db postgres my-app
```
`--frontend` フラグは、`angular` や `react`、`vue` を受け取ります。
diff --git a/docs/README_ko.md b/docs/README_ko.md
index 7c4abc1..9697830 100644
--- a/docs/README_ko.md
+++ b/docs/README_ko.md
@@ -89,17 +89,9 @@ Goxygen은 사용자가 새로운 프로젝트를 설정하는데 필요한 시
## Requirements
사용자는 Go 1.16 또는 그 이상의 버젼이 필요합니다.
-The `GO111MODULE` environment variable has to be set to `auto`
-for the generation logic to work. It is a default for Go
-versions up to 1.15. For Go 1.16, you need to set it explicitly:
-```
-export GO111MODULE=auto
-```
-
## 사용하는 방법
```go
-go get -u github.com/shpota/goxygen
-go run github.com/shpota/goxygen init my-app
+go run github.com/shpota/goxygen@latest init my-app
```
`my-app` 폴더에 프로젝트를 생성합니다.
@@ -107,7 +99,7 @@ go run github.com/shpota/goxygen init my-app
다른 프런트엔드 프레임워크와 데이터베이스를 선택하고 싶다면 `--frontend`와 `--db` 플래그를 사용합니다. 예를 들어 아래의 명령은 Vue와 PostgreSQL을 사용하여 프로젝트를 생성합니다:
```go
-go run github.com/shpota/goxygen init --frontend vue --db postgres my-app
+go run github.com/shpota/goxygen@latest init --frontend vue --db postgres my-app
```
The `--frontend` flag accepts `angular`, `react` and `vue`.
diff --git a/docs/README_pt-br.md b/docs/README_pt-br.md
index f63ad9a..2c23a19 100644
--- a/docs/README_pt-br.md
+++ b/docs/README_pt-br.md
@@ -94,35 +94,10 @@ Você precisa de Go 1.16 ou mais recente na sua máquina.
## Como utilizar
-Go 1.17 e posterior:
```go
go run github.com/shpota/goxygen@latest init my-app
```
-
- Versões anteriores de Go
-
-### Go 1.16
-
-Configure a variável de ambiente `GO111MODULE` como `auto`.
-```
-export GO111MODULE=auto
-```
-Rode os comandos
-```go
-go get -u github.com/shpota/goxygen
-go run github.com/shpota/goxygen init my-app
-```
-
-### Go 1.11 - 1.15
-
-Rode os comandos
-```go
-go get -u github.com/shpota/goxygen
-go run github.com/shpota/goxygen init my-app
-```
-
-
Isso gera um projeto no diretório `my-app`.
Por padrão, será usado React e MongoDB. Você pode selecionar
@@ -131,7 +106,7 @@ os argumentos `--frontend` e `--db`. Por exemplo, este comando
criará um projeto usando Vue e PostgreSQL:
```go
-go run github.com/shpota/goxygen init --frontend vue --db postgres my-app
+go run github.com/shpota/goxygen@latest init --frontend vue --db postgres my-app
```
O argumento `--frontend` aceita as opções `angular`, `react` e `vue`.
diff --git a/docs/README_tr.md b/docs/README_tr.md
index 78964b8..3ae8b13 100644
--- a/docs/README_tr.md
+++ b/docs/README_tr.md
@@ -87,20 +87,12 @@ Goxygen, yeni bir proje oluştururken sizin zamandan tasarruf etmenize odaklanı
Makinenizde Go 1.16 veya daha yenisine sahip olmanız gerekmektedir.
-`GO111MODULE` ortam değişkeni üretim mantığının çalışması için `auto` olarak ayarlanmalıdır. Bu ayar, Go 1.15'e kadar olan sürümlerde varsayılan ayardır. Ancak, Go 1.16 için, bunu açıkça ayarlamanız gerekmektedir:
-
-```
-export GO111MODULE=auto
-```
-
## Nasıl Kullanılır
Çalıştır:
```go
-go get -u github.com/shpota/goxygen
-go run github.com/shpota/goxygen init my-app
-
+go run github.com/shpota/goxygen@latest init my-app
```
`my-app` klasöründe bir proje oluşturur.
@@ -108,7 +100,7 @@ go run github.com/shpota/goxygen init my-app
Varsayılan olarak React ve MongoDB'yi kullanacaktır. Farklı bir front-end framework'ü ve veritabanını `--frontend` ve `--db` flag'lerini kullanarak seçebilirsin. Örneğin bu komut Vue ve PostgreSQL ile bir proje oluşturacaktır:
```go
-go run github.com/shpota/goxygen init --frontend vue --db postgres my-app
+go run github.com/shpota/goxygen@latest init --frontend vue --db postgres my-app
```
`--frontend` flag'i `angular`, `react` ve `vue` değerlerini kabul eder.
diff --git a/docs/README_ua.md b/docs/README_ua.md
index 9e042aa..cd0ea1a 100644
--- a/docs/README_ua.md
+++ b/docs/README_ua.md
@@ -91,17 +91,9 @@ production середовищі.
## Вимоги
Ви повинні мати Go 1.16 або новішу версію на вашому комп'ютері.
-Змінна оточення `GO111MODULE` має бути встановлена в `auto`
-для того, щоб згенерувати проєкт. Це значення за замовчанням
-для версій Go до 1.15. Для 1.16 її треба встановити явно:
-```
-export GO111MODULE=auto
-```
-
## Як користуватися
```go
-go get -u github.com/shpota/goxygen
-go run github.com/shpota/goxygen init my-app
+go run github.com/shpota/goxygen@latest init my-app
```
В результаті буде згенеровано проєкт в папці `my-app`.
@@ -111,7 +103,7 @@ React і MongoDB використовуються за замовчанням.
Наступна команда генерує проєкт з Vue та PostgreSQL:
```go
-go run github.com/shpota/goxygen init --frontend vue --db postgres my-app
+go run github.com/shpota/goxygen@latest init --frontend vue --db postgres my-app
```
Параметер `--frontend` може бути встановленим в `angular`, `react` та `vue`.
diff --git a/docs/README_zh.md b/docs/README_zh.md
index 4a4ca9b..582ab17 100644
--- a/docs/README_zh.md
+++ b/docs/README_zh.md
@@ -85,17 +85,9 @@ Goxygen致力于节省你搭建一个项目的时间。它自动生成一个完
## Requirements
你需要安装Go 1.16或者更新的版本。
-The `GO111MODULE` environment variable has to be set to `auto`
-for the generation logic to work. It is a default for Go
-versions up to 1.15. For Go 1.16, you need to set it explicitly:
-```
-export GO111MODULE=auto
-```
-
# 如何使用
```go
-go get -u github.com/shpota/goxygen
-go run github.com/shpota/goxygen init my-app
+go run github.com/shpota/goxygen@latest init my-app
```
这会在你的 `my-app` 目录下生成一个项目。
@@ -105,7 +97,7 @@ a different front end framework and a database using
will create a project with Vue and PostgreSQL:
```go
-go run github.com/shpota/goxygen init --frontend vue --db postgres my-app
+go run github.com/shpota/goxygen@latest init --frontend vue --db postgres my-app
```
The `--frontend` flag accepts `angular`, `react` and `vue`.
diff --git a/main.go b/main.go
index 0df9ed1..e2ada39 100644
--- a/main.go
+++ b/main.go
@@ -1,5 +1,7 @@
package main
+//go:generate go run transform/transformer.go
+
import (
"github.com/shpota/goxygen/cli"
"github.com/shpota/goxygen/codegen"
diff --git a/transform/transformer.go b/transform/transformer.go
index 1756717..928de06 100644
--- a/transform/transformer.go
+++ b/transform/transformer.go
@@ -8,15 +8,19 @@ import (
"log"
"os"
"path/filepath"
+ "runtime"
"sort"
"strconv"
"strings"
)
func main() {
+ _, filename, _, _ := runtime.Caller(0)
+ projectRoot := filepath.Join(filepath.Dir(filename), "..")
+
var buffer bytes.Buffer
buffer.WriteString(prefix)
- textFiles, images := contentFromFiles("../templates")
+ textFiles, images := contentFromFiles(filepath.Join(projectRoot, "templates"))
for _, path := range sortedFilePaths(textFiles) {
writeTextFile(path, textFiles[path], &buffer)
}
@@ -25,12 +29,12 @@ func main() {
writeImage(path, images[path], &buffer)
}
buffer.WriteString(suffix)
- createSourceFile("../static/generated.go", buffer.Bytes())
+ createSourceFile(filepath.Join(projectRoot, "static", "generated.go"), buffer.Bytes())
log.Println("Completed.")
}
func createSourceFile(path string, content []byte) {
- pkgDir := filepath.Join("..", "static")
+ pkgDir := filepath.Dir(path)
_ = os.MkdirAll(pkgDir, os.ModePerm)
err := os.WriteFile(path, content, 0644)
if err != nil {