Skip to content
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
727 changes: 238 additions & 489 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"dependencies": {
"@fastify/static": "^10.0.0",
"@inquirer/search": "^4.3.3",
"@inquirer/prompts": "^8.7.2",
"@netlify/ai": "^1.0.1",
"@netlify/api": "^15.1.2",
"@netlify/blobs": "^11.1.3",
Expand Down Expand Up @@ -108,7 +108,6 @@
"http-proxy": "^1.18.1",
"http-proxy-middleware": "^3.0.5",
"https-proxy-agent": "^8.0.0",
"inquirer": "^8.2.7",
"is-docker": "^4.0.0",
"is-stream": "^4.0.1",
"is-wsl": "^3.1.0",
Expand Down Expand Up @@ -167,7 +166,6 @@
"@types/express": "^5.0.6",
"@types/folder-walker": "^3.2.5",
"@types/gitconfiglocal": "^2.0.3",
"@types/inquirer": "^9.0.9",
"@types/jsonwebtoken": "^9.0.10",
"@types/lodash.shuffle": "^4.2.9",
"@types/multiparty": "^4.2.1",
Expand Down
58 changes: 19 additions & 39 deletions src/commands/agents/agents-create.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { OptionValues } from 'commander'
import inquirer from 'inquirer'
import { input, select } from '@inquirer/prompts'

import { chalk, logAndThrowError, log, logJson } from '../../utils/command-helpers.js'
import { startSpinner, stopSpinner } from '../../lib/spinner.js'
Expand Down Expand Up @@ -30,17 +30,10 @@ export const agentsCreate = async (promptArg: string, options: AgentCreateOption

// Interactive prompt if not provided
if (!prompt && !promptArg) {
const { promptInput } = await inquirer.prompt<{
promptInput: string
}>([
{
type: 'input',
name: 'promptInput',
message: 'What would you like the agent to do?',
validate: validatePrompt,
},
])
finalPrompt = promptInput
finalPrompt = await input({
message: 'What would you like the agent to do?',
validate: validatePrompt,
})
} else {
finalPrompt = (promptArg || prompt) ?? ''
}
Expand All @@ -52,18 +45,11 @@ export const agentsCreate = async (promptArg: string, options: AgentCreateOption

// Agent selection if not provided
if (!agent) {
const { agentInput } = await inquirer.prompt<{
agentInput: string
}>([
{
type: 'list',
name: 'agentInput',
message: 'Which agent would you like to use?',
choices: AVAILABLE_AGENTS,
default: 'claude',
},
])
agent = agentInput
agent = await select({
message: 'Which agent would you like to use?',
choices: AVAILABLE_AGENTS,
default: 'claude',
})
} else {
const agentIsValid = validateAgent(agent)
if (agentIsValid !== true) {
Expand All @@ -75,22 +61,16 @@ export const agentsCreate = async (promptArg: string, options: AgentCreateOption
if (!branch) {
const defaultBranch = siteInfo.build_settings?.repo_branch

const { branchInput } = await inquirer.prompt<{
branchInput: string
}>([
{
type: 'input',
name: 'branchInput',
message: 'Which branch would you like to work on?',
default: defaultBranch,
validate: (input: string) => {
if (!input || input.trim().length === 0) {
return 'Branch name is required'
}
return true
},
const branchInput = await input({
message: 'Which branch would you like to work on?',
default: defaultBranch,
validate: (value: string) => {
if (!value || value.trim().length === 0) {
return 'Branch name is required'
}
return true
},
])
})

branch = branchInput.trim()
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { NodeFS, NoopLogger } from '@netlify/build-info/node'
import { resolveConfig } from '@netlify/config'
import { getGlobalConfigStore, LocalState } from '@netlify/dev-utils'
import { isCI } from 'ci-info'
import search from '@inquirer/search'
import { search } from '@inquirer/prompts'
import { Command, CommanderError, Help, Option, type OptionValues } from 'commander'
import debug from 'debug'
import { findUp } from 'find-up'
Expand Down
16 changes: 5 additions & 11 deletions src/commands/clone/clone.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolve } from 'path'

import { LocalState } from '@netlify/dev-utils'
import inquirer from 'inquirer'
import { input } from '@inquirer/prompts'

import { normalizeRepoUrl } from '../../utils/normalize-repo-url.js'
import { chalk, logAndThrowError, log, getToken, netlifyCommand, type APIError } from '../../utils/command-helpers.js'
Expand All @@ -26,16 +26,10 @@ const isNetlifyGitServiceUrl = (repoUrl: string): boolean => {
}

const getTargetDir = async (defaultDir: string): Promise<string> => {
const { selectedDir } = await inquirer.prompt<{ selectedDir: string }>([
{
type: 'input',
name: 'selectedDir',
message: 'Where should we clone the repository?',
default: defaultDir,
},
])

return selectedDir
return await input({
message: 'Where should we clone the repository?',
default: defaultDir,
})
}

const cloneRepo = async (repoUrl: string, targetDir: string, debug: boolean): Promise<void> => {
Expand Down
14 changes: 5 additions & 9 deletions src/commands/completion/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs'
import { homedir } from 'os'
import { dirname, join } from 'path'
import { fileURLToPath } from 'url'
import inquirer from 'inquirer'
import { confirm } from '@inquirer/prompts'

import type { OptionValues } from 'commander'
import { install, uninstall } from '@pnpm/tabtab'
Expand Down Expand Up @@ -56,14 +56,10 @@ export const completionGenerate = async (_options: OptionValues, command: BaseCo
) {
log(`To enable Tabtab autocompletion with zsh, the following line may need to be added to your ~/.zshrc:`)
log(chalk.bold.cyan(`\n${AUTOLOAD_COMPINIT}\n`))
const { compinitAdded } = await inquirer.prompt([
{
type: 'confirm',
name: 'compinitAdded',
message: `Would you like to add it?`,
default: true,
},
])
const compinitAdded = await confirm({
message: `Would you like to add it?`,
default: true,
})
if (compinitAdded) {
fs.readFile(zshConfigFilepath, 'utf8', (_err, data) => {
const updatedZshFile = AUTOLOAD_COMPINIT + '\n' + data
Expand Down
35 changes: 12 additions & 23 deletions src/commands/create/create-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { pipeline } from 'stream/promises'
import { promisify } from 'util'

import type { OptionValues } from 'commander'
import inquirer from 'inquirer'
import fetch from 'node-fetch'

import { select } from '@inquirer/prompts'
import type { NetlifyAPI } from '@netlify/api'
import { LocalState } from '@netlify/dev-utils'

Expand Down Expand Up @@ -155,16 +155,10 @@ const selectRepoOwner = async (ghToken: string, repoOwnerFlag?: string): Promise
...orgs.map((org) => ({ name: org.login, value: org.login })),
]

const { owner } = await inquirer.prompt<{ owner: string }>([
{
type: 'list',
name: 'owner',
message: 'Where should the GitHub repo be created?',
choices,
},
])

return owner
return await select({
message: 'Where should the GitHub repo be created?',
choices,
})
}

// TODO: Replace with api client call once the site repo endpoint is added to @netlify/open-api
Expand Down Expand Up @@ -283,18 +277,13 @@ export const createAction = async (promptArg: string, options: CreateOptions, co
if (accountSlugFlag) {
accountSlug = accountSlugFlag
} else if (accounts.length > 1) {
const { accountSlug: selected } = await inquirer.prompt<{ accountSlug: string }>([
{
type: 'list',
name: 'accountSlug',
message: 'Team:',
choices: accounts.map((account) => ({
value: account.slug,
name: account.name,
})),
},
])
accountSlug = selected
accountSlug = await select({
message: 'Team:',
choices: accounts.map((account) => ({
value: account.slug,
name: account.name,
})),
})
} else {
accountSlug = accounts[0]?.slug
}
Expand Down
52 changes: 17 additions & 35 deletions src/commands/database/db-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { mkdir, readdir, writeFile } from 'fs/promises'
import { join } from 'path'

import { applyMigrations } from '@netlify/dev'
import inquirer from 'inquirer'
import { confirm, select } from '@inquirer/prompts'

import { chalk, log, netlifyCommand } from '../../utils/command-helpers.js'
import { startSpinner, stopSpinner } from '../../lib/spinner.js'
Expand Down Expand Up @@ -54,17 +54,10 @@ const success = (text: string): void => {

const carefullyWriteFile = async (filePath: string, data: string, projectRoot: string) => {
if (existsSync(filePath)) {
type Answers = {
overwrite: boolean
}
const answers = await inquirer.prompt<Answers>([
{
type: 'confirm',
name: 'overwrite',
message: `Overwrite existing file .${filePath.replace(projectRoot, '')}?`,
},
])
if (answers.overwrite) {
const overwrite = await confirm({
message: `Overwrite existing file .${filePath.replace(projectRoot, '')}?`,
})
if (overwrite) {
await writeFile(filePath, data)
}
} else {
Expand All @@ -87,20 +80,14 @@ const promptForQueryStyle = async (interactive: boolean): Promise<QueryStyle> =>
}

log('')
const { queryStyle } = await inquirer.prompt<{ queryStyle: QueryStyle }>([
{
type: 'list',
name: 'queryStyle',
message: 'What is your preferred style?',
default: 'drizzle',
choices: [
{ name: 'Drizzle ORM (recommended)', value: 'drizzle' },
{ name: 'Direct SQL', value: 'raw' },
],
},
])

return queryStyle
return await select<QueryStyle>({
message: 'What is your preferred style?',
default: 'drizzle',
choices: [
{ name: 'Drizzle ORM (recommended)', value: 'drizzle' },
{ name: 'Direct SQL', value: 'raw' },
],
})
}

const promptForStarter = async (interactive: boolean): Promise<boolean> => {
Expand All @@ -113,15 +100,10 @@ const promptForStarter = async (interactive: boolean): Promise<boolean> => {
log('and then query it. Alternatively, you can do this yourself at any time.')

log('')
const { answer } = await inquirer.prompt<{ answer: boolean }>([
{
type: 'confirm',
name: 'answer',
message: 'Do you want to create sample data?',
default: true,
},
])
return answer
return await confirm({
message: 'Do you want to create sample data?',
default: true,
})
}

const installDependencies = async (
Expand Down
36 changes: 13 additions & 23 deletions src/commands/database/db-migration-new.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readdir, mkdir, writeFile } from 'fs/promises'
import { join } from 'path'

import inquirer from 'inquirer'
import { input, select } from '@inquirer/prompts'

import { log, logJson } from '../../utils/command-helpers.js'
import BaseCommand from '../base-command.js'
Expand Down Expand Up @@ -91,15 +91,10 @@ export const migrationNew = async (options: MigrationNewOptions, command: BaseCo

if (!description) {
if (isInteractive()) {
const answers = await inquirer.prompt<{ description: string }>([
{
type: 'input',
name: 'description',
message: 'What is the purpose of this migration?',
validate: (input: string) => (input.trim().length > 0 ? true : 'Description cannot be empty'),
},
])
description = answers.description
description = await input({
message: 'What is the purpose of this migration?',
validate: (value: string) => (value.trim().length > 0 ? true : 'Description cannot be empty'),
})
} else {
throw new Error(
`--description <description> argument is required when not running interactively. Provide a description of the migration (e.g. --description "add users table").`,
Expand All @@ -111,19 +106,14 @@ export const migrationNew = async (options: MigrationNewOptions, command: BaseCo
const defaultScheme = detectedScheme ?? 'timestamp'

if (isInteractive()) {
const answers = await inquirer.prompt<{ scheme: NumberingScheme }>([
{
type: 'list',
name: 'scheme',
message: 'Numbering scheme:',
choices: [
{ name: 'Timestamp (e.g. 20260312143000) [Recommended]', value: 'timestamp' },
{ name: 'Sequential (e.g. 0001, 0002, ...)', value: 'sequential' },
],
default: defaultScheme,
},
])
scheme = answers.scheme
scheme = await select<NumberingScheme>({
message: 'Numbering scheme:',
choices: [
{ name: 'Timestamp (e.g. 20260312143000) [Recommended]', value: 'timestamp' },
{ name: 'Sequential (e.g. 0001, 0002, ...)', value: 'sequential' },
],
default: defaultScheme,
})
} else {
scheme = defaultScheme
}
Expand Down
Loading
Loading