(internal) Prepares a repo that is adding BLT for the first time.

@command internal:add-to-project

@return void

@hidden
438483
public function addToProject() {
    $this->initializeBlt();
    $this->displayArt();
    $this->yell("BLT has been added to your project.");
    $this->say("This required a full `composer update`.");
    $this->say("BLT has added and modified various project files.");
    $this->say("Please inspect your repository.");
  }
432011
public function createFromBltProject($options = [
    'base-branch' => self::BLT_DEV_BRANCH,
    'project-dir' => self::BLT_PROJECT_DIR,
  ]) {
    $test_project_dir = $this->bltRoot . "/" . $options['project-dir'];
    $this->prepareTestProjectDir($test_project_dir);
    $this->yell("Creating project from acquia/blt-project:{$options['base-branch']}-dev.");
    $return = $this->taskExecStack()
      ->dir($this->bltRoot . "/..")
      ->exec("COMPOSER_PROCESS_TIMEOUT=2000 composer create-project acquia/blt-project:{$options['base-branch']}-dev blted8 --no-interaction")
      ->run();

    return $return;
  }
1011979
protected function addProjectIniReport()
    {
        $h3     = $this->html->h3();
        $issues = false;
        if (! $this->project->offsetExists('headers')) {
            $this->html->pInfo('No headers section found.');
            $issues = true;
        }
        if (!$this->project->offsetExists('meta')) {
            $this->html->pInfo('No meta headers section found.');
            $issues = true;
        } else {
            if (isset($this->project['meta']['Content-Security-Policy'])) {
                $this->html->pInfo('meta.Content-Security-Policy should be moved to headers section');
                $issues = true;
            }
            if (isset($this->project['meta']['Strict-Transport-Security'])) {
                $this->html->pInfo('meta.Strict-Transport-Security should be moved to headers section');
                $issues = true;
            }
        }

        if (isset($this->project['headers']['Content-Security-Policy']) &&
                preg_match('/img-src\s.*?data:.*?;/', $this->project['headers']['Content-Security-Policy']) !== 1) {
            $this->html->pInfo('The headers.Content-Security-Policy setting img-src should have data: for Two Factor Authentication.');
            $issues = true;
        }
        if ($this->project->offsetExists('jquerycss')) {
            $this->html->pInfo('Separate JQuery CSS no longer in use. Remove jquerycss setting.');
            $issues = true;
        }

        if (! isset($this->project['security'], $this->project['security']['methods'])) {
            $this->html->pInfo('No OpenSSL cipher methods defined in security.methods.');
            $issues = true;
        }

        if ($issues) {
            $h3->append('Project.ini issues found');
            $this->html->pInfo()->strong('See project.example.ini for examples of fixes.');
        } else {
            $h3->append('Project.ini report');
            $this->html->pInfo('No compatibility issues found in project.ini.');
        }
    }
1253366
public function prepare()
  {
    $initFile=$this->basePath . DIRECTORY_SEPARATOR . $this->initScript;

    $this->checkIntegrity(false); //not supported in sqlite

    if(is_file($initFile))
      require($initFile);
    else
    {
      foreach($this->getFixtures() as $tableName=>$fixturePath)
      {
        $this->resetTable($tableName);
        $this->loadFixture($tableName);
      }
    }
    $this->checkIntegrity(true); //not supported in sqlite
  }
37721
protected function installDone()
    {
        $this->nl();
        if ($this->seemsFine) {
            $this->output->writeLn("========================================================================");
            $this->nl();
            $this->output->writeLn("                      Repair completed!");
            $this->nl();
            $this->output->writeLn("========================================================================");
        } else {
            $this->output->writeLn("Automatic installation failed to complete cleanly.");
            $this->output->writeLn("Head over to https://github.com/strata-mvc/strata/ to get help.");
        }
        $this->nl();
    }
164083
public function beforeCompile(): void
	{
		// Skip if it's not CLI mode
		if (!$this->cliMode) return;

		$builder = $this->getContainerBuilder();

		// Lookup for Symfony Console Application
		$application = $builder->getDefinitionByType('Symfony\Component\Console\Application');

		// Register helpers
		$connectionHelper = $this->prefix('@connectionHelper');
		$application->addSetup(new Statement('$service->getHelperSet()->set(?, ?)', [$connectionHelper, 'db']));
	}
615628
public function initialize() {
    $this->excludeFileTemp = $this->getConfigValue('deploy.exclude_file') . '.tmp';
    $this->deployDir = $this->getConfigValue('deploy.dir');
    $this->tagSource = $this->getConfigValue('deploy.tag_source', TRUE);
  }
19253
public function init()
    {
        $paths = Phing::explodeIncludePath();
        foreach ($paths as $path) {
            if (file_exists($path . DIRECTORY_SEPARATOR . 'Net' . DIRECTORY_SEPARATOR . 'FTP.php')) {
                return true;
            }
        }
        throw new BuildException('The FTP Deploy task requires the Net_FTP PEAR package.');
    }
