bauble_core 0.4.0 → 0.5.0

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: 55cf8f90f94a4eb4819828fc2614ebcfa0d0871f3a183bce61f140fecd05b293
4
- data.tar.gz: cf2fe310bafd807a51d70e8d4aae7981da0a269b342541bf0cbf876b49d24f93
3
+ metadata.gz: b7034535f46acc0915d5b0af4bfb6010532fec91ece688550e52e48c07d82026
4
+ data.tar.gz: faa95128a0a9ad6b1c5605dbdc679d95d614f02a618eb32fc5bd5cb8d69b5456
5
5
  SHA512:
6
- metadata.gz: b5048dc7d83fa734f9444bbe4a72a4dd329a374afd054ce66f1e0fbd087854c2a235b2e80799bd6f4a6a07fc9d5c792d18ccc6171d4db7cc0f0a43a0a54df4f7
7
- data.tar.gz: 3f1b8a7dfbbdabc23c7f012346015ae7467879d4af5ccde3f177285544c7e0d59754e36780ca27d6c6ec46dc101b6119fc4d9c83d6d4b8ec81a12e1d0c5bf2ed
6
+ metadata.gz: 0efa58c139a9177ada9f992803e2bf1e3bdf9c4d0230790b305286dc96722e9ebf8cf66360533f3e996b99531ddcb5fe91f3ac045cce907f464090b7f73ac8bb
7
+ data.tar.gz: 37a17a1b8301e61cd494b997438ffb1630f8eddc9e2b8dd06fd89ff5f7ef8b5d2504341279bc839a8a65549b0710b586b5e1e9b457c5fd3bd3786db3125b0fb0
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'httparty', '~> 0.22.0'
6
+
7
+ group :development do
8
+ gem 'bauble_core', '~> 0.4.0'
9
+ end
@@ -0,0 +1,28 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ bauble_core (0.4.0)
5
+ colorize (~> 1.1.0)
6
+ thor (~> 1.3.2)
7
+ bigdecimal (3.1.8)
8
+ colorize (1.1.0)
9
+ csv (3.3.0)
10
+ httparty (0.22.0)
11
+ csv
12
+ mini_mime (>= 1.0.0)
13
+ multi_xml (>= 0.5.2)
14
+ mini_mime (1.1.5)
15
+ multi_xml (0.7.1)
16
+ bigdecimal (~> 3.1)
17
+ thor (1.3.2)
18
+
19
+ PLATFORMS
20
+ arm64-darwin-24
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ bauble_core (~> 0.4.0)
25
+ httparty (~> 0.22.0)
26
+
27
+ BUNDLED WITH
28
+ 2.5.22
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'httparty'
4
+
5
+ def handler(event:, context:) # rubocop:disable Lint/UnusedMethodArgument
6
+ response = HTTParty.get('https://api.chucknorris.io/jokes/random')
7
+ joke = JSON.parse(response.body)['value']
8
+ puts joke
9
+ end
@@ -0,0 +1,3 @@
1
+ {
2
+ "entrypoint": "infra/app.rb"
3
+ }
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bauble'
4
+
5
+ app = Bauble::Application.new(
6
+ name: 'basic-bauble-app',
7
+ code_dir: 'app'
8
+ )
9
+
10
+ role = Bauble::Resources::LambdaRole.new(
11
+ app,
12
+ name: 'lambda-role'
13
+ )
14
+
15
+ Bauble::Resources::RubyFunction.new(
16
+ app,
17
+ role: role,
18
+ name: 'hello-world',
19
+ handler: 'app/hello_world.handler'
20
+ )
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'httparty', '~> 0.22.0'
6
+ gem 'pry', '~> 0.14.2'
7
+
8
+ group :development do
9
+ if ENV['BAUBLE_DEV_GEM_PATH']
10
+ gem 'bauble_core', path: ENV['BAUBLE_DEV_GEM_PATH']
11
+ else
12
+ gem 'bauble_core', path: '/var/task/bauble_core'
13
+ end
14
+ end
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: /Users/james/code/bauble
3
+ specs:
4
+ bauble_core (0.4.0)
5
+ colorize (~> 1.1.0)
6
+ thor (~> 1.3.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ bigdecimal (3.1.8)
12
+ coderay (1.1.3)
13
+ colorize (1.1.0)
14
+ csv (3.3.0)
15
+ httparty (0.22.0)
16
+ csv
17
+ mini_mime (>= 1.0.0)
18
+ multi_xml (>= 0.5.2)
19
+ method_source (1.1.0)
20
+ mini_mime (1.1.5)
21
+ multi_xml (0.7.1)
22
+ bigdecimal (~> 3.1)
23
+ pry (0.14.2)
24
+ coderay (~> 1.1)
25
+ method_source (~> 1.0)
26
+ thor (1.3.2)
27
+
28
+ PLATFORMS
29
+ arm64-darwin-24
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bauble_core!
34
+ httparty (~> 0.22.0)
35
+ pry (~> 0.14.2)
36
+
37
+ BUNDLED WITH
38
+ 2.5.22
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ def world(event:, context:) # rubocop:disable Lint/UnusedMethodArgument
4
+ puts 'hello world'
5
+ end
@@ -0,0 +1,3 @@
1
+ {
2
+ "entrypoint": "infra/app.rb"
3
+ }
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bauble'
4
+ require 'pry'
5
+
6
+ Bauble::Application.new(
7
+ name: 'MyApp',
8
+ code_dir: 'app'
9
+ )
@@ -21,15 +21,17 @@ module Bauble
21
21
  :shared_code_dir,
22
22
  :shared_code_hash,
23
23
  :gem_layer_hash,
24
- :skip_gem_layer
24
+ :skip_gem_layer,
25
+ :s3_backend
25
26
  )
