Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

3.x #41

Closed
wants to merge 33 commits into from
Closed

3.x #41

Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
854c7cd
chore: begin v3 for Flarum v2
SychO9 Mar 16, 2024
05012d7
chore: update `nikic/php-parser`
SychO9 Mar 16, 2024
2d72bcd
feat: `make api-resource`
SychO9 Mar 16, 2024
6b3529e
refactor: `make controller`
SychO9 Mar 17, 2024
f34ebb7
refactor: model make
SychO9 Mar 17, 2024
66033b1
feat: `make backend middleware`
SychO9 Mar 17, 2024
d016957
feat: JS extenders
SychO9 Mar 21, 2024
47df03b
feat: `make frontend forum-page`
SychO9 Mar 21, 2024
692bd2b
feat: `make frontend gambit`
SychO9 Mar 21, 2024
0d68b65
feat: `make backend filter`
SychO9 Mar 21, 2024
85b0c55
feat: `make backend notification-blueprint`
SychO9 Mar 21, 2024
270cc28
feat: param array as scalar arg
SychO9 Mar 21, 2024
7130a01
fix: extend.php escaped namespace (fixes #32)
SychO9 Mar 22, 2024
5f2104a
feat: improve `init` experience (fixes #38)
SychO9 Mar 22, 2024
7afaded
feat: Flarum 2.0 extension boilerplate (fixes #35)
SychO9 Mar 22, 2024
14cbc5a
feat: phpstan infra
SychO9 Mar 23, 2024
662ae57
fix: improve JS AST parsing & gen
SychO9 Mar 24, 2024
251c6b2
chore: add boilerplate `extend.js`
SychO9 Mar 24, 2024
e6db401
chore: `yarn format`
SychO9 Mar 24, 2024
71bb4e2
feat: `fl make notification`
SychO9 Mar 25, 2024
945ce69
feat: `fl make model`
SychO9 Mar 29, 2024
21e2a6e
fix: forget non-given args with interaction
SychO9 Mar 29, 2024
58964cf
chore: improve ast extender generation
SychO9 Mar 29, 2024
22d85cc
feat: `fl make post-type`
SychO9 Mar 29, 2024
0ca20d8
feat: no interaction usage
SychO9 Mar 29, 2024
374a2de
feat: forum-page no interaction usage
SychO9 Mar 29, 2024
0d0252c
feat: modal no interaction usage
SychO9 Mar 29, 2024
4980929
feat: `fl make backend notification-driver`
SychO9 Mar 29, 2024
ccd765c
feat: `fl make backend mail-driver`
SychO9 Mar 29, 2024
f886767
feat: `fl make locale`
SychO9 Mar 29, 2024
e77f416
fix: errors
SychO9 Mar 29, 2024
8d747d9
chore: `yarn format`
SychO9 Mar 30, 2024
1ff4765
feat: `fl infra frontendTesting`
SychO9 May 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2021-2022 Stichting Flarum (Flarum Foundation)
Copyright (c) 2021-2024 Stichting Flarum (Flarum Foundation)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
87 changes: 43 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
A CLI for developing Flarum extensions</p>

<p align=center>
<a href="https://oclif.io"><img alt"oclif" src="https://img.shields.io/badge/cli-oclif-brightgreen.svg"></a>
<a href="https://npmjs.org/package/@flarum/cli"><img alt"Version" src="https://img.shields.io/npm/v/@flarum/cli.svg"></a>
<a href="https://npmjs.org/package/@flarum/cli"><img alt"Downloads/week" src="https://img.shields.io/npm/dw/@flarum/cli.svg"></a>
<a href="https://github.com/flarum/cli/blob/master/package.json"><img alt"License" src="https://img.shields.io/npm/l/@flarum/cli.svg"></a>
<a href="https://oclif.io"><img alt="oclif" src="https://img.shields.io/badge/cli-oclif-brightgreen.svg"></a>
<a href="https://npmjs.org/package/@flarum/cli"><img alt="Version" src="https://img.shields.io/npm/v/@flarum/cli.svg"></a>
<a href="https://npmjs.org/package/@flarum/cli"><img alt="Downloads/week" src="https://img.shields.io/npm/dw/@flarum/cli.svg"></a>
<a href="https://github.com/flarum/cli/blob/master/package.json"><img alt="License" src="https://img.shields.io/npm/l/@flarum/cli.svg"></a>
<br>
<img width=720 src="https://sycho9.github.io/flarum-cli.svg" alt="terminal_example">
</p>
Expand Down Expand Up @@ -51,7 +51,7 @@ $ npm install -g @flarum/cli
$ flarum-cli COMMAND
running command...
$ flarum-cli (-v|--version|version)
@flarum/cli/2.0.0-beta.17 linux-x64 node-v16.13.2
@flarum/cli/3.0.0 linux-x64 node-v16.20.2
$ flarum-cli --help [COMMAND]
USAGE
$ flarum-cli COMMAND
Expand Down Expand Up @@ -85,33 +85,51 @@ The CLI has different types of commands for different tasks:

- `flarum-cli infra [MODULE] [PATH]`: Adds (or updates) infrastructure for some part of extension infrastructure. You can see all available modules by running `fl-dev infra --help`.

**Audit**: These commands help you make sure your extension is up to date.
**Audit**: These commands help you make sure your extension is up-to-date.

- `flarum-cli audit infra [--monorepo] [--fix]` Check that infrastructure files are up to date for all enabled modules.
- `flarum-cli audit infra [--monorepo] [--fix]` Check that infrastructure files are up-to-date for all enabled modules.

**Backend/Frontend Boilerplate Generation**: These commands generate boilerplate code for different parts of an extension.

- `flarum-cli make model [className] [PATH] [-n|--no-interaction]`: Generates a backend model, the corresponding table migration, policy, API resource, routes, frontend equivalent, and related extenders.
- `flarum-cli make notification [className] [PATH] [-n|--no-interaction]`: Generates a backend notification blueprint, the corresponding backend extender, and the frontend equivalent.
- `flarum-cli make post-type [className] [PATH] [-n|--no-interaction]`: Generates a post type, the corresponding extenders, and the frontend equivalent.

**Localized text generation**: This command generates a locale key-value pair for a given string.

- `flarum-cli make locale [key] [value] [PATH] [-n|--no-interaction]`

**Backend Boilerplate Generation**: Generates different types of backend classes and/or extenders, ready to be used.

- `flarum-cli make backend api-controller [PATH]`
- `flarum-cli make backend api-serializer [PATH]`
- `flarum-cli make backend api-serializer-attributes [PATH]`
- `flarum-cli make backend command [PATH]`
- `flarum-cli make backend event-listener [PATH]`
- `flarum-cli make backend handler [PATH]`
- `flarum-cli make backend integration-test [PATH]`
- `flarum-cli make backend job [PATH]`
- `flarum-cli make backend migration [PATH]`
- `flarum-cli make backend model [PATH]`
- `flarum-cli make backend policy [PATH]`
- `flarum-cli make backend repository [PATH]`
- `flarum-cli make backend route [PATH]`
- `flarum-cli make backend service-provider [PATH]`
- `flarum-cli make backend validator [PATH]`
- `flarum-cli make backend model [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make backend controller [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make backend api-resource [PATH] [-n|--no-interaction]`
- `flarum-cli make backend command [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make backend event-listener [PATH] [-n|--no-interaction]`
- `flarum-cli make backend handler [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make backend integration-test [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make backend job [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make backend migration [name] [PATH] [-n|--no-interaction]`
- `flarum-cli make backend policy [PATH] [-n|--no-interaction]`
- `flarum-cli make backend repository [PATH] [-n|--no-interaction]`
- `flarum-cli make backend route [PATH] [-n|--no-interaction]`
- `flarum-cli make backend service-provider [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make backend validator [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make backend filter [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make backend notification-blueprint [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make backend notification-driver [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make backend post-type [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make backend mail-driver [className] [PATH] [-n|--no-interaction]`

**Frontend Boilerplate Generation**: Generate frontend components/classes, ready to be used.

- `flarum-cli make frontend component [PATH]`
- `flarum-cli make frontend modal [PATH]`
- `flarum-cli make frontend model [PATH]`
- `flarum-cli make frontend component [frontend] [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make frontend modal [frontend] [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make frontend model [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make frontend forum-page [className] [routeName] [routePath] [PATH] [-n|--no-interaction]`
- `flarum-cli make frontend gambit [PATH] [-n|--no-interaction]`
- `flarum-cli make frontend notification [className] [PATH] [-n|--no-interaction]`
- `flarum-cli make frontend post-type [className] [PATH] [-n|--no-interaction]`

**Code Updates**: These commands help update extensions for newer versions of Flarum.

Expand All @@ -123,25 +141,6 @@ _And of course, you can always use the help command to see a list of all availab

All commands can use a `--no-interaction` flag to proceed with default values for prompts when possible.

## 🔥 The Most Powerful Commands

Of all the aforementioned commands, the two most powerful ones that will make a huge difference, are the extension initialisation command and the backend **model** generation command. The former obviously allows to kickstart the extension with the recommended skeleton from the Core Dev team, while the latter not only creates the backend model, it allows to create all the classes related to the model, from just its name:

- Table migration
- Policy
- API Serializer
- CRUD API Controllers
- CRUD Handlers
- Repository
- Validator
- Routes
- Related Extenders

[center]
![terminal_example](https://sycho9.github.io/flarum-cli.svg)
![example_project_with_model_command](https://lh3.googleusercontent.com/-fUnfqQ7rwyo/YQVwwm0sa0I/AAAAAAAAFfE/-o9B30M2gE8y6d3NWaVgBhYa8xEwqLuNwCLcBGAsYHQ/s16000/Screenshot%2Bfrom%2B2021-07-31%2B16-46-38.png)
[/center]

## Infrastructure Modules

If you maintain more than just a few extensions, keeping the infrastructure up to date can be very tedious.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [workflow_dispatch, push, pull_request]

jobs:
run:
uses: flarum/framework/.github/workflows/REUSABLE_backend.yml@main
uses: flarum/framework/.github/workflows/REUSABLE_backend.yml@2.x
with:
enable_backend_testing: <%= modules.backendTesting %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [workflow_dispatch, push, pull_request]

jobs:
run:
uses: flarum/framework/.github/workflows/REUSABLE_frontend.yml@main
uses: flarum/framework/.github/workflows/REUSABLE_frontend.yml@2.x
with:
enable_bundlewatch: <%= modules.bundlewatch %>
enable_prettier: <%= modules.prettier %>
Expand Down
12 changes: 12 additions & 0 deletions boilerplate/skeleton/extension/.github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Static Code Analysis

on: [workflow_dispatch, push, pull_request]

jobs:
run:
uses: flarum/framework/.github/workflows/[email protected]
with:
enable_backend_testing: false
enable_phpstan: <%= modules.phpstan %>

backend_directory: <%= params.backendDirectory %>
12 changes: 8 additions & 4 deletions boilerplate/skeleton/extension/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
"type": "flarum-extension",
"license": "<%= params.licenseType %>",
"require": {
"flarum/core": "^1.2.0"
"flarum/core": "^2.0"
},
"require-dev": {
"flarum/testing": "^1.0.0"
"flarum/testing": "^2.0",
"flarum/phpstan": "^2.0"
},
"authors": [<% if (params.authorName) { %>
{
Expand Down Expand Up @@ -49,13 +50,16 @@
],
"test:unit": "phpunit -c tests/phpunit.unit.xml",
"test:integration": "phpunit -c tests/phpunit.integration.xml",
"test:setup": "@php tests/integration/setup.php"
"test:setup": "@php tests/integration/setup.php",
"analyse:phpstan": "phpstan analyse",
"clear-cache:phpstan": "phpstan clear-result-cache"
},
"scripts-descriptions": {
"test": "Runs all tests.",
"test:unit": "Runs all unit tests.",
"test:integration": "Runs all integration tests.",
"test:setup": "Sets up a database for use with integration tests. Execute this only once."
"test:setup": "Sets up a database for use with integration tests. Execute this only once.",
"analyse:phpstan": "Run static analysis"
},
"minimum-stability": "dev",
"prefer-stable": true
Expand Down
2 changes: 1 addition & 1 deletion boilerplate/skeleton/extension/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"devDependencies": {
"@flarum/prettier-config": "^1.0.0",
"flarum-tsconfig": "^1.0.2",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"prettier": "^2.5.1",
"typescript": "^4.5.4",
"typescript-coverage-report": "^0.6.1",
Expand Down
8 changes: 8 additions & 0 deletions boilerplate/skeleton/extension/js/src/admin/extend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Extend from 'flarum/common/extenders';
import commonExtend from '../common/extend';

export default [
...commonExtend,

// Add your admin extenders here
];
8 changes: 8 additions & 0 deletions boilerplate/skeleton/extension/js/src/admin/extend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Extend from 'flarum/common/extenders';
import commonExtend from '../common/extend';

export default [
...commonExtend,

// Add your admin extenders here
];
2 changes: 2 additions & 0 deletions boilerplate/skeleton/extension/js/src/admin/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import app from 'flarum/admin/app';

export { default as extend } from './extend';

app.initializers.add('<%= params.packageName %>', () => {
console.log('[<%= params.packageName %>] Hello, admin!');
});
2 changes: 2 additions & 0 deletions boilerplate/skeleton/extension/js/src/admin/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import app from 'flarum/admin/app';

export { default as extend } from './extend';

app.initializers.add('<%= params.packageName %>', () => {
console.log('[<%= params.packageName %>] Hello, admin!');
});
5 changes: 5 additions & 0 deletions boilerplate/skeleton/extension/js/src/common/extend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Extend from 'flarum/common/extenders';

export default [
// Add your common extenders here
];
5 changes: 5 additions & 0 deletions boilerplate/skeleton/extension/js/src/common/extend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Extend from 'flarum/common/extenders';

export default [
// Add your common extenders here
];
2 changes: 1 addition & 1 deletion boilerplate/skeleton/extension/js/src/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import app from 'flarum/common/app';

app.initializers.add('<%= params.packageName %>', () => {
app.initializers.add('<%= params.packageName %>-common', () => {
console.log('[<%= params.packageName %>] Hello, forum and admin!');
});
8 changes: 8 additions & 0 deletions boilerplate/skeleton/extension/js/src/forum/extend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Extend from 'flarum/common/extenders';
import commonExtend from '../common/extend';

export default [
...commonExtend,

// Add your forum extenders here
];
8 changes: 8 additions & 0 deletions boilerplate/skeleton/extension/js/src/forum/extend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Extend from 'flarum/common/extenders';
import commonExtend from '../common/extend';

export default [
...commonExtend,

// Add your forum extenders here
];
2 changes: 2 additions & 0 deletions boilerplate/skeleton/extension/js/src/forum/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import app from 'flarum/forum/app';

export { default as extend } from './extend';

app.initializers.add('<%= params.packageName %>', () => {
console.log('[<%= params.packageName %>] Hello, forum!');
});
2 changes: 2 additions & 0 deletions boilerplate/skeleton/extension/js/src/forum/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import app from 'flarum/forum/app';

export { default as extend } from './extend';

app.initializers.add('<%= params.packageName %>', () => {
console.log('[<%= params.packageName %>] Hello, forum!');
});
12 changes: 12 additions & 0 deletions boilerplate/skeleton/extension/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
includes:
- vendor/flarum/phpstan/extension.neon

parameters:
level: 6
paths:
- extend.php
- src
excludePaths:
- *.blade.php
checkMissingIterableValueType: false
databaseMigrationsPath: ['migrations']
53 changes: 0 additions & 53 deletions boilerplate/stubs/backend/api-controller/create.php

This file was deleted.

Loading
Loading