rails_plan 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_plan/cli/fetch_branch.rb +17 -0
- data/lib/rails_plan/cli/fetch_template.rb +0 -1
- data/lib/rails_plan/cli/processor.rb +12 -4
- data/lib/rails_plan/version.rb +1 -1
- data/lib/rails_plan.rb +22 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e800d9904813591e2c13377191719763fdf89b6924de4483595bab720273e988
|
4
|
+
data.tar.gz: 0b960db29b50211a2ba51653db3a52869397be95e400482be4c8bd63fd797973
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d79af72fad1e7db9df46e8a7710dc78600f10aa33e589482c3c00367a8dd92af3496b376f05531874faa3d904855174015987662e569543d4bd742e8a2036c9
|
7
|
+
data.tar.gz: 790518e6748bc2c3211352c9da990ba234a9c77801edc0f3883405f9e558cac26034524451b0b401fcc574aa38623409b68122555cda247556a79da363b788f7
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsPlan
|
4
|
+
module Cli
|
5
|
+
class FetchBranch
|
6
|
+
API_URL = 'https://railsplan.com/api/v1'
|
7
|
+
|
8
|
+
def call(uid)
|
9
|
+
response = RestClient.get(API_URL + "/branches/#{uid}") { |res| res }
|
10
|
+
|
11
|
+
return if response.code != 200
|
12
|
+
|
13
|
+
JSON.parse(response.body)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RailsPlan
|
4
4
|
module Cli
|
5
5
|
class Processor
|
6
|
-
COMMANDS = %w[start].freeze
|
6
|
+
COMMANDS = %w[start apply].freeze
|
7
7
|
|
8
8
|
InvalidCommand = Class.new(StandardError)
|
9
9
|
InvalidUid = Class.new(StandardError)
|
@@ -16,9 +16,13 @@ module RailsPlan
|
|
16
16
|
def call
|
17
17
|
validate_command
|
18
18
|
|
19
|
-
raise InvalidUid, "Bootstrap plan not found for #{@uid}" if json_template.nil?
|
19
|
+
raise InvalidUid, "Bootstrap plan or feature not found for #{@uid}" if json_template.nil?
|
20
20
|
|
21
|
-
|
21
|
+
if @command == 'start'
|
22
|
+
::RailsPlan.start(json_template)
|
23
|
+
elsif @command == 'apply'
|
24
|
+
::RailsPlan.apply(json_template)
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
28
|
private
|
@@ -30,7 +34,11 @@ module RailsPlan
|
|
30
34
|
def json_template
|
31
35
|
return @json_template if defined?(@json_template)
|
32
36
|
|
33
|
-
@json_template =
|
37
|
+
@json_template = if @command == 'start'
|
38
|
+
::RailsPlan::Cli::FetchTemplate.new.call(@uid)
|
39
|
+
else
|
40
|
+
::RailsPlan::Cli::FetchBranch.new.call(@uid)
|
41
|
+
end
|
34
42
|
end
|
35
43
|
end
|
36
44
|
end
|
data/lib/rails_plan/version.rb
CHANGED
data/lib/rails_plan.rb
CHANGED
@@ -6,6 +6,7 @@ require 'fileutils'
|
|
6
6
|
require 'thor'
|
7
7
|
|
8
8
|
require 'rails_plan/cli/fetch_template'
|
9
|
+
require 'rails_plan/cli/fetch_branch'
|
9
10
|
require 'rails_plan/cli/processor'
|
10
11
|
require 'rails_plan/version'
|
11
12
|
require 'rails_plan/rails_app'
|
@@ -18,7 +19,7 @@ module RailsPlan
|
|
18
19
|
def start(template)
|
19
20
|
::RailsPlan::GemVersion.validate!
|
20
21
|
|
21
|
-
verify_rails_installation
|
22
|
+
# verify_rails_installation
|
22
23
|
|
23
24
|
generate_project(template)
|
24
25
|
generate_files(template['files'])
|
@@ -28,15 +29,23 @@ module RailsPlan
|
|
28
29
|
append_code(template['append_code'])
|
29
30
|
update_files(template['gsub'])
|
30
31
|
|
31
|
-
puts 'Time for coding! 🚀'
|
32
|
-
|
33
32
|
template['steps'].each do |step|
|
33
|
+
puts step['title'] if step['title']
|
34
34
|
run_commands(step['before_commands'])
|
35
35
|
generate_files(step['files'])
|
36
|
+
prepend_to_file(step['prepend_code'])
|
36
37
|
run_commands(step['after_commands'])
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
41
|
+
def apply(template)
|
42
|
+
puts template['title']
|
43
|
+
run_commands(template['before_commands'])
|
44
|
+
generate_files(template['files'])
|
45
|
+
prepend_to_file(template['prepend_code'])
|
46
|
+
run_commands(template['after_commands'])
|
47
|
+
end
|
48
|
+
|
40
49
|
private
|
41
50
|
|
42
51
|
def verify_rails_installation
|
@@ -77,6 +86,16 @@ module RailsPlan
|
|
77
86
|
end
|
78
87
|
end
|
79
88
|
|
89
|
+
def prepend_to_file(injections)
|
90
|
+
return if injections.nil? || injections.empty?
|
91
|
+
|
92
|
+
thor_app = ::RailsPlan::RailsApp.new
|
93
|
+
|
94
|
+
injections.each do |injection|
|
95
|
+
thor_app.insert_into_file(injection['file_path'], injection['content'], after: injection['after'])
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
80
99
|
def append_code(appends)
|
81
100
|
return if appends.nil? || appends.empty?
|
82
101
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_plan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
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-
|
11
|
+
date: 2024-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- README.md
|
50
50
|
- bin/rplan
|
51
51
|
- lib/rails_plan.rb
|
52
|
+
- lib/rails_plan/cli/fetch_branch.rb
|
52
53
|
- lib/rails_plan/cli/fetch_template.rb
|
53
54
|
- lib/rails_plan/cli/processor.rb
|
54
55
|
- lib/rails_plan/gem_version.rb
|