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
feat: add cause to queued command output
  • Loading branch information
SychO9 committed Dec 11, 2023
commit ca816ae304959b8e9339bac1a16a29fbe89f3939
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,22 @@ export default class TaskOutputModal<CustomAttrs extends TaskOutputModalAttrs =
return (
<div className="Modal-body">
<div className="TaskOutputModal-data">
<div className="Form-group">
<label>{app.translator.trans('flarum-package-manager.admin.sections.queue.output_modal.guessed_cause')}</label>
<div className="FormControl TaskOutputModal-data-guessed-cause">
{(this.attrs.task.guessedCause() &&
app.translator.trans('flarum-package-manager.admin.exceptions.guessed_cause.' + this.attrs.task.guessedCause())) ||
app.translator.trans('flarum-package-manager.admin.sections.queue.output_modal.cause_unknown')}
</div>
</div>

<div className="Form-group">
<label>{app.translator.trans('flarum-package-manager.admin.sections.queue.output_modal.command')}</label>
<div className="FormControl TaskOutputModal-data-command">
<code>$ composer {this.attrs.task.command()}</code>
</div>
</div>

<div className="Form-group">
<label>{app.translator.trans('flarum-package-manager.admin.sections.queue.output_modal.output')}</label>
<div className="FormControl TaskOutputModal-data-output">
Expand Down
6 changes: 4 additions & 2 deletions extensions/package-manager/js/src/admin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ app.initializers.add('flarum-package-manager', (app) => {

app.packageManager = new PackageManagerState();

if (app.data['flarum-package-manager.using_sync_queue']) {
app.data.settings['flarum-package-manager.queue_jobs'] = '0';
}

app.extensionData
.for('flarum-package-manager')
.registerSetting({
Expand All @@ -33,10 +37,8 @@ app.initializers.add('flarum-package-manager', (app) => {
})
)
),
default: false,
type: 'boolean',
disabled: app.data['flarum-package-manager.using_sync_queue'],
// @todo async to sync while setting is enabled
})
.registerSetting({
setting: 'flarum-package-manager.task_retention_days',
Expand Down
4 changes: 4 additions & 0 deletions extensions/package-manager/js/src/admin/models/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export default class Task extends Model {
return Model.attribute<string>('output').call(this);
}

guessedCause() {
return Model.attribute<string>('guessedCause').call(this);
}

createdAt() {
return Model.attribute('createdAt', Model.transformDate).call(this);
}
Expand Down
2 changes: 2 additions & 0 deletions extensions/package-manager/locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ flarum-package-manager:
update_minor: Minor update
why_not: Analyze why a package cannot be updated
output_modal:
cause_unknown: Unknown
command: Composer Command
guessed_cause: Cause
output: Output
refresh: Refresh tasks list
statuses:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

use Flarum\Database\Migration;

return Migration::addColumns('package_manager_tasks', [
'guessed_cause' => ['type' => 'string', 'length' => 255, 'nullable' => true, 'after' => 'output'],
]);
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected function getDefaultAttributes($model)
'command' => $model->command,
'package' => $model->package,
'output' => $model->output,
'guessedCause' => $model->guessed_cause,
'createdAt' => $model->created_at,
'startedAt' => $model->started_at,
'finishedAt' => $model->finished_at,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function handle(UpdateExtension $command)
]);
}

// @todo: soft update and hard update instead of directly hard updating?
$output = $this->composer->run(
new StringInput("require $extension->name:*"),
$command->task ?? null
Expand Down
7 changes: 6 additions & 1 deletion extensions/package-manager/src/Job/ComposerCommandJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Flarum\Bus\Dispatcher;
use Flarum\PackageManager\Command\AbstractActionCommand;
use Flarum\PackageManager\Composer\ComposerAdapter;
use Flarum\PackageManager\Exception\ComposerCommandFailedException;
use Flarum\Queue\AbstractJob;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Queue\Middleware\WithoutOverlapping;
Expand Down Expand Up @@ -56,12 +57,16 @@ public function abort(Throwable $exception)
$this->command->task->output = $exception->getMessage();
}

if ($exception instanceof ComposerCommandFailedException) {
$this->command->task->guessed_cause = $exception->guessCause();
}

$this->command->task->end(false);
}

public function failed(Throwable $exception): void
{
$this->command->task->end(false);
$this->abort($exception);
}

public function middleware(): array
Expand Down
3 changes: 2 additions & 1 deletion extensions/package-manager/src/Task/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @property string $command
* @property string $package
* @property string $output
* @property string|null $guessed_cause
* @property Carbon $created_at
* @property Carbon|null $started_at
* @property Carbon|null $finished_at
Expand Down Expand Up @@ -50,7 +51,7 @@ class Task extends AbstractModel

protected $table = 'package_manager_tasks';

protected $fillable = ['command', 'output'];
protected $guarded = ['id'];

public $timestamps = true;

Expand Down
Loading