diff --git a/src/Config.php b/src/Config.php new file mode 100644 index 0000000..82810a5 --- /dev/null +++ b/src/Config.php @@ -0,0 +1,52 @@ + $value]); + + if (! is_dir($dir = dirname($path))) { + @mkdir($dir, 0755, true); + } + + @file_put_contents($path, json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES).PHP_EOL); + } + + public static function all() + { + if (! ($path = static::path()) || ! is_file($path)) { + return []; + } + + $config = json_decode(@file_get_contents($path), true); + + return is_array($config) ? $config : []; + } + + public static function path() + { + if (PHP_OS_FAMILY === 'Windows') { + $base = getenv('APPDATA') ?: null; + } elseif ($xdg = getenv('XDG_CONFIG_HOME')) { + $base = $xdg; + } elseif ($home = getenv('HOME')) { + $base = $home.'/.config'; + } else { + return null; + } + + return $base ? $base.DIRECTORY_SEPARATOR.'statamic'.DIRECTORY_SEPARATOR.'cli.json' : null; + } +} diff --git a/src/NewCommand.php b/src/NewCommand.php index e2483a6..154400b 100644 --- a/src/NewCommand.php +++ b/src/NewCommand.php @@ -1124,15 +1124,24 @@ protected function showPostInstallInstructions() */ protected function askToSpreadJoy() { - if (! $this->input->isInteractive()) { + if (! $this->input->isInteractive() || Config::get('starred')) { return $this; } $response = select('Would you like to spread the joy of Statamic by starring the repo?', [ $yes = 'Absolutely', $no = 'Maybe later', + $already = "I've already starred it", ], $no); + if ($response === $already) { + Config::set('starred', true); + + $this->output->write(" Thank you! We almost definitely won't ask you next time.".PHP_EOL.PHP_EOL); + + return $this; + } + if ($response === $yes) { if (PHP_OS_FAMILY == 'Darwin') { exec('open https://github.com/statamic/cms');