Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dev): fix custom commands not working in dev console #6341

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core/src/cli/command-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { bindActiveContext, withSessionContext } from "../util/open-telemetry/co
import { wrapActiveSpan } from "../util/open-telemetry/spans.js"
import { DEFAULT_BROWSER_DIVIDER_WIDTH } from "../constants.js"
import { styles } from "../logger/styles.js"
import type { GardenCli } from "./cli.js"

const defaultMessageDuration = 3000
const commandLinePrefix = styles.warning("🌼 > ")
Expand Down Expand Up @@ -153,11 +154,14 @@ export class CommandLine extends TypedEventEmitter<CommandLineEvents> {
private globalConfigStore: GlobalConfigStore
private readonly log: Log
private readonly globalOpts: Partial<ParameterValues<GlobalOptions>>
// TODO: Make this required (doing this will unfortunately involve fixing hundreds of unit tests)
private readonly cli: GardenCli | undefined

constructor({
cwd,
manager,
log,
cli,
globalOpts,
serveCommand,
extraCommands,
Expand All @@ -166,6 +170,7 @@ export class CommandLine extends TypedEventEmitter<CommandLineEvents> {
cwd: string
manager: GardenInstanceManager
log: Log
cli: GardenCli | undefined
globalOpts: Partial<ParameterValues<GlobalOptions>>
serveCommand: ServeCommand
extraCommands: Command[]
Expand All @@ -178,6 +183,7 @@ export class CommandLine extends TypedEventEmitter<CommandLineEvents> {
this.cwd = cwd
this.manager = manager
this.log = log
this.cli = cli
this.globalOpts = globalOpts
this.extraCommands = extraCommands
this.serveCommand = serveCommand
Expand Down Expand Up @@ -778,6 +784,7 @@ ${styles.accent.underline("Keys:")}
.run({
...prepareParams,
garden,
cli: this.cli,
sessionId,
parentSessionId: this.manager.sessionId,
})
Expand Down
3 changes: 2 additions & 1 deletion core/src/commands/dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ Use ${styles.bold("up/down")} arrow keys to scroll through your command history.
}

private async initCommandHandler(params: ActionParams) {
const { garden, log, opts } = params
const { garden, log, opts, cli } = params

// override the session for this manager to ensure we inherit from
// the initial garden dummy instance
Expand All @@ -209,6 +209,7 @@ Use ${styles.bold("up/down")} arrow keys to scroll through your command history.
extraCommands: [new HelpCommand(), new QuitCommand(quit), new QuietCommand(), new QuiteCommand()],
globalOpts: pick(opts, Object.keys(globalOptions)),
history: await garden.localConfigStore.get("devCommandHistory"),
cli,
serveCommand: this,
})
this.commandLine = cl
Expand Down