26
27
 
27
- def initialize(name:, code_dir:, stacks: [], skip_gem_layer: false)
28
+ def initialize(name:, code_dir:, stacks: [], skip_gem_layer: false, s3_backend: nil)
28
29
  # passed arguments
29
30
  @name = name
30
31
  @shared_code_dir = code_dir
31
32
  @stacks = []
32
33
  @skip_gem_layer = skip_gem_layer
34
+ @s3_backend = s3_backend
33
35
 
34
36
  # init others
35
37
  @resources = []
@@ -106,11 +108,13 @@ module Bauble
106
108
  end
107
109
 
108
110
  def base_template
109
- {
111
+ base_hash = {
110
112
  'name' => @name,
111
- 'runtime' => 'yaml',
112
- 'resources' => {}
113
+ 'runtime' => 'yaml'
113
114
  }
115
+ base_hash['backend'] = { 'url' => @s3_backend } if @s3_backend
116
+ base_hash['resources'] = {}
117
+ base_hash
114
118
  end
115
119
 
116
120
  def hash_of_dir(directory)
@@ -6,6 +6,7 @@ require 'json'
6
6
  require_relative 'commands/preview'
7
7
  require_relative 'commands/up'
8
8
  require_relative 'commands/destroy'
9
+ require_relative 'commands/new'
9
10
  require_relative 'pulumi'
10
11
  require_relative '../application'
11
12
 
@@ -16,6 +17,7 @@ module Bauble
16
17
  include Commands::Preview
17
18
  include Commands::Up
18
19
  include Commands::Destroy
20
+ include Commands::New
19
21
 
20
22
  attr_accessor :app, :config
21
23
 
@@ -42,6 +44,7 @@ module Bauble
42
44
  @config = Config.configure do |c|
43
45
  c.app_name = @app.name
44
46
  c.skip_gem_layer = @app.skip_gem_layer
47
+ c.s3_backend = @app.s3_backend
45
48
  end
46
49
  @app.config = @config
47
50
  end
@@ -30,7 +30,6 @@ module Bauble
30
30
  $CHILD_STATUS.success?
31
31
  end
32
32
 
33
- # TODO: Remove the need for this to install things from the sub dir
34
33
  def docker_build_gems_command(gem_path)
35
34
  command = DockerCommandBuilder
36
35
  .new
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'net/http'
4
+ require 'pry'
5
+ require 'thor'
6
+ require_relative '../pulumi'
7
+ require_relative '../logger'
8
+
9
+ module Bauble
10
+ module Cli
11
+ module Commands
12
+ # Up command
13
+ module New
14
+ class << self
15
+ def included(thor) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
16
+ thor.class_eval do # rubocop:disable Metrics/BlockLength
17
+ desc 'new [DESTINATION]', 'Scaffolds a new app from a GitHub repository'
18
+ map 'new' => :new_app
19
+ option :template, type: :string, default: 'basic-app',
20
+ desc: 'The template to use for the new app'
21
+
22
+ def new_app(destination)
23
+ github_repo = 'jamesh38/bauble'
24
+ specific_dir = "examples/#{options[:template]}"
25
+ dest_dir = destination ? "#{Dir.pwd}/#{destination}" : Dir.pwd
26
+ begin
27
+ uri = URI("https://api.github.com/repos/#{github_repo}/contents/#{specific_dir}")
28
+ fetch_and_write_files(uri, dest_dir, specific_dir)
29
+ rescue StandardError => e
30
+ Logger.error e.message
31
+ return
32
+ end
33
+ Logger.block_log 'New app created successfully'
34
+ end
35
+
36
+ no_commands do
37
+ def fetch_and_write_files(uri, destination, specific_dir) # rubocop:disable Metrics
38
+ response = Net::HTTP.get_response(uri)
39
+
40
+ if response.is_a?(Net::HTTPSuccess)
41
+ files = JSON.parse(response.body)
42
+
43
+ files.each do |file|
44
+ if file['type'] == 'file'
45
+ next if file['name'] == 'Gemfile.lock'
46
+
47
+ file_uri = URI(file['download_url'])
48
+ file_content = Net::HTTP.get(file_uri)
49
+ target_path = File.join(destination, file['path'].sub(specific_dir, ''))
50
+ FileUtils.mkdir_p(File.dirname(target_path))
51
+ File.write(target_path, file_content)
52
+ elsif file['type'] == 'dir'
53
+ new_uri = URI(file['url'])
54
+ fetch_and_write_files(new_uri, destination, specific_dir)
55
+ end
56
+ end
57
+ elsif response.is_a?(Net::HTTPNotFound)
58
+ raise 'Failed to create new app: Unknown template'
59
+ else
60
+ raise "Failed to to create new app: #{response.message}"
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -14,7 +14,8 @@ module Bauble
14
14
  :root_dir,
15
15
  :skip_gem_layer,
16
16
  :gem_layer_asset_dir,
17
- :shared_code_asset_dir
17
+ :shared_code_asset_dir,
18
+ :s3_backend
18
19
  )
