Skip to content

Commit

Permalink
feat: add garden up command as alias for deploy --logs
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed May 8, 2023
1 parent 1d0c6e0 commit 6eb45d9
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/cli/command-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ ${chalk.white.underline("Keys:")}
})

const id = uuidv4()
const width = this.getTermWidth()
const width = this.getTermWidth() - 2

const params = {
garden: this.garden,
Expand Down Expand Up @@ -619,7 +619,7 @@ ${chalk.white.underline("Keys:")}

// Execute the command
if (!command.isDevCommand) {
const msg = `Running ${chalk.white.bold(command.getFullName())}...`
const msg = `Running command: ${chalk.white.bold(rawArgs.join(" "))}`
this.flashMessage(msg)
this.log.info({ msg: "\n" + renderDivider({ width, title: msg, color: chalk.blueBright, char: "┈" }) })
this.runningCommands[id] = { command, params }
Expand Down
2 changes: 2 additions & 0 deletions core/src/commands/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { UnlinkCommand } from "./unlink/unlink"
import { UpdateRemoteCommand } from "./update-remote/update-remote"
import { UtilCommand } from "./util/util"
import { ValidateCommand } from "./validate"
import { UpCommand } from "./up"

export const getCoreCommands = (): (Command | CommandGroup)[] => [
new BuildCommand(),
Expand Down Expand Up @@ -67,6 +68,7 @@ export const getCoreCommands = (): (Command | CommandGroup)[] => [
new TestCommand(),
new ToolsCommand(),
new UnlinkCommand(),
new UpCommand(),
new UpdateRemoteCommand(),
new UtilCommand(),
new ValidateCommand(),
Expand Down
62 changes: 62 additions & 0 deletions core/src/commands/up.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (C) 2018-2023 Garden Technologies, Inc. <[email protected]>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import chalk from "chalk"
import { Command, CommandParams, CommandResult } from "./base"
import { dedent } from "../util/string"
import { deployArgs, DeployCommand, deployOpts } from "./deploy"
import { serveOpts } from "./serve"
import { DevCommand } from "./dev"
import type { LoggerType } from "../logger/logger"

const upArgs = {
...deployArgs,
}

const upOpts = {
...deployOpts,
...serveOpts,
}

type UpArgs = typeof upArgs
type UpOpts = typeof upOpts

export class UpCommand extends Command<UpArgs, UpOpts> {
name = "up"
help = "Spin up your stack with the dev console and streaming logs."
emoji: "🚀"

description = dedent`
Spin up your stack with the dev console and streaming logs.
This is basically an alias for ${chalk.cyanBright(
"garden dev --cmd 'deploy --logs'"
)}, but you can add any arguments and flags supported by the ${chalk.cyanBright("deploy")} command as well.
`

getTerminalWriterType(): LoggerType {
return "ink"
}

async action(params: CommandParams<UpArgs, UpOpts>): Promise<CommandResult> {
let cmd: Command = new DevCommand()

if (params.commandLine) {
// We're already in the dev command
cmd = new DeployCommand()
params.opts.logs = true
} else {
params.opts.cmd = ["deploy --logs " + params.args.$all!.join(" ")]
}

cmd.printHeader(params)
await cmd.prepare(params)

return cmd.action(params)
}
}
14 changes: 14 additions & 0 deletions docs/reference/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -3686,6 +3686,20 @@ Examples:
| `--all` | | boolean | Unlink all modules.


### garden up

**Spin up your stack with the dev console and streaming logs.**

Spin up your stack with the dev console and streaming logs.

This is basically an alias for garden dev --cmd 'deploy --logs', but you can add any arguments and flags supported by the deploy command as well.

#### Usage

garden up



### garden update-remote sources

**Update remote sources.**
Expand Down

0 comments on commit 6eb45d9

Please sign in to comment.