feat: enhance --blank scaffolding (#7310)

Merge pull request 7310
This commit is contained in:
jekyllbot 2018-10-12 06:57:45 -04:00 committed by GitHub
parent 1bb7f03e44
commit 37baaec83e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 63 additions and 6 deletions

View File

@ -7,7 +7,8 @@ The Jekyll gem makes a `jekyll` executable available to you in your terminal.
You can use this command in a number of ways: You can use this command in a number of ways:
* `jekyll new` - Creates a new Jekyll site scaffold * `jekyll new` - Creates a new Jekyll site with default gem-based theme
* `jekyll new --blank` - Creates a new blank Jekyll site scaffold
* `jekyll build` or `jekyll b` - Performs a one off build your site to `./_site` (by default) * `jekyll build` or `jekyll b` - Performs a one off build your site to `./_site` (by default)
* `jekyll serve` or `jekyll s` - Builds your site any time a source file changes and serves it locally * `jekyll serve` or `jekyll s` - Builds your site any time a source file changes and serves it locally
* `jekyll doctor` - Outputs any deprecation or configuration issues * `jekyll doctor` - Outputs any deprecation or configuration issues

View File

@ -6,9 +6,18 @@ Feature: Create sites
Scenario: Blank site Scenario: Blank site
Given I do not have a "test_blank" directory Given I do not have a "test_blank" directory
When I run jekyll new test_blank --blank When I run jekyll new test_blank --blank
Then the test_blank/_layouts directory should exist Then the test_blank/_data directory should exist
And the test_blank/_drafts directory should exist
And the test_blank/_includes directory should exist
And the test_blank/_layouts directory should exist
And the test_blank/_posts directory should exist And the test_blank/_posts directory should exist
And the "test_blank/index.html" file should exist And the test_blank/_sass directory should exist
And the test_blank/assets/css directory should exist
And the "test_blank/_layouts/default.html" file should exist
And the "test_blank/_sass/main.scss" file should exist
And the "test_blank/assets/css/main.scss" file should exist
And the "test_blank/_config.yml" file should exist
And the "test_blank/index.md" file should exist
Scenario: Basic site Scenario: Basic site
Given I have an "index.html" file that contains "Basic Site" Given I have an "index.html" file that contains "Basic Site"

View File

@ -0,0 +1,3 @@
url: "" # the base hostname & protocol for your site, e.g. http://example.com
baseurl: "" # the subpath of your site, e.g. /blog
title: "" # the name of your site, e.g. ACME Corp.

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="{{ site.lang | default: "en-US" }}">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>{{ page.title }} - {{ site.title }}</title>
<link rel="stylesheet" href="{{ "/assets/css/main.css" | relative_url }}">
</head>
<body>
{{ content}}
</body>
</html>

View File

@ -0,0 +1,9 @@
$backgroundColor: #ffffff;
$bodyColor: #000000;
$bodyFont: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
body {
background: $backgroundColor;
color: $bodyColor;
font-family: $bodyFont;
}

View File

@ -0,0 +1,4 @@
---
---
@import "main";

View File

@ -0,0 +1,8 @@
---
layout: default
title: "Happy Jekyllin'!"
---
## You're ready to go!
Start developping your Jekyll website.

View File

@ -41,10 +41,16 @@ module Jekyll
after_install(new_blog_path, options) after_install(new_blog_path, options)
end end
def blank_template
File.expand_path("../../blank_template", __dir__)
end
def create_blank_site(path) def create_blank_site(path)
FileUtils.cp_r blank_template + "/.", path
FileUtils.chmod_R "u+w", path
Dir.chdir(path) do Dir.chdir(path) do
FileUtils.mkdir(%w(_layouts _posts _drafts)) FileUtils.mkdir(%w(_data _drafts _includes _posts))
FileUtils.touch("index.html")
end end
end end

View File

@ -14,6 +14,10 @@ class TestNewCommand < JekyllUnitTest
File.expand_path("../lib/site_template", __dir__) File.expand_path("../lib/site_template", __dir__)
end end
def blank_template
File.expand_path("../lib/blank_template", __dir__)
end
context "when args contains a path" do context "when args contains a path" do
setup do setup do
@path = "new-site" @path = "new-site"
@ -86,7 +90,8 @@ class TestNewCommand < JekyllUnitTest
end end
should "create blank project" do should "create blank project" do
blank_contents = %w(/_drafts /_layouts /_posts /index.html) blank_contents = dir_contents(blank_template)
blank_contents += %w(/_data /_drafts /_includes /_posts)
output = capture_output { Jekyll::Commands::New.process(@args, "--blank") } output = capture_output { Jekyll::Commands::New.process(@args, "--blank") }
bundle_message = "Running bundle install in #{@full_path.cyan}..." bundle_message = "Running bundle install in #{@full_path.cyan}..."
assert_same_elements blank_contents, dir_contents(@full_path) assert_same_elements blank_contents, dir_contents(@full_path)