renuo-cli 4.2.1 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccd25184eef6694e483475a333723876704e19ccd95208cc0f2767fe65933e0f
4
- data.tar.gz: c4a2447d6ad50d362e2c774b10891b7413df3466957940c8e7265e869ae63325
3
+ metadata.gz: 63ddefa045f6a882dc8c2cdb625d809dd4867e6d726069c49348299000574aa3
4
+ data.tar.gz: 91f7b57e66180c476c91cb39a143dfdb474a8177e6f8b194dbe0d321369d4601
5
5
  SHA512:
6
- metadata.gz: 0bf03b6b6f03220c7dc3e0ee20697cd74d95ee51674d4070f0b3bde0146397fada1c1971ac12fd98839ce4468afb52d6de6fc9acea55b813b8f65878efaffdc1
7
- data.tar.gz: 805ebae3c760ee7467e767c927845900f32016a2aa75ef72b933f53c39f4c36c9a81d28cfcebff272f65ec030c6bb7ead78ba5a56ef8d702f20501207819fa57
6
+ metadata.gz: dd150d6c2692edd4c90ea37385edb895beca3897ec88de3978145c0b7b2430133f35aba36681a2bca202ded28dc193964dd33fc70353d64145937eea52785a6f
7
+ data.tar.gz: 905e009a98226b7c0e5d48fb808cce676aaab29c077f23d4ca1ed2d4b42b31259e4b55a05b87b53f92fcda697012db31d77d40c0f65cef75aca5ab2fbbce6d7e
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.0
1
+ 3.3.5
@@ -2,8 +2,8 @@ version: v1.0
2
2
  name: main-deploy
3
3
  agent:
4
4
  machine:
5
- type: e1-standard-2
6
- os_image: ubuntu2004
5
+ type: e2-standard-2
6
+ os_image: ubuntu2204
7
7
 
8
8
  blocks:
9
9
  - name: main-deploy
@@ -1,12 +1,15 @@
1
1
  version: "v1.0"
2
2
  name: renuo-cli
3
+
3
4
  agent:
4
5
  machine:
5
- type: e1-standard-2
6
- os_image: ubuntu2004
6
+ type: e2-standard-2
7
+ os_image: ubuntu2204
8
+
7
9
  auto_cancel:
8
10
  running:
9
11
  when: "true"
12
+
10
13
  fail_fast:
11
14
  cancel:
12
15
  when: "branch != 'main'"
File without changes
@@ -105,11 +105,11 @@ class ReleaseProject
105
105
 
106
106
  return unless version_bumped
107
107
 
