📣 The Announcement
Supporting our extension ecosystem in building even more awesome extensions, is something we firmly believe in. As such @askvortsov has been hammering away at this project (RFC: Flarum CLI Alpha, Flarum CLI Dev Diary), setting up a solid foundation for it to create a powerful tool for extension development that would help developers by automating some repetitive and menial tasks, and allow them to get into the actual work without much hassle.
Today, we're very excited to announce the 1.0 version of this tool, it comes with a range of commands to assist you along the way.
📥 Installation
Using npm simply run the following command to install the CLI globally.
If you have the alpha version installed, remove it first:
$ npm uninstall -g flarum-cli
Now install the new package:
$ npm install -g @flarum/cli
To run a command, use either flarum-cli
or fl
:
$ flarum-cli COMMAND
$ fl COMMAND
To see a list of available commands, run either of:
$ flarum-cli
$ flarum-cli --help
⬆️ Updating
$ npm update -g @flarum/cli
🌟 Highlights
The CLI has different types of commands for different tasks:
Initialisation
flarum-cli init [PATH]
: Generates a blank extension skeleton, including all recommended infrastructure.
Infrastructure
flarum-cli infra backend-testing [PATH]
: Adds (or updates) infrastructure for running automated backend tests.
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]
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]
Code Updates:
flarum-cli update js-imports [PATH]
: Adds admin/forum/common namespaces to all JS imports from flarum core.
And of course, you can always use the help command to see a list of all available commands with their descriptions:
flarum-cli help [COMMAND]
🔥 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
🧑🏭 Support & Feedback
If you encounter any problems while using the CLI, or would like to propose additional features/commands, please open an issue in the github repository.
Any and all feedback is appreciated.
Links