theme-juice 0.6.18 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +106 -75
  3. data/bin/tj +5 -5
  4. data/lib/theme-juice.rb +32 -16
  5. data/lib/theme-juice/cli.rb +191 -298
  6. data/lib/theme-juice/command.rb +14 -13
  7. data/lib/theme-juice/commands/create.rb +214 -9
  8. data/lib/theme-juice/commands/delete.rb +45 -10
  9. data/lib/theme-juice/commands/deploy.rb +20 -0
  10. data/lib/theme-juice/config.rb +43 -0
  11. data/lib/theme-juice/env.rb +25 -0
  12. data/lib/theme-juice/io.rb +323 -0
  13. data/lib/theme-juice/project.rb +35 -0
  14. data/lib/theme-juice/task.rb +42 -0
  15. data/lib/theme-juice/tasks/create_confirm.rb +33 -0
  16. data/lib/theme-juice/tasks/create_success.rb +42 -0
  17. data/lib/theme-juice/tasks/database.rb +50 -0
  18. data/lib/theme-juice/tasks/delete_confirm.rb +24 -0
  19. data/lib/theme-juice/tasks/delete_success.rb +31 -0
  20. data/lib/theme-juice/tasks/dns.rb +45 -0
  21. data/lib/theme-juice/tasks/dot_env.rb +53 -0
  22. data/lib/theme-juice/tasks/entry.rb +50 -0
  23. data/lib/theme-juice/tasks/hosts.rb +43 -0
  24. data/lib/theme-juice/tasks/import_database.rb +28 -0
  25. data/lib/theme-juice/tasks/landrush.rb +33 -0
  26. data/lib/theme-juice/tasks/list.rb +50 -0
  27. data/lib/theme-juice/tasks/location.rb +23 -0
  28. data/lib/theme-juice/tasks/nginx.rb +51 -0
  29. data/lib/theme-juice/tasks/repo.rb +49 -0
  30. data/lib/theme-juice/tasks/synced_folder.rb +30 -0
  31. data/lib/theme-juice/tasks/theme.rb +34 -0
  32. data/lib/theme-juice/tasks/vm.rb +30 -0
  33. data/lib/theme-juice/tasks/vm_customfile.rb +42 -0
  34. data/lib/theme-juice/tasks/vm_location.rb +32 -0
  35. data/lib/theme-juice/tasks/vm_plugins.rb +32 -0
  36. data/lib/theme-juice/tasks/vm_provision.rb +39 -0
  37. data/lib/theme-juice/tasks/vm_restart.rb +25 -0
  38. data/lib/theme-juice/tasks/wp_cli.rb +52 -0
  39. data/lib/theme-juice/util.rb +45 -0
  40. data/lib/theme-juice/version.rb +1 -1
  41. metadata +66 -34
  42. data/LICENSE +0 -339
  43. data/lib/theme-juice/commands/install.rb +0 -16
  44. data/lib/theme-juice/commands/list.rb +0 -16
  45. data/lib/theme-juice/commands/subcommand.rb +0 -16
  46. data/lib/theme-juice/environment.rb +0 -15
  47. data/lib/theme-juice/interaction.rb +0 -445
  48. data/lib/theme-juice/interactions/create.rb +0 -278
  49. data/lib/theme-juice/interactions/delete.rb +0 -48
  50. data/lib/theme-juice/interactions/teejay.rb +0 -12
  51. data/lib/theme-juice/service.rb +0 -224
  52. data/lib/theme-juice/services/config.rb +0 -44
  53. data/lib/theme-juice/services/create.rb +0 -376
  54. data/lib/theme-juice/services/delete.rb +0 -113
  55. data/lib/theme-juice/services/list.rb +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 319a340bbbfc7655feb9b0d983bf71e2ebbe8d4d
4
- data.tar.gz: c6180a536324a018aa1d0046984cf0fe6a9d3116
3
+ metadata.gz: a6723de16768298aea17ee0d1f9c07254776eb24
4
+ data.tar.gz: 1221dc65cd74ae60f045aba59e40f7af3765db98
5
5
  SHA512:
6
- metadata.gz: d16f8f8d494d69a691aeb83efe89156b7e5ee99c9f306755e37280e5c7d68378e11f781ba88db6fda35a3d5fc86bccaf7ec6f46f339bfdf38e95d71d11a144a1
7
- data.tar.gz: 0f4ebf24bdcbc7a6ae3706d56122cfcdbc16ad73c8adb1437a3b1c4c96b7b871f451e1e22abcdb2a180cd1b638cec57d83058042aac12b75f6ba2049b9a05ef4
6
+ metadata.gz: 94b54c081943afc61514c857e7df586d5cc244154322200e4962f44576eabfe67b900c38595c0806dd29ad82ee5cbe2bee3114ff4962694cda2a84309d6c601d
7
+ data.tar.gz: 6a926e9644dae59f5e29a5867ddd950299fd4324abaa1e7aeda3d5c681c7d6fdd619eca3f838f8e6e9c7333246e533579d9298f78ef252e358f32faded07fca0
data/README.md CHANGED
@@ -1,35 +1,34 @@
1
1
  # Theme Juice [![Gem Version](http://img.shields.io/gem/v/theme-juice.svg)](https://rubygems.org/gems/theme-juice)
