gempilot 0.3.5 → 0.4.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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/skills/using-command-kit/generator-pattern.rb +2 -2
  3. data/.ruby-version +1 -1
  4. data/CLAUDE.md +12 -0
  5. data/Rakefile +3 -2
  6. data/data/templates/gem/Gemfile.erb +1 -0
  7. data/data/templates/gem/Rakefile.erb +5 -2
  8. data/data/templates/gem/bin/setup.erb +1 -0
  9. data/data/templates/gem/dotfiles/github/workflows/ci.yml.erb +2 -0
  10. data/data/templates/gem/dotfiles/gitignore +1 -0
  11. data/lib/gempilot/cli/commands/bump.rb +4 -5
  12. data/lib/gempilot/cli/commands/console.rb +1 -3
  13. data/lib/gempilot/cli/commands/create.rb +32 -165
  14. data/lib/gempilot/cli/commands/destroy.rb +9 -8
  15. data/lib/gempilot/cli/commands/release.rb +5 -9
  16. data/lib/gempilot/cli/gem_builder.rb +2 -31
  17. data/lib/gempilot/cli/gem_scaffold.rb +188 -0
  18. data/lib/gempilot/cli/generator.rb +11 -11
  19. data/lib/gempilot/github_release.rb +8 -10
  20. data/lib/gempilot/origin.rb +6 -10
  21. data/lib/gempilot/rbs_task.rb +87 -0
  22. data/lib/gempilot/shell/command_failed.rb +17 -0
  23. data/lib/gempilot/shell/gateway.rb +45 -0
  24. data/lib/gempilot/shell/invocation.rb +16 -0
  25. data/lib/gempilot/shell/result.rb +14 -0
  26. data/lib/gempilot/shell/status.rb +20 -0
  27. data/lib/gempilot/shell/stub_gateway.rb +65 -0
  28. data/lib/gempilot/shell/unregistered_command.rb +23 -0
  29. data/lib/gempilot/shell.rb +66 -0
  30. data/lib/gempilot/version.rb +1 -1
  31. data/lib/gempilot/version_tag.rb +13 -17
  32. data/lib/gempilot/zeitwerk_task.rb +2 -2
  33. data/lib/gempilot.rb +1 -3
  34. data/rbs_collection.lock.yaml +188 -0
  35. data/rbs_collection.yaml +19 -0
  36. metadata +14 -3
  37. data/lib/gempilot/strict_shell.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab55a4c336ff8612280f38c41b6c4471e9f7791ae9fd40998af6608c016f5031
4
- data.tar.gz: 1d29b54f07c0c66a0a6781a394d29d0cb73c14ceba5c3cf8278601e5e1db4df9
3
+ metadata.gz: 53a52246a6719fec251c1ac15f2db5270ff7419984ff93db68b0fd3c259c0ea7
4
+ data.tar.gz: 0d5f4d32f3c373c20eb4d846b9be8ce1b5f006cfea4700c8383228d7edd95de0
5
5
  SHA512:
6
- metadata.gz: 22f56e4d465bd05cfb95f4286599ae1c8242c56a63855aefad5878b74eb277dae5f0a497f11a43ccc2e4539cb9e4b18345907fe991ca8a4b93657fb9265138d7
7
- data.tar.gz: 7edb37e82f9f3595bfe6d2002684c8dec2a40dbd7b7cd04440dad519a2e68d521793831fd717786cb53f6466385eb264e2196e4f8c67500feb3ac08bb2eb28d3
6
+ metadata.gz: f6585d264a17e3eb49bb37d085486b8671dbfaed3207370ca2a207edf570c893291b805600eef13f3f37eafe05474ab00e5d977bfa0a5e9e277b1b498c52692d
7
+ data.tar.gz: 377229960329acd2601a65c8acab370e2d390b2f33752f1614044cc66e7e64eb8ccfb97af5745aa0d2bc879ef348fca8b82e21b2f0c62a9a9a3e4965f52eda99
@@ -40,12 +40,12 @@ module MyTool
40
40
 
41
41
  def mkdir(path)
42
42
  print_action "mkdir", path
43
- ::FileUtils.mkdir_p(path)
43
+ mkdir_p(path)
44
44
  end
45
45
 
46
46
  def cp(source, dest)
47
47
  print_action "cp", source, dest
