buildless-app 0.0.1 → 0.0.2

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: ed7567d1939f828c3b011bbcc080d8df4f58a58f00295b2a61a8e756641ac43c
4
- data.tar.gz: 6493c66df265e256b2de234c24493d284d1041b3b9138ed28a0abaeb4b605e20
3
+ metadata.gz: 9a17ef6c2aaa7cc1e8c0c6ca0849876cc5312d7696ee8801e4bfe08922c65d02
4
+ data.tar.gz: b7883b1ec3992ca998de9346bc31e7a7e6d8288546d243600db18eeacbe8e5bd
5
5
  SHA512:
6
- metadata.gz: fc104fb77713679fef8bb2d0de8e23e641eaad41d8be996ec8f50ac5557fa5ac772d80e4d0082283b628dfa8e7f0a3fb081eefd0dd09982e33c757d456680ad8
7
- data.tar.gz: 79bf6864adc583b2fc91c07826fc570c8cf4e0c48fc0c2e2a05d9f266cc576a1d7997cc31be47718d56809efc0b3b7f01d1d0798bec3a74a61fb96272a487086
6
+ metadata.gz: 54cf9ba6cc10f4a29dd745187bf6b788e47efc5033f5ff98a8cf319186dce026f7a698d4ed12389c5b8a9191fff73afaf1b302fe32053079148bc205a29eb67f
7
+ data.tar.gz: f764535a632957d3e16aa6d07c97cd38847ca944b588672d505cfea782b02a3dc5866da76151ff2410f1e31be05cfb9eb27d068784cde6281bd524071d16622b
data/bin/buildless CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ require 'buildless-app'
5
+
4
6
  command_line_arguments = ARGV.dup
5
7
 
6
- puts "Hello, world! Args: #{command_line_arguments}"
8
+ Buildless::Cli::Processor.new(command_line_arguments).call
@@ -25,5 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.metadata['bug_tracker_uri'] = 'https://github.com/pdabrowski6/buildless/issues'
26
26
  spec.metadata['rubygems_mfa_required'] = 'true'
27
27
 
28
+ spec.add_runtime_dependency 'rest-client', '2.1.0'
29
+
28
30
  spec.required_ruby_version = '>= 3.2.2'
29
31
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Buildless
4
+ module Cli
5
+ class FetchTemplate
6
+ COMMANDS = %w[apply].freeze
7
+ API_URL = 'https://buildless.app/api/v1'
8
+
9
+ def call(uid)
10
+ response = RestClient.get(API_URL + "/configurations/#{uid}") { |res| res }
11
+
12
+ return if response.code != 200
13
+
14
+ JSON.parse(response.body)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Buildless
4
+ module Cli
5
+ class Processor
6
+ COMMANDS = %w[apply].freeze
7
+
8
+ InvalidCommand = Class.new(StandardError)
9
+ InvalidUid = Class.new(StandardError)
10
+
11
+ def initialize(args)
12
+ @command = args[0]
13
+ @uid = args[1]
14
+ end
15
+
16
+ def call
17
+ validate_command
18
+
19
+ raise InvalidUid, "Configuration not found for #{@uid}" if json_template.nil?
20
+
21
+ ::Buildless.apply(json_template)
22
+ end
23
+
24
+ private
25
+
26
+ def validate_command
27
+ raise InvalidCommand, "command #{@command} is not supported!" unless COMMANDS.include?(@command.to_s.downcase)
28
+ end
29
+
30
+ def json_template
31
+ return @json_template if defined?(@json_template)
32
+
33
+ @json_template = ::Buildless::Cli::FetchTemplate.new.call(@uid)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Buildless
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
+ RAILS_VERSION = '7.1.3.2'
5
6
  end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rest-client'
4
+ require 'json'
5
+ require 'fileutils'
6
+
7
+ require 'buildless/cli/fetch_template'
8
+ require 'buildless/cli/processor'
9
+ require 'buildless/version'
10
+
11
+ module Buildless
12
+ RailsNotInstalled = Class.new(StandardError)
13
+
14
+ class << self
15
+ def apply(template)
16
+ verify_rails_installation
17
+ generate_project(template)
18
+ end
19
+
20
+ private
21
+
22
+ def verify_rails_installation
23
+ return if system("gem list ^rails$ --version #{Buildless::RAILS_VERSION} -i")
24
+
25
+ raise RailsNotInstalled, "Please install Rails #{Buildless::RAILS_VERSION} and retry"
26
+ end
27
+
28
+ def generate_project(template)
29
+ system template['installation_command']
30
+
31
+ Dir.chdir(template['name'])
32
+ end
33
+ end
34
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildless-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paweł Dąbrowski
@@ -9,7 +9,21 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2024-03-24 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.0
13
27
  description: Speed up Rails app bootstraping
14
28
  email:
15
29
  - contact@paweldabrowski.com
@@ -21,7 +35,9 @@ files:
21
35
  - README.md
22
36
  - bin/buildless
23
37
  - buildless-app.gemspec
24
- - lib/buildless.rb
38
+ - lib/buildless-app.rb
39
+ - lib/buildless/cli/fetch_template.rb
40
+ - lib/buildless/cli/processor.rb
25
41
  - lib/buildless/version.rb
26
42
  homepage: https://buildless.app
27
43
  licenses:
data/lib/buildless.rb DELETED
File without changes