Skip to content

Commit

Permalink
Use desktop package instead of fs.xdg. (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch authored Nov 13, 2024
1 parent ae142d3 commit fd659d9
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 26 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ rebuild-cmake:
# The build-type is otherwise unused.
cmake -B build -DCMAKE_BUILD_TYPE=Debug

.PHONY: all test rebuild-cmake install-pkgs
update-pkgs:
for d in $$(git ls-files | grep package.yaml | grep -v tests/pkg | grep -v tests/lsp/project-root-multi); do \
toit pkg update --project-root $$(dirname $$d); \
done

.PHONY: all test rebuild-cmake install-pkgs update-pkgs
16 changes: 12 additions & 4 deletions examples/package.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,25 @@ packages:
..:
path: ..
prefixes:
desktop: pkg-desktop
fs: pkg-fs
host: pkg-host
pkg-desktop:
url: github.com/toitlang/pkg-desktop
name: desktop
version: 1.0.0
hash: 9c36fbb2cb28706705d9a21158c2fc9345108f6c
prefixes:
host: pkg-host
pkg-fs:
url: github.com/toitlang/pkg-fs
name: fs
version: 2.2.0
hash: 863280c5c62ac259d16d0d3b24df21209b461b14
version: 2.3.1
hash: 60836d4500317af2093d59d50c117d612c33f1fa
prefixes:
host: pkg-host
pkg-host:
url: github.com/toitlang/pkg-host
name: host
version: 1.15.0
hash: 2588faa0c7553eca9a85cb6f829f3df41d9466f2
version: 1.15.3
hash: 62393e8522b77eafbafe60b9817935266117daf6
2 changes: 1 addition & 1 deletion examples/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ dependencies:
path: ..
host:
url: github.com/toitlang/pkg-host
version: ^1.15.0
version: ^1.15.3
18 changes: 13 additions & 5 deletions package.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
sdk: ^2.0.0-alpha.144
sdk: ^2.0.0-alpha.161
prefixes:
desktop: pkg-desktop
fs: pkg-fs
host: pkg-host
packages:
pkg-desktop:
url: github.com/toitlang/pkg-desktop
name: desktop
version: 1.0.0
hash: 9c36fbb2cb28706705d9a21158c2fc9345108f6c
prefixes:
host: pkg-host
pkg-fs:
url: github.com/toitlang/pkg-fs
name: fs
version: 2.2.0
hash: 863280c5c62ac259d16d0d3b24df21209b461b14
version: 2.3.1
hash: 60836d4500317af2093d59d50c117d612c33f1fa
prefixes:
host: pkg-host
pkg-host:
url: github.com/toitlang/pkg-host
name: host
version: 1.15.0
hash: 2588faa0c7553eca9a85cb6f829f3df41d9466f2
version: 1.15.3
hash: 62393e8522b77eafbafe60b9817935266117daf6
7 changes: 5 additions & 2 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ description: Tools, like an argument parser, to create command-line applications
environment:
sdk: ^2.0.0-alpha.161
dependencies:
desktop:
url: github.com/toitlang/pkg-desktop
version: ^1.0.0
fs:
url: github.com/toitlang/pkg-fs
version: ^2.2.0
version: ^2.3.1
host:
url: github.com/toitlang/pkg-host
version: ^1.15.0
version: ^1.15.3
4 changes: 2 additions & 2 deletions src/cache.toit
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import crypto.sha256
import encoding.base64
import encoding.json
import fs
import fs.xdg
import desktop
import host.os
import host.file
import host.directory
Expand Down Expand Up @@ -50,7 +50,7 @@ class Cache:
if env-path:
return Cache --app-name=app-name --path=env-path

cache-home := xdg.cache-home
cache-home := desktop.cache-home
return Cache --app-name=app-name --path="$cache-home/$(app-name)"

/**
Expand Down
11 changes: 5 additions & 6 deletions src/config.toit
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// Use of this source code is governed by an MIT-style license that can be
// found in the package's LICENSE file.
import desktop
import encoding.json
import fs
import host.os
import host.file
import host.directory
import encoding.json
import writer
import fs.xdg
import fs
import .utils_

/**
Expand Down Expand Up @@ -58,10 +57,10 @@ class Config:
data := read-config-file_ env-path --if_absent=: init.call
return Config --app-name=app-name --path=env-path --data=data

config-home := xdg.config-home
config-home := desktop.config-home

// The path we are using to write configurations to.
all-dirs := [config-home] + xdg.config-dirs
all-dirs := [config-home] + desktop.config-dirs
all-dirs.do: | dir/string |
path := "$dir/$app-name/config"
data := read-config-file_ path --if_absent=: null
Expand Down
16 changes: 12 additions & 4 deletions tests/package.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,25 @@ packages:
..:
path: ..
prefixes:
desktop: pkg-desktop
fs: pkg-fs
host: pkg-host
pkg-desktop:
url: github.com/toitlang/pkg-desktop
name: desktop
version: 1.0.0
hash: 9c36fbb2cb28706705d9a21158c2fc9345108f6c
prefixes:
host: pkg-host
pkg-fs:
url: github.com/toitlang/pkg-fs
name: fs
version: 2.2.0
hash: 863280c5c62ac259d16d0d3b24df21209b461b14
version: 2.3.1
hash: 60836d4500317af2093d59d50c117d612c33f1fa
prefixes:
host: pkg-host
pkg-host:
url: github.com/toitlang/pkg-host
name: host
version: 1.15.0
hash: 2588faa0c7553eca9a85cb6f829f3df41d9466f2
version: 1.15.3
hash: 62393e8522b77eafbafe60b9817935266117daf6
2 changes: 1 addition & 1 deletion tests/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ dependencies:
path: ..
host:
url: github.com/toitlang/pkg-host
version: ^1.15.0
version: ^1.15.3

0 comments on commit fd659d9

Please sign in to comment.