Exemplo n.º 1
0
if (!class_exists('jCoordinator', false)) {
    // for old application.init.php which doesn't include init.php
    echo "Error: your application.init.php should include the vendor/autoload.php";
    exit(1);
}
if (!\jServer::isCLI()) {
    echo "Error: you're not allowed to execute this script outside a command line shell.\n";
    exit(1);
}
if (!\Jelix\Core\App::isInit()) {
    echo "Error: should run within an application\n";
    exit(1);
}
\Jelix\Core\App::setEnv('jelix-scripts');
\Jelix\DevHelper\JelixScript::checkTempPath();
$jelixScriptConfig = \Jelix\DevHelper\JelixScript::loadConfig();
$application = new Application("Jelix helpers");
$application->add(new InstallApp($jelixScriptConfig));
$application->add(new InstallModule($jelixScriptConfig));
$application->add(new UninstallModule($jelixScriptConfig));
$application->add(new InitAdmin($jelixScriptConfig));
$application->add(new CreateCtrl($jelixScriptConfig));
$application->add(new CreateDao($jelixScriptConfig));
$application->add(new CreateDaoCrud($jelixScriptConfig));
$application->add(new CreateClassFromDao($jelixScriptConfig));
$application->add(new CreateModule($jelixScriptConfig));
$application->add(new CreateEntryPoint($jelixScriptConfig));
$application->add(new CreateForm($jelixScriptConfig));
$application->add(new CreateLangPackage($jelixScriptConfig));
$application->add(new CreateZone($jelixScriptConfig));
$application->add(new ClearTemp($jelixScriptConfig));
Exemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $appPath = $input->getArgument('path');
     $appPath = Path::normalizePath($appPath, 0, getcwd());
     $appName = basename($appPath);
     $appPath .= '/';
     if (file_exists($appPath . '/jelix-app.json') || file_exists($appPath . '/project.xml')) {
         throw new \Exception("this application is already created");
     }
     $this->prepareSubCommandApp($appName, $appPath);
     App::setEnv('jelix-scripts');
     \Jelix\DevHelper\JelixScript::checkTempPath();
     if ($p = $input->getOption('wwwpath')) {
         $wwwpath = Path::shortestPath($appPath, $p) . '/';
     } else {
         $wwwpath = App::wwwPath();
     }
     if ($output->isVerbose()) {
         $output->writeln("Create directories and files at {$appPath}");
     }
     $param = $this->_createSkeleton($appPath, $appName, $wwwpath, $input);
     App::declareModulesDir(array($appPath . '/modules/'));
     $installer = new \Jelix\Installer\Installer(new \Jelix\Installer\Reporter\Console($output->isVerbose() ? 'notice' : 'warning'));
     $installer->installApplication();
     $moduleok = true;
     if (!$input->getOption('nodefaultmodule')) {
         try {
             if ($output->isVerbose()) {
                 $output->writeln("Create default module " . $param['modulename']);
             }
             $options = array('module' => $param['modulename'], '--addinstallzone' => true, '--noregistration' => true);
             if ($output->isVerbose()) {
                 $options['-v'] = true;
             }
             $this->executeSubCommand('module:create', $options, $output);
             if ($output->isVerbose()) {
                 $output->writeln("Create main template");
             }
             $this->createFile($appPath . 'modules/' . $param['modulename'] . '/templates/main.tpl', 'module/main.tpl.tpl', $param, "Main template");
         } catch (\Exception $e) {
             $moduleok = false;
             $output->writeln("<error>The module has not been created because of this error: " . $e->getMessage() . "</error>");
             $output->writeln("However the application has been created");
         }
     }
     if ($input->getOption('withcmdline')) {
         if (!$input->getOption('nodefaultmodule') && $moduleok) {
             if ($output->isVerbose()) {
                 $output->writeln("Create a controller in the default module for the cli script");
             }
             $options = array('module' => $param['modulename'], 'controller' => 'default', 'method' => 'index', '--cmdline' => true);
             if ($output->isVerbose()) {
                 $options['-v'] = true;
             }
             $this->executeSubCommand('module:createctrl', $options, $output);
         }
         if ($output->isVerbose()) {
             $output->writeln("Create the cli script");
         }
         $options = array('entrypoint' => $param['modulename'], '--type' => 'cmdline');
         if ($output->isVerbose()) {
             $options['-v'] = true;
         }
         $this->executeSubCommand('app:createentrypoint', $options, $output);
     }
 }