bard 1.5.2 → 1.5.4
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/bard/cli/new.rb +34 -7
- data/lib/bard/cli/new_rails_template.rb +1 -1
- data/lib/bard/version.rb +1 -1
- data/spec/bard/cli/new_spec.rb +14 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ecd823956fef238023d672971dd80049518eb8f3408383132db92077ddabe957
|
|
4
|
+
data.tar.gz: 6a69bcac5891b545fabec4009b7b84148a1448fe62567813e8377e963791099a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ea3c080d440a8cd560f713951f9ec5052a89cb9b1dfc0194f02e49f13623c8292379fcc47f6e90d3f1971c9b37e9a33a15e0f357d88a2428e11bd0af202bbc4
|
|
7
|
+
data.tar.gz: cda529a9823733f871fb8f2274c39790e69b142317f016168643e908e75c8551b11437e8fa478b84cec84584331951d8c5c79a3935ced531f2154b556e4700c8
|
data/lib/bard/cli/new.rb
CHANGED
|
@@ -27,20 +27,47 @@ class Bard::CLI::New < Bard::CLI::Command
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def create_project
|
|
30
|
-
run!
|
|
30
|
+
run! build_create_project_script
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def build_create_project_script
|
|
34
|
+
build_bash_env do
|
|
35
|
+
build_rvm_setup +
|
|
36
|
+
build_gem_install("rails", RAILS_REQUIREMENT) +
|
|
37
|
+
build_rails_new
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def build_bash_env
|
|
42
|
+
script = yield
|
|
43
|
+
<<~SH
|
|
31
44
|
env -i bash -lc '
|
|
32
45
|
export HOME=~
|
|
33
|
-
cd ..
|
|
34
46
|
source ~/.rvm/scripts/rvm
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
gem install rails -v "#{RAILS_REQUIREMENT}" --no-document
|
|
38
|
-
RAILS_VERSION=$(ruby -e "spec = Gem::Specification.find_by_name 'rails', '#{RAILS_REQUIREMENT}'; puts spec.version")
|
|
39
|
-
rails _${RAILS_VERSION}_ new #{project_name} --skip-git --skip-kamal --skip-test -m #{template_path}
|
|
47
|
+
#{script}
|
|
40
48
|
'
|
|
41
49
|
SH
|
|
42
50
|
end
|
|
43
51
|
|
|
52
|
+
def build_rvm_setup
|
|
53
|
+
<<~SH
|
|
54
|
+
cd ..
|
|
55
|
+
rvm use --create #{ruby_version}@#{project_name}
|
|
56
|
+
SH
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def build_gem_install(gem_name, version_requirement)
|
|
60
|
+
<<~SH
|
|
61
|
+
GEM_VERSION=$(gem install #{gem_name} -v \"#{version_requirement}\" --no-document 2>&1 | grep -oP \"Successfully installed #{gem_name}-\\K[0-9.]+\")
|
|
62
|
+
SH
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def build_rails_new
|
|
66
|
+
<<~SH
|
|
67
|
+
rails _${GEM_VERSION}_ new #{project_name} --skip-git --skip-kamal --skip-test -m #{template_path}
|
|
68
|
+
SH
|
|
69
|
+
end
|
|
70
|
+
|
|
44
71
|
def push_to_github
|
|
45
72
|
api = Bard::Github.new(project_name)
|
|
46
73
|
api.create_repo
|
data/lib/bard/version.rb
CHANGED
data/spec/bard/cli/new_spec.rb
CHANGED
|
@@ -57,4 +57,17 @@ describe Bard::CLI::New do
|
|
|
57
57
|
expect(new_cli.send(:template_path)).to match(/new_rails_template\.rb$/)
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
|
-
|
|
60
|
+
|
|
61
|
+
describe "#install_and_extract_version" do
|
|
62
|
+
it "correctly installs a gem and extracts its version" do
|
|
63
|
+
cmd = new_cli.send :build_bash_env do
|
|
64
|
+
<<~SH
|
|
65
|
+
#{new_cli.send(:build_gem_install, "bundler", "~> 2.0")}
|
|
66
|
+
echo ${GEM_VERSION}
|
|
67
|
+
SH
|
|
68
|
+
end
|
|
69
|
+
result = `#{cmd}`.strip
|
|
70
|
+
expect(result).to match(/^2\.\d+\.\d+/)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|