bard 1.7.4 → 2.0.0.beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,498 @@
1
+ # Migration Guide: Bard v1.x → v2.0
2
+
3
+ This guide will help you migrate your Bard configuration from v1.x to v2.0.
4
+
5
+ ## Overview of Changes
6
+
7
+ Bard v2.0 introduces a cleaner, more modular architecture:
8
+
9
+ 1. **`server` renamed to `target`** - More accurate for serverless deployments
10
+ 2. **SSH configuration simplified** - Uses hash options instead of separate method calls
11
+ 3. **Strategy-first configuration** - Deployment strategies provide their own configuration
12
+ 4. **Capability-based architecture** - Features are explicitly enabled and checked
13
+ 5. **Default targets** - Pre-configured targets for Bot and Rose workflows
14
+
15
+ ## Breaking Changes
16
+
17
+ ### 1. `server` → `target`
18
+
19
+ **v1.x:**
20
+ ```ruby
21
+ server :production do
22
+ ssh "deploy@example.com:22"
23
+ end
24
+ ```
25
+
26
+ **v2.0:**
27
+ ```ruby
28
+ target :production do
29
+ ssh "deploy@example.com:22"
30
+ end
31
+ ```
32
+
33
+ **Migration:** Simply replace `server` with `target` throughout your `bard.rb`.
34
+
35
+ ### 2. SSH Configuration
36
+
37
+ SSH configuration now uses hash options instead of separate method calls.
38
+
39
+ **v1.x:**
40
+ ```ruby
41
+ server :production do
42
+ ssh "user@host:port"
43
+ path "deploy/path"
44
+ gateway "bastion@host:port"
45
+ key "/path/to/key"
46
+ env "RAILS_ENV=production"
47
+ end
48
+ ```
49
+
50
+ **v2.0:**
51
+ ```ruby
52
+ target :production do
53
+ ssh "user@host:port",
54
+ path: "deploy/path",
55
+ gateway: "bastion@host:port",
56
+ ssh_key: "/path/to/key",
57
+ env: "RAILS_ENV=production"
58
+ end
59
+ ```
60
+
61
+ **Migration:**
62
+ - Combine all SSH-related options into the `ssh` method call
63
+ - `key` → `ssh_key`
64
+ - Use Ruby hash syntax for options
65
+
66
+ ### 3. GitHub Pages Configuration
67
+
68
+ **v1.x:**
69
+ ```ruby
70
+ server :production do
71
+ github_pages true
72
+ ping "https://example.com"
73
+ end
74
+ ```
75
+
76
+ **v2.0:**
77
+ ```ruby
78
+ target :production do
79
+ github_pages "https://example.com" # Sets both strategy and ping URL
80
+ end
81
+ ```
82
+
83
+ **Migration:**
84
+ - Pass the ping URL directly to `github_pages`
85
+ - Remove separate `ping` call (auto-configured by strategy)
86
+
87
+ ### 4. Strategy-First Configuration
88
+
89
+ In v2.0, deployment strategies configure themselves.
90
+
91
+ **v1.x:**
92
+ ```ruby
93
+ server :production do
94
+ strategy :jets
95
+ ping "https://api.example.com"
96
+ option :run_tests, true
97
+ end
98
+ ```
99
+
100
+ **v2.0:**
101
+ ```ruby
102
+ target :production do
103
+ jets "https://api.example.com", run_tests: true
104
+ end
105
+ ```
106
+
107
+ **Migration:**
108
+ - Use strategy name as DSL method
109
+ - Pass ping URL and options directly
110
+ - Remove separate `strategy`, `ping`, and `option` calls
111
+
112
+ ## Migration Examples
113
+
114
+ ### Example 1: Simple SSH Deployment
115
+
116
+ **v1.x:**
117
+ ```ruby
118
+ server :staging do
119
+ ssh "deploy@staging.example.com:22"
120
+ path "app"
121
+ end
122
+
123
+ server :production do
124
+ ssh "deploy@production.example.com:22"
125
+ path "app"
126
+ gateway "bastion.example.com:22"
127
+ end
128
+
129
+ data "public/uploads"
130
+ ```
131
+
132
+ **v2.0:**
133
+ ```ruby
134
+ target :staging do
135
+ ssh "deploy@staging.example.com:22", path: "app"
136
+ end
137
+
138
+ target :production do
139
+ ssh "deploy@production.example.com:22",
140
+ path: "app",
141
+ gateway: "bastion.example.com:22"
142
+ end
143
+
144
+ data "public/uploads"
145
+ ```
146
+
147
+ ### Example 2: GitHub Pages
148
+
149
+ **v1.x:**
150
+ ```ruby
151
+ server :production do
152
+ github_pages true
153
+ ping "https://example.com"
154
+ backup false
155
+ end
156
+ ```
157
+
158
+ **v2.0:**
159
+ ```ruby
160
+ target :production do
161
+ github_pages "https://example.com"
162
+ end
163
+
164
+ backup false
165
+ ```
166
+
167
+ ### Example 3: Jets Serverless
168
+
169
+ **v1.x:**
170
+ ```ruby
171
+ require_relative 'lib/jets_deploy_strategy'
172
+
173
+ server :staging do
174
+ strategy :jets
175
+ ping "https://staging-api.example.com"
176
+ end
177
+
178
+ server :production do
179
+ strategy :jets
180
+ ping "https://api.example.com"
181
+ option :run_tests, true
182
+ end
183
+
184
+ backup false
185
+ ```
186
+
187
+ **v2.0:**
188
+ ```ruby
189
+ require_relative 'lib/jets_deploy_strategy'
190
+
191
+ target :staging do
192
+ jets "https://staging-api.example.com"
193
+ end
194
+
195
+ target :production do
196
+ jets "https://api.example.com", run_tests: true
197
+ end
198
+
199
+ backup false
200
+ ```
201
+
202
+ ### Example 4: Multiple Ping URLs
203
+
204
+ **v1.x:**
205
+ ```ruby
206
+ server :production do
207
+ ssh "deploy@example.com:22"
208
+ ping "https://example.com"
209
+ ping "/health"
210
+ ping "/status"
211
+ end
212
+ ```
213
+
214
+ **v2.0:**
215
+ ```ruby
216
+ target :production do
217
+ ssh "deploy@example.com:22"
218
+ ping "https://example.com", "/health", "/status"
219
+ end
220
+ ```
221
+
222
+ ### Example 5: CI Configuration
223
+
224
+ **v1.x:**
225
+ ```ruby
226
+ # CI auto-detected, no explicit configuration
227
+ ```
228
+
229
+ **v2.0:**
230
+ ```ruby
231
+ # CI auto-detected by default
232
+
233
+ # Override if needed:
234
+ ci :github_actions # Force GitHub Actions
235
+ ci :jenkins # Force Jenkins
236
+ ci :local # Run locally
237
+ ci false # Disable CI
238
+ ```
239
+
240
+ ## Step-by-Step Migration Process
241
+
242
+ ### Step 1: Update Bard gem
243
+
244
+ ```bash
245
+ # Gemfile
246
+ gem 'bard', '~> 2.0'
247
+ ```
248
+
249
+ ```bash
250
+ bundle update bard
251
+ ```
252
+
253
+ ### Step 2: Update bard.rb configuration
254
+
255
+ 1. Replace `server` with `target`
256
+ 2. Combine SSH options into hash
257
+ 3. Update strategy configuration to use DSL methods
258
+ 4. Simplify ping configuration
259
+
260
+ ### Step 3: Test locally
261
+
262
+ ```bash
263
+ # Verify configuration loads
264
+ bard config
265
+
266
+ # Test SSH connection (if applicable)
267
+ bard ssh staging
268
+
269
+ # Test ping (if applicable)
270
+ bard ping staging
271
+ ```
272
+
273
+ ### Step 4: Deploy to staging
274
+
275
+ ```bash
276
+ bard deploy staging
277
+ ```
278
+
279
+ ### Step 5: Deploy to production
280
+
281
+ ```bash
282
+ bard deploy production
283
+ ```
284
+
285
+ ## Automated Migration Script
286
+
287
+ You can use this Ruby script to automatically migrate simple configurations:
288
+
289
+ ```ruby
290
+ #!/usr/bin/env ruby
291
+ # migrate_bard_config.rb
292
+
293
+ config = File.read('bard.rb')
294
+
295
+ # Replace server with target
296
+ config.gsub!(/^(\s*)server\s+/, '\1target ')
297
+
298
+ # Combine SSH options (simple cases)
299
+ config.gsub!(
300
+ /ssh\s+"([^"]+)"\s+path\s+"([^"]+)"/m,
301
+ 'ssh "\1", path: "\2"'
302
+ )
303
+
304
+ # GitHub Pages
305
+ config.gsub!(
306
+ /github_pages\s+true\s+ping\s+"([^"]+)"/m,
307
+ 'github_pages "\1"'
308
+ )
309
+
310
+ puts config
311
+ ```
312
+
313
+ Run with:
314
+ ```bash
315
+ ruby migrate_bard_config.rb > bard.rb.new
316
+ mv bard.rb bard.rb.backup
317
+ mv bard.rb.new bard.rb
318
+ ```
319
+
320
+ **Note:** This script handles simple cases. Review the output and manually update complex configurations.
321
+
322
+ ## Common Pitfalls
323
+
324
+ ### Pitfall 1: Forgetting to combine SSH options
325
+
326
+ **Wrong:**
327
+ ```ruby
328
+ target :production do
329
+ ssh "deploy@example.com:22"
330
+ path "app" # This won't work in v2!
331
+ end
332
+ ```
333
+
334
+ **Right:**
335
+ ```ruby
336
+ target :production do
337
+ ssh "deploy@example.com:22", path: "app"
338
+ end
339
+ ```
340
+
341
+ ### Pitfall 2: Using old strategy configuration
342
+
343
+ **Wrong:**
344
+ ```ruby
345
+ target :production do
346
+ strategy :jets
347
+ ping "https://api.example.com"
348
+ end
349
+ ```
350
+
351
+ **Right:**
352
+ ```ruby
353
+ target :production do
354
+ jets "https://api.example.com"
355
+ end
356
+ ```
357
+
358
+ ### Pitfall 3: Separate ping calls
359
+
360
+ **Wrong:**
361
+ ```ruby
362
+ target :production do
363
+ github_pages true
364
+ ping "https://example.com"
365
+ end
366
+ ```
367
+
368
+ **Right:**
369
+ ```ruby
370
+ target :production do
371
+ github_pages "https://example.com"
372
+ end
373
+ ```
374
+
375
+ ## Capability Dependencies
376
+
377
+ v2.0 makes capability dependencies explicit. If you try to use a command that requires a capability you haven't enabled, you'll get a clear error message.
378
+
379
+ ### SSH-dependent commands
380
+
381
+ These commands require SSH capability:
382
+ - `bard ssh [target]`
383
+ - `bard run [target] "command"`
384
+ - `bard data --from=X --to=Y` (both targets need SSH)
385
+ - `bard master_key --from=X --to=Y` (both targets need SSH)
386
+
387
+ **Enable SSH:**
388
+ ```ruby
389
+ target :production do
390
+ ssh "deploy@example.com:22"
391
+ end
392
+ ```
393
+
394
+ ### Ping-dependent commands
395
+
396
+ These commands require ping URLs:
397
+ - `bard ping [target]`
398
+ - `bard open [target]`
399
+
400
+ **Enable ping:**
401
+ ```ruby
402
+ target :production do
403
+ ssh "deploy@example.com:22"
404
+ ping "https://example.com"
405
+ end
406
+
407
+ # Or let strategy auto-configure:
408
+ target :production do
409
+ jets "https://api.example.com" # Ping auto-configured
410
+ end
411
+ ```
412
+
413
+ ## Default Targets
414
+
415
+ v2.0 ships with default targets for Bot and Rose workflows. You only need to define targets you want to customize.
416
+
417
+ **Default targets:**
418
+ - `:local` - Local development (no SSH, path `./`, ping `#{project_name}.local`)
419
+ - `:ci` - Jenkins at `staging.botandrose.com`
420
+ - `:staging` - SSH to `staging.botandrose.com`
421
+ - `:gubs` - Bot and Rose cloud server
422
+
423
+ **Override any default:**
424
+ ```ruby
425
+ # Override staging to use Jets instead of SSH
426
+ target :staging do
427
+ jets "https://staging-api.example.com"
428
+ end
429
+
430
+ # Keep :ci, :gubs, :local as defaults (no config needed)
431
+ ```
432
+
433
+ ## Custom Strategies
434
+
435
+ If you created custom deployment strategies in v1.x, you'll need to update them for v2.0's auto-registration system.
436
+
437
+ **v1.x:**
438
+ ```ruby
439
+ # Manual registration required
440
+ Bard::DeployStrategy.register(:jets, JetsDeployStrategy)
441
+ ```
442
+
443
+ **v2.0:**
444
+ ```ruby
445
+ # Auto-registers via inherited hook
446
+ module Bard
447
+ class DeployStrategy
448
+ class Jets < DeployStrategy
449
+ def deploy
450
+ # implementation
451
+ end
452
+ end
453
+ end
454
+ end
455
+ ```
456
+
457
+ See [CUSTOM_STRATEGIES.md](CUSTOM_STRATEGIES.md) for detailed guide.
458
+
459
+ ## Rollback Plan
460
+
461
+ If you encounter issues, you can rollback to v1.x:
462
+
463
+ ```bash
464
+ # Gemfile
465
+ gem 'bard', '~> 1.5'
466
+
467
+ bundle update bard
468
+
469
+ # Restore backup
470
+ mv bard.rb.backup bard.rb
471
+ ```
472
+
473
+ ## Getting Help
474
+
475
+ - Review [README.md](README.md) for v2 API documentation
476
+ - Review [ARCHITECTURE.md](ARCHITECTURE.md) for architecture details
477
+ - Check [CUSTOM_STRATEGIES.md](CUSTOM_STRATEGIES.md) for strategy creation
478
+ - Open an issue at https://github.com/botandrose/bard/issues
479
+
480
+ ## Transitional Release (v1.9.x)
481
+
482
+ A transitional release (v1.9.x) will support both v1 and v2 APIs simultaneously with deprecation warnings. This allows gradual migration.
483
+
484
+ **Using v1.9.x:**
485
+ ```bash
486
+ # Gemfile
487
+ gem 'bard', '~> 1.9'
488
+
489
+ bundle update bard
490
+ ```
491
+
492
+ v1.9.x will:
493
+ - Accept both `server` and `target` (with deprecation warning)
494
+ - Accept both old and new SSH configuration styles
495
+ - Show deprecation warnings for old API usage
496
+ - Support full v2 API
497
+
498
+ This gives you time to migrate at your own pace while keeping your deployments working.