-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: extension upgrade tool for 2.0 (#42)
* chore: first iteration (frontend changes) * fix: improvements * fix: improvements * fix: improvements * fix: improvements * feat: backend changes * feat: JSON:API migration help * feat: search api migration * chore: visual improvements * feat: continue * chore: improvements * fix: allow proprietary license (#44) * chore: improvements * chore: improvements * chore: improvements * chore: improvements * chore: improvements * chore: improvements * chore: improvements * chore: improvements * chore: improvements * chore: improvements * chore: improvements * chore: improvements * chore: improvements * chore: improvements * chore: improvements * feat: intervention/image * chore: improvements
- Loading branch information
Showing
80 changed files
with
6,034 additions
and
422 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import app from 'flarum/common/app'; | ||
|
||
app.initializers.add('<%= params.packageName %>-common', () => { | ||
app.initializers.add('<%= params.extensionId %>-common', () => { | ||
console.log('[<%= params.packageName %>] Hello, forum and admin!'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 5 additions & 7 deletions
12
boilerplate/skeleton/extension/tests/phpunit.integration.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
cacheDirectory=".phpunit.cache" | ||
backupStaticProperties="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
> | ||
<coverage processUncoveredFiles="true"> | ||
<source> | ||
<include> | ||
<directory suffix=".php">../src/</directory> | ||
</include> | ||
</coverage> | ||
</source> | ||
<testsuites> | ||
<testsuite name="Flarum Unit Tests"> | ||
<directory suffix="Test.php">./unit</directory> | ||
</testsuite> | ||
</testsuites> | ||
<listeners> | ||
<listener class="\Mockery\Adapter\Phpunit\TestListener" /> | ||
</listeners> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
namespace <%= classNamespace %>; | ||
|
||
use Flarum\Api\Context; | ||
use Flarum\Api\Endpoint; | ||
use Flarum\Api\Resource; | ||
use Flarum\Api\Schema;<% if (modelClassName) { %> | ||
use Flarum\Api\Sort\SortColumn; | ||
use <%= modelClass %>; | ||
use Illuminate\Database\Eloquent\Builder;<% } %> | ||
use Tobyz\JsonApiServer\Context as OriginalContext; | ||
|
||
/** | ||
* @extends <% if (modelClassName) { %>Resource\AbstractDatabaseResource<<%= modelClassName %>><% } else { %>Resource\AbstractResource<object><% } %> | ||
*/ | ||
class <%= className %> extends <% if (modelClassName) { %>Resource\AbstractDatabaseResource<% } else { %>Resource\AbstractResource<% if (interfaces.length > 0) %> implements <%= interfaces.join(', ') %><% } %> | ||
{ | ||
public function type(): string | ||
{ | ||
return '<%= modelType %>'; | ||
}<% if (modelClassName) { %> | ||
|
||
public function model(): string | ||
{ | ||
return <%= modelClassName %>::class; | ||
} | ||
|
||
public function scope(Builder $query, OriginalContext $context): void | ||
{ | ||
$query->whereVisibleTo($context->getActor()); | ||
}<% } %> | ||
|
||
public function endpoints(): array | ||
{ | ||
return [<% if (endpoints.includes('create')) { %> | ||
Endpoint\Create::make()<% if (modelClassName) { %> | ||
->can('create<%= modelClassName %>'),<% } %><% } %><% if (endpoints.includes('update')) { %> | ||
Endpoint\Update::make() | ||
->can('update'),<% } %><% if (endpoints.includes('delete')) { %> | ||
Endpoint\Delete::make() | ||
->can('delete'),<% } %><% if (endpoints.includes('show')) { %> | ||
Endpoint\Show::make() | ||
->authenticated(),<% } %><% if (endpoints.includes('list')) { %> | ||
Endpoint\Index::make() | ||
->paginate(),<% } %> | ||
]; | ||
} | ||
|
||
public function fields(): array | ||
{ | ||
return [ | ||
|
||
/** | ||
* @todo migrate logic from old serializer and controllers to this API Resource. | ||
* @see https://docs.flarum.org/2.x/extend/api#api-resources | ||
*/ | ||
|
||
// Example: | ||
Schema\Str::make('name') | ||
->requiredOnCreate() | ||
->minLength(3) | ||
->maxLength(255) | ||
->writable(), | ||
|
||
<% (relations || []).forEach(([name,type]) => { %> | ||
Schema\Relationship\<% if (type === 'hasOne') { %>ToOne<% } else { %>ToMany<% } %>::make('<%= name %>') | ||
->includable() | ||
// ->inverse('?') // the inverse relationship name if any. | ||
->type('<%= name %>s'), // the serialized type of this relation (type of the relation model's API resource).<% }) %> | ||
]; | ||
}<% if (modelClassName) { %> | ||
|
||
public function sorts(): array | ||
{ | ||
return [ | ||
// SortColumn::make('createdAt'), | ||
]; | ||
}<% } else { %> | ||
|
||
public function getId(object $model, OriginalContext $context): string | ||
{ | ||
return $model->id; | ||
}<% } %> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.