From fd659d913ef5fbab9836d51ea2ceb8f30e2fb623 Mon Sep 17 00:00:00 2001 From: Florian Loitsch Date: Wed, 13 Nov 2024 16:43:15 +0100 Subject: [PATCH] Use desktop package instead of fs.xdg. (#75) --- Makefile | 7 ++++++- examples/package.lock | 16 ++++++++++++---- examples/package.yaml | 2 +- package.lock | 18 +++++++++++++----- package.yaml | 7 +++++-- src/cache.toit | 4 ++-- src/config.toit | 11 +++++------ tests/package.lock | 16 ++++++++++++---- tests/package.yaml | 2 +- 9 files changed, 57 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index e7a7cd1..590e662 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/examples/package.lock b/examples/package.lock index 6894153..79e3b35 100644 --- a/examples/package.lock +++ b/examples/package.lock @@ -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 diff --git a/examples/package.yaml b/examples/package.yaml index 4c423ce..1f55214 100644 --- a/examples/package.yaml +++ b/examples/package.yaml @@ -3,4 +3,4 @@ dependencies: path: .. host: url: github.com/toitlang/pkg-host - version: ^1.15.0 + version: ^1.15.3 diff --git a/package.lock b/package.lock index 1005ea6..76ec383 100644 --- a/package.lock +++ b/package.lock @@ -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 diff --git a/package.yaml b/package.yaml index 632875d..c5b793e 100644 --- a/package.yaml +++ b/package.yaml @@ -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 diff --git a/src/cache.toit b/src/cache.toit index 6bb66ea..1c3eba8 100644 --- a/src/cache.toit +++ b/src/cache.toit @@ -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 @@ -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)" /** diff --git a/src/config.toit b/src/config.toit index 4dbd5e4..26d77d8 100644 --- a/src/config.toit +++ b/src/config.toit @@ -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_ /** @@ -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 diff --git a/tests/package.lock b/tests/package.lock index 6894153..79e3b35 100644 --- a/tests/package.lock +++ b/tests/package.lock @@ -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 diff --git a/tests/package.yaml b/tests/package.yaml index 4c423ce..1f55214 100644 --- a/tests/package.yaml +++ b/tests/package.yaml @@ -3,4 +3,4 @@ dependencies: path: .. host: url: github.com/toitlang/pkg-host - version: ^1.15.0 + version: ^1.15.3