13 | */
14 | class <%= className %> implements FilterInterface
15 | {
16 | public function getFilterKey(): string
17 | {
18 | return '<%= filterKey %>';
19 | }
20 |
21 | public function filter(SearchState $state, string|array $value, bool $negate): void
22 | {
23 | // @TODO: implement filter logic
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/boilerplate/stubs/backend/handler/command.php:
--------------------------------------------------------------------------------
1 | ;
4 |
5 | use Flarum\User\User;
6 |
7 | class <%= className %>
8 | {
9 | public function __construct(<% if (!['create', 'none'].includes(classType)) { %>
10 | public int $modelId;
11 | <% } %>
12 | public User $actor;
13 | public array $data;
14 | ) {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/boilerplate/stubs/backend/handler/handler.php:
--------------------------------------------------------------------------------
1 | ;
4 |
5 | use Illuminate\Support\Arr;<% if (locals.repositoryClassName) { %>
6 | use <%= repositoryClass %>;<% } %><% if (locals.validatorClassName) { %>
7 | use <%= validatorClass %>;<% } %>
8 |
9 | class <%= className %>
10 | {
11 | public function __construct(<% if (locals.repositoryClassName) { %>
12 | protected <%= repositoryClassName %> $repository;
13 | <% } %><% if (locals.validatorClassName) { %>
14 | protected <%= validatorClassName %> $validator;
15 | <% } %>) {
16 | }
17 |
18 | public function handle(<%= handlerCommandClassName %> $command)
19 | {
20 | $actor = $command->actor;
21 | $data = $command->data;
22 |
23 | $actor->assertCan('...');
24 |
25 | // ...
26 |
27 | return $model;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/boilerplate/stubs/backend/job.php:
--------------------------------------------------------------------------------
1 | ;
4 |
5 | use Flarum\Queue\AbstractJob;
6 |
7 | class <%= className %>
8 | {
9 | public function __construct(
10 | //
11 | ) {
12 | }
13 |
14 | public function handle()
15 | {
16 | // See https://laravel.com/docs/11.x/queues for more information.
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/boilerplate/stubs/backend/mail-driver.php:
--------------------------------------------------------------------------------
1 | ;
4 |
5 | use Flarum\Settings\SettingsRepositoryInterface;
6 | use Illuminate\Contracts\Validation\Factory;
7 | use Illuminate\Support\MessageBag;
8 | use Symfony\Component\Mailer\Transport\Dsn;
9 | use Symfony\Component\Mailer\Transport\TransportInterface;
10 |
11 | class <%= className %> implements DriverInterface
12 | {
13 | public function availableSettings(): array
14 | {
15 | return [
16 | //
17 | ];
18 | }
19 |
20 | public function validate(SettingsRepositoryInterface $settings, Factory $validator): MessageBag
21 | {
22 | return $validator->make($settings->all(), [
23 | //
24 | ])->errors();
25 | }
26 |
27 | public function canSend(): bool
28 | {
29 | return true;
30 | }
31 |
32 | public function buildTransport(SettingsRepositoryInterface $settings): TransportInterface
33 | {
34 | //
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/boilerplate/stubs/backend/middleware.php:
--------------------------------------------------------------------------------
1 | ;
4 |
5 | use Flarum\Post\Exception\FloodingException;
6 | use Psr\Http\Message\ResponseInterface as Response;
7 | use Psr\Http\Message\ServerRequestInterface as Request;
8 | use Psr\Http\Server\MiddlewareInterface as Middleware;
9 | use Psr\Http\Server\RequestHandlerInterface as Handler;
10 |
11 | class <%= className %> implements Middleware
12 | {
13 | public function process(Request $request, Handler $handler): Response
14 | {
15 | // do something with the request
16 |
17 | return $handler->handle($request);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/boilerplate/stubs/backend/model.php:
--------------------------------------------------------------------------------
1 | ;
4 |
5 | use Flarum\Database\AbstractModel;
6 | use Flarum\Database\ScopeVisibilityTrait;
7 | use Flarum\Foundation\EventGeneratorTrait;
8 |
9 | class <%= className %> extends AbstractModel
10 | {
11 | // See https://docs.flarum.org/2.x/extend/models.html#backend-models for more information.
12 | <% if (tableName) { %>
13 | protected $table = '<%= tableName %>';<% } %>
14 | }
15 |
--------------------------------------------------------------------------------
/boilerplate/stubs/backend/notification-blueprint.php:
--------------------------------------------------------------------------------
1 | ;
4 |
5 | use Flarum\Database\AbstractModel;
6 | use Flarum\Notification\Blueprint\BlueprintInterface;
7 | use Flarum\Notification\AlertableInterface;
8 | // use Flarum\Notification\MailableInterface;
9 | use Flarum\User\User;
10 |
11 | class <%= className %> implements BlueprintInterface, AlertableInterface/*, MailableInterface*/
12 | {
13 | public function __construct(
14 |
15 | ) {
16 | }
17 |
18 | public function getFromUser(): ?User
19 | {
20 | // @TODO: implement
21 | }
22 |
23 | public function getSubject(): ?AbstractModel
24 | {
25 | // @TODO: implement
26 | }
27 |
28 | public function getData(): array
29 | {
30 | return [];
31 | }
32 |
33 | public static function getType(): string
34 | {
35 | return '<%= type %>';
36 | }
37 |
38 | public static function getSubjectModel(): string
39 | {
40 | // @TODO: implement
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/boilerplate/stubs/backend/policy.php:
--------------------------------------------------------------------------------
1 | ;
4 |
5 | use <%= modelClass %>;
6 | use Flarum\User\Access\AbstractPolicy;
7 | use Flarum\User\User;
8 |
9 | class <%= className %> extends AbstractPolicy
10 | {
11 | public function can(User $actor, string $ability, <%= modelClassName %> $model)
12 | {
13 | // See https://docs.flarum.org/2.x/extend/authorization.html#custom-policies for more information.
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/boilerplate/stubs/backend/post-type.php:
--------------------------------------------------------------------------------
1 | ;
4 |
5 | use Carbon\Carbon;
6 | use Flarum\Post\AbstractEventPost;
7 | use Flarum\Post\MergeableInterface; // implement if a new post type can be merged into a previous one.
8 | use Flarum\Post\Post;
9 |
10 | class <%= className %> extends AbstractEventPost
11 | {
12 | public static string $type = '<%= postType %>';
13 |
14 | /*
15 | * Use this method to create the new post type.
16 | */
17 | public static function reply(int $discussionId, int $userId): static
18 | {
19 | $post = new static;
20 |
21 | $post->content = static::buildContent();
22 | $post->created_at = Carbon::now();
23 | $post->discussion_id = $discussionId;
24 | $post->user_id = $userId;
25 |
26 | return $post;
27 | }
28 |
29 | public static function buildContent(): array
30 | {
31 | return [
32 | // Add the content of the post type here.
33 | ];
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/boilerplate/stubs/backend/repository.php:
--------------------------------------------------------------------------------
1 | ;
4 |
5 | use Flarum\User\User;
6 | use Illuminate\Database\Eloquent\Builder;
7 | use <%= modelClass %>;
8 |
9 | class <%= className %>
10 | {
11 | public function query(): Builder
12 | {
13 | return <%= modelClassName %>::query();
14 | }
15 |
16 | public function findOrFail(int|string $id, User $actor = null): <%= modelClassName %>
17 | {
18 | return <%= modelClassName %>::findOrFail($id);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/boilerplate/stubs/backend/search/driver.php:
--------------------------------------------------------------------------------
1 | ;
4 |
5 | use Flarum\Search\AbstractDriver;
6 |
7 | class <%= className %> extends AbstractDriver
8 | {
9 | public static function name(): string
10 | {
11 | return '<%= driverName %>';
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/boilerplate/stubs/backend/service-provider.php:
--------------------------------------------------------------------------------
1 | ;
4 |
5 | use Flarum\Foundation\AbstractServiceProvider;
6 | use Illuminate\Contracts\Container\Container;
7 |
8 | class <%= className %> extends AbstractServiceProvider
9 | {
10 | public function register()
11 | {
12 | // See https://docs.flarum.org/2.x/extend/service-provider.html#service-provider for more information.
13 | }
14 |
15 | public function boot(Container $container)
16 | {
17 | // ...
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/boilerplate/stubs/backend/validator.php:
--------------------------------------------------------------------------------
1 | ;
4 |
5 | use Flarum\Foundation\AbstractValidator;
6 |
7 | class <%= className %> extends AbstractValidator
8 | {
9 | /**
10 | * {@inheritdoc}
11 | */
12 | protected $rules = [
13 | // See https://laravel.com/docs/11.x/validation#available-validation-rules for more information.
14 | ];
15 | }
16 |
--------------------------------------------------------------------------------
/boilerplate/stubs/frontend/component.js:
--------------------------------------------------------------------------------
1 | import Component from 'flarum/common/Component';
2 |
3 | export default class <%= className %> extends Component {
4 | oninit(vnode) {
5 | super.oninit(vnode);
6 | }
7 |
8 | oncreate(vnode) {
9 | super.oncreate(vnode);
10 | }
11 |
12 | onupdate(vnode) {
13 | super.onupdate(vnode);
14 | }
15 |
16 | view() {
17 | return (
18 |
19 | {/* See https://docs.flarum.org/2.x/extend/frontend.html#components for more information. */}
20 |
21 | );
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/boilerplate/stubs/frontend/gambit/boolean.js:
--------------------------------------------------------------------------------
1 | import app from 'flarum/<%= frontend %>/app';
2 | import { BooleanGambit } from 'flarum/common/query/IGambit';
3 |
4 | export default class <%= className %> extends BooleanGambit {
5 | key() {
6 | return app.translator.trans('<%= extensionId %>.lib.gambits.<%= filterKey %>.key', {}, true);
7 | }
8 |
9 | filterKey() {
10 | return '<%= filterKey %>';
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/boilerplate/stubs/frontend/gambit/key-value.js:
--------------------------------------------------------------------------------
1 | import app from 'flarum/<%= frontend %>/app';
2 | import { KeyValueGambit } from 'flarum/common/query/IGambit';
3 |
4 | export default class <%= className %> extends KeyValueGambit {
5 | key() {
6 | return app.translator.trans('<%= extensionId %>.lib.gambits.<%= filterKey %>.key', {}, true);
7 | }
8 |
9 | hint() {
10 | return app.translator.trans('<%= extensionId %>.lib.gambits.<%= filterKey %>.hint', {}, true);
11 | }
12 |
13 | filterKey() {
14 | return '<%= filterKey %>';
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/boilerplate/stubs/frontend/modal.js:
--------------------------------------------------------------------------------
1 | import Modal from 'flarum/common/components/Modal';
2 |
3 | export default class <%= className %> extends Modal {
4 | className() {
5 | return 'Modal--small <%= className %>';
6 | }
7 |
8 | title() {
9 | return app.translator.trans('<%= extensionId %>._');
10 | }
11 |
12 | content() {
13 | return (
14 |
15 | // See https://docs.flarum.org/2.x/extend/interactive-components.html#modals for more information.
16 |
17 | );
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/boilerplate/stubs/frontend/model.js:
--------------------------------------------------------------------------------
1 | import Model from 'flarum/common/Model';
2 |
3 | // For more details about frontend models
4 | // checkout https://docs.flarum.org/2.x/extend/models.html#frontend-models
5 |
6 | export default class <%= className %> extends Model {
7 | title = Model.attribute('title');
8 | createdAt = Model.attribute('createdAt', Model.transformDate);
9 | }
10 |
--------------------------------------------------------------------------------
/boilerplate/stubs/frontend/notification.js:
--------------------------------------------------------------------------------
1 | import app from 'flarum/forum/app';
2 | import Notification from 'flarum/forum/components/Notification';
3 |
4 | export default class <%= className %> extends Notification {
5 | icon() {
6 | // return 'fas fa-???';
7 | }
8 |
9 | href() {
10 | const notification = this.attrs.notification;
11 |
12 | // return ...;
13 | }
14 |
15 | content() {
16 | return app.translator.trans('<%= extensionId %>.forum.notifications.<%= type %>_text', { user: this.attrs.notification.fromUser() });
17 | }
18 |
19 | excerpt() {
20 | return null;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/boilerplate/stubs/frontend/post-type.js:
--------------------------------------------------------------------------------
1 | import EventPost from 'flarum/forum/components/EventPost';
2 |
3 | export default class DiscussionStickiedPost extends EventPost {
4 | icon() {
5 | return 'fas fa-???';
6 | }
7 |
8 | descriptionKey() {
9 | const content = this.attrs.post.content();
10 |
11 | return '<%= extensionId %>.forum.post_stream.<%= postType %>_text';
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/boilerplate/stubs/migration.php:
--------------------------------------------------------------------------------
1 |
5 | use Illuminate\Database\Schema\Builder;
6 |
7 | // HINT: you might want to use a `Flarum\Database\Migration` helper method for simplicity!
8 | // See https://docs.flarum.org/2.x/extend/models.html#migrations to learn more about migrations.
9 | return [
10 | 'up' => function (Builder $schema) {
11 | // up migration
12 | },
13 | 'down' => function (Builder $schema) {
14 | // down migration
15 | }
16 | ];<% } %><% if (typeof tableName !== 'undefined' && tableName) { %>
17 | use Flarum\Database\Migration;
18 |
19 | return Migration::createTable(
20 | '<%= tableName %>',
21 | function (Blueprint $table) {
22 | $table->increments('id');
23 |
24 | // created_at & updated_at
25 | $table->timestamps();
26 | }
27 | );
28 | <% } %>
29 |
--------------------------------------------------------------------------------
/boilerplate/stubs/views/email/html/information.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | <% if (!content) { %>
4 | <% } else { %> <%- content %><% } %>
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/boilerplate/stubs/views/email/html/notification.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | <% if (!content) { %>
4 | <% } else { %> <%- content %><% } %>
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/boilerplate/stubs/views/email/plain/information.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | <% if (!content) { %>
4 | <% } else { %><%- content %><% } %>
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/boilerplate/stubs/views/email/plain/notification.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | <% if (!content) { %>
4 | <% } else { %><%- content %><% } %>
5 |
6 |
7 |
--------------------------------------------------------------------------------
/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | setupFilesAfterEnv: ['jest-extended'],
3 | collectCoverage: true,
4 | testEnvironment: 'node',
5 | preset: 'ts-jest',
6 | coverageReporters: ['html', 'lcov', 'text-summary'],
7 | transform: {
8 | '^.+\\.(ts|tsx|js|jsx)$': 'ts-jest',
9 | },
10 | moduleNameMapper: {
11 | '^boilersmith/(.*)': '/src/boilersmith/$1',
12 | },
13 | };
14 |
--------------------------------------------------------------------------------
/php-subsystem/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "flarum/cli-php-util",
3 | "type": "library",
4 | "require": {
5 | "ext-json": "*",
6 | "nikic/php-parser": "^5.0",
7 | "php": "^8.0"
8 | },
9 | "autoload": {
10 | "psr-4": {
11 | "Flarum\\CliPhpSubsystem\\": "src/"
12 | }
13 | },
14 | "platform": {
15 | "php": "8.0"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/php-subsystem/src/CustomPrettyPrinter.php:
--------------------------------------------------------------------------------
1 | pDereferenceLhs($node->var) . "\n ->" . $this->pObjectProperty($node->name)
15 | . '(' . $this->pMaybeMultiline($node->args) . ')';
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/php-subsystem/src/NodeVisitors/AddUses.php:
--------------------------------------------------------------------------------
1 | uses = $replacements;
16 | }
17 |
18 | public function leaveNode(Node $node)
19 | {
20 | if ($node instanceof Node\Stmt\Namespace_) {
21 | NodeUtil::addUsesToNamespace($node, $this->uses);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/php-subsystem/src/Upgrade/ReplacementResult.php:
--------------------------------------------------------------------------------
1 | updated = $updated;
15 | $this->data = $data;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/autoload.php:
--------------------------------------------------------------------------------
1 | $vendorDir . '/composer/InstalledVersions.php',
10 | );
11 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/composer/autoload_namespaces.php:
--------------------------------------------------------------------------------
1 | array($vendorDir . '/nikic/php-parser/lib/PhpParser'),
10 | 'Flarum\\CliPhpSubsystem\\' => array($baseDir . '/src'),
11 | );
12 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/composer/platform_check.php:
--------------------------------------------------------------------------------
1 | = 80000)) {
8 | $issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.0". You are running ' . PHP_VERSION . '.';
9 | }
10 |
11 | if ($issues) {
12 | if (!headers_sent()) {
13 | header('HTTP/1.1 500 Internal Server Error');
14 | }
15 | if (!ini_get('display_errors')) {
16 | if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
17 | fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
18 | } elseif (!headers_sent()) {
19 | echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
20 | }
21 | }
22 | trigger_error(
23 | 'Composer detected issues in your platform: ' . implode(' ', $issues),
24 | E_USER_ERROR
25 | );
26 | }
27 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nikic/php-parser",
3 | "type": "library",
4 | "description": "A PHP parser written in PHP",
5 | "keywords": [
6 | "php",
7 | "parser"
8 | ],
9 | "license": "BSD-3-Clause",
10 | "authors": [
11 | {
12 | "name": "Nikita Popov"
13 | }
14 | ],
15 | "require": {
16 | "php": ">=7.4",
17 | "ext-tokenizer": "*",
18 | "ext-json": "*",
19 | "ext-ctype": "*"
20 | },
21 | "require-dev": {
22 | "phpunit/phpunit": "^9.0",
23 | "ircmaxell/php-yacc": "^0.0.7"
24 | },
25 | "extra": {
26 | "branch-alias": {
27 | "dev-master": "5.0-dev"
28 | }
29 | },
30 | "autoload": {
31 | "psr-4": {
32 | "PhpParser\\": "lib/PhpParser"
33 | }
34 | },
35 | "autoload-dev": {
36 | "psr-4": {
37 | "PhpParser\\": "test/PhpParser/"
38 | }
39 | },
40 | "bin": [
41 | "bin/php-parse"
42 | ]
43 | }
44 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder.php:
--------------------------------------------------------------------------------
1 | errors[] = $error;
19 | }
20 |
21 | /**
22 | * Get collected errors.
23 | *
24 | * @return Error[]
25 | */
26 | public function getErrors(): array {
27 | return $this->errors;
28 | }
29 |
30 | /**
31 | * Check whether there are any errors.
32 | */
33 | public function hasErrors(): bool {
34 | return !empty($this->errors);
35 | }
36 |
37 | /**
38 | * Reset/clear collected errors.
39 | */
40 | public function clearErrors(): void {
41 | $this->errors = [];
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php:
--------------------------------------------------------------------------------
1 | type = $type;
28 | $this->old = $old;
29 | $this->new = $new;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php:
--------------------------------------------------------------------------------
1 | id === \T_WHITESPACE
24 | && $tokens[$pos + 2]->id === \T_STRING;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php:
--------------------------------------------------------------------------------
1 | text === '(' ||
27 | ($tokens[$pos + 1]->id === \T_WHITESPACE &&
28 | isset($tokens[$pos + 2]) &&
29 | $tokens[$pos + 2]->text === '(')));
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php:
--------------------------------------------------------------------------------
1 | Attribute arguments */
13 | public array $args;
14 |
15 | /**
16 | * @param Node\Name $name Attribute name
17 | * @param list $args Attribute arguments
18 | * @param array $attributes Additional node attributes
19 | */
20 | public function __construct(Name $name, array $args = [], array $attributes = []) {
21 | $this->attributes = $attributes;
22 | $this->name = $name;
23 | $this->args = $args;
24 | }
25 |
26 | public function getSubNodeNames(): array {
27 | return ['name', 'args'];
28 | }
29 |
30 | public function getType(): string {
31 | return 'Attribute';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php:
--------------------------------------------------------------------------------
1 | $attributes Additional node attributes
14 | */
15 | public function __construct(array $attrs, array $attributes = []) {
16 | $this->attributes = $attributes;
17 | $this->attrs = $attrs;
18 | }
19 |
20 | public function getSubNodeNames(): array {
21 | return ['attrs'];
22 | }
23 |
24 | public function getType(): string {
25 | return 'AttributeGroup';
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/ClosureUse.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
19 | */
20 | public function __construct(Expr\Variable $var, bool $byRef = false, array $attributes = []) {
21 | $this->attributes = $attributes;
22 | $this->var = $var;
23 | $this->byRef = $byRef;
24 | }
25 |
26 | public function getSubNodeNames(): array {
27 | return ['var', 'byRef'];
28 | }
29 |
30 | public function getType(): string {
31 | return 'ClosureUse';
32 | }
33 | }
34 |
35 | // @deprecated compatibility alias
36 | class_alias(ClosureUse::class, Expr\ClosureUse::class);
37 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/ComplexType.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
22 | */
23 | public function __construct($name, Expr $value, array $attributes = []) {
24 | $this->attributes = $attributes;
25 | $this->name = \is_string($name) ? new Identifier($name) : $name;
26 | $this->value = $value;
27 | }
28 |
29 | public function getSubNodeNames(): array {
30 | return ['name', 'value'];
31 | }
32 |
33 | public function getType(): string {
34 | return 'Const';
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
19 | */
20 | public function __construct(Expr $var, ?Expr $dim = null, array $attributes = []) {
21 | $this->attributes = $attributes;
22 | $this->var = $var;
23 | $this->dim = $dim;
24 | }
25 |
26 | public function getSubNodeNames(): array {
27 | return ['var', 'dim'];
28 | }
29 |
30 | public function getType(): string {
31 | return 'Expr_ArrayDimFetch';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
21 | */
22 | public function __construct(array $items = [], array $attributes = []) {
23 | $this->attributes = $attributes;
24 | $this->items = $items;
25 | }
26 |
27 | public function getSubNodeNames(): array {
28 | return ['items'];
29 | }
30 |
31 | public function getType(): string {
32 | return 'Expr_Array';
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
19 | */
20 | public function __construct(Expr $var, Expr $expr, array $attributes = []) {
21 | $this->attributes = $attributes;
22 | $this->var = $var;
23 | $this->expr = $expr;
24 | }
25 |
26 | public function getSubNodeNames(): array {
27 | return ['var', 'expr'];
28 | }
29 |
30 | public function getType(): string {
31 | return 'Expr_Assign';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
19 | */
20 | public function __construct(Expr $var, Expr $expr, array $attributes = []) {
21 | $this->attributes = $attributes;
22 | $this->var = $var;
23 | $this->expr = $expr;
24 | }
25 |
26 | public function getSubNodeNames(): array {
27 | return ['var', 'expr'];
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
19 | */
20 | public function __construct(Expr $var, Expr $expr, array $attributes = []) {
21 | $this->attributes = $attributes;
22 | $this->var = $var;
23 | $this->expr = $expr;
24 | }
25 |
26 | public function getSubNodeNames(): array {
27 | return ['var', 'expr'];
28 | }
29 |
30 | public function getType(): string {
31 | return 'Expr_AssignRef';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php:
--------------------------------------------------------------------------------
1 | ';
10 | }
11 |
12 | public function getType(): string {
13 | return 'Expr_BinaryOp_Greater';
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php:
--------------------------------------------------------------------------------
1 | =';
10 | }
11 |
12 | public function getType(): string {
13 | return 'Expr_BinaryOp_GreaterOrEqual';
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php:
--------------------------------------------------------------------------------
1 | >';
10 | }
11 |
12 | public function getType(): string {
13 | return 'Expr_BinaryOp_ShiftRight';
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php:
--------------------------------------------------------------------------------
1 | ';
10 | }
11 |
12 | public function getType(): string {
13 | return 'Expr_BinaryOp_Spaceship';
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Expr $expr, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->expr = $expr;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['expr'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_BitwiseNot';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Expr $expr, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->expr = $expr;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['expr'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_BooleanNot';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php:
--------------------------------------------------------------------------------
1 |
15 | */
16 | abstract public function getRawArgs(): array;
17 |
18 | /**
19 | * Returns whether this call expression is actually a first class callable.
20 | */
21 | public function isFirstClassCallable(): bool {
22 | $rawArgs = $this->getRawArgs();
23 | return count($rawArgs) === 1 && current($rawArgs) instanceof VariadicPlaceholder;
24 | }
25 |
26 | /**
27 | * Assert that this is not a first-class callable and return only ordinary Args.
28 | *
29 | * @return Arg[]
30 | */
31 | public function getArgs(): array {
32 | assert(!$this->isFirstClassCallable());
33 | return $this->getRawArgs();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Expr $expr, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->expr = $expr;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['expr'];
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Expr $expr, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->expr = $expr;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['expr'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_Clone';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
17 | */
18 | public function __construct(Name $name, array $attributes = []) {
19 | $this->attributes = $attributes;
20 | $this->name = $name;
21 | }
22 |
23 | public function getSubNodeNames(): array {
24 | return ['name'];
25 | }
26 |
27 | public function getType(): string {
28 | return 'Expr_ConstFetch';
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Expr $expr, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->expr = $expr;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['expr'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_Empty';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
18 | */
19 | public function __construct(array $attributes = []) {
20 | $this->attributes = $attributes;
21 | }
22 |
23 | public function getSubNodeNames(): array {
24 | return [];
25 | }
26 |
27 | public function getType(): string {
28 | return 'Expr_Error';
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Expr $expr, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->expr = $expr;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['expr'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_ErrorSuppress';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Expr $expr, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->expr = $expr;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['expr'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_Eval';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
20 | */
21 | public function __construct(?Expr $expr = null, array $attributes = []) {
22 | $this->attributes = $attributes;
23 | $this->expr = $expr;
24 | }
25 |
26 | public function getSubNodeNames(): array {
27 | return ['expr'];
28 | }
29 |
30 | public function getType(): string {
31 | return 'Expr_Exit';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
24 | */
25 | public function __construct(Expr $expr, int $type, array $attributes = []) {
26 | $this->attributes = $attributes;
27 | $this->expr = $expr;
28 | $this->type = $type;
29 | }
30 |
31 | public function getSubNodeNames(): array {
32 | return ['expr', 'type'];
33 | }
34 |
35 | public function getType(): string {
36 | return 'Expr_Include';
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
21 | */
22 | public function __construct(Expr $expr, Node $class, array $attributes = []) {
23 | $this->attributes = $attributes;
24 | $this->expr = $expr;
25 | $this->class = $class;
26 | }
27 |
28 | public function getSubNodeNames(): array {
29 | return ['expr', 'class'];
30 | }
31 |
32 | public function getType(): string {
33 | return 'Expr_Instanceof';
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(array $vars, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->vars = $vars;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['vars'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_Isset';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
21 | */
22 | public function __construct(array $items, array $attributes = []) {
23 | $this->attributes = $attributes;
24 | $this->items = $items;
25 | }
26 |
27 | public function getSubNodeNames(): array {
28 | return ['items'];
29 | }
30 |
31 | public function getType(): string {
32 | return 'Expr_List';
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Match_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
18 | */
19 | public function __construct(Node\Expr $cond, array $arms = [], array $attributes = []) {
20 | $this->attributes = $attributes;
21 | $this->cond = $cond;
22 | $this->arms = $arms;
23 | }
24 |
25 | public function getSubNodeNames(): array {
26 | return ['cond', 'arms'];
27 | }
28 |
29 | public function getType(): string {
30 | return 'Expr_Match';
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Expr $var, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->var = $var;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['var'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_PostDec';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Expr $var, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->var = $var;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['var'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_PostInc';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Expr $var, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->var = $var;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['var'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_PreDec';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Expr $var, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->var = $var;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['var'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_PreInc';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Expr $expr, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->expr = $expr;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['expr'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_Print';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
21 | */
22 | public function __construct(Expr $var, $name, array $attributes = []) {
23 | $this->attributes = $attributes;
24 | $this->var = $var;
25 | $this->name = \is_string($name) ? new Identifier($name) : $name;
26 | }
27 |
28 | public function getSubNodeNames(): array {
29 | return ['var', 'name'];
30 | }
31 |
32 | public function getType(): string {
33 | return 'Expr_PropertyFetch';
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
17 | */
18 | public function __construct(array $parts, array $attributes = []) {
19 | $this->attributes = $attributes;
20 | $this->parts = $parts;
21 | }
22 |
23 | public function getSubNodeNames(): array {
24 | return ['parts'];
25 | }
26 |
27 | public function getType(): string {
28 | return 'Expr_ShellExec';
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
22 | */
23 | public function __construct(Expr $cond, ?Expr $if, Expr $else, array $attributes = []) {
24 | $this->attributes = $attributes;
25 | $this->cond = $cond;
26 | $this->if = $if;
27 | $this->else = $else;
28 | }
29 |
30 | public function getSubNodeNames(): array {
31 | return ['cond', 'if', 'else'];
32 | }
33 |
34 | public function getType(): string {
35 | return 'Expr_Ternary';
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Throw_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Node\Expr $expr, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->expr = $expr;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['expr'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_Throw';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Expr $expr, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->expr = $expr;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['expr'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_UnaryMinus';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Expr $expr, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->expr = $expr;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['expr'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_UnaryPlus';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct($name, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->name = $name;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['name'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_Variable';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Expr $expr, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->expr = $expr;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['expr'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Expr_YieldFrom';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
19 | */
20 | public function __construct(?Expr $value = null, ?Expr $key = null, array $attributes = []) {
21 | $this->attributes = $attributes;
22 | $this->key = $key;
23 | $this->value = $value;
24 | }
25 |
26 | public function getSubNodeNames(): array {
27 | return ['key', 'value'];
28 | }
29 |
30 | public function getType(): string {
31 | return 'Expr_Yield';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(string $value, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->value = $value;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['value'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'InterpolatedStringPart';
28 | }
29 | }
30 |
31 | // @deprecated compatibility alias
32 | class_alias(InterpolatedStringPart::class, Scalar\EncapsedStringPart::class);
33 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/IntersectionType.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
14 | */
15 | public function __construct(array $types, array $attributes = []) {
16 | $this->attributes = $attributes;
17 | $this->types = $types;
18 | }
19 |
20 | public function getSubNodeNames(): array {
21 | return ['types'];
22 | }
23 |
24 | public function getType(): string {
25 | return 'IntersectionType';
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/MatchArm.php:
--------------------------------------------------------------------------------
1 | */
10 | public ?array $conds;
11 | /** @var Node\Expr */
12 | public Expr $body;
13 |
14 | /**
15 | * @param null|list $conds
16 | */
17 | public function __construct(?array $conds, Node\Expr $body, array $attributes = []) {
18 | $this->conds = $conds;
19 | $this->body = $body;
20 | $this->attributes = $attributes;
21 | }
22 |
23 | public function getSubNodeNames(): array {
24 | return ['conds', 'body'];
25 | }
26 |
27 | public function getType(): string {
28 | return 'MatchArm';
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/NullableType.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(Node $type, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->type = $type;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['type'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'NullableType';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
18 | */
19 | public function __construct(array $parts, array $attributes = []) {
20 | $this->attributes = $attributes;
21 | $this->parts = $parts;
22 | }
23 |
24 | public function getSubNodeNames(): array {
25 | return ['parts'];
26 | }
27 |
28 | public function getType(): string {
29 | return 'Scalar_InterpolatedString';
30 | }
31 | }
32 |
33 | // @deprecated compatibility alias
34 | class_alias(InterpolatedString::class, Encapsed::class);
35 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
12 | */
13 | public function __construct(array $attributes = []) {
14 | $this->attributes = $attributes;
15 | }
16 |
17 | public function getSubNodeNames(): array {
18 | return [];
19 | }
20 |
21 | /**
22 | * Get name of magic constant.
23 | *
24 | * @return string Name of magic constant
25 | */
26 | abstract public function getName(): string;
27 | }
28 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(array $stmts, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->stmts = $stmts;
20 | }
21 |
22 | public function getType(): string {
23 | return 'Stmt_Block';
24 | }
25 |
26 | public function getSubNodeNames(): array {
27 | return ['stmts'];
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Break_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(?Node\Expr $num = null, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->num = $num;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['num'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Stmt_Break';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
19 | */
20 | public function __construct(?Node\Expr $cond, array $stmts = [], array $attributes = []) {
21 | $this->attributes = $attributes;
22 | $this->cond = $cond;
23 | $this->stmts = $stmts;
24 | }
25 |
26 | public function getSubNodeNames(): array {
27 | return ['cond', 'stmts'];
28 | }
29 |
30 | public function getType(): string {
31 | return 'Stmt_Case';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(array $consts, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->consts = $consts;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['consts'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Stmt_Const';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(?Node\Expr $num = null, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->num = $num;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['num'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Stmt_Continue';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
20 | */
21 | public function __construct(array $declares, ?array $stmts = null, array $attributes = []) {
22 | $this->attributes = $attributes;
23 | $this->declares = $declares;
24 | $this->stmts = $stmts;
25 | }
26 |
27 | public function getSubNodeNames(): array {
28 | return ['declares', 'stmts'];
29 | }
30 |
31 | public function getType(): string {
32 | return 'Stmt_Declare';
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
19 | */
20 | public function __construct(Node\Expr $cond, array $stmts = [], array $attributes = []) {
21 | $this->attributes = $attributes;
22 | $this->cond = $cond;
23 | $this->stmts = $stmts;
24 | }
25 |
26 | public function getSubNodeNames(): array {
27 | return ['stmts', 'cond'];
28 | }
29 |
30 | public function getType(): string {
31 | return 'Stmt_Do';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(array $exprs, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->exprs = $exprs;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['exprs'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Stmt_Echo';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
19 | */
20 | public function __construct(Node\Expr $cond, array $stmts = [], array $attributes = []) {
21 | $this->attributes = $attributes;
22 | $this->cond = $cond;
23 | $this->stmts = $stmts;
24 | }
25 |
26 | public function getSubNodeNames(): array {
27 | return ['cond', 'stmts'];
28 | }
29 |
30 | public function getType(): string {
31 | return 'Stmt_ElseIf';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(array $stmts = [], array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->stmts = $stmts;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['stmts'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Stmt_Else';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
19 | */
20 | public function __construct(Node\Expr $expr, array $attributes = []) {
21 | $this->attributes = $attributes;
22 | $this->expr = $expr;
23 | }
24 |
25 | public function getSubNodeNames(): array {
26 | return ['expr'];
27 | }
28 |
29 | public function getType(): string {
30 | return 'Stmt_Expression';
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(array $stmts = [], array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->stmts = $stmts;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['stmts'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Stmt_Finally';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(array $vars, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->vars = $vars;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['vars'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Stmt_Global';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
17 | */
18 | public function __construct($name, array $attributes = []) {
19 | $this->attributes = $attributes;
20 | $this->name = \is_string($name) ? new Identifier($name) : $name;
21 | }
22 |
23 | public function getSubNodeNames(): array {
24 | return ['name'];
25 | }
26 |
27 | public function getType(): string {
28 | return 'Stmt_Goto';
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(string $remaining, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->remaining = $remaining;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['remaining'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Stmt_HaltCompiler';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(string $value, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->value = $value;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['value'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Stmt_InlineHTML';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
17 | */
18 | public function __construct($name, array $attributes = []) {
19 | $this->attributes = $attributes;
20 | $this->name = \is_string($name) ? new Identifier($name) : $name;
21 | }
22 |
23 | public function getSubNodeNames(): array {
24 | return ['name'];
25 | }
26 |
27 | public function getType(): string {
28 | return 'Stmt_Label';
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
23 | */
24 | public function __construct(?Node\Name $name = null, ?array $stmts = [], array $attributes = []) {
25 | $this->attributes = $attributes;
26 | $this->name = $name;
27 | $this->stmts = $stmts;
28 | }
29 |
30 | public function getSubNodeNames(): array {
31 | return ['name', 'stmts'];
32 | }
33 |
34 | public function getType(): string {
35 | return 'Stmt_Namespace';
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(?Node\Expr $expr = null, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->expr = $expr;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['expr'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Stmt_Return';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
17 | */
18 | public function __construct(array $vars, array $attributes = []) {
19 | $this->attributes = $attributes;
20 | $this->vars = $vars;
21 | }
22 |
23 | public function getSubNodeNames(): array {
24 | return ['vars'];
25 | }
26 |
27 | public function getType(): string {
28 | return 'Stmt_Static';
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
19 | */
20 | public function __construct(Node\Expr $cond, array $cases, array $attributes = []) {
21 | $this->attributes = $attributes;
22 | $this->cond = $cond;
23 | $this->cases = $cases;
24 | }
25 |
26 | public function getSubNodeNames(): array {
27 | return ['cond', 'cases'];
28 | }
29 |
30 | public function getType(): string {
31 | return 'Stmt_Switch';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
19 | */
20 | public function __construct(array $traits, array $adaptations = [], array $attributes = []) {
21 | $this->attributes = $attributes;
22 | $this->traits = $traits;
23 | $this->adaptations = $adaptations;
24 | }
25 |
26 | public function getSubNodeNames(): array {
27 | return ['traits', 'adaptations'];
28 | }
29 |
30 | public function getType(): string {
31 | return 'Stmt_TraitUse';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
16 | */
17 | public function __construct(array $vars, array $attributes = []) {
18 | $this->attributes = $attributes;
19 | $this->vars = $vars;
20 | }
21 |
22 | public function getSubNodeNames(): array {
23 | return ['vars'];
24 | }
25 |
26 | public function getType(): string {
27 | return 'Stmt_Unset';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
19 | */
20 | public function __construct(Node\Expr $cond, array $stmts = [], array $attributes = []) {
21 | $this->attributes = $attributes;
22 | $this->cond = $cond;
23 | $this->stmts = $stmts;
24 | }
25 |
26 | public function getSubNodeNames(): array {
27 | return ['cond', 'stmts'];
28 | }
29 |
30 | public function getType(): string {
31 | return 'Stmt_While';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/UnionType.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
14 | */
15 | public function __construct(array $types, array $attributes = []) {
16 | $this->attributes = $attributes;
17 | $this->types = $types;
18 | }
19 |
20 | public function getSubNodeNames(): array {
21 | return ['types'];
22 | }
23 |
24 | public function getType(): string {
25 | return 'UnionType';
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/VarLikeIdentifier.php:
--------------------------------------------------------------------------------
1 | $attributes Additional attributes
15 | */
16 | public function __construct(array $attributes = []) {
17 | $this->attributes = $attributes;
18 | }
19 |
20 | public function getType(): string {
21 | return 'VariadicPlaceholder';
22 | }
23 |
24 | public function getSubNodeNames(): array {
25 | return [];
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeTraverserInterface.php:
--------------------------------------------------------------------------------
1 | setAttribute('origNode', $origNode);
17 | return $node;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php:
--------------------------------------------------------------------------------
1 | $node->getAttribute('parent').
16 | */
17 | final class ParentConnectingVisitor extends NodeVisitorAbstract {
18 | /**
19 | * @var Node[]
20 | */
21 | private array $stack = [];
22 |
23 | public function beforeTraverse(array $nodes) {
24 | $this->stack = [];
25 | }
26 |
27 | public function enterNode(Node $node) {
28 | if (!empty($this->stack)) {
29 | $node->setAttribute('parent', $this->stack[count($this->stack) - 1]);
30 | }
31 |
32 | $this->stack[] = $node;
33 | }
34 |
35 | public function leaveNode(Node $node) {
36 | array_pop($this->stack);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitorAbstract.php:
--------------------------------------------------------------------------------
1 | pos + \strlen($this->text);
12 | }
13 |
14 | /** Get 1-based end line number of the token. */
15 | public function getEndLine(): int {
16 | return $this->line + \substr_count($this->text, "\n");
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/boilersmith/utils/clone-and-fill.ts:
--------------------------------------------------------------------------------
1 | export function cloneAndFill(obj: T, params: Record): T {
2 | const fill = (val: string, params: Record) => {
3 | return val.replace(/\${(.*)}/gm, (...match): string => {
4 | return params[match[1]];
5 | });
6 | };
7 |
8 | const recursiveCopyAndFill = (obj: any, params: Record): any => {
9 | if (typeof obj === 'string') return fill(obj, params);
10 | if (Array.isArray(obj)) return obj.map((v) => recursiveCopyAndFill(v, params));
11 | // eslint-disable-next-line no-new-object
12 | if (obj !== new Object(obj)) return obj;
13 |
14 | const newObj: any = {};
15 |
16 | for (const key of Object.keys(obj)) {
17 | const value = obj[key];
18 |
19 | newObj[key] = recursiveCopyAndFill(value, params);
20 | }
21 |
22 | return newObj;
23 | };
24 |
25 | return recursiveCopyAndFill(obj, params);
26 | }
27 |
--------------------------------------------------------------------------------
/src/boilersmith/utils/commit-async.ts:
--------------------------------------------------------------------------------
1 | import { Store } from 'mem-fs';
2 | import { create } from 'mem-fs-editor';
3 |
4 | export async function commitAsync(fs: Store): Promise {
5 | return new Promise((resolve, _reject) => {
6 | create(fs).commit((err) => {
7 | if (err) {
8 | throw new Error(err);
9 | }
10 |
11 | resolve(true);
12 | });
13 | });
14 | }
15 |
--------------------------------------------------------------------------------
/src/boilersmith/utils/cond-format.ts:
--------------------------------------------------------------------------------
1 | export function condFormat(condition: boolean, format: (...args: string[]) => string, message: string | string[]): string {
2 | const args = Array.isArray(message) ? message : [message];
3 | return condition ? format(...args) : args.join(' ');
4 | }
5 |
--------------------------------------------------------------------------------
/src/boilersmith/utils/json-leaf-paths.ts:
--------------------------------------------------------------------------------
1 | type JSONSchema = string | number | boolean | JSONSchemaObject | JSONSchemaArray | null;
2 |
3 | interface JSONSchemaObject {
4 | [key: string]: JSONSchema;
5 | }
6 |
7 | type JSONSchemaArray = Array;
8 |
9 | function inner(o: JSONSchema, prefix: string[]): string[] {
10 | if (Array.isArray(o)) {
11 | // Placed separately in case we eventually decide to support leaves in arrays.
12 | return [prefix.join('.')];
13 | }
14 |
15 | if (o && typeof o === 'object') {
16 | return Object.entries(o).flatMap(([k, v]) => inner(v, [...prefix, k]));
17 | }
18 |
19 | return [prefix.join('.')];
20 | }
21 |
22 | export function jsonLeafPaths(obj: JSONSchema): string[] {
23 | return inner(obj, []);
24 | }
25 |
--------------------------------------------------------------------------------
/src/boilersmith/utils/read-tpl.ts:
--------------------------------------------------------------------------------
1 | import { Data, Options, render } from 'ejs';
2 | import { readFileSync } from 'fs';
3 |
4 | export function readTpl(path: string, data: Data, options?: Options): string {
5 | const template = readFileSync(path, 'utf8');
6 |
7 | return render(template, data, { filename: path, ...options, async: false });
8 | }
9 |
--------------------------------------------------------------------------------
/src/boilersmith/utils/rename-keys.ts:
--------------------------------------------------------------------------------
1 | export function renameKeys(obj: Record, func: (key: string, val: unknown) => string): Record {
2 | return Object.fromEntries(Object.entries(obj).map(([key, val]) => [func(key, val), val]));
3 | }
4 |
--------------------------------------------------------------------------------
/src/commands/flarum/info.ts:
--------------------------------------------------------------------------------
1 | import { Command } from '@oclif/core';
2 | import path from 'path';
3 |
4 | export default class Info extends Command {
5 | static description = 'Related Flarum version information.';
6 |
7 | async run(): Promise {
8 | const jsonPath = path.resolve(__dirname, '../../../package.json');
9 | const json = require(jsonPath);
10 | const flarumVersion = json.flarum;
11 | const cliVersion = json.version;
12 |
13 | this.log(`Flarum version: ${flarumVersion}`);
14 | this.log(`CLI version: ${cliVersion}`);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/commands/make/backend/integration-test.ts:
--------------------------------------------------------------------------------
1 | import { StepManager } from 'boilersmith/step-manager';
2 | import { FlarumProviders } from '../../../providers';
3 | import { genExtScaffolder } from '../../../steps/gen-ext-scaffolder';
4 | import BaseCommand from '../../../base-command';
5 | import { GenerateIntegrationTestStub } from '../../../steps/stubs/backend/integration-test';
6 |
7 | export default class IntegrationTest extends BaseCommand {
8 | static description = 'Generate an integration test class';
9 |
10 | static flags = { ...BaseCommand.flags };
11 |
12 | static args = [BaseCommand.classNameArg, ...BaseCommand.args];
13 |
14 | protected steps(stepManager: StepManager): StepManager {
15 | return stepManager.atomicGroup((stepManager) => {
16 | stepManager.namedStep('test', new GenerateIntegrationTestStub(this.STUB_PATH, genExtScaffolder()));
17 | });
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/commands/make/backend/job.ts:
--------------------------------------------------------------------------------
1 | import { StepManager } from 'boilersmith/step-manager';
2 | import { FlarumProviders } from '../../../providers';
3 | import { genExtScaffolder } from '../../../steps/gen-ext-scaffolder';
4 | import BaseCommand from '../../../base-command';
5 | import { GenerateJobStub } from '../../../steps/stubs/backend/job';
6 |
7 | export default class Job extends BaseCommand {
8 | static description = 'Generate a job class';
9 |
10 | static flags = { ...BaseCommand.flags };
11 |
12 | static args = [BaseCommand.classNameArg, ...BaseCommand.args];
13 |
14 | protected steps(stepManager: StepManager): StepManager {
15 | return stepManager.step(new GenerateJobStub(this.STUB_PATH, genExtScaffolder()));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/commands/make/backend/migration.ts:
--------------------------------------------------------------------------------
1 | import { StepManager } from 'boilersmith/step-manager';
2 | import { FlarumProviders } from '../../../providers';
3 | import { genExtScaffolder } from '../../../steps/gen-ext-scaffolder';
4 | import BaseCommand from '../../../base-command';
5 | import { GenerateMigrationStub } from '../../../steps/stubs/backend/migration';
6 |
7 | export default class Migration extends BaseCommand {
8 | static description = 'Generate a migration';
9 |
10 | static flags = { ...BaseCommand.flags };
11 |
12 | static args = [
13 | {
14 | name: 'name',
15 | description: 'The name of the migration',
16 | required: false,
17 | },
18 | ...BaseCommand.args,
19 | ];
20 |
21 | protected steps(stepManager: StepManager): StepManager {
22 | return stepManager.step(new GenerateMigrationStub(this.STUB_PATH, genExtScaffolder()));
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/commands/make/backend/repository.ts:
--------------------------------------------------------------------------------
1 | import { StepManager } from 'boilersmith/step-manager';
2 | import { FlarumProviders } from '../../../providers';
3 | import { genExtScaffolder } from '../../../steps/gen-ext-scaffolder';
4 | import BaseCommand from '../../../base-command';
5 | import { GenerateRepositoryStub } from '../../../steps/stubs/backend/repository';
6 |
7 | export default class Repository extends BaseCommand {
8 | static description = 'Generate a repository class';
9 |
10 | static flags = { ...BaseCommand.flags };
11 |
12 | static args = [...BaseCommand.args];
13 |
14 | protected steps(stepManager: StepManager): StepManager {
15 | return stepManager.step(new GenerateRepositoryStub(this.STUB_PATH, genExtScaffolder()));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/commands/make/backend/route.ts:
--------------------------------------------------------------------------------
1 | import { StepManager } from 'boilersmith/step-manager';
2 | import { FlarumProviders } from '../../../providers';
3 | import BaseCommand from '../../../base-command';
4 | import { GenerateRoutesExtender } from '../../../steps/extenders/route';
5 |
6 | export default class Route extends BaseCommand {
7 | static description = 'Generate a routes extender';
8 |
9 | static flags = { ...BaseCommand.flags };
10 |
11 | static args = [...BaseCommand.args];
12 |
13 | protected steps(stepManager: StepManager): StepManager {
14 | return stepManager.step(new GenerateRoutesExtender());
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/commands/make/backend/validator.ts:
--------------------------------------------------------------------------------
1 | import { StepManager } from 'boilersmith/step-manager';
2 | import { FlarumProviders } from '../../../providers';
3 | import { genExtScaffolder } from '../../../steps/gen-ext-scaffolder';
4 | import BaseCommand from '../../../base-command';
5 | import { GenerateValidatorStub } from '../../../steps/stubs/backend/validator';
6 |
7 | export default class Validator extends BaseCommand {
8 | static description = 'Generate a validator class';
9 |
10 | static flags = { ...BaseCommand.flags };
11 |
12 | static args = [BaseCommand.classNameArg, ...BaseCommand.args];
13 |
14 | protected steps(stepManager: StepManager): StepManager {
15 | return stepManager.step(new GenerateValidatorStub(this.STUB_PATH, genExtScaffolder()));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/commands/make/frontend/component.ts:
--------------------------------------------------------------------------------
1 | import { StepManager } from 'boilersmith/step-manager';
2 | import { FlarumProviders } from '../../../providers';
3 | import { genExtScaffolder } from '../../../steps/gen-ext-scaffolder';
4 | import BaseCommand from '../../../base-command';
5 | import { GenerateComponentStub } from '../../../steps/stubs/frontend/component';
6 | import { Interfaces } from '@oclif/core';
7 |
8 | export default class Component extends BaseCommand {
9 | static description = 'Generate a frontend component';
10 |
11 | static flags = { ...BaseCommand.flags };
12 |
13 | static frontendArg: Interfaces.Arg = {
14 | name: 'frontend',
15 | description: 'The frontend name',
16 | required: false,
17 | };
18 |
19 | static args = [Component.frontendArg, BaseCommand.classNameArg, ...BaseCommand.args];
20 |
21 | protected steps(stepManager: StepManager): StepManager {
22 | return stepManager.step(new GenerateComponentStub(this.STUB_PATH, genExtScaffolder()));
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/commands/make/frontend/modal.ts:
--------------------------------------------------------------------------------
1 | import { StepManager } from 'boilersmith/step-manager';
2 | import { FlarumProviders } from '../../../providers';
3 | import { genExtScaffolder } from '../../../steps/gen-ext-scaffolder';
4 | import BaseCommand from '../../../base-command';
5 | import { GenerateModalStub } from '../../../steps/stubs/frontend/modal';
6 | import Component from './component';
7 |
8 | export default class Modal extends BaseCommand {
9 | static description = 'Generate a modal component';
10 |
11 | static flags = { ...BaseCommand.flags };
12 |
13 | static args = [Component.frontendArg, BaseCommand.classNameArg, ...BaseCommand.args];
14 |
15 | protected steps(stepManager: StepManager): StepManager {
16 | return stepManager.step(new GenerateModalStub(this.STUB_PATH, genExtScaffolder()));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/commands/make/locale.ts:
--------------------------------------------------------------------------------
1 | import { StepManager } from 'boilersmith/step-manager';
2 | import BaseCommand from '../../base-command';
3 | import { FlarumProviders } from '../../providers';
4 | import { LocaleStep } from '../../steps/locale/base';
5 | import { genExtScaffolder } from '../../steps/gen-ext-scaffolder';
6 |
7 | export default class Locale extends BaseCommand {
8 | static description = 'Generate new locale key value pair.';
9 |
10 | static flags = { ...BaseCommand.flags };
11 |
12 | static args = [
13 | {
14 | name: 'key',
15 | description: 'The nested key of the locale (e.g. `forum.custom_modal.title`).',
16 | required: false,
17 | },
18 | {
19 | name: 'value',
20 | description: 'The value of the locale.',
21 | required: false,
22 | },
23 | ...BaseCommand.args,
24 | ];
25 |
26 | protected steps(stepManager: StepManager): StepManager {
27 | return stepManager.step(new LocaleStep(genExtScaffolder()));
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/commands/monorepo/create.ts:
--------------------------------------------------------------------------------
1 | import { StepManager } from 'boilersmith/step-manager';
2 | import BaseCommand from '../../base-command';
3 | import { FlarumProviders } from '../../providers';
4 | import { Flags } from '@oclif/core';
5 | import { MonorepoCreate } from '../../steps/monorepo/create';
6 | import { genExtScaffolder } from '../../steps/gen-ext-scaffolder';
7 |
8 | export default class Create extends BaseCommand {
9 | static description = 'Create a monorepo of Flarum extensions.';
10 |
11 | static flags = {
12 | config: Flags.string({ char: 'c', required: false }),
13 | ...BaseCommand.flags,
14 | };
15 |
16 | static args = [...BaseCommand.args];
17 |
18 | protected requireExistingExtension = false;
19 |
20 | protected steps(stepManager: StepManager): StepManager {
21 | return stepManager.step(new MonorepoCreate(genExtScaffolder(), this.flags.config));
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/commands/monorepo/split.ts:
--------------------------------------------------------------------------------
1 | import { StepManager } from 'boilersmith/step-manager';
2 | import BaseCommand from '../../base-command';
3 | import { FlarumProviders } from '../../providers';
4 | import { Flags } from '@oclif/core';
5 | import { MonorepoSplit } from '../../steps/monorepo/split';
6 |
7 | export default class Split extends BaseCommand {
8 | static description = 'Split monorepo changes into subrepos.';
9 |
10 | static flags = {
11 | force: Flags.boolean({ char: 'f', required: false }),
12 | ...BaseCommand.flags,
13 | };
14 |
15 | static args = [...BaseCommand.args];
16 |
17 | protected requireExistingExtension = false;
18 |
19 | protected steps(stepManager: StepManager): StepManager {
20 | return stepManager.step(new MonorepoSplit(this.flags.force));
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/commands/update/js-imports.ts:
--------------------------------------------------------------------------------
1 | import { StepManager } from 'boilersmith/step-manager';
2 | import { UpdateJSImports } from '../../steps/update/js-imports';
3 | import BaseCommand from '../../base-command';
4 | import { FlarumProviders } from '../../providers';
5 |
6 | export default class UpdateJsImports extends BaseCommand {
7 | static description = 'Updates JS imports from core to use proper namespaces';
8 |
9 | static flags = { ...BaseCommand.flags };
10 |
11 | static args = [...BaseCommand.args];
12 |
13 | protected steps(stepManager: StepManager): StepManager {
14 | return stepManager.step(new UpdateJSImports());
15 | }
16 |
17 | protected async additionalPreRunChecks(extRoot: string): Promise {
18 | await this.ensureComposerInstallRan(extRoot);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | export { run } from '@oclif/core';
2 |
--------------------------------------------------------------------------------
/src/jest-extended.d.ts:
--------------------------------------------------------------------------------
1 | import 'jest-extended';
2 |
--------------------------------------------------------------------------------
/src/providers/index.ts:
--------------------------------------------------------------------------------
1 | import { DefaultProviders } from 'boilersmith/step-manager';
2 | import { PhpProvider } from './php-provider';
3 |
4 | export interface FlarumProviders extends DefaultProviders {
5 | php: PhpProvider;
6 | }
7 |
--------------------------------------------------------------------------------
/src/steps/extenders/api-resource.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../utils/validation';
2 | import { ExpressionType } from '../../providers/php-provider';
3 | import { BaseExtenderStep, ExtenderGenerationSchema } from './base';
4 | import chalk from 'chalk';
5 |
6 | export class GenerateApiResourceExtender extends BaseExtenderStep {
7 | type = 'Generate Api Resource extender';
8 |
9 | protected schema: ExtenderGenerationSchema = {
10 | extenderDef: {
11 | extender: {
12 | className: '\\Flarum\\Extend\\ApiResource',
13 | args: [
14 | {
15 | type: ExpressionType.CLASS_CONST,
16 | value: '${resourceClass}',
17 | auxiliaryValue: 'class',
18 | },
19 | ],
20 | },
21 | methodCalls: [],
22 | },
23 | params: [
24 | {
25 | name: 'resourceClass',
26 | type: 'text',
27 | validate: Validator.class,
28 | message: `API Resource Class (${chalk.dim('Vendor\\Path\\Event')})`,
29 | },
30 | ],
31 | };
32 | }
33 |
--------------------------------------------------------------------------------
/src/steps/extenders/console-command.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../utils/validation';
2 | import { ExpressionType } from '../../providers/php-provider';
3 | import { BaseExtenderStep, ExtenderGenerationSchema } from './base';
4 | import chalk from 'chalk';
5 |
6 | export class GenerateConsoleCommandExtender extends BaseExtenderStep {
7 | type = 'Generate console extender';
8 |
9 | protected schema: ExtenderGenerationSchema = {
10 | extenderDef: {
11 | extender: {
12 | className: '\\Flarum\\Extend\\Console',
13 | },
14 | methodCalls: [
15 | {
16 | methodName: 'command',
17 | args: [
18 | {
19 | type: ExpressionType.CLASS_CONST,
20 | value: '${commandClass}',
21 | auxiliaryValue: 'class',
22 | },
23 | ],
24 | },
25 | ],
26 | },
27 | params: [
28 | {
29 | name: 'commandClass',
30 | type: 'text',
31 | validate: Validator.class,
32 | message: `Command Class (${chalk.dim('Vendor\\Path\\Command')})`,
33 | },
34 | ],
35 | };
36 | }
37 |
--------------------------------------------------------------------------------
/src/steps/extenders/post-type.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../utils/validation';
2 | import { ExpressionType } from '../../providers/php-provider';
3 | import { BaseExtenderStep, ExtenderGenerationSchema } from './base';
4 | import chalk from 'chalk';
5 |
6 | export class GeneratePostTypeExtender extends BaseExtenderStep {
7 | type = 'Generate Post Type extender';
8 |
9 | protected schema: ExtenderGenerationSchema = {
10 | extenderDef: {
11 | extender: {
12 | className: '\\Flarum\\Extend\\Post',
13 | },
14 | methodCalls: [
15 | {
16 | methodName: 'type',
17 | args: [
18 | {
19 | type: ExpressionType.CLASS_CONST,
20 | value: '${postClass}',
21 | auxiliaryValue: 'class',
22 | },
23 | ],
24 | },
25 | ],
26 | },
27 | params: [
28 | {
29 | name: 'postClass',
30 | type: 'text',
31 | validate: Validator.class,
32 | message: `Post Class (${chalk.dim('Vendor\\Path\\Event')})`,
33 | },
34 | ],
35 | };
36 | }
37 |
--------------------------------------------------------------------------------
/src/steps/extenders/search-driver.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../utils/validation';
2 | import { ExpressionType } from '../../providers/php-provider';
3 | import { BaseExtenderStep, ExtenderGenerationSchema } from './base';
4 | import chalk from 'chalk';
5 |
6 | export class GenerateSearchDriverExtender extends BaseExtenderStep {
7 | type = 'Generate Search Driver extender';
8 |
9 | protected schema: ExtenderGenerationSchema = {
10 | extenderDef: {
11 | extender: {
12 | className: '\\Flarum\\Extend\\SearchDriver',
13 | args: [
14 | {
15 | type: ExpressionType.CLASS_CONST,
16 | value: '${driverClass}',
17 | auxiliaryValue: 'class',
18 | },
19 | ],
20 | },
21 | methodCalls: [],
22 | },
23 | params: [
24 | {
25 | name: 'driverClass',
26 | type: 'text',
27 | validate: Validator.class,
28 | message: `Driver Class (${chalk.dim('Vendor\\Path\\Event')})`,
29 | },
30 | ],
31 | };
32 | }
33 |
--------------------------------------------------------------------------------
/src/steps/extenders/service-provider.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../utils/validation';
2 | import { ExpressionType } from '../../providers/php-provider';
3 | import { BaseExtenderStep, ExtenderGenerationSchema } from './base';
4 | import chalk from 'chalk';
5 |
6 | export class GenerateServiceProviderExtender extends BaseExtenderStep {
7 | type = 'Generate Service Provider extender';
8 |
9 | protected schema: ExtenderGenerationSchema = {
10 | extenderDef: {
11 | extender: {
12 | className: '\\Flarum\\Extend\\ServiceProvider',
13 | },
14 | methodCalls: [
15 | {
16 | methodName: 'register',
17 | args: [
18 | {
19 | type: ExpressionType.CLASS_CONST,
20 | value: '${providerClass}',
21 | auxiliaryValue: 'class',
22 | },
23 | ],
24 | },
25 | ],
26 | },
27 | params: [
28 | {
29 | name: 'providerClass',
30 | type: 'text',
31 | validate: Validator.class,
32 | message: `Provider Class (${chalk.dim('Vendor\\Path\\Event')})`,
33 | },
34 | ],
35 | };
36 | }
37 |
--------------------------------------------------------------------------------
/src/steps/misc/composer.ts:
--------------------------------------------------------------------------------
1 | import { execSync } from 'child_process';
2 | import { Store } from 'mem-fs';
3 | import { IO } from 'boilersmith/io';
4 | import { Paths } from 'boilersmith/paths';
5 | import { DefaultProviders, Step } from 'boilersmith/step-manager';
6 |
7 | export class ComposerInstall implements Step {
8 | type = 'Run composer install/update';
9 |
10 | composable = false;
11 |
12 | async run(fs: Store, paths: Paths, _paramProvider: IO, _providers: DefaultProviders): Promise {
13 | execSync('composer update', { cwd: paths.package('') });
14 |
15 | return fs;
16 | }
17 |
18 | exposes = [];
19 |
20 | getExposed(): Record {
21 | return {};
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/steps/misc/git.ts:
--------------------------------------------------------------------------------
1 | import { Store } from 'mem-fs';
2 | import { IO } from 'boilersmith/io';
3 | import { Paths } from 'boilersmith/paths';
4 | import { DefaultProviders, Step } from 'boilersmith/step-manager';
5 | import simpleGit from 'simple-git';
6 |
7 | export class GitInit implements Step {
8 | type = 'Run git init';
9 |
10 | composable = false;
11 |
12 | async run(fs: Store, paths: Paths, _paramProvider: IO, _providers: DefaultProviders): Promise {
13 | simpleGit(paths.package()).init();
14 |
15 | return fs;
16 | }
17 |
18 | exposes = [];
19 |
20 | getExposed(): Record {
21 | return {};
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/steps/misc/npm.ts:
--------------------------------------------------------------------------------
1 | import { execSync } from 'child_process';
2 | import { Store } from 'mem-fs';
3 | import { IO } from 'boilersmith/io';
4 | import { Paths } from 'boilersmith/paths';
5 | import { DefaultProviders, Step } from 'boilersmith/step-manager';
6 |
7 | export class NpmInstall implements Step {
8 | type = 'Run npm install';
9 |
10 | composable = false;
11 |
12 | async run(fs: Store, paths: Paths, _paramProvider: IO, _providers: DefaultProviders): Promise {
13 | execSync('npm install', { cwd: paths.package('js') });
14 |
15 | return fs;
16 | }
17 |
18 | exposes = [];
19 |
20 | getExposed(): Record {
21 | return {};
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/steps/misc/yarn.ts:
--------------------------------------------------------------------------------
1 | import { execSync } from 'child_process';
2 | import { Store } from 'mem-fs';
3 | import { IO } from 'boilersmith/io';
4 | import { Paths } from 'boilersmith/paths';
5 | import { DefaultProviders, Step } from 'boilersmith/step-manager';
6 |
7 | export class YarnInstall implements Step {
8 | type = 'Run yarn install';
9 |
10 | composable = false;
11 |
12 | async run(fs: Store, paths: Paths, _paramProvider: IO, _providers: DefaultProviders): Promise {
13 | execSync('yarn install', { cwd: paths.package('js') });
14 |
15 | return fs;
16 | }
17 |
18 | exposes = [];
19 |
20 | getExposed(): Record {
21 | return {};
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/steps/stubs/backend/controller.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../../utils/validation';
2 | import { BasePhpStubStep } from '../php-base';
3 |
4 | export class GenerateControllerStub extends BasePhpStubStep {
5 | type = 'Generate Controller Class';
6 |
7 | protected additionalExposes = ['frontend'];
8 |
9 | protected phpClassParams = [];
10 |
11 | protected schema = {
12 | recommendedSubdir: 'Controller',
13 | sourceFile: 'backend/controller.php',
14 | params: [
15 | {
16 | name: 'className',
17 | type: 'text',
18 | message: 'Controller class name',
19 | validate: Validator.className,
20 | },
21 | {
22 | name: 'classNamespace',
23 | type: 'text',
24 | message: 'Class Namespace',
25 | },
26 | {
27 | name: 'frontend',
28 | type: 'autocomplete',
29 | message: 'Controller type/frontend',
30 | choices: ['forum', 'admin', 'api'].map((type: string) => ({
31 | title: type,
32 | value: type.toLowerCase(),
33 | })),
34 | },
35 | ],
36 | };
37 | }
38 |
--------------------------------------------------------------------------------
/src/steps/stubs/backend/integration-test.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../../utils/validation';
2 | import { BasePhpStubStep } from '../php-base';
3 |
4 | export class GenerateIntegrationTestStub extends BasePhpStubStep {
5 | type = 'Generate Integration Test Class';
6 |
7 | protected additionalExposes = [];
8 |
9 | protected phpClassParams = [];
10 |
11 | protected schema = {
12 | root: './tests',
13 | recommendedSubdir: 'integration.api',
14 | sourceFile: 'backend/integration-test.php',
15 | params: [
16 | {
17 | name: 'className',
18 | type: 'text',
19 | message: 'Test class name',
20 | validate: Validator.className,
21 | },
22 | {
23 | name: 'classNamespace',
24 | type: 'text',
25 | message: 'Class Namespace',
26 | },
27 | ],
28 | };
29 | }
30 |
--------------------------------------------------------------------------------
/src/steps/stubs/backend/job.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../../utils/validation';
2 | import { BasePhpStubStep } from '../php-base';
3 |
4 | export class GenerateJobStub extends BasePhpStubStep {
5 | type = 'Generate Job Class';
6 |
7 | protected schema = {
8 | recommendedSubdir: 'Job',
9 | sourceFile: 'backend/job.php',
10 | params: [
11 | {
12 | name: 'className',
13 | type: 'text',
14 | message: 'Job class name',
15 | validate: Validator.className,
16 | },
17 | {
18 | name: 'classNamespace',
19 | type: 'text',
20 | message: 'Class Namespace',
21 | },
22 | ],
23 | };
24 | }
25 |
--------------------------------------------------------------------------------
/src/steps/stubs/backend/mail-driver.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../../utils/validation';
2 | import { BasePhpStubStep } from '../php-base';
3 | import { StubGenerationSchema } from 'boilersmith/steps/stub-base';
4 |
5 | export class GenerateMailDriverStub extends BasePhpStubStep {
6 | type = 'Generate Mail Driver';
7 |
8 | additionalExposes = ['className'];
9 |
10 | protected schema: StubGenerationSchema = {
11 | recommendedSubdir: 'Mail',
12 | sourceFile: 'backend/mail-driver.php',
13 | params: [
14 | {
15 | name: 'className',
16 | type: 'text',
17 | message: 'Mail driver class name',
18 | validate: Validator.className,
19 | },
20 | {
21 | name: 'classNamespace',
22 | type: 'text',
23 | message: 'Class Namespace',
24 | },
25 | ],
26 | };
27 | }
28 |
--------------------------------------------------------------------------------
/src/steps/stubs/backend/middleware.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../../utils/validation';
2 | import { BasePhpStubStep } from '../php-base';
3 |
4 | export class GenerateMiddlewareStub extends BasePhpStubStep {
5 | type = 'Generate a middleware class';
6 |
7 | protected additionalExposes = ['className'];
8 |
9 | protected phpClassParams = [];
10 |
11 | protected schema = {
12 | recommendedSubdir: 'Middleware',
13 | sourceFile: 'backend/middleware.php',
14 | params: [
15 | {
16 | name: 'className',
17 | type: 'text',
18 | message: 'Middleware class name',
19 | validate: Validator.className,
20 | },
21 | {
22 | name: 'classNamespace',
23 | type: 'text',
24 | message: 'Class Namespace',
25 | },
26 | ],
27 | };
28 | }
29 |
--------------------------------------------------------------------------------
/src/steps/stubs/backend/notification-driver.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../../utils/validation';
2 | import { BasePhpStubStep } from '../php-base';
3 | import { StubGenerationSchema } from 'boilersmith/steps/stub-base';
4 |
5 | export class GenerateNotificationDriverStub extends BasePhpStubStep {
6 | type = 'Generate Notification Driver';
7 |
8 | additionalExposes = ['className'];
9 |
10 | protected schema: StubGenerationSchema = {
11 | recommendedSubdir: 'Notification',
12 | sourceFile: 'backend/notification-driver.php',
13 | params: [
14 | {
15 | name: 'className',
16 | type: 'text',
17 | message: 'Notification driver class name',
18 | validate: Validator.className,
19 | },
20 | {
21 | name: 'classNamespace',
22 | type: 'text',
23 | message: 'Class Namespace',
24 | },
25 | ],
26 | };
27 | }
28 |
--------------------------------------------------------------------------------
/src/steps/stubs/backend/policy.ts:
--------------------------------------------------------------------------------
1 | import chalk from 'chalk';
2 | import { Validator } from '../../../utils/validation';
3 | import { BasePhpStubStep } from '../php-base';
4 |
5 | export class GeneratePolicyStub extends BasePhpStubStep {
6 | type = 'Generate a policy Class';
7 |
8 | protected additionalExposes = ['modelClass', 'modelClassName'];
9 |
10 | protected phpClassParams = ['modelClass'];
11 |
12 | protected schema = {
13 | recommendedSubdir: 'Access',
14 | sourceFile: 'backend/policy.php',
15 | params: [
16 | {
17 | name: 'className',
18 | type: 'text',
19 | message: 'Policy class name',
20 | validate: Validator.className,
21 | },
22 | {
23 | name: 'classNamespace',
24 | type: 'text',
25 | message: 'Class Namespace',
26 | },
27 | {
28 | name: 'modelClass',
29 | type: 'text',
30 | message: `Model Class (${chalk.dim('Vendor\\Path\\Model')})`,
31 | validate: Validator.class,
32 | },
33 | {
34 | name: 'modelClassName',
35 | type: 'text',
36 | message: 'Class Namespace',
37 | },
38 | ],
39 | };
40 | }
41 |
--------------------------------------------------------------------------------
/src/steps/stubs/backend/search-driver-searcher.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../../utils/validation';
2 | import { BasePhpStubStep } from '../php-base';
3 |
4 | export class GenerateSearchDriverAbstractModelSearcherStub extends BasePhpStubStep {
5 | type = 'Generate Search Driver abstract model searcher class';
6 |
7 | protected additionalExposes = [];
8 |
9 | protected phpClassParams = [];
10 |
11 | protected schema = {
12 | recommendedSubdir: 'Search',
13 | sourceFile: 'backend/search/searcher.php',
14 | params: [
15 | {
16 | name: 'className',
17 | type: 'text',
18 | message: 'Driver model searcher abstract class name',
19 | validate: Validator.className,
20 | initial: 'Searcher',
21 | },
22 | {
23 | name: 'classNamespace',
24 | type: 'text',
25 | message: 'Class Namespace',
26 | },
27 | ],
28 | };
29 | }
30 |
--------------------------------------------------------------------------------
/src/steps/stubs/backend/service-provider.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../../utils/validation';
2 | import { BasePhpStubStep } from '../php-base';
3 |
4 | export class GenerateServiceProviderStub extends BasePhpStubStep {
5 | type = 'Generate Service Provider Class';
6 |
7 | protected schema = {
8 | recommendedSubdir: '',
9 | sourceFile: 'backend/service-provider.php',
10 | params: [
11 | {
12 | name: 'className',
13 | type: 'text',
14 | message: 'Provider class name',
15 | validate: Validator.className,
16 | },
17 | {
18 | name: 'classNamespace',
19 | type: 'text',
20 | message: 'Class Namespace',
21 | },
22 | ],
23 | };
24 | }
25 |
--------------------------------------------------------------------------------
/src/steps/stubs/backend/validator.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../../utils/validation';
2 | import { BasePhpStubStep } from '../php-base';
3 |
4 | export class GenerateValidatorStub extends BasePhpStubStep {
5 | type = 'Generate Validator Class';
6 |
7 | protected schema = {
8 | recommendedSubdir: '',
9 | sourceFile: 'backend/validator.php',
10 | params: [
11 | {
12 | name: 'className',
13 | type: 'text',
14 | message: 'Validator class name',
15 | validate: Validator.className,
16 | },
17 | {
18 | name: 'classNamespace',
19 | type: 'text',
20 | message: 'Class Namespace',
21 | },
22 | ],
23 | };
24 | }
25 |
--------------------------------------------------------------------------------
/src/steps/stubs/flarum-base.ts:
--------------------------------------------------------------------------------
1 | import { IO } from 'boilersmith/io';
2 | import { Paths } from 'boilersmith/paths';
3 | import { BaseStubStep } from 'boilersmith/steps/stub-base';
4 | import { Store } from 'mem-fs';
5 | import { FlarumProviders } from '../../providers';
6 | import { ExtensionModules, ExtensionParams } from '../gen-ext-scaffolder';
7 |
8 | export abstract class FlarumBaseStubStep extends BaseStubStep {
9 | protected async precompileParams(fs: Store, paths: Paths, io: IO): Promise> {
10 | return {
11 | ...(await super.precompileParams(fs, paths, io)),
12 | extensionId: await this.scaffolder.templateParamVal('extensionId', fs, paths, io),
13 | packageNamespace: await this.scaffolder.templateParamVal('packageNamespace', fs, paths, io),
14 | };
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/steps/stubs/frontend/component.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../../utils/validation';
2 | import { BaseJsStubStep } from '../js-base';
3 |
4 | export class GenerateComponentStub extends BaseJsStubStep {
5 | type = 'Generate a Component';
6 |
7 | protected additionalExposes = ['frontend'];
8 |
9 | protected schema = {
10 | recommendedSubdir: '${frontend}/components',
11 | sourceFile: 'frontend/component.js',
12 | params: [
13 | {
14 | name: 'frontend',
15 | type: 'text',
16 | message: 'Frontend name',
17 | },
18 | {
19 | name: 'className',
20 | type: 'text',
21 | message: 'Component class name',
22 | validate: Validator.className,
23 | },
24 | {
25 | name: 'classNamespace',
26 | type: 'text',
27 | message: 'Class Namespace',
28 | },
29 | ],
30 | };
31 | }
32 |
--------------------------------------------------------------------------------
/src/steps/stubs/frontend/modal.ts:
--------------------------------------------------------------------------------
1 | import { Validator } from '../../../utils/validation';
2 | import { BaseJsStubStep } from '../js-base';
3 |
4 | export class GenerateModalStub extends BaseJsStubStep {
5 | type = 'Generate Modal Component';
6 |
7 | protected additionalExposes = ['frontend'];
8 |
9 | protected schema = {
10 | recommendedSubdir: '${frontend}/components',
11 | sourceFile: 'frontend/modal.js',
12 | params: [
13 | {
14 | name: 'frontend',
15 | type: 'text',
16 | message: 'Frontend name',
17 | },
18 | {
19 | name: 'className',
20 | type: 'text',
21 | message: 'Modal class name',
22 | validate: Validator.className,
23 | },
24 | {
25 | name: 'classNamespace',
26 | type: 'text',
27 | message: 'Class Namespace',
28 | },
29 | ],
30 | };
31 | }
32 |
--------------------------------------------------------------------------------
/src/steps/upgrade/twopointoh/frontend/format.ts:
--------------------------------------------------------------------------------
1 | import { BaseUpgradeStep, GitCommit, Replacement } from '../base';
2 | import { formatCode } from '../../../../utils/ast';
3 |
4 | export default class FormatCode extends BaseUpgradeStep {
5 | type = 'Prettier formatting.';
6 |
7 | replacements(file: string): Replacement[] {
8 | if (!file.endsWith('.js') && !file.endsWith('.ts') && !file.endsWith('.tsx') && !file.endsWith('.jsx')) return [];
9 |
10 | return [
11 | async (_file, code) => ({
12 | updated: await formatCode(code, false),
13 | }),
14 | ];
15 | }
16 |
17 | targets(): string[] {
18 | return ['js/src/**/*'];
19 | }
20 |
21 | gitCommit(): GitCommit {
22 | return {
23 | message: 'chore(2.0): code formatting with prettier',
24 | description: 'Start by formatting your code with Prettier.',
25 | };
26 | }
27 |
28 | pauseMessage(): string {
29 | return `Your code has been formatted with Prettier before proceeding with the upgrade.`;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/utils/migration.ts:
--------------------------------------------------------------------------------
1 | const pad = (val: number, len: number) => String(val).padStart(len, '0');
2 |
3 | export function getNextMigrationName(currNames: string[], name: string): string {
4 | const cleanedName = name.toLowerCase().replace(/ /g, '_');
5 | let number = 0;
6 |
7 | for (const migration of currNames.sort().reverse()) {
8 | const match = migration.match(/^(\d{4})_(\d{2})_(\d{2})_(\d{6})_(.*)\.php/);
9 | if (!match) continue;
10 |
11 | const now = new Date();
12 |
13 | if (
14 | Number.parseInt(match[1], 10) === now.getFullYear() &&
15 | Number.parseInt(match[2], 10) === now.getMonth() + 1 &&
16 | Number.parseInt(match[3], 10) === now.getDate()
17 | ) {
18 | number = Number.parseInt(match[4], 10) + 1;
19 | break;
20 | }
21 | }
22 |
23 | const now = new Date();
24 |
25 | return `${pad(now.getFullYear(), 4)}_${pad(now.getMonth() + 1, 2)}_${pad(now.getDate(), 2)}_${pad(number, 6)}_${cleanedName}`;
26 | }
27 |
--------------------------------------------------------------------------------
/src/utils/model-name.ts:
--------------------------------------------------------------------------------
1 | import pluralize from 'pluralize';
2 | import s from 'string';
3 |
4 | export function pluralSnakeCaseModel(className: string): string {
5 | let name: string;
6 |
7 | name = s(className).underscore().toString();
8 | name = pluralize((name as string).replace('_', ' ')).replace(' ', '_');
9 |
10 | return name;
11 | }
12 |
13 | export function pluralKebabCaseModel(className: string): string {
14 | className = pluralize(className.charAt(0).toLowerCase() + className.slice(1));
15 | className = s(className).dasherize().s;
16 |
17 | return className;
18 | }
19 |
20 | export function kebab(className: string): string {
21 | return s(className.charAt(0).toLowerCase() + className.slice(1)).dasherize().s;
22 | }
23 |
--------------------------------------------------------------------------------
/src/utils/monorepo.ts:
--------------------------------------------------------------------------------
1 | import { Store } from 'mem-fs';
2 | import { Paths } from 'boilersmith/paths';
3 | import { create } from 'mem-fs-editor';
4 |
5 | export function npmPath(name: string): string {
6 | return `js-packages/${name}`;
7 | }
8 |
9 | export function composerPath(name: string): string {
10 | return `php-packages/${name}`;
11 | }
12 |
13 | export function extensionPath(name: string): string {
14 | return `extensions/${name}`;
15 | }
16 |
17 | export function corePath(_name: string): string {
18 | return 'framework/core';
19 | }
20 |
21 | type PackageInfo = {
22 | name: string;
23 | gitRemote: string;
24 |
25 | /**
26 | * Defaults to `main`.
27 | */
28 | mainBranch?: string;
29 | };
30 |
31 | export type FlarumMonorepoJsonSchema = {
32 | packages: {
33 | core?: PackageInfo;
34 | extensions: PackageInfo[];
35 | composer?: PackageInfo[];
36 | npm?: PackageInfo[];
37 | };
38 | };
39 |
40 | export function getMonorepoConf(fs: Store, paths: Paths): FlarumMonorepoJsonSchema {
41 | return create(fs).readJSON(paths.package('flarum-monorepo.json')) as FlarumMonorepoJsonSchema;
42 | }
43 |
--------------------------------------------------------------------------------
/test/boilersmith/fixtures/customizable.txt:
--------------------------------------------------------------------------------
1 | {
2 | // Use Flarum's tsconfig as a starting point
3 | "extends": "flarum-tsconfig",
4 | "include": [
5 | "src/**/*",
6 | "../vendor/*/*/js/dist-typings/@types/**/*",
7 | //
8 | "something-else/**/*",
9 | //
10 | "@types/**/*",
11 | ],
12 | "compilerOptions": {
13 | // This will output typings to `dist-typings`
14 | "declarationDir": "./dist-typings",
15 | "baseUrl": ".",
16 | "paths": {
17 | "flarum/*": [
18 | "../vendor/flarum/core/js/dist-typings/*",
19 | ],
20 |
21 | "something-else/**/*": [""]
22 |
23 | }
24 | }
25 | #
26 | HELLO WORLD!!!!!
27 | #
28 | }
29 |
--------------------------------------------------------------------------------
/test/boilersmith/fixtures/example-scaffold/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/test/boilersmith/fixtures/example-scaffold/config1.json:
--------------------------------------------------------------------------------
1 | {
2 | "hello": "<%= params.someVar %>",
3 | "foo": "<%= params.someOtherVar %>",
4 | "<%= params.varKey %>++\\": "const",
5 | "authors": ["George Washington", "Alexander Hamilton", "Thomas Jefferson"],
6 | "nested": {
7 | "config": {
8 | "string": "a",
9 | "boolean": true,
10 | "null": null
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/test/boilersmith/fixtures/example-scaffold/config2.json:
--------------------------------------------------------------------------------
1 | {
2 | "hello": "world",
3 | "foo": "bar",
4 | "authors": ["George Washington", "Alexander Hamilton", "Thomas Jefferson"],
5 | "nested": {
6 | "config": {
7 | "string": "a",
8 | "boolean": true,
9 | "null": null
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/boilersmith/fixtures/example-scaffold/customizable.txt:
--------------------------------------------------------------------------------
1 | {
2 | // Use Flarum's tsconfig as a starting point
3 | "extends": "flarum-tsconfig",
4 | "include": [
5 | "src/**/*",
6 | "../vendor/*/*/js/dist-typings/@types/**/*",
7 | //
8 | //
9 | "@types/**/*",
10 | ],
11 | "compilerOptions": {
12 | // This will output typings to `dist-typings`
13 | "declarationDir": "./dist-typings",
14 | "baseUrl": ".",
15 | "paths": {
16 | "flarum/*": [
17 | "../vendor/flarum/core/js/dist-typings/*",
18 | ],
19 |
20 | "hello": world
21 |
22 | }
23 | }
24 | #
25 | testing123
26 | #
27 | }
28 |
--------------------------------------------------------------------------------
/test/boilersmith/fixtures/example-scaffold/monorepo-only.ml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flarum/cli/4f706c0df3c65be916c8ad0c43bc14830697dbff/test/boilersmith/fixtures/example-scaffold/monorepo-only.ml
--------------------------------------------------------------------------------
/test/boilersmith/fixtures/example-scaffold/readme.md:
--------------------------------------------------------------------------------
1 | # Sample Scaffolding
2 |
--------------------------------------------------------------------------------
/test/boilersmith/fixtures/example-scaffold/src/index.html:
--------------------------------------------------------------------------------
1 | <%= params.someVar %>
2 |
--------------------------------------------------------------------------------
/test/boilersmith/fixtures/example-scaffold/src/index.js:
--------------------------------------------------------------------------------
1 | <%= params.someVar %>
--------------------------------------------------------------------------------
/test/boilersmith/fixtures/example-scaffold/src/index.ml:
--------------------------------------------------------------------------------
1 | <%= params.someVar %>
--------------------------------------------------------------------------------
/test/boilersmith/fixtures/example-scaffold/src/index.php:
--------------------------------------------------------------------------------
1 | <%= params.someVar %>
--------------------------------------------------------------------------------
/test/boilersmith/fixtures/sample.tpl:
--------------------------------------------------------------------------------
1 | Hello world!
2 |
3 | <%= requiredMessage %>
--------------------------------------------------------------------------------
/test/boilersmith/utils/cond-format.test.ts:
--------------------------------------------------------------------------------
1 | import { condFormat } from 'boilersmith/utils/cond-format';
2 |
3 | describe('cond-format', function () {
4 | it('works when true', function () {
5 | const result = condFormat(true, () => 'foo', 'bar');
6 | expect(result).toStrictEqual('foo');
7 | });
8 |
9 | it('works when false', function () {
10 | const result = condFormat(false, () => 'foo', 'bar');
11 | expect(result).toStrictEqual('bar');
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/test/boilersmith/utils/read-tpl.test.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'path';
2 | import { readTpl } from 'boilersmith/utils/read-tpl';
3 |
4 | describe('read-tpl', function () {
5 | it('errors when data missing', function () {
6 | expect(() => {
7 | readTpl(resolve(__dirname, '../fixtures.sample.tpl'), {});
8 | }).toThrow();
9 | });
10 |
11 | it('works with data provided', function () {
12 | const content = readTpl(resolve(__dirname, '../fixtures/sample.tpl'), { requiredMessage: 'Flarum is great!' });
13 |
14 | expect(content).toStrictEqual('Hello world!\n\nFlarum is great!');
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/test/boilersmith/utils/rename-keys.test.ts:
--------------------------------------------------------------------------------
1 | import { renameKeys } from 'boilersmith/utils/rename-keys';
2 |
3 | describe('rename-keys', function () {
4 | it('works', function () {
5 | const renamed = renameKeys({ a: 'test', b: 'test2' }, (k) => `--${k}`);
6 |
7 | expect(renamed).toStrictEqual({
8 | '--a': 'test',
9 | '--b': 'test2',
10 | });
11 | });
12 | });
13 |
--------------------------------------------------------------------------------
/test/provider/path-provider.test.ts:
--------------------------------------------------------------------------------
1 | import path from 'path';
2 | import { NodePaths } from 'boilersmith/paths';
3 |
4 | describe('NodePaths Works', function () {
5 | test('Returns paths as expected', async function () {
6 | const provider = new NodePaths({
7 | package: '/',
8 | requestedDir: '/tmp',
9 | });
10 |
11 | expect(provider.cwd('file.php')).toStrictEqual(path.resolve(process.cwd(), 'file.php'));
12 | expect(provider.package('composer/composer.json')).toStrictEqual('/composer/composer.json');
13 | expect(provider.requestedDir('file2.php')).toStrictEqual('/tmp/file2.php');
14 | });
15 |
16 | test('Returns null if requestedDir not provided', async function () {
17 | const provider = new NodePaths({
18 | package: '/',
19 | });
20 |
21 | expect(provider.requestedDir('file.php')).toBe(null);
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/test/steps/gen-ext-scaffolder.test.ts:
--------------------------------------------------------------------------------
1 | import { genExtScaffolder } from '../../src/steps/gen-ext-scaffolder';
2 |
3 | describe('genExtScaffolder', function () {
4 | it('validates', async function () {
5 | const scaffolder = genExtScaffolder();
6 |
7 | await scaffolder.validate();
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/test/utils.ts:
--------------------------------------------------------------------------------
1 | import { ExtenderDef, PhpProvider } from '../src/providers/php-provider';
2 |
3 | export function stubPhpProviderFactory(): PhpProvider {
4 | return {
5 | withExtender(extendContents: string, _extenderDef: ExtenderDef): string {
6 | return extendContents;
7 | },
8 | run(_command: string, _args: Record): Record {
9 | return {};
10 | },
11 | };
12 | }
13 |
--------------------------------------------------------------------------------
/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | // tsconfig.build.json
2 | {
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "rootDir": "src",
6 | "outDir": "./lib"
7 | },
8 | "include": ["src/**/*"],
9 | "exclude": ["test/**/*"]
10 | }
11 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "declaration": true,
4 | "esModuleInterop": true,
5 | "importHelpers": true,
6 | "module": "commonjs",
7 | "rootDir": ".",
8 | "strict": true,
9 | "target": "es2017",
10 | "typeRoots": ["./node_modules/@types", "./types/"],
11 | "baseUrl": "./",
12 | "paths": {
13 | "boilersmith/*": ["src/boilersmith/*"]
14 | },
15 | "skipLibCheck": true,
16 | "resolveJsonModule": true
17 | },
18 | "include": ["src/**/*", "test/**/*"],
19 | "exclude": ["node_modules", "lib", "dist"]
20 | }
21 |
--------------------------------------------------------------------------------