48
- ::FileUtils.cp(File.join(@template_dir, source), dest)
48
+ super(File.join(@template_dir, source), dest)
49
49
  end
50
50
 
51
51
  def erb(source, dest = nil)
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 4.0.7
1
+ 4.0.9
data/CLAUDE.md CHANGED
@@ -19,14 +19,25 @@ A CLI tool for creating and managing Ruby gems, built on CommandKit.
19
19
  - Uses CommandKit for CLI framework (commands, options, arguments, interactive prompts)
20
20
  - Uses CommandKit::Inflector for name inflection
21
21
  - Generator module (`lib/gempilot/cli/generator.rb`) provides template rendering via ERB
22
+ - `Gempilot::Shell` (`lib/gempilot/shell.rb`) is the only way gempilot runs external commands: `Shell.run` (raises `Shell::CommandFailed`), `Shell.capture` (returns output and status), `Shell.exec`. All three go through `Shell.gateway`; `Shell::Gateway` is the only code that spawns processes
23
+ - `GemScaffold` (`lib/gempilot/cli/gem_scaffold.rb`) renders a new gem's files and runs no commands; `Commands::Create` subclasses it to run `bin/setup` and commit
22
24
  - GemContext module (`lib/gempilot/cli/gem_context.rb`) shared by new, destroy, release, console
23
25
  - `GemConstant` value object (`lib/gempilot/gem_constant.rb`) owns constant→namespace/path resolution for `new`/`destroy`; constants are rooted at the gem module by construction
