Skip to content

Commit 998bc03

Browse files
committed
feat: add non-interactive, preset and token-setup opts
1 parent 7657e63 commit 998bc03

File tree

2 files changed

+216
-107
lines changed

2 files changed

+216
-107
lines changed

bin/cli.ts

Lines changed: 89 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,14 @@ interface CLIOptions {
8787
cli
8888
.command('setup', '🚀 Interactive setup for automated dependency updates (recommended)')
8989
.option('--verbose, -v', 'Enable verbose logging')
90+
.option('--non-interactive', 'Run setup without prompts (use defaults)')
91+
.option('--preset <type>', 'Workflow preset: standard|high-frequency|security|minimal|testing', { default: 'standard' })
92+
.option('--token-setup <type>', 'Token setup: existing-secret|new-pat|default-token', { default: 'default-token' })
9093
.example('buddy-bot setup')
9194
.example('buddy-bot setup --verbose')
92-
.action(async (options: CLIOptions) => {
95+
.example('buddy-bot setup --non-interactive')
96+
.example('buddy-bot setup --non-interactive --preset testing --verbose')
97+
.action(async (options: CLIOptions & { nonInteractive?: boolean, preset?: string, tokenSetup?: string }) => {
9398
const logger = options.verbose ? Logger.verbose() : Logger.quiet()
9499

95100
try {
@@ -108,7 +113,7 @@ cli
108113
const existingTools = await migrator.detectExistingTools()
109114
const migrationResults: any[] = []
110115

111-
if (existingTools.length > 0) {
116+
if (existingTools.length > 0 && !options.nonInteractive) {
112117
console.log(`\n🔍 Configuration Migration Detection:`)
113118
console.log(`Found ${existingTools.length} existing dependency management tool(s):`)
114119
existingTools.forEach(tool => console.log(` • ${tool.name} (${tool.configFile})`))
@@ -148,6 +153,9 @@ cli
148153
}
149154
}
150155
}
156+
else if (existingTools.length > 0 && options.nonInteractive) {
157+
console.log(`\n🔍 Found ${existingTools.length} existing tool(s), skipping migration in non-interactive mode`)
158+
}
151159

152160
// Plugin Discovery
153161
updateProgress(progress, 'Discovering integrations', true)
@@ -156,7 +164,7 @@ cli
156164
const pluginManager = new PluginManager()
157165
const availablePlugins = await pluginManager.discoverPlugins()
158166

159-
if (availablePlugins.length > 0) {
167+
if (availablePlugins.length > 0 && !options.nonInteractive) {
160168
console.log(`\n🔌 Integration Discovery:`)
161169
console.log(`Found ${availablePlugins.length} available integration(s):`)
162170
availablePlugins.forEach(plugin => console.log(` • ${plugin.name} v${plugin.version}`))
@@ -174,6 +182,9 @@ cli
174182
}
175183
}
176184
}
185+
else if (availablePlugins.length > 0 && options.nonInteractive) {
186+
console.log(`\n🔌 Found ${availablePlugins.length} integration(s), skipping in non-interactive mode`)
187+
}
177188

178189
// Pre-flight checks
179190
updateProgress(progress, 'Running pre-flight checks', true)
@@ -233,10 +244,30 @@ cli
233244
console.log('For full functionality, Buddy Bot needs appropriate GitHub permissions.')
234245
console.log('This enables workflow file updates and advanced GitHub Actions features.\n')
235246

236-
const tokenSetup = await confirmTokenSetup()
237-
238-
if (tokenSetup.needsGuide) {
239-
await guideTokenCreation(repoInfo)
247+
let tokenSetup
248+
if (options.nonInteractive) {
249+
// Use default token setup based on flag
250+
switch (options.tokenSetup) {
251+
case 'existing-secret':
252+
tokenSetup = { hasCustomToken: true, needsGuide: false }
253+
console.log('✅ Using existing organization/repository secrets')
254+
break
255+
case 'new-pat':
256+
tokenSetup = { hasCustomToken: true, needsGuide: true }
257+
console.log('⚠️ Non-interactive mode: Will use custom token but skip setup guide')
258+
break
259+
case 'default-token':
260+
default:
261+
tokenSetup = { hasCustomToken: false, needsGuide: false }
262+
console.log('✅ Using default GITHUB_TOKEN (limited functionality)')
263+
break
264+
}
265+
}
266+
else {
267+
tokenSetup = await confirmTokenSetup()
268+
if (tokenSetup.needsGuide) {
269+
await guideTokenCreation(repoInfo)
270+
}
240271
}
241272

242273
// Step 3: Repository Settings
@@ -251,49 +282,56 @@ cli
251282
displayProgress(progress)
252283

253284
console.log('\n⚙️ Workflow Configuration')
254-
const workflowResponse = await prompts([
255-
{
256-
type: 'select',
257-
name: 'useCase',
258-
message: 'What type of update schedule would you like?',
259-
choices: [
260-
{
261-
title: 'Standard Setup (Recommended)',
262-
description: 'Dashboard updates 3x/week, dependency updates on schedule',
263-
value: 'standard',
264-
},
265-
{
266-
title: 'High Frequency',
267-
description: 'Check for updates multiple times per day',
268-
value: 'high-frequency',
269-
},
270-
{
271-
title: 'Security Focused',
272-
description: 'Frequent patch updates with security-first approach',
273-
value: 'security',
274-
},
275-
{
276-
title: 'Minimal Updates',
277-
description: 'Weekly checks, lower frequency',
278-
value: 'minimal',
279-
},
280-
{
281-
title: 'Development/Testing',
282-
description: 'Manual triggers + frequent checks for testing',
283-
value: 'testing',
284-
},
285-
{
286-
title: 'Custom Configuration',
287-
description: 'Create your own schedule',
288-
value: 'custom',
289-
},
290-
],
291-
},
292-
])
293-
294-
if (!workflowResponse.useCase) {
295-
console.log('Setup cancelled.')
296-
return
285+
let workflowResponse
286+
if (options.nonInteractive) {
287+
workflowResponse = { useCase: options.preset }
288+
console.log(`✅ Using ${options.preset} preset for workflow configuration`)
289+
}
290+
else {
291+
workflowResponse = await prompts([
292+
{
293+
type: 'select',
294+
name: 'useCase',
295+
message: 'What type of update schedule would you like?',
296+
choices: [
297+
{
298+
title: 'Standard Setup (Recommended)',
299+
description: 'Dashboard updates 3x/week, dependency updates on schedule',
300+
value: 'standard',
301+
},
302+
{
303+
title: 'High Frequency',
304+
description: 'Check for updates multiple times per day',
305+
value: 'high-frequency',
306+
},
307+
{
308+
title: 'Security Focused',
309+
description: 'Frequent patch updates with security-first approach',
310+
value: 'security',
311+
},
312+
{
313+
title: 'Minimal Updates',
314+
description: 'Weekly checks, lower frequency',
315+
value: 'minimal',
316+
},
317+
{
318+
title: 'Development/Testing',
319+
description: 'Manual triggers + frequent checks for testing',
320+
value: 'testing',
321+
},
322+
{
323+
title: 'Custom Configuration',
324+
description: 'Create your own schedule',
325+
value: 'custom',
326+
},
327+
],
328+
},
329+
])
330+
331+
if (!workflowResponse.useCase) {
332+
console.log('Setup cancelled.')
333+
return
334+
}
297335
}
298336

299337
// Step 5: Generate Configuration File
@@ -310,7 +348,7 @@ cli
310348
console.log('\n🔄 Workflow Generation')
311349
const preset = getWorkflowPreset(workflowResponse.useCase)
312350

313-
if (workflowResponse.useCase === 'custom') {
351+
if (workflowResponse.useCase === 'custom' && !options.nonInteractive) {
314352
await setupCustomWorkflow(preset, logger)
315353
}
316354
else {

0 commit comments

Comments
 (0)