From 5a1a7e1056a3e9c19ad2f47614068d1034fae6dd Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 29 Jun 2016 14:13:09 -0700 Subject: [PATCH 1/4] Remove the plugin_theme metadata field. Not useful. --- lib/theme_template/theme.gemspec.erb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/theme_template/theme.gemspec.erb b/lib/theme_template/theme.gemspec.erb index 1c3b7ee4..13d795ce 100644 --- a/lib/theme_template/theme.gemspec.erb +++ b/lib/theme_template/theme.gemspec.erb @@ -10,8 +10,6 @@ Gem::Specification.new do |spec| spec.homepage = "TODO: Put your gem's website or public repo URL here." spec.license = "MIT" - spec.metadata["plugin_type"] = "theme" - spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(exe|<%= theme_directories.join("|") %>)/}) } spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } From 4b7109d2735905491c3c31bf0a698cba0cafdf05 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 29 Jun 2016 14:15:02 -0700 Subject: [PATCH 2/4] Themes won't have executables. --- lib/theme_template/theme.gemspec.erb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/theme_template/theme.gemspec.erb b/lib/theme_template/theme.gemspec.erb index 13d795ce..dac6ed39 100644 --- a/lib/theme_template/theme.gemspec.erb +++ b/lib/theme_template/theme.gemspec.erb @@ -10,9 +10,7 @@ Gem::Specification.new do |spec| spec.homepage = "TODO: Put your gem's website or public repo URL here." spec.license = "MIT" - spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(exe|<%= theme_directories.join("|") %>)/}) } - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } + spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(<%= theme_directories.join("|") %>)/}) } spec.add_development_dependency "jekyll", "~> <%= jekyll_version_with_minor %>" spec.add_development_dependency "bundler", "~> 1.12" From 0599f114d6cf951888b5f68e27e8609a8a5a4edc Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 29 Jun 2016 15:11:52 -0700 Subject: [PATCH 3/4] Only add a CODE_OF_CONDUCT.md file if specified. --- lib/jekyll/commands/new_theme.rb | 11 +++++++---- lib/jekyll/theme_builder.rb | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/jekyll/commands/new_theme.rb b/lib/jekyll/commands/new_theme.rb index 08eb4291..a703ca85 100644 --- a/lib/jekyll/commands/new_theme.rb +++ b/lib/jekyll/commands/new_theme.rb @@ -6,20 +6,23 @@ class Jekyll::Commands::NewTheme < Jekyll::Command prog.command(:"new-theme") do |c| c.syntax "new-theme NAME" c.description "Creates a new Jekyll theme scaffold" + c.option "code_of_conduct", \ + "-c", "--code-of-conduct", \ + "Include a Code of Conduct. (defaults to false)" - c.action do |args, _| - Jekyll::Commands::NewTheme.process(args) + c.action do |args, opts| + Jekyll::Commands::NewTheme.process(args, opts) end end end - def process(args) + def process(args, opts) if !args || args.empty? raise Jekyll::Errors::InvalidThemeName, "You must specify a theme name." end new_theme_name = args.join("_") - theme = Jekyll::ThemeBuilder.new(new_theme_name) + theme = Jekyll::ThemeBuilder.new(new_theme_name, opts) if theme.path.exist? Jekyll.logger.abort_with "Conflict:", "#{theme.path} already exists." end diff --git a/lib/jekyll/theme_builder.rb b/lib/jekyll/theme_builder.rb index b0e82e3a..0145ff3c 100644 --- a/lib/jekyll/theme_builder.rb +++ b/lib/jekyll/theme_builder.rb @@ -3,11 +3,12 @@ class Jekyll::ThemeBuilder _layouts _includes _sass ).freeze - attr_reader :name, :path + attr_reader :name, :path, :code_of_conduct - def initialize(theme_name) + def initialize(theme_name, opts) @name = theme_name.to_s.tr(" ", "_").gsub(%r!_+!, "_") @path = Pathname.new(File.expand_path(name, Dir.pwd)) + @code_of_conduct = !!opts["code_of_conduct"] end def create! @@ -71,7 +72,9 @@ class Jekyll::ThemeBuilder end def create_accessories - %w(README.md Rakefile CODE_OF_CONDUCT.md LICENSE.txt).each do |filename| + accessories = %w(README.md Rakefile LICENSE.txt) + accessories << "CODE_OF_CONDUCT.md" if code_of_conduct + accessories.each do |filename| write_file(filename, template(filename)) end end From 897f0c52fa67da1c1fc9fe60d5ab8715c733241e Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 29 Jun 2016 15:17:04 -0700 Subject: [PATCH 4/4] Add test for CoC flag. --- features/theme.feature | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/features/theme.feature b/features/theme.feature index ae18d3a6..0e05d693 100644 --- a/features/theme.feature +++ b/features/theme.feature @@ -8,6 +8,12 @@ Feature: Writing themes Then I should get a zero exit status And the my-cool-theme directory should exist + Scenario: Generating a new theme scaffold with a code of conduct + When I run jekyll new-theme my-cool-theme --code-of-conduct + Then I should get a zero exit status + And the my-cool-theme directory should exist + And the "my-cool-theme/CODE_OF_CONDUCT.md" file should exist + Scenario: A theme with SCSS Given I have a configuration file with "theme" set to "test-theme" And I have a css directory