Skip to content

Commit 3455631

Browse files
committed
Merge pull request #26 from loadsys/f/delete-old-files
F/delete old files
2 parents f73ca97 + b583fe3 commit 3455631

6 files changed

Lines changed: 57 additions & 16 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This collection of scripts is intended to provide consistency and shortcuts for
88
* The 2.x branch is meant for projects that use composer (although submodules are still supported).
99
* Most scripts listed below can take a `-h` option as their first argument to output usage information.
1010
* Most are designed to run with few or no arguments; they try to guess sensible defaults whenever possible.
11+
* Most are designed to fail gracefully. For example, if `pear` is available and your project defines a pear config file, then those dependencies will be installed by `deps-install`, otherwise pear will be silently ignored. This provides maximum flexibility without having to customize the scripts per-project.
1112

1213

1314
## Requirements ##
@@ -29,8 +30,8 @@ Additionally, some scripts expect additional tools that should be automatically
2930

3031
* `bin/phpcs`
3132
* `bin/phpunit`
32-
* `bin/phpdoc.php`
33-
* `bin/cake` (composer installed **by target project**)
33+
* `bin/phpdoc`
34+
* `bin/cake` (composer-installed **by target project**)
3435

3536
If these items are not available, some scripts may not function as expected.
3637

@@ -46,7 +47,7 @@ Your project's own `composer.json` file should look something like this:
4647
```json
4748
{
4849
"require": {
49-
"loadsys/cakephp-shell-scripts": "*"
50+
"loadsys/cakephp-shell-scripts": "2.0.*"
5051
},
5152
"config": {
5253
"bin-dir": "bin"

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"require": {
1212
"php": ">=5.3.0",
1313
"phpunit/phpunit": "3.7.*",
14-
"phpdocumentor/phpdocumentor": "2.*@beta",
14+
"phpdocumentor/phpdocumentor": "2.*",
1515
"squizlabs/php_codesniffer": "1.*",
1616
"loadsys/loadsys_codesniffer": "0.*"
1717
},
@@ -38,6 +38,7 @@
3838
"env-vars-echo",
3939
"env-vars-load",
4040
"find-symlinks-to-in",
41+
"folder-delete-items-older-than-days",
4142
"git-currentbranch",
4243
"git-localchanges",
4344
"git-remotechanges",

docs-generate

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,4 @@ if [ $? -gt 0 ]; then
4040
fi
4141
echo "## Found phpdoc at: ${PHPDOC}"
4242

43-
44-
$PHPDOC --configuration="${CFG_FILE}" "$@"
43+
bin/run-in-vagrant ""${PHPDOC}" --config="${CFG_FILE}" "$@""

find-symlinks-to-in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ ${0##*/}
1414
Usage:
1515
bin/${0##*/} <partial> [search dir]
1616
17-
$1 = The partial file name/path for which to search. You can use grep syntax.
18-
$2 = The directory in which to search. If not provided, defaults to the current directory (./).
17+
\$1 = The partial file name/path for which to search. You can use grep syntax.
18+
\$2 = The directory in which to search. If not provided, defaults to the current directory (./).
1919
2020
Environment Variables:
2121
(none)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
#---------------------------------------------------------------------
4+
usage () {
5+
cat <<EOT
6+
7+
${0##*/}
8+
Deletes files (only) within the given folder that have a
9+
modified time older than the optional second argument.
10+
11+
Usage:
12+
bin/${0##*/} <path> [days]
13+
14+
\$1 = The root filesystem path to search. Will be
15+
provided to \`find\`.
16+
\$2 = Optional last modified age in days for files that should
17+
be kept. Files older than (today - \$2 eu days) will be
18+
deleted. Default = 30 days.
19+
20+
Environment Variables:
21+
(none)
22+
23+
EOT
24+
25+
exit ${1:-0} # Exit with code 0 unless an arg is passed to the method.
26+
}
27+
if [ "$1" = '-h' ]; then
28+
usage
29+
fi
30+
31+
# Process command line args.
32+
if [ -n "$1" ]; then
33+
SEARCH_PATH=$1
34+
else
35+
echo "!! No path provided. Aborting."
36+
usage 1
37+
fi
38+
if [ -n "$2" ]; then
39+
AGE_DAYS=$2
40+
else
41+
AGE_DAYS=30
42+
fi
43+
44+
45+
find "${SEARCH_PATH}" -type f -mtime +${AGE_DAYS} -print0 | xargs -0 rm -f

run-codesniffer

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,13 @@ else
6161
COVERAGE="--report-full --report-summary"
6262
fi
6363

64-
# @TODO: Detect which to use. Ours should be a dependency of the shell-scripts so it's always available though.
65-
CODE_STANDARD=CakePHP
64+
# Should always be available, since it is a sub-dependency of the
65+
# loadsys/cakephp-shell-scripts composer package itself.
6666
CODE_STANDARD=Vendor/loadsys/loadsys_codesniffer/Loadsys
67+
6768
$PHPCS -p --extensions=php --standard="$CODE_STANDARD" ${COVERAGE} ${SNIFF_FOLDERS[@]}
6869

6970
if [ $SAVE_REPORTS ] && [ $? -eq 0 ]; then
7071
echo "## Full report created at: ${FULL_REPORT_FILE}"
7172
echo "## Summary report created at: ${SUMMARY_REPORT_FILE}"
7273
fi
73-
74-
75-
#@TODO: Make use of new Loadsys code standard.
76-
# Ref: https://github.com/loadsys/loadsys_codesniffer
77-
# Example usage:
78-
# bin/phpcs --standard=Vendor/loadsys/loadsys_codesniffer/Loadsys --report-summary -p --extensions=php Controller/ Model/ View/ Lib/

0 commit comments

Comments
 (0)