* docs: deps * Update dependencies and type usage for AI features Upgraded multiple dependencies in package.json and pnpm-lock.yaml, including @ai-sdk, @mui, react, and others for improved compatibility and performance. Changed type usage from CoreMessage to ModelMessage in mockOpenAI.test.ts to align with updated ai package. No functional changes to application logic. * feat: i18n * feat: test oauth login and use PKCE * fix: use ollama-ai-provider-v2 * test: github and mock oauth2 login * test: gitea login * Refactor context menu cleanup and error message Moved context menu cleanup for OAuth window to a single closed event handler in Authentication service. Simplified error message formatting in ContextService for missing keys. * lint: AI fix * Add tsx as a dev dependency and update scripts Replaced usage of 'pnpm dlx tsx' with direct 'tsx' command in development and test scripts for improved reliability. Added 'tsx' to devDependencies in package.json.
5.7 KiB
Development guide
Development plan of TidGi-Desktop is listed in these Kanban.
Explanation of our code can be found in the Wiki.
Detailed environment setup guide
To contribute, fork this repo, then clone it and setup development environment
First-Time Setup Commands
# Clone the project that you forked
git clone https://github.com/YOUR_ACCOUNT/TidGi-Desktop.git
cd TidGi-Desktop
# Switch to the correct Node.js version (recommended)
nvm use
# Install dependencies
pnpm install
# Full setup with all checks
pnpm start:init
Development Workflow
- First run: Use
pnpm start:initto ensure everything is properly set up - Daily development: Use
pnpm run start:devfor faster iteration - After pulling changes: Run
pnpm run build:pluginif plugins were updated - Before committing: Run
pnpm run lintandpnpm run test
Note: You can see webpack error messages at console during development.
Package.json Scripts
Development Scripts
Quick Development (Recommended for daily use)
pnpm run start:dev
This is the fastest way to start development. It directly launches the Electron app without running the full setup process, making it ideal for iterative development.
Full Development Setup
pnpm start
This runs the complete setup process including:
clean- Clears build artifacts and development foldersinit:git-submodule- Updates git submodulesbuild:plugin- Compiles TiddlyWiki pluginsstart:dev- Launches the Electron application
Debug Variants
pnpm run start:dev:debug-worker # Debug worker threads
pnpm run start:dev:debug-main # Debug main process
pnpm run start:dev:debug-react # Debug React renderer, react-devtool will be available in devtools
Show electron-packager debug logs
If you want to see detailed logs from electron-packager during packaging, set the environment variable DEBUG=electron-packager:
-
Linux/macOS:
DEBUG=electron-packager pnpm run start:dev -
Windows PowerShell:
$env:DEBUG="electron-packager"; pnpm run start:dev
This will print verbose debug information from electron-packager to help diagnose packaging issues.
Build & Package Scripts
pnpm run build:plugin # Compile TiddlyWiki plugins only
pnpm run package # Package for production
pnpm run package:dev # Package for testing (with NODE_ENV=test)
pnpm run make # Create distributable packages
Testing Scripts
pnpm run test # Run all tests (unit + E2E)
pnpm run test:unit # Run Jest unit tests only
pnpm run test:e2e # Run Cucumber E2E tests only
E2E Testing
E2E tests require the packaged application to run. Key points:
- Tests run against the packaged application to simulate real user scenarios
- Uses Playwright + Cucumber for browser automation
- Test reports are saved to
logs/directory
Utility Scripts
pnpm run clean # Clean build artifacts and temp folders
pnpm run clean:cache # Clear webpack and build caches, this can fix some error.
pnpm run lint # Run ESLint
pnpm run lint:fix # Run ESLint with auto-fix
First-Time Setup Commands
How to add dependency that used in a worker_thread
For example: tiddlywiki
pnpm i tiddlywiki- Add
ExternalsPluginin webpack.plugins.js (maybe optional for some deps, tiddlywiki needs this because its customrequirecan't require things that is bundled by webpack.dugitedon't need this step) - Add a
await fs.copy(path.join(projectRoot, 'node_modules/tiddlywiki')inscripts/afterPack.js, to copy things to resource folder, that is outside of asar, so it can be used by the worker_thread in electron
How to add plugin that only execute inside TidGi
Edit src/services/wiki/wikiWorker.ts, add another line like:
wikiInstance.boot.argv = [
'+plugins/tiddlywiki/filesystem',
'+plugins/tiddlywiki/tiddlyweb',
Managed Library
Some library doesn't fit electron usage, we move their code to this repo and modify them:
-
app-path: Need to be installed, so we can copy its binary to the resource folder. This lib is used by
externalAppbelow.- When not installed in package.json, when make release, forge will throw error
An unhandled rejection has occurred inside Forge: Error: ENOENT: no such file or directory, stat '/Users/linonetwo/Desktop/repo/TiddlyGit-Desktop/node_modules/app-path/main'
- When not installed in package.json, when make release, forge will throw error
-
externalApp: This was used by Github Desktop to lookup the location of editors like VSCode, we use it in context menu to "open in default text editor"
-
sqlite-vec: The path from its method
getLoadablePathmaybe incorrect after electron app packaged. (It will be in.webpack/main/index.jsin the dist folder instead of innode_modules/sqlite-vecfolder.)- Still need to install its
optionalDependencieslikesqlite-vec-darwin-x64in package.json
- Still need to install its
Don't upgrade these dependency
pure ESM
Electron forge webpack don't support pure ESM yet
- default-gateway
- electron-unhandled
- date-fns
Code Tour
TBD
Testing
Logs
Are in userData-dev/logs/TidGi-xxxx.log, includes all "level":"debug" debug logs and "level":"error" errors.