theme-juice 0.26.3 → 0.27.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 993a7061f134c09e5214a50afd234d7c72f3e56a
4
- data.tar.gz: cac7fcedefb39e8d768727237ed03014522f4dfe
3
+ metadata.gz: 290cdb9fdc0a7207ea88f2fb585739bb55292df5
4
+ data.tar.gz: 25f14c0e4f8f24f2eedeaeec05fa676448cfcfce
5
5
  SHA512:
6
- metadata.gz: 060a2da004e18ec839ab6e25d7bdd0fb95c9f1a50ac1e75e783056590e4ad25d804836987e4fb4406a3ef5b19c7bded3cc1126cc46ed022b9613a3bef4ab6295
7
- data.tar.gz: 4e738554ac822d7e020f200b60570d8cf39b2cb022b0544d3e34cceb2d71c0cc947dd812012a07a26920e56fc142f424016f42963aa5075c425733b4e6ae4d07
6
+ metadata.gz: 775f94c36331cb9b3aa8efce9c4fb5c38efa8a6a4c3f98ab374aacfd8f8a309ab4ec2035d04318e8cab4c8ac2a75f8de777d7e55d4858a66c4ffa1dac11ba9ff
7
+ data.tar.gz: b530f9705253ec34e80512d58d5e3b80319e08554f09b3dd2368393b3eaef67ce997f470befd2c0084dbced47d576be14e6241a8f6310e78cf9c59bdc88a5b2b
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  ![Theme Juice CLI](demo.gif)
9
9
 
10
10
  ## What is it?
