From 1f088d1c4a6b0ed720d519c7e382d7ddea6419f2 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Fri, 9 Oct 2026 17:11:06 -0400 Subject: [PATCH] Add option to skip star prompt if already starred Remembers the choice in a cli.json config file so the prompt isn't shown again. Co-Authored-By: Claude Opus 5.5 --- src/Config.php | 52 ++++++++++++++++++++++++++++++++++++++++++++++ src/NewCommand.php | 11 +++++++++- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/Config.php 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');