bosh-plugin-pipeline 0.2.0

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.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/.rmvrc +1 -0
  4. data/.rspec +3 -0
  5. data/.travis.yml +9 -0
  6. data/Gemfile +8 -0
  7. data/Gemfile.lock +260 -0
  8. data/README.md +61 -0
  9. data/Rakefile +5 -0
  10. data/bosh-plugin-pipeline.gemspec +38 -0
  11. data/lib/bosh/bosh_version_updater/helpers.rb +92 -0
  12. data/lib/bosh/bosh_version_updater.rb +11 -0
  13. data/lib/bosh/cli/commands/bosh_version_updater.rb +27 -0
  14. data/lib/bosh/cli/commands/plugin_generator.rb +26 -0
  15. data/lib/bosh/plugin_generator/generator.rb +29 -0
  16. data/lib/bosh/plugin_generator/helpers.rb +106 -0
  17. data/lib/bosh/plugin_generator.rb +11 -0
  18. data/lib/bosh/plugin_pipeline/version.rb +5 -0
  19. data/spec/assets/simple-template.txt +3 -0
  20. data/spec/plugin_generator/generator_spec.rb +25 -0
  21. data/spec/plugin_generator_spec.rb +85 -0
  22. data/spec/spec_helper.rb +17 -0
  23. data/templates/.gitignore +36 -0
  24. data/templates/.ruby-gemset.erb +1 -0
  25. data/templates/.ruby-version.erb +1 -0
  26. data/templates/.travis.yml +6 -0
  27. data/templates/Gemfile +4 -0
  28. data/templates/README.md.erb +33 -0
  29. data/templates/Rakefile +5 -0
  30. data/templates/cli/commands/command.rb.erb +14 -0
  31. data/templates/gemspec.erb +36 -0
  32. data/templates/helpers_folder/helpers.rb.erb +11 -0
  33. data/templates/helpers_folder/version.rb.erb +5 -0
  34. data/templates/licenses/apache2.txt +13 -0
  35. data/templates/licenses/gpl.txt +15 -0
  36. data/templates/licenses/lgpl.txt +8 -0
  37. data/templates/licenses/mit.txt +21 -0
  38. data/templates/main.rb.erb +11 -0
  39. data/templates/spec/.rspec +3 -0
  40. data/templates/spec/command_spec.rb +11 -0
  41. data/templates/spec/spec_helper.rb +12 -0
  42. metadata +257 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9089f9dc8c810a6d5da790fb00fbee117b531e9e
