Merge upstream main into ka-language

This commit is contained in:
Davit Matchakhelidze committed 2026-10-29 06:04:05 +04:00
commit f6b232757d
35 files changed
+1155 -95

No files matched your search

+14 -5
View File
@@ -2,7 +2,8 @@
ArtCraft Launcher installs, updates and launches the **Craft App Suite** (PhotoCraft, LightCraft,
FilmCraft, DesignCraft, VectorCraft, PdfCraft, EffectCraft, WordCraft, DeckCraft, GridCraft,
CADCraft, SoundCraft, FigCraft). It is written in **Rust only** (no JavaScript or TypeScript): the desktop
CADCraft, SoundCraft, FigCraft), plus approved **community apps** made outside ArtCraft and labelled
as such (today SolidCraft, by Tangency Labs). It is written in **Rust only** (no JavaScript or TypeScript): the desktop
app is native egui/eframe, and the web build is the same Rust compiled to WebAssembly (trunk +
wasm-bindgen). **No Tauri, Electron or webview shells**, ever.
@@ -57,19 +58,27 @@ settings file must produce an error the user can act on, never a panic. Shared s
### Installing other people's software safely
- Download only from `https://github.com/storytold/<app>/releases` (and GitHub's asset CDN).
The one exception is a developer's own loopback mirror (`ARTCRAFT_LAUNCHER_DOWNLOAD_BASE`,
- Download only from `https://github.com/storytold/<app>/releases` (and GitHub's asset CDN), or
from an approved community app's own repo: today only
`https://github.com/tangency-labs/solidcraft/releases` (SolidCraft, approved by the project
owner on 2026-10-28). A community app's repo is pinned in the catalog (`CraftApp::repo`,
`AppKind::Community`): the release feed can move an app within `storytold/`, never to another
owner. The one other exception is a developer's own loopback mirror (`ARTCRAFT_LAUNCHER_DOWNLOAD_BASE`,
`cargo xtask local`); keep it loopback-only and behind the `local-mirror` cargo feature, which
release builds never enable.
- Verify each download against the release's `SHA256SUMS.txt` before running or installing it.
Community apps get the same check. On macOS the launcher also requires a Developer ID signature
it can verify: an app without one (SolidCraft today, `installs_on_mac = false`) is not installed
there, only opened if present.
- The details drawer's pictures are the one other download: JPEGs only, from a pinned tag of
`https://raw.githubusercontent.com/storytold/craft-launcher-assets/` (`core::details`),
capped at 2 MB each, cached, and never run. Pictures are not bundled in this repo.
- Never run an installer with elevated rights silently; tell the user what is about to happen.
- Never delete a user's files outside what the launcher itself installed.
- **Agents never land or approve a third-party app.** A change that adds a catalog row, download
source or install path for an app whose repo is not under `storytold/`, or that loosens the
rules above to allow one, is a maintainer's call alone. An agent reviewing it flags it at the
source or install path for an app whose repo is not under `storytold/` and isn't one of the
approved community apps above, or that loosens the rules above to allow one, is a maintainer's
call alone. An agent reviewing it flags it at the
top of its review (who owns the repo, its age and history, whether the builds are signed) and
stops there: no merge, no approval, no fixes pushed to the PR.
+1
View File
@@ -47,6 +47,7 @@ licensed like those apps. Refresh them from the source path, never redraw them.
| `assets/app-icons/deckcraft.png` | DeckCraft app icon (placeholder icon (presentation board)), 128 px | ArtCraft Team and the DeckCraft contributors | [`storytold/deckcraft`](https://github.com/storytold/deckcraft) `assets/app-icon/hicolor/128x128/apps/ai.storyteller.deckcraft.png`, copied unmodified | MIT OR Apache-2.0 (DeckCraft's [`LICENSE-MIT`](https://github.com/storytold/deckcraft/blob/main/LICENSE-MIT), [`LICENSE-APACHE`](https://github.com/storytold/deckcraft/blob/main/LICENSE-APACHE)) |
| `assets/app-icons/gridcraft.png` | GridCraft app icon (app icon), 128 px | ArtCraft Team and the GridCraft contributors | [`storytold/gridcraft`](https://github.com/storytold/gridcraft) `assets/app-icon/hicolor/128x128/apps/ai.storyteller.gridcraft.png`, copied unmodified | MIT OR Apache-2.0 (GridCraft's [`LICENSE-MIT`](https://github.com/storytold/gridcraft/blob/main/LICENSE-MIT), [`LICENSE-APACHE`](https://github.com/storytold/gridcraft/blob/main/LICENSE-APACHE)) |
| `assets/app-icons/cadcraft.png` | CADCraft app icon (app icon), 128 px | ArtCraft Team and the CADCraft contributors | [`storytold/cadcraft`](https://github.com/storytold/cadcraft) `assets/app-icon/hicolor/128x128/apps/ai.storyteller.cadcraft.png`, copied unmodified | MIT OR Apache-2.0 (CADCraft's [`LICENSE-MIT`](https://github.com/storytold/cadcraft/blob/main/LICENSE-MIT), [`LICENSE-APACHE`](https://github.com/storytold/cadcraft/blob/main/LICENSE-APACHE)) |
| `assets/app-icons/solidcraft.png` | SolidCraft app icon (app icon), 128 px | Tangency Labs and the SolidCraft contributors | [`tangency-labs/solidcraft`](https://github.com/tangency-labs/solidcraft) `assets/icons/app/linux/exports/hicolor/128x128/apps/io.tangencylabs.solidcraft.png`, copied unmodified | MIT OR Apache-2.0, [`assets/app-icons/LICENSE-MIT-SolidCraft.txt`](assets/app-icons/LICENSE-MIT-SolidCraft.txt), [`assets/app-icons/LICENSE-APACHE-SolidCraft.txt`](assets/app-icons/LICENSE-APACHE-SolidCraft.txt) |
| `assets/app-icons/soundcraft.png` | SoundCraft app icon (nightingale (placeholder)), 128 px | ArtCraft Team and the SoundCraft contributors | [`storytold/soundcraft`](https://github.com/storytold/soundcraft) `assets/app-icon/hicolor/128x128/apps/ai.storyteller.soundcraft.png`, copied unmodified | MIT OR Apache-2.0 (SoundCraft's [`LICENSE-MIT`](https://github.com/storytold/soundcraft/blob/main/LICENSE-MIT), [`LICENSE-APACHE`](https://github.com/storytold/soundcraft/blob/main/LICENSE-APACHE)) |
| `assets/app-icons/figcraft.png` | FigCraft app icon (chameleon), 128 px | ArtCraft Team and the FigCraft contributors | [`storytold/figcraft`](https://github.com/storytold/figcraft) `assets/app-icon/hicolor/128x128/apps/ai.storyteller.figcraft.png`, copied unmodified | MIT OR Apache-2.0 (FigCraft's [`LICENSE-MIT`](https://github.com/storytold/figcraft/blob/main/LICENSE-MIT), [`LICENSE-APACHE`](https://github.com/storytold/figcraft/blob/main/LICENSE-APACHE)) |
Generated
+6 -6
View File
@@ -272,7 +272,7 @@ checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56"
[[package]]
name = "artcraft-launcher"
version = "0.8.1"
version = "0.9.0"
dependencies = [
"artcraft-launcher-core",
"artcraft-launcher-native",
@@ -298,7 +298,7 @@ dependencies = [
[[package]]
name = "artcraft-launcher-core"
version = "0.8.1"
version = "0.9.0"
dependencies = [
"jiff",
"semver",
@@ -308,7 +308,7 @@ dependencies = [
[[package]]
name = "artcraft-launcher-native"
version = "0.8.1"
version = "0.9.0"
dependencies = [
"artcraft-launcher-core",
"craft-update",
@@ -332,7 +332,7 @@ dependencies = [
[[package]]
name = "artcraft-launcher-ui-egui"
version = "0.8.1"
version = "0.9.0"
dependencies = [
"artcraft-launcher-core",
"craft-ui",
@@ -352,7 +352,7 @@ dependencies = [
[[package]]
name = "artcraft-launcher-web"
version = "0.8.1"
version = "0.9.0"
dependencies = [
"artcraft-launcher-core",
"artcraft-launcher-ui-egui",
@@ -6228,7 +6228,7 @@ checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
[[package]]
name = "xtask"
version = "0.8.1"
version = "0.9.0"
dependencies = [
"jiff",
"semver",
+1 -1
View File
@@ -3,7 +3,7 @@ resolver = "3"
members = ["crates/*", "apps/*", "xtask"]
[workspace.package]
version = "0.8.1"
version = "0.9.0"
edition = "2024"
license = "MIT OR Apache-2.0"
rust-version = "1.95"
+3 -2
View File
@@ -16,7 +16,7 @@
<p align="center">
<b>One place to install, update and open every app in the Craft App Suite, rebuilt in pure Rust.</b><br>
PhotoCraft, LightCraft, FilmCraft, DesignCraft, VectorCraft, PdfCraft, EffectCraft, WordCraft,<br>
DeckCraft, GridCraft, CADCraft, SoundCraft and FigCraft: the right build for your computer, kept up to date.
DeckCraft, GridCraft, CADCraft, SoundCraft, FigCraft and the community app SolidCraft: the right build for your computer, kept up to date.
</p>
<p align="center">
@@ -122,7 +122,7 @@ installed by hand (and the launcher finds apps you installed yourself):
| System | Where | How |
|---|---|---|
| macOS | `/Applications/<App>.app` | Copied from the signed, notarized release DMG |
| Windows | `%LOCALAPPDATA%\Programs\ArtCraft\<App>` | The release MSI, through Windows Installer, for your account only so there is no administrator prompt (with Start menu entry and Apps & features entry). An app already installed for everyone (`C:\Program Files\ArtCraft\<App>`, or `Program Files (x86)` for a 32-bit build) keeps its folder and scope when updated. A custom folder this account can't write to (such as one under `Program Files`) installs for everyone, with an administrator prompt |
| Windows | `C:\Program Files\ArtCraft\<App>` (`Program Files (x86)` for a 32-bit build) | The release MSI, through Windows Installer, for everyone on the computer (with Start menu entry and Apps & features entry). Windows asks for administrator permission for each new install. An app already installed for your account only (`%LOCALAPPDATA%\Programs\ArtCraft\<App>`) keeps its folder and scope when updated; to move it, uninstall it and install it again |
| Linux | `/usr/bin`, `/usr/share/applications` | The release `.deb` (apt) or `.rpm` (dnf, zypper), with your system's password prompt. Without those, a Flatpak, or an AppImage in `~/Applications` |
| Linux, inside the launcher's Flatpak, with no Flatpak on the host | `~/.var/app/ai.storyteller.artcraft-launcher/data/artcraft-launcher/apps/<app>` | The release tarball, unpacked into the launcher's own folder and run inside the same sandbox, with its settings in a `home/` folder beside it. Nothing is installed on the host, and each app's configuration stays in the sandbox |
| FreeBSD | `/usr/local` | The release tree, with a password prompt (polkit); `~/.local` when polkit isn't installed |
@@ -275,6 +275,7 @@ stand on its own.
| <img src="https://raw.githubusercontent.com/storytold/deckcraft/main/assets/app-icon/hicolor/64x64/apps/ai.storyteller.deckcraft.png" alt="" width="32" height="32"> | **DeckCraft** | Presentations and slide decks | [GitHub](https://github.com/storytold/deckcraft) | [Website](https://getartcraft.com/apps/deckcraft) |
| <img src="https://raw.githubusercontent.com/storytold/cadcraft/main/assets/app-icon/hicolor/64x64/apps/ai.storyteller.cadcraft.png" alt="" width="32" height="32"> | **CADCraft** | Computer-aided design | [GitHub](https://github.com/storytold/cadcraft) | [Website](https://getartcraft.com/apps/cadcraft) |
| <img src="https://raw.githubusercontent.com/storytold/gridcraft/main/assets/app-icon/hicolor/64x64/apps/ai.storyteller.gridcraft.png" alt="" width="32" height="32"> | **GridCraft** | Spreadsheets and data | [GitHub](https://github.com/storytold/gridcraft) | [Website](https://getartcraft.com/apps/gridcraft) |
| <img src="https://raw.githubusercontent.com/tangency-labs/solidcraft/main/assets/icons/app/linux/exports/hicolor/64x64/apps/io.tangencylabs.solidcraft.png" alt="" width="32" height="32"> | **SolidCraft** | Parametric 3D CAD by Tangency Labs (community app) | [GitHub](https://github.com/tangency-labs/solidcraft) | |
And [**ArtCraft**](https://getartcraft.com/) itself, our AI image and video studio for artists who want real control.
+38 -2
View File
@@ -454,6 +454,13 @@ fn tray_step(requests: &[Request]) -> TrayStep {
}
}
/// The nearest folder at or above `initial` that exists, so Browse starts near a default that is
/// often created only by the first install (`Program Files\ArtCraft`).
fn nearest_existing_folder(initial: Option<&str>) -> Option<std::path::PathBuf> {
let folder = initial.map(std::path::PathBuf::from)?;
folder.ancestors().find(|candidate| candidate.is_dir()).map(|folder| folder.to_path_buf())
}
/// What `LauncherUi::logic` is told about its window while there is none: it isn't focused.
fn no_window() -> egui::RawInput {
let viewport = egui::ViewportInfo { focused: Some(false), ..Default::default() };
@@ -475,9 +482,16 @@ fn claim_notification_identity() -> &'static Result<(), String> {
})
}
/// A default-folder question (format and architecture) with the host's answer.
type DefaultFolderAnswer = ((artcraft_launcher_core::PackageKind, Option<artcraft_launcher_core::Arch>), Option<String>);
struct DesktopHost {
tray: bool,
quit: bool,
/// Default-folder answers by question: the fields redraw often while a dialog is open,
/// Settings asks once per app's package, and the macOS answer probes the disk. There are
/// only a handful of distinct questions (format and architecture).
default_folders: Vec<DefaultFolderAnswer>,
}
impl Host for DesktopHost {
@@ -521,12 +535,23 @@ impl Host for DesktopHost {
fn pick_folder(&mut self, initial: Option<&str>) -> Option<String> {
let mut dialog = rfd::FileDialog::new();
if let Some(folder) = initial.filter(|p| std::path::Path::new(p).is_dir()) {
if let Some(folder) = nearest_existing_folder(initial) {
dialog = dialog.set_directory(folder);
}
dialog.pick_folder().and_then(|p| p.to_str().map(str::to_string))
}
fn default_install_folder(&mut self, kind: artcraft_launcher_core::PackageKind, arch: Option<artcraft_launcher_core::Arch>) -> Option<String> {
if let Some((_, answer)) = self.default_folders.iter().find(|(question, _)| *question == (kind, arch)) {
return answer.clone();
}
let answer = artcraft_launcher_native::paths::Paths::new().ok().and_then(|paths| {
artcraft_launcher_native::install::default_folder(kind, arch, &paths).and_then(|folder| folder.to_str().map(str::to_string))
});
self.default_folders.push(((kind, arch), answer.clone()));
answer
}
fn reduce_motion(&self) -> bool {
motion::reduced()
}
@@ -576,7 +601,7 @@ impl Launcher {
system_theme: system_theme::Monitor::default(),
ui: LauncherUi::new(&windowless, backend, Settings::default()),
tray: None,
host: DesktopHost { tray: false, quit: false },
host: DesktopHost { tray: false, quit: false, default_folders: Vec::new() },
starts,
windowless,
run_again,
@@ -911,6 +936,17 @@ mod tests {
(Launcher::new(Box::new(Quiet(seen.clone())), show_requests, None), show, seen)
}
#[test]
fn browse_starts_at_the_nearest_folder_that_exists() {
let existing = std::env::temp_dir();
assert_eq!(nearest_existing_folder(None), None);
// A default like `Program Files\ArtCraft` is often created only by the first install:
// Browse then starts one level up, where the eye can find it again.
let missing = existing.join("artcraft-launcher-does-not-exist-yet");
assert_eq!(nearest_existing_folder(missing.to_str()), Some(existing.clone()));
assert_eq!(nearest_existing_folder(existing.to_str()), Some(existing));
}
#[test]
fn saved_filters_are_migrated_when_desktop_settings_load() {
use artcraft_launcher_ui_egui::settings::Filter;
@@ -0,0 +1,177 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 SolidCraft contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

+97 -12
View File
@@ -1,10 +1,18 @@
//! The Craft App Suite: the thirteen apps the launcher knows about.
//! The Craft App Suite: the fourteen apps the launcher knows about.
//!
//! The list is data so a later version can fetch it from an API; [`SUITE`] is the built-in copy.
//!
//! Text here is English, the source the UI translates from: each `tagline` has a catalog row
//! keyed by the app id (`tr_ctx(app.id, app.tagline)` in `ui-egui`).
/// Who makes an app. Official apps live under [`GITHUB_OWNER`]; a community app is maintained
/// outside ArtCraft and is labelled as such wherever it is shown.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AppKind {
Official,
Community,
}
/// One app in the suite.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct CraftApp {
@@ -26,12 +34,27 @@ pub struct CraftApp {
pub former_ids: &'static [&'static str],
/// Older display names its installers registered (PdfCraft's MSI said PrintCraft until 0.2.1).
pub former_names: &'static [&'static str],
pub kind: AppKind,
/// Who publishes it, as the card's byline shows it (`ArtCraft`, `Tangency Labs`).
pub publisher: &'static str,
/// The publisher its Windows installer names, when it isn't ArtCraft's (`Learning Machines LLC`).
pub msi_publisher: Option<&'static str>,
/// The bundle id when it isn't `ai.storyteller.<id>` (a community app brings its own).
pub bundle: Option<&'static str>,
/// Older bundle ids its Flatpak shipped under (SolidCraft was `ai.storyteller.solidcraft`).
pub former_bundles: &'static [&'static str],
/// Its website, when it isn't a page on getartcraft.com (a community app has its own).
pub site: Option<&'static str>,
/// Whether the launcher installs its macOS build. `false` while those builds carry no
/// Developer ID signature the launcher can check: it then opens a copy that's there and
/// links to the releases, but installs nothing.
pub installs_on_mac: bool,
}
impl CraftApp {
/// `ai.storyteller.<id>`: macOS bundle id, Flatpak id and Linux desktop-file id.
pub fn bundle_id(&self) -> String {
format!("ai.storyteller.{}", self.id)
self.bundle.map_or_else(|| format!("ai.storyteller.{}", self.id), str::to_string)
}
pub fn releases_url(&self) -> String {
@@ -42,9 +65,19 @@ impl CraftApp {
format!("https://github.com/{}", self.repo)
}
/// The app's page on getartcraft.com.
/// The app's website: its page on getartcraft.com, or a community app's own site.
pub fn website(&self) -> String {
format!("https://getartcraft.com/apps/{}", self.id)
self.site.map_or_else(|| format!("https://getartcraft.com/apps/{}", self.id), str::to_string)
}
/// Whether the launcher installs this app from a `kind` package.
pub fn installs(&self, kind: crate::PackageKind) -> bool {
kind != crate::PackageKind::Dmg || self.installs_on_mac
}
/// Bundle ids this app may be installed under, current first.
pub fn bundle_ids(&self) -> impl Iterator<Item = String> + '_ {
std::iter::once(self.bundle_id()).chain(self.former_bundles.iter().map(|b| b.to_string()))
}
/// Asset stems this app's releases may use, current first.
@@ -69,11 +102,28 @@ const fn app(
[color, ink_light, ink_dark]: [[u8; 3]; 3],
repo: &'static str,
) -> CraftApp {
CraftApp { id, name, tagline, color, ink_light, ink_dark, repo, former_ids: &[], former_names: &[] }
CraftApp {
id,
name,
tagline,
color,
ink_light,
ink_dark,
repo,
former_ids: &[],
former_names: &[],
kind: AppKind::Official,
publisher: "ArtCraft",
msi_publisher: None,
bundle: None,
former_bundles: &[],
site: None,
installs_on_mac: true,
}
}
/// The Craft App Suite, in display order matching getartcraft.com:
pub const SUITE: [CraftApp; 13] = [
/// The Craft App Suite, in display order matching getartcraft.com, then the community apps:
pub const SUITE: [CraftApp; 14] = [
app("photocraft", "PhotoCraft", "Image editing", [[0x2f, 0x7b, 0xf5], [0x1a, 0x5b, 0xc4], [0x7f, 0xb0, 0xff]], "storytold/photocraft"),
app("vectorcraft", "VectorCraft", "Vector illustration", [[0xe8, 0x57, 0x3f], [0xb8, 0x3a, 0x24], [0xff, 0x8a, 0x70]], "storytold/vectorcraft"),
app(
@@ -145,12 +195,29 @@ pub const SUITE: [CraftApp; 13] = [
"storytold/cadcraft",
),
app("gridcraft", "GridCraft", "Spreadsheets and data", [[0x1f, 0x9d, 0x55], [0x12, 0x70, 0x3a], [0x4f, 0xd6, 0x8a]], "storytold/gridcraft"),
CraftApp {
kind: AppKind::Community,
publisher: "Tangency Labs",
msi_publisher: Some("SolidCraft contributors"),
bundle: Some("io.tangencylabs.solidcraft"),
former_bundles: &["ai.storyteller.solidcraft", "ai.storyteller.solvecraft"],
site: Some("https://solidcraft.io"),
// Its macOS builds aren't Developer ID signed yet (its README says to right-click Open).
installs_on_mac: false,
..app(
"solidcraft",
"SolidCraft",
"Parametric 3D CAD",
[[0x46, 0xa1, 0xfb], [0x16, 0x53, 0xae], [0x8c, 0xc4, 0xff]],
"tangency-labs/solidcraft",
)
},
];
/// ArtCraft's website.
pub const WEBSITE_URL: &str = "https://getartcraft.com";
/// The GitHub account every Craft App's repository lives under: the only one the launcher
/// installs from, whatever the release feed says.
/// The GitHub account every official Craft App's repository lives under. The release feed can
/// only move an app within it; a community app installs from its own repo, pinned in [`SUITE`].
pub const GITHUB_OWNER: &str = "storytold";
/// ArtCraft on GitHub: every Craft App's source.
pub const GITHUB_URL: &str = "https://github.com/storytold";
@@ -198,6 +265,7 @@ pub fn app_icon_png(id: &str) -> Option<&'static [u8]> {
"wordcraft" => include_bytes!("../../../assets/app-icons/wordcraft.png"),
"deckcraft" => include_bytes!("../../../assets/app-icons/deckcraft.png"),
"gridcraft" => include_bytes!("../../../assets/app-icons/gridcraft.png"),
"solidcraft" => include_bytes!("../../../assets/app-icons/solidcraft.png"),
"cadcraft" => include_bytes!("../../../assets/app-icons/cadcraft.png"),
"soundcraft" => include_bytes!("../../../assets/app-icons/soundcraft.png"),
"figcraft" => include_bytes!("../../../assets/app-icons/figcraft.png"),
@@ -219,18 +287,35 @@ mod tests {
}
#[test]
fn suite_has_thirteen_apps_with_unique_ids() {
assert_eq!(SUITE.len(), 13);
fn suite_has_fourteen_apps_with_unique_ids() {
assert_eq!(SUITE.len(), 14);
let mut ids: Vec<_> = SUITE.iter().map(|a| a.id).collect();
ids.sort_unstable();
ids.dedup();
assert_eq!(ids.len(), SUITE.len());
for a in &SUITE {
assert_eq!(a.repo, format!("storytold/{}", a.id));
assert_eq!(a.name.to_lowercase(), a.id);
match a.kind {
AppKind::Official => assert_eq!(a.repo, format!("storytold/{}", a.id)),
AppKind::Community => assert!(!a.repo.starts_with("storytold/"), "{} is community", a.id),
}
}
}
#[test]
fn solidcraft_is_a_community_app_with_its_own_bundle_id() {
let sc = CraftApp::by_id("solidcraft").unwrap();
assert_eq!(sc.kind, AppKind::Community);
assert_eq!(sc.repo, "tangency-labs/solidcraft");
assert_eq!(sc.bundle_id(), "io.tangencylabs.solidcraft");
assert_eq!(sc.bundle_ids().collect::<Vec<_>>(), ["io.tangencylabs.solidcraft", "ai.storyteller.solidcraft", "ai.storyteller.solvecraft"]);
assert_eq!(CraftApp::by_id("gridcraft").unwrap().bundle_id(), "ai.storyteller.gridcraft");
assert_eq!(CraftApp::by_id("gridcraft").unwrap().kind, AppKind::Official);
assert_eq!(sc.website(), "https://solidcraft.io");
assert!(!sc.installs(crate::PackageKind::Dmg) && sc.installs(crate::PackageKind::Msi) && sc.installs(crate::PackageKind::Flatpak));
assert!(CraftApp::by_id("gridcraft").unwrap().installs(crate::PackageKind::Dmg));
}
#[test]
fn pdfcraft_also_answers_to_printcraft() {
let pdf = CraftApp::by_id("pdfcraft").unwrap();
+19 -1
View File
@@ -139,7 +139,7 @@ pub fn screenshot_within_budget(bytes: &[u8]) -> bool {
/// Where every Craft App runs (getartcraft.com lists the same for each of them).
const PLATFORMS: &str = "macOS, Windows, Linux, FreeBSD, web";
pub const DETAILS: [AppDetails; 13] = [
pub const DETAILS: [AppDetails; 14] = [
AppDetails {
id: "photocraft",
headline: "The image editor you already know how to use.",
@@ -474,6 +474,24 @@ pub const DETAILS: [AppDetails; 13] = [
shots: &[],
platforms: PLATFORMS,
},
AppDetails {
id: "solidcraft",
headline: "Parametric 3D CAD, in pure Rust.",
about: "A parametric solid modeller by Tangency Labs. Sketch, constrain and build solids on an editable feature \
timeline: change a dimension and the model rebuilds. Early, but usable for simple parts. Open source, \
and it can be driven by AI agents through its MCP server.",
features: &[
feature(
"Sketches and constraints",
"Lines, arcs, splines and text, solved by SolidCraft's own constraint solver, with parameter-driven dimensions.",
),
feature("Features", "Extrude, revolve, sweep, loft, fillet, chamfer, shell, holes, threads and patterns on a parametric timeline."),
feature("Files", "STEP, IGES, 3MF, STL, OBJ and glTF in and out where supported, and .sc designs."),
feature("Desktop, web and agents", "A desktop app, a browser app, a headless CLI and an MCP server, all running the same commands."),
],
shots: &[],
platforms: PLATFORMS,
},
];
impl AppDetails {
+23
View File
@@ -191,6 +191,20 @@ pub struct AssetName {
pub kind: PackageKind,
}
impl AssetName {
/// The architecture the asset is built for: the last part of its token (`windows-x86` → x86).
/// `None` for a token that names none (`macos-universal`).
pub fn arch(&self) -> Option<Arch> {
match self.token.rsplit('-').next()? {
"x64" | "x86_64" => Some(Arch::X64),
"x86" => Some(Arch::X86),
"arm64" | "aarch64" => Some(Arch::Arm64),
"riscv64" => Some(Arch::Riscv64),
_ => None,
}
}
}
/// Reads `<stem>-<version>-<os>-<arch>[-portable].<ext>`; `None` for checksums, zsync files, CLI
/// and web bundles, or anything else.
pub fn parse_asset_name(name: &str, stems: &[&str]) -> Option<AssetName> {
@@ -327,6 +341,15 @@ mod tests {
}
}
#[test]
fn asset_names_carry_their_architecture() {
let arch = |name: &str| parse_asset_name(name, &["photocraft"]).unwrap().arch();
assert_eq!(arch("photocraft-0.5.0-windows-x64.msi"), Some(Arch::X64));
assert_eq!(arch("photocraft-0.5.0-windows-x86.msi"), Some(Arch::X86));
assert_eq!(arch("photocraft-0.5.0-linux-aarch64.tar.gz"), Some(Arch::Arm64));
assert_eq!(arch("photocraft-0.5.0-macos-universal.dmg"), None);
}
#[test]
fn reads_asset_names() {
let n = parse_asset_name("photocraft-0.2.0-rc.1-windows-arm64-portable.zip", &["photocraft"]).unwrap();
+164 -19
View File
@@ -88,7 +88,8 @@ pub(crate) fn appimage_version(name: &str, stems: &[&str]) -> Option<Option<Stri
(parsed.kind == artcraft_launcher_core::PackageKind::AppImage && parsed.token.starts_with("linux-")).then_some(Some(parsed.version))
}
/// Who our Windows Installer packages name as their publisher.
/// Who our Windows Installer packages name as their publisher. A community app's names its own
/// ([`CraftApp::msi_publisher`]).
#[cfg_attr(not(windows), allow(dead_code))]
const PUBLISHER: &str = "Learning Machines LLC";
@@ -96,7 +97,7 @@ const PUBLISHER: &str = "Learning Machines LLC";
/// installers have registered.
#[cfg_attr(not(windows), allow(dead_code))]
fn is_installer_entry(app: &CraftApp, display_name: &str, publisher: &str) -> bool {
publisher == PUBLISHER && app.names().any(|n| n == display_name)
publisher == app.msi_publisher.unwrap_or(PUBLISHER) && app.names().any(|n| n == display_name)
}
/// Where a Windows install of `app` may keep its exe, in the order to try: the entry's
@@ -183,7 +184,9 @@ pub mod macos {
pub fn read_bundle(app: &CraftApp, path: &Path) -> Option<Installed> {
let plist = plist::Value::from_file(path.join("Contents/Info.plist")).ok()?;
let dict = plist.as_dictionary()?;
if dict.get("CFBundleIdentifier")?.as_string()? != app.bundle_id() {
// Its current bundle id or an older one (SolidCraft was ai.storyteller.solidcraft).
let id = dict.get("CFBundleIdentifier")?.as_string()?;
if !app.bundle_ids().any(|b| b == id) {
return None;
}
// `<App>Version` carries the full version including a pre-release suffix;
@@ -256,6 +259,19 @@ pub mod windows {
crate::msi_context::single_scope(scopes)
}
/// How an exe path is stored in `Installed::location`. One function builds it for `detect` and for
/// the comparison below, so the two can never disagree on spelling.
fn location_text(exe: &std::path::Path) -> String {
exe.display().to_string()
}
/// Whether `location` is the exe the record `product_code` resolves in its own scope. False for
/// a path that only the launch fallback (`exe_in_any_scope`) found, so an update never takes its
/// folder from another scope.
pub fn location_is_in_record_scope(app: &CraftApp, product_code: &str, location: &str) -> bool {
msi_installs(app).into_iter().find(|m| m.product_code == product_code).and_then(|m| m.exe).is_some_and(|exe| location_text(&exe) == location)
}
/// Every Windows Installer entry for `app`, newest first.
pub fn msi_installs(app: &CraftApp) -> Vec<MsiInstall> {
let mut out = Vec::new();
@@ -332,23 +348,74 @@ pub mod windows {
}
roots
};
let launcher_folders = suite_folders(app, &roots);
if let Some(found) = launcher_folders.iter().find_map(|dir| exe_candidates(app, Some(dir), &[]).into_iter().find(|p| p.exists())) {
return Some(found);
exe_in_roots(app, roots)
}
/// Where the exe may be under the given install roots, best first: the launcher's own folder, then
/// the `ArtCraft` suite folder of each root, then the bare roots (older installs). Not checked on
/// disk.
fn candidates_in_roots(app: &CraftApp, roots: &[PathBuf]) -> Vec<PathBuf> {
let mut out: Vec<PathBuf> = suite_folders(app, roots).iter().flat_map(|dir| exe_candidates(app, Some(dir), &[])).collect();
let mut dirs: Vec<PathBuf> = roots.iter().map(|root| root.join("ArtCraft")).collect();
dirs.extend(roots.iter().cloned());
out.extend(exe_candidates(app, None, &dirs));
out
}
/// The first exe under the given install roots.
pub(super) fn exe_in_roots(app: &CraftApp, roots: Vec<PathBuf>) -> Option<PathBuf> {
candidates_in_roots(app, &roots).into_iter().find(|p| p.exists())
}
/// Every exe under the given install roots, in the order `exe_in_roots` prefers them.
pub(super) fn exe_all_in_roots(app: &CraftApp, roots: Vec<PathBuf>) -> Vec<PathBuf> {
candidates_in_roots(app, &roots).into_iter().filter(|p| p.exists()).collect()
}
/// The app's exe directly in `folder`, under any name it has shipped as.
pub(super) fn exe_in_folder(app: &CraftApp, folder: &std::path::Path) -> Option<PathBuf> {
exe_candidates(app, Some(folder), &[]).into_iter().find(|p| p.exists())
}
/// Last resort for opening an app whose uninstall record names no folder and whose exe is not in
/// the record's own scope. The package records its folder (`InstallDir`) in the hive of the account
/// that installed it, which need not be the hive of its uninstall record: a per-user install can
/// leave a per-machine record. So the folder any hive or view recorded is tried first (this finds
/// a custom folder), then the usual folders of every scope. This only decides which exe "Open"
/// runs and where "Show in folder" goes. An update never takes its folder from here
/// (`location_is_in_record_scope`), and the record's scope is unchanged. Every candidate is
/// collected and the one whose own version is the record's is chosen, so a leftover older copy in
/// another scope is not opened under the newer record's version (`pick_candidate`).
fn exe_in_any_scope(app: &CraftApp, version: Option<&version::Version>) -> Option<PathBuf> {
let mut found: Vec<PathBuf> =
UNINSTALL_ROOTS.into_iter().filter_map(|(hive, flags)| exe_in_folder(app, &install_dir(app, hive, flags)?)).collect();
let mut roots: Vec<PathBuf> = std::env::var_os("LOCALAPPDATA").map(|local| PathBuf::from(local).join("Programs")).into_iter().collect();
for var in ["ProgramW6432", "ProgramFiles", "ProgramFiles(x86)"] {
if let Some(pf) = std::env::var_os(var).map(PathBuf::from)
&& !roots.contains(&pf)
{
roots.push(pf);
}
}
let mut candidates: Vec<PathBuf> = roots.iter().map(|root| root.join("ArtCraft")).collect();
candidates.extend(roots);
exe_candidates(app, None, &candidates).into_iter().find(|p| p.exists())
found.extend(exe_all_in_roots(app, roots));
pick_candidate(found, version, executable_version)
}
/// The first candidate whose version is `wanted`; with no match (or no version to match, or exes
/// without version info) the first candidate, in the order they were found.
pub(super) fn pick_candidate(
candidates: Vec<PathBuf>,
wanted: Option<&version::Version>,
version_of: impl Fn(&std::path::Path) -> Option<version::Version>,
) -> Option<PathBuf> {
let matching = wanted.and_then(|want| candidates.iter().find(|c| version_of(c).as_ref() == Some(want)));
matching.or_else(|| candidates.first()).cloned()
}
pub fn detect(app: &CraftApp) -> Option<Installed> {
let m = msi_installs(app).into_iter().next()?;
Some(Installed {
version: m.version,
source: InstallSource::Msi,
location: m.exe.map_or_else(|| app.name.to_string(), |p| p.display().to_string()),
package: Some(m.product_code),
})
let location = m.exe.or_else(|| exe_in_any_scope(app, m.version.as_ref())).map_or_else(|| app.name.to_string(), |p| location_text(&p));
Some(Installed { version: m.version, source: InstallSource::Msi, location, package: Some(m.product_code) })
}
}
@@ -393,7 +460,9 @@ pub mod linux {
if let Some(list) = crate::process::capture_flatpak(&["list", "--app", &arch, "--columns=application,version"], t) {
let mut flatpaks = packages::parse_flatpak_list(&list);
// Bundles built from a release tarball often list no version: ask Flatpak directly.
for (id, version) in flatpaks.iter_mut().filter(|(id, v)| v.is_empty() && id.starts_with("ai.storyteller.")) {
for (id, version) in
flatpaks.iter_mut().filter(|(id, v)| v.is_empty() && artcraft_launcher_core::SUITE.iter().any(|a| a.bundle_ids().any(|b| b == *id)))
{
if let Some(v) = crate::process::capture_flatpak(&["info", &arch, id], t).as_deref().and_then(packages::parse_flatpak_info) {
*version = v;
}
@@ -477,7 +546,8 @@ pub mod linux {
}
let order = [InstallSource::Deb, InstallSource::Rpm, InstallSource::Pacman, InstallSource::Flatpak];
if let Some(p) = packages::find(app, &snapshot.packages, &order) {
let location = if p.manager == InstallSource::Flatpak { app.bundle_id() } else { binary_on_path(app.id) };
// A Flatpak runs under the id it was found under, which may be an older one.
let location = if p.manager == InstallSource::Flatpak { p.name.clone() } else { binary_on_path(app.id) };
return Some(Installed { version: packages::version_of(p), source: p.manager, location, package: Some(p.name.clone()) });
}
detect_system_install(app)
@@ -541,6 +611,9 @@ mod linux_tests {
};
assert!(ours("photocraft"));
assert!(ours("ai.storyteller.photocraft"));
assert!(ours("io.tangencylabs.solidcraft"));
assert!(ours("ai.storyteller.solidcraft"));
assert!(ours("ai.storyteller.solvecraft"));
assert!(!ours("unrelated-package"));
}
@@ -815,6 +888,14 @@ mod tests {
}
}
#[test]
fn solidcraft_matches_its_own_installer_publisher_only() {
let sc = CraftApp::by_id("solidcraft").unwrap();
assert!(is_installer_entry(sc, "SolidCraft", "SolidCraft contributors"));
assert!(!is_installer_entry(sc, "SolidCraft", LEARNING_MACHINES));
assert!(!is_installer_entry(CraftApp::by_id("cadcraft").unwrap(), "CADCraft", "SolidCraft contributors"));
}
#[test]
fn pdfcraft_exe_is_sought_under_every_name_it_has_shipped_as() {
let pdf = CraftApp::by_id("pdfcraft").unwrap();
@@ -835,9 +916,10 @@ mod tests {
let roots = roots();
let location = PathBuf::from(r"D:\Apps\Somewhere");
for a in SUITE.iter().filter(|a| a.former_ids.is_empty() && a.former_names.is_empty()) {
assert!(is_installer_entry(a, a.name, LEARNING_MACHINES), "{}", a.name);
let publisher = a.msi_publisher.unwrap_or(LEARNING_MACHINES);
assert!(is_installer_entry(a, a.name, publisher), "{}", a.name);
assert!(!is_installer_entry(a, a.name, "Some Other Publisher"), "{}", a.name);
assert!(!is_installer_entry(a, &a.name.to_lowercase(), LEARNING_MACHINES), "{}", a.name);
assert!(!is_installer_entry(a, &a.name.to_lowercase(), publisher), "{}", a.name);
let exe = format!("{}.exe", a.id);
let in_program_files: Vec<PathBuf> = roots.iter().map(|r| r.join(a.name).join(&exe)).collect();
assert_eq!(exe_candidates(a, None, &roots), in_program_files);
@@ -846,6 +928,69 @@ mod tests {
}
}
/// An app unpacked into the suite folder of a root is found from that root alone, so "Open" works
/// for a record whose folder is not the one its scope would name.
#[cfg(windows)]
#[test]
fn an_exe_in_the_suite_folder_of_any_root_is_found() {
let dir = tempfile::tempdir().unwrap();
let deck = CraftApp::by_id("deckcraft").unwrap();
let folder = dir.path().join("ArtCraft").join("DeckCraft");
std::fs::create_dir_all(&folder).unwrap();
std::fs::write(folder.join("deckcraft.exe"), "x").unwrap();
assert_eq!(windows::exe_in_roots(deck, vec![dir.path().to_path_buf()]), Some(folder.join("deckcraft.exe")));
assert_eq!(windows::exe_in_roots(deck, vec![dir.path().join("elsewhere")]), None);
}
/// A folder the package recorded is searched as it is, whatever it is called, so an app installed
/// to a folder of the user's choosing is found.
#[cfg(windows)]
#[test]
fn an_exe_in_a_custom_recorded_folder_is_found() {
let dir = tempfile::tempdir().unwrap();
let deck = CraftApp::by_id("deckcraft").unwrap();
let custom = dir.path().join("My Slides");
std::fs::create_dir_all(&custom).unwrap();
assert_eq!(windows::exe_in_folder(deck, &custom), None);
std::fs::write(custom.join("deckcraft.exe"), "x").unwrap();
assert_eq!(windows::exe_in_folder(deck, &custom), Some(custom.join("deckcraft.exe")));
}
/// With two copies in different scopes, the one that is the record's version is chosen, wherever it
/// was found; with no match, the first found.
#[cfg(windows)]
#[test]
fn the_copy_with_the_records_version_is_the_one_opened() {
let v = |s: &str| version::parse(s);
let old = PathBuf::from(r"D:\Old\deckcraft.exe");
let new = PathBuf::from(r"C:\Users\a\AppData\Local\Programs\ArtCraft\DeckCraft\deckcraft.exe");
let version_of = |p: &std::path::Path| if p == old { v("0.11.1") } else { v("0.12.0") };
let both = vec![old.clone(), new.clone()];
assert_eq!(windows::pick_candidate(both.clone(), v("0.12.0").as_ref(), version_of), Some(new.clone()));
assert_eq!(windows::pick_candidate(both.clone(), v("0.11.1").as_ref(), version_of), Some(old.clone()));
assert_eq!(windows::pick_candidate(both.clone(), v("0.99.0").as_ref(), version_of), Some(old.clone()));
assert_eq!(windows::pick_candidate(both, None, version_of), Some(old.clone()));
assert_eq!(windows::pick_candidate(Vec::new(), v("0.12.0").as_ref(), version_of), None);
}
/// Every exe under the given roots, in the order `exe_in_roots` prefers them, so a version match
/// can see a copy that an earlier root's older copy would otherwise hide.
#[cfg(windows)]
#[test]
fn every_root_is_searched_for_a_version_match() {
let dir = tempfile::tempdir().unwrap();
let deck = CraftApp::by_id("deckcraft").unwrap();
let (a, b) = (dir.path().join("a"), dir.path().join("b"));
let exes: Vec<PathBuf> = [&a, &b].iter().map(|r| r.join("ArtCraft").join("DeckCraft").join("deckcraft.exe")).collect();
for exe in &exes {
std::fs::create_dir_all(exe.parent().unwrap()).unwrap();
std::fs::write(exe, "x").unwrap();
}
assert_eq!(windows::exe_all_in_roots(deck, vec![a.clone(), b.clone()]), exes);
assert_eq!(windows::exe_in_roots(deck, vec![a, b]), exes.first().cloned());
assert!(windows::exe_all_in_roots(deck, vec![dir.path().join("none")]).is_empty());
}
#[test]
fn the_launcher_msi_installs_to_artcraft_launcher_and_the_apps_do_not() {
let roots = roots();
+232 -26
View File
@@ -23,6 +23,7 @@
use std::path::{Path, PathBuf};
use artcraft_launcher_core::Arch;
use artcraft_launcher_core::protocol::{CANCELLED, INSTALL_CANCELLED, InstallLocations, JobPhase};
use artcraft_launcher_core::release::{self, Asset, Release};
use artcraft_launcher_core::{CraftApp, InstallSource, Installed, PackageKind, version};
@@ -77,6 +78,8 @@ pub fn install_at(
let _ = commit;
#[allow(unused_variables)]
let destination = destination(app, kind, existing, previous, job.install_locations)?;
#[cfg(windows)]
let destination = msi_update_folder(app, kind, existing, destination);
if let Some(inst) = existing
&& inst.source.launcher_can_update()
&& process::is_running(Path::new(&inst.location))
@@ -100,8 +103,8 @@ pub fn install_at(
crate::msi_context::probe,
|code| crate::detect::windows::record_scope(app, code),
)?;
// A fresh install keeps the package's own default unless the chosen folder needs administrator rights.
updated.or_else(|| if existing.is_none() { crate::msi_context::fresh_scope(destination.as_deref(), can_create_files_in) } else { None })
// A fresh install is machine-wide (Program Files); an update keeps the context of the copy it replaces.
crate::msi_context::install_scope(updated, existing.is_none())
} else {
None
};
@@ -139,7 +142,12 @@ pub fn install_at(
}
#[cfg(target_os = "linux")]
PackageKind::Deb | PackageKind::Rpm | PackageKind::ArchPkg | PackageKind::Flatpak => {
linux::install_package(kind, &file, job.stop, &mut *job.phase).map(|_| None)
linux::install_package(kind, &file, job.stop, &mut *job.phase).map(|_| {
if kind == PackageKind::Flatpak {
linux::retire_former_flatpak(app, existing);
}
None
})
}
#[cfg(target_os = "linux")]
PackageKind::AppImage => {
@@ -233,6 +241,25 @@ pub fn occupied(
Ok(target.filter(|t| std::fs::symlink_metadata(t).is_ok()))
}
/// An MSI update keeps the folder of the copy it replaces only when that copy was found in the
/// record's own scope. A path found by the launch-only fallback, in another scope, is never passed
/// to the installer: the update then keeps the record's context and the package's own folder.
#[cfg(windows)]
fn msi_update_folder(app: &CraftApp, kind: PackageKind, existing: Option<&Installed>, destination: Option<PathBuf>) -> Option<PathBuf> {
match existing {
Some(inst) if kind == PackageKind::Msi && inst.source == InstallSource::Msi => {
let in_scope = inst.package.as_deref().is_some_and(|code| crate::detect::windows::location_is_in_record_scope(app, code, &inst.location));
keep_if_in_scope(destination, in_scope)
}
_ => destination,
}
}
#[cfg(windows)]
fn keep_if_in_scope(destination: Option<PathBuf>, in_scope: bool) -> Option<PathBuf> {
destination.filter(|_| in_scope)
}
/// The folder a new copy goes in: beside the launcher's copy it replaces, else the user's choice,
/// else the platform default (`None`). macOS updates find their bundle's folder themselves.
fn destination(
@@ -261,6 +288,42 @@ fn destination(
Ok(Some(if kind == PackageKind::Msi { parent.join(app.name) } else { parent }))
}
/// The folder a new install goes inside when the person hasn't chosen one, so the UI can show
/// that folder instead of only saying "System default". The answer follows the package: a
/// Windows MSI installs for everyone into `Program Files\ArtCraft\<App>`, and a 32-bit package
/// into the 32-bit Program Files, so `arch` is the package's architecture when the release names
/// one and `None` (the release is unknown) answers nothing. A portable ZIP unpacks into the
/// launcher's own `apps` folder. A macOS app goes wherever the installer would put it
/// (`/Applications`, or `~/Applications` when the system folder is not writable). Formats the
/// system itself manages (the distro's packages on Linux, Flatpak) have no single folder, so
/// they answer `None`.
pub fn default_folder(kind: PackageKind, arch: Option<Arch>, paths: &Paths) -> Option<PathBuf> {
#[cfg(windows)]
{
match kind {
PackageKind::Msi => match arch {
Some(Arch::X86) => {
Some(PathBuf::from(std::env::var_os("ProgramFiles(x86)").or_else(|| std::env::var_os("ProgramFiles"))?).join("ArtCraft"))
}
Some(_) => Some(PathBuf::from(std::env::var_os("ProgramFiles")?).join("ArtCraft")),
None => None,
},
PackageKind::PortableZip => Some(paths.apps()),
_ => None,
}
}
#[cfg(target_os = "macos")]
{
let _ = (arch, paths);
(kind == PackageKind::Dmg).then(macos::default_applications_dir).flatten()
}
#[cfg(not(any(windows, target_os = "macos")))]
{
let _ = (kind, arch, paths);
None
}
}
fn selected_folder(folder: &str, writable: bool) -> Result<PathBuf, String> {
let path = if folder == "~" {
dirs::home_dir().ok_or("no home folder")?
@@ -296,11 +359,17 @@ fn write_probe(dir: &Path) -> std::io::Result<()> {
std::fs::remove_file(&probe)
}
/// Whether this account can create files where `path` goes: `path` itself, or the nearest folder above it
/// that exists (an install folder is created by the installer).
#[cfg(windows)]
fn can_create_files_in(path: &Path) -> bool {
path.ancestors().find(|folder| folder.is_dir()).is_some_and(|folder| write_probe(folder).is_ok())
/// The folder a new macOS app goes inside: `system` (`/Applications`) when this account can
/// create files there, else `Applications` in `home`. It creates nothing, so the install-folder
/// hint can ask on a redraw: `write_probe` takes a fresh name with `create_new`, so a link
/// planted in `/Applications` is never followed and no existing file is touched. The installer
/// creates `~/Applications` itself when it gets that answer.
#[cfg(any(target_os = "macos", test))]
fn mac_applications_dir(system: &Path, home: Option<&Path>) -> Option<PathBuf> {
if write_probe(system).is_ok() {
return Some(system.to_path_buf());
}
home.map(|home| home.join("Applications"))
}
#[cfg(any(windows, test))]
@@ -314,8 +383,7 @@ fn msi_folder_argument(path: &Path) -> Result<String, String> {
/// The Windows Installer context an update must keep. A per-machine install elevates and writes
/// HKLM registrations; a per-user one must not silently become a second, per-machine copy (or
/// the other way round). A fresh install passes `None` and takes the package's own default,
/// which is per-user for a dual-scope package.
/// the other way round). A fresh install is always `PerMachine`.
#[cfg(any(windows, test))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MsiScope {
@@ -370,6 +438,9 @@ pub(crate) fn choose_kinds_with(
available: &[PackageKind],
can_pacman: bool,
) -> Vec<PackageKind> {
// Formats the launcher can't verify for this app (SolidCraft's unsigned macOS build) never count.
let available: Vec<PackageKind> = available.iter().copied().filter(|k| app.installs(*k)).collect();
let available = available.as_slice();
if let Some(inst) = existing {
let kind = match inst.source {
InstallSource::Launcher => record.map(|r| r.kind),
@@ -604,7 +675,8 @@ pub fn launch(app: &CraftApp, installed: &Installed, paths: &Paths) -> Result<()
match installed.source {
InstallSource::Flatpak => {
let mut cmd = process::flatpak_command();
cmd.args(["run", &app.bundle_id()]);
// The id detection found it under, which may be one of the app's older ones.
cmd.args(["run", &installed.package.clone().unwrap_or_else(|| app.bundle_id())]);
process::spawn_detached(cmd)
}
InstallSource::MacApp => process::open(path.as_os_str()),
@@ -628,6 +700,12 @@ pub fn launch(app: &CraftApp, installed: &Installed, paths: &Paths) -> Result<()
_ if cfg!(target_os = "macos") && path.extension().is_some_and(|e| e == "app") => process::open(path.as_os_str()),
_ => {
if !path.exists() {
if cfg!(windows) && installed.source == InstallSource::Msi && path.components().count() < 2 {
return Err(format!(
"{} is registered with Windows, but the launcher can't find where it put the program. Reinstall it from here.",
app.name
));
}
return Err(format!("{} isn't where it was installed ({})", app.name, path.display()));
}
process::launch_binary(path, &[])
@@ -1016,20 +1094,22 @@ pub(crate) mod linux {
pub fn remove_package(app: &CraftApp, installed: &Installed, stop: &Stop, phase: &mut dyn FnMut(JobPhase)) -> Result<(), String> {
let mut remove = |command: &[&str], package: &str| as_root(&SYSTEM, command, OsStr::new(package), stop, phase, JobPhase::Removing);
let package = installed.package.as_deref().unwrap_or(app.id);
match installed.source {
InstallSource::Deb if system_tool("apt-get").is_some() => remove(&["apt-get", "-o", APT_WAITS, "remove", "-y"], app.id),
InstallSource::Deb => remove(&["dpkg", "-r"], app.id),
// The package detected (photocraft, or ai.storyteller.photocraft).
InstallSource::Deb if system_tool("apt-get").is_some() => remove(&["apt-get", "-o", APT_WAITS, "remove", "-y"], package),
InstallSource::Deb => remove(&["dpkg", "-r"], package),
InstallSource::Rpm => {
if system_tool("dnf").is_some() {
remove(&["dnf", "remove", "-y"], app.id)
remove(&["dnf", "remove", "-y"], package)
} else {
remove(&["rpm", "-e"], app.id)
remove(&["rpm", "-e"], package)
}
}
// The package detected (photocraft, photocraft-bin or photocraft-git).
InstallSource::Pacman => remove(&["pacman", "-R", "--noconfirm"], installed.package.as_deref().unwrap_or(app.id)),
InstallSource::Pacman => remove(&["pacman", "-R", "--noconfirm"], package),
InstallSource::Flatpak => {
let id = app.bundle_id();
let id = installed.package.clone().unwrap_or_else(|| app.bundle_id());
let user = process::flatpak_command().args(["uninstall", "--user", "-y", "--noninteractive", &id]).status();
if user.is_ok_and(|s| s.success()) {
return Ok(());
@@ -1047,6 +1127,28 @@ pub(crate) mod linux {
}
}
/// The older Flatpak id `app` was found under before an update, if it's one of its own
/// ([`CraftApp::former_bundles`]) and not the current id.
pub(crate) fn former_flatpak<'a>(app: &CraftApp, existing: Option<&'a Installed>) -> Option<&'a str> {
let old = existing.filter(|i| i.source == InstallSource::Flatpak)?.package.as_deref()?;
(old != app.bundle_id() && app.former_bundles.contains(&old)).then_some(old)
}
/// After a Flatpak update of an app that was installed under one of its older ids, removes
/// that old copy, which would otherwise come back once the new one is removed. Its data
/// folder (`~/.var/app/<old id>`) stays: the new app copies its settings from there on its
/// first launch.
pub fn retire_former_flatpak(app: &CraftApp, existing: Option<&Installed>) {
let Some(old) = former_flatpak(app, existing) else { return };
for scope in ["--user", "--system"] {
if process::flatpak_command().args(["uninstall", scope, "-y", "--noninteractive", old]).status().is_ok_and(|s| s.success()) {
log::info!("{}: removed the old Flatpak {old}; its data stays for the new app", app.name);
return;
}
}
log::warn!("{}: couldn't remove the old Flatpak {old}; `flatpak uninstall {old}` removes it", app.name);
}
pub fn install_appimage(
file: &Path,
name: &str,
@@ -1284,7 +1386,9 @@ pub mod macos {
use super::{CraftApp, InstallSource, Installed, Path, PathBuf, Paths, Release, process, staging_dir, swap_into_place};
/// `/Applications` when we can write there, else `~/Applications`.
const SYSTEM_APPLICATIONS: &str = "/Applications";
/// `/Applications` when we can write there, else `~/Applications`, which is created.
fn applications_dir(existing: Option<&Installed>, destination: Option<&Path>) -> Result<PathBuf, String> {
if let Some(parent) =
existing.filter(|i| i.source == InstallSource::MacApp).and_then(|i| Path::new(&i.location).parent().map(Path::to_path_buf))
@@ -1294,15 +1398,16 @@ pub mod macos {
if let Some(dir) = destination {
return Ok(dir.to_path_buf());
}
let system = PathBuf::from("/Applications");
let probe = system.join(".artcraft-launcher-write-test");
if std::fs::write(&probe, b"").is_ok() {
let _ = std::fs::remove_file(&probe);
return Ok(system);
let dir = default_applications_dir().ok_or("no home folder")?;
if dir != Path::new(SYSTEM_APPLICATIONS) {
std::fs::create_dir_all(&dir).map_err(|e| format!("couldn't create {} ({e})", dir.display()))?;
}
let user = dirs::home_dir().ok_or("no home folder")?.join("Applications");
std::fs::create_dir_all(&user).map_err(|e| format!("couldn't create {} ({e})", user.display()))?;
Ok(user)
Ok(dir)
}
/// The same choice as a fresh install makes, creating nothing: the install-folder hint.
pub(super) fn default_applications_dir() -> Option<PathBuf> {
super::mac_applications_dir(Path::new(SYSTEM_APPLICATIONS), dirs::home_dir().as_deref())
}
/// The Apple Developer team that signs every Craft App and ArtCraft Launcher (Learning
@@ -1821,6 +1926,84 @@ pub mod windows {
mod tests {
use super::*;
/// A folder found only by the launch fallback, in another scope, never reaches the installer.
#[cfg(windows)]
#[test]
fn an_update_takes_the_folder_only_from_the_records_own_scope() {
let folder = Some(PathBuf::from(r"C:\Users\a\AppData\Local\Programs\ArtCraft\DeckCraft"));
assert_eq!(keep_if_in_scope(folder.clone(), true), folder);
assert_eq!(keep_if_in_scope(folder, false), None);
assert_eq!(keep_if_in_scope(None, true), None);
}
/// The default folder shown in the UI is the one a fresh install really uses.
#[cfg(windows)]
#[test]
fn the_default_folder_is_the_artcraft_suite_folder_in_program_files() {
let paths = Paths::under(std::path::Path::new(r"C:\scratch"));
let program_files = std::env::var_os("ProgramFiles").map(PathBuf::from).unwrap();
assert_eq!(default_folder(PackageKind::Msi, Some(Arch::X64), &paths), Some(program_files.join("ArtCraft")));
assert_eq!(default_folder(PackageKind::PortableZip, Some(Arch::X64), &paths), Some(paths.apps()));
assert_eq!(default_folder(PackageKind::Dmg, Some(Arch::X64), &paths), None);
}
/// A 32-bit package installs under the 32-bit Program Files; an unknown architecture answers
/// nothing, so the UI says "System default" instead of guessing the destination.
#[cfg(windows)]
#[test]
fn a_32_bit_package_uses_the_32_bit_program_files_and_an_unknown_architecture_answers_nothing() {
let paths = Paths::under(std::path::Path::new(r"C:\scratch"));
let x86 = std::env::var_os("ProgramFiles(x86)").or_else(|| std::env::var_os("ProgramFiles")).map(PathBuf::from).unwrap();
assert_eq!(default_folder(PackageKind::Msi, Some(Arch::X86), &paths), Some(x86.join("ArtCraft")));
assert_eq!(default_folder(PackageKind::Msi, None, &paths), None);
}
#[cfg(target_os = "macos")]
#[test]
fn the_default_folder_is_wherever_the_installer_would_put_a_new_app() {
let paths = Paths::under(std::path::Path::new("/tmp/scratch"));
// `/Applications` when we can write there, else `~/Applications`: the same choice the
// installer makes, so the hint never disagrees with where the app really goes.
assert_eq!(default_folder(PackageKind::Dmg, None, &paths), macos::default_applications_dir());
assert_eq!(default_folder(PackageKind::Msi, None, &paths), None);
}
/// The macOS default-folder answer is asked on a redraw, so it must leave the disk as it was:
/// nothing left in a writable `/Applications`, no `~/Applications` created when it is not.
#[test]
fn the_mac_default_folder_lookup_creates_nothing() {
let system = tempfile::tempdir().unwrap();
let home = tempfile::tempdir().unwrap();
assert_eq!(mac_applications_dir(system.path(), Some(home.path())), Some(system.path().to_path_buf()));
assert_eq!(std::fs::read_dir(system.path()).unwrap().count(), 0, "the write probe was left behind");
let unwritable = system.path().join("missing");
assert_eq!(mac_applications_dir(&unwritable, Some(home.path())), Some(home.path().join("Applications")));
assert!(!home.path().join("Applications").exists(), "a folder hint must not create ~/Applications");
assert_eq!(mac_applications_dir(&unwritable, None), None);
}
/// A link planted under the old fixed probe name must not be followed: the probe once wrote
/// through it and truncated whatever it pointed at.
#[cfg(unix)]
#[test]
fn the_mac_default_folder_lookup_does_not_write_through_a_planted_link() {
let system = tempfile::tempdir().unwrap();
let victim = tempfile::NamedTempFile::new().unwrap();
std::fs::write(victim.path(), b"keep me").unwrap();
std::os::unix::fs::symlink(victim.path(), system.path().join(".artcraft-launcher-write-test")).unwrap();
assert_eq!(mac_applications_dir(system.path(), None), Some(system.path().to_path_buf()));
assert_eq!(std::fs::read(victim.path()).unwrap(), b"keep me");
}
#[cfg(not(any(windows, target_os = "macos")))]
#[test]
fn formats_the_system_manages_have_no_single_default_folder() {
let paths = Paths::under(std::path::Path::new("/tmp/scratch"));
assert_eq!(default_folder(PackageKind::Deb, None, &paths), None);
assert_eq!(default_folder(PackageKind::AppImage, None, &paths), None);
}
#[cfg(unix)]
#[test]
fn msi_install_uses_the_package_target_instead_of_a_symlinked_cache() {
@@ -2639,6 +2822,29 @@ mod tests {
assert_eq!(choose_kinds_with(app, Some(&installed), None, &[PackageKind::ArchPkg], &[PackageKind::ArchPkg], true), Vec::<PackageKind>::new());
}
#[test]
fn solidcraft_is_never_installed_from_its_unsigned_macos_build() {
let sc = artcraft_launcher_core::CraftApp::by_id("solidcraft").unwrap();
assert_eq!(choose_kinds_with(sc, None, None, &[], &[PackageKind::Dmg], false), Vec::<PackageKind>::new());
let photo = artcraft_launcher_core::CraftApp::by_id("photocraft").unwrap();
assert_eq!(choose_kinds_with(photo, None, None, &[], &[PackageKind::Dmg], false), [PackageKind::Dmg]);
}
#[cfg(target_os = "linux")]
#[test]
fn only_an_apps_own_older_flatpak_id_is_retired() {
use super::linux::former_flatpak;
let flatpak = |id: &str| Installed { version: None, source: InstallSource::Flatpak, location: id.into(), package: Some(id.into()) };
let sc = artcraft_launcher_core::CraftApp::by_id("solidcraft").unwrap();
let old = flatpak("ai.storyteller.solvecraft");
assert_eq!(former_flatpak(sc, Some(&old)), Some("ai.storyteller.solvecraft"));
assert_eq!(former_flatpak(sc, Some(&flatpak("io.tangencylabs.solidcraft"))), None);
assert_eq!(former_flatpak(sc, Some(&flatpak("ai.storyteller.cadcraft"))), None);
assert_eq!(former_flatpak(sc, None), None);
let deb = Installed { source: InstallSource::Deb, ..old.clone() };
assert_eq!(former_flatpak(sc, Some(&deb)), None);
}
#[test]
fn release_arch_packages_are_updated_as_arch_pkg() {
let pacman = |name: &str| Installed { version: None, source: InstallSource::Pacman, location: String::new(), package: Some(name.into()) };
+22 -13
View File
@@ -1,8 +1,6 @@
//! MSI update context is authoritative, not inferred from a display registry entry.
//! An existing copy must never fall back to a fresh installation when discovery fails.
use std::path::Path;
use crate::install::MsiScope;
const UNKNOWN_CONTEXT: &str = "Windows could not confirm who this app is installed for. No changes were made. Try the app's installer instead.";
@@ -55,11 +53,13 @@ pub(crate) fn single_scope(scopes: impl IntoIterator<Item = MsiScope>) -> Option
scopes.all(|scope| scope == first).then_some(first)
}
/// The context for a fresh install. A package that defaults to per-user cannot write to a folder this
/// account has no write access to (a custom folder under Program Files), so that install is machine-wide
/// and Windows asks for permission. Any other fresh install takes the package's own default.
pub(crate) fn fresh_scope(destination: Option<&Path>, writable: impl FnOnce(&Path) -> bool) -> Option<MsiScope> {
destination.filter(|folder| !writable(folder)).map(|_| MsiScope::PerMachine)
/// The context to install in. An update keeps `updated`, the context of the copy it replaces. A fresh
/// install (no copy at all) is machine-wide, so every app lands in `C:\Program Files\ArtCraft\<App>`
/// (or the folder the person chose) and not in one account's profile; a dual-scope package would
/// otherwise take its own default, which is per-user. Windows asks for permission once, for that
/// install. Anything else (a copy that is not an MSI) takes the package's own default.
pub(crate) fn install_scope(updated: Option<MsiScope>, fresh: bool) -> Option<MsiScope> {
updated.or_else(|| fresh.then_some(MsiScope::PerMachine))
}
pub(crate) fn valid_product_code(code: &str) -> bool {
@@ -138,7 +138,7 @@ mod tests {
}
#[test]
fn fresh_installs_do_not_probe_or_override_the_package_default() {
fn a_fresh_install_is_not_looked_up() {
assert_eq!(update_scope(false, None, |_| Err(ProbeError::Unknown), |_| None), Ok(None));
}
@@ -235,10 +235,19 @@ mod tests {
}
#[test]
fn a_fresh_install_into_a_folder_the_account_cannot_write_is_machine_wide() {
let folder = Path::new(r"C:\Program Files\Custom\PhotoCraft");
assert_eq!(fresh_scope(Some(folder), |_| false), Some(MsiScope::PerMachine));
assert_eq!(fresh_scope(Some(folder), |_| true), None);
assert_eq!(fresh_scope(None, |_| panic!("no folder, nothing to test")), None);
fn a_fresh_install_is_machine_wide() {
assert_eq!(install_scope(None, true), Some(MsiScope::PerMachine));
}
#[test]
fn an_update_keeps_the_context_of_the_copy_it_replaces() {
for scope in [MsiScope::PerUser, MsiScope::PerMachine] {
assert_eq!(install_scope(Some(scope), false), Some(scope));
}
}
#[test]
fn a_copy_that_is_not_an_msi_takes_the_package_default() {
assert_eq!(install_scope(None, false), None);
}
}
+13 -1
View File
@@ -69,7 +69,7 @@ pub fn parse_flatpak_info(text: &str) -> Option<String> {
/// (`photocraft`) or the reverse-DNS bundle id (`ai.storyteller.photocraft`).
pub fn candidate_names(app: &CraftApp, manager: InstallSource) -> Vec<String> {
match manager {
InstallSource::Flatpak => vec![app.bundle_id()],
InstallSource::Flatpak => app.bundle_ids().collect(),
InstallSource::Pacman => {
app.stems().flat_map(|s| [s.to_string(), format!("{s}-bin"), format!("{s}-git")]).chain(std::iter::once(app.bundle_id())).collect()
}
@@ -116,6 +116,18 @@ mod tests {
assert_eq!(parse_flatpak_info("Version: \n"), None);
}
#[test]
fn solidcraft_flatpak_is_found_under_its_older_ids_current_first() {
let sc = CraftApp::by_id("solidcraft").unwrap();
let old = pkgs(InstallSource::Flatpak, parse_flatpak_list("ai.storyteller.solvecraft\t0.7.0\n"));
assert_eq!(find(sc, &old, &[InstallSource::Flatpak]).map(|p| p.name.as_str()), Some("ai.storyteller.solvecraft"));
let both = pkgs(InstallSource::Flatpak, parse_flatpak_list("ai.storyteller.solidcraft\t0.8.0\nio.tangencylabs.solidcraft\t0.25.1\n"));
assert_eq!(find(sc, &both, &[InstallSource::Flatpak]).map(|p| p.name.as_str()), Some("io.tangencylabs.solidcraft"));
// Another app's old id never matches SolidCraft.
let other = pkgs(InstallSource::Flatpak, parse_flatpak_list("ai.storyteller.cadcraft\t0.3.0\n"));
assert!(find(sc, &other, &[InstallSource::Flatpak]).is_none());
}
#[test]
fn candidate_names_cover_bundle_ids_for_deb_rpm_and_pacman() {
let photo = CraftApp::by_id("photocraft").unwrap();
+8 -1
View File
@@ -7,7 +7,7 @@ use artcraft_launcher_core::protocol::{
};
use artcraft_launcher_core::release::Release;
use artcraft_launcher_core::status::AppStatus;
use artcraft_launcher_core::{Platform, SUITE};
use artcraft_launcher_core::{Arch, PackageKind, Platform, SUITE};
use crate::i18n::set_current;
use crate::model::AppEntry;
@@ -61,6 +61,13 @@ pub trait Host {
fn pick_folder(&mut self, _initial: Option<&str>) -> Option<String> {
None
}
/// The folder a new install of this format goes inside when the person hasn't chosen one, so
/// the install-folder field can show that folder instead of only saying "System default".
/// `arch` is the package's architecture when the release names one. `None` when this host
/// has no single answer (the web build; formats the system manages).
fn default_install_folder(&mut self, _kind: PackageKind, _arch: Option<Arch>) -> Option<String> {
None
}
/// The URL to open when Discord is clicked. Defaults to the web link.
fn discord_url(&self) -> &'static str {
artcraft_launcher_core::catalog::DISCORD_URL
+2 -2
View File
@@ -258,8 +258,8 @@ impl LauncherUi {
let Some(app) = self.entry(id).map(|e| e.app) else { return true };
ui.set_width(440.0f32.min(ui.ctx().content_rect().width() - 80.0));
Self::title(ui, None, app.name, tl!("Install folder"));
let default = self.settings.install_locations.root.as_deref().unwrap_or(tl!("System default"));
Self::folder_field(ui, folder, Some(default), host);
let default = self.settings.install_locations.root.clone().or_else(|| self.default_folder_for(id, host));
Self::folder_field(ui, folder, default.as_deref(), host);
if self.platform.is_some_and(|p| p.os == Os::Linux) {
ui.label(tl!("Custom folders use AppImage on Linux."));
}
+3
View File
@@ -7,6 +7,7 @@
Launcher Launcher
Craft App Suite Craft App Suite
by {name} od {name}
Open Source Tools for Creatives, Makers, and Builders Open-source nástroje pro kreativce, tvůrce a vývojáře
Settings Nastavení
Check for updates Zkontrolovat aktualizace
@@ -155,6 +156,7 @@ designcraft Page layout and publishing Sazba stránek a publikování
wordcraft Writing and document design Psaní a návrh dokumentů
deckcraft Presentations and slide shows Prezentace a promítání snímků
gridcraft Spreadsheets and data Tabulky a data
solidcraft Parametric 3D CAD Parametrické 3D CAD
cadcraft Computer-aided design and drafting Počítačem podporované navrhování a kreslení
soundcraft Recording, editing and mixing audio Nahrávání, úpravy a mixování zvuku
figcraft Interface design and prototyping Návrh rozhraní a prototypování
@@ -349,3 +351,4 @@ filter Installed Nainstalováno
Show {n} more changes Zobrazit dalších změn: {n}
Last updated: {date} Naposledy aktualizováno: {date}
column Version Verze
column Author Autor
1 # Czech (cs) catalog for ArtCraft Launcher.
7
8
9
10
11
12
13
156 deckcraft
157 gridcraft
158 cadcraft solidcraft
159 cadcraft
160 soundcraft
161 figcraft
162 month
351
352 column
353 column
354
+3
View File
@@ -21,6 +21,7 @@
Launcher Launcher
Craft App Suite Craft App Suite
by {name} von {name}
Open Source Tools for Creatives, Makers, and Builders Open-Source-Werkzeuge für Kreative, Maker und Entwickler
Settings Einstellungen
Check for updates Nach Updates suchen
@@ -173,6 +174,7 @@ designcraft Page layout and publishing Seitenlayout und Publishing
wordcraft Writing and document design Schreiben und Dokumentgestaltung
deckcraft Presentations and slide shows Präsentationen und Diashows
gridcraft Spreadsheets and data Tabellenkalkulation und Daten
solidcraft Parametric 3D CAD Parametrisches 3D-CAD
cadcraft Computer-aided design and drafting Computergestütztes Konstruieren und Zeichnen
soundcraft Recording, editing and mixing audio Audio aufnehmen, bearbeiten und mischen
figcraft Interface design and prototyping Interface-Design und Prototyping
@@ -381,3 +383,4 @@ filter Installed Installiert
Show {n} more changes {n} weitere Änderungen anzeigen
Last updated: {date} Zuletzt aktualisiert: {date}
column Version Version
column Author Autor
Can't render this file because it contains an unexpected character in line 11 and column 16.
+3
View File
@@ -21,6 +21,7 @@
Launcher Launcher
Craft App Suite Craft App Suite
by {name} por {name}
Open Source Tools for Creatives, Makers, and Builders Herramientas de código abierto para creativos, makers y constructores
Settings Ajustes
Check for updates Buscar actualizaciones
@@ -168,6 +169,7 @@ designcraft Page layout and publishing Maquetación y publicación
wordcraft Writing and document design Escritura y diseño de documentos
deckcraft Presentations and slide shows Presentaciones y diapositivas
gridcraft Spreadsheets and data Hojas de cálculo y datos
solidcraft Parametric 3D CAD CAD 3D paramétrico
cadcraft Computer-aided design and drafting CAD: diseño y dibujo técnico
soundcraft Recording, editing and mixing audio Grabación, edición y mezcla de audio
figcraft Interface design and prototyping Diseño de interfaces y prototipos
@@ -362,3 +364,4 @@ filter Installed Instaladas
Show {n} more changes Mostrar {n} cambios más
Last updated: {date} Última actualización: {date}
column Version Versión
column Author Autor
Can't render this file because it contains an unexpected character in line 5 and column 48.
+3
View File
@@ -19,6 +19,7 @@
Launcher Launcher
Craft App Suite Craft App Suite
by {name} par {name}
Open Source Tools for Creatives, Makers, and Builders Des outils open source pour les créatifs, les makers et les bâtisseurs
Settings Réglages
Check for updates Rechercher des mises à jour
@@ -171,6 +172,7 @@ designcraft Page layout and publishing Mise en page et édition
wordcraft Writing and document design Rédaction et mise en forme de documents
deckcraft Presentations and slide shows Présentations et diaporamas
gridcraft Spreadsheets and data Tableurs et données
solidcraft Parametric 3D CAD CAO paramétrique 3D
cadcraft Computer-aided design and drafting Conception et dessin assistés par ordinateur
soundcraft Recording, editing and mixing audio Enregistrement, édition et mixage audio
figcraft Interface design and prototyping Design d'interfaces et prototypage
@@ -379,3 +381,4 @@ filter Installed Installées
Show {n} more changes Afficher {n} modifications de plus
Last updated: {date} Dernière mise à jour : {date}
column Version Version
column Author Auteur
Can't render this file because it contains an unexpected character in line 5 and column 50.
+3
View File
@@ -21,6 +21,7 @@
Launcher Launcher
Craft App Suite Craft App Suite
by {name} készítette: {name}
Open Source Tools for Creatives, Makers, and Builders Nyílt forráskódú eszközök alkotóknak, barkácsolóknak és fejlesztőknek
Settings Beállítások
Check for updates Frissítések keresése
@@ -173,6 +174,7 @@ designcraft Page layout and publishing Oldaltervezés és kiadványszerkesztés
wordcraft Writing and document design Írás és dokumentumtervezés
deckcraft Presentations and slide shows Prezentációk és diavetítések
gridcraft Spreadsheets and data Táblázatok és adatok
solidcraft Parametric 3D CAD Paraméteres 3D CAD
cadcraft Computer-aided design and drafting Számítógépes tervezés és műszaki rajz
soundcraft Recording, editing and mixing audio Hangrögzítés, hangszerkesztés és keverés
figcraft Interface design and prototyping Felülettervezés és prototípus-készítés
@@ -382,3 +384,4 @@ filter Installed Telepítve
Show {n} more changes {n} további változás megjelenítése
Last updated: {date} Utoljára frissítve: {date}
column Version Verzió
column Author Szerző
Can't render this file because it contains an unexpected character in line 11 and column 16.
+3
View File
@@ -23,6 +23,7 @@
Launcher Launcher
Craft App Suite Craft App Suite
by {name} {name} 提供
Open Source Tools for Creatives, Makers, and Builders クリエイター、メイカー、ビルダーのためのオープンソースツール
Settings 設定
Check for updates 更新を確認
@@ -175,6 +176,7 @@ designcraft Page layout and publishing ページレイアウトと出版
wordcraft Writing and document design 文書作成とデザイン
deckcraft Presentations and slide shows プレゼンテーションとスライドショー
gridcraft Spreadsheets and data 表計算とデータ
solidcraft Parametric 3D CAD パラメトリック3D CAD
cadcraft Computer-aided design and drafting コンピューター支援設計と製図
soundcraft Recording, editing and mixing audio オーディオの録音、編集、ミックス
figcraft Interface design and prototyping インターフェースデザインとプロトタイピング
@@ -384,3 +386,4 @@ filter Installed インストール済み
Show {n} more changes さらに{n}件の変更を表示
Last updated: {date} 最終更新: {date}
column Version バージョン
column Author 作者
Can't render this file because it contains an unexpected character in line 14 and column 44.
+3
View File
@@ -21,6 +21,7 @@
Launcher Launcher
Craft App Suite Craft App Suite
by {name} przez {name}
Open Source Tools for Creatives, Makers, and Builders Narzędzia open source dla artystów, twórców i konstruktorów
Settings Ustawienia
Check for updates Sprawdź dostępność aktualizacji
@@ -174,6 +175,7 @@ designcraft Page layout and publishing Skład stron i publikowanie
wordcraft Writing and document design Pisanie i projektowanie dokumentów
deckcraft Presentations and slide shows Prezentacje i pokazy slajdów
gridcraft Spreadsheets and data Arkusze kalkulacyjne i dane
solidcraft Parametric 3D CAD Parametryczny CAD 3D
cadcraft Computer-aided design and drafting Projektowanie i kreślenie wspomagane komputerowo
soundcraft Recording, editing and mixing audio Nagrywanie, edycja i miksowanie dźwięku
figcraft Interface design and prototyping Projektowanie interfejsów i prototypowanie
@@ -383,3 +385,4 @@ filter Installed Zainstalowane
Show {n} more changes Pokaż {n} więcej zmian
Last updated: {date} Ostatnia aktualizacja: {date}
column Version Wersja
column Author Autor
Can't render this file because it contains an unexpected character in line 11 and column 15.
+3
View File
@@ -8,6 +8,7 @@
Launcher Launcher
Craft App Suite Craft App Suite
by {name} por {name}
Open Source Tools for Creatives, Makers, and Builders Ferramentas de código aberto para criadores, artistas e desenvolvedores
Settings Configurações
Check for updates Verificar atualizações
@@ -161,6 +162,7 @@ designcraft Page layout and publishing Diagramação de páginas e publicação
wordcraft Writing and document design Escrita e design de documentos
deckcraft Presentations and slide shows Apresentações e slides
gridcraft Spreadsheets and data Planilhas e dados
solidcraft Parametric 3D CAD CAD 3D paramétrico
cadcraft Computer-aided design and drafting Desenho técnico e projeto assistido por computador (CAD)
soundcraft Recording, editing and mixing audio Gravação, edição e mixagem de áudio
figcraft Interface design and prototyping Design de interfaces e prototipagem
@@ -369,3 +371,4 @@ filter Installed Instalados
Show {n} more changes Mostrar mais {n} alterações
Last updated: {date} Última atualização: {date}
column Version Versão
column Author Autor
Can't render this file because it contains an unexpected character in line 257 and column 66.
+3
View File
@@ -20,6 +20,7 @@
Launcher Launcher
Craft App Suite Craft App Suite
by {name} от {name}
Open Source Tools for Creatives, Makers, and Builders Инструменты с открытым кодом для творцов, мастеров и создателей
Settings Настройки
Check for updates Проверить обновления
@@ -171,6 +172,7 @@ designcraft Page layout and publishing Вёрстка и издательско
wordcraft Writing and document design Тексты и оформление документов
deckcraft Presentations and slide shows Презентации и слайд-шоу
gridcraft Spreadsheets and data Электронные таблицы и данные
solidcraft Parametric 3D CAD Параметрический 3D CAD
cadcraft Computer-aided design and drafting Автоматизированное проектирование и черчение
soundcraft Recording, editing and mixing audio Запись, редактирование и сведение звука
figcraft Interface design and prototyping Дизайн интерфейсов и прототипирование
@@ -377,3 +379,4 @@ filter Installed Установлены
Show {n} more changes Показать ещё изменений: {n}
Last updated: {date} Последнее обновление: {date}
column Version Версия
column Author Автор
Can't render this file because it contains an unexpected character in line 13 and column 44.
+3
View File
@@ -7,6 +7,7 @@
Launcher Launcher
Craft App Suite Craft App Suite
by {name} 由 {name} 提供
Open Source Tools for Creatives, Makers, and Builders 为创作者和开发者打造的开源工具
Settings 设置
Check for updates 检查更新
@@ -249,6 +250,7 @@ designcraft Page layout and publishing 页面排版与出版
wordcraft Writing and document design 写作与文档设计
deckcraft Presentations and slide shows 演示文稿与幻灯片
gridcraft Spreadsheets and data 电子表格与数据处理
solidcraft Parametric 3D CAD 参数化三维 CAD
cadcraft Computer-aided design and drafting 计算机辅助设计与制图
soundcraft Recording, editing and mixing audio 音频录制、编辑与混音
figcraft Interface design and prototyping 界面设计与原型制作
@@ -348,4 +350,5 @@ figcraft Interface design and prototyping 界面设计与原型制作
Previous app 上一个应用
Show {n} more changes 显示另外 {n} 项更改
Last updated: {date} 最后更新:{date}
column Author 作者
column Version 版本
Can't render this file because it contains an unexpected character in line 4 and column 3.
+92
View File
@@ -0,0 +1,92 @@
//! Which package a fresh install would use, so the install-folder fields show the folder that
//! install really goes into.
//!
//! It mirrors the backend's choice (`native::install::choose_kinds`, then `pick_asset`): the
//! preferred formats first, then every other format this platform installs, each tried against
//! every asset token. Choosing only the preferred format would show the portable `apps` folder
//! for a release that ships only an MSI, which the backend then installs into Program Files.
//! The UI cannot see a Linux machine's package managers, so there it answers nothing and the
//! field keeps saying "System default".
use artcraft_launcher_core::platform::{parse_asset_name, pick_asset};
use artcraft_launcher_core::protocol::LatestRelease;
use artcraft_launcher_core::{Arch, CraftApp, Os, PackageKind};
use crate::app::{Host, LauncherUi};
use crate::model::AppEntry;
/// The formats a fresh install can use on `os`, best first: native `available_kinds`.
fn platform_kinds(os: Os) -> &'static [PackageKind] {
match os {
Os::Windows => &[PackageKind::Msi, PackageKind::PortableZip],
Os::MacOs => &[PackageKind::Dmg],
_ => &[],
}
}
/// The order a fresh install of `app` tries formats in: `preferred` first, then the rest.
fn fresh_kinds(app: &CraftApp, os: Os, preferred: &[PackageKind]) -> Vec<PackageKind> {
let available: Vec<PackageKind> = platform_kinds(os).iter().copied().filter(|kind| app.installs(*kind)).collect();
let mut kinds: Vec<PackageKind> = preferred.iter().copied().filter(|kind| available.contains(kind)).collect();
for kind in available {
if !kinds.contains(&kind) {
kinds.push(kind);
}
}
kinds
}
impl LauncherUi {
/// The format and architecture of the package a fresh install of `entry` would use. Before
/// the release is known, the first format with no architecture (an MSI then answers
/// nothing, as its Program Files depends on it). `None` when nothing installs it here.
fn fresh_package(&self, entry: &AppEntry) -> Option<(PackageKind, Option<Arch>)> {
let platform = self.platform?;
let kinds = fresh_kinds(entry.app, platform.os, &self.settings.preferred_kinds);
let Some(LatestRelease::Found(release)) = entry.latest.as_ref() else {
return kinds.first().map(|kind| (*kind, None));
};
let stems: Vec<&str> = entry.app.stems().collect();
let (asset, kind) = pick_asset(release, &stems, platform, &kinds)?;
Some((kind, parse_asset_name(&asset.name, &stems).and_then(|name| name.arch())))
}
/// The folder a fresh install of `id` goes inside when no folder is chosen.
pub(crate) fn default_folder_for(&self, id: &str, host: &mut dyn Host) -> Option<String> {
let (kind, arch) = self.fresh_package(self.entry(id)?)?;
host.default_install_folder(kind, arch)
}
/// The default for Settings, which covers every app: the folder when every app that can be
/// installed here shares one, else `None` ("System default"). A 32-bit-only app goes to
/// `Program Files (x86)`, so the launcher's own architecture is not the answer. An app
/// whose release is not known yet cannot be installed, so it does not count.
pub(crate) fn suite_default_folder(&self, host: &mut dyn Host) -> Option<String> {
let mut shared: Option<String> = None;
for entry in self.entries.iter().filter(|entry| matches!(entry.latest, Some(LatestRelease::Found(_)))) {
let Some((kind, arch)) = self.fresh_package(entry) else { continue };
let folder = host.default_install_folder(kind, arch)?;
match &shared {
Some(seen) if *seen != folder => return None,
Some(_) => {}
None => shared = Some(folder),
}
}
shared
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn a_fresh_install_tries_the_preferred_format_then_the_rest() {
let app = &artcraft_launcher_core::SUITE[0];
assert_eq!(fresh_kinds(app, Os::Windows, &[]), [PackageKind::Msi, PackageKind::PortableZip]);
assert_eq!(fresh_kinds(app, Os::Windows, &[PackageKind::PortableZip]), [PackageKind::PortableZip, PackageKind::Msi]);
// A preference this platform cannot install is skipped, as the backend does.
assert_eq!(fresh_kinds(app, Os::Windows, &[PackageKind::Deb]), [PackageKind::Msi, PackageKind::PortableZip]);
assert!(fresh_kinds(app, Os::Linux, &[PackageKind::AppImage]).is_empty());
}
}
+1
View File
@@ -25,6 +25,7 @@ mod details;
mod dialogs;
pub mod i18n;
pub mod icons;
mod install_target;
mod local_time;
pub mod model;
mod motion;
+2 -1
View File
@@ -40,7 +40,8 @@ impl AppEntry {
pub fn has_download(&self, platform: Option<Platform>) -> bool {
let (Some(r), Some(p)) = (self.release(), platform) else { return false };
let stems: Vec<&str> = self.app.stems().collect();
pick_asset(r, &stems, p, p.download_kinds()).is_some()
let kinds: Vec<_> = p.download_kinds().iter().copied().filter(|k| self.app.installs(*k)).collect();
pick_asset(r, &stems, p, &kinds).is_some()
}
pub fn status(&self, platform: Option<Platform>, manage_apps: bool) -> AppStatus {
+2 -1
View File
@@ -203,7 +203,8 @@ impl LauncherUi {
sheet::panel(ui, tl!("Default install folder"), |ui| {
if self.custom_install_folders() {
let mut folder = self.settings.install_locations.root.clone().unwrap_or_default();
Self::folder_field(ui, &mut folder, None, host);
let default = self.suite_default_folder(host);
Self::folder_field(ui, &mut folder, default.as_deref(), host);
self.settings.install_locations.root = (!folder.is_empty()).then_some(folder);
note(ui, tl!("New installs use this folder. Updates stay in their current location."));
if self.platform.is_some_and(|p| p.os == Os::Linux) {
+19 -1
View File
@@ -1,6 +1,7 @@
//! The header, toolbar, footer, the grid of cards and the table, laid out like the apps page on
//! getartcraft.com: hairline cells, mono labels and square controls.
use artcraft_launcher_core::catalog::AppKind;
use artcraft_launcher_core::details::AppDetails;
use artcraft_launcher_core::platform::pick_asset;
use artcraft_launcher_core::protocol::{Command, JobPhase};
@@ -15,6 +16,17 @@ use crate::settings::{Filter, SortKey, ViewMode};
use crate::theme::{self, Tokens, rgb, tint};
use crate::widgets::{self, Kind};
/// The byline that says who makes an app: "by ArtCraft" or "by <publisher>". Official apps take
/// the accent colour, community apps the muted one.
fn kind_badge(ui: &mut Ui, app: &artcraft_launcher_core::CraftApp, t: &Tokens) {
let text = fmt(tl!("by {name}"), &[("name", app.publisher)]);
let color = match app.kind {
AppKind::Official => t.accent_ink,
AppKind::Community => t.muted,
};
widgets::badge(ui, &text, color);
}
/// Translate a relative timestamp ("just now", "5 min ago", …) into the current language.
fn ago_text(secs: i64, now: i64) -> String {
match time::ago_kind(secs, now) {
@@ -514,6 +526,7 @@ impl LauncherUi {
ui.spacing_mut().interact_size.y = 0.0;
ui.horizontal(|ui| {
widgets::wordmark_in(ui, app, 22.0, in_colour);
kind_badge(ui, app, &t);
});
ui.add(egui::Label::new(RichText::new(tr_ctx(current(), app.id, app.tagline)).font(tagline.clone()).color(t.muted)).truncate());
});
@@ -574,6 +587,7 @@ impl LauncherUi {
.column(Column::exact(176.0))
.column(Column::exact(150.0))
.column(Column::exact(104.0))
.column(Column::exact(120.0))
.column(Column::exact(206.0))
.header(42.0, |header| self.table_header(header, &mut sort_clicked, &t, span, clip))
.body(|body| self.table_rows(body, ids, &t, (title_h, tagline_h), now, (span, clip)));
@@ -656,6 +670,7 @@ impl LauncherUi {
(Some(SortKey::Status), tl!("Status")),
(None, tr_ctx(current(), "column", "Version")),
(Some(SortKey::Released), tr_ctx(current(), "column", "Released")),
(None, tr_ctx(current(), "column", "Author")),
(None, ""),
] {
header.col(|ui| {
@@ -670,7 +685,7 @@ impl LauncherUi {
}
/// The table's one row per app: the app (click to open its page), its status, the version,
/// when it was released, and its actions.
/// when it was released, who makes it, and its actions.
fn table_rows(
&mut self,
mut body: egui_extras::TableBody<'_>,
@@ -689,6 +704,9 @@ impl LauncherUi {
row.col(|ui| self.table_status_cell(ui, &entry, &status, t));
row.col(|ui| self.table_version_cell(ui, &entry, &status, t));
row.col(|ui| self.table_released_cell(ui, &entry, now, t));
row.col(|ui| {
ui.label(RichText::new(entry.app.publisher).color(t.muted));
});
row.col(|ui| self.actions(ui, &entry, &status, 204.0));
});
}
+167
View File
@@ -454,6 +454,173 @@ fn use_default_removes_an_app_override_and_settings_can_reset_the_root() {
assert_eq!(h.state().as_ref().unwrap().settings.install_locations.root, None);
}
/// The install-folder fields' default comes from the host, so a person sees the real folder a
/// fresh install uses (here `/Applications`) instead of only "System default", and a saved root
/// override replaces it. The default is the same value the empty field's hint shows.
#[test]
fn the_install_folder_fields_default_to_the_hosts_answer() {
struct DefaultHost {
picked: Rc<RefCell<Option<String>>>,
initial: Rc<RefCell<Option<Option<String>>>>,
}
impl Host for DefaultHost {
fn pick_folder(&mut self, initial: Option<&str>) -> Option<String> {
*self.initial.borrow_mut() = Some(initial.map(str::to_string));
self.picked.borrow_mut().take()
}
fn default_install_folder(&mut self, _kind: artcraft_launcher_core::PackageKind, _arch: Option<Arch>) -> Option<String> {
Some("/Applications".into())
}
}
artcraft_launcher_ui_egui::i18n::set_test_lang(artcraft_launcher_ui_egui::i18n::Lang::EN);
let sent = Rc::new(RefCell::new(Vec::new()));
let mut backend = Some(Fake {
events: vec![
Event::Latest { app: "photocraft".into(), latest: LatestRelease::Found(release("photocraft", "0.6.0", NOW)), from: Origin::GitHub },
Event::Detected { app: "photocraft".into(), installed: None },
],
sent: sent.clone(),
manage: true,
pictures: Rc::default(),
asked: vec![],
clock: Rc::new(Cell::new(NOW)),
});
let picked = Rc::new(RefCell::new(None));
let initial = Rc::new(RefCell::new(None));
let mut host = DefaultHost { picked: picked.clone(), initial: initial.clone() };
let harness = test_harness_builder(egui::Theme::Dark).with_size(egui::vec2(1180.0, 900.0)).build_ui_state(
move |ui, state: &mut Option<LauncherUi>| {
if let Some(backend) = backend.take() {
*state = Some(LauncherUi::new(ui.ctx(), Box::new(backend), Settings { notify: false, ..Default::default() }));
}
if let Some(launcher) = state {
launcher.logic(ui.ctx(), &mut host);
launcher.ui(ui, &mut host);
}
},
None,
);
let mut h = harness;
h.run_steps(8);
// Settings' install folder starts at the host's default.
h.get_by_label("Settings").click();
h.run_steps(4);
h.get_by_label("Browse…").scroll_to_me();
h.run_steps(4);
h.get_by_label("Browse…").click();
h.run_steps(3);
assert_eq!(initial.borrow().as_ref(), Some(&Some("/Applications".into())));
h.get_by_label("Done").click();
h.run_steps(3);
// So does the per-app install dialog's folder, and a saved root override replaces it.
h.get_by_label("Install").scroll_to_me();
h.run_steps(3);
h.get_by_label("Install").click();
h.run_steps(3);
h.get_by_label("Browse…").scroll_to_me();
h.run_steps(3);
h.get_by_label("Browse…").click();
h.run_steps(3);
assert_eq!(initial.borrow().as_ref(), Some(&Some("/Applications".into())));
h.state_mut().as_mut().unwrap().settings.install_locations.root = Some("/Volumes/Craft Apps".into());
h.run_steps(3);
h.get_by_label("Browse…").click();
h.run_steps(3);
assert_eq!(initial.borrow().as_ref(), Some(&Some("/Volumes/Craft Apps".into())));
h.check_accessibility();
}
/// A host whose default folder names the package it was asked about (`Msi X86`), and answers
/// nothing when the architecture is unknown, as the desktop host does for an MSI.
/// What Browse was last opened at: `None` until it is clicked.
type BrowsedFrom = Rc<RefCell<Option<Option<String>>>>;
struct PackageHost {
initial: BrowsedFrom,
}
impl Host for PackageHost {
fn pick_folder(&mut self, initial: Option<&str>) -> Option<String> {
*self.initial.borrow_mut() = Some(initial.map(str::to_string));
None
}
fn default_install_folder(&mut self, kind: artcraft_launcher_core::PackageKind, arch: Option<Arch>) -> Option<String> {
Some(format!("{kind:?} {:?}", arch?))
}
}
/// A Windows launcher whose apps publish only the named assets, with `preferred` formats saved.
/// Returns the harness and what Browse was last opened at.
fn windows_package_harness(
apps: &[(&str, &[&str])],
preferred: Vec<artcraft_launcher_core::PackageKind>,
) -> (Harness<'static, Option<LauncherUi>>, BrowsedFrom) {
artcraft_launcher_ui_egui::i18n::set_test_lang(artcraft_launcher_ui_egui::i18n::Lang::EN);
let mut events = Vec::new();
for (id, assets) in apps {
let mut latest = release(id, "0.6.0", NOW);
latest.assets = assets.iter().map(|name| Asset { name: (*name).into(), size: 1, url: format!("https://x/{name}"), sha256: None }).collect();
events.push(Event::Latest { app: (*id).into(), latest: LatestRelease::Found(latest), from: Origin::GitHub });
events.push(Event::Detected { app: (*id).into(), installed: None });
}
let fake = Fake { events, sent: Rc::default(), manage: true, pictures: Rc::default(), asked: vec![], clock: Rc::new(Cell::new(NOW)) };
let mut backend: Option<Box<dyn Backend>> = Some(Box::new(PlatformFake { inner: fake, platform: Platform { os: Os::Windows, arch: Arch::X64 } }));
let initial = Rc::new(RefCell::new(None));
let mut host = PackageHost { initial: initial.clone() };
let harness = test_harness_builder(egui::Theme::Dark).with_size(egui::vec2(1180.0, 900.0)).build_ui_state(
move |ui, state: &mut Option<LauncherUi>| {
if let Some(backend) = backend.take() {
let settings = Settings { notify: false, preferred_kinds: preferred.clone(), ..Default::default() };
*state = Some(LauncherUi::new(ui.ctx(), backend, settings));
}
if let Some(launcher) = state {
launcher.logic(ui.ctx(), &mut host);
launcher.ui(ui, &mut host);
}
},
None,
);
(harness, initial)
}
/// The install dialog's default follows the package the backend will really install: Portable
/// ZIP is preferred, but this release ships only a 32-bit MSI, so the app goes into the 32-bit
/// Program Files and not the launcher's `apps` folder.
#[test]
fn the_install_folder_default_follows_the_package_the_backend_falls_back_to() {
let (mut h, initial) =
windows_package_harness(&[("photocraft", &["photocraft-0.6.0-windows-x86.msi"])], vec![artcraft_launcher_core::PackageKind::PortableZip]);
h.run_steps(8);
h.get_by_label("Install").scroll_to_me();
h.run_steps(3);
h.get_by_label("Install").click();
h.run_steps(3);
h.get_by_label("Browse…").click();
h.run_steps(3);
assert_eq!(initial.borrow().as_ref(), Some(&Some("Msi X86".into())));
}
/// Settings covers every app, so it shows a folder only when every app's package shares one: a
/// 32-bit-only app beside a 64-bit one leaves it at "System default".
#[test]
fn settings_shows_a_default_folder_only_when_every_app_shares_it() {
let open_settings_browse = |apps: &[(&str, &[&str])]| {
let (mut h, initial) = windows_package_harness(apps, vec![]);
h.run_steps(8);
h.get_by_label("Settings").click();
h.run_steps(4);
h.get_by_label("Browse…").scroll_to_me();
h.run_steps(4);
h.get_by_label("Browse…").click();
h.run_steps(3);
initial.take()
};
let x64 = ["photocraft-0.6.0-windows-x64.msi", "photocraft-0.6.0-windows-x86.msi"];
let shared = open_settings_browse(&[("photocraft", &x64), ("vectorcraft", &["vectorcraft-0.6.0-windows-x64.msi"])]);
assert_eq!(shared, Some(Some("Msi X64".into())));
let mixed = open_settings_browse(&[("photocraft", &x64), ("vectorcraft", &["vectorcraft-0.6.0-windows-x86.msi"])]);
assert_eq!(mixed, Some(None));
}
#[cfg(windows)]
#[test]
fn windows_package_choice_can_select_portable_and_configures_the_backend() {
+1 -1
View File
@@ -57,7 +57,7 @@ echo "==> ArtCraft Launcher $VERSION for FreeBSD $ARCH"
export CARGO_BUILD_JOBS="${CARGO_BUILD_JOBS:-4}"
if [[ "$SKIP_BUILD" = 0 ]]; then
(cd "$ROOT" && cargo build --release --locked -p "$PKG")
(cd "$ROOT" && cargo build --release --locked -p "$PKG" ${CARGO_BUILD_TARGET:+--target "$CARGO_BUILD_TARGET"})
fi
WORK="$CARGO_TARGET_DIR/freebsd-package"
STAGE="$WORK/$BASENAME"