diff --git a/app/Middleware/AnnouncesAbandonment.php b/app/Middleware/AnnouncesAbandonment.php new file mode 100644 index 00000000..f6130437 --- /dev/null +++ b/app/Middleware/AnnouncesAbandonment.php @@ -0,0 +1,35 @@ +laravel/cloud-cli is abandoned and will no longer receive updates. + Install its replacement with npm install -g @laravel/cloud-cli or brew install laravel/tap/cloud. + Your saved tokens carry over. Learn more: https://www.npmjs.com/package/@laravel/cloud-cli + + TXT; + + public function handle($command, callable $next) + { + // JSON errors go to stderr, so the notice would corrupt them for machine readers. + if (! $this->isInternalCommand($command) && ! Renderer::$suppressOutput) { + $this->output()->writeln(self::MESSAGE); + } + + return $next(); + } + + protected function output(): OutputInterface + { + return (new ConsoleOutput)->getErrorOutput(); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index bcc67192..1d4337ca 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use App\Middleware\AnnouncesAbandonment; use App\Middleware\CommandMiddlewareManager; use App\Middleware\OffersSkillsInstall; use App\Middleware\RequiresAuthToken; @@ -82,6 +83,7 @@ protected function registerCommandMiddleware(): void $manager = $this->app->make(CommandMiddlewareManager::class); $manager->register(SuppressOutputIfJson::class); + $manager->register(AnnouncesAbandonment::class); $manager->register(RequiresAuthToken::class); $manager->register(OffersSkillsInstall::class); diff --git a/composer.json b/composer.json index a88bb82f..68186f40 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,7 @@ ], "homepage": "https://cloud.laravel.com", "type": "project", + "abandoned": "https://www.npmjs.com/package/@laravel/cloud-cli", "license": "MIT", "support": { "issues": "https://github.com/laravel/cloud-cli/issues", diff --git a/skills/deploying-to-cloud/SKILL.md b/skills/deploying-to-cloud/SKILL.md index ac3577f9..8951f67a 100644 --- a/skills/deploying-to-cloud/SKILL.md +++ b/skills/deploying-to-cloud/SKILL.md @@ -7,7 +7,7 @@ metadata: --- # Deploying with Laravel Cloud -Use the [Laravel Cloud documentation](https://cloud.laravel.com/docs/llms.txt) for detailed, current feature behavior. Use the Cloud CLI for Cloud operations rather than guessing dashboard or API workflows. Install it in the project and invoke it as `./vendor/bin/cloud` by default; use a globally installed `cloud` command only as a fallback. Commands below are written as `cloud` for brevity; run them as `./vendor/bin/cloud` unless falling back to the global installation. +Use the [Laravel Cloud documentation](https://cloud.laravel.com/docs/llms.txt) for detailed, current feature behavior. Use the Cloud CLI for Cloud operations rather than guessing dashboard or API workflows. Install it globally from npm and invoke it as `cloud`. ## Application Setup @@ -57,11 +57,11 @@ Use the [Laravel Cloud documentation](https://cloud.laravel.com/docs/llms.txt) f ### Setup ```shell -composer require --dev laravel/cloud-cli -./vendor/bin/cloud auth -n +npm install -g @laravel/cloud-cli +cloud auth -n ``` -If a project-local installation is not available, install the CLI globally with `composer global require laravel/cloud-cli` and invoke it as `cloud`. +To run a single command without installing, as in a CI job, use `npx @laravel/cloud-cli `. The Composer package `laravel/cloud-cli` is abandoned; if a project still requires it, replace it with the npm package. `cloud auth` opens a browser. If a browser is unavailable, set `LARAVEL_CLOUD_TOKEN` in the environment. It overrides any saved token and writes nothing to disk. To save a token instead, run `cloud auth:token --add --token= -n` or pipe it with `echo "$TOKEN" | cloud auth:token --add -n`. diff --git a/tests/Feature/AnnouncesAbandonmentTest.php b/tests/Feature/AnnouncesAbandonmentTest.php new file mode 100644 index 00000000..4d5418d8 --- /dev/null +++ b/tests/Feature/AnnouncesAbandonmentTest.php @@ -0,0 +1,49 @@ +makePartial(); + $middleware->shouldAllowMockingProtectedMethods(); + $middleware->shouldReceive('output')->andReturn($output); + + return $middleware; +} + +it('points users to the npm package', function () { + $output = new BufferedOutput; + $called = false; + + abandonmentMiddleware($output)->handle('application:list', function () use (&$called) { + $called = true; + }); + + expect($called)->toBeTrue() + ->and($output->fetch()) + ->toContain('laravel/cloud-cli is abandoned') + ->toContain('npm install -g @laravel/cloud-cli'); +}); + +it('stays quiet for internal commands', function () { + $output = new BufferedOutput; + + abandonmentMiddleware($output)->handle('_complete', fn () => null); + + expect($output->fetch())->toBe(''); +}); + +it('stays quiet when output is JSON', function () { + Renderer::$suppressOutput = true; + $output = new BufferedOutput; + + abandonmentMiddleware($output)->handle('application:list', fn () => null); + + expect($output->fetch())->toBe(''); +});