buildless-app 0.0.4 → 0.0.6

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: 6e37691927afe6386fbbe83ce9e479ff306106f16af92eef485acf5b7c39f791
4
- data.tar.gz: a01031d0bf2835bcfc974184527a3c4d715b1c1753ff1167ab72d3b51dd716a6
3
+ metadata.gz: 6ad8d64dfbc8635e93004addff1b880a120a0a52e2f1968da4d920f7a8d92817
4
+ data.tar.gz: 18d3a7c60d2ec635c14f04126d4d0fe100c27580ea245aa23966cedee281ac6b
5
5
  SHA512:
6
- metadata.gz: 86f1056a239d782c8e069f66db52b0de67260d70721861b88f604102755ebca9f7a8118e18b26f717446ef33ab95d1fe2970fac16a1be5d46d9c99976c88b076
7
- data.tar.gz: 3863c1f95ead8c3f5cfb53e285586951b4b073c58071b4d56d275bdd991553596cd3871a90a1aeda76dc500961f3598409a0499da8991f0480f146b8b4d72fa8
6
+ metadata.gz: 892efe4ea39105f50755518815701d0652c18b091f94a09ca2f10da36b234f06f4a7d3648fc88602ab5205a21667936acd90162a39b3beb261152a2a70650f5f
7
+ data.tar.gz: c3a73b8ca037ade6d2de193446a074d2c7402c9121d21936859abf9daa2e8f19d2c865d025ba90c96dd4ca08e68d3a98a164ffb2d649d5dd7104d2ceb017c5ad
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.metadata['rubygems_mfa_required'] = 'true'
27
27
 
28
28
  spec.add_runtime_dependency 'rest-client', '2.1.0'
29
+ spec.add_runtime_dependency 'thor', '1.3.1'
29
30
 
30
31
  spec.required_ruby_version = '>= 3.2.2'
31
32
  end
@@ -13,6 +13,13 @@ module Buildless
13
13
 
14
14
  JSON.parse(response.body)
15
15
  end
16
+
17
+ def gem_version
18
+ response = RestClient.get(API_URL + "/configurations/gem_current_version")
19
+ parsed_response = JSON.parse(response.body)
20
+
21
+ parsed_response['version']
22
+ end
16
23
  end
17
24
  end
18
25
  end
@@ -0,0 +1,13 @@
1
+ module Buildless
2
+ class GemVersion
3
+ NotUpdatedGem = Class.new(StandardError)
4
+
5
+ def self.validate!
6
+ newest_version = Buildless::Cli::FetchTemplate.new.gem_version
7
+
8
+ return if system("gem list ^buildless-app$ --version #{newest_version} -i")
9
+
10
+ raise NotUpdatedGem, "Please update the gem to newest version #{newest_version} and retry"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ module Buildless
2
+ class RailsApp < Thor
3
+ include Thor::Actions
4
+
5
+ def self.source_root
6
+ File.dirname(__FILE__)
7
+ end
8
+ end
9
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Buildless
4
- VERSION = '0.0.4'
4
+ VERSION = '0.0.6'
5
5
  RAILS_VERSION = '7.1.3.2'
6
6
  end
data/lib/buildless-app.rb CHANGED
@@ -3,19 +3,30 @@
3
3
  require 'rest-client'
4
4
  require 'json'
5
5
  require 'fileutils'
6
+ require 'thor'
6
7
 
7
8
  require 'buildless/cli/fetch_template'
8
9
  require 'buildless/cli/processor'
9
10
  require 'buildless/version'
11
+ require 'buildless/rails_app'
12
+ require 'buildless/gem_version'
10
13
 
11
14
  module Buildless
12
15
  RailsNotInstalled = Class.new(StandardError)
13
16
 
14
17
  class << self
15
18
  def apply(template)
19
+ ::Buildless::GemVersion.validate!
20
+
16
21
  verify_rails_installation
17
22
  generate_project(template)
18
23
  generate_files(template['files'])
24
+ run_bundle_commands(template['bundle_commands'])
25
+ clone_files(template['clones'])
26
+ inject_code(template['inject_code'])
27
+ append_code(template['append_code'])
28
+
29
+ puts 'Time for coding! 🚀'
19
30
  end
20
31
 
21
32
  private
@@ -40,5 +51,39 @@ module Buildless
40
51
  File.write(file_path, file['content'])
41
52
  end
42
53
  end
54
+
55
+ def run_bundle_commands(commands)
56
+ commands.each do |command|
57
+ system command
58
+ end
59
+ end
60
+
61
+ def inject_code(injections)
62
+ return if injections.nil? || injections.empty?
63
+
64
+ thor_app = ::Buildless::RailsApp.new
65
+
66
+ injections.each do |injection|
67
+ thor_app.inject_into_class(injection['file_path'], injection['class_name'], injection['content'])
68
+ end
69
+ end
70
+
71
+ def append_code(appends)
72
+ return if appends.nil? || appends.empty?
73
+
74
+ thor_app = ::Buildless::RailsApp.new
75
+
76
+ appends.each do |append|
77
+ thor_app.append_to_file(append['file_path'], append['content'])
78
+ end
79
+ end
80
+
81
+ def clone_files(files)
82
+ return if files.nil? || files.empty?
83
+
84
+ files.each do |file|
85
+ FileUtils.cp(file['from'], file['to'])
86
+ end
87
+ end
43
88
  end
44
89
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildless-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paweł Dąbrowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-24 00:00:00.000000000 Z
11
+ date: 2024-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.1
27
41
  description: Speed up Rails app bootstraping
28
42
  email:
29
43
  - contact@paweldabrowski.com
@@ -38,6 +52,8 @@ files:
38
52
  - lib/buildless-app.rb
39
53
  - lib/buildless/cli/fetch_template.rb
40
54
  - lib/buildless/cli/processor.rb
55
+ - lib/buildless/gem_version.rb
56
+ - lib/buildless/rails_app.rb
41
57
  - lib/buildless/version.rb
42
58
  homepage: https://buildless.app
43
59
  licenses: