belt 0.3.31 → 0.3.32

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3545e62c7890adc16931218212e284d8e68994814be13ae0e231d5aee89b2ec
4
- data.tar.gz: 89b19c24b919d441bffbbb8cd426697e656b8726596c24c58cf5f03d79233c81
3
+ metadata.gz: d6661697f19873dc93fa45b49d27d6665e370d771b947a6ea5539fb33a0970c9
4
+ data.tar.gz: ad996f0d38638b90ae2ebb1c8c761487b9bc4939fe3dba009dbed4f8ea4a6b4d
5
5
  SHA512:
6
- metadata.gz: 7df1d7c18c7208d54cb0e37cbea0cf6c998f9b502950651c7e3e304f2786c3a750d664894d5f7f09cbc8848b550f365d7ebe415a5bcb701da45ef115fb7d28bb
7
- data.tar.gz: '05380ceae6d72a8874e66f52f616b527baa69f7101513842a6240765d2b1b6644bcd7b6d469acffeab246d18a152eabfb618a52c74753f5e61fd8cbbb663143a'
6
+ metadata.gz: 5eda51e4ed021da4d55135db7d5945c8370bbd6ae2d378e760aab837cdd353fc70dd34f2ae18c35dca6bd5d57eb8222bc0646b017a2199bdd01c747c94d6c6ee
7
+ data.tar.gz: 0e3e599b0972fb45145735ff8d390ff23bca425521c1fdaba2c5758071017b1857aad884a57fcf124a39bdba2f66845ca85b8890f21d9b5e0f3bf2ab9ae6e1be
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.32
4
+
5
+ ### Enhancement
6
+
7
+ - **`belt destroy environment --full` for fully non-interactive teardown**: Added
8
+ a `--full` / `-y` flag that tears an environment down with zero prompts —
9
+ intended for CI pipelines and agents that spin up ephemeral per-PR
10
+ environments and destroy them on merge. Unlike `--force` (which skips
11
+ terraform and only removes local files), `--full` **always runs
12
+ `terraform destroy`** when terraform state is present, then deletes the local
13
+ `infrastructure/<env>/` files. It also auto-continues past the nested-children
14
+ warning. When no terraform state exists there is nothing to tear down, so the
15
+ destroy step is skipped and only the files are removed.
16
+
17
+ ```bash
18
+ belt destroy environment pr-1234 --full
19
+ ```
20
+
3
21
  ## 0.3.31
4
22
 
5
23
  ### Bug Fix
@@ -47,7 +47,7 @@ module Belt
47
47
  when 'environment'
48
48
  name = args.shift
49
49
  if name.nil? || name.empty?
50
- puts 'Usage: belt destroy environment <name> [--force] [--skip-terraform]'
50
+ puts 'Usage: belt destroy environment <name> [--full] [--force] [--skip-terraform]'
51
51
  exit 1
52
52
  end
53
53
  flags = parse_environment_flags(args)
@@ -79,13 +79,15 @@ module Belt
79
79
  end
80
80
 
81
81
  def self.parse_environment_flags(args)
82
- flags = { force: false, skip_terraform: false }
82
+ flags = { force: false, skip_terraform: false, full: false }
83
83
  args.each do |arg|
84
84
  case arg
85
85
  when '--force', '-f'
86
86
  flags[:force] = true
87
87
  when '--skip-terraform'
88
88
  flags[:skip_terraform] = true
89
+ when '--full', '-y'
90
+ flags[:full] = true
89
91
  end
90
92
  end
91
93
  flags
@@ -114,7 +116,11 @@ module Belt
114
116
  views Remove React pages for a resource
115
117
 
116
118
  Environment options:
117
- --force, -f Skip all prompts (CI mode)
119
+ --full, -y Non-interactive teardown: ALWAYS run terraform
120
+ destroy, then delete local files, no prompts
121
+ (use this for CI / agents tearing down ephemeral envs)
122
+ --force, -f Skip all prompts but SKIP terraform destroy —
123
+ only deletes local files (leaves cloud resources)
118
124
  --skip-terraform Delete local files without running terraform destroy
119
125
 
120
126
  Examples:
@@ -124,6 +130,7 @@ module Belt
124
130
  belt d environment staging
125
131
  belt d environment dev --skip-terraform
126
132
  belt d environment dev --force
133
+ belt d environment pr-1234 --full # full non-interactive teardown
127
134
  belt d frontend
