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