@niyamulahsan/create-deskapp 1.2.2 → 1.2.3
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 +1 -1
- package/template/src/core/api/generate.manifest.ts +4 -10
- package/template/src/core/api/registry.ts +1 -1
- package/template/src/core/config.ts +2 -2
- package/template/src/core/database/aggregate.ts +1 -1
- package/template/src/core/database/connection.ts +11 -11
- package/template/src/core/database/migrate-hooks.ts +1 -1
- package/template/src/core/database/paginate.ts +9 -9
- package/template/src/core/database/reset.ts +2 -2
- package/template/src/core/database/seed.ts +3 -5
- package/template/src/core/database/status.ts +4 -1
- package/template/src/core/env.ts +1 -1
- package/template/src/core/maker/db/fresh.ts +2 -2
- package/template/src/core/maker/db/generate.ts +1 -1
- package/template/src/core/maker/db/migrate.ts +3 -4
- package/template/src/core/maker/db/mod.ts +47 -19
- package/template/src/core/maker/db/module-migrate.ts +7 -6
- package/template/src/core/maker/db/push.ts +1 -1
- package/template/src/core/maker/db/reset.ts +1 -1
- package/template/src/core/maker/db/seed.ts +1 -1
- package/template/src/core/maker/db/status.ts +1 -1
- package/template/src/core/maker/help.ts +6 -15
- package/template/src/core/maker/make/controller.ts +5 -10
- package/template/src/core/maker/make/helpers.ts +6 -8
- package/template/src/core/maker/make/mod.ts +13 -14
- package/template/src/core/maker/make/model.ts +1 -1
- package/template/src/core/maker/make/module.ts +6 -29
- package/template/src/core/maker/make/seeder.ts +2 -2
- package/template/src/core/maker/make/test.ts +3 -3
- package/template/src/core/maker/mod.ts +4 -4
- package/template/src/core/maker/run/mod.ts +34 -14
- package/template/src/core/utils/playwright.ts +25 -25
- package/template/src/core/utils/queue.ts +17 -10
- package/template/src/core/utils/scheduler.ts +7 -17
- package/template/src/core/utils/storage.ts +1 -1
- package/template/src/core/utils/validation.ts +3 -3
- package/template/src/database/migrations/sqlite/meta/_journal.json +5 -1
- package/template/src/preload.ts +1 -1
- package/template/src/ui/src/plugins/gum.ts.bak +0 -683
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { CommandDef } from "
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { makeSeeder } from "
|
|
7
|
-
import { makeTest } from "
|
|
1
|
+
import type { CommandDef } from "@/core/maker/help";
|
|
2
|
+
import { makeController } from "@/core/maker/make/controller";
|
|
3
|
+
import type { MakerOptions } from "@/core/maker/make/helpers";
|
|
4
|
+
import { makeModel } from "@/core/maker/make/model";
|
|
5
|
+
import { makeModule } from "@/core/maker/make/module";
|
|
6
|
+
import { makeSeeder } from "@/core/maker/make/seeder";
|
|
7
|
+
import { makeTest } from "@/core/maker/make/test";
|
|
8
8
|
|
|
9
9
|
const GROUP = "Generators - modules";
|
|
10
10
|
|
|
@@ -24,28 +24,28 @@ export function registerMakeCommands(register: (cmd: CommandDef) => void): void
|
|
|
24
24
|
usage: "<name> [--force]",
|
|
25
25
|
group: GROUP,
|
|
26
26
|
description: "Create a module with model, seeder, controller + schema",
|
|
27
|
-
action: (flags, args) => makeModule(need(args, 0, "Module name"), opts(flags))
|
|
27
|
+
action: (flags, args) => makeModule(need(args, 0, "Module name"), opts(flags))
|
|
28
28
|
});
|
|
29
29
|
register({
|
|
30
30
|
name: "make:controller",
|
|
31
31
|
usage: "<module> <name> [--force] [--dry-run]",
|
|
32
32
|
group: GROUP,
|
|
33
33
|
description: "Generate a controller + schema for an existing module",
|
|
34
|
-
action: (flags, args) => makeController(need(args, 0, "Module name"), need(args, 1, "Controller name"), opts(flags))
|
|
34
|
+
action: (flags, args) => makeController(need(args, 0, "Module name"), need(args, 1, "Controller name"), opts(flags))
|
|
35
35
|
});
|
|
36
36
|
register({
|
|
37
37
|
name: "make:model",
|
|
38
38
|
usage: "<module> <name> [--force] [--dry-run]",
|
|
39
39
|
group: GROUP,
|
|
40
40
|
description: "Generate a model file for an existing module",
|
|
41
|
-
action: (flags, args) => makeModel(need(args, 0, "Module name"), need(args, 1, "Model name"), opts(flags))
|
|
41
|
+
action: (flags, args) => makeModel(need(args, 0, "Module name"), need(args, 1, "Model name"), opts(flags))
|
|
42
42
|
});
|
|
43
43
|
register({
|
|
44
44
|
name: "make:seeder",
|
|
45
45
|
usage: "<module> <name> [--force] [--dry-run]",
|
|
46
46
|
group: GROUP,
|
|
47
47
|
description: "Generate a seeder for an existing module model",
|
|
48
|
-
action: (flags, args) => makeSeeder(need(args, 0, "Module name"), need(args, 1, "Seeder name"), opts(flags))
|
|
48
|
+
action: (flags, args) => makeSeeder(need(args, 0, "Module name"), need(args, 1, "Seeder name"), opts(flags))
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
const testAction = (flags: Record<string, string | boolean>, args: string[]) =>
|
|
@@ -55,14 +55,13 @@ export function registerMakeCommands(register: (cmd: CommandDef) => void): void
|
|
|
55
55
|
usage: "<module> [name] [--force] [--dry-run]",
|
|
56
56
|
group: GROUP,
|
|
57
57
|
description: "Generate a Vitest file in src/modules/<module>/__tests__",
|
|
58
|
-
action: testAction
|
|
58
|
+
action: testAction
|
|
59
59
|
});
|
|
60
60
|
register({
|
|
61
61
|
name: "module:make-test",
|
|
62
62
|
usage: "<module> [name] [--force] [--dry-run]",
|
|
63
63
|
group: GROUP,
|
|
64
64
|
description: "Alias for make:test (Nexwire-style)",
|
|
65
|
-
action: testAction
|
|
65
|
+
action: testAction
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import type { MakerOptions } from "
|
|
2
|
+
import type { MakerOptions } from "@/core/maker/make/helpers";
|
|
3
3
|
import { assertModuleExists, assertName, modelContent, moduleDir, writeFile } from "./helpers";
|
|
4
4
|
|
|
5
5
|
export function makeModel(module: string, name: string, options: MakerOptions = {}): void {
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import type { MakerOptions } from "
|
|
4
|
-
import {
|
|
5
|
-
assertName,
|
|
6
|
-
controllerContent,
|
|
7
|
-
modelContent,
|
|
8
|
-
modulesRoot,
|
|
9
|
-
schemaContent,
|
|
10
|
-
seederContent,
|
|
11
|
-
writeFile,
|
|
12
|
-
} from "./helpers";
|
|
3
|
+
import type { MakerOptions } from "@/core/maker/make/helpers";
|
|
4
|
+
import { assertName, controllerContent, modelContent, modulesRoot, schemaContent, seederContent, writeFile } from "./helpers";
|
|
13
5
|
|
|
14
6
|
export function makeModule(name: string, options: MakerOptions = {}): void {
|
|
15
7
|
const moduleName = assertName(name, "Module name");
|
|
@@ -30,30 +22,15 @@ export function makeModule(name: string, options: MakerOptions = {}): void {
|
|
|
30
22
|
fs.mkdirSync(path.join(root, "database", "seeders"), { recursive: true });
|
|
31
23
|
fs.mkdirSync(path.join(root, "controllers"), { recursive: true });
|
|
32
24
|
|
|
33
|
-
writeFile(
|
|
34
|
-
|
|
35
|
-
modelContent(moduleName, moduleName),
|
|
36
|
-
options,
|
|
37
|
-
"Model file",
|
|
38
|
-
);
|
|
39
|
-
writeFile(
|
|
40
|
-
path.join(root, "database", "seeders", `${moduleName}.seed.ts`),
|
|
41
|
-
seederContent(moduleName, moduleName),
|
|
42
|
-
options,
|
|
43
|
-
"Seeder file",
|
|
44
|
-
);
|
|
25
|
+
writeFile(path.join(root, "database", "models", `${moduleName}.model.ts`), modelContent(moduleName, moduleName), options, "Model file");
|
|
26
|
+
writeFile(path.join(root, "database", "seeders", `${moduleName}.seed.ts`), seederContent(moduleName, moduleName), options, "Seeder file");
|
|
45
27
|
writeFile(
|
|
46
28
|
path.join(root, "controllers", `${moduleName}.controller.ts`),
|
|
47
29
|
controllerContent(moduleName, moduleName),
|
|
48
30
|
options,
|
|
49
|
-
"Controller file"
|
|
50
|
-
);
|
|
51
|
-
writeFile(
|
|
52
|
-
path.join(root, "controllers", `${moduleName}.schema.ts`),
|
|
53
|
-
schemaContent(moduleName, moduleName),
|
|
54
|
-
options,
|
|
55
|
-
"Schema file",
|
|
31
|
+
"Controller file"
|
|
56
32
|
);
|
|
33
|
+
writeFile(path.join(root, "controllers", `${moduleName}.schema.ts`), schemaContent(moduleName, moduleName), options, "Schema file");
|
|
57
34
|
|
|
58
35
|
console.log(`Module ready: ${path.resolve(root)}`);
|
|
59
36
|
console.log("Database files: database/models/{name}.model.ts, database/seeders/{name}.seed.ts");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import type { MakerOptions } from "
|
|
3
|
+
import type { MakerOptions } from "@/core/maker/make/helpers";
|
|
4
4
|
import { assertModuleExists, assertName, moduleDir, seederContent, writeFile } from "./helpers";
|
|
5
5
|
|
|
6
6
|
export function makeSeeder(module: string, name: string, options: MakerOptions = {}): void {
|
|
@@ -10,7 +10,7 @@ export function makeSeeder(module: string, name: string, options: MakerOptions =
|
|
|
10
10
|
const modelPath = path.join(moduleDir(moduleName), "database", "models", `${seederName}.model.ts`);
|
|
11
11
|
if (!fs.existsSync(modelPath) || !fs.statSync(modelPath).isFile()) {
|
|
12
12
|
throw new Error(
|
|
13
|
-
`Model not found for seeder: src/modules/${moduleName}/database/models/${seederName}.model.ts. Create it first with: npm run maker -- make:model ${moduleName} ${seederName}
|
|
13
|
+
`Model not found for seeder: src/modules/${moduleName}/database/models/${seederName}.model.ts. Create it first with: npm run maker -- make:model ${moduleName} ${seederName}`
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
16
|
const filePath = path.join(moduleDir(moduleName), "database", "seeders", `${seederName}.seed.ts`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import type { MakerOptions } from "@/core/maker/make/helpers";
|
|
3
|
+
import { loadStub } from "@/core/maker/stub";
|
|
4
4
|
import { assertModuleExists, assertName, moduleDir, writeFile } from "./helpers";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -10,7 +10,7 @@ import { assertModuleExists, assertName, moduleDir, writeFile } from "./helpers"
|
|
|
10
10
|
export function makeTest(module: string, name?: string, options: MakerOptions = {}): void {
|
|
11
11
|
const moduleName = assertName(module, "Module name");
|
|
12
12
|
assertModuleExists(moduleName);
|
|
13
|
-
const rawName = name
|
|
13
|
+
const rawName = name?.trim() ? assertName(name, "Test name") : moduleName;
|
|
14
14
|
// strip trailing .test/.spec if provided
|
|
15
15
|
const testName = rawName.replace(/\.(test|spec)$/i, "");
|
|
16
16
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { registerDbCommands } from "
|
|
2
|
-
import { printCommandHelp, printHelp
|
|
3
|
-
import { registerMakeCommands } from "
|
|
4
|
-
import { registerRunCommands } from "
|
|
1
|
+
import { registerDbCommands } from "@/core/maker/db/mod";
|
|
2
|
+
import { type CommandDef, printCommandHelp, printHelp } from "@/core/maker/help";
|
|
3
|
+
import { registerMakeCommands } from "@/core/maker/make/mod";
|
|
4
|
+
import { registerRunCommands } from "@/core/maker/run/mod";
|
|
5
5
|
|
|
6
6
|
const commands = new Map<string, CommandDef>();
|
|
7
7
|
|
|
@@ -2,7 +2,7 @@ import { spawnSync } from "node:child_process";
|
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import type { CommandDef } from "
|
|
5
|
+
import type { CommandDef } from "@/core/maker/help";
|
|
6
6
|
|
|
7
7
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
8
|
const ROOT = path.resolve(__dirname, "..", "..", "..", "..");
|
|
@@ -14,7 +14,7 @@ function run(cmd: string, args: string[], opts: { cwd?: string; label?: string }
|
|
|
14
14
|
cwd: opts.cwd ?? ROOT,
|
|
15
15
|
stdio: "inherit",
|
|
16
16
|
shell: false,
|
|
17
|
-
env: process.env
|
|
17
|
+
env: process.env
|
|
18
18
|
});
|
|
19
19
|
if (r.error) throw r.error;
|
|
20
20
|
if (r.status !== 0) process.exit(r.status ?? 1);
|
|
@@ -42,42 +42,42 @@ export function registerRunCommands(register: (cmd: CommandDef) => void): void {
|
|
|
42
42
|
action: () => {
|
|
43
43
|
schemaAndBindings();
|
|
44
44
|
run("npm", ["run", "dev"], { label: "dev" });
|
|
45
|
-
}
|
|
45
|
+
}
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
register({
|
|
49
49
|
name: "ui",
|
|
50
50
|
group: "Getting started",
|
|
51
51
|
description: "Start Vite dev server for the renderer only (no Electron bindings)",
|
|
52
|
-
action: () => run("npx", ["vite", "--config", "src/ui/vite.config.ts"], { label: "vite dev", cwd: ROOT })
|
|
52
|
+
action: () => run("npx", ["vite", "--config", "src/ui/vite.config.ts"], { label: "vite dev", cwd: ROOT })
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
register({
|
|
56
56
|
name: "start",
|
|
57
57
|
group: "Getting started",
|
|
58
58
|
description: "Run the built Electron app (loads src/ui/dist; requires build)",
|
|
59
|
-
action: () => run("npm", ["run", "start"], { label: "start" })
|
|
59
|
+
action: () => run("npm", ["run", "start"], { label: "start" })
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
register({
|
|
63
63
|
name: "config:sync",
|
|
64
64
|
group: "Build & codegen",
|
|
65
65
|
description: "Sync src/config/app.ts -> package.json build/identity + scripts/installer.nsh",
|
|
66
|
-
action: () => configSync()
|
|
66
|
+
action: () => configSync()
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
register({
|
|
70
70
|
name: "codegen",
|
|
71
71
|
group: "Build & codegen",
|
|
72
72
|
description: "Sync config + regenerate database schema + bindings manifest",
|
|
73
|
-
action: () => schemaAndBindings()
|
|
73
|
+
action: () => schemaAndBindings()
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
register({
|
|
77
77
|
name: "bindings:gen",
|
|
78
78
|
group: "Build & codegen",
|
|
79
79
|
description: "Regenerate src/core/api/bindings.generated.ts from controllers",
|
|
80
|
-
action: () => tsxScript("src/core/api/generate.manifest.ts", "bindings:gen")
|
|
80
|
+
action: () => tsxScript("src/core/api/generate.manifest.ts", "bindings:gen")
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
register({
|
|
@@ -87,7 +87,7 @@ export function registerRunCommands(register: (cmd: CommandDef) => void): void {
|
|
|
87
87
|
action: () => {
|
|
88
88
|
schemaAndBindings();
|
|
89
89
|
run("npm", ["run", "build"], { label: "build", cwd: ROOT });
|
|
90
|
-
}
|
|
90
|
+
}
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
register({
|
|
@@ -101,12 +101,32 @@ export function registerRunCommands(register: (cmd: CommandDef) => void): void {
|
|
|
101
101
|
if (typeof flags.platform === "string") ebArgs.push(`--${flags.platform}`);
|
|
102
102
|
if (typeof flags.target === "string") ebArgs.push(`--${flags.target}`);
|
|
103
103
|
run("npx", ebArgs, { label: "electron-builder" });
|
|
104
|
-
}
|
|
104
|
+
}
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
register({
|
|
107
|
+
register({
|
|
108
|
+
name: "serve",
|
|
109
|
+
group: "Getting started",
|
|
110
|
+
description: "Alias for dev (Electron)",
|
|
111
|
+
action: () => run("npm", ["run", "dev"], { label: "dev" })
|
|
112
|
+
});
|
|
108
113
|
|
|
109
|
-
register({
|
|
110
|
-
|
|
111
|
-
|
|
114
|
+
register({
|
|
115
|
+
name: "test",
|
|
116
|
+
group: "Testing",
|
|
117
|
+
description: "Run Vitest unit tests (node environment)",
|
|
118
|
+
action: () => run("npx", ["vitest", "run"], { label: "test" })
|
|
119
|
+
});
|
|
120
|
+
register({
|
|
121
|
+
name: "test:watch",
|
|
122
|
+
group: "Testing",
|
|
123
|
+
description: "Run Vitest in watch mode",
|
|
124
|
+
action: () => run("npx", ["vitest"], { label: "test:watch" })
|
|
125
|
+
});
|
|
126
|
+
register({
|
|
127
|
+
name: "test:coverage",
|
|
128
|
+
group: "Testing",
|
|
129
|
+
description: "Run Vitest with V8 coverage",
|
|
130
|
+
action: () => run("npx", ["vitest", "run", "--coverage"], { label: "test:coverage" })
|
|
131
|
+
});
|
|
112
132
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { dirname, join } from "node:path";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
1
|
import { execSync } from "node:child_process";
|
|
4
2
|
import fs from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
5
|
import { app } from "electron";
|
|
6
6
|
|
|
7
7
|
function getRequire(): NodeRequire {
|
|
@@ -16,15 +16,15 @@ export const chromium = {
|
|
|
16
16
|
exists(path: string): boolean {
|
|
17
17
|
return existsPath(path);
|
|
18
18
|
},
|
|
19
|
-
candidates(overrides?: { env?: string | null; execPath?: string; cwd?: string
|
|
19
|
+
candidates(overrides?: { env?: string | null; execPath?: string; cwd?: string }): string[] {
|
|
20
20
|
return chromiumCandidates(overrides);
|
|
21
21
|
},
|
|
22
|
-
resolve(overrides?: { env?: string | null; execPath?: string; cwd?: string
|
|
22
|
+
resolve(overrides?: { env?: string | null; execPath?: string; cwd?: string }): string | undefined {
|
|
23
23
|
return resolveChromium(overrides);
|
|
24
24
|
},
|
|
25
|
-
extensions(overrides?: { execPath?: string; cwd?: string
|
|
25
|
+
extensions(overrides?: { execPath?: string; cwd?: string }): string[] {
|
|
26
26
|
return extensionsCandidates(overrides);
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export function existsPath(path: string): boolean {
|
|
@@ -38,28 +38,31 @@ export function existsPath(path: string): boolean {
|
|
|
38
38
|
|
|
39
39
|
export function platformRelPaths(): string[][] {
|
|
40
40
|
if (process.platform === "win32") {
|
|
41
|
-
return [
|
|
41
|
+
return [
|
|
42
|
+
["chrome-win64", "chrome.exe"],
|
|
43
|
+
["chrome-win", "chrome.exe"]
|
|
44
|
+
];
|
|
42
45
|
}
|
|
43
46
|
if (process.platform === "linux") {
|
|
44
47
|
return [["chrome-linux", "chrome"]];
|
|
45
48
|
}
|
|
46
49
|
if (process.platform === "darwin") {
|
|
47
50
|
const app = ["Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"];
|
|
48
|
-
return [
|
|
51
|
+
return [
|
|
52
|
+
["chrome-mac-arm64", ...app],
|
|
53
|
+
["chrome-mac", ...app]
|
|
54
|
+
];
|
|
49
55
|
}
|
|
50
56
|
return [];
|
|
51
57
|
}
|
|
52
58
|
|
|
53
|
-
export function chromiumCandidates(overrides?: { env?: string | null; execPath?: string; cwd?: string
|
|
59
|
+
export function chromiumCandidates(overrides?: { env?: string | null; execPath?: string; cwd?: string }): string[] {
|
|
54
60
|
const out: string[] = [];
|
|
55
61
|
const env = overrides?.env === undefined ? process.env.DESKAPP_CHROMIUM : overrides.env;
|
|
56
62
|
if (env) out.push(env);
|
|
57
63
|
|
|
58
|
-
const bases = [
|
|
59
|
-
|
|
60
|
-
overrides?.cwd ?? process.cwd()
|
|
61
|
-
];
|
|
62
|
-
|
|
64
|
+
const bases = [dirname(overrides?.execPath ?? app.getPath("exe")), overrides?.cwd ?? process.cwd()];
|
|
65
|
+
|
|
63
66
|
for (const base of bases) {
|
|
64
67
|
for (const rel of platformRelPaths()) {
|
|
65
68
|
out.push(join(base, "chromium", ...rel));
|
|
@@ -68,17 +71,14 @@ export function chromiumCandidates(overrides?: { env?: string | null; execPath?:
|
|
|
68
71
|
return out;
|
|
69
72
|
}
|
|
70
73
|
|
|
71
|
-
export function resolveChromium(overrides?: { env?: string | null; execPath?: string; cwd?: string
|
|
74
|
+
export function resolveChromium(overrides?: { env?: string | null; execPath?: string; cwd?: string }): string | undefined {
|
|
72
75
|
return chromiumCandidates(overrides).find(existsPath);
|
|
73
76
|
}
|
|
74
77
|
|
|
75
|
-
export function extensionsCandidates(overrides?: { execPath?: string; cwd?: string
|
|
78
|
+
export function extensionsCandidates(overrides?: { execPath?: string; cwd?: string }): string[] {
|
|
76
79
|
const out: string[] = [];
|
|
77
|
-
const bases = [
|
|
78
|
-
|
|
79
|
-
overrides?.cwd ?? process.cwd()
|
|
80
|
-
];
|
|
81
|
-
|
|
80
|
+
const bases = [dirname(overrides?.execPath ?? app.getPath("exe")), overrides?.cwd ?? process.cwd()];
|
|
81
|
+
|
|
82
82
|
for (const base of bases) {
|
|
83
83
|
for (const rel of ["extensions", join("src", "extensions")]) {
|
|
84
84
|
const root = join(base, rel);
|
|
@@ -96,7 +96,7 @@ export function extensionsCandidates(overrides?: { execPath?: string; cwd?: stri
|
|
|
96
96
|
return out;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
export function resolveExtensions(overrides?: { execPath?: string; cwd?: string
|
|
99
|
+
export function resolveExtensions(overrides?: { execPath?: string; cwd?: string }): string[] {
|
|
100
100
|
return extensionsCandidates(overrides);
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -106,11 +106,11 @@ export async function ensurePlaywrightBrowser(browser = "chromium"): Promise<voi
|
|
|
106
106
|
const req = getRequire();
|
|
107
107
|
const playwrightPkg = req.resolve("playwright/package.json");
|
|
108
108
|
const cliFile = join(dirname(playwrightPkg), "cli.js");
|
|
109
|
-
|
|
109
|
+
|
|
110
110
|
if (!existsPath(cliFile)) {
|
|
111
111
|
throw new Error(`playwright CLI not found at ${cliFile}; install the browser manually with 'npx playwright install ${browser}'.`);
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
// In Electron, process.execPath is the Electron binary, not Node.
|
|
115
115
|
// We use the system's Node execution to run the playwright CLI.
|
|
116
116
|
execSync(`node "${cliFile}" install ${browser}`, { stdio: "inherit" });
|
|
@@ -118,4 +118,4 @@ export async function ensurePlaywrightBrowser(browser = "chromium"): Promise<voi
|
|
|
118
118
|
console.error("[playwright] Failed to ensure browser:", error);
|
|
119
119
|
throw new Error(`playwright install ${browser} failed; retry with 'npx playwright install ${browser}'.`);
|
|
120
120
|
}
|
|
121
|
-
}
|
|
121
|
+
}
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
export type QueueTask<T> = () => Promise<T>;
|
|
10
10
|
|
|
11
|
-
interface Pending<T> {
|
|
11
|
+
interface Pending<T> {
|
|
12
|
+
task: QueueTask<T>;
|
|
13
|
+
resolve: (value: T) => void;
|
|
14
|
+
reject: (reason?: unknown) => void;
|
|
15
|
+
}
|
|
12
16
|
|
|
13
17
|
export interface Queue<T> {
|
|
14
18
|
add(task: QueueTask<T>): Promise<T>;
|
|
@@ -21,12 +25,12 @@ export interface Queue<T> {
|
|
|
21
25
|
* facade: `const q = queue.create({ concurrency: 3 })`.
|
|
22
26
|
*/
|
|
23
27
|
export const queue = {
|
|
24
|
-
create<T>(options?: { concurrency?: number
|
|
28
|
+
create<T>(options?: { concurrency?: number }): Queue<T> {
|
|
25
29
|
return createQueue<T>(options);
|
|
26
|
-
}
|
|
30
|
+
}
|
|
27
31
|
};
|
|
28
32
|
|
|
29
|
-
function createQueue<T>(options?: { concurrency?: number
|
|
33
|
+
function createQueue<T>(options?: { concurrency?: number }): Queue<T> {
|
|
30
34
|
const concurrency = Math.max(1, options?.concurrency ?? 1);
|
|
31
35
|
const pending: Pending<T>[] = [];
|
|
32
36
|
let running = 0;
|
|
@@ -35,10 +39,13 @@ function createQueue<T>(options?: { concurrency?: number; }): Queue<T> {
|
|
|
35
39
|
while (running < concurrency && pending.length > 0) {
|
|
36
40
|
const entry = pending.shift()!;
|
|
37
41
|
running += 1;
|
|
38
|
-
entry
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
entry
|
|
43
|
+
.task()
|
|
44
|
+
.then(entry.resolve, entry.reject)
|
|
45
|
+
.finally(() => {
|
|
46
|
+
running -= 1;
|
|
47
|
+
tick();
|
|
48
|
+
});
|
|
42
49
|
}
|
|
43
50
|
};
|
|
44
51
|
|
|
@@ -54,6 +61,6 @@ function createQueue<T>(options?: { concurrency?: number; }): Queue<T> {
|
|
|
54
61
|
},
|
|
55
62
|
get running() {
|
|
56
63
|
return running;
|
|
57
|
-
}
|
|
64
|
+
}
|
|
58
65
|
};
|
|
59
|
-
}
|
|
66
|
+
}
|
|
@@ -23,48 +23,38 @@ export const cron = {
|
|
|
23
23
|
* Schedule a named cron job. Re-scheduling the same name replaces the old
|
|
24
24
|
* job (and stops it). Returns a handle with `stop()`.
|
|
25
25
|
*/
|
|
26
|
-
schedule(
|
|
27
|
-
name: string,
|
|
28
|
-
expression: string,
|
|
29
|
-
task: () => void | Promise<void>,
|
|
30
|
-
options?: { timezone?: string; },
|
|
31
|
-
): CronHandle {
|
|
26
|
+
schedule(name: string, expression: string, task: () => void | Promise<void>, options?: { timezone?: string }): CronHandle {
|
|
32
27
|
return scheduleCron(name, expression, task, options);
|
|
33
28
|
},
|
|
34
29
|
|
|
35
30
|
/** Stop every scheduled job (call on app shutdown). */
|
|
36
31
|
stop(): void {
|
|
37
32
|
stopSchedules();
|
|
38
|
-
}
|
|
33
|
+
}
|
|
39
34
|
};
|
|
40
35
|
|
|
41
|
-
function scheduleCron(
|
|
42
|
-
name: string,
|
|
43
|
-
expression: string,
|
|
44
|
-
task: () => void | Promise<void>,
|
|
45
|
-
options?: { timezone?: string; },
|
|
46
|
-
): CronHandle {
|
|
36
|
+
function scheduleCron(name: string, expression: string, task: () => void | Promise<void>, options?: { timezone?: string }): CronHandle {
|
|
47
37
|
jobs.get(name)?.stop();
|
|
48
38
|
const job = new Cron(
|
|
49
39
|
expression,
|
|
50
40
|
{
|
|
51
41
|
timezone: options?.timezone,
|
|
52
|
-
catch: (error: unknown) => console.error(`[scheduler] "${name}" run failed:`, error)
|
|
42
|
+
catch: (error: unknown) => console.error(`[scheduler] "${name}" run failed:`, error)
|
|
53
43
|
},
|
|
54
44
|
() => {
|
|
55
45
|
void task();
|
|
56
|
-
}
|
|
46
|
+
}
|
|
57
47
|
);
|
|
58
48
|
jobs.set(name, job);
|
|
59
49
|
return {
|
|
60
50
|
stop() {
|
|
61
51
|
job.stop();
|
|
62
52
|
jobs.delete(name);
|
|
63
|
-
}
|
|
53
|
+
}
|
|
64
54
|
};
|
|
65
55
|
}
|
|
66
56
|
|
|
67
57
|
function stopSchedules(): void {
|
|
68
58
|
for (const job of jobs.values()) job.stop();
|
|
69
59
|
jobs.clear();
|
|
70
|
-
}
|
|
60
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import { basename, dirname, join, resolve } from "node:path";
|
|
3
4
|
import { pathToFileURL } from "node:url";
|
|
4
|
-
import { createRequire } from "node:module";
|
|
5
5
|
import { appBaseDir } from "@/core/env";
|
|
6
6
|
|
|
7
7
|
function getElectronApp(): { getPath: (name: string) => string; isPackaged: boolean } | undefined {
|
package/template/src/preload.ts
CHANGED