26
+ - `Gempilot::RBSTask` (`lib/gempilot/rbs_task.rb`, a `Rake::TaskLib`) wraps `rbs collection`: `rbs:setup`, `rbs:clobber`, `rbs:validate`, `rbs:collection:init/install/update` (requires `rbs` in the consuming gem's bundle)
24
27
  - `SegmentedVersion` value object (`lib/gempilot/segmented_version.rb`) owns version parsing and bump arithmetic; every bump moves to the smallest version of the requested shape greater than the current version (RubyGems ordering)
25
28
  - CommandKit::Commands::AutoLoad maps filenames in `commands/` to command names
26
29
 
30
+ ### Ruby Conventions
31
+ - Every `rescue` and `ensure` sits inside an explicit `begin ... end`; never attach one directly to a `def` or `do` body (`Style/RedundantBegin` is disabled for this). Capture state to restore before `begin`, so `ensure` only guards what it undoes
32
+ - A spec, class, or module that calls `FileUtils` more than once mixes it in (`include FileUtils`) and calls its methods bare. Don't define methods that share a name with FileUtils' own helpers in such a class: FileUtils calls them on `self` (e.g. `rm` calls `remove_file`), so an override changes FileUtils' behavior. Where a wrapper deliberately overrides one (e.g. `Generator#touch`), it reaches the original with `super`
33
+
34
+ - RDoc is public documentation for users, not notes about the implementation: one or two plain sentences, then a real code example with its output
35
+
27
36
  ### Testing
28
37
  - Minitest with minitest-reporters
29
38
  - Run tests: `bundle exec rake test`
39
+ - Never shell out directly (`system`, backticks, `Open3`, `exec`) in code or tests; use `Gempilot::Shell`. A test that must not run a command for real (one that publishes, like `gh release` or `rake release`) swaps in `Shell::StubGateway` with `Shell.with_gateway`, the way WebMock fakes HTTP; never stub `sh`/`system` on objects
40
+ - End-to-end specs live in `spec/e2e/`. They build gempilot from this checkout, install it into an isolated gem directory (`spec/support/installed_gempilot.rb`), and run the installed `gempilot` executable to build a full gem project and run it. They use no mocks, stubs, or wrapped methods, and never patch generated files mid-run; if a real run can't work, fix the code rather than faking around it
30
41
 
31
42
  ### Generated Gem Features
32
43
  - Zeitwerk autoloading with `LOADER` constant exposed for eager loading
@@ -37,4 +48,5 @@ A CLI tool for creating and managing Ruby gems, built on CommandKit.
37
48
  - GitHub Actions CI workflow (`.github/workflows/ci.yml`)
38
49
  - `git ls-files`-based gemspec with glob fallback for non-git repos
39
50
  - Version lifecycle rake tasks installed via `Gempilot::VersionTask.new` (a `Rake::TaskLib`): `version:current/bump/commit/tag/untag/reset/revert` and composite `version:release`/`version:unrelease`
51
+ - RBS collection rake tasks via `Gempilot::RBSTask.new`; `bin/setup` runs `rake setup`, which chains `rbs:setup` → `rbs:collection:install` → `rbs:collection:init`. `gempilot create` runs the new gem's `bin/setup`, so the collection (and `rbs_collection.lock.yaml`) exist before the initial commit
40
52
  - Publishing rake tasks (mixed into `VersionTask` via `Gempilot::ReleaseTasks`): `release` (all remotes), `release:rubygems`, `release:github`, `release:list:github`, `unrelease`, `unrelease:github`. These override and reuse bundler's `bundler/gem_tasks` release chain; `release:source_control_push` is replaced with `Gempilot::Origin` to push commit+tag idempotently
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ require_relative "lib/gempilot"
11
11
  namespace :spec do
12
12
  desc "Prints the specification suite in documentation format and exits"
13
13
  task :print do
14
- exec("rspec", "--format", "documentation", "--dry-run")
14
+ Gempilot::Shell.exec("rspec", "--format", "documentation", "--dry-run")
15
15
  end
16
16
  end
17
17
 
@@ -39,5 +39,6 @@ RuboCop::RakeTask.new do |t|
39
39
  end
40
40
 
41
41
  Gempilot::VersionTask.new
42
+ Gempilot::RBSTask.new
42
43
 
43
- task default: [:test, :spec, :rubocop]
44
+ task default: [:test, :spec, :rubocop, "rbs:validate"]
@@ -10,6 +10,7 @@ gem "minitest"
10
10
  gem "minitest-reporters"
11
11
  <% end -%>
12
12
  gem "rake"
13
+ gem "rbs"
13
14
  <% if @test_framework == :rspec -%>
14
15
  gem "rspec", "~> 3.0"
15
16
  <% end -%>
@@ -21,8 +21,11 @@ Gempilot::VersionTask.new
21
21
  require "gempilot/zeitwerk_task"
22
22
  Gempilot::ZeitwerkTask.new
23
23
 
24
+ require "gempilot/rbs_task"
25
+ Gempilot::RBSTask.new
26
+
24
27
  <% if @test_framework == :minitest -%>
25
- task default: [:test, :rubocop]
28
+ task default: [:test, :rubocop, "rbs:validate"]
26
29
  <% elsif @test_framework == :rspec -%>
27
- task default: [:spec, :rubocop]
30
+ task default: [:spec, :rubocop, "rbs:validate"]
28
31
  <% end -%>
@@ -3,3 +3,4 @@ set -euo pipefail
3
3
  IFS=$'\n\t'
4
4
 
5
5
  bundle install
6
+ bundle exec rake setup
@@ -31,3 +31,5 @@ jobs:
31
31
  <% end -%>
32
32
  - name: Run RuboCop
33
33
  run: bundle exec rake rubocop
34
+ - name: Validate RBS
35
+ run: bundle exec rake rbs:validate
@@ -1,4 +1,5 @@
1
1
  /.bundle/
2
+ /.gem_rbs_collection/
2
3
  /.yardoc
3
4
  /_yardoc/
4
5
  /coverage/
@@ -1,5 +1,3 @@
1
- require "bundler"
2
-
3
1
  module Gempilot
4
2
  class CLI
5
3
  module Commands
@@ -39,10 +37,11 @@ module Gempilot
39
37
  end
40
38
 
41
39
  def run_rake_bump(segment)
42
- success = Bundler.with_unbundled_env do
43
- system("bundle", "exec", "rake", "version:bump[#{segment}]")
40
+ begin
41
+ Shell.run("bundle", "exec", "rake", "version:bump[#{segment}]", unbundled: true)
42
+ rescue Shell::CommandFailed
43
+ exit 1
44
44
  end
45
- exit 1 unless success
46
45
  end
47
46
  end
48
47
  end
@@ -1,5 +1,3 @@
1
- require "bundler"
2
-
3
1
  module Gempilot
4
2
  class CLI
5
3
  module Commands
@@ -13,7 +11,7 @@ module Gempilot
13
11
  detect_gem_context
14
12
  console_path = find_console_script
15
13
  print_console_banner
16
- Bundler.with_unbundled_env { exec(console_path) }
14
+ Shell.exec(console_path, unbundled: true)
17
15
  end
18
16
 
19
17
  private
@@ -1,16 +1,14 @@
1
1
  module Gempilot
2
2
  class CLI
3
3
  module Commands
4
- ## Scaffolds a new gem with Zeitwerk autoloading, test framework, RuboCop config,
5
- ## CI workflow, and version management rake tasks.
6
- class Create < Command
7
- using String::Inflectable
8
-
9
- include Generator
10
- include GemBuilder
11
-
12
- template_dir File.join(Gempilot::ROOT, "data", "templates", "gem")
13
-
4
+ ## Creates a new gem: writes its files, runs its +bin/setup+, and commits it.
5
+ ##
6
+ ## $ gempilot create --test minitest --git my_gem
7
+ ## # Creating gem 'my_gem'...
8
+ ## # ...
9
+ ## # run bin/setup
10
+ ## # run git init -q -b master
11
+ class Create < GemScaffold
14
12
  usage "[options] GEM_NAME"
15
13
  description "Create a new gem"
16
14
 
@@ -22,175 +20,44 @@ module Gempilot
22
20
  "--summary 'A web scraper' my_gem",
23
21
  ]
