Skip to content

Commit 79116d5

Browse files
committed
add deps package command
1 parent c3bb977 commit 79116d5

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

bin/phpsdk_deps.php

+18-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use SDK\{Config, Exception};
66

7-
$sopt = "s:cuhb:a:d:t:fn";
7+
$sopt = "s:cuhb:a:d:t:fnp";
88
$lopt = array(
99
"branch:",
1010
"update",
@@ -16,6 +16,7 @@
1616
"deps:",
1717
"force",
1818
"no-backup",
19+
"pack",
1920
);
2021

2122
$cmd = NULL;
@@ -87,6 +88,11 @@
8788
case "no-backup":
8889
$backup = false;
8990
break;
91+
92+
case "p":
93+
case "pack":
94+
$cmd = "pack";
95+
break;
9096
}
9197
}
9298

@@ -157,6 +163,15 @@
157163
$dm->performUpdate($msg, $force, $backup);
158164
msg($msg);
159165
break;
166+
case "pack":
167+
$path_to_pack = Config::getDepsLocalPath();
168+
$pack_path = dirname($path_to_pack) . DIRECTORY_SEPARATOR . "deps-$branch-$branch_data[crt]-$branch_data[arch].7z";
169+
print "Packaging '$path_to_pack' as '$pack_path'.\n\n";
170+
if ($force && is_file($pack_path)) {
171+
unlink($pack_path);
172+
}
173+
`7za a $pack_path $path_to_pack`;
174+
break;
160175
}
161176

162177
} catch (Throwable $e) {
@@ -177,7 +192,8 @@ function usage(int $code = -1)
177192
echo " -s --stability One of stable or staging.", PHP_EOL, PHP_EOL;
178193
echo "Commands:", PHP_EOL;
179194
echo " -c --check Check for dependency updates. If updates are available, the exit code is set to 7.", PHP_EOL;
180-
echo " -u --update Update dependencies. If deps directory already exists, backup copy is created automatically.", PHP_EOL, PHP_EOL;
195+
echo " -u --update Update dependencies. If deps directory already exists, backup copy is created automatically.", PHP_EOL;
196+
echo " -p --pack Archive the dependency directory.", PHP_EOL, PHP_EOL;
181197
echo "Misc:", PHP_EOL;
182198
echo " -d --deps Path to the dependencies directory. If omited, CWD is used to guess.", PHP_EOL;
183199
echo " -f --force Force the operation even if there are no upgrades available.", PHP_EOL;

0 commit comments

Comments
 (0)