set_time_limit(0);
Benchmark::startLive();
// get app name
if (empty($_REQUEST['name'])) {
    die('Parameter name required');
}
$appName = $_REQUEST['name'];
$App = new Sencha_App($appName);
// get target framework version
if (empty($_REQUEST['cmdVersion'])) {
    die('Parameter cmdVersion required');
}
$cmdVersion = $_REQUEST['cmdVersion'];
Benchmark::mark("configured request: appName={$appName}");
// get framework
$framework = $App->getFramework();
$frameworkVersion = $App->getFrameworkVersion();
if (!$frameworkVersion) {
    die("Unable to determine framework version, if this is an old application you need to manually set app.framework.version in .sencha/app/sencha.cfg");
}
// set paths
$workspacePath = 'sencha-workspace';
$workspaceConfigPath = "{$workspacePath}/.sencha";
$frameworkPath = "{$workspacePath}/{$framework}-{$frameworkVersion}";
$packagesPath = "{$workspacePath}/packages";
$appPath = "{$workspacePath}/{$appName}";
$archivePath = "sencha-build/{$appName}/archive";
// get temporary directory and set paths
$tmpPath = Emergence_FS::getTmpDir();
$workspaceConfigTmpPath = "{$tmpPath}/.sencha";
$frameworkTmpPath = "{$tmpPath}/{$framework}";
 public static function handleCacheManifestRequest(Sencha_App $App)
 {
     $templateNode = Emergence\Dwoo\Template::findNode($App->getFramework() . '.tpl');
     $cacheConfig = $App->getAppCfg('appCache');
     header('Content-Type: text/cache-manifest');
     echo "CACHE MANIFEST\n";
     echo "# {$templateNode->SHA1}\n";
     if (!empty($cacheConfig['cache']) && is_array($cacheConfig['cache'])) {
         foreach ($cacheConfig['cache'] as $path) {
             if ($path != 'index.html') {
                 $path = "build/production/{$path}";
                 echo "{$path}\n";
                 if ($assetNode = $App->getAsset($path)) {
                     echo "#{$assetNode->SHA1}\n";
                 }
             }
         }
     }
     if (!empty($_GET['platform']) && !empty($cacheConfig['platformCache']) && !empty($cacheConfig['platformCache'][$_GET['platform']]) && is_array($cacheConfig['platformCache'][$_GET['platform']])) {
         echo "\n# {$_GET['platform']}:\n";
         foreach ($cacheConfig['platformCache'][$_GET['platform']] as $path) {
             $path = "build/production/{$path}";
             if ($assetNode = $App->getAsset($path)) {
                 echo "{$path}\n";
                 echo "#{$assetNode->SHA1}\n";
             }
         }
     }
     echo "\nFALLBACK:\n";
     if (!empty($cacheConfig['fallback']) && is_array($cacheConfig['fallback'])) {
         foreach ($cacheConfig['fallback'] as $path) {
             echo "{$path}\n";
         }
     }
     echo "\nNETWORK:\n";
     if (!empty($cacheConfig['network']) && is_array($cacheConfig['network'])) {
         foreach ($cacheConfig['network'] as $path) {
             echo "{$path}\n";
         }
     }
     echo "\n# TRIGGERS:\n";
     $templateNode = Emergence\Dwoo\Template::findNode($App->getFramework() . '.tpl');
     echo "#template: {$templateNode->SHA1}\n";
     if (!empty($cacheConfig['triggers']) && is_array($cacheConfig['triggers'])) {
         foreach ($cacheConfig['triggers'] as $path) {
             $assetNode = $path[0] == '/' ? Site::resolvePath($path) : $App->getAsset($path);
             if ($assetNode) {
                 echo "#{$assetNode->SHA1}\n";
             }
         }
     }
     exit;
 }