Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
11 changes: 5 additions & 6 deletions apps/emdash-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@
"main": "./out/main/index.js",
"scripts": {
"d": "pnpm install && pnpm run dev",
"dev": "LOG_LEVEL=debug EMDASH_LOG_FILE=.emdash-logs/emdash.log electron-vite dev",
"dev:debug": "VITE_LOG_LEVEL=debug LOG_LEVEL=debug EMDASH_LOG_FILE=.emdash-logs/emdash.log electron-vite dev",
"dev": "cross-env LOG_LEVEL=debug EMDASH_LOG_FILE=.emdash-logs/emdash.log electron-vite dev",
"dev:debug": "cross-env VITE_LOG_LEVEL=debug LOG_LEVEL=debug EMDASH_LOG_FILE=.emdash-logs/emdash.log electron-vite dev",
"dev:main": "electron-vite dev --watch main",
"dev:renderer": "electron-vite dev --watch renderer",
"db:generate": "drizzle-kit generate",
"db:setup": "npm install --prefix tooling/node-deps",
"db:fixtures": "vitest run --project fixtures",
"test:migrations": "vitest run --project migrations",
"db:reset": "pnpm run db:reset:3 && pnpm run db:reset:4",
"db:reset:3": "rm -f \"$HOME/Library/Application Support/emdash-dev/emdash3.db\" \"$HOME/Library/Application Support/emdash-dev/emdash3.db-wal\" \"$HOME/Library/Application Support/emdash-dev/emdash3.db-shm\" \"$HOME/.config/emdash-dev/emdash3.db\" \"$HOME/.config/emdash-dev/emdash3.db-wal\" \"$HOME/.config/emdash-dev/emdash3.db-shm\"",
"db:reset:4": "rm -f \"$HOME/Library/Application Support/emdash-dev/emdash4.db\" \"$HOME/Library/Application Support/emdash-dev/emdash4.db-wal\" \"$HOME/Library/Application Support/emdash-dev/emdash4.db-shm\" \"$HOME/.config/emdash-dev/emdash4.db\" \"$HOME/.config/emdash-dev/emdash4.db-wal\" \"$HOME/.config/emdash-dev/emdash4.db-shm\"",
"db:reset": "node --experimental-strip-types scripts/db-reset.ts",
"test": "vitest run --project node --project main-db --project migrations --project browser --project scripts",
"build": "electron-vite build",
"build:main": "electron-vite build --filter main",
Expand All @@ -41,7 +39,7 @@
"postinstall": "node --experimental-strip-types scripts/postinstall.ts",
"rebuild": "electron-rebuild -f -v 40.7.0 --only=better-sqlite3,node-pty",
"run:docker-ssh": "docker compose up --build -d",
"clean": "rm -rf node_modules dist",
"clean": "node --experimental-strip-types scripts/clean.ts",
"reset": "pnpm run clean && pnpm install",
"lint": "oxlint .",
"format": "oxfmt",
Expand Down Expand Up @@ -115,6 +113,7 @@
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
"concurrently": "^8.2.2",
"cross-env": "^10.1.0",
"date-fns": "^4.1.0",
"devicon": "^2.17.0",
"dotenv": "^17.4.2",
Expand Down
9 changes: 9 additions & 0 deletions apps/emdash-desktop/scripts/clean.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { rmSync } from 'node:fs';

// Cross-platform replacement for `rm -rf node_modules dist`, which only ran on
// POSIX shells. The build output lives in `out/` (electron-vite default), not
// `dist/`, so wipe that. `rmSync` with recursive+force is a no-op when a target
// is missing.
for (const target of ['node_modules', 'out']) {
rmSync(target, { recursive: true, force: true });
}
32 changes: 32 additions & 0 deletions apps/emdash-desktop/scripts/db-reset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { rmSync } from 'node:fs';
import { homedir } from 'node:os';
import { join } from 'node:path';

// Cross-platform replacement for the old `rm -f` db:reset scripts, which only ran
// on POSIX shells. Wipes the dev SQLite databases (and their -wal/-shm sidecars)
// from the platform-specific userData directory.
const DEV_DIR_NAME = 'emdash-dev';
const DB_BASENAMES = ['emdash3.db', 'emdash4.db'];

function devUserDataDir(): string {
const home = process.env.HOME ?? homedir();
Comment thread
janburzinski marked this conversation as resolved.
Outdated

if (process.platform === 'darwin') {
return join(home, 'Library', 'Application Support', DEV_DIR_NAME);
}
if (process.platform === 'win32') {
const appData = process.env.APPDATA ?? join(home, 'AppData', 'Roaming');
return join(appData, DEV_DIR_NAME);
}
const xdgConfig = process.env.XDG_CONFIG_HOME ?? join(home, '.config');
return join(xdgConfig, DEV_DIR_NAME);
}

const dir = devUserDataDir();
for (const base of DB_BASENAMES) {
for (const suffix of ['', '-wal', '-shm']) {
rmSync(join(dir, `${base}${suffix}`), { force: true });
}
}

console.log(`db:reset: cleared dev databases in ${dir}`);
18 changes: 18 additions & 0 deletions pnpm-lock.yaml

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

Loading