Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Allow make:addon to work for any minimum-stability #10814

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Ensure minimum-stability is dev before requiring new addon
  • Loading branch information
duncanmcclean committed Sep 18, 2024
commit f719d42ea9402a5d7ab97fe3fbe2fdbb527c23b9
28 changes: 27 additions & 1 deletion src/Console/Commands/MakeAddon.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ protected function addRepositoryPath()

$this->files->put(base_path('composer.json'), $json);

$this->components->info("Repository added to your app's composer.json.");
$this->components->info("Repository added to your app's composer.json file.");
$this->components->bulletList([
'This allows Composer to reference your addon locally during development.',
'When you publish your package, you should remove this from your composer.json file.',
Expand All @@ -246,6 +246,31 @@ protected function addRepositoryPath()
return $this;
}

/**
* Ensures the `minimum-stability` setting is set to `dev` in the app's composer.json file,
* so we can install the addon successfully.
*
* @return $this
*/
protected function ensureMinimumStabilityIsDev()
{
$decoded = json_decode($this->files->get(base_path('composer.json')), true);

if (isset($decoded['minimum-stability']) && $decoded['minimum-stability'] === 'dev') {
return;
}

$decoded['minimum-stability'] = 'dev';

$json = json_encode($decoded, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);

$this->files->put(base_path('composer.json'), $json);

$this->components->info("Changed `minimum-stability` to `dev` in your app's composer.json file.");

return $this;
}

/**
* Install addon.
*
Expand All @@ -254,6 +279,7 @@ protected function addRepositoryPath()
protected function installAddon()
{
$this->addRepositoryPath();
$this->ensureMinimumStabilityIsDev();

spin(
function () {
Expand Down
Loading