From 9b9c7dd27e671292fe75ab6e28675ccbdd7a5996 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Fri, 22 Sep 2023 11:32:12 +0100 Subject: [PATCH] feat: added interactive check before opening feedback site --- .../src/commands/feedback/feedback-command.ts | 16 ++++++++++++---- .../src/commands/feedback/feedback.types.ts | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/composable-cli/src/commands/feedback/feedback-command.ts b/packages/composable-cli/src/commands/feedback/feedback-command.ts index 2ad593b0..5cc73eeb 100644 --- a/packages/composable-cli/src/commands/feedback/feedback-command.ts +++ b/packages/composable-cli/src/commands/feedback/feedback-command.ts @@ -1,5 +1,9 @@ import yargs from "yargs" -import { CommandContext, CommandHandlerFunction } from "../../types/command" +import { + CommandContext, + CommandHandlerFunction, + RootCommandArguments, +} from "../../types/command" import { handleErrors } from "../../util/error-handler" import { renderInk } from "../../lib/ink/render-ink" import React from "react" @@ -11,9 +15,10 @@ import { import open from "open" import { Feedback } from "../ui/feedback/feedback" import { trackCommandHandler } from "../../util/track-command-handler" +import { isTTY } from "../../util/is-tty" export function createFeedbackCommand( ctx: CommandContext -): yargs.CommandModule<{}, FeedbackCommandArguments> { +): yargs.CommandModule { return { command: "feedback", describe: "Feedback to the Composable CLI", @@ -30,8 +35,11 @@ export function createFeedbackCommandHandler( FeedbackCommandError, FeedbackCommandArguments > { - return async function feedbackCommandHandler(_args) { - await open("https://elasticpath.dev/docs") + return async function feedbackCommandHandler(args) { + if (args.interactive && isTTY()) { + await open("https://elasticpath.dev/docs") + } + await renderInk(React.createElement(Feedback)) return { success: true, diff --git a/packages/composable-cli/src/commands/feedback/feedback.types.ts b/packages/composable-cli/src/commands/feedback/feedback.types.ts index f9324f7c..48873ccc 100644 --- a/packages/composable-cli/src/commands/feedback/feedback.types.ts +++ b/packages/composable-cli/src/commands/feedback/feedback.types.ts @@ -1,4 +1,4 @@ -import { EmptyObj } from "../../types/empty-object" +import { RootCommandArguments } from "../../types/command" export type FeedbackCommandData = {} @@ -7,4 +7,4 @@ export type FeedbackCommandError = { message: string } -export type FeedbackCommandArguments = EmptyObj +export type FeedbackCommandArguments = RootCommandArguments