theme-juice 0.28.2 → 0.28.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +101 -39
- data/lib/theme-juice.rb +2 -0
- data/lib/theme-juice/commands/update.rb +1 -0
- data/lib/theme-juice/migration.rb +5 -0
- data/lib/theme-juice/migrations/forward_ports.rb +64 -0
- data/lib/theme-juice/tasks/forward_ports.rb +17 -6
- data/lib/theme-juice/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f12cd91eab07108476ae286e82f6ae5af6b19197
|
4
|
+
data.tar.gz: 4421b161238e6124ae10883665eb40f87f58dbd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a6e53691dbb84feb5c8e56d0d2c7589fde51449a6b3ef56b0c2587092f6985dcb0ca8cf2228a14fcfdc522fdf639227059822d93ad31bfacc6fb21d18bd0ee8
|
7
|
+
data.tar.gz: 6c631a84db30b5f5699d541f639c9b78296c656d841e24d41b0a430a4cee61f5b5e1c2487b24eb9f5b0bc5bc6d0c1db963dbcf3a4289a56a4f36ff730d35e931
|
data/README.md
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
#
|
1
|
+
# `tj`
|
2
|
+
[![Mac App](https://img.shields.io/badge/mac-app-brightgreen.svg)](https://www.themejuice.it)
|
2
3
|
[![Gem Version](http://img.shields.io/gem/v/theme-juice.svg?style=flat-square)](https://rubygems.org/gems/theme-juice)
|
3
|
-
[![Travis](https://img.shields.io/travis/
|
4
|
-
[![Code Climate](https://img.shields.io/codeclimate/github/
|
5
|
-
[![Code Climate](https://img.shields.io/codeclimate/coverage/github/
|
6
|
-
[![Gitter](https://img.shields.io/gitter/room/ezekg/theme-juice-cli.svg?style=flat-square)](https://gitter.im/ezekg/theme-juice-cli)
|
4
|
+
[![Travis](https://img.shields.io/travis/themejuice/tj.svg?style=flat-square)](https://travis-ci.org/themejuice/tj)
|
5
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/themejuice/tj.svg?style=flat-square)](https://codeclimate.com/github/themejuice/tj)
|
6
|
+
[![Code Climate](https://img.shields.io/codeclimate/coverage/github/themejuice/tj.svg?style=flat-square)](https://codeclimate.com/github/themejuice/tj)
|
7
7
|
|
8
8
|
![Theme Juice CLI](demo.gif)
|
9
9
|
|
10
10
|
## What is it?
|
11
|
-
The [Theme Juice CLI](http://cli.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/
|
11
|
+
The [Theme Juice CLI](http://cli.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/themejuice/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://cli.themejuice.it).
|
14
14
|
|
15
15
|
## What problems does `tj` help solve?
|
16
|
-
To get the most out of `tj`, it is recommended that you use our [starter template](https://github.com/
|
16
|
+
To get the most out of `tj`, it is recommended that you use our [starter template](https://github.com/themejuice/sprout). Why? Keep on reading and we'll tell you. `tj` is built on top of tried and true open source libraries such as [Capistrano](http://capistranorb.com/) for deployment, [Vagrant](https://www.vagrantup.com/) for local development, and even a little bit of [WP-CLI](http://wp-cli.org) for database migration. Some of the main pain points `tj` helps solve are:
|
17
17
|
|
18
18
|
### 1. Local development
|
19
19
|
Say goodbye to MAMP! With one command, `tj create`, you can have a new local development site up and running in under a minute. It uses Vagrant to create a robust development environment, and lets you create and manage multiple projects within a single virtual machine. It also handles deployments over SSH using Capistrano if you want to move away from FTP (more about that below).
|
@@ -21,19 +21,19 @@ Say goodbye to MAMP! With one command, `tj create`, you can have a new local dev
|
|
21
21
|
### 2. Multi-environment projects
|
22
22
|
Oh, multi-environment development! Usually, you would have to ignore your entire `wp-config.php` file and create one for every single stage. These can get out of sync fast. Even worse, the config file actually gets checked into the project repo and so the credentials fluctuate from `dev` to `staging` to `production`. Not good. Not good at all.
|
23
23
|
|
24
|
-
Our [starter template](https://github.com/
|
24
|
+
Our [starter template](https://github.com/themejuice/sprout) uses a `.env` file, and has support for an unlimited number of environments (we generally do `development`, `staging` and `production`). Since these settings are housed in a `.env` file, they are not checked into the repo. That means the codebase is 100% environment agnostic. [The way it should be.](http://12factor.net/)
|
25
25
|
|
26
26
|
### 3. Multi-environment deployments
|
27
|
-
Really. Want to deploy to staging? Set up a staging environment inside of the [`Juicefile`](https://github.com/
|
27
|
+
Really. Want to deploy to staging? Set up a staging environment inside of the [`Juicefile`](https://github.com/themejuice/sprout/blob/master/Juicefile?ts=2), make sure you can SSH in without a password (remember, best practices here!) and run `tj deploy staging`. Boom, you're done. Make a mistake? Run `tj remote staging rollback`. Crisis averted!
|
28
28
|
|
29
29
|
Want to pull the database from your production server to your development install? Run `tj remote production db:pull` and you're good to go; `tj` will automatically handle rewriting any URLs within the database.
|
30
30
|
|
31
|
-
How about pushing your development database and your local uploads folder? Run `tj remote production db:push && tj remote production uploads:push` and you're done. [You can even send notifications to your teams Slack channel if you want to!](
|
31
|
+
How about pushing your development database and your local uploads folder? Run `tj remote production db:push && tj remote production uploads:push` and you're done. [You can even send notifications to your teams Slack channel if you want to!](#can-i-integrate-my-deployments-with-slack)
|
32
32
|
|
33
33
|
## Requirements
|
34
34
|
**`tj` requires [Vagrant](https://www.vagrantup.com/) and [VirtualBox](https://www.virtualbox.org/) to be able to create virtual machines for local development. Please download and install both of these before getting started.** If you plan on using `tj` for deployments, you should also ensure that your `remote` servers have [WP-CLI](http://wp-cli.org/) installed in order for `tj` to be able to handle database migration.
|
35
35
|
|
36
|
-
I recommend one of the latest versions of Ruby MRI (2.2, 2.1, 2.0). `tj` requires at least MRI 1.9.3. For the full report, check out the [Travis CI build status](https://travis-ci.org/
|
36
|
+
I recommend one of the latest versions of Ruby MRI (2.2, 2.1, 2.0). `tj` requires at least MRI 1.9.3. For the full report, check out the [Travis CI build status](https://travis-ci.org/themejuice/tj), where I test against an array of Ruby interpreters.
|
37
37
|
|
38
38
|
I also recommend you set up [SSH-keys for GitHub](https://help.github.com/articles/generating-ssh-keys/). Internally, `tj` uses `git clone` with SSH URLs, [so things might break if you don't have your keys set up properly](#help-it-wont-let-me-git-clone-anything).
|
39
39
|
|
@@ -44,7 +44,7 @@ gem install theme-juice
|
|
44
44
|
|
45
45
|
## Getting Started
|
46
46
|
|
47
|
-
_If you're going to be using [our starter template](https://github.com/
|
47
|
+
_If you're going to be using [our starter template](https://github.com/themejuice/sprout), then I recommend checking out [it's dependencies](https://github.com/themejuice/sprout#development-dependencies) before running your first `create`. That way, the build step doesn't fail._
|
48
48
|
|
49
49
|
### Initialize the VM
|
50
50
|
This will install and configure the virtual machine. It will clone the VM into the `vm-path`, install the required Vagrant plugins (such as [Landrush](https://github.com/phinze/landrush), unless disabled) and will also set up port forwarding if you're on OSX.
|
@@ -150,7 +150,7 @@ To use these permanently, set the appropriate `ENV` variables through your `.bas
|
|
150
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._
|
151
151
|
|
152
152
|
### So, does that mean I can use any Vagrant box?
|
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/
|
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/themejuice/graft), and include logic for a `Customfile`. Here is the required structure that `tj` needs in order to be able to create new projects:
|
154
154
|
|
155
155
|
```
|
156
156
|
├── config/
|
@@ -185,14 +185,19 @@ Yes and no; in order for `tj` to properly create a project, the Vagrant box need
|
|
185
185
|
```
|
186
186
|
|
187
187
|
### What is a `Customfile`?
|
188
|
-
[It's a file that contains custom rules to add into the main `Vagrantfile`, without actually having to modify it](https://github.com/
|
188
|
+
[It's a file that contains custom rules to add into the main `Vagrantfile`, without actually having to modify it](https://github.com/themejuice/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.
|
189
189
|
|
190
190
|
### What is a `Juicefile`?
|
191
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://cli.themejuice.it/deploy).
|
192
192
|
|
193
|
-
For reference, below is an example config: (see the config for our starter template, [Sprout](https://github.com/
|
193
|
+
For reference, below is an example config: (see the config for our starter template, [Sprout](https://github.com/themejuice/sprout))
|
194
194
|
|
195
195
|
```yml
|
196
|
+
# Project configuration
|
197
|
+
project:
|
198
|
+
name: example
|
199
|
+
url: example.dev
|
200
|
+
|
196
201
|
# Manage command aliases for the current project
|
197
202
|
commands:
|
198
203
|
|
@@ -206,7 +211,7 @@ commands:
|
|
206
211
|
- grunt %args%
|
207
212
|
|
208
213
|
# Manage front-end dependencies
|
209
|
-
|
214
|
+
asset:
|
210
215
|
- npm %args%
|
211
216
|
|
212
217
|
# Manage back-end dependencies
|
@@ -216,48 +221,105 @@ commands:
|
|
216
221
|
# Create a backup of the current database with a nice timestamp
|
217
222
|
backup:
|
218
223
|
- mkdir -p backup
|
219
|
-
- wp @
|
224
|
+
- wp @development db export backup/$(date +'%Y-%m-%d-%H-%M-%S').sql
|
220
225
|
|
221
226
|
# Manage deployment settings for the current project
|
222
227
|
deployment:
|
228
|
+
# …
|
223
229
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
# ...
|
230
|
+
stages:
|
231
|
+
# …
|
228
232
|
```
|
229
233
|
|
230
|
-
|
234
|
+
Each command within the above example can be run from the command-line via `tj <command>`. For example, we can run the `tj dev` command, which will in turn run the command `grunt`. Pretty simple, right?
|
231
235
|
|
232
|
-
If you noticed in the example above, there are a few commands that contain `%args%`;
|
236
|
+
If you happened to have noticed in the example above, there are a few sub-commands that contain `%args%`; these are called placeholders. Each sub-command list is run within a single execution via joining: `cmd1 && cmd2 && cmd3 && ...`, with all placeholders (`%args%`/`%argN%`) replaced with their corresponding argument index, when available.
|
233
237
|
|
234
|
-
|
238
|
+
Here's a few example commands utilizing placeholders:
|
239
|
+
|
240
|
+
```yaml
|
235
241
|
commands:
|
236
|
-
|
242
|
+
|
243
|
+
example-command-1:
|
237
244
|
# Will contain all arguments joined by a space
|
238
|
-
-
|
245
|
+
- echo "%args%"
|
246
|
+
|
247
|
+
example-command-2:
|
239
248
|
# Will contain each argument mapped to its respective index
|
240
|
-
-
|
249
|
+
- cat '%arg1% %arg2% %arg3%'
|
241
250
|
# Will only map argument 4, while ignoring 1-3
|
242
|
-
-
|
251
|
+
- pbcopy < "%arg4%"
|
243
252
|
```
|
244
253
|
|
245
|
-
To clarify a little bit more, we could run `tj dev build
|
254
|
+
To clarify a little bit more using our first example config, we could run `tj dev build` (notice the `build` argument), and since our `dev` command contains `%args%`, that will in turn run the command `grunt build`; if we run `tj dev` command with the arguments `some:other task`, that would be interpreted and run as `grunt some:other task`.
|
246
255
|
|
247
256
|
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.
|
248
257
|
|
258
|
+
#### Template strings
|
259
|
+
You may define ERB template strings within a project starter template's `Juicefile`. These will be replaced when creating a new project.
|
260
|
+
|
261
|
+
For example,
|
262
|
+
|
263
|
+
```yaml
|
264
|
+
# Project configuration
|
265
|
+
project:
|
266
|
+
name: <%= name %>
|
267
|
+
url: <%= url %>
|
268
|
+
```
|
269
|
+
|
270
|
+
will be replaced with,
|
271
|
+
|
272
|
+
```yaml
|
273
|
+
# Project configuration
|
274
|
+
project:
|
275
|
+
name: example-project
|
276
|
+
url: example-project.dev
|
277
|
+
```
|
278
|
+
|
279
|
+
if those were the options chosen during a project creation.
|
280
|
+
|
281
|
+
#### Available variables for use
|
282
|
+
- `name`: Project name
|
283
|
+
- `location`: Project location
|
284
|
+
- `url`: Project URL
|
285
|
+
- `xip_url`: Project xip.io URL
|
286
|
+
- `template`: Project template repository URL
|
287
|
+
- `repository`: Initialized repository URL, if available
|
288
|
+
- `db_host`: Project database host
|
289
|
+
- `db_name`: Project database name
|
290
|
+
- `db_user`: Project database user
|
291
|
+
- `db_pass`: Project database password
|
292
|
+
- `db_import`: Path to imported database file
|
293
|
+
- `vm_box`: Virtual machine box URL
|
294
|
+
- `vm_ip`: Virtual machine IP address
|
295
|
+
- `vm_revision` Revision hash or branch of VM
|
296
|
+
- `vm_path`: Virtual machine location on the host machine
|
297
|
+
- `vm_root`: Web root of the VM on the host machine
|
298
|
+
- `vm_location`: Project location within the VM on the host machine
|
299
|
+
- `vm_srv`: Project location within the VM on the guest machine
|
300
|
+
- `vm_prefix`: Virtual machine project location prefix
|
301
|
+
|
249
302
|
### Does `tj` support subdomain multi-sites?
|
250
303
|
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!
|
251
304
|
|
252
305
|
### Can I access a project from another device (i.e. mobile)?
|
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.
|
306
|
+
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.
|
254
307
|
|
255
308
|
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`.
|
256
309
|
|
257
|
-
_If you're familiar with forwarding host ports on operating systems other than OSX, check out [this file](https://github.com/
|
310
|
+
_If you're familiar with forwarding host ports on operating systems other than OSX, check out [this file](https://github.com/themejuice/tj/blob/master/lib/theme-juice/tasks/forward_ports.rb#L34-L51) and make a pull request so that everybody else can benefit from your smarts._
|
311
|
+
|
312
|
+
#### Using `ngrok`
|
313
|
+
You can also use a service like [ngrok](https://ngrok.com/), if you prefer that over xip.io:
|
314
|
+
|
315
|
+
```bash
|
316
|
+
ngrok http -host-header project.dev 80
|
317
|
+
```
|
318
|
+
|
319
|
+
⚠️ With both of these options, you'll need to make sure your WordPress project has a plugin like [Dynamic Hostname](https://wordpress.org/plugins/dynamic-hostname/) so that your assets and links continue to function correctly.
|
258
320
|
|
259
321
|
### Can I add my starter template, ________?
|
260
|
-
Yes! Just update the `TEMPLATES` constant inside [commands/create.rb](https://github.com/
|
322
|
+
Yes! Just update the `TEMPLATES` constant inside [commands/create.rb](https://github.com/themejuice/tj/blob/master/lib/theme-juice/commands/create.rb#L7-L12) and make a pull request. I'll verify that the template includes a `Juicefile` (not required, but preferred to automate build steps), and that everything looks solid. Until then (or if your template is private), just run the command below to clone your template.
|
261
323
|
|
262
324
|
```
|
263
325
|
tj create --template git@your.repo:link/goes-here.git
|
@@ -282,16 +344,16 @@ deployment:
|
|
282
344
|
Check out [capistrano-slackify](https://github.com/onthebeach/capistrano-slackify) for more information.
|
283
345
|
|
284
346
|
### Can I use 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/
|
347
|
+
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/themejuice/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/themejuice/graft#accepting-a-self-signed-ssl-cert).
|
286
348
|
|
287
349
|
### Can I define my own Capistrano tasks?
|
288
350
|
Yes. Any file within a directory called `deploy/` in your project with extensions `.rb`, `.cap` or `.rake` will be automatically loaded by Capistrano.
|
289
351
|
|
290
|
-
For example, within our [starter template](https://github.com/
|
352
|
+
For example, within our [starter template](https://github.com/themejuice/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>`.
|
291
353
|
|
292
354
|
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/).
|
293
355
|
|
294
|
-
If you're interested in checking out `tj`'s predefined tasks, head over [here](https://github.com/
|
356
|
+
If you're interested in checking out `tj`'s predefined tasks, head over [here](https://github.com/themejuice/tj/tree/master/lib/theme-juice/tasks/capistrano). You may override any task with custom functionality by using the same namespace/task name as outlined below,
|
295
357
|
|
296
358
|
```ruby
|
297
359
|
# encoding: UTF-8
|
@@ -362,11 +424,11 @@ sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
|
|
362
424
|
sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches
|
363
425
|
```
|
364
426
|
|
365
|
-
_Still having issues? [Yell at me!](https://github.com/
|
427
|
+
_Still having issues? [Yell at me!](https://github.com/themejuice/tj/issues)_
|
366
428
|
|
367
429
|
## Contributing
|
368
|
-
1. First, create a _well documented_ [issue](https://github.com/
|
369
|
-
1. After getting approval for the new feature, [fork the repository](https://github.com/
|
430
|
+
1. First, create a _well documented_ [issue](https://github.com/themejuice/tj/issues) for your proposed feature/bug fix
|
431
|
+
1. After getting approval for the new feature, [fork the repository](https://github.com/themejuice/tj/fork)
|
370
432
|
1. Create a new feature branch (`git checkout -b my-new-feature`)
|
371
433
|
1. Write tests before pushing your changes, then run Rspec (`rake`)
|
372
434
|
1. Commit your changes (`git commit -am 'add some feature'`)
|
@@ -374,7 +436,7 @@ _Still having issues? [Yell at me!](https://github.com/ezekg/theme-juice-cli/iss
|
|
374
436
|
1. Create a new Pull Request
|
375
437
|
|
376
438
|
## License
|
377
|
-
Please see [LICENSE](https://github.com/
|
439
|
+
Please see [LICENSE](https://github.com/themejuice/tj/blob/master/LICENSE) for licensing details.
|
378
440
|
|
379
441
|
## Author
|
380
442
|
Ezekiel Gabrielse, [@ezekkkg](https://twitter.com/ezekkkg), [http://ezekielg.com](http://ezekielg.com)
|
data/lib/theme-juice.rb
CHANGED
@@ -54,6 +54,8 @@ require "theme-juice/tasks/settings"
|
|
54
54
|
require "theme-juice/tasks/load"
|
55
55
|
require "theme-juice/tasks/invoke"
|
56
56
|
require "theme-juice/tasks/vm_update_box"
|
57
|
+
require "theme-juice/migration"
|
58
|
+
require "theme-juice/migrations/forward_ports"
|
57
59
|
require "theme-juice/command"
|
58
60
|
require "theme-juice/commands/init"
|
59
61
|
require "theme-juice/commands/create"
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module ThemeJuice
|
4
|
+
module Migrations
|
5
|
+
class ForwardPorts < Migration
|
6
|
+
|
7
|
+
def initialize(opts = {})
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def execute
|
12
|
+
return if migration_is_completed?
|
13
|
+
replace_content
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def migration_is_completed?
|
19
|
+
File.read(migration_file).include? new_content.gsub(/\\%|\\\\/, "\\")
|
20
|
+
end
|
21
|
+
|
22
|
+
def migration_file
|
23
|
+
"#{@env.vm_path}/Customfile"
|
24
|
+
end
|
25
|
+
|
26
|
+
def replace_content
|
27
|
+
@io.log "Migrating forwarded ports entry"
|
28
|
+
@util.gsub_file migration_file, old_content, new_content, {
|
29
|
+
:verbose => @env.verbose, :capture => @env.quiet }
|
30
|
+
end
|
31
|
+
|
32
|
+
def old_content
|
33
|
+
%Q{if defined? VagrantPlugins::Triggers
|
34
|
+
config.trigger.after [:up, :reload, :provision], :stdout => true do
|
35
|
+
system \%Q{echo "
|
36
|
+
rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
|
37
|
+
rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443
|
38
|
+
" | sudo pfctl -ef - >/dev/null 2>&1; echo "Forwarding ports (80 => 8080)\\nForwarding ports (443 => 8443)"}
|
39
|
+
end
|
40
|
+
config.trigger.after [:halt, :suspend, :destroy], :stdout => true do
|
41
|
+
system \%Q{sudo pfctl -F all -f /etc/pf.conf >/dev/null 2>&1; echo "Removing forwarded ports (80 => 8080)\\nRemoving forwarded ports (443 => 8443)"}
|
42
|
+
end
|
43
|
+
end}
|
44
|
+
end
|
45
|
+
|
46
|
+
def new_content
|
47
|
+
%Q{if Vagrant.has_plugin?("vagrant-triggers")
|
48
|
+
config.trigger.before [:reload, :provision], :stdout => true do
|
49
|
+
system \%Q{sudo pfctl -F all -f /etc/pf.conf >/dev/null 2>&1; echo "Removing forwarded ports (80 => 8080)\\nRemoving forwarded ports (443 => 8443)"}
|
50
|
+
end
|
51
|
+
config.trigger.after [:up, :reload, :provision], :stdout => true do
|
52
|
+
system \%Q{echo "
|
53
|
+
rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
|
54
|
+
rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443
|
55
|
+
" | sudo pfctl -ef - >/dev/null 2>&1; echo "Forwarding ports (80 => 8080)\\nForwarding ports (443 => 8443)"}
|
56
|
+
end
|
57
|
+
config.trigger.after [:halt, :suspend, :destroy], :stdout => true do
|
58
|
+
system \%Q{sudo pfctl -F all -f /etc/pf.conf >/dev/null 2>&1; echo "Removing forwarded ports (80 => 8080)\\nRemoving forwarded ports (443 => 8443)"}
|
59
|
+
end
|
60
|
+
end}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -35,20 +35,31 @@ config.vm.network "forwarded_port", :guest => 443, :host => 8443}
|
|
35
35
|
# OSX, so that's why there's nothing else here at the moment
|
36
36
|
def forward_host_ports
|
37
37
|
if OS.osx?
|
38
|
-
%Q{if
|
38
|
+
%Q{if Vagrant.has_plugin?("vagrant-triggers")
|
39
|
+
config.trigger.before [:reload, :provision], :stdout => true do
|
40
|
+
system \%Q{#{remove_forward_ports}}
|
41
|
+
end
|
39
42
|
config.trigger.after [:up, :reload, :provision], :stdout => true do
|
40
|
-
system \%Q{
|
41
|
-
rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
|
42
|
-
rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443
|
43
|
-
" | sudo pfctl -ef - >/dev/null 2>&1; echo "Forwarding ports (80 => 8080)\\nForwarding ports (443 => 8443)"}
|
43
|
+
system \%Q{#{add_forward_ports}}
|
44
44
|
end
|
45
45
|
config.trigger.after [:halt, :suspend, :destroy], :stdout => true do
|
46
|
-
system \%Q{
|
46
|
+
system \%Q{#{remove_forward_ports}}
|
47
47
|
end
|
48
48
|
end
|
49
49
|
}
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
53
|
+
def add_forward_ports
|
54
|
+
'echo "
|
55
|
+
rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
|
56
|
+
rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443
|
57
|
+
" | sudo pfctl -ef - >/dev/null 2>&1; echo "Forwarding ports (80 => 8080)\\nForwarding ports (443 => 8443)"'
|
58
|
+
end
|
59
|
+
|
60
|
+
def remove_forward_ports
|
61
|
+
'sudo pfctl -F all -f /etc/pf.conf >/dev/null 2>&1; echo "Removing forwarded ports (80 => 8080)\\nRemoving forwarded ports (443 => 8443)"'
|
62
|
+
end
|
52
63
|
end
|
53
64
|
end
|
54
65
|
end
|
data/lib/theme-juice/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: theme-juice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.28.
|
4
|
+
version: 0.28.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ezekiel Gabrielse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -172,6 +172,8 @@ files:
|
|
172
172
|
- lib/theme-juice/man/tj-setup
|
173
173
|
- lib/theme-juice/man/tj-setup.txt
|
174
174
|
- lib/theme-juice/man/tj.txt
|
175
|
+
- lib/theme-juice/migration.rb
|
176
|
+
- lib/theme-juice/migrations/forward_ports.rb
|
175
177
|
- lib/theme-juice/project.rb
|
176
178
|
- lib/theme-juice/task.rb
|
177
179
|
- lib/theme-juice/tasks/apache.rb
|