@niyamulahsan/create-deskapp 1.2.4 → 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.
Files changed (104) hide show
  1. package/package.json +16 -16
  2. package/template/.env.example +20 -13
  3. package/template/AGENTS.md +699 -0
  4. package/template/package.json +3 -0
  5. package/template/src/config/app.ts +26 -24
  6. package/template/src/config/winsetup.ts +93 -91
  7. package/template/src/core/api/binding-error.ts +57 -0
  8. package/template/src/core/api/bindings.generated.ts +2 -0
  9. package/template/src/core/api/generate.manifest.ts +84 -80
  10. package/template/src/core/api/registry.ts +58 -48
  11. package/template/src/core/config.ts +101 -99
  12. package/template/src/core/database/aggregate.ts +89 -85
  13. package/template/src/core/database/config.ts +50 -48
  14. package/template/src/core/database/connection.ts +116 -114
  15. package/template/src/core/database/migrate-hooks.ts +86 -84
  16. package/template/src/core/database/paginate.ts +226 -224
  17. package/template/src/core/database/reset.ts +21 -19
  18. package/template/src/core/database/seed.ts +169 -167
  19. package/template/src/core/database/status.ts +37 -35
  20. package/template/src/core/env.ts +108 -106
  21. package/template/src/core/facade.ts +63 -61
  22. package/template/src/core/maker/db/fresh.ts +10 -8
  23. package/template/src/core/maker/db/generate.ts +13 -11
  24. package/template/src/core/maker/db/helpers.ts +92 -96
  25. package/template/src/core/maker/db/migrate.ts +37 -35
  26. package/template/src/core/maker/db/mod.ts +93 -91
  27. package/template/src/core/maker/db/module-migrate.ts +56 -54
  28. package/template/src/core/maker/db/push.ts +23 -21
  29. package/template/src/core/maker/db/reset.ts +8 -6
  30. package/template/src/core/maker/db/seed.ts +9 -7
  31. package/template/src/core/maker/db/status.ts +8 -6
  32. package/template/src/core/maker/help.ts +59 -57
  33. package/template/src/core/maker/make/controller.ts +25 -22
  34. package/template/src/core/maker/make/helpers.ts +97 -91
  35. package/template/src/core/maker/make/mod.ts +69 -67
  36. package/template/src/core/maker/make/model.ts +16 -14
  37. package/template/src/core/maker/make/module.ts +53 -39
  38. package/template/src/core/maker/make/seeder.ts +23 -21
  39. package/template/src/core/maker/make/test.ts +33 -30
  40. package/template/src/core/maker/mod.ts +85 -83
  41. package/template/src/core/maker/run/mod.ts +134 -132
  42. package/template/src/core/maker/stub.ts +26 -24
  43. package/template/src/core/maker/stubs/controller/controller.controller.stub +57 -55
  44. package/template/src/core/maker/stubs/controller/controller.schema.stub +18 -13
  45. package/template/src/core/maker/stubs/facade/facade.stub +21 -0
  46. package/template/src/core/maker/stubs/model/model.stub +10 -8
  47. package/template/src/core/maker/stubs/seeder/seeder.stub +18 -16
  48. package/template/src/core/maker/stubs/test/test.stub +9 -7
  49. package/template/src/core/maker/sync-config.ts +93 -94
  50. package/template/src/core/utils/password.ts +29 -27
  51. package/template/src/core/utils/playwright.ts +123 -121
  52. package/template/src/core/utils/queue.ts +68 -66
  53. package/template/src/core/utils/scheduler.ts +62 -60
  54. package/template/src/core/utils/storage.ts +3 -1
  55. package/template/src/core/utils/validation.ts +37 -35
  56. package/template/src/database/schema.ts +2 -0
  57. package/template/src/main.ts +120 -118
  58. package/template/src/modules/app/__tests__/demo.controller.test.ts +75 -0
  59. package/template/src/modules/app/__tests__/net.controller.test.ts +65 -0
  60. package/template/src/modules/app/__tests__/playwright.controller.test.ts +50 -0
  61. package/template/src/modules/app/__tests__/storage.controller.test.ts +114 -0
  62. package/template/src/modules/app/__tests__/window.controller.test.ts +98 -0
  63. package/template/src/modules/app/controllers/demo.controller.ts +120 -118
  64. package/template/src/modules/app/controllers/net.controller.ts +50 -48
  65. package/template/src/modules/app/controllers/playwright.controller.ts +142 -140
  66. package/template/src/modules/app/controllers/storage.controller.ts +231 -229
  67. package/template/src/modules/app/controllers/window.controller.ts +2 -0
  68. package/template/src/modules/app/facade.ts +21 -0
  69. package/template/src/preload.ts +25 -2
  70. package/template/src/ui/src/App.vue +4 -2
  71. package/template/src/ui/src/app.ts +38 -23
  72. package/template/src/ui/src/bindings.d.ts +18 -16
  73. package/template/src/ui/src/components/Button.vue +34 -32
  74. package/template/src/ui/src/components/Checkbox.vue +26 -29
  75. package/template/src/ui/src/components/Input.vue +221 -227
  76. package/template/src/ui/src/components/InputGroup.vue +141 -0
  77. package/template/src/ui/src/components/InputPasswordToggle.vue +204 -0
  78. package/template/src/ui/src/components/Modal.vue +65 -55
  79. package/template/src/ui/src/components/Spinner.vue +44 -42
  80. package/template/src/ui/src/components/Switch.vue +62 -65
  81. package/template/src/ui/src/components/TextArea.vue +108 -121
  82. package/template/src/ui/src/components/Toast.vue +55 -56
  83. package/template/src/ui/src/components/datatable/DataTableSkeleton.vue +100 -98
  84. package/template/src/ui/src/components/datatable/Pagination.vue +153 -125
  85. package/template/src/ui/src/components/datatable/SelectOpption.vue +36 -35
  86. package/template/src/ui/src/components/datatable/index.vue +336 -258
  87. package/template/src/ui/src/env.d.ts +16 -13
  88. package/template/src/ui/src/global.d.ts +21 -2
  89. package/template/src/ui/src/helpers/nformatter.ts +12 -10
  90. package/template/src/ui/src/pages/dashboard/index.vue +690 -687
  91. package/template/src/ui/src/plugins/browserDetect.ts +57 -0
  92. package/template/src/ui/src/plugins/gum.ts +576 -549
  93. package/template/src/ui/src/plugins/pulse.ts +181 -147
  94. package/template/src/ui/src/plugins/routeProgress.ts +89 -0
  95. package/template/src/ui/src/router/index.ts +44 -25
  96. package/template/src/ui/src/stores/example.ts +2 -0
  97. package/template/src/ui/vite.config.ts +40 -38
  98. package/template/src/window/app-menu.ts +89 -87
  99. package/template/src/window/config.ts +14 -12
  100. package/template/src/window/context-menu.ts +23 -21
  101. package/template/src/window/dialogs.ts +92 -90
  102. package/template/src/window/manager.ts +2 -0
  103. package/template/src/window/native.ts +47 -45
  104. package/template/src/window/tray.ts +132 -130
