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

feat: package manager improvements #3943

Merged
merged 26 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
34a66a8
chore: track
SychO9 Dec 7, 2023
a7b49fa
Apply fixes from StyleCI
StyleCIBot Dec 7, 2023
1e390fe
chore: track
SychO9 Dec 8, 2023
c28e5a9
Apply fixes from StyleCI
StyleCIBot Dec 8, 2023
323cc1a
fix: installing beta packages #3792
SychO9 Dec 8, 2023
5b1ddf4
chore: guess package not found error
SychO9 Dec 8, 2023
0bc859e
Apply fixes from StyleCI
StyleCIBot Dec 8, 2023
82b7fa1
feat: queue improvements
SychO9 Dec 8, 2023
e48a1ac
feat: queue improvements
SychO9 Dec 9, 2023
c9d2763
fix: issues with job failure and unique runs
SychO9 Dec 9, 2023
91990d5
fix: enforce one composer action at a time
SychO9 Dec 9, 2023
ca816ae
feat: add cause to queued command output
SychO9 Dec 11, 2023
e248822
Apply fixes from StyleCI
StyleCIBot Dec 11, 2023
8878e9c
feat: add soft & hard extension update options
SychO9 Dec 13, 2023
25c9f3d
chore: explain why an extension cannot be removed
SychO9 Dec 13, 2023
1ccbd36
chore: remove test
SychO9 Dec 13, 2023
d6632ca
chore: simplify
SychO9 Dec 13, 2023
ba43f85
docs: readme
SychO9 Dec 13, 2023
ac4c1f2
Apply fixes from StyleCI
StyleCIBot Dec 13, 2023
361f795
Merge branch '1.x' into sm/package-manager-stable
SychO9 Dec 14, 2023
616206e
fea: allow adding repositories and auth methods
SychO9 Dec 15, 2023
dd35701
chore: prevent future issues when min stability is set
SychO9 Dec 16, 2023
d5e80b2
chore: typings check
SychO9 Dec 16, 2023
b8a744a
fix: phpstan
SychO9 Dec 16, 2023
02b414a
Apply fixes from StyleCI
StyleCIBot Dec 16, 2023
6d61c81
fix: bugs
SychO9 Dec 16, 2023
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
Prev Previous commit
Next Next commit
chore: simplify
  • Loading branch information
SychO9 committed Dec 13, 2023
commit d6632ca72254168fa8e3597076ba52137b560289
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ export default class ConfigureComposer<CustomAttrs extends IConfigureComposer =
this.settings[key] = Stream(data[key]);
});

if (this.initialSettings === null) {
this.initialSettings = data;
}
this.initialSettings = data;
})
.finally(() => {
this.loading = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Flarum\Foundation\Paths;
use Flarum\Http\RequestUtil;
use Flarum\PackageManager\Composer\ComposerJson;
use Flarum\PackageManager\ConfigureComposerValidator;
use Illuminate\Support\Arr;
use Laminas\Diactoros\Response\JsonResponse;
Expand All @@ -34,10 +35,16 @@ class ConfigureComposerController implements RequestHandlerInterface
*/
protected $paths;

public function __construct(ConfigureComposerValidator $validator, Paths $paths)
/**
* @var ComposerJson
*/
protected $composerJson;

public function __construct(ConfigureComposerValidator $validator, Paths $paths, ComposerJson $composerJson)
{
$this->validator = $validator;
$this->paths = $paths;
$this->composerJson = $composerJson;
}

public function handle(ServerRequestInterface $request): ResponseInterface
Expand All @@ -48,32 +55,18 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$actor->assertAdmin();

$this->validator->assertValid($data);
$composerJson = $this->readComposerJson();
$composerJson = $this->composerJson->get();

if (! empty($data)) {
foreach ($data as $key => $value) {
Arr::set($composerJson, $key, $value);
}

$this->writeComposerJson($composerJson);
$this->composerJson->set($composerJson);
}

return new JsonResponse([
'data' => Arr::only($composerJson, $this->configurable),
]);
}

protected function readComposerJson()
{
$composerJson = file_get_contents($this->paths->base.'/composer.json');
$composerJson = json_decode($composerJson, true);

return $composerJson;
}

protected function writeComposerJson($composerJson)
{
$composerJson = json_encode($composerJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
file_put_contents($this->paths->base.'/composer.json', $composerJson);
}
}
2 changes: 1 addition & 1 deletion extensions/package-manager/src/Composer/ComposerJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function get(): array
return $json;
}

protected function set(array $json): void
public function set(array $json): void
{
$this->filesystem->put($this->getComposerJsonPath(), json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
Expand Down