Lf94/tauri to electron (#3315)

* Get electron building something at all

* Merge Frank test setup work (#3418)

* Working window.electron.getPath

* Loading project-specific settings in electron tests

* Simplify test until we can get snapshots/traces working in electron tests

* test tweaks

---------

Co-authored-by: Frank Noirot <frank@kittycad.io>

* add test #3375 and #3420

* put kcl files together

* move files

* can sort projects #3362

* File in the file pane should open with a single click #3385

* pressing delete on home screen should do nothing #3387

* add aria labels to icons

* Rename and delete projects, also spam arrow keys when renaming #3364 #3365 #3259

* Fix up paths

* Update flake.nix to support Electron

* Remove a layer of indirection

* Work without a web server

* Fix settings#projectDir link on home

* Fix login (requires new @kittycad/lib WHICH IS NOT INCLUDED HERE)

* Lee: Tests are broken because auth skip needs to happen

* get setting override envs passed through

* tweak eletron CI

* yml tweak

* fmt

* NUKE tauri shit post merge with main

* another test auth tweak

* Revert "another test auth tweak"

This reverts commit b2254b10af.

* try CI again

* CI tweaks

* SKIP_AUTH true now on playwright

* Skipping auth when NODE_ENV=development now

* fmt

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* Use BASE_URL()

* fix exists

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix foldername for macos

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* update for windows

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix version in lower right

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* cleanup unused imports

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* progress on is playwright

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix test folders

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix fmt

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* remove tauri from actions bullshit

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* remove tauri dir

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixups the coredump async shit

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* node env dev

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix cancellable

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* cleanup unnessary things

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* env vars

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* Bring back fix for NOT using hardcoded main.kcl

* env

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fmt

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* Revert "updates"

This reverts commit da5d9f1043eb94404e8b3f8044088e990e34a4ef.

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* remove tauri clippuy

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* less retries for now, no debug

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* tsconfig

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* small tsc fix

* update some tsc

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* tsc env

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix other tsc

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* small change for routeLoaders

* rm old screenshot

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix auth

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix last onew

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* auth clean up

* fix package.json

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* dissmissed screen on tests

* add waits between files being written

* put back retried

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix weird programMemory Map issue

* put private back

* Revert "put private back"

This reverts commit d311b978ca.

* Revert "fix weird programMemory Map issue"

This reverts commit 6c387bdf62.

* remove serde-wasm-bindgen

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* add env

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)

* fix tests

* more test tweaks

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)

* another tweak

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)

* more test tweaks

* more tweaks

* increase macos timeout

* try fix macos

* disable macos playwright tests

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch>
Co-authored-by: Frank Noirot <frank@kittycad.io>
Co-authored-by: Adam Sunderland <iterion@gmail.com>
Co-authored-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
49fl
2024-08-16 07:15:42 -04:00
committed by GitHub
parent d916c79874
commit 8400e06dd6
196 changed files with 7133 additions and 13052 deletions

View File

@ -15,19 +15,10 @@ import {
} from 'xstate'
import { useCommandsContext } from 'hooks/useCommandsContext'
import { fileMachine } from 'machines/fileMachine'
import {
mkdir,
remove,
rename,
create,
writeTextFile,
exists,
} from '@tauri-apps/plugin-fs'
import { isTauri } from 'lib/isTauri'
import { join, sep } from '@tauri-apps/api/path'
import { isDesktop } from 'lib/isDesktop'
import { DEFAULT_FILE_NAME, FILE_EXT } from 'lib/constants'
import { getProjectInfo } from 'lib/tauri'
import { getNextDirName, getNextFileName } from 'lib/tauriFS'
import { getProjectInfo } from 'lib/desktop'
import { getNextDirName, getNextFileName } from 'lib/desktopFS'
type MachineContext<T extends AnyStateMachine> = {
state: StateFrom<T>
@ -59,7 +50,9 @@ export const FileMachineProvider = ({
commandBarSend({ type: 'Close' })
navigate(
`${PATHS.FILE}/${encodeURIComponent(
context.selectedDirectory + sep() + event.data.name
context.selectedDirectory +
window.electron.path.sep +
event.data.name
)}`
)
} else if (
@ -94,7 +87,7 @@ export const FileMachineProvider = ({
},
services: {
readFiles: async (context: ContextFrom<typeof fileMachine>) => {
const newFiles = isTauri()
const newFiles = isDesktop()
? (await getProjectInfo(context.project.path)).children
: []
return {
@ -113,7 +106,7 @@ export const FileMachineProvider = ({
})
createdName = name
createdPath = path
await mkdir(createdPath)
await window.electron.mkdir(createdPath)
} else {
const { name, path } = await getNextFileName({
entryName: createdName,
@ -121,9 +114,9 @@ export const FileMachineProvider = ({
})
createdName = name
createdPath = path
await create(createdPath)
await window.electron.mkdir(createdPath)
if (event.data.content) {
await writeTextFile(createdPath, event.data.content)
await window.electron.writeFile(createdPath, event.data.content)
}
}
@ -143,7 +136,7 @@ export const FileMachineProvider = ({
})
createdName = name
createdPath = path
await mkdir(createdPath)
await window.electron.mkdir(createdPath)
} else {
const { name, path } = await getNextFileName({
entryName: createdName,
@ -151,9 +144,9 @@ export const FileMachineProvider = ({
})
createdName = name
createdPath = path
await create(createdPath)
await window.electron.mkdir(createdPath)
if (event.data.content) {
await writeTextFile(createdPath, event.data.content)
await window.electron.writeFile(createdPath, '')
}
}
@ -167,14 +160,25 @@ export const FileMachineProvider = ({
) => {
const { oldName, newName, isDir } = event.data
const name = newName ? newName : DEFAULT_FILE_NAME
const oldPath = await join(context.selectedDirectory.path, oldName)
const newDirPath = await join(context.selectedDirectory.path, name)
const oldPath = window.electron.path.join(
context.selectedDirectory.path,
oldName
)
const newDirPath = window.electron.path.join(
context.selectedDirectory.path,
name
)
const newPath =
newDirPath + (name.endsWith(FILE_EXT) || isDir ? '' : FILE_EXT)
await rename(oldPath, newPath, {})
await window.electron.rename(oldPath, newPath)
if (oldPath === file?.path && project?.path) {
if (!file) {
return Promise.reject(new Error('file is not defined'))
}
const currentFilePath = window.electron.path.join(file.path, file.name)
if (oldPath === currentFilePath && project?.path) {
// If we just renamed the current file, navigate to the new path
navigate(PATHS.FILE + '/' + encodeURIComponent(newPath))
} else if (file?.path.includes(oldPath)) {
@ -199,13 +203,15 @@ export const FileMachineProvider = ({
const isDir = !!event.data.children
if (isDir) {
await remove(event.data.path, {
recursive: true,
}).catch((e) => console.error('Error deleting directory', e))
await window.electron
.rm(event.data.path, {
recursive: true,
})
.catch((e) => console.error('Error deleting directory', e))
} else {
await remove(event.data.path).catch((e) =>
console.error('Error deleting file', e)
)
await window.electron
.rm(event.data.path)
.catch((e) => console.error('Error deleting file', e))
}
// If we just deleted the current file or one of its parent directories,