@@ -1,114 +1,116 @@
1
- import fsSync from "node:fs";
2
- import fs from "node:fs/promises";
3
- import path from "node:path";
4
- import type { Client as LibSqlClient } from "@libsql/client";
5
- import { sqliteFile } from "@/core/database/config";
6
- import * as schema from "@/database/schema";
7
-
8
- let databaseInstance: DrizzleDatabase | null = null;
9
- let databaseClient: LibSqlClient | null = null;
10
-
11
- export type DrizzleDatabase = import("drizzle-orm/libsql").LibSQLDatabase<typeof schema>;
12
-
13
- async function resolveMigrationsDir(): Promise<string> {
14
- try {
15
- const e = (await import("electron").catch(() => null)) as any;
16
- if (e?.app?.getAppPath) {
17
- const dir = path.join(e.app.getAppPath(), "src", "database", "migrations", "sqlite");
18
- if (fsSync.existsSync(dir)) return dir;
19
- }
20
- } catch {}
21
- // CLI/dev fallback: find project root
22
- let dir = process.cwd();
23
- for (let i = 0; i < 6; i++) {
24
- const candidate = path.join(dir, "src", "database", "migrations", "sqlite");
25
- if (fsSync.existsSync(path.join(dir, "package.json"))) return candidate;
26
- const parent = path.dirname(dir);
27
- if (parent === dir) break;
28
- dir = parent;
29
- }
30
- return path.join(process.cwd(), "src", "database", "migrations", "sqlite");
31
- }
32
-
33
- export async function initDatabase(): Promise<DrizzleDatabase> {
34
- if (databaseInstance) return databaseInstance;
35
-
36
- const filePath = sqliteFile();
37
- await createFolderFor(filePath);
38
-
39
- databaseInstance = await connectWithLibSql(filePath);
40
- await runBundledMigrations();
41
-
42
- return databaseInstance;
43
- }
44
-
45
- async function runBundledMigrations(): Promise<void> {
46
- const folder = await resolveMigrationsDir();
47
- let journal: { entries?: { tag: string }[] };
48
-
49
- try {
50
- const journalRaw = await fs.readFile(path.join(folder, "meta", "_journal.json"), "utf-8");
51
- journal = JSON.parse(journalRaw);
52
- } catch {
53
- return;
54
- }
55
-
56
- if (!journal.entries?.length || !databaseClient) return;
57
- if ((await countTables()) > 0) return;
58
-
59
- for (const entry of journal.entries) {
60
- try {
61
- const step = await fs.readFile(path.join(folder, `${entry.tag}.sql`), "utf-8");
62
- await databaseClient.executeMultiple(step);
63
- } catch (err) {
64
- console.error(`[db] Failed to run migration ${entry.tag}`, err);
65
- }
66
- }
67
- }
68
-
69
- async function countTables(): Promise<number> {
70
- const sql = "select count(*) as n from sqlite_master where type='table' and name not like 'sqlite_%' and name not like '__drizzle_%'";
71
- const result = await databaseClient!.execute(sql);
72
- const row = result.rows[0] as { n?: bigint | number };
73
- return Number(row?.n ?? 0);
74
- }
75
-
76
- async function connectWithLibSql(filePath: string): Promise<DrizzleDatabase> {
77
- const { createClient } = await import("@libsql/client");
78
- const { drizzle } = await import("drizzle-orm/libsql");
79
-
80
- // libsql requires forward slashes even on Windows
81
- const normalizedPath = filePath.replace(/\\/g, "/");
82
- const client = createClient({ url: `file:${normalizedPath}` });
83
- databaseClient = client;
84
-
85
- return drizzle(client, { schema }) as unknown as DrizzleDatabase;
86
- }
87
-
88
- export function database(): DrizzleDatabase {
89
- if (!databaseInstance) throw new Error("Database is not initialized.");
90
- return databaseInstance;
91
- }
92
-
93
- export const db: DrizzleDatabase & {
94
- init: typeof initDatabase;
95
- close: typeof closeDatabase;
96
- } = new Proxy({} as any, {
97
- get(_target, property) {
98
- if (property === "init") return initDatabase;
99
- if (property === "close") return closeDatabase;
100
- const value = database()[property as keyof DrizzleDatabase];
101
- return typeof value === "function" ? value.bind(database()) : value;
102
- }
103
- });
104
-
105
- export function closeDatabase(): void {
106
- if (databaseClient) databaseClient.close();
107
- databaseClient = null;
108
- databaseInstance = null;
109
- }
110
-
111
- async function createFolderFor(filePath: string): Promise<void> {
112
- const dir = path.dirname(filePath);
113
- await fs.mkdir(dir, { recursive: true });
114
- }
1
+ // ./src/core/database/connection.ts
2
+
3
+ import fsSync from "node:fs";
4
+ import fs from "node:fs/promises";
5
+ import path from "node:path";
6
+ import type { Client as LibSqlClient } from "@libsql/client";
7
+ import { sqliteFile } from "@/core/database/config";
8
+ import * as schema from "@/database/schema";
9
+
10
+ let databaseInstance: DrizzleDatabase | null = null;
11
+ let databaseClient: LibSqlClient | null = null;
12
+
13
+ export type DrizzleDatabase = import("drizzle-orm/libsql").LibSQLDatabase<typeof schema>;
14
+
15
+ async function resolveMigrationsDir(): Promise<string> {
16
+ try {
17
+ const e = (await import("electron").catch(() => null)) as any;
18
+ if (e?.app?.getAppPath) {
19
+ const dir = path.join(e.app.getAppPath(), "src", "database", "migrations", "sqlite");
20
+ if (fsSync.existsSync(dir)) return dir;
21
+ }
22
+ } catch {}
23
+ // CLI/dev fallback: find project root
24
+ let dir = process.cwd();
25
+ for (let i = 0; i < 6; i++) {
26
+ const candidate = path.join(dir, "src", "database", "migrations", "sqlite");
27
+ if (fsSync.existsSync(path.join(dir, "package.json"))) return candidate;
28
+ const parent = path.dirname(dir);
29
+ if (parent === dir) break;
30
+ dir = parent;
31
+ }
32
+ return path.join(process.cwd(), "src", "database", "migrations", "sqlite");
33
+ }
34
+
35
+ export async function initDatabase(): Promise<DrizzleDatabase> {
36
+ if (databaseInstance) return databaseInstance;
37
+
38
+ const filePath = sqliteFile();
39
+ await createFolderFor(filePath);
40
+
41
+ databaseInstance = await connectWithLibSql(filePath);
42
+ await runBundledMigrations();
43
+
44
+ return databaseInstance;
45
+ }
46
+
47
+ async function runBundledMigrations(): Promise<void> {
48
+ const folder = await resolveMigrationsDir();
49
+ let journal: { entries?: { tag: string }[] };
50
+
51
+ try {
52
+ const journalRaw = await fs.readFile(path.join(folder, "meta", "_journal.json"), "utf-8");
53
+ journal = JSON.parse(journalRaw);
54
+ } catch {
55
+ return;
56
+ }
57
+
58
+ if (!journal.entries?.length || !databaseClient) return;
59
+ if ((await countTables()) > 0) return;
60
+
61
+ for (const entry of journal.entries) {
62
+ try {
63
+ const step = await fs.readFile(path.join(folder, `${entry.tag}.sql`), "utf-8");
64
+ await databaseClient.executeMultiple(step);
65
+ } catch (err) {
66
+ console.error(`[db] Failed to run migration ${entry.tag}`, err);
67
+ }
68
+ }
69
+ }
70
+
71
+ async function countTables(): Promise<number> {
72
+ const sql = "select count(*) as n from sqlite_master where type='table' and name not like 'sqlite_%' and name not like '__drizzle_%'";
73
+ const result = await databaseClient!.execute(sql);
74
+ const row = result.rows[0] as { n?: bigint | number };
75
+ return Number(row?.n ?? 0);
76
+ }
77
+
78
+ async function connectWithLibSql(filePath: string): Promise<DrizzleDatabase> {
79
+ const { createClient } = await import("@libsql/client");
80
+ const { drizzle } = await import("drizzle-orm/libsql");
81
+
82
+ // libsql requires forward slashes even on Windows
83
+ const normalizedPath = filePath.replace(/\\/g, "/");
84
+ const client = createClient({ url: `file:${normalizedPath}` });
85
+ databaseClient = client;
86
+
87
+ return drizzle(client, { schema }) as unknown as DrizzleDatabase;
88
+ }
89
+
90
+ export function database(): DrizzleDatabase {
91
+ if (!databaseInstance) throw new Error("Database is not initialized.");
92
+ return databaseInstance;
93
+ }
94
+
95
+ export const db: DrizzleDatabase & {
96
+ init: typeof initDatabase;
97
+ close: typeof closeDatabase;
98
+ } = new Proxy({} as any, {
99
+ get(_target, property) {
100
+ if (property === "init") return initDatabase;
101
+ if (property === "close") return closeDatabase;
102
+ const value = database()[property as keyof DrizzleDatabase];
103
+ return typeof value === "function" ? value.bind(database()) : value;
104
+ }
105
+ });
106
+
107
+ export function closeDatabase(): void {
108
+ if (databaseClient) databaseClient.close();
109
+ databaseClient = null;
110
+ databaseInstance = null;
111
+ }
112
+
113
+ async function createFolderFor(filePath: string): Promise<void> {
114
+ const dir = path.dirname(filePath);
115
+ await fs.mkdir(dir, { recursive: true });
116
+ }
@@ -1,84 +1,86 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { pathToFileURL } from "node:url";
4
- import { sql } from "drizzle-orm";
5
- import { db } from "@/core/database/connection";
6
-
7
- interface HookMap {
8
- __migrationSql: true;
9
- sqlite?: string[];
10
- }
11
-
12
- function isHookMap(value: unknown): value is HookMap {
13
- if (!value || typeof value !== "object") return false;
14
- return (value as HookMap).__migrationSql === true;
15
- }
16
-
17
- function collectStatements(exportsObj: Record<string, unknown>): string[] {
18
- const statements: string[] = [];
19
- for (const value of Object.values(exportsObj)) {
20
- if (!isHookMap(value)) continue;
21
- const list = value.sqlite || [];
22
- for (const statement of list) {
23
- if (typeof statement === "string" && statement.trim()) statements.push(statement);
24
- }
25
- }
26
- return statements;
27
- }
28
-
29
- const SRC_PATH = path.resolve(process.cwd(), "src");
30
-
31
- function walkTs(dir: string, out: string[]): void {
32
- try {
33
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
34
- const full = path.join(dir, entry.name);
35
- if (entry.isDirectory()) {
36
- walkTs(full, out);
37
- } else if (entry.isFile() && entry.name.endsWith(".ts")) {
38
- out.push(full);
39
- }
40
- }
41
- } catch {}
42
- }
43
-
44
- function discoverModelFiles(): string[] {
45
- const files: string[] = [];
46
- const modulesDir = path.join(SRC_PATH, "modules");
47
- const coreDir = path.join(SRC_PATH, "core");
48
-
49
- if (fs.existsSync(modulesDir)) {
50
- for (const moduleDir of fs.readdirSync(modulesDir, { withFileTypes: true })) {
51
- if (!moduleDir.isDirectory()) continue;
52
- walkTs(path.join(modulesDir, moduleDir.name, "database", "models"), files);
53
- }
54
- }
55
- if (fs.existsSync(coreDir)) {
56
- for (const areaDir of fs.readdirSync(coreDir, { withFileTypes: true })) {
57
- if (!areaDir.isDirectory()) continue;
58
- walkTs(path.join(coreDir, areaDir.name, "database", "models"), files);
59
- }
60
- }
61
- return files.sort();
62
- }
63
-
64
- const modelFiles = discoverModelFiles();
65
- await db.init();
66
-
67
- let applied = 0;
68
- try {
69
- for (const file of modelFiles) {
70
- const mod = await import(pathToFileURL(file).href);
71
- const statements = collectStatements(mod as Record<string, unknown>);
72
- if (!statements.length) continue;
73
- for (const statement of statements) {
74
- await db.run(sql.raw(statement));
75
- }
76
- applied += statements.length;
77
- }
78
- } finally {
79
- await db.close();
80
- }
81
-
82
- if (applied > 0) {
83
- console.log(`Applied ${applied} model migration SQL statement(s) for sqlite.`);
84
- }
1
+ // ./src/core/database/migrate-hooks.ts
2
+
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+ import { sql } from "drizzle-orm";
7
+ import { db } from "@/core/database/connection";
8
+
9
+ interface HookMap {
10
+ __migrationSql: true;
11
+ sqlite?: string[];
12
+ }
13
+
14
+ function isHookMap(value: unknown): value is HookMap {
15
+ if (!value || typeof value !== "object") return false;
16
+ return (value as HookMap).__migrationSql === true;
17
+ }
18
+
19
+ function collectStatements(exportsObj: Record<string, unknown>): string[] {
20
+ const statements: string[] = [];
21
+ for (const value of Object.values(exportsObj)) {
22
+ if (!isHookMap(value)) continue;
23
+ const list = value.sqlite || [];
24
+ for (const statement of list) {
25
+ if (typeof statement === "string" && statement.trim()) statements.push(statement);
26
+ }
27
+ }
28
+ return statements;
29
+ }
30
+
31
+ const SRC_PATH = path.resolve(process.cwd(), "src");
32
+
33
+ function walkTs(dir: string, out: string[]): void {
34
+ try {
35
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
36
+ const full = path.join(dir, entry.name);
37
+ if (entry.isDirectory()) {
38
+ walkTs(full, out);
39
+ } else if (entry.isFile() && entry.name.endsWith(".ts")) {
40
+ out.push(full);
41
+ }
42
+ }
43
+ } catch {}
44
+ }
45
+
46
+ function discoverModelFiles(): string[] {
47
+ const files: string[] = [];
48
+ const modulesDir = path.join(SRC_PATH, "modules");
49
+ const coreDir = path.join(SRC_PATH, "core");
50
+
51
+ if (fs.existsSync(modulesDir)) {
52
+ for (const moduleDir of fs.readdirSync(modulesDir, { withFileTypes: true })) {
53
+ if (!moduleDir.isDirectory()) continue;
54
+ walkTs(path.join(modulesDir, moduleDir.name, "database", "models"), files);
55
+ }
56
+ }
57
+ if (fs.existsSync(coreDir)) {
58
+ for (const areaDir of fs.readdirSync(coreDir, { withFileTypes: true })) {
59
+ if (!areaDir.isDirectory()) continue;
60
+ walkTs(path.join(coreDir, areaDir.name, "database", "models"), files);
61
+ }
62
+ }
63
+ return files.sort();
64
+ }
65
+
66
+ const modelFiles = discoverModelFiles();
67
+ await db.init();
68
+
69
+ let applied = 0;
70
+ try {
71
+ for (const file of modelFiles) {
72
+ const mod = await import(pathToFileURL(file).href);
73
+ const statements = collectStatements(mod as Record<string, unknown>);
74
+ if (!statements.length) continue;
75
+ for (const statement of statements) {
76
+ await db.run(sql.raw(statement));
77
+ }
78
+ applied += statements.length;
79
+ }
80
+ } finally {
81
+ await db.close();
82
+ }
83
+
84
+ if (applied > 0) {
85
+ console.log(`Applied ${applied} model migration SQL statement(s) for sqlite.`);
86
+ }