24
22
 
25
- option :summary, value: { type: String },
26
- desc: "Gem summary"
27
-
28
- option :author, value: {
29
- type: String,
30
- default: -> { `git config user.name 2>/dev/null`.strip },
31
- },
32
- desc: "Author name"
33
-
34
- option :email, value: {
35
- type: String,
36
- default: -> { `git config user.email 2>/dev/null`.strip },
37
- },
38
- desc: "Author email"
39
-
40
- option :ruby_version, value: {
41
- type: String,
42
- default: RUBY_VERSION,
43
- },
44
- desc: "Minimum Ruby version"
45
-
46
- option :test, value: {
47
- type: { "minitest" => :minitest, "rspec" => :rspec },
48
- },
49
- desc: "Test framework"
50
-
51
- option :exe, long: "--[no-]exe", desc: "Create an executable"
52
-
53
- option :git, long: "--[no-]git", desc: "Initialize git repo"
54
-
55
- option :branch, value: { type: String },
56
- desc: "Git branch name"
57
-
58
- argument :gem_name, required: false,
59
- desc: "Name of the gem"
60
-
61
23
  def run(gem_name = nil)
62
- puts colors.bold("Creating gem...")
63
- puts
64
- collect_options(gem_name)
65
- print_header
66
- scaffold_gem
67
- end
68
-
69
- private
70
-
71
- def collect_options(gem_name)
72
- collect_gem_name(gem_name)
73
- derive_naming
74
- collect_author_info
75
- collect_summary
76
- collect_build_options
77
- end
78
-
79
- def scaffold_gem
80
- create_directories
81
- render_core_templates
82
- render_test_templates
83
- render_dev_files
84
- render_config_files
85
- render_executable
86
- run_bundle_install
87
- initialize_git_repo
88
- end
89
-
90
- GEM_NAME_PATTERN = /\A[a-z][a-z0-9]*([_-][a-z0-9]+)*\z/
91
- private_constant :GEM_NAME_PATTERN
92
-
93
- def collect_gem_name(gem_name)
94
- @gem_name = gem_name || begin
95
- puts colors.bright_black("The gem name determines the directory, require path, and gemspec name.")
96
- ask(colors.green("Gem name"), required: true)
24
+ super
25
+ begin
26
+ run_setup
27
+ initialize_git_repo
28
+ rescue Shell::CommandFailed => e
29
+ puts colors.red(e.message)
30
+ exit 1
97
31
  end
98
- validate_gem_name
99
32
  end
100
33
 
