2016-07-01
@return \Composer\Composer
195797
private function composer() {
		if (!isset($this->{__METHOD__})) {
			/** @var ComposerFactory $factory */
			$factory = df_o(ComposerFactory::class);
			$this->{__METHOD__} = $factory->create();
		}
		return $this->{__METHOD__};
	}
933236
protected function setComposerJson() {
    if (file_exists($this->getConfigValue('repo.root') . '/composer.json')) {
      $composer_json = json_decode(file_get_contents($this->getConfigValue('repo.root') . '/composer.json'), TRUE);
      $this->composerJson = $composer_json;

      return $composer_json;
    }

    return [];
  }
183869
public function getVersion()
  {
    $composerJson = config('app.dir') . 'composer.json';

    if (file_exists($composerJson)) {
      $composer = json_decode(file_get_contents($composerJson, true));

      $version  = isset($composer->version) ? $composer->version : '1';
      $require  = isset($composer->require) ? (array)$composer->require : false;

      if (!is_array($require)) return "{$version} (1)";

      if (isset($require['modulusphp/framework'])) {
        return $version . " ({$require['modulusphp/framework']})";
      } else {
        return "{$version} (1)";
      }
    }

    return '1';
  }
528044
public function create()
    {
        return Merchant::content(function (Content $content) {
            $content->header(trans('merchant.permissions'));
            $content->description(trans('merchant.create'));
            $content->body($this->form());
        });
    }
543679
public function getPackages()
    {
        if ($this->packages === null) {
            $this->packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
            $this->packages[] = $this->composer->getPackage();
        }

        return $this->packages;
    }
874391
private static function getComposerHome(Composer $composer)
    {
        return null !== $composer->getConfig() && $composer->getConfig()->has('home')
            ? $composer->getConfig()->get('home')
            : '';
    }
1191393
public function getVersion()
    {
        $process = $this->getProcess();
        $processCommand = trim($this->findComposer() . ' --version');
        $process->setCommandLine($processCommand);
        $this->log->info('Running Composer command', ['command' => $processCommand]);
        $process->run();

        if ($process->isSuccessful() == false) {
            $composerError = remove_ansi($process->getErrorOutput());
            $this->log->error('Composer version process failure', ['composer' => $composerError]);
            throw new ComposerException('There was an error retrieving the Composer version');
        }

        return $process->getOutput();
    }
883400
public function build()
    {
        if ($this->constraints->count() == 1) {
            return $this->constraints->first();
        }

        return new Group($this->constraints);
    }
408205
public function get()
    {
        if (Cache::has($this->getCacheKey()))
            return Cache::get($this->getCacheKey());

        return $this->create();
    }
719590
public function getComposer()
    {
        $composerFile = new SplFileInfo($this->composer);
        if (false === $composerFile->isFile()) {
            $message = sprintf('Composer binary not found at "%s"', $composerFile);
            $this->log($message, Project::MSG_WARN);
            $composerLocation = FileSystem::getFileSystem()->which('composer');
            if (!empty($composerLocation)) {
                $message = sprintf('Composer binary found at "%s", updating location', $composerLocation[0]);
                $this->log($message, Project::MSG_INFO);
                $this->setComposer($composerLocation);
            }
        }
        return $this->composer;
    }
1285449
protected function response()
    {
        if ( $this->responseObject ) {
            return $this->responseObject;
        }
        $this->responseObject = new Response;

        return $this->responseObject;
    }
348535
function () {
      var isNewProject = (this.composerOrig == undefined);
      if (!isNewProject) {
        // Use original composer file if project already generated.
        this.composer = this.composerOrig;
      }

      this.composer.name = 'organization/' + options.projectName;
      this.composer.description = options.projectDescription;
      // Allow distros to modify the composer.json.
      if (typeof options.drupalDistro.modifyComposer == 'function') {
        var done = this.async();
        options.drupalDistro.modifyComposer(options, this.composer, isNewProject, done, function(err, result, done) {
          if (!err && result) {
            this.composer = result;
          }
          else {
            this.log.warning("Could not retrieve Octane's composer.json: "  + err);
            return done(err);
          }
          done();
        }.bind(this));
      }
    }
864455
protected function getComposer()
    {
        if (!$this->composer) {
            // Set composer environment variables
            putenv('COMPOSER_HOME=' . $this->app['path_resolver']->resolve('%cache%/composer'));

            // Set working directory
            chdir($this->getOptions()->baseDir());

            try {
                // Use the factory to get a new Composer object
                $this->composer = Factory::create($this->getIO(), $this->getOptions()->composerJson()->getPath(), false);
            } catch (\InvalidArgumentException $e) {
                throw new PackageManagerException($e->getMessage(), $e->getCode(), $e);
            } catch (\Exception $e) {
                $this->app['logger.system']->critical($e->getMessage(), ['event' => 'exception', 'exception' => $e]);
                throw $e;
            }

            // Add the event subscriber
            $this->composer->getEventDispatcher()->addSubscriber($this->app['extend.listener']);

            if (!$this->app['extend.manager']->useSsl()) {
                $this->setAllowSslDowngrade(true);
            }
        }

        return $this->composer;
    }
1192158
private function getComposer(): string
	{
		$composer = $this->tempDir . $this->composer;

		$temp = $this->tempDir . $this->composerDir;
		if (!file_exists($temp)) {
			mkdir($temp);
		}

		$home = 'COMPOSER_HOME="' . $temp . '" ';

		if (!file_exists($composer)) {
			$expectedSignature = trim(file_get_contents('https://composer.github.io/installer.sig'));
			copy('https://getcomposer.org/installer', $this->tempDir . '/composer-setup.php');
			$actualSignature = hash_file('SHA384', $this->tempDir . '/composer-setup.php');
			if ($expectedSignature === $actualSignature) {
				$command = 'cd ' . $this->tempDir . ';'
					. $home . 'php composer-setup.php;';
				exec($command, $output);
				foreach ($output as $str) {
					if (!empty($str)) {
						Debugger::log($str, 'composer');
					}
				}
				unlink($this->tempDir . '/composer-setup.php');
			} else {
				Debugger::log('Invalid installer signature', 'composer');
			}
		}
		return $home . $composer;
	}
850399
protected function updateComposerConfig()
    {
        parent::updateComposerConfig();
        $this->composerManager->updateProjectConfig(array(
            'name' => $this->composerManager->createPackageName($this->projectName),
            'license' => 'proprietary',
            'description' => null,
            'extra' => array('branch-alias' => null),
        ));

        return $this;
    }
166770
public function execute() {
        $this->log
            ->printAsOutput()
            ->info(
                '%s %s',
                $this->config['composer']['extra']['name'],
                $this->config['composer']['extra']['version']
            );

        return $this;
    }
369178
protected function _packages()
    {
        $installed = static::cache('_composerPackages');
        if (is_array($installed)) {
            return $installed;
        }

        $jsonPath = VENDOR_INCLUDE_PATH . 'composer/installed.json';
        $installed = [];

        if (is_readable($jsonPath)) {
            $json = (array)json_decode(file_get_contents($jsonPath), true);
            foreach ($json as $pkg) {
                $installed[$pkg['name']] = [
                    'name' => $pkg['name'],
                    'version' => $pkg['version'],
                    'version_normalized' => $pkg['version_normalized'],
                ];
            }
        }

        return static::cache('_composerPackages', $installed);
    }