Skip to content

Commit 5f6a448

Browse files
committed
feat: add non-interactive, preset and token-setup opts
chore: wip chore: wip chore: wip chore: wip
1 parent 7657e63 commit 5f6a448

10 files changed

+1423
-134
lines changed

README.md

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ bun add -g buddy-bot
4343
# Interactive setup (recommended)
4444
buddy-bot setup
4545

46+
# Non-interactive setup for CI/CD
47+
buddy-bot setup --non-interactive
48+
49+
# Non-interactive with specific preset
50+
buddy-bot setup --non-interactive --preset testing --verbose
51+
4652
# Or run directly for scanning only
4753
buddy-bot scan
4854
```
@@ -57,7 +63,29 @@ The easiest way to get started is with the interactive setup command:
5763
buddy-bot setup
5864
```
5965

60-
This comprehensive setup wizard will guide you through configuring automated dependency updates for your project in a Renovate-like experience. The setup process includes:
66+
This comprehensive setup wizard will guide you through configuring automated dependency updates for your project in a Renovate-like experience.
67+
68+
### Non-Interactive Setup
69+
70+
For CI/CD pipelines and automated deployments, use the non-interactive mode:
71+
72+
```bash
73+
# Basic non-interactive setup (uses defaults)
74+
buddy-bot setup --non-interactive
75+
76+
# Specify preset and token setup
77+
buddy-bot setup --non-interactive --preset testing --token-setup existing-secret --verbose
78+
79+
# Production setup with security focus
80+
buddy-bot setup --non-interactive --preset security --token-setup existing-secret
81+
```
82+
83+
**Available options:**
84+
- `--non-interactive` - Skip all prompts, use defaults
85+
- `--preset <type>` - Workflow preset: `standard`, `high-frequency`, `security`, `minimal`, `testing` (default: `standard`)
86+
- `--token-setup <type>` - Token mode: `default-token`, `existing-secret`, `new-pat` (default: `default-token`)
87+
88+
The setup process includes:
6189

6290
**🔍 Pre-flight Validation**
6391
- **Environment checks** - Validates git repository, Node.js/Bun installation
@@ -150,10 +178,13 @@ Choose from several carefully crafted presets with smart recommendations:
150178
### Command Line Interface
151179

152180
```bash
181+
# Setup commands
182+
buddy setup # Interactive setup (recommended)
183+
buddy setup --non-interactive # Non-interactive with defaults
184+
buddy setup --non-interactive --preset testing --verbose
185+
153186
# Scan for dependency updates
154187
buddy scan
155-
156-
# Scan with verbose output
157188
buddy scan --verbose
158189

159190
# Create or update dependency dashboard
@@ -773,19 +804,34 @@ This PR was generated by [Buddy](https://github.com/stacksjs/buddy-bot).
773804
Buddy includes powerful GitHub Actions workflow templates for different automation strategies:
774805
775806
```yaml
776-
# Basic daily patch updates
777-
name: Daily Dependency Updates
807+
# Basic dependency updates (generated by setup)
808+
name: Buddy Update
778809
on:
779810
schedule:
780-
- cron: '0 2 * * *' # 2 AM daily
811+
- cron: '0 */2 * * *' # Every 2 hours
812+
workflow_dispatch:
813+
inputs:
814+
strategy:
815+
description: Update strategy
816+
required: false
817+
default: patch
818+
dry_run:
819+
description: Dry run (preview only)
820+
required: false
821+
default: true
822+
type: boolean
781823
jobs:
782-
update-deps:
824+
dependency-update:
783825
runs-on: ubuntu-latest
784826
steps:
785827
- uses: actions/checkout@v4
786828
- uses: oven-sh/setup-bun@v2
787829
- run: bun install
788-
- run: bunx buddy-bot update --strategy patch --verbose
830+
- run: bunx buddy-bot scan --strategy ${{ github.event.inputs.strategy || 'patch' }} --verbose
831+
env:
832+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
833+
- if: ${{ github.event.inputs.dry_run != 'true' }}
834+
run: bunx buddy-bot update --strategy ${{ github.event.inputs.strategy || 'patch' }} --verbose
789835
env:
790836
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
791837
```
@@ -807,13 +853,13 @@ buddy generate-workflows
807853
808854
**🔥 Comprehensive Multi-Strategy Workflow:**
809855
810-
The comprehensive workflow automatically:
811-
- **Daily 2 AM**: Patch updates (auto-mergeable)
812-
- **Mon/Thu 2 AM**: Minor updates (review required)
813-
- **1st of month 2 AM**: Major updates (review required)
814-
- **Manual trigger**: Any strategy with dry-run option
856+
The updated workflow system automatically:
857+
- **Every 2 hours**: All configured strategies with dry-run by default
858+
- **Manual trigger**: Any strategy with configurable dry-run option
859+
- **Enhanced testing**: Comprehensive validation and summaries
815860
- **Failure handling**: Auto-creates GitHub issues
816861
- **Smart summaries**: Rich GitHub Actions summaries
862+
- **Flexible scheduling**: Consistent 2-hour intervals for all presets
817863
818864
### GitHub Actions Permissions Setup
819865

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 {

docs/cli/overview.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ buddy-bot <command> [options] [arguments]
2929

3030
| Command | Description |
3131
|---------|-------------|
32-
| [`setup`](/cli/setup) | **Interactive setup wizard** - Complete Renovate-like experience |
32+
| [`setup`](/cli/setup) | **Interactive/Non-interactive setup wizard** - Complete Renovate-like experience |
3333
| [`open-settings`](/cli/utility#open-settings) | Open GitHub repository and organization settings |
3434

3535
### 🔍 Scanning & Analysis
@@ -83,6 +83,12 @@ All commands support these global options:
8383
# Interactive setup (recommended for new projects)
8484
buddy-bot setup
8585

86+
# Non-interactive setup with defaults
87+
buddy-bot setup --non-interactive
88+
89+
# Non-interactive setup with specific preset
90+
buddy-bot setup --non-interactive --preset testing --verbose
91+
8692
# Scan for available updates
8793
buddy-bot scan --verbose
8894

0 commit comments

Comments
 (0)