108
- system(cmd_in_folder('git add . && git commit -m "bump version"'))
108
+ system(cmd_in_folder(%(git add #{find_files_with_version.join(' ')} && git commit -m "Bump version")))
109
109
  end
110
110
 
111
111
  def find_and_replace_version
112
- find_files_with_version.split("\n").any? do |file_name|
112
+ find_files_with_version.any? do |file_name|
113
113
  puts "Replace the version in #{file_name}?"
114
114
  print_version_found(file_name)
115
115
  if agree('confirm?')
@@ -124,7 +124,7 @@ class ReleaseProject
124
124
  def find_files_with_version
125
125
  excluded_dirs = %w[.git node_modules tmp].map { |dir| "--exclude-dir=#{dir}" }.join(' ')
126
126
  grep_current_version = "grep -rl -F #{excluded_dirs} --include='*.rb' #{current_version} ."
127
- `#{cmd_in_folder(grep_current_version)}`
127
+ `#{cmd_in_folder(grep_current_version)}`.split("\n")
128
128
  end
129
129
 
130
130
  def print_version_found(file_name)
@@ -132,7 +132,10 @@ class ReleaseProject
132
132
  end
133
133
 
134
134
  def bump_version_in_file(file_name)
135
- system(cmd_in_folder("sed -i '' 's|#{current_version}|#{@version}|g' #{file_name}"))
135
+ # Use `-i ''` for OS X and `-i` for GNU
136
+ args = "''" unless system('sed --version > /dev/null 2>&1')
137
+
138
+ system(cmd_in_folder("sed -i #{args} 's|#{current_version}|#{@version}|g' #{file_name}"))
136
139
  end
137
140
 
138
141
  def finish_release_branch
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+ require 'fileutils'
5
+ require 'json'
6
+
7
+ CONFIG_FILE = 'config/1password-secrets.yml'
8
+
9
+ class SecretsFetcher
10
+ def run
11
+ system('which op > /dev/null') || abort('op is not installed. Please install it (e.g. brew install 1password-cli).')
12
+
13
+ abort("Config file #{CONFIG_FILE} not found.") unless File.exist?(CONFIG_FILE)
14
+ config = YAML.load_file(CONFIG_FILE).deep_symbolize_keys
15
+
16
+ config[:items].each do |item|
17
+ elaborate_item(item)
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def elaborate_item(item)
24
+ private_link = item[:private_link]
25
+ files = item[:files]
26
+ default_folder = item[:default_folder]
27
+ item_id = extract_item_id(private_link)
28
+ item = get_item(item_id)
29
+ return if item.nil?
30
+
31
+ files.each do |file|
32
+ process_files(file[:folder] || default_folder, file[:name], item, item_id)
33
+ end
34
+ end
35
+
36
+ def get_item(item_id)
37
+ output = execute_command(command: "op item get #{item_id} --format json",
38
+ success_message: '',
39
+ error_message: "Error fetching item #{item_id}." \
40
+ "Check `private_link` in your #{CONFIG_FILE} file.")
41
+ JSON.parse(output) if output
42
+ end
43
+
44
+ def execute_command(command:, success_message:, error_message:)
45
+ output = `#{command}`
46
+ if $CHILD_STATUS.success?
47
+ puts success_message unless success_message.empty?
48
+ output
49
+ else
50
+ warn error_message
51
+ end
52
+ end
53
+
54
+ def extract_item_id(private_link)
55
+ /&i=([^&]+)/.match(private_link)[1]
56
+ end
57
+
58
+ def process_files(output_folder, filename, item, item_id)
59
+ FileUtils.mkdir_p(output_folder)
60
+ output_path = File.join(output_folder, filename)
61
+
62
+ vault_id = item.dig('vault', 'id')
63
+ download_file_from_item(item['files'], vault_id, item_id, filename, output_path)
64
+ puts "\n\n"
65
+ end
66
+
67
+ def download_file_from_item(files, vault_id, item_id, filename, output_path)
68
+ item_file = files&.find { |tmp_file_config| tmp_file_config['name'].eql?(filename) }
69
+ if item_file.nil?
70
+ warn "File `#{filename}` not found in item #{item_id}. Check the file name in your #{CONFIG_FILE} file."
71
+ return
72
+ end
73
+ execute_command(command: "op read \"op://#{vault_id}/#{item_id}/#{item_file['id']}\" --out-file #{output_path}",
74
+ success_message: "Successfully fetched #{filename} and saved to #{output_path}",
75
+ error_message: "Error fetching #{filename}.")
76
+ end
77
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Renuo
4
4
  module Cli
5
- VERSION = '4.2.1'
5
+ VERSION = '4.3.0'
6
6
  NAME = 'renuo-cli'
7
7
  end
8
8
  end
data/lib/renuo/cli.rb CHANGED
@@ -28,6 +28,7 @@ require 'renuo/cli/app/renuo_version'
28
28
  require 'renuo/cli/app/create_slidev_presentation'
29
29
  require 'renuo/cli/app/commit_leaderboard'
30
30
  require 'renuo/cli/app/commit_leaderboard_sync'
31
+ require 'renuo/cli/app/secrets_fetcher'
31
32
  require 'highline'
32
33
 
33
34
  def agree(question)
@@ -69,17 +70,6 @@ module Renuo
69
70
  end
70
71
  end
71
72
 
72
- command :config do |c|
73
- c.syntax = 'renuo config [options]'
74
- c.summary = 'Setup the config (API keys)'
75
- c.description = 'Setup the config (API keys)'
76
- c.action do
77
- key = ask('API Key?') { |q| q.echo = '*' }
78
- LocalStorage.new.store(:api_key, key)
79
- say('stored the api key')
80
- end
81
- end
82
-
83
73
  command 'list-large-git-files' do |c|
84
74
  c.syntax = 'renuo list-large-git-files'
85
75
  c.summary = 'Lists the 5 largest files in a git repository. Warning: must be a bare checkout of the repo!'
@@ -299,6 +289,18 @@ module Renuo
299
289
  CommitLeaderboardSync.new.run(args)
300
290
  end
301
291
  end
292
+
293
+ command 'fetch-secrets' do |c|
294
+ c.syntax = 'renuo fetch-secrets'
295
+ c.summary = 'Fetches the needed secrets in a project from the renuo secrets store'
296
+ c.description = <<~DESCRIPTION
297
+ Run the command within a project folder to fetch the secrets from the renuo secrets store.
298
+ The bin/setup of the project might run this command for you.
299
+ DESCRIPTION
300
+ c.action do
301
+ SecretsFetcher.new.run
302
+ end
303
+ end
302
304
  end
303
305
  end
304
306
  end
data/renuo-cli.gemspec CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency 'dotenv', '~> 2.7.2'
38
38
  spec.add_development_dependency 'mdl', '~> 0.13'
39
39
  spec.add_development_dependency 'pry', '~> 0.14'
40
- spec.add_development_dependency 'rake', '~> 10.0'
40
+ spec.add_development_dependency 'rake', '~> 13.0'
41
41
  spec.add_development_dependency 'renuocop'
42
42
  spec.add_development_dependency 'rspec', '~> 3.5'
43
43
  spec.add_development_dependency 'rubocop', '~> 1.62'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renuo-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.1
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renuo AG
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-04 00:00:00.000000000 Z
11
+ date: 2024-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -198,14 +198,14 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: '10.0'
201
+ version: '13.0'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: '10.0'
208
+ version: '13.0'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: renuocop
211
211
  requirement: !ruby/object:Gem::Requirement
@@ -333,6 +333,7 @@ files:
333
333
  - bin/renuo
334
334
  - bin/run
335
335
  - bin/setup
336
+ - config/1password-secrets.yml
336
337
  - lib/renuo/cli.rb
337
338
  - lib/renuo/cli/app/command_helper.rb
338
339
  - lib/renuo/cli/app/commit_leaderboard.rb
@@ -357,6 +358,7 @@ files:
357
358
  - lib/renuo/cli/app/release_project.rb
358
359
  - lib/renuo/cli/app/release_xing.rb
359
360
  - lib/renuo/cli/app/renuo_version.rb
361
+ - lib/renuo/cli/app/secrets_fetcher.rb
360
362
  - lib/renuo/cli/app/services/cloudfront_config_service.rb
361
363
  - lib/renuo/cli/app/services/markdown_parser_service.rb
362
364
  - lib/renuo/cli/app/services/renuo_cli_config.rb
@@ -385,7 +387,7 @@ licenses:
385
387
  - MIT
386
388
  metadata:
387
389
  rubygems_mfa_required: 'true'
388
- post_install_message:
390
+ post_install_message:
389
391
  rdoc_options: []
390
392
  require_paths:
391
393
  - lib
@@ -400,8 +402,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
400
402
  - !ruby/object:Gem::Version
401
403
  version: '0'
402
404
  requirements: []
403
- rubygems_version: 3.5.3
404
- signing_key:
405
+ rubygems_version: 3.5.16
406
+ signing_key:
405
407
  specification_version: 4
406
408
  summary: The Renuo CLI automates some common workflows.
407
409
  test_files: []