@strav/cli 1.0.0-alpha.42 → 1.0.0-alpha.43
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 +2 -2
- package/src/run_cli.ts +15 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strav/cli",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.43",
|
|
4
4
|
"description": "Strav CLI layer — Command base, signature parser, ConsoleProvider, interactive prompts on top of @strav/kernel's ConsoleKernel",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@strav/kernel": "1.0.0-alpha.
|
|
22
|
+
"@strav/kernel": "1.0.0-alpha.43"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@types/bun": ">=1.3.14"
|
package/src/run_cli.ts
CHANGED
|
@@ -29,7 +29,9 @@ import {
|
|
|
29
29
|
ConsoleKernel,
|
|
30
30
|
type ConsoleOutputOptions,
|
|
31
31
|
parseArgv,
|
|
32
|
+
resolveProviders,
|
|
32
33
|
type ServiceProvider,
|
|
34
|
+
type ServiceProviderEntry,
|
|
33
35
|
} from '@strav/kernel'
|
|
34
36
|
import type { CliCommandClass } from './command.ts'
|
|
35
37
|
import { collectCommands } from './console_provider.ts'
|
|
@@ -37,8 +39,13 @@ import { selectProviders } from './subset_boot.ts'
|
|
|
37
39
|
|
|
38
40
|
export interface RunCliOptions {
|
|
39
41
|
argv: readonly string[]
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Full default provider list — typically from `bootstrap/providers.ts`.
|
|
44
|
+
* Accepts the same entry forms as `Application.useProviders`: instances,
|
|
45
|
+
* zero-arg constructors, and closures. Entries are resolved once, up front,
|
|
46
|
+
* so command collection and subset-boot can read provider metadata.
|
|
47
|
+
*/
|
|
48
|
+
defaultProviders: readonly ServiceProviderEntry[]
|
|
42
49
|
/**
|
|
43
50
|
* Explicit command list. Optional — when omitted, commands are collected
|
|
44
51
|
* from every `ConsoleProvider` subclass in `defaultProviders`.
|
|
@@ -52,7 +59,11 @@ export interface RunCliOptions {
|
|
|
52
59
|
}
|
|
53
60
|
|
|
54
61
|
export async function runCli(options: RunCliOptions): Promise<number> {
|
|
55
|
-
|
|
62
|
+
// Resolve provider entries (constructors / closures) to instances once, up
|
|
63
|
+
// front — `collectCommands` and `selectProviders` read instance metadata
|
|
64
|
+
// (`commands`, `name`, `dependencies`) that bare entries don't expose.
|
|
65
|
+
const defaultProviders = await resolveProviders(options.defaultProviders)
|
|
66
|
+
const commands = options.commands ?? collectCommands(defaultProviders)
|
|
56
67
|
assertUniqueCommands(commands)
|
|
57
68
|
const byName = indexByName(commands)
|
|
58
69
|
const { command: commandName } = parseArgv(options.argv)
|
|
@@ -71,7 +82,7 @@ export async function runCli(options: RunCliOptions): Promise<number> {
|
|
|
71
82
|
} else {
|
|
72
83
|
const Class = byName.get(commandName)
|
|
73
84
|
const requested = (Class as { providers?: readonly string[] } | undefined)?.providers
|
|
74
|
-
providers = selectProviders(
|
|
85
|
+
providers = selectProviders(defaultProviders, requested, commandName)
|
|
75
86
|
}
|
|
76
87
|
|
|
77
88
|
// ─── delegate to kernel's ConsoleKernel.run ────────────────────────────────
|