Split any YouTube song into stems
TypeScript
feat: add STEMKIT_DATA_DIR to move the app data folder
bluzername55b86b40dfa2
diff --git a/README.md b/README.mdindex 27df3b2..6f557e8 100644--- a/README.md+++ b/README.md@@ -105,6 +105,7 @@ video iframe (muted) + Web Audio stem playback · master clock = the audio itsel## Notes- Downloading audio from YouTube violates their ToS for public products — keep this personal.+- Want the data somewhere else (venv, models, songs, library)? Start the app with `STEMKIT_DATA_DIR=/path/to/folder` set. Unset keeps the default app folder.- yt-dlp breaks occasionally when YouTube changes things; the error dialog offers a one-click update (updates `yt-dlp` + the challenge solver together).## Privacydiff --git a/package.json b/package.jsonindex 7c48a02..ed98906 100644--- a/package.json+++ b/package.json@@ -11,6 +11,7 @@"scripts": {"dev": "node scripts/run.cjs dev","build": "node scripts/run.cjs build",+ "test": "node --test --experimental-strip-types src/main/data-dir.test.ts","typecheck:node": "node scripts/run.cjs typecheck:node","typecheck:web": "node scripts/run.cjs typecheck:web","typecheck": "node scripts/run.cjs typecheck",diff --git a/src/main/data-dir.test.ts b/src/main/data-dir.test.tsnew file mode 100644index 0000000..b02710b--- /dev/null+++ b/src/main/data-dir.test.ts@@ -0,0 +1,22 @@+import { test } from 'node:test'+import assert from 'node:assert/strict'+import { resolve } from 'path'+import { resolveDataDir } from './data-dir.ts'++const DEFAULT = '/home/user/.config/StemKit'++test('falls back to the electron default when unset', () => {+ assert.equal(resolveDataDir({}, DEFAULT), DEFAULT)+})++test('falls back when the override is blank', () => {+ assert.equal(resolveDataDir({ STEMKIT_DATA_DIR: ' ' }, DEFAULT), DEFAULT)+})++test('uses the override folder when set', () => {+ assert.equal(resolveDataDir({ STEMKIT_DATA_DIR: '/mnt/big/stemkit' }, DEFAULT), '/mnt/big/stemkit')+})++test('resolves a relative override to an absolute path', () => {+ assert.equal(resolveDataDir({ STEMKIT_DATA_DIR: 'data' }, DEFAULT), resolve('data'))+})diff --git a/src/main/data-dir.ts b/src/main/data-dir.tsnew file mode 100644index 0000000..af83201--- /dev/null+++ b/src/main/data-dir.ts@@ -0,0 +1,8 @@+import { resolve } from 'path'++/* STEMKIT_DATA_DIR moves every app-owned path (venv, models, songs, library)+ to a folder you pick. Unset or blank keeps the Electron default. */+export function resolveDataDir(env: NodeJS.ProcessEnv, electronDefault: string): string {+ const override = env.STEMKIT_DATA_DIR?.trim()+ return override ? resolve(override) : electronDefault+}diff --git a/src/main/env.ts b/src/main/env.tsindex 8ecd392..1fbf0dd 100644--- a/src/main/env.ts+++ b/src/main/env.ts@@ -4,6 +4,7 @@ import { homedir } from 'os'import { join } from 'path'import { app, BrowserWindow, net } from 'electron'import type { EngineStatus, GpuVendor } from '../shared/types'+import { resolveDataDir } from './data-dir'export interface ToolInfo {found: boolean@@ -29,7 +30,7 @@ const state: EnvState = {}export function userDataDir(): string {- return app.getPath('userData')+ return resolveDataDir(process.env, app.getPath('userData'))}const IS_WIN = process.platform === 'win32'diff --git a/tsconfig.node.json b/tsconfig.node.jsonindex 06a41f7..ef6a0b6 100644--- a/tsconfig.node.json+++ b/tsconfig.node.json@@ -9,7 +9,8 @@"noUnusedLocals": true,"skipLibCheck": true,"esModuleInterop": true,- "resolveJsonModule": true+ "resolveJsonModule": true,+ "allowImportingTsExtensions": true},"include": ["electron.vite.config.ts",