@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,67 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
1
|
+
// ./src/core/maker/make/mod.ts
|
|
2
|
+
|
|
3
|
+
import type { CommandDef } from "@/core/maker/help";
|
|
4
|
+
import { makeController } from "@/core/maker/make/controller";
|
|
5
|
+
import type { MakerOptions } from "@/core/maker/make/helpers";
|
|
6
|
+
import { makeModel } from "@/core/maker/make/model";
|
|
7
|
+
import { makeModule } from "@/core/maker/make/module";
|
|
8
|
+
import { makeSeeder } from "@/core/maker/make/seeder";
|
|
9
|
+
import { makeTest } from "@/core/maker/make/test";
|
|
10
|
+
|
|
11
|
+
const GROUP = "Generators - modules";
|
|
12
|
+
|
|
13
|
+
function opts(flags: Record<string, string | boolean>): MakerOptions {
|
|
14
|
+
return { force: Boolean(flags.force), dryRun: Boolean(flags["dry-run"] ?? flags.dryRun) };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function need(args: string[], i: number, label: string): string {
|
|
18
|
+
const v = args[i];
|
|
19
|
+
if (!v) throw new Error(`${label} is required.`);
|
|
20
|
+
return v;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function registerMakeCommands(register: (cmd: CommandDef) => void): void {
|
|
24
|
+
register({
|
|
25
|
+
name: "make:module",
|
|
26
|
+
usage: "<name> [--force]",
|
|
27
|
+
group: GROUP,
|
|
28
|
+
description: "Create a module with model, seeder, controller + schema + facade",
|
|
29
|
+
action: (flags, args) => makeModule(need(args, 0, "Module name"), opts(flags))
|
|
30
|
+
});
|
|
31
|
+
register({
|
|
32
|
+
name: "make:controller",
|
|
33
|
+
usage: "<module> <name> [--force] [--dry-run]",
|
|
34
|
+
group: GROUP,
|
|
35
|
+
description: "Generate a controller + schema for an existing module",
|
|
36
|
+
action: (flags, args) => makeController(need(args, 0, "Module name"), need(args, 1, "Controller name"), opts(flags))
|
|
37
|
+
});
|
|
38
|
+
register({
|
|
39
|
+
name: "make:model",
|
|
40
|
+
usage: "<module> <name> [--force] [--dry-run]",
|
|
41
|
+
group: GROUP,
|
|
42
|
+
description: "Generate a model file for an existing module",
|
|
43
|
+
action: (flags, args) => makeModel(need(args, 0, "Module name"), need(args, 1, "Model name"), opts(flags))
|
|
44
|
+
});
|
|
45
|
+
register({
|
|
46
|
+
name: "make:seeder",
|
|
47
|
+
usage: "<module> <name> [--force] [--dry-run]",
|
|
48
|
+
group: GROUP,
|
|
49
|
+
description: "Generate a seeder for an existing module model",
|
|
50
|
+
action: (flags, args) => makeSeeder(need(args, 0, "Module name"), need(args, 1, "Seeder name"), opts(flags))
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const testAction = (flags: Record<string, string | boolean>, args: string[]) =>
|
|
54
|
+
makeTest(need(args, 0, "Module name"), args[1], opts(flags));
|
|
55
|
+
register({
|
|
56
|
+
name: "make:test",
|
|
57
|
+
usage: "<module> [name] [--force] [--dry-run]",
|
|
58
|
+
group: GROUP,
|
|
59
|
+
description: "Generate a Vitest file in src/modules/<module>/__tests__",
|
|
60
|
+
action: testAction
|
|
61
|
+
});
|
|
62
|
+
register({
|
|
63
|
+
name: "module:make-test",
|
|
64
|
+
usage: "<module> [name] [--force] [--dry-run]",
|
|
65
|
+
group: GROUP,
|
|
66
|
+
description: "Alias for make:test (Nexwire-style)",
|
|
67
|
+
action: testAction
|
|
68
|
+
});
|
|
69
|
+
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
1
|
+
// ./src/core/maker/make/model.ts
|
|
2
|
+
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import type { MakerOptions } from "@/core/maker/make/helpers";
|
|
5
|
+
import { assertModuleExists, assertName, modelContent, moduleDir, writeFile } from "./helpers";
|
|
6
|
+
|
|
7
|
+
export function makeModel(module: string, name: string, options: MakerOptions = {}): void {
|
|
8
|
+
const moduleName = assertName(module, "Module name");
|
|
9
|
+
const modelName = assertName(name, "Model name");
|
|
10
|
+
assertModuleExists(moduleName);
|
|
11
|
+
const filePath = path.join(moduleDir(moduleName), "database", "models", `${modelName}.model.ts`);
|
|
12
|
+
writeFile(filePath, modelContent(moduleName, modelName), options, "Model file");
|
|
13
|
+
if (!options.dryRun) {
|
|
14
|
+
console.log(`Next: \`npm run maker -- db:generate\` (or \`db:migrate\`) to include '${modelName}' in the schema.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,39 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
1
|
+
// ./src/core/maker/make/module.ts
|
|
2
|
+
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import type { MakerOptions } from "@/core/maker/make/helpers";
|
|
6
|
+
import {
|
|
7
|
+
assertName,
|
|
8
|
+
controllerContent,
|
|
9
|
+
facadeContent,
|
|
10
|
+
modelContent,
|
|
11
|
+
modulesRoot,
|
|
12
|
+
schemaContent,
|
|
13
|
+
seederContent,
|
|
14
|
+
writeFile
|
|
15
|
+
} from "./helpers";
|
|
16
|
+
|
|
17
|
+
export function makeModule(name: string, options: MakerOptions = {}): void {
|
|
18
|
+
const moduleName = assertName(name, "Module name");
|
|
19
|
+
const root = path.join(modulesRoot(), moduleName);
|
|
20
|
+
const exists = fs.existsSync(root) && fs.statSync(root).isDirectory();
|
|
21
|
+
if (exists && !options.force) throw new Error(`Module already exists: ${moduleName}.`);
|
|
22
|
+
|
|
23
|
+
if (options.dryRun) {
|
|
24
|
+
console.log(`[dry-run] would create module: ${path.resolve(root)}`);
|
|
25
|
+
console.log(`[dry-run] - database/models/${moduleName}.model.ts`);
|
|
26
|
+
console.log(`[dry-run] - database/seeders/${moduleName}.seed.ts`);
|
|
27
|
+
console.log(`[dry-run] - controllers/${moduleName}.controller.ts`);
|
|
28
|
+
console.log(`[dry-run] - controllers/${moduleName}.schema.ts`);
|
|
29
|
+
console.log("[dry-run] - facade.ts");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fs.mkdirSync(path.join(root, "database", "models"), { recursive: true });
|
|
34
|
+
fs.mkdirSync(path.join(root, "database", "seeders"), { recursive: true });
|
|
35
|
+
fs.mkdirSync(path.join(root, "controllers"), { recursive: true });
|
|
36
|
+
|
|
37
|
+
writeFile(path.join(root, "database", "models", `${moduleName}.model.ts`), modelContent(moduleName, moduleName), options, "Model file");
|
|
38
|
+
writeFile(path.join(root, "database", "seeders", `${moduleName}.seed.ts`), seederContent(moduleName, moduleName), options, "Seeder file");
|
|
39
|
+
writeFile(
|
|
40
|
+
path.join(root, "controllers", `${moduleName}.controller.ts`),
|
|
41
|
+
controllerContent(moduleName, moduleName),
|
|
42
|
+
options,
|
|
43
|
+
"Controller file"
|
|
44
|
+
);
|
|
45
|
+
writeFile(path.join(root, "controllers", `${moduleName}.schema.ts`), schemaContent(moduleName, moduleName), options, "Schema file");
|
|
46
|
+
writeFile(path.join(root, "facade.ts"), facadeContent(moduleName), options, "Facade file");
|
|
47
|
+
|
|
48
|
+
console.log(`Module ready: ${path.resolve(root)}`);
|
|
49
|
+
console.log("Database files: database/models/{name}.model.ts, database/seeders/{name}.seed.ts");
|
|
50
|
+
console.log("Controller + schema: controllers/{name}.controller.ts, controllers/{name}.schema.ts");
|
|
51
|
+
console.log("Public API: facade.ts (re-exports controllers + models for other modules)");
|
|
52
|
+
console.log("Next: `npm run maker -- db:generate` (or `db:migrate`), then `npm run maker -- bindings:gen` and rebuild Electron.");
|
|
53
|
+
}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
// ./src/core/maker/make/seeder.ts
|
|
2
|
+
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import type { MakerOptions } from "@/core/maker/make/helpers";
|
|
6
|
+
import { assertModuleExists, assertName, moduleDir, seederContent, writeFile } from "./helpers";
|
|
7
|
+
|
|
8
|
+
export function makeSeeder(module: string, name: string, options: MakerOptions = {}): void {
|
|
9
|
+
const moduleName = assertName(module, "Module name");
|
|
10
|
+
const seederName = assertName(name, "Seeder name");
|
|
11
|
+
assertModuleExists(moduleName);
|
|
12
|
+
const modelPath = path.join(moduleDir(moduleName), "database", "models", `${seederName}.model.ts`);
|
|
13
|
+
if (!fs.existsSync(modelPath) || !fs.statSync(modelPath).isFile()) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
`Model not found for seeder: src/modules/${moduleName}/database/models/${seederName}.model.ts. Create it first with: npm run maker -- make:model ${moduleName} ${seederName}`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
const filePath = path.join(moduleDir(moduleName), "database", "seeders", `${seederName}.seed.ts`);
|
|
19
|
+
writeFile(filePath, seederContent(moduleName, seederName), options, "Seeder file");
|
|
20
|
+
if (!options.dryRun) {
|
|
21
|
+
console.log("Fills seed values from parent FKs manually; ordering is resolved automatically by the seeder runner.");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
// ./src/core/maker/make/test.ts
|
|
2
|
+
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import type { MakerOptions } from "@/core/maker/make/helpers";
|
|
5
|
+
import { loadStub } from "@/core/maker/stub";
|
|
6
|
+
import { assertModuleExists, assertName, moduleDir, writeFile } from "./helpers";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* make:test / module:make-test - create a Vitest file in a module's __tests__ folder.
|
|
10
|
+
* Nexwire-style: `module:make-test <module> [name]` -> __tests__/<name|module>.test.ts
|
|
11
|
+
*/
|
|
12
|
+
export function makeTest(module: string, name?: string, options: MakerOptions = {}): void {
|
|
13
|
+
const moduleName = assertName(module, "Module name");
|
|
14
|
+
assertModuleExists(moduleName);
|
|
15
|
+
const rawName = name?.trim() ? assertName(name, "Test name") : moduleName;
|
|
16
|
+
// strip trailing .test/.spec if provided
|
|
17
|
+
const testName = rawName.replace(/\.(test|spec)$/i, "");
|
|
18
|
+
|
|
19
|
+
const filePath = path.join(moduleDir(moduleName), "__tests__", `${testName}.test.ts`);
|
|
20
|
+
const content = loadStub("test/test.stub", {
|
|
21
|
+
module: moduleName,
|
|
22
|
+
name: testName === moduleName ? "" : testName,
|
|
23
|
+
file: `${testName}.test.ts`
|
|
24
|
+
}).replace(/\{\{#name\}\}[\s\S]*?\{\{\/name\}\}/g, (m) => {
|
|
25
|
+
// simple conditional: keep inner text when name is non-empty
|
|
26
|
+
return testName === moduleName ? "" : m.replace(/\{\{#name\}\}|\{\{\/name\}\}/g, "");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
writeFile(filePath, content, options, "Test file");
|
|
30
|
+
if (!options.dryRun) {
|
|
31
|
+
console.log(`Run tests with: npm test (or \`npm run maker -- test\`).`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,83 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
flags
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
1
|
+
// ./src/core/maker/mod.ts
|
|
2
|
+
|
|
3
|
+
import { registerDbCommands } from "@/core/maker/db/mod";
|
|
4
|
+
import { type CommandDef, printCommandHelp, printHelp } from "@/core/maker/help";
|
|
5
|
+
import { registerMakeCommands } from "@/core/maker/make/mod";
|
|
6
|
+
import { registerRunCommands } from "@/core/maker/run/mod";
|
|
7
|
+
|
|
8
|
+
const commands = new Map<string, CommandDef>();
|
|
9
|
+
|
|
10
|
+
function register(cmd: CommandDef) {
|
|
11
|
+
commands.set(cmd.name, cmd);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
registerMakeCommands(register);
|
|
15
|
+
registerDbCommands(register);
|
|
16
|
+
registerRunCommands(register);
|
|
17
|
+
|
|
18
|
+
function parseFlags(argv: string[]): { flags: Record<string, string | boolean>; positionals: string[] } {
|
|
19
|
+
const flags: Record<string, string | boolean> = {};
|
|
20
|
+
const positionals: string[] = [];
|
|
21
|
+
for (let i = 0; i < argv.length; i++) {
|
|
22
|
+
const arg = argv[i];
|
|
23
|
+
if (arg === "--") {
|
|
24
|
+
positionals.push(...argv.slice(i + 1));
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
if (arg.startsWith("--")) {
|
|
28
|
+
const eq = arg.indexOf("=");
|
|
29
|
+
if (eq !== -1) {
|
|
30
|
+
flags[arg.slice(2, eq)] = arg.slice(eq + 1);
|
|
31
|
+
} else {
|
|
32
|
+
const key = arg.slice(2);
|
|
33
|
+
const next = argv[i + 1];
|
|
34
|
+
if (key === "no-zip") {
|
|
35
|
+
flags.zip = false;
|
|
36
|
+
} else if (next !== undefined && !next.startsWith("--")) {
|
|
37
|
+
flags[key] = next;
|
|
38
|
+
i++;
|
|
39
|
+
} else {
|
|
40
|
+
flags[key] = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
positionals.push(arg);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return { flags, positionals };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function main() {
|
|
51
|
+
const argv = process.argv.slice(2);
|
|
52
|
+
if (argv.length === 0 || argv[0] === "-h" || argv[0] === "--help") {
|
|
53
|
+
printHelp(commands);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (argv[0] === "help") {
|
|
57
|
+
const target = argv[1];
|
|
58
|
+
if (target && commands.has(target)) printCommandHelp(commands.get(target)!);
|
|
59
|
+
else printHelp(commands);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const name = argv[0];
|
|
64
|
+
const cmd = commands.get(name);
|
|
65
|
+
if (!cmd) {
|
|
66
|
+
console.error(`\n Unknown command: ${name}\n`);
|
|
67
|
+
printHelp(commands);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const { flags, positionals } = parseFlags(argv.slice(1));
|
|
72
|
+
if (flags.help || flags.h) {
|
|
73
|
+
printCommandHelp(cmd);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
await cmd.action(flags, positionals);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error(error instanceof Error ? error.message : error);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
main();
|