128
135
  belt d frontend --frontend ops
129
136
  belt d views post
@@ -133,16 +140,18 @@ module Belt
133
140
 
134
141
  For environments: if terraform state is detected, you'll be prompted to run
135
142
  `terraform destroy` first to tear down cloud resources before removing files.
143
+ Pass --full to run the whole teardown non-interactively (destroy + delete).
136
144
  HELP
137
145
  end
138
146
 
139
147
  # -- keyword options for destroy flags
140
- def initialize(generator, name, fields, force: false, skip_terraform: false, frontend_name: nil)
148
+ def initialize(generator, name, fields, force: false, skip_terraform: false, full: false, frontend_name: nil)
141
149
  @generator = generator
142
150
  @name = name&.downcase&.gsub(/[^a-z0-9_]/, '_')
143
151
  @fields = fields
144
152
  @force = force
145
153
  @skip_terraform = skip_terraform
154
+ @full = full
146
155
  @frontend_name = frontend_name
147
156
  @app_name = detect_namespace
148
157
  @singular_name = @name ? Belt::Inflector.singularize(@name) : nil
@@ -205,7 +214,7 @@ module Belt
205
214
  puts ' Consider destroying nested environments first:'
206
215
  nested_children.each { |child| puts " belt destroy environment #{child}" }
207
216
  puts ''
208
- unless @force
217
+ unless @force || @full
209
218
  print ' Continue anyway? [y/N] '
210
219
  response = $stdin.gets&.strip&.downcase
211
220
  unless response&.start_with?('y')
@@ -227,7 +236,12 @@ module Belt
227
236
  puts "⚠ Environment '#{@name}' appears to have active infrastructure."
228
237
  puts " Terraform state was found — resources may still be running.\n\n"
229
238
 
230
- if @force
239
+ if @full
240
+ # Fully non-interactive teardown (CI / agents): always run terraform
241
+ # destroy, then delete files. This is the flag to reach for when an
242
+ # automated workflow spins an environment up and tears it down.
243
+ run_terraform_destroy(dir)
244
+ elsif @force
231
245
  puts ' --force passed, skipping terraform destroy.'
232
246
  else
233
247
  puts ' Options:'
@@ -251,7 +265,7 @@ module Belt
251
265
  end
252
266
 
253
267
  # Final confirmation before deleting files
254
- unless @force
268
+ unless @force || @full
255
269
  print "\nPermanently delete #{dir}/? [y/N] "
256
270
  response = $stdin.gets&.strip&.downcase
257
271
  unless response&.start_with?('y')
@@ -106,6 +106,34 @@ belt destroy frontend --frontend ops
106
106
  belt destroy views post
107
107
  ```
108
108
 
109
+ ### Non-interactive environment teardown
110
+
111
+ `belt destroy environment` is interactive by default: it prompts before running
112
+ `terraform destroy` and again before deleting local files. For CI pipelines and
113
+ agents that spin up ephemeral per-PR environments and tear them down on merge,
114
+ use `--full`:
115
+
116
+ ```bash
117
+ belt destroy environment pr-1234 --full
118
+ ```
119
+
120
+ `--full` (alias `-y`) runs the whole teardown with zero prompts: it **always runs
121
+ `terraform destroy`** (when terraform state is present), then deletes the local
122
+ `infrastructure/<env>/` files.
123
+
124
+ Flag comparison:
125
+
126
+ | Flag | terraform destroy | Deletes local files | Prompts |
127
+ |------|-------------------|---------------------|---------|
128
+ | _(none)_ | Prompted | Prompted | Yes |
129
+ | `--full` / `-y` | Always (if state exists) | Yes | No |
130
+ | `--force` / `-f` | **Skipped** (leaves cloud resources) | Yes | No |
131
+ | `--skip-terraform` | Never | Yes | Final delete only |
132
+
133
+ > `--force` is for the "just clean up my local files" case — it intentionally
134
+ > leaves cloud infrastructure running. Reach for `--full` when you want the
135
+ > environment fully gone.
136
+
109
137
  ## Plugin Generators
110
138
 
111
139
  Gems that follow the Belt plugin contract are auto-discovered:
data/lib/belt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Belt
4
- VERSION = '0.3.31'
4
+ VERSION = '0.3.32'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: belt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.31
4
+ version: 0.3.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stowzilla