11
- The [Theme Juice CLI](http://themejuice.it), also known as `tj`, helps you create new local WordPress development sites, manage existing sites, and deploy them, all from the command line. It utilizes our [Graft VM](https://github.com/ezekg/theme-juice-vm) for the virtual machine to spin up new development sites in seconds.
11
+ The [Theme Juice CLI](http://themejuice.it), also known as `tj`, helps you create new local WordPress development sites, manage existing sites, and deploy them, all from the command line. It utilizes our [Graft VM](https://github.com/ezekg/graft) for the virtual machine to spin up new development sites in seconds.
12
12
 
13
13
  Check out [our getting started guide over at SitePoint](http://www.sitepoint.com/introducing-theme-juice-for-local-wordpress-development/), or [view the documentation site](http://themejuice.it).
14
14
 
@@ -64,15 +64,15 @@ tj create
64
64
  #### What happens on your first `create`?
65
65
  1. `tj` will execute `tj init` if the VM is uninitialized
66
66
  1. `tj` will clone the selected starter template
67
- 1. `tj` will run the starter template's Juicefile `install` command
67
+ 1. `tj` will run the starter template's `Juicefile` install command
68
68
  1. `tj` will create all of the necessary project files, such as:
69
- * `Customfile` containing DNS and synced folder settings
70
- * `init-custom.sql` containing database setup
71
- * `project.conf` containing server settings
72
- * `wp-cli.local.yml` containing VM paths
69
+ * Create/append to `Customfile` containing DNS and synced folder settings
70
+ * Create/append to `init-custom.sql` for database creation and setup
71
+ * Create `$project.conf` containing Apache server settings
72
+ * Create `wp-cli.local.yml` containing SSH settings
73
73
  1. `tj` will provision the VM to put the new configuration into effect
74
74
 
75
- If you've never used `tj` before, then that last step might take awhile. After that's done, you should be able to access your new project at the specified url. It's that easy!
75
+ If you've never used `tj` before, then that last step might take a little while. After that's done, you should be able to access your new project at the specified development url. It's that easy!
76
76
 
77
77
  ### Set up an existing project
78
78
  This sets up an existing local project within the development environment. You will go through a series of prompts to create the necessary files. This command is essentially an alias for `tj create --bare`.
@@ -91,7 +91,7 @@ tj delete
91
91
  ```
92
92
 
93
93
  ### Deploy a project
94
- This will deploy a project to the passed `<stage>` using [Capistrano](http://capistranorb.com/). Head over to the [docs](http://themejuice.it/deploy) to see all of the available commands. There's a quick getting started section there too for your first deployment!
94
+ After configuring your `Juicefile` and setting up SSH keys for yourself, this will deploy a project to the passed `<stage>` using [Capistrano](http://capistranorb.com/). Head over to the [docs](http://themejuice.it/deploy) to see all of the available commands. There's a quick getting started section there too for your first deployment!
95
95
 
96
96
  ```
97
97
  tj deploy <stage>
@@ -119,18 +119,19 @@ Or, you can also check out [themejuice.it](http://themejuice.it) for a pretty we
119
119
  1. [Can I integrate my deployments with Slack?](#can-i-integrate-my-deployments-with-slack)
120
120
  1. [Can I use a self-signed SSL cert?](#can-i-use-a-self-signed-ssl-cert)
121
121
  1. [Can I define my own Capistrano tasks?](#can-i-define-my-own-capistrano-tasks)
122
+ 1. [Can I run `wp-cli` commands on my deployment stages?](#can-i-run-wp-cli-commands-on-my-deployment-stages)
122
123
  1. [Troubleshooting](#troubleshooting)
123
124
 
124
125
  ### Is Windows supported?
125
126
  Yes! But, since Windows doesn't support UTF-8 characters inside of the terminal, and is picky about ANSI color codes, you'll probably have to run `tj` with a couple flags.
126
127
 
127
- Something that has worked for me on one of my Windows machines is to run all commands through [git-scm](http://git-scm.com/downloads) with the `--boring --no-landrush` flags. This will disable all unicode characters and colors from being output, and will also disable [Landrush](https://github.com/phinze/landrush), which isn't fully supported on Windows.
128
+ Something that has worked for me on one of my Windows machines is to run all commands through [git-scm](http://git-scm.com/downloads) with the `--boring` flags. This will disable all unicode characters and colors from being output. You may also use the `--no-landrush` flag to disable [Landrush](https://github.com/phinze/landrush), which currently has experimental Windows support (at least try it first and help report any bugs!).
128
129
 
129
- To set these globally via the `ENV`, set the following environment variables or run the commands below in your terminal:
130
+ To set these globally via the `ENV`, set the following environment variables:
130
131
 
131
132
  ```bash
132
- export TJ_BORING=true
133
- export TJ_NO_LANDRUSH=true
133
+ TJ_BORING=true
134
+ TJ_NO_LANDRUSH=true
134
135
  ```
135
136
 
136
137
  In addition to that, `tj` uses the [OS gem](https://github.com/rdp/os) to sniff out your OS and it'll adjust a few things accordingly to make sure that nothing breaks.
@@ -141,15 +142,15 @@ _I don't regularly develop on Windows, so if you encounter any bugs, please let
141
142
  Definitely. If you want to use `tj` with Nginx and say, [VVV](https://github.com/Varying-Vagrant-Vagrants/VVV), it's as simple as running `tj` with a few flags:
142
143
 
143
144
  ```bash
144
- tj new --vm-box git@github.com:Varying-Vagrant-Vagrants/VVV.git --nginx
145
+ tj new --vm-box git@github.com:Varying-Vagrant-Vagrants/VVV.git --vm-ip 192.168.50.4 --nginx
145
146
  ```
146
147
 
147
- To use these permanently, set the appropriate `ENV` variables through your `.bashrc` or similar, i.e. `export TJ_VM_BOX=git@github.com:Varying-Vagrant-Vagrants/VVV.git` and `export TJ_NGINX=true`.
148
+ To use these permanently, set the appropriate `ENV` variables through your `.bashrc` or similar, i.e. `export TJ_VM_BOX=git@github.com:Varying-Vagrant-Vagrants/VVV.git`, `export TJ_VM_IP=192.168.50.4` and `export TJ_NGINX=true`.
148
149
 
149
- _Note: Before running this, you might want to either choose a new `vm-path`, or destroy any existing VMs inside of your `~/tj-vagrant` directory. If `tj` detects that a VM already installed, it will skip installing the new box._
150
+ _Note: Before running this, you might want to either choose a new `vm-path`, or destroy and remove any existing VMs inside of your `~/tj-vagrant` directory. If `tj` detects that a VM already installed, it will skip installing the new box._
150
151
 
151
152
  ### So, does that mean I can use any Vagrant box?
152
- Yes and no; in order for `tj` to properly create a project, the Vagrant box needs to follow the same directory structure as [Graft](https://github.com/ezekg/theme-juice-vm), and include logic for a `Customfile`. Here is the required structure that `tj` needs in order to be able to create new projects:
153
+ Yes and no; in order for `tj` to properly create a project, the Vagrant box needs to follow the same directory structure as [Graft](https://github.com/ezekg/graft), and include logic for a `Customfile`. Here is the required structure that `tj` needs in order to be able to create new projects:
153
154
 
154
155
  ```
155
156
  ├── config/
@@ -184,70 +185,72 @@ Yes and no; in order for `tj` to properly create a project, the Vagrant box need
184
185
  ```
185
186
 
186
187
  ### What is a `Customfile`?
187
- [It's a file that contains custom rules to add into the main `Vagrantfile`, without actually having to modify it](https://github.com/ezekg/theme-juice-vm/blob/master/Vagrantfile?ts=2#L96-L98). This allows us to easily modify the Vagrant box without causing merge conflicts if you were to update the VM source via `git pull`. Every file that `tj` modifies is _meant to be modified_, so at any time you may update your installation of Graft with a simple `git pull` without getting merge conflicts out the wazoo.
188
+ [It's a file that contains custom rules to add into the main `Vagrantfile`, without actually having to modify it](https://github.com/ezekg/graft/blob/master/Vagrantfile?ts=2). This allows us to easily modify the Vagrant box without causing merge conflicts if you were to update the VM source via `git pull`. Every file that `tj` modifies is _meant to be modified_, so at any time you may update your installation of Graft with a simple `git pull` without getting merge conflicts out the wazoo.
188
189
 
189
190
  ### What is a `Juicefile`?
190
- A YAML configuration file called `Juicefile` can be used to store commonly-used build scripts, similar to [npm scripts](https://docs.npmjs.com/misc/scripts). Each command block sequence can be mapped to an individual project's build script, allowing a streamlined set of commands to be used across multiple projects that utilize different tools. If you plan to deploy using `tj`, this file will also house your [deployment configuration](http://themejuice.it/deploy).
191
+ A YAML configuration file called a `Juicefile` can be used to store commonly-used build scripts, similar to [npm scripts](https://docs.npmjs.com/misc/scripts). Each command can be mapped to any build script you like, allowing you to define a set of commands that can be used across all of your projects. If you plan to deploy using `tj`, this file will also house your [deployment configuration](http://themejuice.it/deploy).
191
192
 
192
- Below is the config that comes baked into [our starter template](https://github.com/ezekg/theme-juice-starter):
193
+ For reference, below is an example config: (see the config for our starter template, [Sprout](https://github.com/ezekg/theme-juice-starter))
193
194
 
194
195
  ```yml
195
- #
196
196
  # Manage command aliases for the current project
197
- #
198
197
  commands:
199
198
 
200
199
  # Run project install scripts
201
200
  install:
202
- - composer install
203
- - bundle install
204
201
  - npm install
205
- - bower install
206
202
  - grunt build
207
203
 
208
204
  # Manage build tools
209
- watch:
205
+ dev:
210
206
  - grunt %args%
211
207
 
212
208
  # Manage front-end dependencies
213
209
  assets:
214
- - bower %args%
210
+ - npm %args%
215
211
 
216
212
  # Manage back-end dependencies
217
213
  vendor:
218
214
  - composer %args%
219
215
 
220
- # Manage WP installation
221
- wp:
222
- - wp ssh --host=vagrant %args%
223
-
224
216
  # Create a backup of the current database with a nice timestamp
225
217
  backup:
226
218
  - mkdir -p backup
227
- - wp ssh --host=vagrant db export backup/$(date +'%Y-%m-%d-%H-%M-%S').sql
219
+ - wp @dev db export backup/$(date +'%Y-%m-%d-%H-%M-%S').sql
220
+
221
+ # Manage deployment settings for the current project
222
+ deployment:
228
223
 
229
- # Package up entire project into a gzipped tar file
230
- dist:
231
- - tar -zcvf dist.tar.gz .
224
+ application:
225
+ name: "example"
226
+
227
+ # ...
232
228
  ```
233
229
 
234
- Each list of commands is run within a single execution, with all `%args%`/`%argN%` being replaced with the corresponding argument index, when available. Here's a few example scenarios:
235
- ```bash
236
- # Will contain all arguments stitched together by a space
237
- cmd1 %args%
238
- # Will contain each argument mapped to its respective index
239
- cmd2 '%arg1% %arg2% %arg3%'
240
- # Will only map argument 4, while ignoring 1-3
241
- cmd3 "%arg4%"
230
+ The commands within the `commands` block can be run from the command line via `tj <command>`. For example, we can run the `dev` command by running `tj dev`, which will in turn run the command `grunt`.
231
+
232
+ If you noticed in the example above, there are a few commands that contain `%args%`; each command list is run within a single execution via joining: `cmd1 && cmd2 [&& cmd3...]`, with all `%args%`/`%argN%` being replaced with the corresponding argument index, when available. Here's a few example scenarios:
233
+
234
+ ```yml
235
+ commands:
236
+ example-command:
237
+ # Will contain all arguments joined by a space
238
+ - cmd1 %args%
239
+ # Will contain each argument mapped to its respective index
240
+ - cmd2 '%arg1% %arg2% %arg3%'
241
+ # Will only map argument 4, while ignoring 1-3
242
+ - cmd3 "%arg4%"
242
243
  ```
243
244
 
244
- You can specify an unlimited number of commands with an unlimited number of arguments; however, you should be careful with how this is used. Don't go including `sudo rm -rf %arg1%` in a command, while passing `/` as an argument. Keep it simple. These are meant to make your life easier by helping you manage build tools, not to do fancy scripting.
245
+ To clarify a little bit more, we could run `tj dev build`, and since our `dev` command contains `%args%`, that will in turn run the command `grunt build`; if we can `tj dev some other task`, that would be interpreted and run as `grunt some other task`.
246
+
247
+ You can specify an unlimited number of commands with an unlimited number of arguments within your `Juicefile`; however, you should be careful with how this is used. Don't go including `sudo rm -rf %arg1%` in a command, while passing `/` as an argument. Keep it simple. These are meant to make your life easier by helping you manage build tools, not to do fancy scripting.
245
248
 
246
249
  ### Does `tj` support subdomain multi-sites?
247
- If you're able to use [Landrush](https://github.com/phinze/landrush) for your DNS, then yes. All subdomains will resolve to their parent domain. Landrush comes pre-installed when you create your first project with `tj`. Having said that, unfortunately, if you're on Windows you'll probably have to manually add the subdomains due to Landrush not being fully supported. If you have the Windows chops, head over there and contribute to Landrush by squashing that bug. I'm sure he would appreciate it!
250
+ If you're able to use [Landrush](https://github.com/phinze/landrush) for your DNS, then yes. All subdomains will resolve to their parent domain. Landrush comes pre-installed when you create your first project with `tj`. Having said that, unfortunately, if you're on Windows you'll might have to manually add the subdomains to your `/etc/hosts` file due to Landrush not being fully supported yet. If you have the Windows chops, head over there and contribute to Landrush by squashing that bug. I'm sure he would appreciate it!
248
251
 
249
252
  ### Can I access a project from another device (i.e. mobile)?
250
- Yes! Every project created with `tj` will automatically be set up to support using [xip.io](http://xip.io/). If you're using OSX, then everything should work out of the box. If you're not using OSX, then you'll need to point port `80` on your host machine to `8080`; Vagrant cannot do this by default for security reasons.
253
+ Yes! Every project created with `tj` will automatically be set up to support using [xip.io](http://xip.io/). If you're using OSX, then everything should work out of the box. If you're not using OSX, then you'll need to point port `80` on your host machine to `8080`; Vagrant cannot do this by default for security reasons. You can also use a service like [ngrok](https://ngrok.com/), if you prefer.
251
254
 
252
255
  Once everything is good to go, you can access a project from another device on the same network by going to `<project-name>.<your-hosts-ip-address>.xip.io` e.g. `themejuice.192.168.1.1.xip.io`.
253
256
 
@@ -279,12 +282,12 @@ deployment:
279
282
  Check out [capistrano-slackify](https://github.com/onthebeach/capistrano-slackify) for more information.
280
283
 
281
284
  ### Can I use a self-signed SSL cert?
282
- Yes, unless you used the `--no-ssl` flag, `tj` will set up each new site to support SSL, [and the VM will generate a new self-signed certificate](https://github.com/ezekg/theme-juice-vm#automatically-generated-self-signed-ssl-certs). In order to take advantage of it, [you'll need to accept the self-signed certificate on your host machine](https://github.com/ezekg/theme-juice-vm#accepting-a-self-signed-ssl-cert).
285
+ Yes, unless you used the `--no-ssl` flag, `tj` will set up each new site to support SSL, [and the VM will generate a new self-signed certificate](https://github.com/ezekg/graft#automatically-generated-self-signed-ssl-certs). In order to take advantage of it, [you'll need to accept the self-signed certificate on your host machine](https://github.com/ezekg/graft#accepting-a-self-signed-ssl-cert).
283
286
 
284
287
  ### Can I define my own Capistrano tasks?
285
288
  Yes. Any file within a directory called `deploy/` in your project with extensions `.rb`, `.cap` or `.rake` will be automatically loaded by Capistrano.
286
289
 
287
- For example, within our [starter template](https://github.com/ezekg/theme-juice-starter), you will find a `deploy/` directory, inside is an example task named `task.rb.example`. Open the file and you will see an example task invokable by `tj remote <stage> hello:world`.
290
+ For example, within our [starter template](https://github.com/ezekg/theme-juice-starter), you will find a `deploy/` directory, inside is a few example tasks. Open one of them and you'll see an example task invokable by `tj remote <stage> <namespace:task>`.
288
291
 
289
292
  To learn more about Rake and how you can define your own Capistrano tasks, check out the [official Rake repository](https://github.com/ruby/rake) as well as the [official Capistrano tasks documentation](http://capistranorb.com/documentation/getting-started/tasks/).
290
293
 
@@ -304,6 +307,22 @@ namespace :db do
304
307
  end
305
308
  ```
306
309
 
310
+ ### Can I run `wp-cli` commands on my deployment stages?
311
+ Sure can, and without the help of `tj`! As of version `0.24`, `wp-cli` does this out of the box. Whenever you create a new site, `tj` will add a file to your project's root directory called `wp-cli.local.yml` that contains something along the lines of:
312
+
313
+ ```yml
314
+ @development:
315
+ ssh: vagrant@example.dev/srv/www/tj-example
316
+ ```
317
+
318
+ You can then run `wp` commands like this,
319
+
320
+ ```bash
321
+ wp @development plugin list
322
+ ```
323
+
324
+ Feel free to add your other stages into that file as well!
325
+
307
326
  ## Troubleshooting
308
327
 
309
328
  1. [Help! It won't let me `git clone` anything!](#help-it-wont-let-me-git-clone-anything)
@@ -4,6 +4,7 @@ require "thor"
4
4
  require "faker"
5
5
  require "os"
6
6
  require "yaml"
7
+ require "erb"
7
8
  require "shellwords"
8
9
  require "capistrano/all"
9
10
 
@@ -88,7 +88,7 @@ module ThemeJuice
88
88
  if File.exist? man_path
89
89
  shell_escaped_man_path = man_path.shellescape
90
90
  if OS.windows?
91
- @io.say File.read "#{shell_escaped_man_path}.txt", :color => :white
91
+ @io.say File.read("#{shell_escaped_man_path}.txt"), :color => :white
92
92
  else
93
93
  @util.run "man #{shell_escaped_man_path}", :verbose => @env.verbose
94
94
  end
@@ -121,7 +121,7 @@ module ThemeJuice
121
121
  end
122
122
 
123
123
  desc "init", "Initialize the VM"
124
- method_option :provision, :type => :boolean, :desc => ""
124
+ method_option :vm_provision, :type => :boolean, :aliases => %w[--provision-vm --provision], :desc => ""
125
125
  def init
126
126
  @io.say "Initializing the VM...", {
127
127
  :color => [:black, :on_green, :bold],
@@ -148,7 +148,6 @@ module ThemeJuice
148
148
  method_option :no_config, :type => :boolean, :aliases => %w[--no-juicefile], :desc => ""
149
149
  method_option :wp_config_modify, :type => :boolean, :aliases => %w[--modify-wp-config], :desc => ""
150
150
  method_option :no_ssl, :type => :boolean, :aliases => %w[--no-https], :desc => ""
151
- method_option :provision, :type => :boolean, :desc => ""
152
151
  def create
153
152
  @io.hello
154
153
  @create.new(options).execute
@@ -170,7 +169,6 @@ module ThemeJuice
170
169
  method_option :no_config, :type => :boolean, :aliases => %w[--no-juicefile], :desc => ""
171
170
  method_option :wp_config_modify, :type => :boolean, :aliases => %w[--modify-wp-config], :desc => ""
172
171
  method_option :no_ssl, :type => :boolean, :aliases => %w[--no-https], :desc => ""
173
- method_option :provision, :type => :boolean, :desc => ""
174
172
  def setup
175
173
  @io.hello
176
174
  @create.new(options.dup.merge(:bare => true)).execute
@@ -41,11 +41,7 @@ module ThemeJuice
41
41
  tasks << Tasks::DNS.new
42
42
  tasks << Tasks::WPCLI.new
43
43
  tasks << Tasks::Repo.new
44
- if @project.provision
45
- tasks << Tasks::VMProvision.new
46
- else
47
- tasks << Tasks::VMRestart.new
48
- end
44
+ tasks << Tasks::VMProvision.new
49
45
  tasks << Tasks::ImportDatabase.new
50
46
  tasks << Tasks::CreateSuccess.new
51
47
  end
@@ -54,6 +50,14 @@ module ThemeJuice
54
50
  private
55
51
 
56
52
  def init_project
53
+
54
+ # Assume bare if the project path isn't empty (template install will fail)
55
+ unless @opts[:bare] || Dir["#{@project.location}/*"].empty?
56
+ @opts[:template] = false
57
+ @opts[:bare] = true
58
+ @io.notice "Project location is not empty. Assuming you meant to run a setup..."
59
+ end
60
+
57
61
  @project.use_defaults = @opts.fetch("use_defaults") { false }
58
62
  @project.bare = @opts.fetch("bare") { false }
59
63
  @project.skip_repo = @opts.fetch("skip_repo") { false }
@@ -64,11 +68,9 @@ module ThemeJuice
64
68
  @project.wp_config_modify = @opts.fetch("wp_config_modify") { false }
65
69
  @project.no_config = @opts.fetch("no_config") { false }
66
70
  @project.no_ssl = @opts.fetch("no_ssl") { false }
67
- @project.provision = @opts.fetch("provision") { false }
68
71
  @project.no_env = @opts.fetch("no_env") { @project.wp_config_modify }
69
72
  @project.name = @opts.fetch("name") { name }
70
73
  @project.location = @opts.fetch("location") { location }
71
- @project.location = "#{Dir.pwd}" if @project.location == "."
72
74
  @project.url = @opts.fetch("url") { url }
73
75
  @project.xip_url = @opts.fetch("xip_url") { xip_url }
74
76
  @project.template = @opts.fetch("template") { template }
@@ -78,14 +80,34 @@ module ThemeJuice
78
80
  @project.db_user = @opts.fetch("db_user") { db_user }
79
81
  @project.db_pass = @opts.fetch("db_pass") { db_pass }
80
82
  @project.db_import = @opts.fetch("db_import") { db_import }
83
+ @project.vm_root
84
+ @project.vm_location
85
+ @project.vm_srv
86
+
87
+ # TODO: Think up a nicer way of implementing additional logic
88
+
89
+ # Special cases for location paths
90
+ case @project.location
91
+ when "."
92
+ @project.location = "#{Dir.pwd}"
93
+ when /^~/
94
+ @project.location = File.expand_path @project.location
95
+ end
81
96
  end
82
97
 
83
98
  def name
84
- if @env.yolo
85
- name = Faker::Internet.domain_word
86
- else
87
- name = @io.ask "What's the project name? (letters, numbers and dashes only)"
88
- end
99
+ name =
100
+ begin
101
+ @io.say "Inferred project name '#{@config.project.name}' from existing config...", {
102
+ :color => :yellow, :icon => :notice }
103
+ @config.project.name
104
+ rescue NoMethodError
105
+ if @env.yolo
106
+ Faker::Internet.domain_word
107
+ else
108
+ @io.ask "What's the project name? (lowercase letters, numbers and dashes only)"
109
+ end
110
+ end
89
111
 
90
112
  valid_name? name
91
113
 
@@ -114,7 +136,7 @@ module ThemeJuice
114
136
  if @project.use_defaults
115
137
  location = File.absolute_path @project.name, path
116
138
  else
117
- location = File.absolute_path @io.ask("Where do you want to setup the project?",
139
+ location = File.expand_path @io.ask("Where do you want to setup the project?",
118
140
  :default => path, :path => true), path
119
141
  end
120
142
 
@@ -122,11 +144,18 @@ module ThemeJuice
122
144
  end
123
145
 
124
146
  def url
125
- if @project.use_defaults
126
- url = "#{@project.name}.dev"
127
- else
128
- url = @io.ask "What do you want the development url to be? (this should end in '.dev')", :default => "#{@project.name}.dev"
129
- end
147
+ url =
148
+ begin
149
+ @io.say "Inferred project url '#{@config.project.url}' from existing config...", {
150
+ :color => :yellow, :icon => :notice }
151
+ @config.project.url
152
+ rescue NoMethodError
153
+ if @project.use_defaults
154
+ "#{@project.name}.dev"
155
+ else
156
+ @io.ask "What do you want the development url to be? (this should end in '.dev')", :default => "#{@project.name}.dev"
157
+ end
158
+ end
130
159
 
131
160
  valid_url? url
132
161
 
@@ -32,6 +32,9 @@ module ThemeJuice
32
32
  @project.url = @opts.fetch("url") { url }
33
33
  @project.db_drop = @opts.fetch("db_drop") { false }
34
34
  @project.vm_restart = @opts.fetch("vm_restart") { false }
35
+ @project.vm_root
36
+ @project.vm_location
37
+ @project.vm_srv
35
38
  end
36
39
 
37
40
  def name
@@ -46,7 +49,7 @@ module ThemeJuice
46
49
 
47
50
  def url
48
51
  return "#{@project.name}.dev" if @env.no_landrush
49
-
52
+
50
53
  url = @io.ask "What is the project's development url?", :default => "#{@project.name}.dev"
51
54
 
52
55
  unless @list.urls.include? url
@@ -16,13 +16,16 @@ module ThemeJuice
16
16
  tasks << Tasks::VMCustomfile.new
17
17
  tasks << Tasks::Landrush.new
18
18
  tasks << Tasks::ForwardPorts.new
19
- tasks << Tasks::VMProvision.new
19
+ tasks << Tasks::VMProvision.new if @project.vm_provision
20
20
  tasks << Tasks::InitSuccess.new
21
21
  end
22
22
  end
23
23
 
24
24
  def init_project
25
- @project.provision = @opts.fetch("provision") { false }
25
+ @project.vm_provision = @opts.fetch("vm_provision") { false }
26
+ @project.vm_root
27
+ @project.vm_location
28
+ @project.vm_srv
26
29
  end
27
30
  end
28
31
  end
@@ -8,6 +8,8 @@ module ThemeJuice
8
8
  @util = Util.new
9
9
  @config = nil
10
10
 
11
+ attr_accessor :path
12
+
11
13
  def command(cmd, *args)
12
14
  return if @project.no_config
13
15
 
@@ -22,6 +24,12 @@ module ThemeJuice
22
24
  @io.say "Skipping...", :color => :yellow, :icon => :notice
23
25
  end
24
26
 
27
+ def project
28
+ config.project
29
+ rescue NoMethodError
30
+ {}
31
+ end
32
+
25
33
  def commands
26
34
  config.commands
27
35
  rescue NoMethodError
@@ -38,6 +46,10 @@ module ThemeJuice
38
46
  !capture { config }.nil?
39
47
  end
40
48
 
49
+ def refresh!
50
+ @config = read
51
+ end
52
+
41
53
  private
42
54
 
43
55
  def run(command)
@@ -69,17 +81,18 @@ module ThemeJuice
69
81
  end
70
82
 
71
83
  def config
72
- @config = read_config if @config.nil?
73
- @config
84
+ @config ||= read
74
85
  end
75
86
 
76
- def read_config
87
+ def read
77
88
  @project.location ||= @env.from_path || Dir.pwd
78
89
  @project.name ||= File.basename @project.location
79
90
 
80
- YAML.load_file Dir["#{@project.location}/*"].select { |f|
81
- config_regex =~ File.basename(f) }.last ||
82
- @io.error("Config file not found in '#{@project.location}'", LoadError)
91
+ @path = Dir["#{@project.location}/*"].select { |f|
92
+ config_regex =~ File.basename(f)
93
+ }.last || @io.error("Config file not found in '#{@project.location}'", LoadError)
94
+
95
+ YAML.load File.read(@path)
83
96
  rescue ::Psych::SyntaxError => err
84
97
  @io.error "Config file contains invalid YAML", SyntaxError do
85
98
  puts err
@@ -88,20 +101,30 @@ module ThemeJuice
88
101
  nil
89
102
  end
90
103
 
104
+ # Allowed:
105
+ # - Juicefile
106
+ # - Juicefile.yml
107
+ # - Juicefile.yaml
108
+ # - juicefile
109
+ # - juicefile.yml
110
+ # - juicefile.yaml
111
+ # - .tj
112
+ # - .tj.yml
113
+ # - .tj.yaml
91
114
  def config_regex
92
- %r{^(((\.)?(tj)|((J|j)uicefile))(\.y(a)?ml)?$)}
115
+ %r{^(\.?(tj)|((J|j)uicefile))(\.ya?ml)?$}
93
116
  end
94
117
 
95
118
  def any_arg_regex
96
- %r{(%arg(\w+)?%)|(%argument(\w+)?%)}
119
+ %r{%arg(?:ument)?[s\d]+%}
97
120
  end
98
121
 
99
122
  def multi_arg_regex
100
- %r{(%args%)|(%arguments%)}
123
+ %r{%arg(?:ument)?s%}
101
124
  end
102
125
 
103
126
  def single_arg_regex(i)
104
- %r{(%arg#{i}%)|(%argument#{i}%)}
127
+ %r{%arg(?:ument)?#{i}%}
105
128
  end
106
129
 
107
130
  def capture