Esempio n. 1
0
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));
// clean up
if (empty($_GET['leaveWorkspace'])) {
    exec("rm -R {$tmpPath}");
    Benchmark::mark("erased {$tmpPath}");
}
Esempio n. 2
0
    } elseif (!$treeOptions['path']) {
        $treeOptions['path'] = $srcPath;
    }
    $treeOptions['exclude'][] = '#(^|/)\\.git(/|$)#';
    if (is_file($treeOptions['path'])) {
        $sha1 = sha1_file($treeOptions['path']);
        $existingNode = Site::resolvePath($srcPath);
        if (!$existingNode || $existingNode->SHA1 != $sha1) {
            $fileRecord = SiteFile::createFromPath($srcPath, null, $existingNode ? $existingNode->ID : null);
            SiteFile::saveRecordData($fileRecord, fopen($treeOptions['path'], 'r'), $sha1);
            Benchmark::mark("importing file {$srcPath} from {$treeOptions['path']}");
        } else {
            Benchmark::mark("skipped unchanged file {$srcPath} from {$treeOptions['path']}");
        }
    } else {
        $cachedFiles = Emergence_FS::cacheTree($srcPath);
        Benchmark::mark("precached {$srcPath}: " . $cachedFiles);
        $exportResult = Emergence_FS::importTree($treeOptions['path'], $srcPath, $treeOptions);
        Benchmark::mark("importing directory {$srcPath} from {$treeOptions['path']}: " . http_build_query($exportResult));
    }
}
// commit changes
#$repo->git('add --all');
#
#$repo->git(sprintf(
#	'commit -n -m "%s" --author="%s <%s>"'
#	,addslashes($_POST['message'])
#	,$GLOBALS['Session']->Person->FullName
#	,$GLOBALS['Session']->Person->Email
#));
#Benchmark::mark("committed all changes");
    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
exec("rm -R {$tmpPath}");
Benchmark::mark("erased {$tmpPath}");
Esempio n. 4
0
    }
}
// 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
if ($cmdStatus == 0) {
    Benchmark::mark("importing {$buildTmpPath}/resources to {$buildPath}/resources");
    $importResults = Emergence_FS::importTree("{$buildTmpPath}/resources", "{$buildPath}/resources", array('exclude' => $defaultExclude));
    Benchmark::mark("imported files: " . http_build_query($importResults));
}
// clean up
if (empty($_GET['leaveWorkspace'])) {
    exec("rm -R {$tmpPath}");
    Benchmark::mark("erased {$tmpPath}");
}
Esempio n. 5
0
    exec($cmd);
    header('Content-Type: application/x-bzip-compressed-tar');
    header('Content-Disposition: attachment; filename="' . $appName . '.' . date('Y-m-d') . '.tbz"');
    chdir($tmpPath);
    passthru("tar -cjf - ./");
    exec("rm -R {$tmpPath}");
    exit;
} else {
    passthru("{$cmd} 2>&1", $cmdStatus);
}
Benchmark::mark("CMD finished: exitCode={$cmdStatus}");
// import build
if ($cmdStatus == 0) {
    Benchmark::mark("importing {$buildTmpPath}");
    $importResults = Emergence_FS::importTree($buildTmpPath, "sencha-build/{$appName}/{$buildType}", array('exclude' => $defaultExclude));
    Benchmark::mark("imported files: " . http_build_query($importResults));
    if ($framework == 'ext') {
        Emergence_FS::importFile("{$appTmpPath}/bootstrap.js", "{$appPath}/bootstrap.js");
        Benchmark::mark("imported bootstrap.js");
    }
    if (!empty($_GET['archive'])) {
        Benchmark::mark("importing {$archiveTmpPath} to {$archivePath}");
        $importResults = Emergence_FS::importTree($archiveTmpPath, $archivePath);
        Benchmark::mark("imported files: " . http_build_query($importResults));
    }
}
// clean up
if (empty($_GET['leaveWorkspace'])) {
    exec("rm -R {$tmpPath}");
    Benchmark::mark("erased {$tmpPath}");
}
Esempio n. 6
0
$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));
}
// clean up
if (empty($_GET['leaveWorkspace'])) {
    exec("rm -R {$tmpPath}");
    Benchmark::mark("erased {$tmpPath}");
}
Esempio n. 7
0
            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}");
// import build
if ($cmdStatus == 0) {
    $buildTmpPath = "{$tmpPath}/build";
    Benchmark::mark("importing {$docsTmpPath} to {$docsPath}");
    $importResults = Emergence_FS::importTree($docsTmpPath, $docsPath);
    Benchmark::mark("imported files: " . http_build_query($importResults));
}
// clean up
if (empty($_GET['leaveWorkspace'])) {
    exec("rm -R {$tmpPath}");
    Benchmark::mark("erased {$tmpPath}");
}
 public static function handleImportRequest()
 {
     // 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];
     // 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);
         }
         if (!is_string($srcPath)) {
             $srcPath = $treeOptions['path'];
         } elseif (!$treeOptions['path']) {
             $treeOptions['path'] = $srcPath;
         }
         if (is_string($treeOptions['exclude'])) {
             $treeOptions['exclude'] = array($treeOptions['exclude']);
         }
         $treeOptions['exclude'][] = '#(^|/)\\.git(/|$)#';
         $treeOptions['dataPath'] = false;
         try {
             if (is_file($treeOptions['path'])) {
                 $sha1 = sha1_file($treeOptions['path']);
                 $existingNode = Site::resolvePath($srcPath);
                 if (!$existingNode || $existingNode->SHA1 != $sha1) {
                     $fileRecord = SiteFile::createFromPath($srcPath, null, $existingNode ? $existingNode->ID : null);
                     SiteFile::saveRecordData($fileRecord, fopen($treeOptions['path'], 'r'), $sha1);
                     Benchmark::mark("importing file {$srcPath} from {$treeOptions['path']}");
                 } else {
                     Benchmark::mark("skipped unchanged file {$srcPath} from {$treeOptions['path']}");
                 }
             } else {
                 $exportResult = Emergence_FS::importTree($treeOptions['path'], $srcPath, $treeOptions);
                 Benchmark::mark("importing directory {$srcPath} from {$treeOptions['path']}: " . http_build_query($exportResult));
             }
         } catch (Exception $e) {
             Benchmark::mark("failed to import directory {$srcPath} from {$treeOptions['path']}: " . $e->getMessage());
         }
     }
 }
Esempio n. 9
0
$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
if (empty($_GET['leaveWorkspace'])) {
    exec("rm -R {$tmpPath}");
    Benchmark::mark("erased {$tmpPath}");
}