@niyamulahsan/create-deskapp 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/.env.example +20 -13
- package/template/AGENTS.md +699 -0
- package/template/package.json +3 -0
- package/template/src/config/app.ts +26 -24
- package/template/src/config/winsetup.ts +93 -91
- package/template/src/core/api/binding-error.ts +57 -0
- package/template/src/core/api/bindings.generated.ts +2 -0
- package/template/src/core/api/generate.manifest.ts +84 -80
- package/template/src/core/api/registry.ts +58 -48
- package/template/src/core/config.ts +101 -99
- package/template/src/core/database/aggregate.ts +89 -85
- package/template/src/core/database/config.ts +50 -48
- package/template/src/core/database/connection.ts +116 -114
- package/template/src/core/database/migrate-hooks.ts +86 -84
- package/template/src/core/database/paginate.ts +226 -224
- package/template/src/core/database/reset.ts +21 -19
- package/template/src/core/database/seed.ts +169 -167
- package/template/src/core/database/status.ts +37 -35
- package/template/src/core/env.ts +108 -106
- package/template/src/core/facade.ts +63 -61
- package/template/src/core/maker/db/fresh.ts +10 -8
- package/template/src/core/maker/db/generate.ts +13 -11
- package/template/src/core/maker/db/helpers.ts +92 -96
- package/template/src/core/maker/db/migrate.ts +37 -35
- package/template/src/core/maker/db/mod.ts +93 -91
- package/template/src/core/maker/db/module-migrate.ts +56 -54
- package/template/src/core/maker/db/push.ts +23 -21
- package/template/src/core/maker/db/reset.ts +8 -6
- package/template/src/core/maker/db/seed.ts +9 -7
- package/template/src/core/maker/db/status.ts +8 -6
- package/template/src/core/maker/help.ts +59 -57
- package/template/src/core/maker/make/controller.ts +25 -22
- package/template/src/core/maker/make/helpers.ts +97 -91
- package/template/src/core/maker/make/mod.ts +69 -67
- package/template/src/core/maker/make/model.ts +16 -14
- package/template/src/core/maker/make/module.ts +53 -39
- package/template/src/core/maker/make/seeder.ts +23 -21
- package/template/src/core/maker/make/test.ts +33 -30
- package/template/src/core/maker/mod.ts +85 -83
- package/template/src/core/maker/run/mod.ts +134 -132
- package/template/src/core/maker/stub.ts +26 -24
- package/template/src/core/maker/stubs/controller/controller.controller.stub +57 -55
- package/template/src/core/maker/stubs/controller/controller.schema.stub +18 -13
- package/template/src/core/maker/stubs/facade/facade.stub +21 -0
- package/template/src/core/maker/stubs/model/model.stub +10 -8
- package/template/src/core/maker/stubs/seeder/seeder.stub +18 -16
- package/template/src/core/maker/stubs/test/test.stub +9 -7
- package/template/src/core/maker/sync-config.ts +93 -94
- package/template/src/core/utils/password.ts +29 -27
- package/template/src/core/utils/playwright.ts +123 -121
- package/template/src/core/utils/queue.ts +68 -66
- package/template/src/core/utils/scheduler.ts +62 -60
- package/template/src/core/utils/storage.ts +3 -1
- package/template/src/core/utils/validation.ts +37 -35
- package/template/src/database/schema.ts +2 -0
- package/template/src/main.ts +120 -118
- package/template/src/modules/app/__tests__/demo.controller.test.ts +75 -0
- package/template/src/modules/app/__tests__/net.controller.test.ts +65 -0
- package/template/src/modules/app/__tests__/playwright.controller.test.ts +50 -0
- package/template/src/modules/app/__tests__/storage.controller.test.ts +114 -0
- package/template/src/modules/app/__tests__/window.controller.test.ts +98 -0
- package/template/src/modules/app/controllers/demo.controller.ts +120 -118
- package/template/src/modules/app/controllers/net.controller.ts +50 -48
- package/template/src/modules/app/controllers/playwright.controller.ts +142 -140
- package/template/src/modules/app/controllers/storage.controller.ts +231 -229
- package/template/src/modules/app/controllers/window.controller.ts +2 -0
- package/template/src/modules/app/facade.ts +21 -0
- package/template/src/preload.ts +25 -2
- package/template/src/ui/src/App.vue +4 -2
- package/template/src/ui/src/app.ts +38 -23
- package/template/src/ui/src/bindings.d.ts +18 -16
- package/template/src/ui/src/components/Button.vue +34 -32
- package/template/src/ui/src/components/Checkbox.vue +26 -29
- package/template/src/ui/src/components/Input.vue +221 -227
- package/template/src/ui/src/components/InputGroup.vue +141 -0
- package/template/src/ui/src/components/InputPasswordToggle.vue +204 -0
- package/template/src/ui/src/components/Modal.vue +65 -55
- package/template/src/ui/src/components/Spinner.vue +44 -42
- package/template/src/ui/src/components/Switch.vue +62 -65
- package/template/src/ui/src/components/TextArea.vue +108 -121
- package/template/src/ui/src/components/Toast.vue +55 -56
- package/template/src/ui/src/components/datatable/DataTableSkeleton.vue +100 -98
- package/template/src/ui/src/components/datatable/Pagination.vue +153 -125
- package/template/src/ui/src/components/datatable/SelectOpption.vue +36 -35
- package/template/src/ui/src/components/datatable/index.vue +336 -258
- package/template/src/ui/src/env.d.ts +16 -13
- package/template/src/ui/src/global.d.ts +21 -2
- package/template/src/ui/src/helpers/nformatter.ts +12 -10
- package/template/src/ui/src/pages/dashboard/index.vue +690 -687
- package/template/src/ui/src/plugins/browserDetect.ts +57 -0
- package/template/src/ui/src/plugins/gum.ts +576 -549
- package/template/src/ui/src/plugins/pulse.ts +2 -0
- package/template/src/ui/src/plugins/routeProgress.ts +89 -0
- package/template/src/ui/src/router/index.ts +44 -25
- package/template/src/ui/src/stores/example.ts +2 -0
- package/template/src/ui/vite.config.ts +40 -38
- package/template/src/window/app-menu.ts +89 -87
- package/template/src/window/config.ts +14 -12
- package/template/src/window/context-menu.ts +23 -21
- package/template/src/window/dialogs.ts +92 -90
- package/template/src/window/manager.ts +2 -0
- package/template/src/window/native.ts +47 -45
- package/template/src/window/tray.ts +132 -130
|
@@ -1,99 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
1
|
+
// ./src/core/config.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* config.ts - runtime framework configuration.
|
|
5
|
+
*
|
|
6
|
+
* Reads app identity from src/config/app.ts (edit that file for 0-hassle naming),
|
|
7
|
+
* with safe fallback to package.json.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
import { createRequire } from "node:module";
|
|
12
|
+
import { dirname, join } from "node:path";
|
|
13
|
+
import { appConfig } from "@config/app";
|
|
14
|
+
|
|
15
|
+
interface PackageJsonConfig {
|
|
16
|
+
name?: string;
|
|
17
|
+
productName?: string;
|
|
18
|
+
build?: {
|
|
19
|
+
productName?: string;
|
|
20
|
+
mac?: { icon?: string };
|
|
21
|
+
win?: { icon?: string };
|
|
22
|
+
linux?: { icon?: string };
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getElectronApp(): any {
|
|
27
|
+
try {
|
|
28
|
+
const req = typeof require !== "undefined" ? require : createRequire(process.cwd() + "/");
|
|
29
|
+
const e = req("electron");
|
|
30
|
+
if (e && typeof e === "object" && typeof e.app?.getPath === "function") return e.app;
|
|
31
|
+
} catch {}
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The project's package.json, read once and cached (fallback / extra build metadata). */
|
|
36
|
+
let pkgJsonCache: PackageJsonConfig | null | undefined;
|
|
37
|
+
function readPackageJson(): PackageJsonConfig | undefined {
|
|
38
|
+
if (pkgJsonCache !== undefined) return pkgJsonCache;
|
|
39
|
+
|
|
40
|
+
const candidates: string[] = [];
|
|
41
|
+
const app = getElectronApp();
|
|
42
|
+
try {
|
|
43
|
+
if (app?.getAppPath) candidates.push(join(app.getAppPath(), "package.json"));
|
|
44
|
+
} catch {}
|
|
45
|
+
try {
|
|
46
|
+
if (app?.isPackaged) candidates.push(join(dirname(app.getPath("exe")), "package.json"));
|
|
47
|
+
} catch {}
|
|
48
|
+
candidates.push(join(process.cwd(), "package.json"));
|
|
49
|
+
|
|
50
|
+
// Walk up from cwd to find package.json (CLI/dev safety)
|
|
51
|
+
let dir = process.cwd();
|
|
52
|
+
for (let i = 0; i < 6; i++) {
|
|
53
|
+
candidates.push(join(dir, "package.json"));
|
|
54
|
+
const parent = dirname(dir);
|
|
55
|
+
if (parent === dir) break;
|
|
56
|
+
dir = parent;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
for (const p of candidates) {
|
|
60
|
+
try {
|
|
61
|
+
if (fs.existsSync(p)) {
|
|
62
|
+
pkgJsonCache = JSON.parse(fs.readFileSync(p, "utf-8")) as PackageJsonConfig;
|
|
63
|
+
return pkgJsonCache;
|
|
64
|
+
}
|
|
65
|
+
} catch {}
|
|
66
|
+
}
|
|
67
|
+
pkgJsonCache = null;
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Parse a boolean env var: "1"/"true"/"yes"/"on" are on, anything else off. */
|
|
72
|
+
export function envBool(name: string, fallback: boolean): boolean {
|
|
73
|
+
const value = process.env[name];
|
|
74
|
+
if (value === undefined) return fallback;
|
|
75
|
+
return ["1", "true", "yes", "on"].includes(value.trim().toLowerCase());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const uiEnabled = () => envBool("DESKAPP_UI", true);
|
|
79
|
+
|
|
80
|
+
const APP_NAME_FALLBACK = "Deskapp";
|
|
81
|
+
const pkg = readPackageJson();
|
|
82
|
+
|
|
83
|
+
// Prefer src/config/app.ts (zero-hassle), fall back to package.json.
|
|
84
|
+
const appName = appConfig?.productName || pkg?.build?.productName || pkg?.productName || pkg?.name || APP_NAME_FALLBACK;
|
|
85
|
+
const appKebab = (appConfig?.name || appName)
|
|
86
|
+
.toLowerCase()
|
|
87
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
88
|
+
.replace(/^-+|-+$/g, "");
|
|
89
|
+
|
|
90
|
+
export const config = {
|
|
91
|
+
/** Display name (src/config/app.ts > package.json, fallback "Deskapp"). */
|
|
92
|
+
appName,
|
|
93
|
+
/** Filesystem-safe kebab form — sqlite filename, linux binary name. */
|
|
94
|
+
appKebab,
|
|
95
|
+
/** Per-OS output paths from package.json build config */
|
|
96
|
+
desktopOutput: pkg?.build ?? null,
|
|
97
|
+
ui: {
|
|
98
|
+
/** True when the frontend should be served and a window opened. */
|
|
99
|
+
enabled: uiEnabled()
|
|
100
|
+
}
|
|
101
|
+
};
|
|
@@ -1,85 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
1
|
+
// ./src/core/database/aggregate.ts
|
|
2
|
+
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const SRC_PATH = path.resolve(process.cwd(), "src");
|
|
8
|
+
const SCHEMA_PATH = path.join(SRC_PATH, "database", "schema.ts");
|
|
9
|
+
|
|
10
|
+
export function walkTs(dir: string, out: string[]): void {
|
|
11
|
+
try {
|
|
12
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
13
|
+
const full = path.join(dir, entry.name);
|
|
14
|
+
if (entry.isDirectory()) walkTs(full, out);
|
|
15
|
+
else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx"))) out.push(full);
|
|
16
|
+
}
|
|
17
|
+
} catch {
|
|
18
|
+
// path does not exist - skip
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function discoverModelFiles(srcPath = SRC_PATH): string[] {
|
|
23
|
+
const modelFiles: string[] = [];
|
|
24
|
+
const modulesDir = path.join(srcPath, "modules");
|
|
25
|
+
const coreDir = path.join(srcPath, "core");
|
|
26
|
+
|
|
27
|
+
if (fs.existsSync(modulesDir)) {
|
|
28
|
+
for (const moduleDir of fs.readdirSync(modulesDir, { withFileTypes: true })) {
|
|
29
|
+
if (!moduleDir.isDirectory()) continue;
|
|
30
|
+
walkTs(path.join(moduleDir.name ? path.join(modulesDir, moduleDir.name) : "", "database", "models"), modelFiles);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// fix: above had a bug in my quick logic; do it clearly
|
|
34
|
+
modelFiles.length = 0;
|
|
35
|
+
if (fs.existsSync(modulesDir)) {
|
|
36
|
+
for (const moduleDir of fs.readdirSync(modulesDir, { withFileTypes: true })) {
|
|
37
|
+
if (!moduleDir.isDirectory()) continue;
|
|
38
|
+
walkTs(path.join(modulesDir, moduleDir.name, "database", "models"), modelFiles);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (fs.existsSync(coreDir)) {
|
|
42
|
+
for (const areaDir of fs.readdirSync(coreDir, { withFileTypes: true })) {
|
|
43
|
+
if (!areaDir.isDirectory()) continue;
|
|
44
|
+
walkTs(path.join(coreDir, areaDir.name, "database", "models"), modelFiles);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return modelFiles.sort();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function generateSchemaFile(srcPath = SRC_PATH, schemaPath = SCHEMA_PATH): string[] {
|
|
51
|
+
const modelFiles = discoverModelFiles(srcPath);
|
|
52
|
+
const modelExports = modelFiles
|
|
53
|
+
.map((f) => {
|
|
54
|
+
const rel = path.relative(srcPath, f).replace(/\\/g, "/");
|
|
55
|
+
const ext = rel.endsWith(".tsx") ? ".tsx" : ".ts";
|
|
56
|
+
const base = rel.slice(0, -ext.length);
|
|
57
|
+
return `export * from "../${base}";`;
|
|
58
|
+
})
|
|
59
|
+
.join("\n");
|
|
60
|
+
|
|
61
|
+
const content = `// ./src/database/schema.ts
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* schema.ts - GENERATED by \`npm run db:schema\`. Do NOT edit by hand.
|
|
65
|
+
* Aggregates every module + core database/models/*.ts into one Drizzle schema.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
${modelExports || "export {};"}
|
|
69
|
+
`;
|
|
70
|
+
fs.mkdirSync(path.dirname(schemaPath), { recursive: true });
|
|
71
|
+
fs.mkdirSync(path.join(srcPath, "storage"), { recursive: true });
|
|
72
|
+
fs.writeFileSync(schemaPath, content);
|
|
73
|
+
return modelFiles;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function isMain(): boolean {
|
|
77
|
+
try {
|
|
78
|
+
const arg = process.argv[1];
|
|
79
|
+
if (!arg) return false;
|
|
80
|
+
return path.resolve(arg) === path.resolve(fileURLToPath(import.meta.url));
|
|
81
|
+
} catch {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (isMain()) {
|
|
87
|
+
const found = generateSchemaFile();
|
|
88
|
+
console.log(`[db:schema] wrote ${SCHEMA_PATH} (${found.length} model(s))`);
|
|
89
|
+
}
|
|
@@ -1,48 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
// ./src/core/database/config.ts
|
|
2
|
+
|
|
3
|
+
import { isAbsolute, join } from "node:path";
|
|
4
|
+
import { config } from "@/core/config";
|
|
5
|
+
import { appBaseDir } from "@/core/env";
|
|
6
|
+
|
|
7
|
+
function getElectronApp(): { getPath: (name: string) => string; isPackaged: boolean } | undefined {
|
|
8
|
+
try {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
10
|
+
const e = require("electron") as any;
|
|
11
|
+
if (e && typeof e.app?.getPath === "function") return e.app;
|
|
12
|
+
} catch {}
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getAppBaseDir(): string {
|
|
17
|
+
try {
|
|
18
|
+
return appBaseDir();
|
|
19
|
+
} catch {
|
|
20
|
+
return process.cwd();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The URI (scheme + path) for the local SQLite file. */
|
|
25
|
+
export function resolveDatabaseUrl(): string {
|
|
26
|
+
const raw = (process.env.DATABASE_URL ?? "").trim();
|
|
27
|
+
|
|
28
|
+
// Default: Store in the OS-specific user data folder when running in Electron.
|
|
29
|
+
if (!raw) {
|
|
30
|
+
const electronApp = getElectronApp();
|
|
31
|
+
if (electronApp) {
|
|
32
|
+
return `sqlite:${join(electronApp.getPath("userData"), `${config.appKebab}.sqlite`)}`;
|
|
33
|
+
}
|
|
34
|
+
// CLI / non-Electron fallback
|
|
35
|
+
return `sqlite:${join(getAppBaseDir(), "src", "storage", `${config.appKebab}.sqlite`)}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// In-memory databases and remote libsql URLs are used as-is.
|
|
39
|
+
if (raw.includes(":memory:")) return raw;
|
|
40
|
+
if (raw.includes("://")) return raw;
|
|
41
|
+
|
|
42
|
+
const body = raw.replace(/^(sqlite|file):/, "");
|
|
43
|
+
const anchored = body && !isAbsolute(body) ? join(getAppBaseDir(), body) : body;
|
|
44
|
+
return `${raw.startsWith("file:") ? "file" : "sqlite"}:${anchored}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The local SQLite file path (strips the `sqlite:`/`file:` scheme). */
|
|
48
|
+
export function sqliteFile(): string {
|
|
49
|
+
return resolveDatabaseUrl().replace(/^(sqlite|file):/, "");
|
|
50
|
+
}
|