Skip to content

Commit

Permalink
feat!: move data directory to XDG standard directory (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
morremeyer authored Oct 19, 2022
1 parent 9a2edc5 commit e709c62
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ coverage.out
dist/
tmp/
/data
.DS_Store

# Created in the workflows but need to be ignored
node_modules/
Expand Down
9 changes: 0 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,42 @@

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

This software is constantly developed, therefore only the latest version is supported. If you encounter an issue, please update to the latest version and verify that it still exists in that version.

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).
17 changes: 17 additions & 0 deletions docs/upgrading.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
15 changes: 14 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ package main
import (
"context"
"embed"
"fmt"
"io/fs"
"net/http"
"os"
"os/signal"
"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"
)
Expand Down Expand Up @@ -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())
}
Expand Down

0 comments on commit e709c62

Please sign in to comment.