Files
modeling-app/src/lib/tauriFS.ts

431 lines
12 KiB
TypeScript
Raw Normal View History

import {
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
mkdir,
exists,
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
readTextFile,
writeTextFile,
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
stat,
} from '@tauri-apps/plugin-fs'
import { invoke } from '@tauri-apps/api/core'
import {
appConfigDir,
documentDir,
homeDir,
join,
sep,
} from '@tauri-apps/api/path'
import { isTauri } from './isTauri'
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
import type { FileEntry, ProjectWithEntryPointMetadata } from 'lib/types'
Rearchitect settings system to be scoped (#1956) * BROKEN: start of scopes for each setting * Clean up later: mostly-functional scoped settings! Broken command bar, unimplemented generated settings components * Working persisted project settings in-folder * Start working toward automatic commands and settings UI * Relatively stable, settings-menu-editable * Settings persistence tweaks after merge * Custom settings UI working properly, cleaner types * Allow boolean command types, create Settings UI for them * Add support for option and string Settings input types * Proof of concept settings from command bar * Add all settings to command bar * Allow settings to be hidden on a level * Better command titles for settings * Hide the settings the settings from the commands bar * Derive command defaultValue from *current* settingsMachine context * Fix generated settings UI for 'options' type settings * Pretty settings modal 💅 * Allow for rollback to parent level setting * fmt * Fix tsc errors not related to loading from localStorage * Better setting descriptions, better buttons * Make displayName searchable in command bar * Consolidate constants, get working in browser * Start fixing tests, better types for saved settings payloads * Fix playwright tests * Add a test for the settings modal * Add AtLeast to codespell ignore list * Goofed merge of codespellrc * Try fixing linux E2E tests * Make codespellrc word lowercase * fmt * Fix data-testid in Tauri test * Don't set text settings if nothing changed * Turn off unimplemented settings * Allow for multiple "execution-done" messages to have appeared in snapshot tests * Try fixing up snapshot tests * Switch from .json to .toml settings file format * Use a different method for overriding the default units * Try to force using the new common storage state in snapshot tests * Update tests to use TOML * fmt and remove console logs * Restore units to export * tsc errors, make snapshot tests use TOML * Ensure that snapshot tests use the basicStorageState * Re-organize use of test.use() * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update snapshots one more time since lighting changed * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix broken "Show in folder" for project-level settings * Fire all relevant actions after settings reset * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Properly reset the default directory * Hide settings by platform * Actually honor showDebugPanel * Unify settings hiding logic * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fix first extrusion snapshot * another attempt to fix extrustion snapshot * Rerun test suite * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger CI * more extrusion stuff * Replace resetSettings console log with comment --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
2024-04-02 10:29:34 -04:00
import {
FILE_EXT,
INDEX_IDENTIFIER,
MAX_PADDING,
PROJECT_ENTRYPOINT,
PROJECT_FOLDER,
RELEVANT_FILE_TYPES,
SETTINGS_FILE_EXT,
} from 'lib/constants'
import { SaveSettingsPayload, SettingsLevel } from './settings/settingsTypes'
import { initPromise, tomlParse } from 'lang/wasm'
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
type PathWithPossibleError = {
path: string | null
error: Error | null
}
export async function getInitialDefaultDir() {
if (!isTauri()) return ''
let dir
try {
dir = await documentDir()
} catch (e) {
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
dir = await join(await homeDir(), 'Documents') // for headless Linux (eg. Github Actions)
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
}
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
return await join(dir, PROJECT_FOLDER)
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
}
// Initializes the project directory and returns the path
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
// with any Errors that occurred
export async function initializeProjectDirectory(
directory: string
): Promise<PathWithPossibleError> {
let returnValue: PathWithPossibleError = {
path: null,
error: null,
}
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
if (!isTauri()) return returnValue
if (directory) {
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
returnValue = await testAndCreateDir(directory, returnValue)
}
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
// If the directory from settings does not exist or could not be created,
// use the default directory
if (returnValue.path === null) {
const INITIAL_DEFAULT_DIR = await getInitialDefaultDir()
const defaultReturnValue = await testAndCreateDir(
INITIAL_DEFAULT_DIR,
returnValue,
{
exists: 'Error checking default directory.',
create: 'Error creating default directory.',
}
)
returnValue.path = defaultReturnValue.path
returnValue.error =
returnValue.error === null ? defaultReturnValue.error : returnValue.error
}
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
return returnValue
}
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
async function testAndCreateDir(
directory: string,
returnValue = {
path: null,
error: null,
} as PathWithPossibleError,
errorMessages = {
exists:
'Error checking directory at path from saved settings. Using default.',
create:
'Error creating directory at path from saved settings. Using default.',
}
): Promise<PathWithPossibleError> {
const dirExists = await exists(directory).catch((e) => {
console.error(`Error checking directory ${directory}. Original error:`, e)
return new Error(errorMessages.exists)
})
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
if (dirExists instanceof Error) {
returnValue.error = dirExists
} else if (dirExists === false) {
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
const newDirCreated = await mkdir(directory, { recursive: true }).catch(
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
(e) => {
console.error(
`Error creating directory ${directory}. Original error:`,
e
)
return new Error(errorMessages.create)
}
)
if (newDirCreated instanceof Error) {
returnValue.error = newDirCreated
} else {
returnValue.path = directory
}
} else if (dirExists === true) {
returnValue.path = directory
}
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
return returnValue
}
export function isProjectDirectory(fileOrDir: Partial<FileEntry>) {
return (
fileOrDir.children?.length &&
fileOrDir.children.some((child) => child.name === PROJECT_ENTRYPOINT)
)
}
// Read the contents of a directory
// and return the valid projects
export async function getProjectsInDir(projectDir: string) {
const readProjects = (
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
await invoke<FileEntry[]>('read_dir_recursive', { path: projectDir })
).filter(isProjectDirectory)
const projectsWithMetadata = await Promise.all(
readProjects.map(async (p) => ({
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
entrypointMetadata: await stat(await join(p.path, PROJECT_ENTRYPOINT)),
...p,
}))
)
return projectsWithMetadata
}
Franknoirot/multi file (#844) * Fix unrelated bug, settings button in the home sidebar doesn't go to the home settings after my previous fixes to routes * Turn on "Replay Onboarding" button in home settings * Add icons * Add Tooltip component * Rough-in of sidebar styling and add initial File Tree * Polish basic styling * Show nested files and directories * Add tests * use camelCase for entrypointMetadata * Add ability to switch files via links * Revert "Improve Prop Typings for Modals. Remove instances of `any`. (… (#813) Revert "Improve Prop Typings for Modals. Remove instances of `any`. (#792)" This reverts commit 629f326f4cdf13d83a62f471b4b9a40d3c3a2a88. * ffmpeg instructions (#814) * Formatting * Remove folder names from display in app header * Highlight current file, open folders it's within * Navigate on double click, delete on Cmd + Esc + highlight focused folders * Migrate to an XState machine, add create new file * Add ability to create folders (with naive names) + remove command bar stuff for now * Use route loader data to instantiate the kcl code * Clean up some unused things * Add ability to rename files * Add ability to rename folders * Add keyboard shortcuts for creating files/folders * Tooltip style tweaks * Polish + re-execute when switching files with a connection * Reset code before navigating via file tree * Don't invoke `readProject` if you're in a browser * Show files and folders for projects on home page * Don't highlight folders further down the file tree * @jgomez720 and @jessfraz feedback: + indentation markers + proper file icon + bump down font size + touch up colors * Tune down spacing, allow scroll overflow * Fix formatting * Update src/lib/tauriFS.ts * Add a confirmation dialog when deleting Signed-off-by: Frank Noirot <frank@kittycad.io> --------- Signed-off-by: Frank Noirot <frank@kittycad.io> Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch>
2023-10-16 13:28:41 -04:00
export const isHidden = (fileOrDir: FileEntry) =>
!!fileOrDir.name?.startsWith('.')
export const isDir = (fileOrDir: FileEntry) =>
'children' in fileOrDir && fileOrDir.children !== undefined
export function deepFileFilter(
entries: FileEntry[],
filterFn: (f: FileEntry) => boolean
): FileEntry[] {
const filteredEntries: FileEntry[] = []
for (const fileOrDir of entries) {
if ('children' in fileOrDir && fileOrDir.children !== undefined) {
const filteredChildren = deepFileFilter(fileOrDir.children, filterFn)
if (filterFn(fileOrDir)) {
filteredEntries.push({
...fileOrDir,
children: filteredChildren,
})
}
} else if (filterFn(fileOrDir)) {
filteredEntries.push(fileOrDir)
}
}
return filteredEntries
}
export function deepFileFilterFlat(
entries: FileEntry[],
filterFn: (f: FileEntry) => boolean
): FileEntry[] {
const filteredEntries: FileEntry[] = []
for (const fileOrDir of entries) {
if ('children' in fileOrDir && fileOrDir.children !== undefined) {
const filteredChildren = deepFileFilterFlat(fileOrDir.children, filterFn)
if (filterFn(fileOrDir)) {
filteredEntries.push({
...fileOrDir,
children: filteredChildren,
})
}
filteredEntries.push(...filteredChildren)
} else if (filterFn(fileOrDir)) {
filteredEntries.push(fileOrDir)
}
}
return filteredEntries
}
// Read the contents of a project directory
// and return all relevant files and sub-directories recursively
export async function readProject(projectDir: string) {
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
const readFiles = await invoke<FileEntry[]>('read_dir_recursive', {
path: projectDir,
Franknoirot/multi file (#844) * Fix unrelated bug, settings button in the home sidebar doesn't go to the home settings after my previous fixes to routes * Turn on "Replay Onboarding" button in home settings * Add icons * Add Tooltip component * Rough-in of sidebar styling and add initial File Tree * Polish basic styling * Show nested files and directories * Add tests * use camelCase for entrypointMetadata * Add ability to switch files via links * Revert "Improve Prop Typings for Modals. Remove instances of `any`. (… (#813) Revert "Improve Prop Typings for Modals. Remove instances of `any`. (#792)" This reverts commit 629f326f4cdf13d83a62f471b4b9a40d3c3a2a88. * ffmpeg instructions (#814) * Formatting * Remove folder names from display in app header * Highlight current file, open folders it's within * Navigate on double click, delete on Cmd + Esc + highlight focused folders * Migrate to an XState machine, add create new file * Add ability to create folders (with naive names) + remove command bar stuff for now * Use route loader data to instantiate the kcl code * Clean up some unused things * Add ability to rename files * Add ability to rename folders * Add keyboard shortcuts for creating files/folders * Tooltip style tweaks * Polish + re-execute when switching files with a connection * Reset code before navigating via file tree * Don't invoke `readProject` if you're in a browser * Show files and folders for projects on home page * Don't highlight folders further down the file tree * @jgomez720 and @jessfraz feedback: + indentation markers + proper file icon + bump down font size + touch up colors * Tune down spacing, allow scroll overflow * Fix formatting * Update src/lib/tauriFS.ts * Add a confirmation dialog when deleting Signed-off-by: Frank Noirot <frank@kittycad.io> --------- Signed-off-by: Frank Noirot <frank@kittycad.io> Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch>
2023-10-16 13:28:41 -04:00
})
return deepFileFilter(readFiles, isRelevantFileOrDir)
}
// Given a read project, return the number of .kcl files,
// both in the root directory and in sub-directories,
// and folders that contain at least one .kcl file
export function getPartsCount(project: FileEntry[]) {
const flatProject = deepFileFilterFlat(project, isRelevantFileOrDir)
const kclFileCount = flatProject.filter((f) =>
f.name?.endsWith(FILE_EXT)
).length
const kclDirCount = flatProject.filter((f) => f.children !== undefined).length
return {
kclFileCount,
kclDirCount,
}
}
// Determines if a file or directory is relevant to the project
// i.e. not a hidden file or directory, and is a relevant file type
// or contains at least one relevant file (even if it's nested)
// or is a completely empty directory
export function isRelevantFileOrDir(fileOrDir: FileEntry) {
let isRelevantDir = false
if ('children' in fileOrDir && fileOrDir.children !== undefined) {
isRelevantDir =
!isHidden(fileOrDir) &&
(fileOrDir.children.some(isRelevantFileOrDir) ||
fileOrDir.children.length === 0)
}
const isRelevantFile =
!isHidden(fileOrDir) &&
RELEVANT_FILE_TYPES.some((ext) => fileOrDir.name?.endsWith(ext))
return (
(isDir(fileOrDir) && isRelevantDir) || (!isDir(fileOrDir) && isRelevantFile)
)
}
// Deeply sort the files and directories in a project like VS Code does:
// The main.kcl file is always first, then files, then directories
// Files and directories are sorted alphabetically
export function sortProject(project: FileEntry[]): FileEntry[] {
const sortedProject = project.sort((a, b) => {
if (a.name === PROJECT_ENTRYPOINT) {
return -1
} else if (b.name === PROJECT_ENTRYPOINT) {
return 1
} else if (a.children === undefined && b.children !== undefined) {
return -1
} else if (a.children !== undefined && b.children === undefined) {
return 1
} else if (a.name && b.name) {
return a.name.localeCompare(b.name)
} else {
return 0
}
})
return sortedProject.map((fileOrDir: FileEntry) => {
if ('children' in fileOrDir && fileOrDir.children !== undefined) {
return {
...fileOrDir,
children: sortProject(fileOrDir.children),
}
} else {
return fileOrDir
}
})
}
// Creates a new file in the default directory with the default project name
// Returns the path to the new file
export async function createNewProject(
path: string,
initCode = ''
): Promise<ProjectWithEntryPointMetadata> {
if (!isTauri) {
throw new Error('createNewProject() can only be called from a Tauri app')
}
const dirExists = await exists(path)
if (!dirExists) {
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
await mkdir(path, { recursive: true }).catch((err) => {
console.error('Error creating new directory:', err)
throw err
})
}
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
await writeTextFile(await join(path, PROJECT_ENTRYPOINT), initCode).catch(
(err) => {
console.error('Error creating new file:', err)
throw err
}
)
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
const m = await stat(path)
return {
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
name: path.slice(path.lastIndexOf(sep()) + 1),
path: path,
Franknoirot/multi file (#844) * Fix unrelated bug, settings button in the home sidebar doesn't go to the home settings after my previous fixes to routes * Turn on "Replay Onboarding" button in home settings * Add icons * Add Tooltip component * Rough-in of sidebar styling and add initial File Tree * Polish basic styling * Show nested files and directories * Add tests * use camelCase for entrypointMetadata * Add ability to switch files via links * Revert "Improve Prop Typings for Modals. Remove instances of `any`. (… (#813) Revert "Improve Prop Typings for Modals. Remove instances of `any`. (#792)" This reverts commit 629f326f4cdf13d83a62f471b4b9a40d3c3a2a88. * ffmpeg instructions (#814) * Formatting * Remove folder names from display in app header * Highlight current file, open folders it's within * Navigate on double click, delete on Cmd + Esc + highlight focused folders * Migrate to an XState machine, add create new file * Add ability to create folders (with naive names) + remove command bar stuff for now * Use route loader data to instantiate the kcl code * Clean up some unused things * Add ability to rename files * Add ability to rename folders * Add keyboard shortcuts for creating files/folders * Tooltip style tweaks * Polish + re-execute when switching files with a connection * Reset code before navigating via file tree * Don't invoke `readProject` if you're in a browser * Show files and folders for projects on home page * Don't highlight folders further down the file tree * @jgomez720 and @jessfraz feedback: + indentation markers + proper file icon + bump down font size + touch up colors * Tune down spacing, allow scroll overflow * Fix formatting * Update src/lib/tauriFS.ts * Add a confirmation dialog when deleting Signed-off-by: Frank Noirot <frank@kittycad.io> --------- Signed-off-by: Frank Noirot <frank@kittycad.io> Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch>
2023-10-16 13:28:41 -04:00
entrypointMetadata: m,
children: [
{
name: PROJECT_ENTRYPOINT,
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
path: await join(path, PROJECT_ENTRYPOINT),
children: [],
},
],
}
}
// create a regex to match the project name
// replacing any instances of "$n" with a regex to match any number
function interpolateProjectName(projectName: string) {
const regex = new RegExp(
projectName.replace(getPaddedIdentifierRegExp(), '([0-9]+)')
)
return regex
}
// Returns the next available index for a project name
export function getNextProjectIndex(projectName: string, files: FileEntry[]) {
const regex = interpolateProjectName(projectName)
const matches = files.map((file) => file.name?.match(regex))
const indices = matches
.filter(Boolean)
.map((match) => match![1])
.map(Number)
const maxIndex = Math.max(...indices, -1)
return maxIndex + 1
}
// Interpolates the project name with the next available index,
// padding the index with 0s if necessary
export function interpolateProjectNameWithIndex(
projectName: string,
index: number
) {
const regex = getPaddedIdentifierRegExp()
const matches = projectName.match(regex)
const padStartLength = Math.min(
matches !== null ? matches[1]?.length || 0 : 0,
MAX_PADDING
)
return projectName.replace(
regex,
index.toString().padStart(padStartLength + 1, '0')
)
}
export function doesProjectNameNeedInterpolated(projectName: string) {
return projectName.includes(INDEX_IDENTIFIER)
}
function escapeRegExpChars(string: string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
}
function getPaddedIdentifierRegExp() {
const escapedIdentifier = escapeRegExpChars(INDEX_IDENTIFIER)
return new RegExp(`${escapedIdentifier}(${escapedIdentifier.slice(-1)}*)`)
}
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
Rearchitect settings system to be scoped (#1956) * BROKEN: start of scopes for each setting * Clean up later: mostly-functional scoped settings! Broken command bar, unimplemented generated settings components * Working persisted project settings in-folder * Start working toward automatic commands and settings UI * Relatively stable, settings-menu-editable * Settings persistence tweaks after merge * Custom settings UI working properly, cleaner types * Allow boolean command types, create Settings UI for them * Add support for option and string Settings input types * Proof of concept settings from command bar * Add all settings to command bar * Allow settings to be hidden on a level * Better command titles for settings * Hide the settings the settings from the commands bar * Derive command defaultValue from *current* settingsMachine context * Fix generated settings UI for 'options' type settings * Pretty settings modal 💅 * Allow for rollback to parent level setting * fmt * Fix tsc errors not related to loading from localStorage * Better setting descriptions, better buttons * Make displayName searchable in command bar * Consolidate constants, get working in browser * Start fixing tests, better types for saved settings payloads * Fix playwright tests * Add a test for the settings modal * Add AtLeast to codespell ignore list * Goofed merge of codespellrc * Try fixing linux E2E tests * Make codespellrc word lowercase * fmt * Fix data-testid in Tauri test * Don't set text settings if nothing changed * Turn off unimplemented settings * Allow for multiple "execution-done" messages to have appeared in snapshot tests * Try fixing up snapshot tests * Switch from .json to .toml settings file format * Use a different method for overriding the default units * Try to force using the new common storage state in snapshot tests * Update tests to use TOML * fmt and remove console logs * Restore units to export * tsc errors, make snapshot tests use TOML * Ensure that snapshot tests use the basicStorageState * Re-organize use of test.use() * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update snapshots one more time since lighting changed * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix broken "Show in folder" for project-level settings * Fire all relevant actions after settings reset * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Properly reset the default directory * Hide settings by platform * Actually honor showDebugPanel * Unify settings hiding logic * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fix first extrusion snapshot * another attempt to fix extrustion snapshot * Rerun test suite * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger CI * more extrusion stuff * Replace resetSettings console log with comment --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
2024-04-02 10:29:34 -04:00
export async function getUserSettingsFilePath(
filename: string = SETTINGS_FILE_EXT
) {
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
const dir = await appConfigDir()
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
return await join(dir, filename)
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
}
Rearchitect settings system to be scoped (#1956) * BROKEN: start of scopes for each setting * Clean up later: mostly-functional scoped settings! Broken command bar, unimplemented generated settings components * Working persisted project settings in-folder * Start working toward automatic commands and settings UI * Relatively stable, settings-menu-editable * Settings persistence tweaks after merge * Custom settings UI working properly, cleaner types * Allow boolean command types, create Settings UI for them * Add support for option and string Settings input types * Proof of concept settings from command bar * Add all settings to command bar * Allow settings to be hidden on a level * Better command titles for settings * Hide the settings the settings from the commands bar * Derive command defaultValue from *current* settingsMachine context * Fix generated settings UI for 'options' type settings * Pretty settings modal 💅 * Allow for rollback to parent level setting * fmt * Fix tsc errors not related to loading from localStorage * Better setting descriptions, better buttons * Make displayName searchable in command bar * Consolidate constants, get working in browser * Start fixing tests, better types for saved settings payloads * Fix playwright tests * Add a test for the settings modal * Add AtLeast to codespell ignore list * Goofed merge of codespellrc * Try fixing linux E2E tests * Make codespellrc word lowercase * fmt * Fix data-testid in Tauri test * Don't set text settings if nothing changed * Turn off unimplemented settings * Allow for multiple "execution-done" messages to have appeared in snapshot tests * Try fixing up snapshot tests * Switch from .json to .toml settings file format * Use a different method for overriding the default units * Try to force using the new common storage state in snapshot tests * Update tests to use TOML * fmt and remove console logs * Restore units to export * tsc errors, make snapshot tests use TOML * Ensure that snapshot tests use the basicStorageState * Re-organize use of test.use() * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update snapshots one more time since lighting changed * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix broken "Show in folder" for project-level settings * Fire all relevant actions after settings reset * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Properly reset the default directory * Hide settings by platform * Actually honor showDebugPanel * Unify settings hiding logic * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fix first extrusion snapshot * another attempt to fix extrustion snapshot * Rerun test suite * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger CI * more extrusion stuff * Replace resetSettings console log with comment --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
2024-04-02 10:29:34 -04:00
export async function readSettingsFile(
path: string
): Promise<Partial<SaveSettingsPayload>> {
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
const dir = path.slice(0, path.lastIndexOf(sep()))
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
const dirExists = await exists(dir)
if (!dirExists) {
Migrate to tauri v2 (#1400) * Fix vite build (tauri build still broken) * Fix yarn builds with a couple of shortcuts * Fix file creation * Fix documentDir behavior * Got stream with default file * Clean up * Clean up * Use 'unstable'; fix devtools callsite The API changed a bit here, which forces us to use the unstable crate feature. The call to open devtools is also new; it's now on the webview not window. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> * Bring back read_dir_recursive from v1 * Fix dates * More fixes, incl. conf files * cargo fmt * Add Updater plugin * Fix types * Fix isTauri detection and updater bootup * Schemas * Clean up * Disable devtools * Attempt at fixing builds * WIP Ubuntu dep * WIP Ubuntu dep * WIP keys in debug * Enable updater only on release builds * Reenable webtools on debug * No linux bundles * Typo * Attemp at fixing --bundles none * Manual tauri debug build * Empty commit to trigger the CI * Fix settings * Empty commit to trigger the CI * Merge branch 'main' into pierremtb/issue1349 * Add allow-create perm * tauri-driver no cap * Empty commit to trigger the CI * Clean up * Clean up * Migrate to tauri v2 Fixes #1349 * Fix fmt * Merge branch 'main' into pierremtb/issue1349 * Force BUILD_RELEASE: true * Bump tauri to new beta * Merge branch 'main' into pierremtb/issue1349 * Fix linux tests * Fix types * Add --verbose to tauri-action * Move --verbose to front * Back to tauri-driver@0.1.3 and single \ for win * Back to latest driver, and windows wip * Disable release conf temporarily * Rollback to 2.0.0-beta.2 * Rollback to 2.0.0-beta.1 * Move bundle to root for src-tauri/tauri.release.conf.json * All packages to latest (add http and shell to package.json) * Testing latest commit for tauri-action * Remove tauri action * Add cat * WIP * Update ci.yml * Disable release conf * Disable rust cache * Add tauri-action back for release builds * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update .codespellrc * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix type * Clean up * More clean up * Fix path concatenation with join * Attempt at fixing linux tests * Config clean up * Downgrade to tauri-driver@0.1.3 * Looks like tauri v2 is actually doing better with linux package names ah! * Change Linux apt packages * Increase wdio connectionRetryTimeout * Revert connectionRetryTimeout and bump tauri packages * Back to latest tauri-driver * Disable linux e2e tests * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Clean up * Update snapshots * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Remove @sentry/react * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rename migrated.json to desktop.json * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Trigger CI * Change wasm url to http on Windows --------- Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: Paul R. Tagliamonte <paul@kittycad.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
2024-04-09 08:04:36 -04:00
await mkdir(dir, { recursive: true })
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
}
const settingsExist = dirExists ? await exists(path) : false
if (!settingsExist) {
console.log(`Settings file does not exist at ${path}`)
Rearchitect settings system to be scoped (#1956) * BROKEN: start of scopes for each setting * Clean up later: mostly-functional scoped settings! Broken command bar, unimplemented generated settings components * Working persisted project settings in-folder * Start working toward automatic commands and settings UI * Relatively stable, settings-menu-editable * Settings persistence tweaks after merge * Custom settings UI working properly, cleaner types * Allow boolean command types, create Settings UI for them * Add support for option and string Settings input types * Proof of concept settings from command bar * Add all settings to command bar * Allow settings to be hidden on a level * Better command titles for settings * Hide the settings the settings from the commands bar * Derive command defaultValue from *current* settingsMachine context * Fix generated settings UI for 'options' type settings * Pretty settings modal 💅 * Allow for rollback to parent level setting * fmt * Fix tsc errors not related to loading from localStorage * Better setting descriptions, better buttons * Make displayName searchable in command bar * Consolidate constants, get working in browser * Start fixing tests, better types for saved settings payloads * Fix playwright tests * Add a test for the settings modal * Add AtLeast to codespell ignore list * Goofed merge of codespellrc * Try fixing linux E2E tests * Make codespellrc word lowercase * fmt * Fix data-testid in Tauri test * Don't set text settings if nothing changed * Turn off unimplemented settings * Allow for multiple "execution-done" messages to have appeared in snapshot tests * Try fixing up snapshot tests * Switch from .json to .toml settings file format * Use a different method for overriding the default units * Try to force using the new common storage state in snapshot tests * Update tests to use TOML * fmt and remove console logs * Restore units to export * tsc errors, make snapshot tests use TOML * Ensure that snapshot tests use the basicStorageState * Re-organize use of test.use() * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update snapshots one more time since lighting changed * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix broken "Show in folder" for project-level settings * Fire all relevant actions after settings reset * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Properly reset the default directory * Hide settings by platform * Actually honor showDebugPanel * Unify settings hiding logic * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fix first extrusion snapshot * another attempt to fix extrustion snapshot * Rerun test suite * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger CI * more extrusion stuff * Replace resetSettings console log with comment --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
2024-04-02 10:29:34 -04:00
return {}
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
}
try {
await initPromise
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
const settings = await readTextFile(path)
Rearchitect settings system to be scoped (#1956) * BROKEN: start of scopes for each setting * Clean up later: mostly-functional scoped settings! Broken command bar, unimplemented generated settings components * Working persisted project settings in-folder * Start working toward automatic commands and settings UI * Relatively stable, settings-menu-editable * Settings persistence tweaks after merge * Custom settings UI working properly, cleaner types * Allow boolean command types, create Settings UI for them * Add support for option and string Settings input types * Proof of concept settings from command bar * Add all settings to command bar * Allow settings to be hidden on a level * Better command titles for settings * Hide the settings the settings from the commands bar * Derive command defaultValue from *current* settingsMachine context * Fix generated settings UI for 'options' type settings * Pretty settings modal 💅 * Allow for rollback to parent level setting * fmt * Fix tsc errors not related to loading from localStorage * Better setting descriptions, better buttons * Make displayName searchable in command bar * Consolidate constants, get working in browser * Start fixing tests, better types for saved settings payloads * Fix playwright tests * Add a test for the settings modal * Add AtLeast to codespell ignore list * Goofed merge of codespellrc * Try fixing linux E2E tests * Make codespellrc word lowercase * fmt * Fix data-testid in Tauri test * Don't set text settings if nothing changed * Turn off unimplemented settings * Allow for multiple "execution-done" messages to have appeared in snapshot tests * Try fixing up snapshot tests * Switch from .json to .toml settings file format * Use a different method for overriding the default units * Try to force using the new common storage state in snapshot tests * Update tests to use TOML * fmt and remove console logs * Restore units to export * tsc errors, make snapshot tests use TOML * Ensure that snapshot tests use the basicStorageState * Re-organize use of test.use() * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update snapshots one more time since lighting changed * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix broken "Show in folder" for project-level settings * Fire all relevant actions after settings reset * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Properly reset the default directory * Hide settings by platform * Actually honor showDebugPanel * Unify settings hiding logic * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fix first extrusion snapshot * another attempt to fix extrustion snapshot * Rerun test suite * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger CI * more extrusion stuff * Replace resetSettings console log with comment --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
2024-04-02 10:29:34 -04:00
// We expect the settings to be under a top-level [settings] key
return tomlParse(settings).settings as Partial<SaveSettingsPayload>
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
} catch (e) {
console.error('Error reading settings file:', e)
Rearchitect settings system to be scoped (#1956) * BROKEN: start of scopes for each setting * Clean up later: mostly-functional scoped settings! Broken command bar, unimplemented generated settings components * Working persisted project settings in-folder * Start working toward automatic commands and settings UI * Relatively stable, settings-menu-editable * Settings persistence tweaks after merge * Custom settings UI working properly, cleaner types * Allow boolean command types, create Settings UI for them * Add support for option and string Settings input types * Proof of concept settings from command bar * Add all settings to command bar * Allow settings to be hidden on a level * Better command titles for settings * Hide the settings the settings from the commands bar * Derive command defaultValue from *current* settingsMachine context * Fix generated settings UI for 'options' type settings * Pretty settings modal 💅 * Allow for rollback to parent level setting * fmt * Fix tsc errors not related to loading from localStorage * Better setting descriptions, better buttons * Make displayName searchable in command bar * Consolidate constants, get working in browser * Start fixing tests, better types for saved settings payloads * Fix playwright tests * Add a test for the settings modal * Add AtLeast to codespell ignore list * Goofed merge of codespellrc * Try fixing linux E2E tests * Make codespellrc word lowercase * fmt * Fix data-testid in Tauri test * Don't set text settings if nothing changed * Turn off unimplemented settings * Allow for multiple "execution-done" messages to have appeared in snapshot tests * Try fixing up snapshot tests * Switch from .json to .toml settings file format * Use a different method for overriding the default units * Try to force using the new common storage state in snapshot tests * Update tests to use TOML * fmt and remove console logs * Restore units to export * tsc errors, make snapshot tests use TOML * Ensure that snapshot tests use the basicStorageState * Re-organize use of test.use() * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update snapshots one more time since lighting changed * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix broken "Show in folder" for project-level settings * Fire all relevant actions after settings reset * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Properly reset the default directory * Hide settings by platform * Actually honor showDebugPanel * Unify settings hiding logic * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fix first extrusion snapshot * another attempt to fix extrustion snapshot * Rerun test suite * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger CI * more extrusion stuff * Replace resetSettings console log with comment --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
2024-04-02 10:29:34 -04:00
return {}
}
}
export async function getSettingsFilePaths(
projectPath?: string
): Promise<Partial<Record<SettingsLevel, string>>> {
const { user, project } = await getSettingsFolderPaths(projectPath)
return {
user: user + 'user' + SETTINGS_FILE_EXT,
project:
project !== undefined
? project + (isTauri() ? sep() : '/') + 'project' + SETTINGS_FILE_EXT
Rearchitect settings system to be scoped (#1956) * BROKEN: start of scopes for each setting * Clean up later: mostly-functional scoped settings! Broken command bar, unimplemented generated settings components * Working persisted project settings in-folder * Start working toward automatic commands and settings UI * Relatively stable, settings-menu-editable * Settings persistence tweaks after merge * Custom settings UI working properly, cleaner types * Allow boolean command types, create Settings UI for them * Add support for option and string Settings input types * Proof of concept settings from command bar * Add all settings to command bar * Allow settings to be hidden on a level * Better command titles for settings * Hide the settings the settings from the commands bar * Derive command defaultValue from *current* settingsMachine context * Fix generated settings UI for 'options' type settings * Pretty settings modal 💅 * Allow for rollback to parent level setting * fmt * Fix tsc errors not related to loading from localStorage * Better setting descriptions, better buttons * Make displayName searchable in command bar * Consolidate constants, get working in browser * Start fixing tests, better types for saved settings payloads * Fix playwright tests * Add a test for the settings modal * Add AtLeast to codespell ignore list * Goofed merge of codespellrc * Try fixing linux E2E tests * Make codespellrc word lowercase * fmt * Fix data-testid in Tauri test * Don't set text settings if nothing changed * Turn off unimplemented settings * Allow for multiple "execution-done" messages to have appeared in snapshot tests * Try fixing up snapshot tests * Switch from .json to .toml settings file format * Use a different method for overriding the default units * Try to force using the new common storage state in snapshot tests * Update tests to use TOML * fmt and remove console logs * Restore units to export * tsc errors, make snapshot tests use TOML * Ensure that snapshot tests use the basicStorageState * Re-organize use of test.use() * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Update snapshots one more time since lighting changed * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Fix broken "Show in folder" for project-level settings * Fire all relevant actions after settings reset * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Properly reset the default directory * Hide settings by platform * Actually honor showDebugPanel * Unify settings hiding logic * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fix first extrusion snapshot * another attempt to fix extrustion snapshot * Rerun test suite * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger CI * more extrusion stuff * Replace resetSettings console log with comment --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
2024-04-02 10:29:34 -04:00
: undefined,
}
}
export async function getSettingsFolderPaths(projectPath?: string) {
const user = isTauri() ? await appConfigDir() : '/'
const project = projectPath !== undefined ? projectPath : undefined
return {
user,
project,
File based settings (#1679) * Rename GlobalStateContext to SettingsAuthContext * Naive initial impl of settings persistence to file system * Update app identifier in tauri config * Add "show in folder" tauri command * Load from and save to file system in Tauri app * Add documents drive to tauri permission scope * Add recursive prop to default dir selection dialog * Add success toast to web restore defaults action * Add a way to validate read-in settings * Update imports to use separate settings lib file * Validate localStorage-loaded settings, combine error message * Add a e2e test for validation * Clean up state state bugs * Reverse validation looping so new users don't error * update settingsMachine typegen to remove conflicts * Fmt * Fix TS errors * Fix import paths, etc post-merge * Make default length units `mm` and 'metric' * Rename to SettingsAuth* * cargo fmt * Revert Tauri config identifier change * Update clientSideInfra's baseUnits from settings * Break apart CommandBar and CommandBarProvider * Bugfix: don't validate defaultValue when it's not configured * Allow some TauriFS functions to no-op from browser * Sidestep circular deps by loading context and kclManager only from React-land * Update broken import paths * Separate loaders from Router, load settings on every route * Break apart settings types, utils, and constants * Fix Jest tests by decoupling reliance on useLoaderData from SettingsAuthProvider * Fix up Router loader data with "layout routes" https://reactrouter.com/en/main/route/route#layout-routes * Move settings validation and toast to custom hook so the toast renders * fmt * Use forks for Vitest https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker * $APPCONFIG !== $APPDATA only on Linux + change the identifier back since it really doesn't seem to affect app signing * Debugging on Linux * Better directory validation, fix reset settings button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * defaultDirectory can be empty in browser * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * re-trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-14 15:56:45 -04:00
}
}