2
- What is it? Theme Juice is a command line interface created to scaffold out a new WordPress development environment (using [VVV](https://github.com/Varying-Vagrant-Vagrants/VVV)) and countless development sites. Everybody loves one command setups, and `tj` can even do one command deployments too.
2
+ What is it? Theme Juice is a command line tool that allows you to scaffold out a new WordPress development environment (using [VVV](https://github.com/Varying-Vagrant-Vagrants/VVV) as the VM) and countless development projects. Everybody loves one command setups, and `tj` will eventually even do one command deployments too.
3
3
 
4
4
  ## Installation
5
5
  * First, install [Vagrant](https://www.vagrantup.com/) and [VirtualBox](https://www.virtualbox.org/) for local development.
6
- * Then, install [Composer](https://getcomposer.org/) and [WP-CLI](http://wp-cli.org/) (make sure they're executable).
6
+ * Then, install [Composer](https://getcomposer.org/) and [WP-CLI](http://wp-cli.org/), and make sure they're executable.
7
7
  * Finally, install with: `gem install theme-juice`
8
8
  That`s it!
9
9
 
10
10
  ## Config
11
- Because everybody likes to use different tools, you can create a `tj.yml` file (with an optional preceding `.`) that will house all of your theme-specific commands. This allows you to use a streamlined set of commands that will act as aliases to your per-project configuration, as well as starter-theme specific information, such as deployment configuration, etc. For right now, we'll just stick to the `commands` section.
11
+ Because everybody likes to use different tools, you can create a `Juicefile` or `tj.yaml` config (with an optional preceding `.`) that will house all of your theme-specific commands. This allows you to use a streamlined set of commands that will act as aliases to your per-project configuration, as well as starter-theme specific information, such as deployment configuration, etc. For right now, we'll just stick to the `commands` section.
12
12
 
13
- If you're into [Grunt](https://github.com/gruntjs/grunt), then use it. Prefer [Guard](https://github.com/guard/guard)? Go right ahead. This is obviously relative to the starter theme you use, since you can't exactly use Grunt with a starter theme that doesn't support it. Below is the config that comes baked into [our starter theme](https://github.com/ezekg/theme-juice-starter):
13
+ If you're into [Grunt](https://github.com/gruntjs/grunt), then use it. Prefer [Guard](https://github.com/guard/guard)? Go right ahead. This is obviously relative to the starter theme you use, since you can't exactly use Grunt with a project that doesn't support it. Below is the config that comes baked into [our starter theme](https://github.com/ezekg/theme-juice-starter):
14
14
 
15
15
  ```yml
16
16
  commands:
17
- watch: bundle exec guard
18
- server: bundle exec cap
19
- vendor: composer
20
- install:
21
- - composer install
17
+ install:
18
+ - composer install
19
+ watch:
20
+ - grunt
21
+ vendor:
22
+ - composer
23
+ wp:
24
+ - wp ssh --host=vagrant
25
+ backup:
26
+ - wp ssh --host=vagrant db export backup/$(date +'%Y-%m-%d-%H-%M-%S').sql
27
+ dist:
28
+ - tar -zcvf dist.tar.gz .
22
29
  ```
23
30
 
24
- _Note: If you use a starter theme that doesn't have a `tj.yml` file, you'll be prompted through a series of steps in order to create one._
25
-
26
- ### Command options:
27
- | Option | Usage |
28
- |:--------- |:----------------------------------------------------------------------------- |
29
- | `watch` | Command to be aliased when you run `tj watch` for bulding assets |
30
- | `server` | Command to be aliased when you run `tj server` for deployments |
31
- | `vendor` | Command to be aliased when you run `tj vendor` for dependencies |
32
- | `install` | Each command is executed when you run `tj install` to prepare a starter theme |
31
+ Each command is run within a single execution, with all arguments passed to each command; i.e. `cmd1 [<ARGS>] && cmd2 [<ARGS>] && ...`. So, you should be careful with how this is used. Don't do something like including `sudo rm -rf` in a command, and then passing `/` as an argument. Keep it simple.
33
32
 
34
33
  ## Usage
35
34
 
@@ -42,103 +41,135 @@ tj
42
41
  ### Print version:
43
42
  This command will print the current version of `tj`.
44
43
  ```bash
45
- tj --version # Aliases: -v, version
44
+ tj --version # Aliases: -v version
46
45
  ```
47
46
 
48
47
  ### Global flags:
49
- | Flag | Type | Description |
50
- |:------------------- |:------ |:------------------------------------------ |
51
- | `[--no-unicode]` | Bool | Disable all unicode characters |
52
- | `[--no-colors]` | Bool | Disable colored output |
53
- <!-- | `[--no-animations]` | Bool | Disable animations | -->
54
- <!-- | `[--no-deployer]` | Bool | Disable deployer | -->
55
- | `[--vvv-path=PATH]` | String | Force custom path to your VVV installation |
48
+ | Flag | Type | Description |
49
+ |:---------------------- |:------ |:------------------------------------------ |
50
+ | `[--vm-path=PATH]` | String | Force path to VM |
51
+ | `[--vm-ip=IP]` | String | Force IP address for VM |
52
+ | `[--vm-prefix=PREFIX]` | String | Force directory prefix for project in VM |
53
+ | `[--yolo]` | Bool | Say yes to anything and everything |
54
+ | `[--boring]` | Bool | Disable all the coolness |
55
+ | `[--no-unicode]` | Bool | Disable all unicode characters |
56
+ | `[--no-colors]` | Bool | Disable all colored output |
57
+ | `[--no-animations]` | Bool | Disable all animations |
58
+ | `[--no-landrush]` | Bool | Disable landrush for DNS |
59
+ | `[--verbose]` | Bool | Verbose output |
60
+ | `[--dryrun]` | Bool | Disable running all commands |
61
+
62
+ _Use `ENV` variables to set global flags. For example, by running `export TJ_VM_PATH=~/vagrant-vvv`, the `ENV` variable will be used instead of the default `vm-path` from then on. You can remove global flags with `unset TJ_VM_PATH`_
56
63
 
57
64
  ### Creating a new development site:
58
- Use this to create a new development site. It will automagically set up your entire development environment, including a local development site at `http://<sites-dev-url>.dev` with WordPress installed and a fresh WP database. It will sync up your local site installation with the Vagrant VM. This task will also install and configure Vagrant/VVV into your `~/` directory if it has not already been installed. Site name is optional, as it will be asked for if not given.
65
+ Use this to create a new project. It will automagically set up your VM, including a local development site at `http://<url>.dev` with WordPress installed and a fresh WP database. It will sync up your local site installation with the Vagrant VM, so you can organize your projects however you want. This task will also install VVV into your `vm-path` directory if it has not already been installed.
59
66
  ```bash
60
- tj create [<SITE-NAME>] # Aliases: new, add, build, make
67
+ tj create # Aliases: mk new add
61
68
  ```
62
69
 
63
70
  #### Option flags:
64
- | Flag | Type | Description |
65
- |:--------------------------- |:------ |:------------------------------------------------ |
66
- | `-b, [--bare]` | Bool | Create a VVV site without a starter theme |
67
- | `-n, [--name=NAME]` | String | Name of the development site |
68
- | `-l, [--location=LOCATION]` | Path | Location of the local site |
69
- | `-t, [--theme=THEME]` | URL | Starter theme to install |
70
- | `-u, [--url=URL]` | URL | Development URL of the site (must end in `.dev`) |
71
- | `-r, [--repository]` | String | Initialize a new Git remote repository |
72
- | `[--skip-repo]` | Bool | Skip repository prompts and set to `none` |
73
- | `[--skip-db]` | Bool | Skip database prompts and use defaults |
74
- | `[--use-defaults]` | Bool | Skip all prompts and use defaults |
71
+ | Flag | Type | Description |
72
+ |:-------------------------------- |:------ |:------------------------------------------------ |
73
+ | `[-n, --name]` | String | Name of the project |
74
+ | `[-l, --location]` | String | Location of the local project |
75
+ | `[-t, --theme]` | String | Starter theme to install |
76
+ | `[-u, --url]` | String | Development URL for the project |
77
+ | `[-r, --repository]` | String | Initialize a new Git remote repository |
78
+ | `[--import-db, --db_import, -i]` | String | Import an existing database |
79
+ | `[--bare]` | Bool | Create a project without a starter theme |
80
+ | `[--skip_repo]` | Bool | Skip repository prompts and use default settings |
81
+ | `[--skip_db]` | Bool | Skip database prompts and use default settings |
82
+ | `[--use_defaults]` | Bool | Skip all prompts and use default settings |
83
+ | `[--no_wp]` | Bool | New project is not a WordPress install |
84
+ | `[--no_db]` | Bool | New project does not need a database |
75
85
 
76
86
  ### Setting up an existing site:
77
- Use this to setup an existing local site installation within the development environment. You will go through the setup process to create the necessary files for the VM, including `vvv-hosts`, `vvv-nginx.conf`, and a fresh database (unless one already exists by the name chosen). Site name is optional, as it will be asked for if not given.
87
+ Use this to setup an existing local site installation within the development environment. You will go through the setup process to create the necessary files for the VM, including `vvv-hosts`, `vvv-nginx.conf`, and a fresh database (unless one already exists by the name chosen). This is essentially an alias for `create`, but with a few options being skipped.
78
88
  ```bash
79
- tj setup [<SITE-NAME>] # Aliases: prep
89
+ tj setup # Aliases: up prep init make
80
90
  ```
81
91
 
82
92
  #### Option flags:
83
- | Flag | Type | Description |
84
- |:--------------------------- |:------ |:------------------------------------------------ |
85
- | `-n, [--name=NAME]` | String | Name of the development site |
86
- | `-l, [--location=LOCATION]` | Path | Location of the local site |
87
- | `-u, [--url=URL]` | URL | Development URL of the site (must end in `.dev`) |
88
- | `-r, [--repository]` | String | Initialize a new Git remote repository |
89
- | `[--skip-repo]` | Bool | Skip repository prompts and set to `none` |
90
- | `[--skip-db]` | Bool | Skip database prompts and use defaults |
91
- | `[--use-defaults]` | Bool | Skip all prompts and use defaults |
93
+ | Flag | Type | Description |
94
+ |:-------------------------------- |:------ |:------------------------------------------------ |
95
+ | `[-n, --name]` | String | Name of the project |
96
+ | `[-l, --location]` | String | Location of the local project |
97
+ | `[-u, --url]` | String | Development URL for the project |
98
+ | `[-r, --repository]` | String | Initialize a new Git remote repository |
99
+ | `[-i, --import-db, --db_import]` | String | Import an existing database |
100
+ | `[--skip_repo]` | Bool | Skip repository prompts and use default settings |
101
+ | `[--skip_db]` | Bool | Skip database prompts and use default settings |
102
+ | `[--use_defaults]` | Bool | Skip all prompts and use default settings |
103
+ | `[--no_wp]` | Bool | New project is not a WordPress install |
104
+ | `[--no_db]` | Bool | New project does not need a database |
92
105
 
93
106
  ### Deleting a site from the VM: _(Does not remove your local site)_
94
- Use this to remove a site from your development environment. This is only remove files that were generated by `tj`. including the database setup, development url, and shared directories. _It will not touch your local files._
107
+ Use this to remove a site from your development environment. This will only remove files that were generated by `tj`. including the database setup, development url, and shared directories. _It will not touch your local folders that were synced to the VM._
95
108
  ```bash
96
- tj delete <SITE-NAME> # Aliases: rm, remove, trash, teardown
109
+ tj delete # Aliases: rm remove trash teardown
97
110
  ```
98
111
 
99
112
  #### Option flags:
100
- | Flag | Type | Description |
101
- |:----------------------- |:------ |:------------------------------------------------ |
102
- | `-n, [--name=NAME]` | String | Name of the development site |
103
- | `[--restart]` | Bool | Restart development environment after deletion |
104
-
105
- ### Listing all `tj` sites in the VM:
106
- Use this to list all sites within your development environment that were generated by `tj`.
113
+ | Flag | Type | Description |
114
+ |:---------------- |:------ |:------------------------------- |
115
+ | `[-n, --name]` | String | Name of the development project |
116
+ | `[-u, --url]` | String | Development URL for the project |
117
+ | `[--db_drop]` | Bool | Drop project's database |
118
+ | `[--vm_restart]` | Bool | Restart VM after deletion |
119
+
120
+ ### Managing deployment and migration (coming soon):
121
+ Use this to easily manage your deployment and migration with [Capistrano](https://github.com/capistrano/capistrano) or whatever command is in your config. This is just a wrapper for your chosen command.
107
122
  ```bash
108
- tj list # Aliases: ls, sites, show
123
+ tj deploy # Aliases: deployer server remote
109
124
  ```
110
125
 
111
- ### Watching and compiling assets:
112
- Use this to watch and compile assets with your preferred build tool, whether that be [Grunt](https://github.com/gruntjs/grunt), [Gulp](https://github.com/gulpjs/gulp), [Guard](https://github.com/guard/guard), or whatever. This is simply a wrapper for whatever command is in your `tj.yml` file.
126
+ ### Listing all `tj` projects in the VM:
127
+ Use this to list all projects within your VM that were generated by `tj`.
113
128
  ```bash
114
- tj watch # Aliases: dev, assets
129
+ tj list # Aliases: ls projects apps sites
115
130
  ```
116
131
 
117
132
  ### Managing development environment:
118
- Use this to easily manage your [Varying Vagrant Vagrants](https://github.com/Varying-Vagrant-Vagrants/VVV) development environment. This is simply a wrapper for Vagrant commands executed within your VVV path.
133
+ Use this to easily manage your [Varying Vagrant Vagrants](https://github.com/Varying-Vagrant-Vagrants/VVV) VM. This is a wrapper for Vagrant commands executed within your VM path.
134
+ ```bash
135
+ tj vm # Aliases: vagrant vvv
136
+ ```
137
+
138
+ ### Watching and compiling assets:
139
+ Use this to watch and compile assets with your preferred build tool, whether that be [Grunt](https://github.com/gruntjs/grunt), [Gulp](https://github.com/gulpjs/gulp), [Guard](https://github.com/guard/guard), or whatever. This is simply a wrapper for whatever command is in your config file.
119
140
  ```bash
120
- tj vm # Aliases: vagrant, vvv
141
+ tj watch # Aliases: assets dev build
121
142
  ```
122
143
 
123
144
  ### Managing vendor dependencies:
124
- Use this to easily manage your dependencies with [Composer](https://github.com/composer/composer), or whatever other command you set in your `tj.yml`. This is a wrapper for whatever command is in your config file.
145
+ Use this to easily manage your dependencies with [Composer](https://github.com/composer/composer), or whatever command you set within your config.
146
+ ```bash
147
+ tj vendor # Aliases: dependencies deps
148
+ ```
149
+
150
+ ### Executing WP-CLI locally inside your VM:
151
+ Upon setup, an `ssh` block for the VM is automatically added to the `wp-cli.local.yml` file with all of your VM paths. In our starter theme, we use [wp-cli-ssh](https://github.com/xwp/wp-cli-ssh) to run `wp` commands locally.
152
+ In order to do the same, it needs to be a dependency in your `composer.json`.
125
153
  ```bash
126
- tj vendor # Aliases: deps, dependencies
154
+ tj wp # Aliases: wordpress
127
155
  ```
128
156
 
129
- ### Managing deployment and migration:
130
- Use this to easily manage your deployment and migration with [Capistrano](https://github.com/capistrano/capistrano) (or again, anything else set within your `tj.yml`). This is just a wrapper for your chosen command.
157
+ ### Backing up your database:
158
+ Uses `backup` command within your config.
131
159
  ```bash
132
- tj server # Aliases: deploy, remote
160
+ tj backup # Aliases: bk
133
161
  ```
134
162
 
135
- ### Executing WP-CLI locally inside your VM with `wp-cli-ssh`
136
- You can run `wp` commands locally if you specify a `--host`. Upon setup, an `ssh` block for the VM is automatically added to the `wp-cli.local.yml` file with all of your development environment paths.
163
+ ### Distributing a package of your project:
164
+ Uses `dist` command within your config.
137
165
  ```bash
138
- wp ssh --host=vagrant [<COMMANDS>]
166
+ tj dist # Aliases: distrubute pack package
167
+ ```
139
168
 
140
- # Create an alias
141
- alias wpv="wp ssh --host=vagrant"
169
+ ### Running your test suite:
170
+ Uses `dist` command within your config.
171
+ ```bash
172
+ tj test # Aliases: tests spec specs
142
173
  ```
143
174
 
144
175
  ## Contributing
data/bin/tj CHANGED
@@ -2,14 +2,14 @@
2
2
  # encoding: UTF-8
3
3
 
4
4
  begin
5
- require_relative "../lib/theme-juice"
5
+ require_relative "../lib/theme-juice"
6
6
  rescue LoadError => err
7
- warn err
8
- exit 1
7
+ warn err
8
+ exit 1
9
9
  end
10
10
 
11
11
  Signal.trap "INT" do
12
- ::ThemeJuice::Interaction.goodbye
12
+ ThemeJuice::IO.goodbye
13
13
  end
14
14
 
15
- ::ThemeJuice::CLI.start
15
+ ThemeJuice::CLI.start
@@ -2,29 +2,45 @@
2
2
 
3
3
  require "thor"
4
4
  require "faker"
5
- require "fileutils"
6
- require "pathname"
7
- require "tempfile"
5
+ require "os"
8
6
  require "yaml"
9
7
 
10
8
  module ThemeJuice
11
9
  end
12
10
 
13
11
  require_relative "theme-juice/version"
14
- require_relative "theme-juice/environment"
15
- require_relative "theme-juice/interaction"
16
- require_relative "theme-juice/interactions/teejay"
17
- require_relative "theme-juice/interactions/create"
18
- require_relative "theme-juice/interactions/delete"
19
- require_relative "theme-juice/service"
20
- require_relative "theme-juice/services/config"
21
- require_relative "theme-juice/services/create"
22
- require_relative "theme-juice/services/delete"
23
- require_relative "theme-juice/services/list"
12
+ require_relative "theme-juice/env"
13
+ require_relative "theme-juice/project"
14
+ require_relative "theme-juice/util"
15
+ require_relative "theme-juice/io"
16
+ require_relative "theme-juice/config"
17
+ require_relative "theme-juice/task"
18
+ require_relative "theme-juice/tasks/entry"
19
+ require_relative "theme-juice/tasks/vm"
20
+ require_relative "theme-juice/tasks/create_confirm"
21
+ require_relative "theme-juice/tasks/delete_confirm"
22
+ require_relative "theme-juice/tasks/location"
23
+ require_relative "theme-juice/tasks/theme"
24
+ require_relative "theme-juice/tasks/repo"
25
+ require_relative "theme-juice/tasks/dot_env"
26
+ require_relative "theme-juice/tasks/hosts"
27
+ require_relative "theme-juice/tasks/nginx"
28
+ require_relative "theme-juice/tasks/vm_plugins"
29
+ require_relative "theme-juice/tasks/vm_location"
30
+ require_relative "theme-juice/tasks/vm_customfile"
31
+ require_relative "theme-juice/tasks/database"
32
+ require_relative "theme-juice/tasks/landrush"
33
+ require_relative "theme-juice/tasks/synced_folder"
34
+ require_relative "theme-juice/tasks/dns"
35
+ require_relative "theme-juice/tasks/wp_cli"
36
+ require_relative "theme-juice/tasks/create_success"
37
+ require_relative "theme-juice/tasks/delete_success"
38
+ require_relative "theme-juice/tasks/vm_provision"
39
+ require_relative "theme-juice/tasks/vm_restart"
40
+ require_relative "theme-juice/tasks/import_database"
41
+ require_relative "theme-juice/tasks/list"
24
42
  require_relative "theme-juice/command"
25
- require_relative "theme-juice/commands/install"
26
43
  require_relative "theme-juice/commands/create"
27
44
  require_relative "theme-juice/commands/delete"
28
- require_relative "theme-juice/commands/list"
29
- require_relative "theme-juice/commands/subcommand"
45
+ require_relative "theme-juice/commands/deploy"
30
46
  require_relative "theme-juice/cli"
@@ -1,318 +1,211 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module ThemeJuice
4
- class CLI < Thor
5
-
6
- #
7
- # Command aliases
8
- #
9
- map %w[--version -v] => :version
10
- map %w[new, add, build, make] => :create
11
- map %w[prep] => :setup
12
- map %w[rm, remove, trash, teardown] => :delete
13
- map %w[ls, sites, show] => :list
14
- map %w[assets, dev] => :watch
15
- map %w[dependencies, deps] => :vendor
16
- map %w[deploy, remote] => :server
17
- map %w[vagrant, vvv] => :vm
18
-
19
- #
20
- # Class options
21
- #
22
- class_option :vvv_path, :type => :string, :default => nil, :desc => "Force path to VVV installation"
23
- class_option :yolo, :type => :boolean, :desc => "Say yes to anything and everything"
24
- class_option :boring, :type => :boolean, :desc => "Disable all the coolness"
25
- class_option :no_unicode, :type => :boolean, :desc => "Disable all unicode characters"
26
- class_option :no_colors, :type => :boolean, :desc => "Disable all colored output"
27
- # class_option :no_animations, :type => :boolean, :desc => "Disable all animations"
28
- # class_option :no_deployer, :type => :boolean, :desc => "Disable deployer"
29
-
30
- desc "--version, -v", "Print current version"
31
- #
32
- # Print current version
33
- #
34
- # @return {String}
35
- #
36
- def version
37
- self.set_environment
38
-
39
- @interaction.speak @version, {
40
- :color => :green
41
- }
42
- end
43
-
44
- desc "create [NAME]", "Create new site and setup VVV environment"
45
- method_option :name, :type => :string, :aliases => "-n", :default => false, :desc => "Name of the development site"
46
- method_option :location, :type => :string, :aliases => "-l", :default => false, :desc => "Location of the local site"
47
- method_option :theme, :type => :string, :aliases => "-t", :default => false, :desc => "Starter theme to install"
48
- method_option :url, :type => :string, :aliases => "-u", :default => false, :desc => "Development URL of the site"
49
- method_option :repository, :type => :string, :aliases => "-r", :desc => "Initialize a new Git remote repository"
50
- method_option :bare, :type => :boolean, :desc => "Create a VVV site without a starter theme"
51
- method_option :skip_repo, :type => :boolean, :desc => "Skip repository prompts and use defaults"
52
- method_option :skip_db, :type => :boolean, :desc => "Skip database prompts and use defaults"
53
- method_option :use_defaults, :type => :boolean, :desc => "Skip all prompts and use default settings"
54
- #
55
- # Install and setup VVV environment with new site
56
- #
57
- # @param {String} name (nil)
58
- # Name of the site to create
59
- #
60
- # @return {Void}
61
- #
62
- def create(name = nil)
63
- self.set_environment
64
- @interaction.hello
65
-
66
- opts = {
67
- :site_name => name || options[:name],
68
- :site_location => options[:location],
69
- :site_starter_theme => options[:theme],
70
- :site_dev_location => nil,
71
- :site_dev_url => options[:url],
72
- :site_repository => options[:repository],
73
- :site_bare => options[:bare],
74
- :skip_repo => options[:skip_repo],
75
- :skip_db => options[:skip_db],
76
- :use_defaults => options[:use_defaults]
77
- }
78
-
79
- @create.new(opts)
80
- end
81
-
82
- desc "setup [NAME]", "Setup an existing site within the development environment"
83
- method_option :name, :type => :string, :aliases => "-n", :default => false, :desc => "Name of the development site"
84
- method_option :location, :type => :string, :aliases => "-l", :default => false, :desc => "Location of the local site"
85
- method_option :url, :type => :string, :aliases => "-u", :default => false, :desc => "Development URL of the site"
86
- method_option :repository, :type => :string, :aliases => "-r", :desc => "Initialize a new Git remote repository"
87
- method_option :skip_repo, :type => :boolean, :desc => "Skip repository prompts and use defaults"
88
- method_option :skip_db, :type => :boolean, :desc => "Skip database prompts and use defaults"
89
- method_option :use_defaults, :type => :boolean, :desc => "Skip all prompts and use default settings"
90
- #
91
- # Setup an existing WordPress install in VVV
92
- #
93
- # @param {String} name (nil)
94
- # Name of the site to setup
95
- #
96
- # @return {Void}
97
- #
98
- def setup(name = nil)
99
- self.set_environment
100
- @interaction.hello
101
-
102
- opts = {
103
- :site_name => name || options[:name],
104
- :site_location => options[:location],
105
- :site_starter_theme => false,
106
- :site_dev_location => nil,
107
- :site_dev_url => options[:url],
108
- :site_repository => options[:repository],
109
- :site_bare => true,
110
- :skip_repo => options[:skip_repo],
111
- :skip_db => options[:skip_db],
112
- :use_defaults => options[:use_defaults]
113
- }
114
-
115
- @create.new(opts)
116
- end
117
-
118
- desc "delete [NAME]", "Remove site from the VVV development environment (does not remove local site)"
119
- method_option :name, :type => :string, :aliases => "-n", :default => false, :desc => "Name of the development site"
120
- method_option :restart, :type => :boolean, :desc => "Restart development environment after deletion"
121
- #
122
- # Remove all traces of site from Vagrant
123
- #
124
- # @param {String} name (nil)
125
- # Site to delete. This will not delete your local files, only
126
- # files within the VVV environment.
127
- #
128
- # @return {Void}
129
- #
130
- def delete(name = nil)
131
- self.set_environment
132
-
133
- opts = {
134
- :site_name => name || options[:name],
135
- :site_dev_location => nil,
136
- :restart => options[:restart]
137
- }
138
-
139
- @delete.new(opts)
140
- end
141
-
142
- desc "list", "List all sites within the VVV development environment"
143
- #
144
- # List all development sites
145
- #
146
- # @return {Void}
147
- #
148
- def list
149
- self.set_environment
150
-
151
- @list.new
152
- end
153
-
154
- desc "install", "Run installation for the starter theme"
155
- #
156
- # Install and setup starter theme
157
- #
158
- # @return {Void}
159
- #
160
- def install
161
- self.set_environment
162
-
163
- @install.new
164
- end
165
-
166
- desc "watch [COMMANDS]", "Watch and compile assets"
167
- #
168
- # Assets
169
- #
170
- # @param {*} commands
171
- # Commands to run
172
- #
173
- # @return {Void}
174
- #
175
- def watch(*commands)
176
- self.set_environment
177
-
178
- opts = {
179
- :subcommand => "watch",
180
- :commands => commands.join(" ")
181
- }
182
-
183
- @subcommand.new(opts)
184
- end
185
-
186
- desc "vendor [COMMANDS]", "Manage vendor dependencies"
187
- #
188
- # Vendor dependencies
189
- #
190
- # @param {*} commands
191
- # Commands to run
192
- #
193
- # @return {Void}
194
- #
195
- def vendor(*commands)
196
- self.set_environment
197
-
198
- opts = {
199
- :subcommand => "vendor",
200
- :commands => commands.join(" ")
201
- }
4
+ class CLI < Thor
5
+
6
+ def initialize(*)
7
+ super
8
+
9
+ @version = VERSION
10
+ @env = Env
11
+ @io = IO
12
+ @config = Config
13
+ @project = Project
14
+ @util = Util.new
15
+ @list = Tasks::List
16
+ @create = Commands::Create
17
+ @delete = Commands::Delete
18
+ @deploy = Commands::Deploy
19
+ @env.vm_path = options.fetch "vm_path", ENV.fetch("TJ_VM_PATH", File.expand_path("~/vagrant"))
20
+ @env.vm_ip = options.fetch "vm_ip", ENV.fetch("TJ_VM_IP", "192.168.50.4")
21
+ @env.vm_prefix = options.fetch "vm_prefix", ENV.fetch("TJ_VM_PREFIX", "tj-")
22
+ @env.yolo = options.fetch "yolo", ENV.fetch("TJ_YOLO", false)
23
+ @env.boring = options.fetch "boring", ENV.fetch("TJ_BORING", false)
24
+ @env.no_unicode = options.fetch "no_unicode", ENV.fetch("TJ_NO_UNICODE", @env.boring)
25
+ @env.no_colors = options.fetch "no_colors", ENV.fetch("TJ_NO_COLORS", @env.boring)
26
+ @env.no_animations = options.fetch "no_animations", ENV.fetch("TJ_NO_ANIMATIONS", @env.boring)
27
+ @env.no_landrush = options.fetch "no_landrush", ENV.fetch("TJ_NO_LANDRUSH", false)
28
+ @env.verbose = options.fetch "verbose", ENV.fetch("TJ_VERBOSE", false)
29
+ @env.dryrun = options.fetch "dryrun", ENV.fetch("TJ_DRYRUN", false)
30
+ end
202
31
 
203
- @subcommand.new(opts)
204
- end
32
+ map %w[--version -v] => :version
33
+ map %w[mk new add] => :create
34
+ map %w[up prep init make] => :setup
35
+ map %w[rm remove trash teardown] => :delete
36
+ map %w[ls projects apps sites] => :list
37
+ map %w[assets dev build] => :watch
38
+ map %w[dependencies deps] => :vendor
39
+ map %w[distrubute pack package] => :dist
40
+ map %w[wordpress] => :wp
41
+ map %w[bk] => :backup
42
+ map %w[tests spec specs] => :test
43
+ map %w[deployer server remote] => :deploy
44
+ map %w[vagrant vvv] => :vm
45
+
46
+ class_option :vm_path, :type => :string, :default => nil, :desc => "Force path to VM"
47
+ class_option :vm_ip, :type => :string, :default => nil, :desc => "Force IP address for VM"
48
+ class_option :vm_prefix, :type => :string, :default => nil, :desc => "Force directory prefix for project in VM"
49
+ class_option :yolo, :type => :boolean, :desc => "Say yes to anything and everything"
50
+ class_option :boring, :type => :boolean, :desc => "Disable all the coolness"
51
+ class_option :no_unicode, :type => :boolean, :desc => "Disable all unicode characters"
52
+ class_option :no_colors, :type => :boolean, :desc => "Disable all colored output"
53
+ class_option :no_animations, :type => :boolean, :desc => "Disable all animations"
54
+ class_option :no_landrush, :type => :boolean, :desc => "Disable landrush for DNS"
55
+ class_option :verbose, :type => :boolean, :desc => "Verbose output"
56
+ class_option :dryrun, :type => :boolean, :desc => "Disable running all commands"
57
+
58
+ desc "--version, -v", "Print current version"
59
+ #
60
+ # @return {String}
61
+ #
62
+ def version
63
+ @io.speak @version, :color => :green
64
+ end
205
65
 
206
- desc "server [COMMANDS]", "Manage deployment and migration"
207
- #
208
- # Server/Deployment
209
- #
210
- # @param {*} commands
211
- # Commands to run
212
- #
213
- # @return {Void}
214
- #
215
- def server(*commands)
216
- self.set_environment
66
+ desc "create", "Create new project"
67
+ method_option :name, :type => :string, :aliases => "-n", :default => nil, :desc => "Name of the project"
68
+ method_option :location, :type => :string, :aliases => "-l", :default => nil, :desc => "Location of the local project"
69
+ method_option :theme, :type => :string, :aliases => "-t", :default => nil, :desc => "Starter theme to install"
70
+ method_option :url, :type => :string, :aliases => "-u", :default => nil, :desc => "Development URL for the project"
71
+ method_option :repository, :type => :string, :aliases => "-r", :desc => "Initialize a new Git remote repository"
72
+ method_option :db_import, :type => :string, :aliases => %w[--import-db -i], :desc => "Import an existing database"
73
+ method_option :bare, :type => :boolean, :desc => "Create a project without a starter theme"
74
+ method_option :skip_repo, :type => :boolean, :desc => "Skip repository prompts and use default settings"
75
+ method_option :skip_db, :type => :boolean, :desc => "Skip database prompts and use default settings"
76
+ method_option :use_defaults, :type => :boolean, :desc => "Skip all prompts and use default settings"
77
+ method_option :no_wp, :type => :boolean, :desc => "New project is not a WordPress install"
78
+ method_option :no_db, :type => :boolean, :desc => "New project does not need a database"
79
+ #
80
+ # @return {Void}
81
+ #
82
+ def create
83
+ @io.hello
84
+ @create.new(options).execute
85
+ end
217
86
 
218
- opts = {
219
- :subcommand => "server",
220
- :commands => commands.join(" ")
221
- }
87
+ desc "setup", "Setup existing project"
88
+ method_option :name, :type => :string, :aliases => "-n", :default => nil, :desc => "Name of the project"
89
+ method_option :location, :type => :string, :aliases => "-l", :default => nil, :desc => "Location of the local project"
90
+ method_option :url, :type => :string, :aliases => "-u", :default => nil, :desc => "Development URL for the project"
91
+ method_option :repository, :type => :string, :aliases => "-r", :desc => "Initialize a new Git remote repository"
92
+ method_option :import_db, :type => :string, :aliases => "-i", :desc => "Import an existing database"
93
+ method_option :skip_repo, :type => :boolean, :desc => "Skip repository prompts and use default settings"
94
+ method_option :skip_db, :type => :boolean, :desc => "Skip database prompts and use default settings"
95
+ method_option :use_defaults, :type => :boolean, :desc => "Skip all prompts and use default settings"
96
+ method_option :no_wp, :type => :boolean, :desc => "New project is not a WordPress install"
97
+ method_option :no_db, :type => :boolean, :desc => "New project does not need a database"
98
+ #
99
+ # @return {Void}
100
+ #
101
+ def setup
102
+ @io.hello
103
+ @create.new(options.dup.merge({
104
+ :theme => false,
105
+ :bare => true,
106
+ })).execute
107
+ end
222
108
 
223
- @subcommand.new(opts)
224
- end
109
+ desc "delete", "Delete project (does not delete local project)"
110
+ method_option :name, :type => :string, :aliases => "-n", :default => nil, :desc => "Name of the development project"
111
+ method_option :url, :type => :string, :aliases => "-u", :default => nil, :desc => "Development URL for the project"
112
+ method_option :db_drop, :type => :boolean, :aliases => "--drop-db", :desc => "Drop project's database"
113
+ method_option :vm_restart, :type => :boolean, :aliases => "--restart-vm", :desc => "Restart VM after deletion"
114
+ #
115
+ # @return {Void}
116
+ #
117
+ def delete
118
+ @delete.new(options).unexecute
119
+ end
225
120
 
226
- desc "vm [COMMANDS]", "Manage virtual development environment with Vagrant"
227
- #
228
- # Vagrant
229
- #
230
- # @param {*} commands
231
- # Commands to run
232
- #
233
- # @return {Void}
234
- #
235
- def vm(*commands)
236
- self.set_environment
121
+ desc "deploy", "Manage deployment and migration"
122
+ #
123
+ # @return {Void}
124
+ #
125
+ def deploy
126
+ @deploy.new(options).execute
127
+ end
237
128
 
238
- system "cd #{@environment.vvv_path} && vagrant #{commands.join(" ")}"
239
- end
129
+ desc "list", "List all projects"
130
+ #
131
+ # @return {Void}
132
+ #
133
+ def list
134
+ @list.new(options).list :projects
135
+ end
240
136
 
241
- #
242
- # Non-Thor commands
243
- #
244
- no_commands do
137
+ desc "install", "Run installation for project"
138
+ #
139
+ # @return {Void}
140
+ #
141
+ def install
142
+ @config.install
143
+ end
245
144
 
246
- #
247
- # Set up the environment
248
- #
249
- # @return {Void}
250
- #
251
- def set_environment
252
- @version = ::ThemeJuice::VERSION
253
- @environment = ::ThemeJuice::Environment
254
- @interaction = ::ThemeJuice::Interaction
255
- @create = ::ThemeJuice::Command::Create
256
- @delete = ::ThemeJuice::Command::Delete
257
- @list = ::ThemeJuice::Command::List
258
- @install = ::ThemeJuice::Command::Install
259
- @subcommand = ::ThemeJuice::Command::Subcommand
145
+ desc "update", "Update tj and its dependencies"
146
+ #
147
+ # @return {Void}
148
+ #
149
+ def update
150
+ @io.error "Not implemented"
151
+ end
260
152
 
261
- self.force_vvv_path?
153
+ desc "watch [COMMANDS]", "Watch and compile assets"
154
+ #
155
+ # @return {Void}
156
+ #
157
+ def watch(*commands)
158
+ @config.watch *commands
159
+ end
262
160
 
263
- @environment.yolo = options[:yolo]
264
- @environment.boring = options[:boring]
265
- # @environment.no_deployer = options[:no_deployer]
266
- @environment.no_colors = if @environment.boring then true else options[:no_colors] end
267
- @environment.no_unicode = if @environment.boring then true else options[:no_unicode] end
268
- # @environment.no_animations = if @environment.boring then true else options[:no_animations] end
161
+ desc "vendor [COMMANDS]", "Manage vendor dependencies"
162
+ #
163
+ # @return {Void}
164
+ #
165
+ def vendor(*commands)
166
+ @config.vendor *commands
167
+ end
269
168
 
270
- # if self.deployer?
271
- # @deployer = ::ThemeJuiceDeploy::Deployer
272
- # else
273
- # @deployer = nil
274
- # end
275
- end
169
+ desc "dist [COMMANDS]", "Package project for distribution"
170
+ #
171
+ # @return {Void}
172
+ #
173
+ def dist(*commands)
174
+ @config.dist *commands
175
+ end
276
176
 
277
- # #
278
- # # Load deployer if installed
279
- # #
280
- # # @return {Bool}
281
- # #
282
- # def deployer?
283
- # if @environment.no_deployer
284
- # false
285
- # else
286
- # begin
287
- # require "theme-juice-deploy"
288
- # true
289
- # rescue LoadError
290
- # false
291
- # end
292
- # end
293
- # end
177
+ desc "wp [COMMANDS]", "Manage WordPress installation"
178
+ #
179
+ # @return {Void}
180
+ #
181
+ def wp(*commands)
182
+ @config.wp *commands
183
+ end
294
184
 
295
- #
296
- # Set VVV path
297
- #
298
- # @return {Void}
299
- #
300
- def force_vvv_path?
301
- if options[:vvv_path].nil?
302
- @environment.vvv_path = File.expand_path("~/vagrant")
303
- else
304
- @environment.vvv_path = options[:vvv_path]
305
- @interaction.notice "You're using a custom VVV path : (#{@environment.vvv_path})"
185
+ desc "backup [COMMANDS]", "Backup project"
186
+ #
187
+ # @return {Void}
188
+ #
189
+ def backup(*commands)
190
+ @config.backup *commands
191
+ end
306
192
 
307
- unless @interaction.agree? "Is the path correct?"
308
- @interaction.error "Good call. Let's create things, not break things. Aborting mission."
309
- end
310
- end
193
+ desc "test [COMMANDS]", "Manage and run project tests"
194
+ #
195
+ # @return {Void}
196
+ #
197
+ def test(*commands)
198
+ @config.test *commands
199
+ end
311
200
 
312
- unless Dir.exist? @environment.vvv_path
313
- @interaction.error "Cannot load VVV path (#{@environment.vvv_path}). Aborting mission before something bad happens."
314
- end
315
- end
316
- end
201
+ desc "vm [COMMANDS]", "Manage development environment"
202
+ #
203
+ # @return {Void}
204
+ #
205
+ def vm(*commands)
206
+ @util.inside @env.vm_path do
207
+ @util.run "vagrant #{commands.join(" ")}", :verbose => @env.verbose
208
+ end
317
209
  end
210
+ end
318
211
  end