rails_plan 0.0.5 → 0.0.6
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 +4 -4
- data/lib/rails_plan/cli/fetch_template.rb +3 -9
- data/lib/rails_plan/cli/processor.rb +4 -12
- data/lib/rails_plan/version.rb +1 -2
- data/lib/rails_plan.rb +6 -107
- metadata +2 -19
- data/lib/rails_plan/cli/fetch_branch.rb +0 -17
- data/lib/rails_plan/gem_version.rb +0 -13
- data/lib/rails_plan/rails_app.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 969195f7b64b0ef75ccf58680888c53b11ba90802ed85c73b67e00069b6595c0
|
4
|
+
data.tar.gz: 5e14518c6e60047d2c0c301d825b0be45c227e8f2eafe21fb5d5320f918c18e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1f65c034266e92e2e21e44a54aa36698fb066312fd65ee895c522194abba62228e3657c57660d0798375b6d7d5964098188b7992b13e792319a154d76d6599e
|
7
|
+
data.tar.gz: 8f809791401f24dbb6df1f9b42fc82ed320c8311bddc7f3b045c3cfc52b8e71caa70d3aa9b23996c2a889c01395d0523208618ac88549d365e0ec519d7879de6
|
@@ -3,22 +3,16 @@
|
|
3
3
|
module RailsPlan
|
4
4
|
module Cli
|
5
5
|
class FetchTemplate
|
6
|
-
API_URL = 'https://railsplan.com/api/v1'
|
6
|
+
# API_URL = 'https://railsplan.com/api/v1'
|
7
|
+
API_URL = 'http://localhost:3000/api/v1'
|
7
8
|
|
8
9
|
def call(uid)
|
9
|
-
response = RestClient.get(API_URL + "/
|
10
|
+
response = RestClient.get(API_URL + "/plans/#{uid}") { |res| res }
|
10
11
|
|
11
12
|
return if response.code != 200
|
12
13
|
|
13
14
|
JSON.parse(response.body)
|
14
15
|
end
|
15
|
-
|
16
|
-
def gem_version
|
17
|
-
response = RestClient.get(API_URL + "/bootstrap_plans/gem_current_version")
|
18
|
-
parsed_response = JSON.parse(response.body)
|
19
|
-
|
20
|
-
parsed_response['version']
|
21
|
-
end
|
22
16
|
end
|
23
17
|
end
|
24
18
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RailsPlan
|
4
4
|
module Cli
|
5
5
|
class Processor
|
6
|
-
COMMANDS = %w[
|
6
|
+
COMMANDS = %w[build].freeze
|
7
7
|
|
8
8
|
InvalidCommand = Class.new(StandardError)
|
9
9
|
InvalidUid = Class.new(StandardError)
|
@@ -16,13 +16,9 @@ module RailsPlan
|
|
16
16
|
def call
|
17
17
|
validate_command
|
18
18
|
|
19
|
-
raise InvalidUid, "
|
19
|
+
raise InvalidUid, "Plan not found for #{@uid}" if json_template.nil?
|
20
20
|
|
21
|
-
|
22
|
-
::RailsPlan.start(json_template)
|
23
|
-
elsif @command == 'apply'
|
24
|
-
::RailsPlan.apply(json_template)
|
25
|
-
end
|
21
|
+
::RailsPlan.build(json_template)
|
26
22
|
end
|
27
23
|
|
28
24
|
private
|
@@ -34,11 +30,7 @@ module RailsPlan
|
|
34
30
|
def json_template
|
35
31
|
return @json_template if defined?(@json_template)
|
36
32
|
|
37
|
-
@json_template =
|
38
|
-
::RailsPlan::Cli::FetchTemplate.new.call(@uid)
|
39
|
-
else
|
40
|
-
::RailsPlan::Cli::FetchBranch.new.call(@uid)
|
41
|
-
end
|
33
|
+
@json_template = ::RailsPlan::Cli::FetchTemplate.new.call(@uid)
|
42
34
|
end
|
43
35
|
end
|
44
36
|
end
|
data/lib/rails_plan/version.rb
CHANGED
data/lib/rails_plan.rb
CHANGED
@@ -3,125 +3,24 @@
|
|
3
3
|
require 'rest-client'
|
4
4
|
require 'json'
|
5
5
|
require 'fileutils'
|
6
|
-
require 'thor'
|
7
6
|
|
8
7
|
require 'rails_plan/cli/fetch_template'
|
9
|
-
require 'rails_plan/cli/fetch_branch'
|
10
8
|
require 'rails_plan/cli/processor'
|
11
9
|
require 'rails_plan/version'
|
12
|
-
require 'rails_plan/rails_app'
|
13
|
-
require 'rails_plan/gem_version'
|
14
10
|
|
15
11
|
module RailsPlan
|
16
|
-
RailsNotInstalled = Class.new(StandardError)
|
17
|
-
|
18
12
|
class << self
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
generate_project(template)
|
25
|
-
generate_files(template['files'])
|
26
|
-
run_commands(template['before_commands'])
|
27
|
-
clone_files(template['clones'])
|
28
|
-
inject_code(template['inject_code'])
|
29
|
-
append_code(template['append_code'])
|
30
|
-
update_files(template['gsub'])
|
31
|
-
|
32
|
-
template['steps'].each do |step|
|
33
|
-
puts step['title'] if step['title']
|
34
|
-
run_commands(step['before_commands'])
|
35
|
-
generate_files(step['files'])
|
36
|
-
prepend_to_file(step['prepend_code'])
|
37
|
-
run_commands(step['after_commands'])
|
38
|
-
end
|
39
|
-
end
|
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
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def verify_rails_installation
|
52
|
-
return if system("gem list ^rails$ --version #{RailsPlan::RAILS_VERSION} -i")
|
53
|
-
|
54
|
-
raise RailsNotInstalled, "Please install Rails #{RailsPlan::RAILS_VERSION} and retry"
|
55
|
-
end
|
13
|
+
def build(files)
|
14
|
+
dir_name = "rails_plan_app-#{Time.now.strftime('%Y%m%d%H%M%S')}"
|
15
|
+
FileUtils.mkdir_p(dir_name)
|
16
|
+
Dir.chdir(dir_name)
|
56
17
|
|
57
|
-
def generate_project(template)
|
58
|
-
system template['installation_command']
|
59
|
-
|
60
|
-
Dir.chdir(template['name'])
|
61
|
-
end
|
62
|
-
|
63
|
-
def generate_files(files)
|
64
18
|
files.each do |file|
|
65
|
-
puts "-> \e[1;32;49mCreate\e[0m #{file['
|
66
|
-
file_path = File.join(Dir.pwd, file['
|
19
|
+
puts "-> \e[1;32;49mCreate\e[0m #{file['path']}"
|
20
|
+
file_path = File.join(Dir.pwd, file['path'])
|
67
21
|
FileUtils.mkdir_p(File.dirname(file_path))
|
68
22
|
File.write(file_path, file['content'])
|
69
23
|
end
|
70
24
|
end
|
71
|
-
|
72
|
-
def run_commands(commands)
|
73
|
-
commands.each do |command|
|
74
|
-
puts "-> \e[1;32;49mRun\e[0m #{command}"
|
75
|
-
system command
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def inject_code(injections)
|
80
|
-
return if injections.nil? || injections.empty?
|
81
|
-
|
82
|
-
thor_app = ::RailsPlan::RailsApp.new
|
83
|
-
|
84
|
-
injections.each do |injection|
|
85
|
-
thor_app.inject_into_class(injection['file_path'], injection['class_name'], injection['content'])
|
86
|
-
end
|
87
|
-
end
|
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
|
-
|
99
|
-
def append_code(appends)
|
100
|
-
return if appends.nil? || appends.empty?
|
101
|
-
|
102
|
-
thor_app = ::RailsPlan::RailsApp.new
|
103
|
-
|
104
|
-
appends.each do |append|
|
105
|
-
thor_app.append_to_file(append['file_path'], append['content'])
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def update_files(updates)
|
110
|
-
return if updates.nil? || updates.empty?
|
111
|
-
|
112
|
-
thor_app = ::RailsPlan::RailsApp.new
|
113
|
-
|
114
|
-
updates.each do |update|
|
115
|
-
thor_app.gsub_file(update['file_path'], update['pattern'], update['value'])
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def clone_files(files)
|
120
|
-
return if files.nil? || files.empty?
|
121
|
-
|
122
|
-
files.each do |file|
|
123
|
-
FileUtils.cp(file['from'], file['to'])
|
124
|
-
end
|
125
|
-
end
|
126
25
|
end
|
127
26
|
end
|
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.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-
|
11
|
+
date: 2024-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -24,20 +24,6 @@ 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
|
41
27
|
description: Speed up Rails app planning and development process
|
42
28
|
email:
|
43
29
|
- contact@paweldabrowski.com
|
@@ -49,11 +35,8 @@ files:
|
|
49
35
|
- README.md
|
50
36
|
- bin/rplan
|
51
37
|
- lib/rails_plan.rb
|
52
|
-
- lib/rails_plan/cli/fetch_branch.rb
|
53
38
|
- lib/rails_plan/cli/fetch_template.rb
|
54
39
|
- lib/rails_plan/cli/processor.rb
|
55
|
-
- lib/rails_plan/gem_version.rb
|
56
|
-
- lib/rails_plan/rails_app.rb
|
57
40
|
- lib/rails_plan/version.rb
|
58
41
|
homepage: https://railsplan.com
|
59
42
|
licenses:
|
@@ -1,17 +0,0 @@
|
|
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
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module RailsPlan
|
2
|
-
class GemVersion
|
3
|
-
NotUpdatedGem = Class.new(StandardError)
|
4
|
-
|
5
|
-
def self.validate!
|
6
|
-
newest_version = RailsPlan::Cli::FetchTemplate.new.gem_version
|
7
|
-
|
8
|
-
return if system("gem list ^rails_plan$ --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
|