alepha 0.15.0 → 0.15.1
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/README.md +43 -98
- package/dist/api/audits/index.d.ts +240 -240
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/audits/index.js +2 -2
- package/dist/api/audits/index.js.map +1 -1
- package/dist/api/files/index.d.ts +185 -185
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js +2 -2
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.d.ts +245 -245
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/notifications/index.browser.js +4 -4
- package/dist/api/notifications/index.browser.js.map +1 -1
- package/dist/api/notifications/index.d.ts +74 -74
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/notifications/index.js +4 -4
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/parameters/index.d.ts +221 -221
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/users/index.d.ts +1632 -1631
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +26 -34
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts +132 -132
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/batch/index.d.ts +122 -122
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/bucket/index.d.ts +163 -163
- package/dist/bucket/index.d.ts.map +1 -1
- package/dist/cache/core/index.d.ts +46 -46
- package/dist/cache/core/index.d.ts.map +1 -1
- package/dist/cache/redis/index.d.ts.map +1 -1
- package/dist/cache/redis/index.js +2 -2
- package/dist/cache/redis/index.js.map +1 -1
- package/dist/cli/index.d.ts +5933 -201
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +609 -169
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +296 -296
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +19 -19
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +268 -79
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +768 -694
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +268 -79
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +268 -79
- package/dist/core/index.native.js.map +1 -1
- package/dist/datetime/index.d.ts +44 -44
- package/dist/datetime/index.d.ts.map +1 -1
- package/dist/email/index.d.ts +25 -25
- package/dist/email/index.d.ts.map +1 -1
- package/dist/fake/index.d.ts +5409 -5409
- package/dist/fake/index.d.ts.map +1 -1
- package/dist/fake/index.js +22 -22
- package/dist/fake/index.js.map +1 -1
- package/dist/file/index.d.ts +435 -435
- package/dist/file/index.d.ts.map +1 -1
- package/dist/lock/core/index.d.ts +208 -208
- package/dist/lock/core/index.d.ts.map +1 -1
- package/dist/lock/redis/index.d.ts.map +1 -1
- package/dist/logger/index.d.ts +24 -24
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +1 -5
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.d.ts +216 -198
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +28 -4
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/index.browser.js +9 -9
- package/dist/orm/index.browser.js.map +1 -1
- package/dist/orm/index.bun.js +83 -76
- package/dist/orm/index.bun.js.map +1 -1
- package/dist/orm/index.d.ts +961 -960
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +88 -81
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/core/index.d.ts +244 -244
- package/dist/queue/core/index.d.ts.map +1 -1
- package/dist/queue/redis/index.d.ts.map +1 -1
- package/dist/redis/index.d.ts +105 -105
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/retry/index.d.ts +69 -69
- package/dist/retry/index.d.ts.map +1 -1
- package/dist/router/index.d.ts +6 -6
- package/dist/router/index.d.ts.map +1 -1
- package/dist/scheduler/index.d.ts +108 -26
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js +393 -1
- package/dist/scheduler/index.js.map +1 -1
- package/dist/security/index.d.ts +532 -209
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +1422 -11
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +1296 -271
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +1249 -18
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cache/index.d.ts +56 -56
- package/dist/server/cache/index.d.ts.map +1 -1
- package/dist/server/compress/index.d.ts +3 -3
- package/dist/server/compress/index.d.ts.map +1 -1
- package/dist/server/cookies/index.d.ts +6 -6
- package/dist/server/cookies/index.d.ts.map +1 -1
- package/dist/server/core/index.d.ts +196 -186
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +43 -27
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/cors/index.d.ts +11 -11
- package/dist/server/cors/index.d.ts.map +1 -1
- package/dist/server/health/index.d.ts.map +1 -1
- package/dist/server/helmet/index.d.ts +2 -2
- package/dist/server/helmet/index.d.ts.map +1 -1
- package/dist/server/links/index.browser.js +9 -1
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.d.ts +83 -83
- package/dist/server/links/index.d.ts.map +1 -1
- package/dist/server/links/index.js +13 -5
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/metrics/index.d.ts +514 -1
- package/dist/server/metrics/index.d.ts.map +1 -1
- package/dist/server/metrics/index.js +4462 -4
- package/dist/server/metrics/index.js.map +1 -1
- package/dist/server/multipart/index.d.ts +6 -6
- package/dist/server/multipart/index.d.ts.map +1 -1
- package/dist/server/proxy/index.d.ts +102 -102
- package/dist/server/proxy/index.d.ts.map +1 -1
- package/dist/server/rate-limit/index.d.ts +16 -16
- package/dist/server/rate-limit/index.d.ts.map +1 -1
- package/dist/server/static/index.d.ts +44 -44
- package/dist/server/static/index.d.ts.map +1 -1
- package/dist/server/swagger/index.d.ts +47 -47
- package/dist/server/swagger/index.d.ts.map +1 -1
- package/dist/sms/index.d.ts +11 -11
- package/dist/sms/index.d.ts.map +1 -1
- package/dist/sms/index.js +3 -3
- package/dist/sms/index.js.map +1 -1
- package/dist/thread/index.d.ts +71 -71
- package/dist/thread/index.d.ts.map +1 -1
- package/dist/thread/index.js +2 -2
- package/dist/thread/index.js.map +1 -1
- package/dist/topic/core/index.d.ts +318 -318
- package/dist/topic/core/index.d.ts.map +1 -1
- package/dist/topic/redis/index.d.ts +6 -6
- package/dist/topic/redis/index.d.ts.map +1 -1
- package/dist/vite/index.d.ts +2324 -1719
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +123 -475
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js +3 -3
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.d.ts +275 -275
- package/dist/websocket/index.d.ts.map +1 -1
- package/dist/websocket/index.js +3 -3
- package/dist/websocket/index.js.map +1 -1
- package/package.json +9 -9
- package/src/api/users/services/SessionService.ts +0 -10
- package/src/cli/apps/AlephaCli.ts +2 -2
- package/src/cli/apps/AlephaPackageBuilderCli.ts +9 -1
- package/src/cli/assets/apiHelloControllerTs.ts +2 -1
- package/src/cli/assets/biomeJson.ts +2 -1
- package/src/cli/assets/claudeMd.ts +9 -4
- package/src/cli/assets/dummySpecTs.ts +2 -1
- package/src/cli/assets/editorconfig.ts +2 -1
- package/src/cli/assets/mainBrowserTs.ts +2 -1
- package/src/cli/assets/mainCss.ts +24 -0
- package/src/cli/assets/tsconfigJson.ts +2 -1
- package/src/cli/assets/webAppRouterTs.ts +2 -1
- package/src/cli/assets/webHelloComponentTsx.ts +6 -2
- package/src/cli/atoms/appEntryOptions.ts +13 -0
- package/src/cli/atoms/buildOptions.ts +1 -1
- package/src/cli/atoms/changelogOptions.ts +1 -1
- package/src/cli/commands/build.ts +63 -47
- package/src/cli/commands/dev.ts +16 -33
- package/src/cli/commands/gen/env.ts +1 -1
- package/src/cli/commands/init.ts +17 -8
- package/src/cli/commands/lint.ts +1 -1
- package/src/cli/defineConfig.ts +9 -0
- package/src/cli/index.ts +2 -1
- package/src/cli/providers/AppEntryProvider.ts +131 -0
- package/src/cli/providers/ViteBuildProvider.ts +82 -0
- package/src/cli/providers/ViteDevServerProvider.ts +350 -0
- package/src/cli/providers/ViteTemplateProvider.ts +27 -0
- package/src/cli/services/AlephaCliUtils.ts +33 -2
- package/src/cli/services/PackageManagerUtils.ts +13 -6
- package/src/cli/services/ProjectScaffolder.ts +72 -49
- package/src/core/Alepha.ts +2 -8
- package/src/core/primitives/$module.ts +12 -0
- package/src/core/providers/KeylessJsonSchemaCodec.spec.ts +257 -0
- package/src/core/providers/KeylessJsonSchemaCodec.ts +396 -14
- package/src/core/providers/SchemaValidator.spec.ts +236 -0
- package/src/logger/providers/PrettyFormatterProvider.ts +0 -9
- package/src/mcp/errors/McpError.ts +30 -0
- package/src/mcp/index.ts +3 -0
- package/src/mcp/transports/SseMcpTransport.ts +16 -6
- package/src/orm/providers/DrizzleKitProvider.ts +3 -5
- package/src/orm/services/Repository.ts +11 -0
- package/src/server/core/index.ts +1 -1
- package/src/server/core/providers/BunHttpServerProvider.ts +1 -1
- package/src/server/core/providers/NodeHttpServerProvider.spec.ts +125 -0
- package/src/server/core/providers/NodeHttpServerProvider.ts +71 -22
- package/src/server/core/providers/ServerLoggerProvider.ts +2 -2
- package/src/server/core/providers/ServerProvider.ts +9 -12
- package/src/server/links/atoms/apiLinksAtom.ts +7 -0
- package/src/server/links/index.browser.ts +2 -0
- package/src/server/links/index.ts +2 -0
- package/src/vite/index.ts +3 -2
- package/src/vite/tasks/buildClient.ts +0 -1
- package/src/vite/tasks/buildServer.ts +68 -21
- package/src/vite/tasks/copyAssets.ts +5 -4
- package/src/vite/tasks/generateSitemap.ts +64 -23
- package/src/vite/tasks/index.ts +0 -2
- package/src/vite/tasks/prerenderPages.ts +49 -24
- package/src/cli/assets/indexHtml.ts +0 -15
- package/src/cli/commands/format.ts +0 -23
- package/src/vite/helpers/boot.ts +0 -117
- package/src/vite/plugins/viteAlephaDev.ts +0 -177
- package/src/vite/tasks/devServer.ts +0 -71
- package/src/vite/tasks/runAlepha.ts +0 -270
- /package/dist/orm/{chunk-DtkW-qnP.js → chunk-DH6iiROE.js} +0 -0
package/dist/command/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as alepha1 from "alepha";
|
|
2
2
|
import { Alepha, AlephaError, Async, KIND, Primitive, Static, TObject, TSchema, TString } from "alepha";
|
|
3
3
|
import * as node_readline_promises0 from "node:readline/promises";
|
|
4
|
-
import * as
|
|
4
|
+
import * as alepha_logger2 from "alepha/logger";
|
|
5
5
|
import * as fs from "node:fs/promises";
|
|
6
6
|
import { glob } from "node:fs/promises";
|
|
7
7
|
import { DateTimeProvider, Interval } from "alepha/datetime";
|
|
@@ -14,28 +14,28 @@ declare class CommandError extends AlephaError {
|
|
|
14
14
|
//#region ../../src/command/helpers/Asker.d.ts
|
|
15
15
|
interface AskOptions<T extends TSchema = TString> {
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
* Response schema expected.
|
|
18
|
+
*
|
|
19
|
+
* Recommended schemas:
|
|
20
|
+
* - t.text() - for free text input
|
|
21
|
+
* - t.number() - for numeric input
|
|
22
|
+
* - t.boolean() - for yes/no input (accepts "true", "false", "1", "0")
|
|
23
|
+
* - t.enum(["option1", "option2"]) - for predefined options
|
|
24
|
+
*
|
|
25
|
+
* You can use schema.default to provide a default value.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* ask("What is your name?", { schema: t.text({ default: "John Doe" }) })
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @default TString
|
|
33
|
+
*/
|
|
34
34
|
schema?: T;
|
|
35
35
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
* Custom validation function.
|
|
37
|
+
* Throws an AlephaError in case of validation failure.
|
|
38
|
+
*/
|
|
39
39
|
validate?: (value: Static<T>) => void;
|
|
40
40
|
}
|
|
41
41
|
interface AskMethod {
|
|
@@ -43,7 +43,7 @@ interface AskMethod {
|
|
|
43
43
|
permission: (question: string) => Promise<boolean>;
|
|
44
44
|
}
|
|
45
45
|
declare class Asker {
|
|
46
|
-
protected readonly log:
|
|
46
|
+
protected readonly log: alepha_logger2.Logger;
|
|
47
47
|
readonly ask: AskMethod;
|
|
48
48
|
protected readonly alepha: Alepha;
|
|
49
49
|
constructor();
|
|
@@ -54,12 +54,12 @@ declare class Asker {
|
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region ../../src/command/helpers/EnvUtils.d.ts
|
|
56
56
|
declare class EnvUtils {
|
|
57
|
-
protected readonly log:
|
|
57
|
+
protected readonly log: alepha_logger2.Logger;
|
|
58
58
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
* Load environment variables from .env files into process.env.
|
|
60
|
+
* By default, it loads from ".env" and ".env.local".
|
|
61
|
+
* You can specify additional files to load, e.g. [".env", ".env.production"].
|
|
62
|
+
*/
|
|
63
63
|
loadEnv(root: string, files?: string[]): Promise<void>;
|
|
64
64
|
}
|
|
65
65
|
//#endregion
|
|
@@ -85,40 +85,40 @@ declare class PrettyPrint {
|
|
|
85
85
|
dim: string;
|
|
86
86
|
};
|
|
87
87
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
* Start a new command session with header
|
|
89
|
+
*/
|
|
90
90
|
startCommand(cliName: string, commandName: string): void;
|
|
91
91
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
* End the command session with footer
|
|
93
|
+
*/
|
|
94
94
|
endCommand(): void;
|
|
95
95
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
* Start an animated spinner with a task name
|
|
97
|
+
*/
|
|
98
98
|
startSpinner(id: string, taskName: string): void;
|
|
99
99
|
/**
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
* Stop the spinner and show success with a tick
|
|
101
|
+
*/
|
|
102
102
|
success(id: string, taskName?: string, duration?: string): void;
|
|
103
103
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
* Stop the spinner and show error with a cross
|
|
105
|
+
*/
|
|
106
106
|
error(id: string, taskName?: string): void;
|
|
107
107
|
/**
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
* Update the display for all tasks
|
|
109
|
+
*/
|
|
110
110
|
protected updateDisplay(): void;
|
|
111
111
|
/**
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
* Check if all tasks are done and stop the interval
|
|
113
|
+
*/
|
|
114
114
|
protected checkIfAllDone(): void;
|
|
115
115
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
* Stop the spinner without showing any symbol
|
|
117
|
+
*/
|
|
118
118
|
stopSpinner(): void;
|
|
119
119
|
/**
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
* Clear all tasks
|
|
121
|
+
*/
|
|
122
122
|
clear(): void;
|
|
123
123
|
}
|
|
124
124
|
//#endregion
|
|
@@ -133,12 +133,12 @@ interface Timer {
|
|
|
133
133
|
}
|
|
134
134
|
interface RunOptions {
|
|
135
135
|
/**
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
* Rename the command for logging purposes.
|
|
137
|
+
*/
|
|
138
138
|
alias?: string;
|
|
139
139
|
/**
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
* Root directory to execute the command in.
|
|
141
|
+
*/
|
|
142
142
|
root?: string;
|
|
143
143
|
}
|
|
144
144
|
interface RunnerMethod {
|
|
@@ -147,7 +147,7 @@ interface RunnerMethod {
|
|
|
147
147
|
cp: (source: string, dest: string, options?: RunOptions) => Promise<string>;
|
|
148
148
|
}
|
|
149
149
|
declare class Runner {
|
|
150
|
-
protected readonly log:
|
|
150
|
+
protected readonly log: alepha_logger2.Logger;
|
|
151
151
|
protected readonly timers: Timer[];
|
|
152
152
|
protected readonly startTime: number;
|
|
153
153
|
protected readonly prettyPrint: PrettyPrint;
|
|
@@ -159,22 +159,22 @@ declare class Runner {
|
|
|
159
159
|
constructor();
|
|
160
160
|
protected get useDynamicLogger(): boolean;
|
|
161
161
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
* Start a new command session with header (for pretty print mode)
|
|
163
|
+
*/
|
|
164
164
|
startCommand(cliName: string, commandName: string): void;
|
|
165
165
|
protected createRunMethod(): RunnerMethod;
|
|
166
166
|
protected exec(cmd: string, opts?: {
|
|
167
167
|
root?: string;
|
|
168
168
|
}): Promise<string>;
|
|
169
169
|
/**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
* Executes one or more tasks.
|
|
171
|
+
*
|
|
172
|
+
* @param task - A single task or an array of tasks to run in parallel.
|
|
173
|
+
*/
|
|
174
174
|
protected execute(task: Task | Task[]): Promise<string>;
|
|
175
175
|
/**
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
* Prints a summary of all executed tasks and their durations.
|
|
177
|
+
*/
|
|
178
178
|
end(): void;
|
|
179
179
|
protected executeTask(task: Task): Promise<string>;
|
|
180
180
|
protected renderTable(data: string[][]): void;
|
|
@@ -193,203 +193,203 @@ declare const $command: {
|
|
|
193
193
|
};
|
|
194
194
|
interface CommandPrimitiveOptions<T extends TObject, A extends TSchema, E extends TObject = TObject> {
|
|
195
195
|
/**
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
196
|
+
* The handler function to execute when the command is matched.
|
|
197
|
+
*
|
|
198
|
+
* For parent commands with children, the handler is called when:
|
|
199
|
+
* - The parent command is invoked without a subcommand
|
|
200
|
+
* - The parent command is invoked with --help (to show available subcommands)
|
|
201
|
+
*/
|
|
202
202
|
handler: (args: CommandHandlerArgs<T, A, E>) => Async<void>;
|
|
203
203
|
/**
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
204
|
+
* The name of the command. If omitted, the property key is used.
|
|
205
|
+
*
|
|
206
|
+
* An empty string "" denotes the root command.
|
|
207
|
+
*/
|
|
208
208
|
name?: string;
|
|
209
209
|
/**
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
* A short description of the command, shown in the help message.
|
|
211
|
+
*/
|
|
212
212
|
description?: string;
|
|
213
213
|
/**
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
* An array of alternative names for the command.
|
|
215
|
+
*/
|
|
216
216
|
aliases?: string[];
|
|
217
217
|
/**
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
* A TypeBox object schema defining the flags for the command.
|
|
219
|
+
*/
|
|
220
220
|
flags?: T;
|
|
221
221
|
/**
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
222
|
+
* A TypeBox object schema defining required environment variables.
|
|
223
|
+
*
|
|
224
|
+
* Environment variables are validated before the handler runs (fail fast).
|
|
225
|
+
* They are displayed in the help output under "Env:" section.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```ts
|
|
229
|
+
* $command({
|
|
230
|
+
* env: t.object({
|
|
231
|
+
* VERCEL_TOKEN: t.text({ description: "Vercel API token" }),
|
|
232
|
+
* VERCEL_ORG_ID: t.optional(t.text({ description: "Organization ID" })),
|
|
233
|
+
* }),
|
|
234
|
+
* handler: async ({ env }) => {
|
|
235
|
+
* // env.VERCEL_TOKEN is typed & guaranteed to exist
|
|
236
|
+
* console.log(env.VERCEL_TOKEN);
|
|
237
|
+
* }
|
|
238
|
+
* })
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
241
|
env?: E;
|
|
242
242
|
/**
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
243
|
+
* An optional TypeBox schema defining the arguments for the command.
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* args: t.text()
|
|
247
|
+
* my-cli command <arg1: string>
|
|
248
|
+
*
|
|
249
|
+
* args: t.optional(t.text())
|
|
250
|
+
* my-cli command [arg1: string]
|
|
251
|
+
*
|
|
252
|
+
* args: t.tuple([t.text(), t.number()])
|
|
253
|
+
* my-cli command <arg1: string> <arg2: number>
|
|
254
|
+
*
|
|
255
|
+
* args: t.tuple([t.text(), t.optional(t.number())])
|
|
256
|
+
* my-cli command <arg1: string> [arg2: number]
|
|
257
|
+
*/
|
|
258
258
|
args?: A;
|
|
259
259
|
/**
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
260
|
+
* Marks this command as the root command.
|
|
261
|
+
* Equivalent to setting name to an empty string "".
|
|
262
|
+
*/
|
|
263
263
|
root?: boolean;
|
|
264
264
|
/**
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
265
|
+
* Run this command's handler BEFORE the specified target command.
|
|
266
|
+
*
|
|
267
|
+
* Pre-hooks are not listed in help and cannot be called directly.
|
|
268
|
+
* They receive the same parsed flags and args as the target command.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* class BuildCommands {
|
|
273
|
+
* prebuild = $command({
|
|
274
|
+
* pre: "build",
|
|
275
|
+
* handler: async ({ run }) => {
|
|
276
|
+
* await run("cleaning dist folder...", () => fs.rm("dist"));
|
|
277
|
+
* }
|
|
278
|
+
* });
|
|
279
|
+
*
|
|
280
|
+
* build = $command({
|
|
281
|
+
* name: "build",
|
|
282
|
+
* handler: async () => { ... }
|
|
283
|
+
* });
|
|
284
|
+
* }
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
287
|
pre?: string;
|
|
288
288
|
/**
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
289
|
+
* Run this command's handler AFTER the specified target command.
|
|
290
|
+
*
|
|
291
|
+
* Post-hooks are not listed in help and cannot be called directly.
|
|
292
|
+
* They receive the same parsed flags and args as the target command.
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```ts
|
|
296
|
+
* class BuildCommands {
|
|
297
|
+
* build = $command({
|
|
298
|
+
* name: "build",
|
|
299
|
+
* handler: async () => { ... }
|
|
300
|
+
* });
|
|
301
|
+
*
|
|
302
|
+
* postbuild = $command({
|
|
303
|
+
* post: "build",
|
|
304
|
+
* handler: async ({ run }) => {
|
|
305
|
+
* await run("generating checksums...", generateChecksums);
|
|
306
|
+
* }
|
|
307
|
+
* });
|
|
308
|
+
* }
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
311
|
post?: string;
|
|
312
312
|
/**
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
* If true, this command will be hidden from the help output.
|
|
314
|
+
*/
|
|
315
315
|
hide?: boolean;
|
|
316
316
|
/**
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
317
|
+
* Adds a `--mode, -m` flag to load environment files.
|
|
318
|
+
*
|
|
319
|
+
* When enabled:
|
|
320
|
+
* - Loads `.env` and `.env.local` by default
|
|
321
|
+
* - With `--mode production`, also loads `.env.production` and `.env.production.local`
|
|
322
|
+
* - The mode value is exposed in the handler as `mode: string | undefined`
|
|
323
|
+
*
|
|
324
|
+
* Set to `true` to enable with no default, or a string to set a default mode.
|
|
325
|
+
*
|
|
326
|
+
* This follows Vite's environment loading convention.
|
|
327
|
+
* @see https://vite.dev/guide/env-and-mode
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```ts
|
|
331
|
+
* // No default mode
|
|
332
|
+
* build = $command({
|
|
333
|
+
* mode: true,
|
|
334
|
+
* handler: async ({ mode }) => {
|
|
335
|
+
* console.log(`Building for ${mode ?? 'development'}...`);
|
|
336
|
+
* }
|
|
337
|
+
* });
|
|
338
|
+
*
|
|
339
|
+
* // Default mode "production"
|
|
340
|
+
* deploy = $command({
|
|
341
|
+
* mode: "production",
|
|
342
|
+
* handler: async ({ mode }) => {
|
|
343
|
+
* console.log(`Deploying for ${mode}...`); // always defined
|
|
344
|
+
* }
|
|
345
|
+
* });
|
|
346
|
+
* ```
|
|
347
|
+
*
|
|
348
|
+
* Usage:
|
|
349
|
+
* - `cli build` - loads .env (mode = undefined)
|
|
350
|
+
* - `cli build --mode production` - loads .env and .env.production
|
|
351
|
+
* - `cli deploy` - loads .env and .env.production (default mode)
|
|
352
|
+
* - `cli deploy --mode staging` - loads .env and .env.staging
|
|
353
|
+
*/
|
|
354
354
|
mode?: boolean | string;
|
|
355
355
|
/**
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
356
|
+
* Child commands (subcommands) for this command.
|
|
357
|
+
*
|
|
358
|
+
* When children are defined, the command becomes a parent command that
|
|
359
|
+
* can be invoked with space-separated subcommands:
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```ts
|
|
363
|
+
* class DeployCommands {
|
|
364
|
+
* // Subcommands
|
|
365
|
+
* vercel = $command({
|
|
366
|
+
* description: "Deploy to Vercel",
|
|
367
|
+
* handler: async () => { ... }
|
|
368
|
+
* });
|
|
369
|
+
*
|
|
370
|
+
* cloudflare = $command({
|
|
371
|
+
* description: "Deploy to Cloudflare",
|
|
372
|
+
* handler: async () => { ... }
|
|
373
|
+
* });
|
|
374
|
+
*
|
|
375
|
+
* // Parent command with children
|
|
376
|
+
* deploy = $command({
|
|
377
|
+
* description: "Deploy the application",
|
|
378
|
+
* children: [this.vercel, this.cloudflare],
|
|
379
|
+
* handler: async () => {
|
|
380
|
+
* // Called when "deploy" is invoked without subcommand
|
|
381
|
+
* console.log("Available: deploy vercel, deploy cloudflare");
|
|
382
|
+
* }
|
|
383
|
+
* });
|
|
384
|
+
* }
|
|
385
|
+
* ```
|
|
386
|
+
*
|
|
387
|
+
* This allows CLI usage like:
|
|
388
|
+
* - `cli deploy vercel` - runs the vercel subcommand
|
|
389
|
+
* - `cli deploy cloudflare` - runs the cloudflare subcommand
|
|
390
|
+
* - `cli deploy` - runs the parent handler (shows available subcommands)
|
|
391
|
+
* - `cli deploy --help` - shows help with all available subcommands
|
|
392
|
+
*/
|
|
393
393
|
children?: CommandPrimitive<any, any>[];
|
|
394
394
|
}
|
|
395
395
|
declare class CommandPrimitive<T extends TObject = TObject, A extends TSchema = TSchema, E extends TObject = TObject> extends Primitive<CommandPrimitiveOptions<T, A, E>> {
|
|
@@ -399,16 +399,16 @@ declare class CommandPrimitive<T extends TObject = TObject, A extends TSchema =
|
|
|
399
399
|
protected onInit(): void;
|
|
400
400
|
get name(): string;
|
|
401
401
|
/**
|
|
402
|
-
|
|
403
|
-
|
|
402
|
+
* Get the child commands (subcommands) for this command.
|
|
403
|
+
*/
|
|
404
404
|
get children(): CommandPrimitive<any, any>[];
|
|
405
405
|
/**
|
|
406
|
-
|
|
407
|
-
|
|
406
|
+
* Check if this command has child commands (is a parent command).
|
|
407
|
+
*/
|
|
408
408
|
get hasChildren(): boolean;
|
|
409
409
|
/**
|
|
410
|
-
|
|
411
|
-
|
|
410
|
+
* Find a child command by name or alias.
|
|
411
|
+
*/
|
|
412
412
|
findChild(name: string): CommandPrimitive<any, any> | undefined;
|
|
413
413
|
}
|
|
414
414
|
interface CommandHandlerArgs<T extends TObject, A extends TSchema = TSchema, E extends TObject = TObject> {
|
|
@@ -420,31 +420,31 @@ interface CommandHandlerArgs<T extends TObject, A extends TSchema = TSchema, E e
|
|
|
420
420
|
glob: typeof glob;
|
|
421
421
|
fs: typeof fs;
|
|
422
422
|
/**
|
|
423
|
-
|
|
424
|
-
|
|
423
|
+
* The root directory where the command is executed.
|
|
424
|
+
*/
|
|
425
425
|
root: string;
|
|
426
426
|
/**
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
427
|
+
* Display help for the current command.
|
|
428
|
+
*
|
|
429
|
+
* Useful for parent commands with children to show available subcommands
|
|
430
|
+
* when invoked without a specific subcommand.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```ts
|
|
434
|
+
* deploy = $command({
|
|
435
|
+
* children: [this.vercel, this.cloudflare],
|
|
436
|
+
* handler: async ({ help }) => {
|
|
437
|
+
* help(); // Shows available subcommands
|
|
438
|
+
* }
|
|
439
|
+
* });
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
442
442
|
help: () => void;
|
|
443
443
|
/**
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
444
|
+
* The current execution mode (e.g., "development", "production", "staging").
|
|
445
|
+
*
|
|
446
|
+
* Use --mode flag to set this value when running the command.
|
|
447
|
+
*/
|
|
448
448
|
mode?: string;
|
|
449
449
|
}
|
|
450
450
|
//#endregion
|
|
@@ -511,7 +511,7 @@ declare class CliProvider {
|
|
|
511
511
|
CLI_DESCRIPTION: string;
|
|
512
512
|
};
|
|
513
513
|
protected readonly alepha: Alepha;
|
|
514
|
-
protected readonly log:
|
|
514
|
+
protected readonly log: alepha_logger2.Logger;
|
|
515
515
|
protected readonly color: ConsoleColorProvider;
|
|
516
516
|
protected readonly runner: Runner;
|
|
517
517
|
protected readonly asker: Asker;
|
|
@@ -533,21 +533,21 @@ declare class CliProvider {
|
|
|
533
533
|
};
|
|
534
534
|
protected readonly onReady: alepha1.HookPrimitive<"ready">;
|
|
535
535
|
/**
|
|
536
|
-
|
|
537
|
-
|
|
536
|
+
* Execute a command with the given argv.
|
|
537
|
+
*/
|
|
538
538
|
protected executeCommand(command: CommandPrimitive<TObject>, argv: string[], isRootCommand: boolean): Promise<void>;
|
|
539
539
|
/**
|
|
540
|
-
|
|
541
|
-
|
|
540
|
+
* Remove consumed command path arguments from argv.
|
|
541
|
+
*/
|
|
542
542
|
protected removeConsumedArgs(argv: string[], consumedArgs: string[]): string[];
|
|
543
543
|
/**
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
544
|
+
* Resolve a command from positional arguments.
|
|
545
|
+
*
|
|
546
|
+
* Supports:
|
|
547
|
+
* 1. Space-separated subcommands: `deploy vercel` -> finds deploy command, then vercel child
|
|
548
|
+
* 2. Colon notation (backwards compat): `deploy:vercel` -> finds command with name "deploy:vercel"
|
|
549
|
+
* 3. Simple commands: `build` -> finds command with name "build"
|
|
550
|
+
*/
|
|
551
551
|
protected resolveCommand(positionalArgs: string[]): {
|
|
552
552
|
command: CommandPrimitive<TObject> | undefined;
|
|
553
553
|
consumedArgs: string[];
|
|
@@ -555,16 +555,16 @@ declare class CliProvider {
|
|
|
555
555
|
get commands(): CommandPrimitive<any>[];
|
|
556
556
|
protected findCommand(name: string): CommandPrimitive<TObject> | undefined;
|
|
557
557
|
/**
|
|
558
|
-
|
|
559
|
-
|
|
558
|
+
* Find all pre-hooks for a command.
|
|
559
|
+
*/
|
|
560
560
|
protected findPreHooks(commandName: string): CommandPrimitive<TObject>[];
|
|
561
561
|
/**
|
|
562
|
-
|
|
563
|
-
|
|
562
|
+
* Find all post-hooks for a command.
|
|
563
|
+
*/
|
|
564
564
|
protected findPostHooks(commandName: string): CommandPrimitive<TObject>[];
|
|
565
565
|
/**
|
|
566
|
-
|
|
567
|
-
|
|
566
|
+
* Get global flags (help only, root command flags are NOT global).
|
|
567
|
+
*/
|
|
568
568
|
protected getAllGlobalFlags(): Record<string, {
|
|
569
569
|
aliases: string[];
|
|
570
570
|
description?: string;
|
|
@@ -573,12 +573,12 @@ declare class CliProvider {
|
|
|
573
573
|
protected parseCommandFlags(argv: string[], schema: TObject): Record<string, any>;
|
|
574
574
|
protected parseCommandEnv(schema: TObject, commandName: string): Record<string, any>;
|
|
575
575
|
/**
|
|
576
|
-
|
|
577
|
-
|
|
576
|
+
* Parse --mode or -m flag from argv.
|
|
577
|
+
*/
|
|
578
578
|
protected parseModeFlag(argv: string[]): string | undefined;
|
|
579
579
|
/**
|
|
580
|
-
|
|
581
|
-
|
|
580
|
+
* Load environment files based on mode.
|
|
581
|
+
*/
|
|
582
582
|
protected loadModeEnv(root: string, mode: string | undefined): Promise<void>;
|
|
583
583
|
protected parseFlags(argv: string[], flagDefs: {
|
|
584
584
|
key: string;
|
|
@@ -586,8 +586,8 @@ declare class CliProvider {
|
|
|
586
586
|
schema: TSchema;
|
|
587
587
|
}[]): Record<string, any>;
|
|
588
588
|
/**
|
|
589
|
-
|
|
590
|
-
|
|
589
|
+
* Get indices of argv elements that are consumed by flags (including space-separated values).
|
|
590
|
+
*/
|
|
591
591
|
protected getFlagConsumedIndices(argv: string[], flagDefs: {
|
|
592
592
|
key: string;
|
|
593
593
|
aliases: string[];
|
|
@@ -599,24 +599,24 @@ declare class CliProvider {
|
|
|
599
599
|
protected getTypeName(schema: TSchema): string;
|
|
600
600
|
printHelp(command?: CommandPrimitive<any>): void;
|
|
601
601
|
/**
|
|
602
|
-
|
|
603
|
-
|
|
602
|
+
* Generate colored args usage string for help display.
|
|
603
|
+
*/
|
|
604
604
|
protected generateColoredArgsUsage(schema?: TSchema): string;
|
|
605
605
|
/**
|
|
606
|
-
|
|
607
|
-
|
|
606
|
+
* Get the full command path (e.g., "deploy vercel" for a child command).
|
|
607
|
+
*/
|
|
608
608
|
protected getCommandPath(command: CommandPrimitive<any>): string;
|
|
609
609
|
/**
|
|
610
|
-
|
|
611
|
-
|
|
610
|
+
* Find the parent command of a given command.
|
|
611
|
+
*/
|
|
612
612
|
protected findParentCommand(command: CommandPrimitive<any>): CommandPrimitive<any> | undefined;
|
|
613
613
|
/**
|
|
614
|
-
|
|
615
|
-
|
|
614
|
+
* Get top-level commands (commands that are not children of other commands).
|
|
615
|
+
*/
|
|
616
616
|
protected getTopLevelCommands(): CommandPrimitive<any>[];
|
|
617
617
|
/**
|
|
618
|
-
|
|
619
|
-
|
|
618
|
+
* Get max length for child command display.
|
|
619
|
+
*/
|
|
620
620
|
protected getMaxChildCmdLength(children: CommandPrimitive<any>[]): number;
|
|
621
621
|
protected getMaxCmdLength(commands: CommandPrimitive[]): number;
|
|
622
622
|
private getMaxFlagLength;
|
|
@@ -636,10 +636,10 @@ declare const AlephaCommand: alepha1.Service<alepha1.Module>;
|
|
|
636
636
|
declare module "typebox" {
|
|
637
637
|
interface StringOptions {
|
|
638
638
|
/**
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
639
|
+
* Additional aliases for the flags.
|
|
640
|
+
*
|
|
641
|
+
* @module alepha.command
|
|
642
|
+
*/
|
|
643
643
|
aliases?: string[];
|
|
644
644
|
}
|
|
645
645
|
} //# sourceMappingURL=index.d.ts.map
|