示例#1
0
// check if there is an existing repo
if (!is_dir("{$repoPath}/.git")) {
    die("{$repoPath} does not contain .git");
}
// get repo
chdir($repoPath);
// sync trees
foreach ($repoCfg['trees'] as $srcPath => $treeOptions) {
    if (is_string($treeOptions)) {
        $treeOptions = array('path' => $treeOptions);
    }
    $treeOptions = array_merge($exportOptions, $treeOptions, ['dataPath' => false]);
    if (!is_string($srcPath)) {
        $srcPath = $treeOptions['path'];
    } elseif (!$treeOptions['path']) {
        $treeOptions['path'] = $srcPath;
    }
    $srcFileNode = Site::resolvePath($srcPath);
    if (is_a($srcFileNode, 'SiteFile')) {
        $destDir = dirname($treeOptions['path']);
        if ($destDir && !is_dir($destDir)) {
            mkdir($destDir, 0777, true);
        }
        copy($srcFileNode->RealPath, $treeOptions['path']);
        Benchmark::mark("exported file {$srcPath} to {$treeOptions['path']}");
    } else {
        $exportResult = Emergence_FS::exportTree($srcPath, $treeOptions['path'], $treeOptions);
        Benchmark::mark("exported directory {$srcPath} to {$treeOptions['path']}: " . http_build_query($exportResult));
    }
}
Benchmark::mark("wrote all changes");
示例#2
0
        #		Benchmark::mark("precached $cachedFiles files in $classPathSource");
        $sourceNode = Site::resolvePath($classPathSource);
        if (is_a($sourceNode, SiteFile)) {
            mkdir(dirname($classPathDest), 0777, true);
            copy($sourceNode->RealPath, $classPathDest);
            Benchmark::mark("copied file {$classPathSource} to {$classPathDest}");
        } else {
            $exportResult = Emergence_FS::exportTree($classPathSource, $classPathDest);
            Benchmark::mark("exported {$classPathSource} to {$classPathDest}: " . http_build_query($exportResult));
        }
    }
}
// write archive
if (!empty($_GET['archive'])) {
    try {
        $exportResult = Emergence_FS::exportTree($archivePath, $archiveTmpPath);
        Benchmark::mark("exported {$archivePath} to {$archiveTmpPath}: " . http_build_query($exportResult));
    } catch (Exception $e) {
        Benchmark::mark("failed to export {$archivePath}, continueing");
    }
}
// change into app's directory
chdir($appTmpPath);
Benchmark::mark("chdir to: {$appTmpPath}");
// prepare cmd
$cmd = Sencha::buildCmd($cmdVersion, 'ant', "-Dbuild.dir={$buildTmpPath}", 'sass');
Benchmark::mark("running CMD: {$cmd}");
// execute CMD
passthru("{$cmd} 2>&1", $cmdStatus);
Benchmark::mark("CMD finished: exitCode={$cmdStatus}");
// import resources directory
示例#3
0
Benchmark::mark("precached {$frameworkPath}");
$exportResult = Emergence_FS::exportTree($frameworkPath, $frameworkTmpPath);
Benchmark::mark("exported {$frameworkPath} to {$frameworkTmpPath}: " . http_build_query($exportResult));
// ... app
$cachedFiles = Emergence_FS::cacheTree($appPath);
Benchmark::mark("precached {$appPath}");
$exportResult = Emergence_FS::exportTree($appPath, $appTmpPath);
Benchmark::mark("exported {$appPath} to {$appTmpPath}: " . http_build_query($exportResult));
// write any libraries from classpath
$classPaths = explode(',', $App->getBuildCfg('app.classpath'));
foreach ($classPaths as $classPath) {
    if (substr($classPath, 0, 2) == 'x/') {
        $classPathSource = 'ext-library' . substr($classPath, 1);
        $cachedFiles = Emergence_FS::cacheTree($classPathSource);
        Benchmark::mark("precached {$cachedFiles} files from {$classPathSource}");
        $exportResult = Emergence_FS::exportTree($classPathSource, "{$appTmpPath}/{$classPath}");
        Benchmark::mark("exported {$classPathSource} to {$appTmpPath}/{$classPath}: " . http_build_query($exportResult));
    }
}
// change into app's directory
chdir($appTmpPath);
Benchmark::mark("chdir to: {$appTmpPath}");
// prepare and run upgrade command
$upgradeCmd = Sencha::buildCmd($cmdVersion, 'app upgrade --noframework');
Benchmark::mark("running upgrade CMD: {$upgradeCmd}");
passthru($upgradeCmd, $upgradeCmdStatus);
Benchmark::mark("Upgrade CMD finished: exitCode={$upgradeCmdStatus}");
// import results
Benchmark::mark("importing {$appTmpPath}");
$importResults = Emergence_FS::importTree($appTmpPath, $appPath, array('exclude' => array("#^/x(/|\$)#", "#/\\.sass-cache(/|\$)#", "#/\\.sencha-backup(/|\$)#", "#/\\.emergence(/|\$)#")));
Benchmark::mark("imported files: " . http_build_query($importResults));
示例#4
0
$tmpPath = Emergence_FS::getTmpDir();
$tmpConfigPath = "{$tmpPath}/.sencha";
$tmpFrameworkPath = "{$tmpPath}/{$framework}";
Benchmark::mark("created tmp: {$tmpPath}");
$workspacePath = 'sencha-workspace';
$workspaceConfigPath = "{$workspacePath}/.sencha";
$workspaceFrameworkPath = "{$workspacePath}/{$framework}-{$frameworkVersion}";
// precache framework and workspace config
$cachedFiles = Emergence_FS::cacheTree($workspaceConfigPath);
Benchmark::mark("precached {$workspaceConfigPath}");
$cachedFiles = Emergence_FS::cacheTree($workspaceFrameworkPath);
Benchmark::mark("precached {$workspaceFrameworkPath}");
// write workspace to tmp
$exportResult = Emergence_FS::exportTree($workspaceConfigPath, $tmpConfigPath);
Benchmark::mark("exported {$workspaceConfigPath} to {$tmpConfigPath}: " . http_build_query($exportResult));
$exportResult = Emergence_FS::exportTree($workspaceFrameworkPath, $tmpFrameworkPath);
Benchmark::mark("exported {$workspaceFrameworkPath} to {$tmpFrameworkPath}: " . http_build_query($exportResult));
// begin cmd
$appPath = "{$workspacePath}/{$appName}";
$appTmpPath = "{$tmpPath}/{$appName}";
$cmd = Sencha::buildCmd(null, "-sdk {$tmpFrameworkPath}", 'generate app', $appName, $appTmpPath);
//config -prop templates.dir=/root/templates then
Benchmark::mark("running CMD: {$cmd}");
passthru("{$cmd} 2>&1", $cmdStatus);
Benchmark::mark("CMD finished: exitCode={$cmdStatus}");
// import app
if ($cmdStatus == 0) {
    Benchmark::mark("importing {$appTmpPath} to {$appPath}");
    $importResults = Emergence_FS::importTree($appTmpPath, $appPath, array('exclude' => array("#^/{$framework}/#")));
    Benchmark::mark("imported files: " . http_build_query($importResults));
}
// get framework
if (empty($_REQUEST['framework'])) {
    die('Parameter framework required');
}
$framework = $_REQUEST['framework'];
Benchmark::mark("configured request: framework={$framework}");
// get temporary directory
$tmpPath = Emergence_FS::getTmpDir();
Benchmark::mark("created tmp: {$tmpPath}");
// write workspace
$workspacePath = 'sencha-workspace';
Benchmark::mark("precaching workspace: {$workspacePath}");
$cachedFiles = Emergence_FS::cacheTree($workspacePath);
Benchmark::mark("precaching finished: {$cachedFiles} files loaded/updated");
Benchmark::mark("exporting workspace: {$workspacePath} to {$tmpPath}");
$exportResult = Emergence_FS::exportTree($workspacePath, $tmpPath);
Benchmark::mark("exported finished: " . http_build_query($exportResult));
// begin cmd
set_time_limit(0);
$cmd = Sencha::buildCmd($framework, 'generate workspace', $tmpPath);
Benchmark::mark("running CMD: {$cmd}");
passthru($cmd, $cmdStatus);
Benchmark::mark("CMD finished: exitCode={$cmdStatus}");
// import app
if ($cmdStatus == 0) {
    $destPath = 'sencha-workspace';
    Benchmark::mark("importing to: {$destPath}");
    $filesImported = Emergence_FS::importTree($tmpPath, $destPath);
    Benchmark::mark("imported {$filesImported} files");
}
// clean up
示例#6
0
$classPaths = explode(',', $App->getBuildCfg('app.classpath'));
foreach ($classPaths as $classPath) {
    if (strpos($classPath, '${workspace.dir}/x/') === 0) {
        $extensionPath = substr($classPath, 19);
        $classPathSource = "ext-library/{$extensionPath}";
        $classPathDest = "{$tmpPath}/x/{$extensionPath}";
        Benchmark::mark("importing classPathSource: {$classPathSource}");
        #		$cachedFiles = Emergence_FS::cacheTree($classPathSource);
        #		Benchmark::mark("precached $cachedFiles files in $classPathSource");
        $sourceNode = Site::resolvePath($classPathSource);
        if (is_a($sourceNode, SiteFile)) {
            mkdir(dirname($classPathDest), 0777, true);
            copy($sourceNode->RealPath, $classPathDest);
            Benchmark::mark("copied file {$classPathSource} to {$classPathDest}");
        } else {
            $exportResult = Emergence_FS::exportTree($classPathSource, $classPathDest);
            Benchmark::mark("exported {$classPathSource} to {$classPathDest}: " . http_build_query($exportResult));
        }
    }
}
// generate docs
$cmd = "jsduck {$srcTmpPath}";
if ($guideJson) {
    $cmd .= " --guides {$appGuidesTmpPath}.json";
}
$cmd .= " --title=\"{$appName} Documentation\"";
$cmd .= " --warnings=-link,-extend,-type_name,+no_doc";
$cmd .= " --output {$docsTmpPath} 2>&1";
Benchmark::mark("running jsduck: {$cmd}");
passthru($cmd, $cmdStatus);
Benchmark::mark("CMD finished: exitCode={$cmdStatus}");
if (empty($_REQUEST['framework'])) {
    $framework = null;
} else {
    $framework = $_REQUEST['framework'];
}
Benchmark::mark("configured request: framework={$framework}");
// get temporary directory
$tmpPath = Emergence_FS::getTmpDir();
Benchmark::mark("created tmp: {$tmpPath}");
// write workspace
$workspacePath = 'sencha-workspace';
Benchmark::mark("precaching workspace: {$workspacePath}");
$cachedFiles = Emergence_FS::cacheTree($workspacePath);
Benchmark::mark("precaching finished: {$cachedFiles} files loaded/updated");
Benchmark::mark("exporting workspace: {$workspacePath}/.sencha to {$tmpPath}/.sencha");
$exportResult = Emergence_FS::exportTree("{$workspacePath}/.sencha", "{$tmpPath}/.sencha");
Benchmark::mark("exported finished: " . http_build_query($exportResult));
// delete old framework directory to force upgrade
exec("rm -R {$tmpPath}/{$framework}");
// begin cmd
set_time_limit(0);
$cmd = Sencha::buildCmd($framework, 'generate workspace', $tmpPath);
Benchmark::mark("running CMD: {$cmd}");
passthru($cmd, $cmdStatus);
Benchmark::mark("CMD finished: exitCode={$cmdStatus}");
// import app
if ($cmdStatus == 0) {
    $destPath = 'sencha-workspace';
    Benchmark::mark("importing to: {$destPath}");
    $filesImported = Emergence_FS::importTree($tmpPath, $destPath);
    Benchmark::mark("imported " . http_build_query($filesImported) . " files");
 public static function handleExportRequest()
 {
     // get repo
     if (empty($_REQUEST['repo'])) {
         die('Parameter "repo" required');
     }
     $repoName = $_REQUEST['repo'];
     if (!array_key_exists($repoName, Git::$repositories)) {
         die("Repo '{$repoName}' is not defined in Git::\$repositories");
     }
     $repoCfg = Git::$repositories[$repoName];
     $exportOptions = array('localOnly' => false);
     if (!empty($repoCfg['localOnly'])) {
         $exportOptions['localOnly'] = true;
     }
     // start the process
     set_time_limit(0);
     Benchmark::startLive();
     Benchmark::mark("configured request: repoName={$repoName}");
     // get paths
     $repoPath = "{$_SERVER['SITE_ROOT']}/site-data/git/{$repoName}";
     // check if there is an existing repo
     if (!is_dir("{$repoPath}/.git")) {
         die("{$repoPath} does not contain .git");
     }
     // get repo
     chdir($repoPath);
     // sync trees
     foreach ($repoCfg['trees'] as $srcPath => $treeOptions) {
         if (is_string($treeOptions)) {
             $treeOptions = array('path' => $treeOptions);
         }
         $treeOptions = array_merge($exportOptions, $treeOptions, ['dataPath' => false]);
         if (!is_string($srcPath)) {
             $srcPath = $treeOptions['path'];
         } elseif (!$treeOptions['path']) {
             $treeOptions['path'] = $srcPath;
         }
         $srcFileNode = Site::resolvePath($srcPath);
         if (is_a($srcFileNode, 'SiteFile')) {
             $destDir = dirname($treeOptions['path']);
             if ($destDir && !is_dir($destDir)) {
                 mkdir($destDir, 0777, true);
             }
             copy($srcFileNode->RealPath, $treeOptions['path']);
             Benchmark::mark("exported file {$srcPath} to {$treeOptions['path']}");
         } else {
             $exportResult = Emergence_FS::exportTree($srcPath, $treeOptions['path'], $treeOptions);
             Benchmark::mark("exported directory {$srcPath} to {$treeOptions['path']}: " . http_build_query($exportResult));
         }
     }
     Benchmark::mark("wrote all changes");
 }
示例#9
0
// get temporary directory and set paths
$tmpPath = Emergence_FS::getTmpDir();
$sassTmpPath = "{$tmpPath}/sass";
$imgTmpPath = "{$tmpPath}/img";
$fontsTmpPath = "{$tmpPath}/fonts";
$cssTmpPath = "{$tmpPath}/css";
Benchmark::mark("created tmp: {$tmpPath}");
// grab resources to work with
Emergence_FS::cacheTree($sassPath);
$exportResult = Emergence_FS::exportTree($sassPath, $sassTmpPath);
Benchmark::mark("exported {$sassPath} to {$sassTmpPath}: " . http_build_query($exportResult));
Emergence_FS::cacheTree($imgPath);
$exportResult = Emergence_FS::exportTree($imgPath, $imgTmpPath);
Benchmark::mark("exported {$imgPath} to {$imgTmpPath}: " . http_build_query($exportResult));
Emergence_FS::cacheTree($fontsPath);
$exportResult = Emergence_FS::exportTree($fontsPath, $fontsTmpPath);
Benchmark::mark("exported {$fontsPath} to {$fontsTmpPath}: " . http_build_query($exportResult));
// begin cmd
chdir($sassTmpPath);
Benchmark::mark("chdir to: {$sassTmpPath}");
$cmd = 'compass compile 2>&1';
Benchmark::mark("running CMD: {$cmd}");
passthru($cmd, $cmdStatus);
Benchmark::mark("CMD finished: exitCode={$cmdStatus}");
// import build
if ($cmdStatus == 0) {
    Benchmark::mark("importing {$cssTmpPath}");
    $importResults = Emergence_FS::importTree($cssTmpPath, "site-root/css", array('transferDelete' => false));
    Benchmark::mark("imported files: " . http_build_query($importResults));
}
// clean up
示例#10
0
// get requested test suite
$testSuite = empty($_GET['suite']) ? 'emergence.read-only' : $_GET['suite'];
// set paths
$testsPath = "phpunit-tests";
$suitePath = "{$testsPath}/{$testSuite}";
if (!Site::resolvePath($suitePath)) {
    die('Requested test suite not found');
}
// get temporary directory and set paths
$tmpPath = Emergence_FS::getTmpDir();
$suiteTmpPath = "{$tmpPath}/{$testSuite}";
$configTmpPath = "{$tmpPath}/phpunit.xml";
Benchmark::mark("created tmp: {$tmpPath}");
// export tests
Emergence_FS::cacheTree($suitePath);
$exportResult = Emergence_FS::exportTree($suitePath, $suiteTmpPath);
Benchmark::mark("exported {$suitePath} to {$suiteTmpPath}: " . http_build_query($exportResult));
// write phpunit configuration
$timezone = date_default_timezone_get();
// bootstrap path
$bootstrapPath = dirname($_SERVER['SCRIPT_FILENAME']) . '/phpunit.php';
file_put_contents($configTmpPath, <<<EOT
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit bootstrap="{$bootstrapPath}"
         convertErrorsToExceptions="false"
         convertNoticesToExceptions="false"
         convertWarningsToExceptions="false"
         stopOnError="false">
    <php>
        <ini name="date.timezone" value="{$timezone}" />
\t\t<server name="SITE_ROOT" value="{$_SERVER['SITE_ROOT']}" />