19
20
 
20
21
  def initialize
@@ -27,6 +28,7 @@ module Bauble
27
28
  @app_stack_name = 'bauble'
28
29
  @debug = ENV['BAUBLE_DEBUG'] || false
29
30
  @skip_gem_layer = false
31
+ @s3_backend = nil
30
32
  set_pulumi_env_vars
31
33
  end
32
34
 
@@ -97,7 +97,9 @@ module Bauble
97
97
 
98
98
  def login
99
99
  Logger.debug 'Logging into pulumi locally...'
100
- run_command('login --local')
100
+ command = 'login'
101
+ command += ' --local' unless @config.s3_backend
102
+ run_command(command)
101
103
  end
102
104
 
103
105
  def pulumi_logged_in?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bauble
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bauble_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Hoegerl
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-22 00:00:00.000000000 Z
11
+ date: 2024-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -52,6 +52,16 @@ files:
52
52
  - CODE_OF_CONDUCT.md
53
53
  - LICENSE.txt
54
54
  - README.md
55
+ - examples/basic-app/Gemfile
56
+ - examples/basic-app/Gemfile.lock
57
+ - examples/basic-app/app/hello_world.rb
58
+ - examples/basic-app/bauble.json
59
+ - examples/basic-app/infra/app.rb
60
+ - examples/gem-dev-app/Gemfile
61
+ - examples/gem-dev-app/Gemfile.lock
62
+ - examples/gem-dev-app/app/hello.rb
63
+ - examples/gem-dev-app/bauble.json
64
+ - examples/gem-dev-app/infra/app.rb
55
65
  - exe/bauble
56
66
  - lib/bauble.rb
57
67
  - lib/bauble/application.rb
@@ -59,6 +69,7 @@ files:
59
69
  - lib/bauble/cli/cli.rb
60
70
  - lib/bauble/cli/code_bundler.rb
61
71
  - lib/bauble/cli/commands/destroy.rb
72
+ - lib/bauble/cli/commands/new.rb
62
73
  - lib/bauble/cli/commands/preview.rb
63
74
  - lib/bauble/cli/commands/up.rb
64
75
  - lib/bauble/cli/config.rb