351358
def create_new(projectname):
    """"""
    git_url = "https://github.com/moluwole/Bast_skeleton"
    path = os.path.abspath('.') + "/" + projectname
    if not os.path.exists(path):
        os.makedirs(path)

    click.echo(Fore.GREEN + '    ___  ___   __________')
    click.echo(Fore.GREEN + '  / _ )/ _ | / __/_  __/')
    click.echo(Fore.GREEN + ' / _  / __ |_\ \  / /')
    click.echo(Fore.GREEN + '/____/_/ |_/___/ /_/')

    click.echo(Fore.GREEN + "Creating Project at %s.... " % path)
    click.echo(Fore.GREEN + "Pulling Project Skeleton from Repo")
    try:
        Repo.clone_from(git_url, path)

        click.echo(Fore.GREEN + "Setting up project")

        shutil.rmtree(path + "/.git")

        if not os.path.exists('/.env'):
            shutil.copy(path + '/.env.example', path + '/.env')

        env_file = path + "/.env"
        if not os.path.isfile(env_file):
            shutil.copy('.env.example', '.env')
        call(['panther', 'generate:key', path])

        click.echo(Fore.GREEN + "New Bast Project created at  %s " % path)
    except Exception as e:
        click.echo(Fore.RED + "An error occurred creating a new project. Try Again.\n Reason: {}".format(e))
1365171
private function initialize()
    {
        // get parameters
        $params = $this->getParameters();
        if ($params !== null) {
            /**
             * @var Parameter $param
             */
            foreach ($params as $param) {
                if ('prepend' === $param->getName()) {
                    $this->setPrepend(new PhingFile($param->getValue()));
                    continue;
                }
                if ('append' === $param->getName()) {
                    $this->setAppend(new PhingFile($param->getValue()));
                    continue;
                }
            }
        }
        if ($this->prepend !== null) {
            if (!$this->prepend->isAbsolute()) {
                $this->prepend = new PhingFile($this->getProject()->getBasedir(), $this->prepend->getPath());
            }
            $this->prependReader = new BufferedReader(new FileReader($this->prepend));
        }
        if ($this->append !== null) {
            if (!$this->append->isAbsolute()) {
                $this->append = new PhingFile($this->getProject()->getBasedir(), $this->append->getPath());
            }
            $this->appendReader = new BufferedReader(new FileReader($this->append));
        }
    }
1260218
public function projectSetupBehat() {
    $tokens = $this->config('behat.tokens');
    $this->collectionBuilder()->addTaskList([
      $this->taskFilesystemStack()->copy($this->config('behat.source'), $this->config('behat.destination'), TRUE),
      $this->taskReplaceInFile($this->config('behat.destination'))->from(array_keys($tokens))->to($tokens),
    ])->run();
  }
785288
protected function executeBltUpdate($version) {
    $options = $this->getOptions();

    if ($this->isInitialInstall()) {
      $this->io->write('<info>Creating BLT templated files...</info>');
      if ($this->isNewProject()) {
        // The BLT command will not work at this point because the .git dir doesn't exist yet.
        $command = $this->getVendorPath() . '/acquia/blt/bin/blt internal:create-project --ansi';
      }
      else {
        $command = $this->getVendorPath() . '/acquia/blt/bin/blt internal:add-to-project --ansi -n';
      }
      $success = $this->executeCommand($command, [], TRUE);
      if (!$success) {
        $this->io->writeError("<error>BLT installation failed! Please execute <comment>$command --verbose</comment> to debug the issue.</error>");
        throw new \Exception('Installation aborted due to error');
      }
    }
    elseif ($options['blt']['update']) {
      $this->io->write('<info>Updating BLT templated files...</info>');
      $success = $this->executeCommand('blt blt:update --ansi --no-interaction', [], TRUE);
      if (!$success) {
        $this->io->writeError("<error>BLT update script failed! Run `blt blt:update --verbose` to retry.</error>");
      }
    }
    else {
      $this->io->write('<comment>Skipping update of BLT templated files</comment>');
    }
  }
736001
public function travisInit() {
    $result = $this->taskFilesystemStack()
      ->copy($this->getConfigValue('blt.root') . '/scripts/travis/.travis.yml', $this->getConfigValue('repo.root') . '/.travis.yml', TRUE)
      ->stopOnFail()
      ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
      ->run();

    if (!$result->wasSuccessful()) {
      throw new BltException("Could not initialize Travis CI configuration.");
    }

    $this->say("<info>A pre-configured .travis.yml file was copied to your repository root.</info>");
  }
770604
public function subsplitInit()
    {
        $remote = $this->getRemote();
        $cmd = $this->client->getCommand('subsplit');
        $this->log('running git-subsplit init ' . $remote);

        $cmd->setArguments(array(
            'init',
            $remote
        ));

        try {
            $output = $cmd->execute();
        } catch (Exception $e) {
            throw new BuildException('git subsplit init failed'. $e);
        }
        $this->log(trim($output), Project::MSG_INFO);
        $repo = $this->getRepository();
        chdir($repo . '/.subsplit');
        passthru('php ../composer.phar install --dev');
        chdir($repo);
    }
