wordless 0.3.0 → 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.
- checksums.yaml +7 -0
- data/.gitignore +0 -17
- data/.travis.yml +10 -0
- data/Gemfile.lock +56 -21
- data/{README.md → README.mdown} +45 -22
- data/Rakefile +5 -0
- data/lib/wordless/cli.rb +10 -81
- data/lib/wordless/version.rb +1 -1
- data/lib/wordless/wordless_cli.rb +122 -0
- data/setup_tests.sh +32 -0
- data/spec/cli_spec.rb +32 -27
- data/spec/fixtures/wordless_preferences.php +5 -0
- data/spec/spec_helper.rb +25 -2
- data/wordless.gemspec +15 -11
- metadata +88 -41
- data/lib/wordless/cli_helper.rb +0 -42
- data/spec/cli_helper_spec.rb +0 -65
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3da29df733fc405d1627fb449aa30b9fc9caf92b
|
4
|
+
data.tar.gz: 9c5bfd9561d5738dc776c89fc20e81a6687f4905
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d649552b3e245354cfd89d4e985929fe055bd457ec10be01091137b0006a0aa65fd8212a0578319dc2e2b7adfa544b57e8b65c0c49e4ad956fcee55d8caf1ce2
|
7
|
+
data.tar.gz: d3e7a3c362182c41b3ba2d7b7772be481e689daf7cc4627eee79a85e5b93c5304c8a804745433059d525ab10a06983a37106ffe735d50cb7d21454ea2104bfb5
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
@@ -1,37 +1,72 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
wordless (0.
|
5
|
-
activesupport
|
6
|
-
|
7
|
-
|
4
|
+
wordless (0.4.0)
|
5
|
+
activesupport
|
6
|
+
coffee-script
|
7
|
+
compass
|
8
|
+
sprockets
|
9
|
+
thor
|
10
|
+
wordpress_tools (~> 0.0.2)
|
11
|
+
yui-compressor
|
8
12
|
|
9
13
|
GEM
|
10
14
|
remote: https://rubygems.org/
|
11
15
|
specs:
|
12
|
-
activesupport (
|
13
|
-
i18n (~> 0.6)
|
14
|
-
|
15
|
-
|
16
|
+
activesupport (4.0.0)
|
17
|
+
i18n (~> 0.6, >= 0.6.4)
|
18
|
+
minitest (~> 4.2)
|
19
|
+
multi_json (~> 1.3)
|
20
|
+
thread_safe (~> 0.1)
|
21
|
+
tzinfo (~> 0.3.37)
|
22
|
+
atomic (1.1.13)
|
23
|
+
chunky_png (1.2.8)
|
24
|
+
coffee-script (2.2.0)
|
25
|
+
coffee-script-source
|
26
|
+
execjs
|
27
|
+
coffee-script-source (1.6.3)
|
28
|
+
compass (0.12.2)
|
29
|
+
chunky_png (~> 1.2)
|
30
|
+
fssm (>= 0.2.7)
|
31
|
+
sass (~> 3.1)
|
32
|
+
diff-lcs (1.2.4)
|
33
|
+
execjs (2.0.1)
|
16
34
|
fakeweb (1.3.0)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
rspec
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
35
|
+
fssm (0.2.10)
|
36
|
+
hike (1.2.3)
|
37
|
+
i18n (0.6.5)
|
38
|
+
minitest (4.7.5)
|
39
|
+
multi_json (1.7.9)
|
40
|
+
rack (1.5.2)
|
41
|
+
rake (10.1.0)
|
42
|
+
rspec (2.14.1)
|
43
|
+
rspec-core (~> 2.14.0)
|
44
|
+
rspec-expectations (~> 2.14.0)
|
45
|
+
rspec-mocks (~> 2.14.0)
|
46
|
+
rspec-core (2.14.5)
|
47
|
+
rspec-expectations (2.14.2)
|
48
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
49
|
+
rspec-mocks (2.14.3)
|
50
|
+
sass (3.2.10)
|
51
|
+
sprockets (2.10.0)
|
52
|
+
hike (~> 1.2)
|
53
|
+
multi_json (~> 1.0)
|
54
|
+
rack (~> 1.0)
|
55
|
+
tilt (~> 1.1, != 1.3.0)
|
56
|
+
thor (0.18.1)
|
57
|
+
thread_safe (0.1.2)
|
58
|
+
atomic
|
59
|
+
tilt (1.4.1)
|
60
|
+
tzinfo (0.3.37)
|
61
|
+
wordpress_tools (0.0.2)
|
62
|
+
rake
|
29
63
|
thor
|
64
|
+
yui-compressor (0.11.0)
|
30
65
|
|
31
66
|
PLATFORMS
|
32
67
|
ruby
|
33
68
|
|
34
69
|
DEPENDENCIES
|
35
70
|
fakeweb
|
36
|
-
rspec
|
71
|
+
rspec
|
37
72
|
wordless!
|
data/{README.md → README.mdown}
RENAMED
@@ -1,6 +1,14 @@
|
|
1
1
|
# Wordless
|
2
2
|
|
3
|
-
A command line tool to help manage your [Wordless](http://welaika.github.com/wordless/)-based WordPress sites.
|
3
|
+
A command line tool to help manage your [Wordless](http://welaika.github.com/wordless/)-based WordPress sites.
|
4
|
+
|
5
|
+
## Premise
|
6
|
+
|
7
|
+
This is a ruby-gem, so we expect you have already installed _ruby_; if it isn't
|
8
|
+
the case, probably you'll like to take a look to [RVM](http://rvm.io).
|
9
|
+
|
10
|
+
Wordless can't recognize if you are inside a wordpress' dirtree if you won't
|
11
|
+
be in the root dir; so use it from the root dir. Easy peasy.
|
4
12
|
|
5
13
|
## Installation
|
6
14
|
|
@@ -8,27 +16,59 @@ A command line tool to help manage your [Wordless](http://welaika.github.com/wor
|
|
8
16
|
|
9
17
|
## Usage
|
10
18
|
|
19
|
+
wordless help
|
20
|
+
|
21
|
+
Tasks:
|
22
|
+
wordless clean # Clean static assets
|
23
|
+
wordless compile # Compile static assets
|
24
|
+
wordless deploy # Deploy your WordPress site using the deploy_command defined in your Wordfile
|
25
|
+
wordless help [TASK] # Describe available tasks or one specific task
|
26
|
+
wordless install # Install the Wordless plugin into an existing WordPress installation
|
27
|
+
wordless new [NAME] # Download WordPress in specified directory, install the Wordless plugin and create a Wordless theme
|
28
|
+
wordless theme [NAME] # Create a new Wordless theme NAME
|
29
|
+
|
30
|
+
#### new
|
31
|
+
|
11
32
|
Create a new Wordless-enabled WordPress site in directory `mysite`. This downloads the latest stable release of WordPress (you can also specify a locale):
|
12
33
|
|
13
34
|
wordless new mysite
|
35
|
+
|
36
|
+
or
|
37
|
+
|
14
38
|
wordless new mysite --locale=fr_FR
|
15
39
|
|
40
|
+
#### install
|
41
|
+
|
16
42
|
If you already have WordPress installed, you can install the Wordless plugin (this currently installs from the master branch on GitHub):
|
17
43
|
|
18
44
|
wordless install
|
19
45
|
|
46
|
+
#### theme
|
47
|
+
|
20
48
|
Once Wordless is installed, you can create a new Wordless theme:
|
21
49
|
|
22
50
|
wordless theme mytheme
|
23
51
|
|
52
|
+
Note: don't try at home to use `wordless theme .`: it won't work! So call it within
|
53
|
+
the `wp-content/themes` dir and pass a theme name as argument.
|
54
|
+
|
55
|
+
#### compile
|
56
|
+
|
57
|
+
Note: if you have no idea why the need to compile assets, you should read the
|
58
|
+
Wordless' README.
|
59
|
+
|
24
60
|
Compile your site's static assets:
|
25
61
|
|
26
62
|
wordless compile
|
27
63
|
|
64
|
+
#### clean
|
65
|
+
|
28
66
|
Clean your compiled static assets:
|
29
67
|
|
30
68
|
wordless clean
|
31
69
|
|
70
|
+
#### deploy
|
71
|
+
|
32
72
|
Deploy your wordless installation using the `deploy_command` specified in your Wordfile:
|
33
73
|
|
34
74
|
wordless deploy
|
@@ -37,13 +77,9 @@ You can also use the refresh option `-r` to compile your assets before deploying
|
|
37
77
|
|
38
78
|
wordless deploy -r
|
39
79
|
|
40
|
-
Get some help:
|
41
|
-
|
42
|
-
wordless help
|
43
|
-
|
44
80
|
## Configuration
|
45
81
|
|
46
|
-
You can create a Wordfile to customize the behaviour of wordless:
|
82
|
+
You can, **optionally**, create a `Wordfile` to customize the behaviour of wordless:
|
47
83
|
|
48
84
|
```yaml
|
49
85
|
wordless_repo: 'git://github.com/welaika/wordless.git'
|
@@ -53,7 +89,7 @@ static_css:
|
|
53
89
|
static_js:
|
54
90
|
- 'wp-content/themes/mytheme/assets/javascripts/application.js'
|
55
91
|
- 'wp-content/themes/mytheme/assets/javascripts/mobile.js'
|
56
|
-
deploy_command: 'wordmove push -
|
92
|
+
deploy_command: 'wordmove push -t'
|
57
93
|
```
|
58
94
|
|
59
95
|
## Caveats
|
@@ -63,21 +99,7 @@ deploy_command: 'wordmove push -du'
|
|
63
99
|
|
64
100
|
## Running specs
|
65
101
|
|
66
|
-
|
67
|
-
|
68
|
-
git clone https://github.com/welaika/wordless.git spec/fixtures/wordless && cd spec/fixtures/wordless
|
69
|
-
|
70
|
-
Set your compass and ruby paths:
|
71
|
-
|
72
|
-
vim wordless/theme_builder/vanilla_theme/config/initializers/wordless_preferences.php
|
73
|
-
|
74
|
-
Commit your changes:
|
75
|
-
|
76
|
-
git commit -am "Set compass and ruby paths"
|
77
|
-
|
78
|
-
Go back to the wordless_gem directory and have fun:
|
79
|
-
|
80
|
-
cd - && rspec
|
102
|
+
bundle install && ./setup_tests && rspec
|
81
103
|
|
82
104
|
## Contributing
|
83
105
|
|
@@ -87,3 +109,4 @@ Go back to the wordless_gem directory and have fun:
|
|
87
109
|
4. Commit your changes (`git commit -am 'Added some feature'`)
|
88
110
|
5. Push to the branch (`git push origin my-new-feature`)
|
89
111
|
6. Create new Pull Request
|
112
|
+
|
data/Rakefile
CHANGED
data/lib/wordless/cli.rb
CHANGED
@@ -1,123 +1,52 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'yaml'
|
3
3
|
require 'net/http'
|
4
|
-
require 'rbconfig'
|
5
4
|
require 'tempfile'
|
6
|
-
require 'wordpress_tools/cli'
|
7
|
-
require 'wordless/cli_helper'
|
8
5
|
require 'active_support/all'
|
6
|
+
require 'wordless/wordless_cli'
|
9
7
|
|
10
8
|
module Wordless
|
11
9
|
class CLI < Thor
|
12
10
|
include Thor::Actions
|
13
|
-
include Wordless::CLIHelper
|
14
|
-
|
15
|
-
@@lib_dir = File.expand_path(File.dirname(__FILE__))
|
16
|
-
@@config = if File.exists?('Wordfile')
|
17
|
-
YAML::load(File.open('Wordfile')).symbolize_keys
|
18
|
-
else
|
19
|
-
{}
|
20
|
-
end
|
21
11
|
|
22
12
|
no_tasks do
|
23
|
-
def
|
24
|
-
|
13
|
+
def wordless_cli
|
14
|
+
Wordless::WordlessCLI.new(options, self)
|
25
15
|
end
|
26
16
|
end
|
27
17
|
|
28
18
|
desc "new [NAME]", "Download WordPress in specified directory, install the Wordless plugin and create a Wordless theme"
|
29
19
|
method_option :locale, :aliases => "-l", :desc => "WordPress locale (default is en_US)"
|
30
20
|
def new(name)
|
31
|
-
|
32
|
-
Dir.chdir(name)
|
33
|
-
install
|
34
|
-
theme(name)
|
21
|
+
wordless_cli.start(name)
|
35
22
|
end
|
36
23
|
|
37
24
|
desc "install", "Install the Wordless plugin into an existing WordPress installation"
|
38
25
|
def install
|
39
|
-
|
40
|
-
error "Git is not available. Please install git."
|
41
|
-
return
|
42
|
-
end
|
43
|
-
|
44
|
-
unless File.directory? 'wp-content/plugins'
|
45
|
-
error "Directory 'wp-content/plugins' not found. Make sure you're at the root level of a WordPress installation."
|
46
|
-
return
|
47
|
-
end
|
48
|
-
|
49
|
-
if add_git_repo wordless_repo, 'wp-content/plugins/wordless'
|
50
|
-
success "Installed Wordless plugin."
|
51
|
-
else
|
52
|
-
error "There was an error installing the Wordless plugin."
|
53
|
-
end
|
26
|
+
wordless_cli.install
|
54
27
|
end
|
55
28
|
|
56
29
|
desc "theme [NAME]", "Create a new Wordless theme NAME"
|
57
30
|
def theme(name)
|
58
|
-
|
59
|
-
error "Directory 'wp-content/themes' not found. Make sure you're at the root level of a WordPress installation."
|
60
|
-
return
|
61
|
-
end
|
62
|
-
|
63
|
-
# Run PHP helper script
|
64
|
-
if system "php #{File.join(@@lib_dir, 'theme_builder.php')} #{name}"
|
65
|
-
success "Created a new Wordless theme in 'wp-content/themes/#{name}'."
|
66
|
-
else
|
67
|
-
error "Couldn't create Wordless theme."
|
68
|
-
return
|
69
|
-
end
|
31
|
+
wordless_cli.theme(name)
|
70
32
|
end
|
71
33
|
|
72
34
|
desc "compile", "Compile static assets"
|
73
35
|
def compile
|
74
|
-
|
75
|
-
success "Compiled static assets."
|
76
|
-
else
|
77
|
-
error "Couldn't compile static assets."
|
78
|
-
end
|
36
|
+
wordless_cli.compile
|
79
37
|
end
|
80
38
|
|
81
39
|
desc "clean", "Clean static assets"
|
82
40
|
def clean
|
83
|
-
|
84
|
-
error "Directory 'wp-content/themes' not found. Make sure you're at the root level of a WordPress installation."
|
85
|
-
return
|
86
|
-
end
|
87
|
-
|
88
|
-
static_css = Array(@@config[:static_css] || Dir['wp-content/themes/*/assets/stylesheets/screen.css'])
|
89
|
-
static_js = Array(@@config[:static_js] || Dir['wp-content/themes/*/assets/javascripts/application.js'])
|
90
|
-
|
91
|
-
begin
|
92
|
-
(static_css + static_js).each do |file|
|
93
|
-
FileUtils.rm_f(file) if File.exists?(file)
|
94
|
-
end
|
95
|
-
success "Cleaned static assets."
|
96
|
-
rescue
|
97
|
-
error "Couldn't clean static assets."
|
98
|
-
end
|
41
|
+
wordless_cli.clean
|
99
42
|
end
|
100
43
|
|
101
44
|
desc "deploy", "Deploy your WordPress site using the deploy_command defined in your Wordfile"
|
102
45
|
method_option :refresh, :aliases => "-r", :desc => "Compile static assets before deploying and clean them afterwards"
|
103
46
|
method_option :command, :aliases => "-c", :desc => "Use a custom deploy command"
|
104
47
|
def deploy
|
105
|
-
|
106
|
-
error "WordPress not found. Make sure you're at the root level of a WordPress installation."
|
107
|
-
return
|
108
|
-
end
|
109
|
-
|
110
|
-
compile if options['refresh']
|
111
|
-
|
112
|
-
deploy_command = options['command'].presence || @@config[:deploy_command]
|
113
|
-
|
114
|
-
if deploy_command
|
115
|
-
system "#{deploy_command}"
|
116
|
-
else
|
117
|
-
error "deploy_command not set. Make sure it is included in your Wordfile."
|
118
|
-
end
|
119
|
-
|
120
|
-
clean if options['refresh']
|
48
|
+
wordless_cli.deploy
|
121
49
|
end
|
122
50
|
end
|
123
51
|
end
|
52
|
+
|
data/lib/wordless/version.rb
CHANGED
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'wordpress_tools/cli'
|
2
|
+
|
3
|
+
module Wordless
|
4
|
+
class WordlessCLI
|
5
|
+
include WordPressTools::CLIHelper
|
6
|
+
attr_reader :options, :thor
|
7
|
+
|
8
|
+
def lib_dir
|
9
|
+
@@lib_dir ||= File.expand_path(File.dirname(__FILE__))
|
10
|
+
end
|
11
|
+
|
12
|
+
def config
|
13
|
+
@@config ||= (
|
14
|
+
if File.exists?('Wordfile')
|
15
|
+
YAML::load(File.open('Wordfile')).symbolize_keys
|
16
|
+
else
|
17
|
+
{}
|
18
|
+
end
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
[ :say, :run ].each do |sym|
|
23
|
+
define_method sym do |*args|
|
24
|
+
thor.send(sym, *args)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(options = {}, thor = nil)
|
29
|
+
@options = options
|
30
|
+
@thor = thor
|
31
|
+
end
|
32
|
+
|
33
|
+
def start(name)
|
34
|
+
WordPressTools::CLI.new.invoke('new', [name], :bare => true, :locale => options['locale'])
|
35
|
+
Dir.chdir(name)
|
36
|
+
install
|
37
|
+
theme(name)
|
38
|
+
end
|
39
|
+
|
40
|
+
def install
|
41
|
+
unless git_installed?
|
42
|
+
error "Git is not available. Please install git."
|
43
|
+
end
|
44
|
+
|
45
|
+
unless File.directory? 'wp-content/plugins'
|
46
|
+
error "Directory 'wp-content/plugins' not found. Make sure you're at the root level of a WordPress installation."
|
47
|
+
end
|
48
|
+
|
49
|
+
if run_command "git clone #{wordless_repo} wp-content/plugins/wordless"
|
50
|
+
success "Installed Wordless plugin."
|
51
|
+
else
|
52
|
+
error "There was an error installing the Wordless plugin."
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def theme(name)
|
57
|
+
if File.directory? 'wp-content/themes'
|
58
|
+
# Run PHP helper script
|
59
|
+
if system "php #{File.join(lib_dir, 'theme_builder.php')} #{name}"
|
60
|
+
success "Created a new Wordless theme in 'wp-content/themes/#{name}'."
|
61
|
+
else
|
62
|
+
error "Couldn't create Wordless theme."
|
63
|
+
end
|
64
|
+
else
|
65
|
+
error "Directory 'wp-content/themes' not found. Make sure you're at the root level of a WordPress installation."
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def compile
|
70
|
+
if system "php #{File.join(lib_dir, 'compile_assets.php')}"
|
71
|
+
success "Compiled static assets."
|
72
|
+
else
|
73
|
+
error "Couldn't compile static assets."
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def clean
|
78
|
+
if File.directory? 'wp-content/themes'
|
79
|
+
static_css = Array(config[:static_css] || Dir['wp-content/themes/*/assets/stylesheets/screen.css'])
|
80
|
+
static_js = Array(config[:static_js] || Dir['wp-content/themes/*/assets/javascripts/application.js'])
|
81
|
+
|
82
|
+
(static_css + static_js).each do |file|
|
83
|
+
FileUtils.rm_f(file) if File.exists?(file)
|
84
|
+
end
|
85
|
+
|
86
|
+
success "Cleaned static assets."
|
87
|
+
else
|
88
|
+
error "Directory 'wp-content/themes' not found. Make sure you're at the root level of a WordPress installation."
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def deploy
|
93
|
+
unless File.exists? 'wp-config.php'
|
94
|
+
error "WordPress not found. Make sure you're at the root level of a WordPress installation."
|
95
|
+
end
|
96
|
+
|
97
|
+
compile if options['refresh']
|
98
|
+
|
99
|
+
deploy_command = options['command'].presence || config[:deploy_command]
|
100
|
+
|
101
|
+
if deploy_command
|
102
|
+
system "#{deploy_command}"
|
103
|
+
else
|
104
|
+
error "deploy_command not set. Make sure it is included in your Wordfile."
|
105
|
+
end
|
106
|
+
|
107
|
+
clean if options['refresh']
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def wordless_repo
|
113
|
+
config[:wordless_repo] || 'git://github.com/welaika/wordless.git'
|
114
|
+
end
|
115
|
+
|
116
|
+
def add_git_repo(repo, destination)
|
117
|
+
run_command "git clone #{repo} #{destination}"
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
data/setup_tests.sh
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#! /bin/bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
FIXTURE_PATH="spec/fixtures/wordless"
|
6
|
+
WORDLESS_REPO="git://github.com/welaika/wordless.git"
|
7
|
+
WORDLESS_PREFERENCES="wordless/theme_builder/vanilla_theme/config/initializers/wordless_preferences.php"
|
8
|
+
|
9
|
+
function log {
|
10
|
+
echo;
|
11
|
+
echo "== [ $1 ] ==";
|
12
|
+
}
|
13
|
+
|
14
|
+
rm -rf $FIXTURE_PATH
|
15
|
+
|
16
|
+
log "Cloning wordless repo"
|
17
|
+
git clone --branch=master $WORDLESS_REPO $FIXTURE_PATH && cd $FIXTURE_PATH
|
18
|
+
|
19
|
+
log "Customizing ruby and compass paths"
|
20
|
+
echo "# BEGIN: wordless_preferences.php"
|
21
|
+
cp -f ../wordless_preferences.php $WORDLESS_PREFERENCES
|
22
|
+
perl -p -i -e "s|<RUBY_PATH>|$(which ruby)|" $WORDLESS_PREFERENCES
|
23
|
+
perl -p -i -e "s|<COMPASS_PATH>|$(which compass)|" $WORDLESS_PREFERENCES
|
24
|
+
cat $WORDLESS_PREFERENCES
|
25
|
+
echo "# END: wordless_preferences.php"
|
26
|
+
|
27
|
+
log "Committing changes to test repo"
|
28
|
+
git config user.name "Wordless Tester"
|
29
|
+
git config user.email "tester@wordless.com"
|
30
|
+
git commit -am "updated ruby and compass path"
|
31
|
+
|
32
|
+
log "DONE!"
|
data/spec/cli_spec.rb
CHANGED
@@ -1,32 +1,24 @@
|
|
1
|
+
require 'thor'
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe Wordless::CLI do
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
upgrade
|
8
|
-
http://wordpress.org/download/
|
9
|
-
http://wordpress.org/wordpress-3.3.1.zip
|
10
|
-
3.3.1
|
11
|
-
en_US
|
12
|
-
5.2.4
|
13
|
-
5.0
|
14
|
-
eof
|
15
|
-
FakeWeb.register_uri(:get, %r|http://api.wordpress.org/core/version-check/1.5/.*|, :body => wp_api_response)
|
16
|
-
FakeWeb.register_uri(:get, "http://wordpress.org/wordpress-3.3.1.zip", :body => File.expand_path('spec/fixtures/wordpress_stub.zip'))
|
6
|
+
let(:config) do
|
7
|
+
{ :wordless_repo => File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'wordless')) }
|
17
8
|
end
|
18
9
|
|
19
|
-
before
|
20
|
-
Wordless::
|
21
|
-
|
22
|
-
|
10
|
+
before do
|
11
|
+
Wordless::WordlessCLI.class_variable_set(:@@config, config)
|
12
|
+
end
|
13
|
+
|
14
|
+
before do
|
23
15
|
@original_wd = Dir.pwd
|
24
16
|
Dir.chdir('tmp')
|
25
17
|
end
|
26
18
|
|
27
|
-
after
|
19
|
+
after do
|
28
20
|
Dir.chdir(@original_wd)
|
29
|
-
|
21
|
+
Dir["tmp/*"].each do |dir|
|
30
22
|
FileUtils.rm_rf(dir) if File.directory? dir
|
31
23
|
end
|
32
24
|
end
|
@@ -85,14 +77,21 @@ describe Wordless::CLI do
|
|
85
77
|
|
86
78
|
context "#compile" do
|
87
79
|
context "with a valid Wordless installation" do
|
80
|
+
let(:compiled_css) { 'wp-content/themes/myapp/assets/stylesheets/screen.css' }
|
81
|
+
let(:compiled_js) { 'wp-content/themes/myapp/assets/javascripts/application.js' }
|
82
|
+
|
88
83
|
before :each do
|
89
84
|
Wordless::CLI.start ['new', 'myapp']
|
90
85
|
end
|
91
86
|
|
92
87
|
it "compiles static assets" do
|
93
88
|
Wordless::CLI.start ['compile']
|
94
|
-
|
95
|
-
File.exists?(
|
89
|
+
|
90
|
+
File.exists?(compiled_css).should be_true
|
91
|
+
File.exists?(compiled_js).should be_true
|
92
|
+
|
93
|
+
File.readlines(compiled_css).grep(/html{line-height:1}/).should_not be_empty
|
94
|
+
File.readlines(compiled_js).grep(/return "Yep, it works!";/).should_not be_empty
|
96
95
|
end
|
97
96
|
end
|
98
97
|
end
|
@@ -123,7 +122,7 @@ describe Wordless::CLI do
|
|
123
122
|
end
|
124
123
|
|
125
124
|
it "should remove assets specified on config" do
|
126
|
-
Wordless::
|
125
|
+
Wordless::WordlessCLI.class_variable_set :@@config, {
|
127
126
|
:static_css => [ first_css, second_css ],
|
128
127
|
:static_js => [ first_js, second_js ]
|
129
128
|
}
|
@@ -144,11 +143,16 @@ describe Wordless::CLI do
|
|
144
143
|
|
145
144
|
let(:cli) { Wordless::CLI.new }
|
146
145
|
let(:file) { 'shrubbery.txt' }
|
146
|
+
let(:wordless_cli) { Wordless::WordlessCLI.new({}, Thor.new) }
|
147
147
|
|
148
|
-
before
|
148
|
+
before do
|
149
149
|
FileUtils.mkdir_p('myapp') and Dir.chdir('myapp')
|
150
150
|
FileUtils.touch('wp-config.php')
|
151
|
-
|
151
|
+
end
|
152
|
+
|
153
|
+
before do
|
154
|
+
cli.stub(:wordless_cli).and_return(wordless_cli)
|
155
|
+
Wordless::WordlessCLI.class_variable_set :@@config, {
|
152
156
|
:deploy_command => "touch #{file}"
|
153
157
|
}
|
154
158
|
end
|
@@ -159,9 +163,10 @@ describe Wordless::CLI do
|
|
159
163
|
end
|
160
164
|
|
161
165
|
it "should compile and clean if refresh option is passed" do
|
162
|
-
|
163
|
-
|
164
|
-
|
166
|
+
wordless_cli.should_receive(:compile).and_return(true)
|
167
|
+
wordless_cli.should_receive(:clean).and_return(true)
|
168
|
+
wordless_cli.stub(:options).and_return({ 'refresh' => true })
|
169
|
+
|
165
170
|
cli.deploy
|
166
171
|
end
|
167
172
|
|
@@ -169,7 +174,7 @@ describe Wordless::CLI do
|
|
169
174
|
let(:file) { 'knights.txt' }
|
170
175
|
|
171
176
|
it "should launch the custom deploy command" do
|
172
|
-
|
177
|
+
wordless_cli.stub(:options).and_return({ 'command' => "touch #{file}" })
|
173
178
|
cli.deploy
|
174
179
|
File.exists?(file).should be_true
|
175
180
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,9 +2,31 @@ require 'wordless/cli'
|
|
2
2
|
require 'fakeweb'
|
3
3
|
require 'thor'
|
4
4
|
|
5
|
+
module WordPressTools
|
6
|
+
module CLIHelper
|
7
|
+
def exit; end
|
8
|
+
def info(message); end
|
9
|
+
def success(message); end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
5
13
|
RSpec.configure do |config|
|
6
|
-
|
7
|
-
|
14
|
+
|
15
|
+
config.before(:all) do
|
16
|
+
FileUtils.mkdir('tmp') unless File.directory? 'tmp'
|
17
|
+
FakeWeb.allow_net_connect = false
|
18
|
+
WP_API_RESPONSE = <<-eof
|
19
|
+
upgrade
|
20
|
+
http://wordpress.org/download/
|
21
|
+
http://wordpress.org/wordpress-3.6.zip
|
22
|
+
3.6
|
23
|
+
en_US
|
24
|
+
5.2.4
|
25
|
+
5.0
|
26
|
+
eof
|
27
|
+
FakeWeb.register_uri(:get, %r|http://api.wordpress.org/core/version-check/1.5/.*|, :body => WP_API_RESPONSE)
|
28
|
+
FakeWeb.register_uri(:get, "http://wordpress.org/wordpress-3.6.zip", :body => File.expand_path('spec/fixtures/wordpress_stub.zip'))
|
29
|
+
end
|
8
30
|
|
9
31
|
# utility to log commands output or errors
|
10
32
|
def capture(stream)
|
@@ -16,6 +38,7 @@ RSpec.configure do |config|
|
|
16
38
|
ensure
|
17
39
|
eval("$#{stream} = #{stream.upcase}")
|
18
40
|
end
|
41
|
+
|
19
42
|
result
|
20
43
|
end
|
21
44
|
end
|
data/wordless.gemspec
CHANGED
@@ -1,24 +1,28 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
require File.expand_path('../lib/wordless/version', __FILE__)
|
3
2
|
|
4
3
|
Gem::Specification.new do |gem|
|
5
4
|
gem.authors = ["Étienne Després", "Ju Liu"]
|
6
|
-
gem.email = ["etienne@molotov.ca"]
|
5
|
+
gem.email = ["etienne@molotov.ca", "ju.liu@welaika.com"]
|
7
6
|
gem.description = %q{Command line tool to manage Wordless themes.}
|
8
7
|
gem.summary = %q{Manage Wordless themes.}
|
9
|
-
gem.homepage = "http://github.com/
|
10
|
-
|
11
|
-
gem.add_dependency "thor", "~> 0.16.0"
|
12
|
-
gem.add_dependency "wordpress_tools", '~> 0.0.1'
|
13
|
-
gem.add_dependency "activesupport", '~> 3.2.0'
|
14
|
-
|
15
|
-
gem.add_development_dependency 'rspec', "~> 2.11.0"
|
16
|
-
gem.add_development_dependency 'fakeweb'
|
17
|
-
|
8
|
+
gem.homepage = "http://github.com/welaika/wordless_gem"
|
9
|
+
|
18
10
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
11
|
gem.files = `git ls-files`.split("\n")
|
20
12
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
13
|
gem.name = "wordless"
|
22
14
|
gem.require_paths = ["lib"]
|
23
15
|
gem.version = Wordless::VERSION
|
16
|
+
|
17
|
+
gem.add_dependency "thor"
|
18
|
+
gem.add_dependency "sprockets"
|
19
|
+
gem.add_dependency "compass"
|
20
|
+
gem.add_dependency "coffee-script"
|
21
|
+
gem.add_dependency "yui-compressor"
|
22
|
+
gem.add_dependency "activesupport"
|
23
|
+
gem.add_dependency "wordpress_tools", '~> 0.0.2'
|
24
|
+
|
25
|
+
gem.add_development_dependency 'rspec'
|
26
|
+
gem.add_development_dependency 'fakeweb'
|
24
27
|
end
|
28
|
+
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wordless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Étienne Després
|
@@ -10,91 +9,138 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2013-08-31 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: thor
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - '>='
|
21
19
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0
|
20
|
+
version: '0'
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- -
|
25
|
+
- - '>='
|
29
26
|
- !ruby/object:Gem::Version
|
30
|
-
version: 0
|
27
|
+
version: '0'
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
|
-
name:
|
29
|
+
name: sprockets
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- -
|
32
|
+
- - '>='
|
37
33
|
- !ruby/object:Gem::Version
|
38
|
-
version: 0
|
34
|
+
version: '0'
|
39
35
|
type: :runtime
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- -
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: compass
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: coffee-script
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
45
68
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: yui-compressor
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
47
84
|
- !ruby/object:Gem::Dependency
|
48
85
|
name: activesupport
|
49
86
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: wordpress_tools
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
51
101
|
requirements:
|
52
102
|
- - ~>
|
53
103
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
104
|
+
version: 0.0.2
|
55
105
|
type: :runtime
|
56
106
|
prerelease: false
|
57
107
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
108
|
requirements:
|
60
109
|
- - ~>
|
61
110
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
111
|
+
version: 0.0.2
|
63
112
|
- !ruby/object:Gem::Dependency
|
64
113
|
name: rspec
|
65
114
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
115
|
requirements:
|
68
|
-
- -
|
116
|
+
- - '>='
|
69
117
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
118
|
+
version: '0'
|
71
119
|
type: :development
|
72
120
|
prerelease: false
|
73
121
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
122
|
requirements:
|
76
|
-
- -
|
123
|
+
- - '>='
|
77
124
|
- !ruby/object:Gem::Version
|
78
|
-
version:
|
125
|
+
version: '0'
|
79
126
|
- !ruby/object:Gem::Dependency
|
80
127
|
name: fakeweb
|
81
128
|
requirement: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
129
|
requirements:
|
84
|
-
- -
|
130
|
+
- - '>='
|
85
131
|
- !ruby/object:Gem::Version
|
86
132
|
version: '0'
|
87
133
|
type: :development
|
88
134
|
prerelease: false
|
89
135
|
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
136
|
requirements:
|
92
|
-
- -
|
137
|
+
- - '>='
|
93
138
|
- !ruby/object:Gem::Version
|
94
139
|
version: '0'
|
95
140
|
description: Command line tool to manage Wordless themes.
|
96
141
|
email:
|
97
142
|
- etienne@molotov.ca
|
143
|
+
- ju.liu@welaika.com
|
98
144
|
executables:
|
99
145
|
- wordless
|
100
146
|
extensions: []
|
@@ -102,52 +148,53 @@ extra_rdoc_files: []
|
|
102
148
|
files:
|
103
149
|
- .gitignore
|
104
150
|
- .rspec
|
151
|
+
- .travis.yml
|
105
152
|
- Gemfile
|
106
153
|
- Gemfile.lock
|
107
154
|
- LICENSE
|
108
|
-
- README.
|
155
|
+
- README.mdown
|
109
156
|
- Rakefile
|
110
157
|
- bin/wordless
|
111
158
|
- lib/wordless.rb
|
112
159
|
- lib/wordless/cli.rb
|
113
|
-
- lib/wordless/cli_helper.rb
|
114
160
|
- lib/wordless/compile_assets.php
|
115
161
|
- lib/wordless/theme_builder.php
|
116
162
|
- lib/wordless/version.rb
|
117
163
|
- lib/wordless/wordless_bridge.php
|
118
|
-
-
|
164
|
+
- lib/wordless/wordless_cli.rb
|
165
|
+
- setup_tests.sh
|
119
166
|
- spec/cli_spec.rb
|
167
|
+
- spec/fixtures/wordless_preferences.php
|
120
168
|
- spec/fixtures/wordpress_stub.zip
|
121
169
|
- spec/fixtures/zipped_file.zip
|
122
170
|
- spec/spec_helper.rb
|
123
171
|
- wordless.gemspec
|
124
|
-
homepage: http://github.com/
|
172
|
+
homepage: http://github.com/welaika/wordless_gem
|
125
173
|
licenses: []
|
174
|
+
metadata: {}
|
126
175
|
post_install_message:
|
127
176
|
rdoc_options: []
|
128
177
|
require_paths:
|
129
178
|
- lib
|
130
179
|
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
-
none: false
|
132
180
|
requirements:
|
133
|
-
- -
|
181
|
+
- - '>='
|
134
182
|
- !ruby/object:Gem::Version
|
135
183
|
version: '0'
|
136
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
185
|
requirements:
|
139
|
-
- -
|
186
|
+
- - '>='
|
140
187
|
- !ruby/object:Gem::Version
|
141
188
|
version: '0'
|
142
189
|
requirements: []
|
143
190
|
rubyforge_project:
|
144
|
-
rubygems_version:
|
191
|
+
rubygems_version: 2.0.3
|
145
192
|
signing_key:
|
146
|
-
specification_version:
|
193
|
+
specification_version: 4
|
147
194
|
summary: Manage Wordless themes.
|
148
195
|
test_files:
|
149
|
-
- spec/cli_helper_spec.rb
|
150
196
|
- spec/cli_spec.rb
|
197
|
+
- spec/fixtures/wordless_preferences.php
|
151
198
|
- spec/fixtures/wordpress_stub.zip
|
152
199
|
- spec/fixtures/zipped_file.zip
|
153
200
|
- spec/spec_helper.rb
|
data/lib/wordless/cli_helper.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
|
3
|
-
module Wordless
|
4
|
-
module CLIHelper
|
5
|
-
def error(message)
|
6
|
-
say message, :red
|
7
|
-
end
|
8
|
-
|
9
|
-
def success(message)
|
10
|
-
say message, :green
|
11
|
-
end
|
12
|
-
|
13
|
-
def warning(message)
|
14
|
-
say message, :yellow
|
15
|
-
end
|
16
|
-
|
17
|
-
def download(url, destination)
|
18
|
-
begin
|
19
|
-
f = open(destination, "wb")
|
20
|
-
f.write(open(url).read) ? true : false
|
21
|
-
rescue
|
22
|
-
false
|
23
|
-
ensure
|
24
|
-
f.close
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def unzip(file, destination)
|
29
|
-
run "unzip #{file} -d #{destination}", :verbose => false, :capture => true
|
30
|
-
end
|
31
|
-
|
32
|
-
def git_installed?
|
33
|
-
# http://stackoverflow.com/questions/4597490/platform-independent-way-of-detecting-if-git-is-installed
|
34
|
-
void = RbConfig::CONFIG['host_os'] =~ /msdos|mswin|djgpp|mingw/ ? 'NUL' : '/dev/null'
|
35
|
-
system "git --version >>#{void} 2>&1"
|
36
|
-
end
|
37
|
-
|
38
|
-
def add_git_repo(repo, destination)
|
39
|
-
run "git clone #{repo} #{destination}", :verbose => false, :capture => true
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
data/spec/cli_helper_spec.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Wordless::CLIHelper do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
@cli = Wordless::CLI.new
|
7
|
-
end
|
8
|
-
|
9
|
-
context "::download" do
|
10
|
-
before(:each) do
|
11
|
-
@tempfile = Tempfile.new("download_test")
|
12
|
-
@valid_url = "http://www.example.com/test"
|
13
|
-
FakeWeb.register_uri(:get, @valid_url, :body => "Download test")
|
14
|
-
end
|
15
|
-
|
16
|
-
it "downloads a file to the specified location" do
|
17
|
-
@cli.download(@valid_url, @tempfile.path)
|
18
|
-
open(@tempfile.path).read.should == "Download test"
|
19
|
-
end
|
20
|
-
|
21
|
-
it "returns true on success" do
|
22
|
-
@cli.download(@valid_url, @tempfile.path).should be_true
|
23
|
-
end
|
24
|
-
|
25
|
-
it "returns false on failure" do
|
26
|
-
@cli.download("http://an.invalid.url", @tempfile.path).should be_false
|
27
|
-
end
|
28
|
-
|
29
|
-
after(:each) do
|
30
|
-
@tempfile.close!
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "::unzip" do
|
35
|
-
it "unzips a file" do
|
36
|
-
@cli.unzip(File.expand_path('spec/fixtures/zipped_file.zip'), 'tmp/unzip')
|
37
|
-
File.exists?('tmp/unzip/zipped_file').should be_true
|
38
|
-
end
|
39
|
-
|
40
|
-
after(:each) do
|
41
|
-
FileUtils.rm_rf('tmp/unzip') if File.directory? 'tmp/unzip'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "::error" do
|
46
|
-
it "displays an error" do
|
47
|
-
$stdout.should_receive(:puts).with("\e[31mI am an error\e[0m")
|
48
|
-
@cli.error("I am an error")
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "::success" do
|
53
|
-
it "displays a success message" do
|
54
|
-
$stdout.should_receive(:puts).with("\e[32mI am a success message\e[0m")
|
55
|
-
@cli.success("I am a success message")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "::warning" do
|
60
|
-
it "displays a warning" do
|
61
|
-
$stdout.should_receive(:puts).with("\e[33mI am a warning\e[0m")
|
62
|
-
@cli.warning("I am a warning")
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|