diff --git a/.gitignore b/.gitignore index 11fc819..30e7175 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ coverage.out dist/ tmp/ /data +.DS_Store # Created in the workflows but need to be ignored node_modules/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 24e4012..0bfef96 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,12 +24,3 @@ Once those are installed, run `make setup` to perform the repository setup. This project uses [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0-beta.4/) to enable better overview over changes and enables automated tooling based on commit messages. - -## Releases & Versioning - -Releases are fully automated and happen on every _feature_ and _bug fix_ that is merged into the `main` branch. - -Versioning strictly adheres to [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html) with the following additions: - -- If the Envelope Zero backend or frontend are updated, the version bump is the same as for the dependency that is updated -- If a release with only dependency updates is made, it incerases the `PATCH` version. diff --git a/README.md b/README.md index 958f605..155f7fe 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,15 @@ Download the latest release and start the executable. -Then, open [http://localhost:3200](http://localhost:3200) in your browser. +## Backing up of data -Envelope Zero will create a directory `data` with a file `gorm.db`. This is the database of everything you enter into Envelope Zero, keep it safe! -If you want to move the executable to another directory, you must also move the `data` directory with it, it always has to be in the same directory. +Envelope Zero will create an `envelope-zero` directory in the standard application data directory for your operating system. This is the following: + +- Windows: `%APPDATA%/envelope-zero` +- macOS: `~/Library/Application Support/envelope-zero` +- Other Unix based systems: `~/.local/share/envelope-zero` + +If you back up this directory, all Envelope Zero data is backed up. ## Supported Versions @@ -19,6 +24,26 @@ This software is constantly developed, therefore only the latest version is supp Please check the [releases page](https://github.com/envelope-zero/standalone/releases) for the latest release. +## Versioning + +This project uses [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html). This means that the version has three parts: `major.minor.patch`. +Releases are fully automated and happen on every _feature_ and _bug fix_ that is merged into the `main` branch. + +The versions increase as follows: + +- The **major** version increases when there are breaking changes, meaning that the behavior of the software changes compared to an earlier version (unless that behavior was wrong, then it's a **patch** version increase). Please check the [upgrading documentation](docs/upgrading.md) before updating major versions! +- The **minor** version increases when there are new features +- The **patch** version increases when bugs are fixed. +- If the Envelope Zero backend or frontend are updated, the version bump is the same as for the dependency that is updated +- If a release with only dependency updates is made, it bumps the `PATCH` version. + +Whenever a version increases, all numbers to the right of it are reset to 0. + +The following things are looked at for versioning (called “public API” in Semantic Versioning): + +- Location of the data on your computer +- Behavior of the application, e.g. how budget values are calculated, including new features + ## Contributing Please see [the contribution guidelines](CONTRIBUTING.md). diff --git a/docs/upgrading.md b/docs/upgrading.md new file mode 100644 index 0000000..4f72a8b --- /dev/null +++ b/docs/upgrading.md @@ -0,0 +1,17 @@ +# Upgrading + +This document describes breaking changes and manual actions required on major upgrades. + +## v1.1.0 to v2.0.0 + +The data directory has moved to the standard application data directory. To upgrade, follow the instructions here. + +Stop the software by closing the console window and rename the `data/gorm.db` file to `envelope-zero.db` + +Now, move the file to the directories described below depending on your operating system. + +- on Windows: `%APPDATA%/envelope-zero` +- on macOS: `~/Library/Application Support/envelope-zero` +- on all other Unix based systems: `~/.local/share/envelope-zero` + +You will need to create the `envelope-zero` directory before copying the file into it. diff --git a/go.mod b/go.mod index 4340d81..15aea77 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/envelope-zero/standalone go 1.19 require ( + github.com/adrg/xdg v0.4.0 github.com/envelope-zero/backend v1.8.0 github.com/gin-contrib/static v0.0.2-0.20220829131751-3035101e2445 github.com/rs/zerolog v1.28.0 diff --git a/go.sum b/go.sum index a2b6653..739e895 100644 --- a/go.sum +++ b/go.sum @@ -3,6 +3,8 @@ github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls= +github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E= github.com/agiledragon/gomonkey/v2 v2.3.1/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= @@ -201,6 +203,7 @@ golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/main.go b/main.go index 5472707..3e195b3 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "context" "embed" + "fmt" "io/fs" "net/http" "os" @@ -10,11 +11,13 @@ import ( "syscall" "time" + "github.com/adrg/xdg" "github.com/envelope-zero/backend/pkg/controllers" "github.com/envelope-zero/backend/pkg/database" "github.com/envelope-zero/backend/pkg/models" "github.com/envelope-zero/backend/pkg/router" "github.com/gin-contrib/static" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/skratchdot/open-golang/open" ) @@ -46,7 +49,17 @@ func EmbedFolder(fsEmbed embed.FS, targetPath string) static.ServeFileSystem { } func main() { - db, err := database.Connect("data/gorm.db?_pragma=foreign_keys(1)") + zerolog.SetGlobalLevel(zerolog.InfoLevel) + + dbPath, err := xdg.DataFile("envelope-zero/envelope-zero.db") + if err != nil { + log.Fatal().Msg(err.Error()) + } + log.Info().Str("database file", dbPath).Msg("Init") + + dbConnectionOptions := "_pragma=foreign_keys(1)" + + db, err := database.Connect(fmt.Sprintf("%s?%s", dbPath, dbConnectionOptions)) if err != nil { log.Fatal().Msg(err.Error()) }