999377
public function runBuild()
    {
        if (!$this->readyToRun) {
            return;
        }

        $project = new Project();

        self::setCurrentProject($project);
        set_error_handler(['Phing', 'handlePhpError']);

        $error = null;

        $this->addBuildListeners($project);
        $this->addInputHandler($project);

        // set this right away, so that it can be used in logging.
        $project->setUserProperty("phing.file", $this->buildFile->getAbsolutePath());
        $project->setUserProperty("phing.dir", dirname($this->buildFile->getAbsolutePath()));

        try {
            $project->fireBuildStarted();
            $project->init();
        } catch (Exception $exc) {
            $project->fireBuildFinished($exc);
            throw $exc;
        }

        $project->setKeepGoingMode($this->keepGoingMode);

        $project->setUserProperty("phing.version", static::getPhingVersion());

        $e = self::$definedProps->keys();
        while (count($e)) {
            $arg = (string) array_shift($e);
            $value = (string) self::$definedProps->getProperty($arg);
            $project->setUserProperty($arg, $value);
        }
        unset($e);

        $project->setUserProperty("phing.file", $this->buildFile->getAbsolutePath());

        // first use the Configurator to create the project object
        // from the given build file.

        try {
            ProjectConfigurator::configureProject($project, $this->buildFile);
        } catch (Exception $exc) {
            $project->fireBuildFinished($exc);
            restore_error_handler();
            self::unsetCurrentProject();
            throw $exc;
        }

        // Set the project mode
        $project->setStrictMode(StringHelper::booleanValue($this->strictMode));

        // make sure that we have a target to execute
        if (count($this->targets) === 0) {
            $this->targets[] = $project->getDefaultTarget();
        }

        // make sure that minimum required phing version is satisfied
        try {
            $this->comparePhingVersion($project->getPhingVersion());
        } catch (Exception $exc) {
            $project->fireBuildFinished($exc);
            restore_error_handler();
            self::unsetCurrentProject();
            throw $exc;
        }

        // execute targets if help param was not given
        if (!$this->projectHelp) {
            try {
                $project->executeTargets($this->targets);
            } catch (Exception $exc) {
                $project->fireBuildFinished($exc);
                restore_error_handler();
                self::unsetCurrentProject();
                throw $exc;
            }
        }
        // if help is requested print it
        if ($this->projectHelp) {
            try {
                $this->printDescription($project);
                $this->printTargets($project);
            } catch (Exception $exc) {
                $project->fireBuildFinished($exc);
                restore_error_handler();
                self::unsetCurrentProject();
                throw $exc;
            }
        }

        // finally {
        if (!$this->projectHelp) {
            $project->fireBuildFinished(null);
        }

        restore_error_handler();
        self::unsetCurrentProject();
    }
1134443
protected function initializeBlt() {
    $this->updateRootProjectFiles();
    $this->taskExecStack()
      ->dir($this->getConfigValue("repo.root"))
      ->exec("composer drupal:scaffold")
      ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
      ->run();

    // Reinitialize configuration now that project files exist.
    $config_initializer = new ConfigInitializer($this->getConfigValue('repo.root'), $this->input());
    $new_config = $config_initializer->initialize();
    $this->getConfig()->import($new_config->export());

    $this->invokeCommand('blt:init:settings');
    $this->invokeCommand('recipes:blt:init:command');
    $this->invokeCommand('blt:init:shell-alias');
    if (DIRECTORY_SEPARATOR === '\\') {
      // On Windows, during composer create-project,
      // the wizard command fails when it reaches the interactive steps.
      // Until this is fixed, go with the defaults.
      // The user can run blt wizard any time later for changing defaults.
      $this->input()->setInteractive(FALSE);
    }
    if ($this->input()->isInteractive()) {
      $this->invokeCommand('wizard');
    }
  }
113624
def init(name, subnames, dest, skeleton, description, project_type, skip_core):
    """"""
    dest = dest or CUR_DIR
    skeleton = join(skeleton or SKEL_PATH, project_type)
    project = join(dest, name)
    script = join(project, name + '.py')
    core = join(project, name)
    if project_type == 'standalone':
        renames = [
            (join(project, 'project.py'), script),
            (join(project, 'project'), core)]
        copy_skeleton(
            name, skeleton, project, renames=renames, description=description,
            ignore=False)
    else:
        renames = [
            (join(project, 'project.py'), script),
            (join(project, 'project'), core)]
        exclude_dirs = ['submodule'] + (['project'] if skip_core else [])
        copy_skeleton(
            name, skeleton, project, renames=renames, description=description,
            exclude_dirs=exclude_dirs, ignore=True)
        for subname in subnames:
            renames = [
                (join(project, 'submodule'), join(project, subname))
            ]
            copy_skeleton(
                subname, skeleton, project, renames=renames,
                description=description, ignore=True,
                exclude_dirs=['project'], exclude_files=['project.py'])
    return 0, "\n{}\n".format(project)