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>
This commit is contained in:
@ -1,15 +1,20 @@
|
||||
import {
|
||||
FileEntry,
|
||||
createDir,
|
||||
mkdir,
|
||||
exists,
|
||||
readDir,
|
||||
readTextFile,
|
||||
writeTextFile,
|
||||
} from '@tauri-apps/api/fs'
|
||||
import { appConfigDir, documentDir, homeDir, sep } from '@tauri-apps/api/path'
|
||||
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'
|
||||
import { type ProjectWithEntryPointMetadata } from 'lib/types'
|
||||
import { metadata } from 'tauri-plugin-fs-extra-api'
|
||||
import type { FileEntry, ProjectWithEntryPointMetadata } from 'lib/types'
|
||||
import {
|
||||
FILE_EXT,
|
||||
INDEX_IDENTIFIER,
|
||||
@ -33,10 +38,10 @@ export async function getInitialDefaultDir() {
|
||||
try {
|
||||
dir = await documentDir()
|
||||
} catch (e) {
|
||||
dir = `${await homeDir()}Documents/` // for headless Linux (eg. Github Actions)
|
||||
dir = await join(await homeDir(), 'Documents') // for headless Linux (eg. Github Actions)
|
||||
}
|
||||
|
||||
return dir + PROJECT_FOLDER
|
||||
return await join(dir, PROJECT_FOLDER)
|
||||
}
|
||||
|
||||
// Initializes the project directory and returns the path
|
||||
@ -96,7 +101,7 @@ async function testAndCreateDir(
|
||||
if (dirExists instanceof Error) {
|
||||
returnValue.error = dirExists
|
||||
} else if (dirExists === false) {
|
||||
const newDirCreated = await createDir(directory, { recursive: true }).catch(
|
||||
const newDirCreated = await mkdir(directory, { recursive: true }).catch(
|
||||
(e) => {
|
||||
console.error(
|
||||
`Error creating directory ${directory}. Original error:`,
|
||||
@ -129,14 +134,12 @@ export function isProjectDirectory(fileOrDir: Partial<FileEntry>) {
|
||||
// and return the valid projects
|
||||
export async function getProjectsInDir(projectDir: string) {
|
||||
const readProjects = (
|
||||
await readDir(projectDir, {
|
||||
recursive: true,
|
||||
})
|
||||
await invoke<FileEntry[]>('read_dir_recursive', { path: projectDir })
|
||||
).filter(isProjectDirectory)
|
||||
|
||||
const projectsWithMetadata = await Promise.all(
|
||||
readProjects.map(async (p) => ({
|
||||
entrypointMetadata: await metadata(p.path + sep + PROJECT_ENTRYPOINT),
|
||||
entrypointMetadata: await stat(await join(p.path, PROJECT_ENTRYPOINT)),
|
||||
...p,
|
||||
}))
|
||||
)
|
||||
@ -196,8 +199,8 @@ export function deepFileFilterFlat(
|
||||
// Read the contents of a project directory
|
||||
// and return all relevant files and sub-directories recursively
|
||||
export async function readProject(projectDir: string) {
|
||||
const readFiles = await readDir(projectDir, {
|
||||
recursive: true,
|
||||
const readFiles = await invoke<FileEntry[]>('read_dir_recursive', {
|
||||
path: projectDir,
|
||||
})
|
||||
|
||||
return deepFileFilter(readFiles, isRelevantFileOrDir)
|
||||
@ -285,29 +288,29 @@ export async function createNewProject(
|
||||
|
||||
const dirExists = await exists(path)
|
||||
if (!dirExists) {
|
||||
await createDir(path, { recursive: true }).catch((err) => {
|
||||
await mkdir(path, { recursive: true }).catch((err) => {
|
||||
console.error('Error creating new directory:', err)
|
||||
throw err
|
||||
})
|
||||
}
|
||||
|
||||
await writeTextFile(path + sep + PROJECT_ENTRYPOINT, initCode).catch(
|
||||
await writeTextFile(await join(path, PROJECT_ENTRYPOINT), initCode).catch(
|
||||
(err) => {
|
||||
console.error('Error creating new file:', err)
|
||||
throw err
|
||||
}
|
||||
)
|
||||
|
||||
const m = await metadata(path)
|
||||
const m = await stat(path)
|
||||
|
||||
return {
|
||||
name: path.slice(path.lastIndexOf(sep) + 1),
|
||||
name: path.slice(path.lastIndexOf(sep()) + 1),
|
||||
path: path,
|
||||
entrypointMetadata: m,
|
||||
children: [
|
||||
{
|
||||
name: PROJECT_ENTRYPOINT,
|
||||
path: path + sep + PROJECT_ENTRYPOINT,
|
||||
path: await join(path, PROJECT_ENTRYPOINT),
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
@ -371,17 +374,17 @@ export async function getUserSettingsFilePath(
|
||||
filename: string = SETTINGS_FILE_EXT
|
||||
) {
|
||||
const dir = await appConfigDir()
|
||||
return dir + filename
|
||||
return await join(dir, filename)
|
||||
}
|
||||
|
||||
export async function readSettingsFile(
|
||||
path: string
|
||||
): Promise<Partial<SaveSettingsPayload>> {
|
||||
const dir = path.slice(0, path.lastIndexOf(sep))
|
||||
const dir = path.slice(0, path.lastIndexOf(sep()))
|
||||
|
||||
const dirExists = await exists(dir)
|
||||
if (!dirExists) {
|
||||
await createDir(dir, { recursive: true })
|
||||
await mkdir(dir, { recursive: true })
|
||||
}
|
||||
|
||||
const settingsExist = dirExists ? await exists(path) : false
|
||||
|
Reference in New Issue
Block a user