Skip to content

Commit

Permalink
chore: remove last deprecated inquirerer usage
Browse files Browse the repository at this point in the history
  • Loading branch information
karl-run committed Dec 18, 2024
1 parent f4fbc79 commit 9ea8aaa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 33 deletions.
32 changes: 12 additions & 20 deletions src/actions/sync-cmd/sync-cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import chalk from 'chalk'
import * as R from 'remeda'
import { $ } from 'bun'
import { PushResult } from 'simple-git'
import { checkbox, confirm, input } from '@inquirer/prompts'

import { getAllRepos } from '../../common/repos.ts'
import { getTeam } from '../../common/config.ts'
import { Gitter } from '../../common/git.ts'
import { BaseRepoNode } from '../../common/octokit.ts'
import { log } from '../../common/log.ts'
import { GIT_CACHE_DIR } from '../../common/cache.ts'
import inquirer from '../../common/inquirer.ts'

export async function syncCmd(query: string | undefined, cmd: string | undefined, force: boolean): Promise<void> {
if (query == null) {
Expand Down Expand Up @@ -71,9 +71,7 @@ async function updateGitterCache(repos: BaseRepoNode<unknown>[]): Promise<void>
}

async function getTargetRepos<Repo extends { name: string }>(otherRepos: Repo[]): Promise<Repo[]> {
const checkboxResponse = await inquirer.prompt<{ target: string[] }>({
type: 'checkbox',
name: 'target',
const checkboxResponse = await checkbox({
message: 'Select repos to run commands in',
choices: [
{ value: 'all', name: 'All repos' },
Expand All @@ -84,10 +82,10 @@ async function getTargetRepos<Repo extends { name: string }>(otherRepos: Repo[])
],
})

if (checkboxResponse.target.includes('all')) {
if (checkboxResponse.includes('all')) {
return otherRepos
} else if (checkboxResponse.target.length !== 0) {
return otherRepos.filter((it) => checkboxResponse.target.includes(it.name))
} else if (checkboxResponse.length !== 0) {
return otherRepos.filter((it) => checkboxResponse.includes(it.name))
} else {
log(chalk.red('You must select at least one repo'))
return getTargetRepos(otherRepos)
Expand Down Expand Up @@ -156,14 +154,12 @@ async function runCommand(
}

const confirmResult = force
? { confirm: true }
: await inquirer.prompt({
name: 'confirm',
type: 'confirm',
? true
: await confirm({
message: `Do you want to stage these changes?`,
})

if (confirmResult.confirm) {
if (confirmResult) {
if (otherRepos.length === 0) {
return [[repo.name, 'staged']]
} else {
Expand All @@ -179,17 +175,13 @@ async function runCommand(
}

async function finalCheckAndCommitPush(stagedRepos: BaseRepoNode<unknown>[]): Promise<void> {
const confirmResult = await inquirer.prompt({
name: 'confirm',
type: 'confirm',
const confirmResult = await confirm({
message: `Do you want to commit and push these changes?`,
})

if (confirmResult.confirm) {
if (confirmResult) {
const gitter = new Gitter('cache')
const commitMessage = await inquirer.prompt<{ message: string }>({
type: 'input',
name: 'message',
const commitMessage = await input({
message: `Enter commit message:`,
})

Expand All @@ -199,7 +191,7 @@ async function finalCheckAndCommitPush(stagedRepos: BaseRepoNode<unknown>[]): Pr
const pushResult: PushResult = await gitter
.createRepoGitClient(it.name)
.add('.')
.commit(commitMessage.message)
.commit(commitMessage)
.push()

log(`${chalk.green(`Pushed to repo ${pushResult.repo}`)} - ${it.url}`)
Expand Down
2 changes: 0 additions & 2 deletions src/actions/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as R from 'remeda'
import chalk from 'chalk'
import { search } from '@inquirer/prompts'

import { hackilyFixBackToBackPrompt } from '../common/inquirer.ts'
import { log } from '../common/log.ts'
import { openUrl } from '../common/open-url.ts'

Expand Down Expand Up @@ -127,7 +126,6 @@ async function openAppOrPage(appOrPage: string): Promise<void> {
return
}

await hackilyFixBackToBackPrompt()
const selectedEnv = await getAppEnv(cleanItem)

await openApp(cleanItem, selectedEnv)
Expand Down
11 changes: 0 additions & 11 deletions src/common/inquirer.ts

This file was deleted.

0 comments on commit 9ea8aaa

Please sign in to comment.