Skip to content

Commit 48db514

Browse files
authored
Merge pull request #48 from statamic/fix/overzealous-github-auth-check
2 parents 7879fb3 + 8fd15eb commit 48db514

1 file changed

Lines changed: 0 additions & 66 deletions

File tree

src/NewCommand.php

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class NewCommand extends Command
3232
public $name;
3333
public $version;
3434
public $starterKit;
35-
public $starterKitVcs;
3635
public $starterKitLicense;
3736
public $local;
3837
public $withConfig;
@@ -88,8 +87,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
8887

8988
$this
9089
->askForRepo()
91-
->detectRepoVcs()
92-
->detectMissingVcsAuth()
9390
->validateStarterKitLicense()
9491
->installBaseProject()
9592
->installStarterKit()
@@ -278,54 +275,6 @@ protected function askForRepo()
278275
return $this;
279276
}
280277

281-
/**
282-
* Detect starter kit repo vcs, using same precedence logic used in statamic/cms.
283-
*
284-
* @return $this
285-
*/
286-
protected function detectRepoVcs()
287-
{
288-
if ($this->local) {
289-
return $this;
290-
}
291-
292-
$request = new Client(['http_errors' => false]);
293-
294-
if ($request->get("https://repo.packagist.org/p2/{$this->starterKit}.json")->getStatusCode() === 200) {
295-
return $this;
296-
}
297-
298-
if ($request->get("https://github.com/{$this->starterKit}")->getStatusCode() === 200) {
299-
$this->starterKitVcs = 'github';
300-
} elseif ($request->get($bitbucketUrl = "https://bitbucket.org/{$this->starterKit}.git")->getStatusCode() === 200) {
301-
$this->starterKitVcs = 'bitbucket';
302-
} elseif ($request->get($gitlabUrl = "https://gitlab.com/{$this->starterKit}")->getStatusCode() === 200) {
303-
$this->starterKitVcs = 'gitlab';
304-
}
305-
306-
return $this;
307-
}
308-
309-
/**
310-
* Detect missing starter kit repo vcs auth, and prompt user to properly authenticate.
311-
*
312-
* @return $this
313-
*/
314-
protected function detectMissingVcsAuth()
315-
{
316-
if ($this->starterKitVcs === 'github' && $this->hasMissingComposerToken('github-oauth.github.com')) {
317-
$this->output->write(PHP_EOL);
318-
$this->output->write('<error>Composer could not authenticate with GitHub!</error>'.PHP_EOL);
319-
$this->output->write('<comment>Please generate a personal access token at: https://github.com/settings/tokens/new</comment>'.PHP_EOL);
320-
$this->output->write('<comment>Then save your token for future use by running the following command:</comment>'.PHP_EOL);
321-
$this->output->write('<comment>composer config --global --auth github-oauth.github.com [your-token-here]</comment>'.PHP_EOL);
322-
323-
return $this->exitInstallation();
324-
}
325-
326-
return $this;
327-
}
328-
329278
/**
330279
* Validate starter kit license.
331280
*
@@ -816,21 +765,6 @@ protected function getStarterKitLicense()
816765
return $license;
817766
}
818767

819-
/**
820-
* Check if user has missing composer token.
821-
*
822-
* @param string $tokenKey
823-
* @return bool
824-
*/
825-
protected function hasMissingComposerToken($tokenKey)
826-
{
827-
$composer = $this->findComposer();
828-
829-
return ! $this
830-
->runCommand("{$composer} config --global --auth {$tokenKey}", true)
831-
->isSuccessful();
832-
}
833-
834768
/**
835769
* Exit installation.
836770
*

0 commit comments

Comments
 (0)