4
+ data.tar.gz: 281dbf6141bcf7b4a3935e68777fe6f388202cf5
5
+ SHA512:
6
+ metadata.gz: 956e22c11d04394b5bec843165d4a7c94a33e535710ee21064d48ae5f8a8e6b336505f1cc006eead833496792be32963500a7af7fbc705a5f5525059382f13b2
7
+ data.tar.gz: cf2fc8bf2bbb464a271b60bdf594151527092f834e77e097d34a4a5c1921b8608d5085c87a25850664d6a69af3100f71b5bc8bfe9aee5366f88c05616771ac51
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ tmp
2
+ .rvmrc
3
+ .ruby-gemset
4
+ .ruby-version
5
+ magic
6
+ bosh-plugin-pipeline-*.gem
data/.rmvrc ADDED
@@ -0,0 +1 @@
1
+ rvm use --create 2.1.5@bosh-plugin-generator
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format progress
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ before_install:
3
+ - sudo apt-get update -qq --fix-missing
4
+ - sudo apt-get install -qq git
5
+ - "git config --global user.name git-user && git config --global user.email git-user@mail.com"
6
+ rvm:
7
+ - 2.2.0
8
+ - 2.1.5
9
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bosh-plugin.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'pry-byebug'
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,260 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bosh-plugin-pipeline (0.1.0)
5
+ bosh-versions (~> 0.1.1)
6
+ bosh_cli (>= 1.3098.0)
7
+ bosh_common (>= 1.3098.0)
8
+ erubis (~> 2.7.0)
9
+ git (~> 1.2.6)
10
+ membrane (~> 1.1.0)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ CFPropertyList (2.3.2)
16
+ ast (2.1.0)
17
+ astrolabe (1.3.1)
18
+ parser (~> 2.2)
19
+ aws-sdk (1.60.2)
20
+ aws-sdk-v1 (= 1.60.2)
21
+ aws-sdk-v1 (1.60.2)
22
+ json (~> 1.4)
23
+ nokogiri (>= 1.4.4)
24
+ blobstore_client (1.3098.0)
25
+ aws-sdk (= 1.60.2)
26
+ bosh_common (~> 1.3098.0)
27
+ fog (~> 1.31.0)
28
+ fog-aws (<= 0.1.1)
29
+ httpclient (= 2.4.0)
30
+ multi_json (~> 1.1)
31
+ bosh-template (1.3098.0)
32
+ semi_semantic (~> 1.1.0)
33
+ bosh-versions (0.1.1)
34
+ bosh_cli (>= 1.3098.0)
35
+ bosh_common (>= 1.3098.0)
36
+ membrane (~> 1.1.0)
37
+ rest-client (~> 1.8.0)
38
+ rubygems_api (~> 1.0.1)
39
+ bosh_cli (1.3098.0)
40
+ blobstore_client (~> 1.3098.0)
41
+ bosh-template (~> 1.3098.0)
42
+ bosh_common (~> 1.3098.0)
43
+ cf-uaa-lib (~> 3.2.1)
44
+ highline (~> 1.6.2)
45
+ httpclient (= 2.4.0)
46
+ json_pure (~> 1.7)
47
+ minitar (~> 0.5.4)
48
+ net-scp (~> 1.1.0)
49
+ net-ssh (>= 2.2.1)
50
+ net-ssh-gateway (~> 1.2.0)
51
+ netaddr (~> 1.5.0)
52
+ progressbar (~> 0.9.0)
53
+ sshkey (~> 1.7.0)
54
+ terminal-table (~> 1.4.3)
55
+ bosh_common (1.3098.0)
56
+ logging (~> 1.8.2)
57
+ semi_semantic (~> 1.1.0)
58
+ builder (3.2.2)
59
+ byebug (5.0.0)
60
+ columnize (= 0.9.0)
61
+ cf-uaa-lib (3.2.4)
62
+ multi_json
63
+ coderay (1.1.0)
64
+ columnize (0.9.0)
65
+ diff-lcs (1.2.5)
66
+ domain_name (0.5.25)
67
+ unf (>= 0.0.5, < 1.0.0)
68
+ erubis (2.7.0)
69
+ excon (0.45.4)
70
+ fission (0.5.0)
71
+ CFPropertyList (~> 2.2)
72
+ fog (1.31.0)
73
+ fog-atmos
74
+ fog-aws (~> 0.0)
75
+ fog-brightbox (~> 0.4)
76
+ fog-core (~> 1.30)
77
+ fog-ecloud
78
+ fog-google (>= 0.0.2)
79
+ fog-json
80
+ fog-local
81
+ fog-powerdns (>= 0.1.1)
82
+ fog-profitbricks
83
+ fog-radosgw (>= 0.0.2)
84
+ fog-riakcs
85
+ fog-sakuracloud (>= 0.0.4)
86
+ fog-serverlove
87
+ fog-softlayer
88
+ fog-storm_on_demand
89
+ fog-terremark
90
+ fog-vmfusion
91
+ fog-voxel
92
+ fog-xml (~> 0.1.1)
93
+ ipaddress (~> 0.5)
94
+ nokogiri (~> 1.5, >= 1.5.11)
95
+ fog-atmos (0.1.0)
96
+ fog-core
97
+ fog-xml
98
+ fog-aws (0.1.1)
99
+ fog-core (~> 1.27)
100
+ fog-json (~> 1.0)
101
+ fog-xml (~> 0.1)
102
+ ipaddress (~> 0.8)
103
+ fog-brightbox (0.9.0)
104
+ fog-core (~> 1.22)
105
+ fog-json
106
+ inflecto (~> 0.0.2)
107
+ fog-core (1.32.1)
108
+ builder
109
+ excon (~> 0.45)
110
+ formatador (~> 0.2)
111
+ mime-types
112
+ net-scp (~> 1.1)
113
+ net-ssh (>= 2.1.3)
114
+ fog-ecloud (0.3.0)
115
+ fog-core
116
+ fog-xml
117
+ fog-google (0.1.1)
118
+ fog-core
119
+ fog-json
120
+ fog-xml
121
+ fog-json (1.0.2)
122
+ fog-core (~> 1.0)
123
+ multi_json (~> 1.10)
124
+ fog-local (0.2.1)
125
+ fog-core (~> 1.27)
126
+ fog-powerdns (0.1.1)
127
+ fog-core (~> 1.27)
128
+ fog-json (~> 1.0)
129
+ fog-xml (~> 0.1)
130
+ fog-profitbricks (0.0.5)
131
+ fog-core
132
+ fog-xml
133
+ nokogiri
134
+ fog-radosgw (0.0.4)
135
+ fog-core (>= 1.21.0)
136
+ fog-json
137
+ fog-xml (>= 0.0.1)
138
+ fog-riakcs (0.1.0)
139
+ fog-core
140
+ fog-json
141
+ fog-xml
142
+ fog-sakuracloud (1.3.3)
143
+ fog-core
144
+ fog-json
145
+ fog-serverlove (0.1.2)
146
+ fog-core
147
+ fog-json
148
+ fog-softlayer (0.4.7)
149
+ fog-core
150
+ fog-json
151
+ fog-storm_on_demand (0.1.1)
152
+ fog-core
153
+ fog-json
154
+ fog-terremark (0.1.0)
155
+ fog-core
156
+ fog-xml
157
+ fog-vmfusion (0.1.0)
158
+ fission
159
+ fog-core
160
+ fog-voxel (0.1.0)
161
+ fog-core
162
+ fog-xml
163
+ fog-xml (0.1.2)
164
+ fog-core
165
+ nokogiri (~> 1.5, >= 1.5.11)
166
+ formatador (0.2.5)
167
+ git (1.2.9.1)
168
+ highline (1.6.21)
169
+ http-cookie (1.0.2)
170
+ domain_name (~> 0.5)
171
+ httpclient (2.4.0)
172
+ hurley (0.2)
173
+ inflecto (0.0.2)
174
+ ipaddress (0.8.0)
175
+ json (1.8.3)
176
+ json_pure (1.8.2)
177
+ little-plugger (1.1.4)
178
+ logging (1.8.2)
179
+ little-plugger (>= 1.1.3)
180
+ multi_json (>= 1.8.4)
181
+ membrane (1.1.0)
182
+ method_source (0.8.2)
183
+ mime-types (2.6.2)
184
+ mini_portile (0.6.2)
185
+ minitar (0.5.4)
186
+ multi_json (1.11.2)
187
+ net-scp (1.1.2)
188
+ net-ssh (>= 2.6.5)
189
+ net-ssh (3.0.1)
190
+ net-ssh-gateway (1.2.0)
191
+ net-ssh (>= 2.6.5)
192
+ netaddr (1.5.0)
193
+ netrc (0.10.3)
194
+ nokogiri (1.6.6.2)
195
+ mini_portile (~> 0.6.0)
196
+ parser (2.2.2.6)
197
+ ast (>= 1.1, < 3.0)
198
+ powerpack (0.1.1)
199
+ progressbar (0.9.2)
200
+ pry (0.10.2)
201
+ coderay (~> 1.1.0)
202
+ method_source (~> 0.8.1)
203
+ slop (~> 3.4)
204
+ pry-byebug (3.2.0)
205
+ byebug (~> 5.0)
206
+ pry (~> 0.10)
207
+ rainbow (2.0.0)
208
+ rake (10.4.2)
209
+ rest-client (1.8.0)
210
+ http-cookie (>= 1.0.2, < 2.0)
211
+ mime-types (>= 1.16, < 3.0)
212
+ netrc (~> 0.7)
213
+ rspec (3.3.0)
214
+ rspec-core (~> 3.3.0)
215
+ rspec-expectations (~> 3.3.0)
216
+ rspec-mocks (~> 3.3.0)
217
+ rspec-core (3.3.2)
218
+ rspec-support (~> 3.3.0)
219
+ rspec-expectations (3.3.1)
220
+ diff-lcs (>= 1.2.0, < 2.0)
221
+ rspec-support (~> 3.3.0)
222
+ rspec-its (1.2.0)
223
+ rspec-core (>= 3.0.0)
224
+ rspec-expectations (>= 3.0.0)
225
+ rspec-mocks (3.3.2)
226
+ diff-lcs (>= 1.2.0, < 2.0)
227
+ rspec-support (~> 3.3.0)
228
+ rspec-support (3.3.0)
229
+ rubocop (0.34.2)
230
+ astrolabe (~> 1.3)
231
+ parser (>= 2.2.2.5, < 3.0)
232
+ powerpack (~> 0.1)
233
+ rainbow (>= 1.99.1, < 3.0)
234
+ ruby-progressbar (~> 1.4)
235
+ ruby-progressbar (1.7.5)
236
+ rubygems_api (1.0.1)
237
+ hurley (~> 0)
238
+ semi_semantic (1.1.0)
239
+ slop (3.6.0)
240
+ sshkey (1.7.0)
241
+ terminal-table (1.4.5)
242
+ unf (0.1.4)
243
+ unf_ext
244
+ unf_ext (0.0.7.1)
245
+
246
+ PLATFORMS
247
+ ruby
248
+
249
+ DEPENDENCIES
250
+ bosh-plugin-pipeline!
251
+ bundler (~> 1.10)
252
+ pry-byebug
253
+ rake
254
+ rspec (~> 3.3.0)
255
+ rspec-its (~> 1.2.0)
256
+ rspec-mocks
257
+ rubocop
258
+
259
+ BUNDLED WITH
260
+ 1.10.6
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # Bosh plugin pipeline
2
+ [![Build Status](https://travis-ci.org/Altoros/bosh-plugin-pipeline.svg?branch=master)](https://travis-ci.org/Altoros/bosh-plugin-pipeline)
3
+
4
+ This gem allows to create a file system tree structure for BOSH plugin and to update BOSH version in this plugin automatically. The project is build using [bosh-plugin-generator](https://github.com/Altoros/bosh-plugin-generator), that is no deprecated.
5
+
6
+ ## What is BOSH?
7
+
8
+ BOSH orchestrates initial deployments and ongoing updates that are: predictable, repeatable, reliable, self-healing, infrastructure-agnostic. You can take a look on [BOSH project on GitHub](https://github.com/cloudfoundry/bosh) and read more details in [docs](http://docs.cloudfoundry.org/bosh/).
9
+
10
+ ## How to install
11
+
12
+ ```
13
+ gem install bosh-plugin-pipeline
14
+ ```
15
+
16
+ ## How to use
17
+
18
+ ### Generating a BOSH CLI plugin
19
+
20
+ ```
21
+ bosh generate plugin <plugin-name>
22
+ ```
23
+
24
+ Possible attributes:
25
+
26
+ * `--author` - a name of the plugin author, if is not specified it will be taken from `git` global config;
27
+ * `--email` - email of the plugin author, if is not specified it will be taken from `git` global config;
28
+ * `--description` - short description for your plugin;
29
+ * `--license` - license type to generate license file;
30
+ * `--no-travis` - do not expect to use travis with this plugin;
31
+
32
+ To get familiar with how to build your custom BOSH CLI plugin you'll find useful [this blog post](http://blog.altoros.com/cloud-foundry-internals-how-to-create-custom-bosh-cli-plugins.html).
33
+
34
+ To publish your plugin as a gem on [rubygems.org](http://rubygems.org/) see [this notes](http://guides.rubygems.org/publishing/).
35
+
36
+ ### Updating BOSH version in your plugin
37
+
38
+ ```
39
+ bosh update-bosh-version [path]
40
+ ```
41
+
42
+ It takes as a parameter `path` to plugin, if `path` is not specified it uses current folder.
43
+
44
+ Possible attributes:
45
+
46
+ * `--without-tests` - Don't run tests before commit
47
+ * `--without-commit` - Don't do commit after update
48
+ * `--without-push` - Don't push updated gem to github and rubygems
49
+
50
+
51
+ ## Contributing
52
+
53
+ 1. Fork it
54
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
55
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
56
+ 4. Push to the branch (`git push origin my-new-feature`)
57
+ 5. Create new Pull Request
58
+
59
+ ## List of Contributors
60
+
61
+ * [Altoros](https://www.altoros.com)
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ task :default => :spec
5
+ RSpec::Core::RakeTask.new
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'bosh/plugin_pipeline/version'
6
+ bosh_version = '1.3098.0'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = 'bosh-plugin-pipeline'
10
+ spec.version = Bosh::PluginPipeline::VERSION
11
+ spec.authors = ["Alexander Lomov"]
12
+ spec.email = ["alexander.lomov@altoros.com"]
13
+ spec.description = %q{BOSH CLI plug-in to create and manage BOSH CLI plug-ins.}
14
+ spec.summary = %q{This gem allows to create a file system tree structure for BOSH plugin and to update BOSH version in this plugin automatically.}
15
+ spec.homepage = 'http://altoros.com'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files`.split($/)
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.required_ruby_version = '>= 2.0.0'
24
+
25
+ spec.add_runtime_dependency 'bosh_cli', ">= #{bosh_version}"
26
+ spec.add_runtime_dependency 'bosh_common', ">= #{bosh_version}"
27
+ spec.add_runtime_dependency 'bosh-versions', '~> 0.1.1'
28
+ spec.add_runtime_dependency 'membrane', '~> 1.1.0'
29
+ spec.add_runtime_dependency 'erubis', '~> 2.7.0'
30
+ spec.add_runtime_dependency 'git', '~> 1.2.6'
31
+
32
+ spec.add_development_dependency 'bundler', '~> 1.10'
33
+ spec.add_development_dependency 'rspec', '~> 3.3.0'
34
+ spec.add_development_dependency 'rspec-its', '~> 1.2.0'
35
+ spec.add_development_dependency 'rake'
36
+ spec.add_development_dependency 'rubocop'
37
+ spec.add_development_dependency 'rspec-mocks'
38
+ end
@@ -0,0 +1,92 @@
1
+ require 'git'
2
+
3
+ module Bosh
4
+ module BoshVersionUpdater
5
+ module Helpers
6
+
7
+ def run_tests?
8
+ !options[:without_tests]
9
+ end
10
+
11
+ def make_commit?
12
+ !options[:without_commit]
13
+ end
14
+
15
+ def make_push?
16
+ !options[:without_commit]
17
+ end
18
+
19
+ def find_gemspec_file(plugin_path)
20
+ gemspec_file = Dir[File.join(plugin_path, "*.gemspec")].first
21
+ if gemspec_file.nil?
22
+ say "Can't find gemspec file in #{plugin_path}.".make_yellow
23
+ say "[ERROR] The folder doesn't seem to contain a gem.".make_red
24
+ exit(2)
25
+ end
26
+ gemspec_file
27
+ end
28
+
29
+ def update_bosh_gem_version_in_gemspec(gemspec_file)
30
+ say "Using #{gemspec_file} gemspec file to update BOSH version"
31
+
32
+ current_bosh_version = bosh_gem_latest_version
33
+ bosh_version_regex = /bosh_version\s*=\s*['"]((\d+\.)?(\d+\.)?(\*|\d+))['"]/
34
+ gemspec_file_text = File.read(gemspec_file)
35
+ old_bosh_version_match = gemspec_file_text.match(bosh_version_regex)
36
+
37
+ if old_bosh_version_match.nil?
38
+ say "Can't find BOSH version if gemspec.".make_yellow
39
+ say "We expected your gemspec file contains 'bosh_version = \"<some-version>\" string.".make_yellow
40
+ say "[ERROR] Can't find BOSH version.".make_red
41
+ exit(2)
42
+ end
43
+
44
+ old_bosh_version = old_bosh_version_match.to_a[1]
45
+ if old_bosh_version == current_bosh_version
46
+ say "Everything is uptodate."
47
+ exit(0)
48
+ end
49
+
50
+ say "Changing BOSH version from #{old_bosh_version} to #{current_bosh_version}"
51
+ gemspec_file_text.gsub!(bosh_version_regex, "bosh_version = '#{current_bosh_version}'")
52
+ File.open(gemspec_file, 'w') { |file| file.write(gemspec_file_text) }
53
+
54
+ say "gemspec file is updated."
55
+ end
56
+
57
+ def run_bundle_install(plugin_path)
58
+ Dir.chdir(plugin_path) do
59
+ Bundler.with_clean_env do
60
+ system('bundle install')
61
+ unless ($?.success?)
62
+ say "`bundle install` failed.".make_red
63
+ exit(2)
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ def run_tests(plugin_path)
70
+ Dir.chdir(plugin_path) do
71
+ Bundler.with_clean_env do
72
+ say "Running tests"
73
+ system('bundle exec rake')
74
+ unless ($?.success?)
75
+ say "Tests failed.".make_red
76
+ exit(2)
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ def make_commit(plugin_path)
83
+ say '#make_commit is not implemented yet'
84
+ end
85
+
86
+ def make_push(plugin_path)
87
+ say '#make_commit is not implemented yet'
88
+ end
89
+
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,11 @@
1
+ require 'cli'
2
+ require 'cli/core_ext'
3
+ require 'bosh-versions'
4
+
5
+ module Bosh
6
+ module BoshVersionUpdater
7
+ include BoshExtensions
8
+ end
9
+ end
10
+
11
+ require "bosh/bosh_version_updater/helpers"
@@ -0,0 +1,27 @@
1
+ require "bosh/bosh_version_updater"
2
+
3
+ module Bosh::Cli::Command
4
+ class BoshVersionUpdater < Base
5
+ include Bosh::BoshVersionUpdater::Helpers
6
+ include Bosh::Versions::Helpers
7
+
8
+ # example: bosh generate plugin bosh-magic
9
+ usage "update-bosh-version"
10
+ desc "Updates plugin's BOSH version, runs tests and makes commit, " +
11
+ "takes as parameter path to plugin, by default uses current folder"
12
+ option "--without-tests", "Don't run tests before commit"
13
+ option "--without-commit", "Don't do commit after update"
14
+ option "--without-push", "Don't push updated gem to github and rubygems"
15
+ def update_bosh_version(plugin_path = Dir.pwd)
16
+ gemspec_file = find_gemspec_file(plugin_path)
17
+ update_bosh_gem_version_in_gemspec(gemspec_file)
18
+ run_bundle_install(plugin_path)
19
+ run_tests(plugin_path) if run_tests?
20
+ if make_commit?
21
+ make_commit(plugin_path)
22
+ make_push(plugin_path) if make_push?
23
+ end
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ require "bosh/plugin_generator"
2
+
3
+ module Bosh::Cli::Command
4
+ class PluginGenerator < Base
5
+ include Bosh::PluginGenerator::Helpers
6
+
7
+ # example: bosh generate plugin bosh-magic
8
+ usage "generate plugin"
9
+ desc "Generates folder with skeleton of new BOSH plugin."
10
+ option "--author [author]", String, "name of the owner (by default will take from git settings)"
11
+ option "--email [email]", String, "email of the owner (by default will take from git settings)"
12
+ option "--description [text]", String, "Short description of the plugin"
13
+ option "--license [type]", String, "type of license file included to plugin repository" +
14
+ "(possible values mit|gpl|lgpl|apache2)"
15
+ def perform(plugin_name)
16
+ extract_options(plugin_name)
17
+ say "Generating BOSH CLI plugin...".make_green
18
+ generate_files
19
+ say "Creating git repository...".make_green
20
+ Git.init(plugin_name)
21
+ say 'Done'.make_green
22
+ say "The plugin is saved to #{File.join(Dir.pwd, plugin_name)}"
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,29 @@
1
+ require 'erubis'
2
+
3
+ module Bosh
4
+ module PluginGenerator
5
+ class Generator
6
+
7
+ attr_accessor :context, :options
8
+ def initialize(context, options = {})
9
+ @options = options
10
+ @context = context
11
+ end
12
+
13
+ def generate(source, target)
14
+ folder = File.dirname(target)
15
+ FileUtils.mkdir_p(folder)
16
+ template = File.read(File.join(source_folder, source))
17
+ result = Erubis::Eruby.new(template).result(context)
18
+ File.write(target, result)
19
+ end
20
+
21
+ private
22
+
23
+ def source_folder
24
+ options[:source_folder] || Dir.pwd
25
+ end
26
+
27
+ end
28
+ end
29
+ end