feat(seo-copy): restore all source scenes
This commit is contained in:
@@ -19,18 +19,20 @@ function usage(): void
|
||||
$script = basename(__FILE__);
|
||||
echo <<<TXT
|
||||
Usage:
|
||||
php code/scripts/{$script} --host=chuanjiafeng-net --source=/abs/source/path [--target=/abs/target/path] [--dry-run]
|
||||
php code/scripts/{$script} --host=chuanjiafeng-net --source=/abs/source/path [--target=/abs/target/path] [--scenes=detail,play] [--dry-run]
|
||||
|
||||
Options:
|
||||
--host Host directory name under seo_copy, e.g. chuanjiafeng-net
|
||||
--source Source root that contains <host>/detail/*.json and <host>/play/*.json
|
||||
--target Target root. Defaults to code/data/seo_copy_published
|
||||
--scenes Optional comma-separated scenes. Defaults to all known scenes found in source
|
||||
--dry-run Preview only, do not write files
|
||||
|
||||
Examples:
|
||||
php code/scripts/{$script} \\
|
||||
--host=chuanjiafeng-net \\
|
||||
--source=code/storage/domain_bootstrap_bundles/chuanjiafeng-compact/data/seo_copy \\
|
||||
--scenes=home,category_index,category_list,search,rank_index,rank_list,detail,forge,play \\
|
||||
--dry-run
|
||||
|
||||
TXT;
|
||||
@@ -80,6 +82,7 @@ foreach (array_slice($argv, 1) as $strArg) {
|
||||
$strHost = trim((string)($arrArgs['host'] ?? ''));
|
||||
$strSource = trim((string)($arrArgs['source'] ?? ''));
|
||||
$strTarget = trim((string)($arrArgs['target'] ?? base_path('data/seo_copy_published')));
|
||||
$strScenes = trim((string)($arrArgs['scenes'] ?? ''));
|
||||
$boolDryRun = !empty($arrArgs['dry-run']);
|
||||
|
||||
if ($strHost === '' || $strSource === '') {
|
||||
@@ -96,7 +99,33 @@ if (!is_dir($strHostSource)) {
|
||||
exit(2);
|
||||
}
|
||||
|
||||
$arrScenes = ['detail', 'play'];
|
||||
$arrKnownScenes = ['home', 'category_index', 'category_list', 'search', 'rank_index', 'rank_list', 'detail', 'forge', 'play'];
|
||||
$arrScenes = [];
|
||||
|
||||
if ($strScenes !== '') {
|
||||
foreach (explode(',', $strScenes) as $strScene) {
|
||||
$strScene = trim((string)$strScene);
|
||||
if ($strScene === '' || !in_array($strScene, $arrKnownScenes, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$arrScenes[] = $strScene;
|
||||
}
|
||||
} else {
|
||||
foreach ($arrKnownScenes as $strScene) {
|
||||
if (is_dir($strHostSource . '/' . $strScene)) {
|
||||
$arrScenes[] = $strScene;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$arrScenes = array_values(array_unique($arrScenes));
|
||||
|
||||
if (empty($arrScenes)) {
|
||||
fwrite(STDERR, "no valid scenes found for host: {$strHost}\n");
|
||||
exit(3);
|
||||
}
|
||||
|
||||
$arrSummary = [];
|
||||
|
||||
foreach ($arrScenes as $strScene) {
|
||||
|
||||
Reference in New Issue
Block a user