Skip to content

Commit 87f4580

Browse files
committed
Merge pull request #9 from andimal/v1.0.0
v1.0.0
2 parents fbb5fb6 + 2cad40e commit 87f4580

1,244 files changed

Lines changed: 99 additions & 386308 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ mkmf.log
1616
.sass-cache/
1717
node_modules/
1818
*.gem
19+
.ruby-version

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
# Stump CLI
22

3-
Initialize a WordPress project based on the Stump theme
3+
Initialize a WordPress project based on the [Stump](https://github.com/kohactive/stump) theme
44

55
## Installation
66

7-
`$ gem install stump-cli --no-rdoc --no-ri`
7+
`$ gem install stump-cli`
88

99
## Usage
1010

11-
`stump-cli init NAME`
11+
`stump-cli init NAME`
12+
_See the [Stump repo](https://github.com/kohactive/stump) for theme usage_
1213

1314
## TODO
14-
* pull latest WordPress release on init
15-
* pull Stump from https://github.com/kohactive/stump on init
15+
* [prompt user if dir already exists where they are trying to init](https://github.com/kohactive/stump-cli/issues/10)
16+
* [remove default themes](https://github.com/kohactive/stump-cli/issues/11)
17+
* [install plugins (acf, ?)](https://github.com/kohactive/stump-cli/issues/12)
18+
* [add link to theme usage instructions in output](https://github.com/kohactive/stump-cli/issues/13)
19+
* [run `npm install` and `grunt`?](https://github.com/kohactive/stump-cli/issues/14)
1620

1721
## Contributing
1822

bin/stump-cli

Lines changed: 76 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,108 @@
11
#!/usr/bin/env ruby
22

3+
require "open-uri"
4+
require "tilt/erb"
35
require "thor"
46
require "wordmove/generators/movefile"
57
require "wordmove/deployer/base"
6-
require "tilt/erb"
8+
require "zip"
79

810
class StumpCLI < Thor
911

1012
desc "init NAME", "Create new project NAME"
1113
def init(name)
1214

13-
puts "Creating project..."
14-
wp_core = File.expand_path("../../lib/wp", __FILE__)
1515
new_project_dir = "#{Dir.pwd}/#{name}"
1616
new_project_theme = "#{new_project_dir}/wp-content/themes/#{name}"
1717

18-
# copy wp core with stump theme to current dir
19-
FileUtils.cp_r wp_core, new_project_dir
18+
puts "Downloading latest stable WordPress zip..."
19+
20+
# TODO: need to check if dir exists
21+
# if it does, prompt user to overwrite or cancel
22+
FileUtils.mkdir new_project_dir
23+
wp_zip = File.new("#{new_project_dir}/wp.zip", "w")
24+
open(wp_zip, 'wb') do |wp|
25+
wp << open('https://wordpress.org/latest.zip').read
26+
end
2027

21-
# render gitignore for project
22-
gitignore = Tilt::ERBTemplate.new("#{new_project_dir}/.gitignore.erb")
23-
new_gitignore = gitignore.render { name }
24-
File.write( "#{new_project_dir}/.gitignore", new_gitignore )
25-
FileUtils.remove_file( "#{new_project_dir}/.gitignore.erb" )
28+
puts "Extracting WordPress zip..."
29+
Zip::File.open(wp_zip) do |zip_file|
30+
zip_file.each do |entry|
31+
entry.extract("#{new_project_dir}/#{entry.name}")
32+
end
33+
end
34+
35+
# remove wp zip file
36+
FileUtils.rm wp_zip
37+
38+
# pull everything up a level from the extracted "wordpress" dir
39+
Dir.foreach("#{new_project_dir}/wordpress") do |item|
40+
next if item == '.' or item == '..'
41+
FileUtils.mv "#{new_project_dir}/wordpress/#{item}", "#{new_project_dir}/#{item}"
42+
end
43+
44+
# remove leftover dir from unzipping
45+
FileUtils.rmdir "#{new_project_dir}/wordpress"
46+
47+
# TODO: remove default themes
48+
# doesn't work for whatever reason...
49+
# Dir.foreach("#{new_project_dir}/wp-content/themes") do |item|
50+
# next if item == '.' or item == '..'
51+
# puts item
52+
# puts File.directory?(item)
53+
# puts "::::"
54+
# FileUtils.rm_rf "#{new_project_dir}/wp-content/themes/#{item}" if File.directory?(item)
55+
# end
56+
57+
puts "Downloading latest stable Stump zip..."
58+
stump_zip = File.new("#{new_project_dir}/stump.zip", "w")
59+
open(stump_zip, 'wb') do |wp|
60+
wp << open('https://github.com/kohactive/stump/archive/master.zip').read
61+
end
62+
63+
puts "Extracting Stump zip..."
64+
Zip::File.open(stump_zip) do |zip_file|
65+
zip_file.each do |entry|
66+
entry.extract("#{new_project_dir}/wp-content/themes/#{entry.name}")
67+
end
68+
end
69+
70+
# remove .gitignore used for theme repo
71+
# we'll make our own for the new project below
72+
FileUtils.rm "#{new_project_dir}/wp-content/themes/stump-master/.gitignore"
73+
74+
# remove stump zip file
75+
FileUtils.rm stump_zip
2676

2777
# change theme dir to project NAME
2878
puts "Changing theme name..."
29-
FileUtils.mv "#{new_project_dir}/wp-content/themes/stump", new_project_theme
79+
FileUtils.mv "#{new_project_dir}/wp-content/themes/stump-master", new_project_theme
3080

31-
# cd into new theme dir
32-
FileUtils.cd new_project_dir
81+
# render style.css
82+
style_template = File.expand_path("../../lib/style.erb", __FILE__)
83+
FileUtils.cp style_template, new_project_dir
84+
style = Tilt::ERBTemplate.new("#{new_project_dir}/style.erb")
85+
new_style = style.render { name }
86+
File.write( "#{new_project_dir}/wp-content/themes/#{name}/style.css", new_style )
87+
FileUtils.remove_file( "#{new_project_dir}/style.erb" )
3388

34-
# update style.css with project NAME
35-
File.write( "#{new_project_theme}/style.css", theme_style(name) )
89+
# render gitignore for project
90+
gitignore_template = File.expand_path("../../lib/.gitignore.erb", __FILE__)
91+
FileUtils.cp gitignore_template, new_project_dir
92+
gitignore = Tilt::ERBTemplate.new("#{new_project_dir}/.gitignore.erb")
93+
new_gitignore = gitignore.render { name }
94+
File.write( "#{new_project_dir}/.gitignore", new_gitignore )
95+
FileUtils.remove_file( "#{new_project_dir}/.gitignore.erb" )
3696

3797
# initialize Wordmove
3898
puts "Initializing Wordmove..."
99+
FileUtils.cd new_project_dir
39100
Wordmove::Generators::Movefile.start
40101

41102
puts "Complete!"
42103
puts Dir.pwd
43104
end
44105

45-
no_tasks do
46-
def theme_style(name)
47-
<<-END.gsub(/^ {6}/, '')
48-
/*
49-
Theme Name: #{name}
50-
Theme URI:
51-
Description:
52-
Version: 0.0.1
53-
Author:
54-
Author URI:
55-
56-
License: MIT License
57-
License URI: http://opensource.org/licenses/MIT
58-
*/
59-
END
60-
end
61-
end
62-
63106
end
64107

65108
StumpCLI.start

lib/stump-cli/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module StumpCLI
2-
VERSION = "0.1.4"
2+
VERSION = "1.0.0"
33
end

lib/style.erb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
Theme Name: <%= yield %>
3+
Theme URI:
4+
Description:
5+
Version: 0.0.1
6+
Author:
7+
Author URI:
8+
9+
License: MIT License
10+
License URI: http://opensource.org/licenses/MIT
11+
*/

lib/wp/Movefile-example

Lines changed: 0 additions & 62 deletions
This file was deleted.

lib/wp/README.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

lib/wp/index.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)