101
- def validate_gem_name
102
- return if @gem_name.match?(GEM_NAME_PATTERN)
103
-
104
- puts colors.red("Invalid gem name '#{@gem_name}'.")
105
- puts colors.red("Use lowercase letters, digits, hyphens, or underscores (e.g., my_gem or my-gem).")
106
- exit 1
107
- end
108
-
109
- def derive_naming
110
- @require_path = @gem_name.tr("-", "/")
111
- @module_name = @require_path.camelize
112
- @module_parts = @module_name.split("::")
113
- @base_module = @module_parts.first
114
- @hyphenated = @gem_name.include?("-")
115
- end
116
-
117
- def collect_author_info
118
- @author = option_or_ask(:author, "The author name for the gemspec and LICENSE.", "Author name")
119
- @email = option_or_ask(:email, "The contact email for the gemspec.", "Author email")
120
- end
121
-
122
- def option_or_ask(key, hint, label)
123
- options[key].then { |v| v.to_s.empty? ? nil : v } || begin
124
- puts colors.bright_black(hint)
125
- ask(colors.green(label), required: true)
126
- end
127
- end
128
-
129
- def collect_summary
130
- @summary = options[:summary] || begin
131
- puts
132
- puts colors.bright_black("A short (one line) summary of what your gem does.")
133
- ask(colors.green("Summary"), default: "A new Ruby gem")
134
- end
135
- @ruby_version = options[:ruby_version]
136
- end
137
-
138
- def collect_build_options
139
- collect_test_framework
140
- collect_exe_option
141
- collect_git_options
142
- end
34
+ private
143
35
 
144
- def collect_test_framework
145
- @test_framework = options[:test] || begin
146
- puts
147
- puts colors.bright_black("Choose a test framework for your gem:")
148
- puts " * #{colors.bold("Minitest")} - https://github.com/minitest/minitest"
149
- puts " * #{colors.bold("RSpec")} - https://rspec.info"
150
- ask_multiple_choice(colors.green("Test framework"), { "minitest" => :minitest, "rspec" => :rspec })
36
+ def run_setup
37
+ cd @gem_name do
38
+ run_command "bin/setup"
151
39
  end
152
40
  end
153
41
 
154
- def collect_exe_option
155
- return if options.key?(:exe)
156
-
157
- puts
158
- puts colors.bright_black("An executable in exe/ lets users run your gem from the command line.")
159
- prompt = colors.green("Create an executable")
160
- options[:exe] = ask_yes_or_no(prompt, default: false)
161
- end
162
-
163
- def collect_git_options
164
- collect_git_flag
165
- collect_branch if options[:git]
166
- end
167
-
168
- def collect_git_flag
169
- return if options.key?(:git)
170
-
171
- puts
172
- puts colors.bright_black("Initialize a git repository with an initial commit.")
173
- prompt = colors.green("Initialize git repo")
174
- options[:git] = ask_yes_or_no(prompt, default: true)
175
- end
42
+ def initialize_git_repo
43
+ return unless options[:git]
176
44
 
177
- def collect_branch
178
- @branch = options[:branch] || begin
179
- puts
180
- puts colors.bright_black("The default branch name for the new git repository.")
181
- ask(colors.green("Branch name"), default: "master")
45
+ cd @gem_name do
46
+ run_command "git", "init", "-q", "-b", @branch
47
+ run_command "git", "add", "."
48
+ run_command "git", "commit", "-q", "-m", commit_message
182
49
  end
183
50
  end
184
51
 
185
- def print_header
186
- styled_name = colors.bold(colors.cyan(@gem_name))
187
- puts
188
- puts colors.bright_white("Creating gem '") + styled_name + colors.bright_white("'...")
189
- puts
52
+ # "Initial commit." is wrong when scaffolding into a directory that is
53
+ # already a repository with history (e.g. a cloned remote), so name the
54
+ # commit after the gem in that case.
55
+ def commit_message
56
+ existing_history? ? "Add #{@gem_name} gem scaffolding." : "Initial commit."
190
57
  end
191
58
 
192
- def minor_version_for(version)
193
- version.split(".")[0..1].join(".")
59
+ def existing_history?
60
+ Shell.capture("git", "rev-parse", "--verify", "--quiet", "HEAD").success?
194
61
  end
195
62
  end
196
63
  end
@@ -7,6 +7,7 @@ module Gempilot
7
7
  class Destroy < Command
8
8
  using String::Inflectable
9
9
 
10
+ include ::FileUtils
10
11
  include GemContext
11
12
 
12
13
  usage "[options] TYPE CONSTANT"
@@ -57,8 +58,8 @@ module Gempilot
57
58
  lib_path = constant.lib_path
58
59
  test_path = constant.test_path(@test_framework)
59
60
 
60
- remove_file(lib_path)
61
- remove_file(test_path)
61
+ destroy_file(lib_path)
62
+ destroy_file(test_path)
62
63
  cleanup_empty_dirs(lib_path, test_path)
63
64
  end
64
65
 
@@ -71,7 +72,7 @@ module Gempilot
71
72
  def destroy_module(constant)
