Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"tauri:dev": "RUST_BACKTRACE=1 tauri dev",
"tauri:dev": "tauri dev",
"tauri:build": "tauri build",
"check": "svelte-check --tsconfig ./tsconfig.json",
"bump": "sh ./bump.sh",
"format": "prettier --write ./src",
"lint": "eslint --config ./eslint.config.js ./src"
"lint": "eslint --config ./eslint.config.js ./src",
"gen:ts": "zx --quiet ./scripts/gen-ts.mjs"
},
"dependencies": {
"@tauri-apps/api": "^2.0.3",
"@tauri-apps/plugin-autostart": "~2",
"@tauri-apps/plugin-http": "~2",
"@tauri-apps/plugin-log": "~2",
"@tauri-apps/plugin-notification": "~2",
"@tauri-apps/plugin-shell": "~2",
"@tauri-apps/plugin-store": "~2",
"@tauri-apps/plugin-updater": "~2",
"clsx": "2.1.1",
"svelte": "^5.1.12",
Expand Down Expand Up @@ -57,7 +60,8 @@
"typescript": "5.6.3",
"typescript-eslint": "^8.13.0",
"valibot": "1.0.0-beta.9",
"vite": "5.4.8"
"vite": "5.4.8",
"zx": "^8.2.4"
},
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
}
50 changes: 50 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions scripts/gen-ts.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { fileURLToPath } from 'url';
import { $, cd, chalk } from 'zx';
import fs from 'fs/promises';

const srcFile = fileURLToPath(new URL('../src-tauri/bindings/index.ts', import.meta.url));
const destFile = fileURLToPath(new URL('../src/types/index.ts', import.meta.url));

cd('src-tauri');

await $`cargo test export_bindings`;

await $`mv ${srcFile} ${destFile}`;

const content = await fs.readFile(destFile, 'utf-8');

const typeNames = content.match(/export type (\w+)/g).map(match => match.replace('export type ', ''));

console.log(chalk.grey(destFile));
console.log(chalk.green(`Successfully generated ${typeNames.length} TypeScript types:`));
console.log(chalk.blueBright(typeNames.join(', ')));

await $`pnpm exec prettier --write ${destFile}`;
1 change: 1 addition & 0 deletions src-tauri/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Generated by Cargo
# will have compiled files and executables
/target/
/bindings/
Loading