You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-21Lines changed: 49 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,11 @@
1
1
# Loadsys Cake Command Line Scripts
2
2
3
-
**DISCLAIMER: We use these tools ourselves, but that doesn't mean they will necessarily work for you in your situation. This repo is public in case it can be of use to anyone else (and because it's convenient for us), but it _is not supported_ and _may change without notice_. Issues and contributions may be flat out ignored if they don't impact us. You have been warned!**
3
+
This collection of scripts is intended to provide consistency and shortcuts for common project tasks. Key tools are highlighted and described below. Coordinates heavily with the [Loadsys CakePHP App Skeleton](https://github.com/loadsys/CakePHP-Skeleton).
4
+
5
+
* This is the `master` branch and along with the `3.x.x` releases is meant for use with Cake 3 projects exclusively.
6
+
* The [`cake-2.x`](https://github.com/loadsys/CakePHP-Shell-Scripts/tree/cake-2.x) branch and `2.x.x` releases are meant for Cake 2.x projects that use composer (git submodules are still supported).
4
7
5
-
This collection of scripts is intended to provide consistency and shortcuts for common project tasks. Key tools are highlighted and described below.
6
8
7
-
* The master branch is meant for use with Cake 3 projects exclusively.
8
-
* The 2.x branch is meant for Cake 2.x projects that use composer (git submodules are still supported).
9
-
* The 1.x branch is tuned for Cake 1.x projects that use git submodules for dependency management.
10
9
* Most scripts listed below can take a `-h` option as their first argument to output usage information.
11
10
* Most are designed to run with few or no arguments; they try to guess sensible defaults whenever possible.
12
11
* Most are designed to fail gracefully with a non-zero exit code.
@@ -20,8 +19,9 @@ The following dependencies are assumed to be available on the target system and
20
19
*`composer`
21
20
*`git`
22
21
*`mail`
22
+
*`mysql`
23
23
*`mysqldump`
24
-
*`php`
24
+
*`php` (v5.6 recommended)
25
25
*`realpath` (not available by default on OS X)
26
26
*`readlink`
27
27
*`zip`
@@ -52,9 +52,10 @@ Your project's `composer.json` file should include something like this:
52
52
}
53
53
}
54
54
```
55
+
55
56
Then run `composer install` to pull this repo into your project. A `bin/` folder should be created in your project root with symlinks to all of the scripts from this package.
56
57
57
-
**Note**: The `bin-dir` is non-standard and may cause conflicts with other composer packages that install "binaries". These scripts are all expect to live in `PROJECT_ROOT/bin` though so don't expect anything to work if you forgo the `bin-dir` setting in your project.
58
+
**Note**: The `bin-dir` is non-standard and may cause conflicts with other composer packages that install "binaries". The bundled scripts all expect to live in `PROJECT_ROOT/bin` though so don't expect anything to work if you forgo the `bin-dir` setting in your project.
58
59
59
60
60
61
## Contributing Improvements
@@ -73,42 +74,69 @@ There currently is not a convenient way to set up a test harness around this rep
73
74
## Notable Scripts
74
75
75
76
76
-
### bin/update
77
+
### bin/cache-clear
78
+
79
+
Uses the new `ConsoleShell` to iterate over all of the configured Caches in your app and clear each one.
80
+
81
+
82
+
### bin/codesniffer-run
83
+
84
+
Wraps the call to PHPCodeSniffer so that it can be called from inside or outside a Vagrant VM. Also checks the `installed_paths` configuration of phpcs and injects the necessary paths for the CakePHP and Loadsys coding standards if they are not already present.
85
+
86
+
87
+
### bin/coverage-ensure
88
+
89
+
Reads the location of the `clover.xml` file generated from your phpunit runs from your `phpunit.xml[.dist]` file, then examines that file for how much of your code is covered. Takes an integer command line argument representing the minimum required percentage, and returns with an exit status non-zero if your coverage is lacking. Intended for use during automated testing runs, such as on Travis.
90
+
91
+
92
+
### bin/db-backup
93
+
94
+
Uses the default database credentials in `config/app.php` to create a ZIPed `mysqldump` of that database in a local `backups/` folder. Helpful because you don't have to specify DB credentials. It also reports the ZIP size to help you keep a mental tally over time.
95
+
96
+
Can be used manually for one-off backups before dangerous operations (such as a code deploy and DB migrations), or automatically (such as in a Vagrant VM shutdown script, to preserve an internal DB and protect it from `vagrant destroy`.)
97
+
98
+
99
+
### bin/db-login
100
+
101
+
A simple shortcut script that uses the `[Datasources][default]` key defined in `config/app.php` to start a command line `mysql` session for you. Incredibly convenient in a production environment to run manual data queries during troubleshooting.
102
+
103
+
Also properly handles I/O redirection, so any time you would normally run `mysql --user=user -ppass --host=host --port=3306 database_name < import.sql` you can instead just run `bin/db-login < import.sql` and never have to worry about the connection credentials. Great for scripting and provisioning.
104
+
105
+
106
+
### bin/deploy
77
107
78
108
Automates all of the steps for a read-only copy of the app (such as staging or production) to pull new code from the repo and update the local running copy. It performs tasks like:
79
109
80
110
* Checking the local working copy to make sure no changes have been made from the checked-out commit that might prevent an automatic pull or merge.
81
111
* Backing up the active database (crudely, but effective for smallish apps).
82
-
* On older projects, checking for db_updates.sql changes that should be applied before merging new code and pausing to display them to the user before proceeding.
83
112
* Pulling and merging code from the remote repo.
84
113
* Applying Migrations, if present.
85
114
* Clearing Cake cache directories.
86
115
* Copying over environment-specific configs, if present.
* Ensuring file ownership and write permissions are still correct.
89
-
* Showing the user the new active commit's log.
118
+
* Showing the user the new active commit's log and optionally generating a notification email.
90
119
91
120
92
-
### bin/db-login
121
+
### bin/docs-generate
93
122
94
-
A simple shortcut script that uses the `[Datasources][default]` key defined in `config/app.php`to start a command line `mysql` session for you. Incredibly convenient in a production environment to run manual data queries during troubleshooting.
123
+
Wraps the call to phpDocumentor so that it can be called from inside or outside a Vagrant VM but always executed inside.
95
124
96
125
97
-
### bin/db-backup
126
+
### bin/tests-run
98
127
99
-
Uses the default database credentials in `config/app.php`to create a ZIPed `mysqldump` of that database in a local `backups/` folder. Helpful because you don't have to specify DB credentials. It also reports the ZIP size to help you keep a mental tally over time.
128
+
Intended to serve as a convenience method for executing phpunit since it's callable from your host machine and will execute tests inside of vagrant in that case.
100
129
101
-
102
-
### @TODO:
103
-
104
-
Add cache-clear, tests-run, docs-generate, codesniffer-run here as notable scripts.
130
+
It can also take a partial filename as an argument and run the corresponding test case directly. This mode of use is intended to be paired with a file watcher, like [kicker](https://github.com/alloy/kicker), [grunt](http://gruntjs.com/) or [efsw](https://bitbucket.org/SpartanJ/efsw). When a source file or its test case counterpart is changed, the tests for that single file can be executed automatically inside the VM.
105
131
106
132
107
133
## License
108
134
109
-
MIT
135
+
[MIT](LICENSE.md)
136
+
137
+
**DISCLAIMER: We use these tools ourselves, but that doesn't mean they will necessarily work for you in your situation. This repo is public in case it can be of use to anyone else (and because it's convenient for us), but it _is not supported_ and _may change without notice_. Issues and contributions may be ignored if they don't impact us. You have been warned!**
0 commit comments