72
73
  lib_path = constant.lib_path
73
74
 
74
- remove_file(lib_path)
75
+ destroy_file(lib_path)
75
76
  remove_empty_parents(File.dirname(lib_path), File.join("lib", @require_path))
76
77
  end
77
78
 
@@ -79,20 +80,20 @@ module Gempilot
79
80
  name = name.split("::").last if name.include?("::")
80
81
  file_name = name.underscore
81
82
  file_path = File.join("lib", @require_path, "cli", "commands", "#{file_name}.rb")
82
- remove_file(file_path)
83
+ destroy_file(file_path)
83
84
 
84
85
  test_path = if @test_framework == :rspec
85
86
  File.join("spec", @require_path, "cli", "commands", "#{file_name}_spec.rb")
86
87
  else
87
88
  File.join("test", @require_path, "cli", "commands", "#{file_name}_test.rb")
88
89
  end
89
- remove_file(test_path)
90
+ destroy_file(test_path)
90
91
  end
91
92
 
92
- def remove_file(path)
93
+ def destroy_file(path)
93
94
  if File.exist?(path)
94
95
  print_remove(path)
95
- ::FileUtils.rm(path)
96
+ rm(path)
96
97
  else
97
98
  print_skip(path)
98
99
  end
@@ -104,7 +105,7 @@ module Gempilot
104
105
  break unless Dir.empty?(dir)
105
106
 
106
107
  print_remove(dir)
107
- ::FileUtils.rmdir(dir)
108
+ rmdir(dir)
108
109
  dir = File.dirname(dir)
109
110
  end
110
111
  end
@@ -1,5 +1,3 @@
1
- require "bundler"
2
-
3
1
  module Gempilot
4
2
  class CLI
5
3
  module Commands
@@ -24,14 +22,12 @@ module Gempilot
24
22
  end
25
23
 
26
24
  def run_rake_release
27
- success = Bundler.with_unbundled_env do
28
- system("bundle", "exec", "rake", "release")
25
+ begin
26
+ Shell.run("bundle", "exec", "rake", "release", unbundled: true)
27
+ rescue Shell::CommandFailed
28
+ puts colors.red("Release failed. Check the output above for errors.")
29
+ exit 1
29
30
  end
30
-
31
- return if success
32
-
33
- puts colors.red("Release failed. Check the output above for errors.")
34
- exit 1
35
31
  end
36
32
  end
37
33
  end
@@ -3,9 +3,8 @@ module Gempilot
3
3
  ## File rendering and directory creation logic for scaffolding a new gem.
4
4
  ##
5
5
  ## Expects the including class to provide Generator methods (+mkdir+, +erb+,
6
- ## +chmod+, +cp+, +cd+, +sh+) and the following instance variables:
7
- ## +@gem_name+, +@require_path+, +@module_name+, +@hyphenated+,
8
- ## +@test_framework+, +@branch+.
6
+ ## +chmod+, +cp+) and the following instance variables: +@gem_name+,
7
+ ## +@require_path+, +@module_name+, +@hyphenated+, +@test_framework+.
9
8
  module GemBuilder
10
9
  private
11
10
 
@@ -84,34 +83,6 @@ module Gempilot
84
83
  erb "exe/gem_name.erb", "#{@gem_name}/exe/#{@gem_name}"
85
84
  chmod "+x", "#{@gem_name}/exe/#{@gem_name}"
86
85
  end
87
-
88
- def run_bundle_install
89
- cd @gem_name do
90
- sh "bundle", "install"
91
- end
92
- end
93
-
94
- def initialize_git_repo
95
- return unless options[:git]
96
-
97
- cd @gem_name do
98
- sh "git", "init", "-q", "-b", @branch
99
- sh "git", "add", "."
100
- sh "git", "commit", "-q", "-m", commit_message
101
- end
102
- end
103
-
104
- # "Initial commit." is wrong when scaffolding into a directory that is
105
- # already a repository with history (e.g. a cloned remote), so name the
106
- # commit after the gem in that case.
107
- def commit_message
108
- existing_history? ? "Add #{@gem_name} gem scaffolding." : "Initial commit."
109
- end
110
-
111
- def existing_history?
112
- system("git", "rev-parse", "--verify", "--quiet", "HEAD",
113
- out: File::NULL, err: File::NULL)
114
- end
115
86
  end
116
87
  end
117
88
  end