Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b14fa74

Browse files
author
Slavey Karadzhov
committedJul 23, 2015
Added support for the **/xyz format in the properties file.
See issue #69. Compiled new phar file with that functionality.
1 parent 433bf7d commit b14fa74

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed
 

‎README.md

+5
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ Notice about delimiters: Choose your delimiter wisely.
275275
* A delimiter should not be special character that is removed silently by your shell.
276276
* A delimiter should not be one of the characters that are already in the data.
277277

278+
Deployment properties syntax
279+
============================
280+
In the `deployment.properties` file one can specify the files that will become part of the
281+
application or part of the deployment scripts.
282+
278283
Feedback
279284
========
280285
For questions and feedback write to slavey (at) zend DOT com.

‎bin/zs-client.phar

620 Bytes
Binary file not shown.

‎module/Client/src/Client/Service/ZpkInvokable.php

+37-9
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public function pack($sourceFolder, $destinationFolder=".", $fileName=null, arra
305305
$includeMap = array();
306306
if ($type == self::TYPE_LIBRARY) {
307307
// Include all files and folders for the library
308-
$properties['appdir.includes'] = array_diff(scandir($sourceFolder), array('.','..','deployment.properties'));
308+
$properties['appdir.includes'] = array_diff(scandir($sourceFolder), array('.','..','deployment.properties'));
309309
$appDir = '';
310310
}
311311
$includeMap['appdir'] = $this->getAppPaths($appDir, $properties['appdir.includes']);
@@ -325,8 +325,22 @@ public function pack($sourceFolder, $destinationFolder=".", $fileName=null, arra
325325
$excludes = $properties[$type.'.excludes'];
326326
}
327327

328+
$excludedEndings = array();
329+
foreach ($excludes as $exclude) {
330+
$exclude = trim($exclude);
331+
$exclude = rtrim($exclude, '/'); # no trailing slashes
332+
if (strlen($exclude) == 0) {
333+
continue;
334+
}
335+
// We support **/<something> syntax. It means all entries ending with <something>
336+
// will be excluded from the list of files
337+
if (preg_match("/^\*\*\/(.*?)$/", $exclude, $matches)) {
338+
$excludedEndings[$matches[1]] = strlen($matches[1]);
339+
}
340+
}
341+
328342
foreach ($paths as $localPath => $zpkPath) {
329-
$this->addPathToZpk($zpk, $sourceFolder, $localPath, $zpkPath, $excludes);
343+
$this->addPathToZpk($zpk, $sourceFolder, $localPath, $zpkPath, $excludes, $excludedEndings);
330344
}
331345
}
332346

@@ -445,12 +459,17 @@ protected function fixZipPath($path)
445459
* @param string $directory
446460
* @param string $baseDir
447461
*/
448-
protected function addPathToZpk($zpk, $sourceFolder, $localPath, $zpkPath, $excludes = array())
462+
protected function addPathToZpk($zpk, $sourceFolder, $localPath, $zpkPath, $excludes = array(), $excludedEndings=array())
449463
{
450464
$localPath = $this->normalizePath($localPath);
451465
if (in_array($localPath, $excludes)) {
452466
return;
453467
}
468+
foreach ($excludedEndings as $exclude => $length) {
469+
if (substr($localPath, -$length) === $exclude) {
470+
return;
471+
}
472+
}
454473

455474
$fullPath = $sourceFolder.'/'.$localPath;
456475
if (is_file($fullPath)) {
@@ -467,17 +486,26 @@ protected function addPathToZpk($zpk, $sourceFolder, $localPath, $zpkPath, $excl
467486

468487
// we are dealing with directories
469488
$entries = scandir($fullPath);
470-
if (count($entries) <= 2) {
489+
// filter entries
490+
foreach ($entries as $idx => $name) {
491+
if (in_array($name, array('.','..'))) {
492+
unset($entries[$idx]);
493+
continue;
494+
}
495+
496+
foreach ($excludedEndings as $exclude => $length) {
497+
if ($name === $exclude) {
498+
unset($entries[$idx]);
499+
}
500+
}
501+
}
502+
if (count($entries) == 0) {
471503
$zpk->addEmptyDir($zpkPath);
472504
return;
473505
}
474506

475507
foreach ($entries as $name) {
476-
if (in_array($name, array('.','..'))) {
477-
continue;
478-
}
479-
480-
$this->addPathToZpk($zpk, $sourceFolder, $localPath.'/'.$name, $zpkPath.'/'.$name, $excludes);
508+
$this->addPathToZpk($zpk, $sourceFolder, $localPath.'/'.$name, $zpkPath.'/'.$name, $excludes, $excludedEndings);
481509
}
482510
}
483511

-529 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.