Skip to content

cybertronbaka/loki

Repository files navigation

Loki

Static Badge License: MIT

Loki is a command-line interface (CLI) tool designed for managing Dart and Flutter projects featuring multiple packages.

The inspiration for Loki was drawn from melos. However, melos lacked support for running applications with distinct flavors and encountered issues with hot reloading/restarting due to detached stdin. Hence, this package was conceived.

Features

  • Running apps ☑️
    • Running apps in (debug, release, profile) ☑️
    • Running apps in flavors ☑️
  • Clean workspace ☑️
  • Fetching dependencies in workspace ☑️
  • List packages/apps in workspace ☑️
  • Run custom scripts with or without standard input ☑️
  • Validating config file ☑️

Installation

To install the package from the command line after cloning the repository:

git clone https://github.com/cybertronbaka/loki.git
dart pub global activate --source path <path to cloned directory>

Alternatively, you can install the package directly using the following command:

dart pub global activate loki

Setup

Loki is specifically engineered to function in tandem with a workspace. A workspace constitutes a directory encompassing all packages slated for simultaneous development. Its root directory should house a loki.yaml file.

Configuring the Workspace

Consider the following file structure for our example workspace:

workspace/
  loki.yaml
  apps/
    app1/
      ...
      pubspec.yaml
    app2/
      ...
      pubspec.yaml
  

Create a loki.yaml file with

loki init

or

Create a loki.yaml file manually at the root of the repository. Within this file, specify the name and packages fields:

name: <project>
description: <description>
packages:
  - apps

Usage

Adding Scripts to the Workspace

Loki extends its functionality to include valuable features such as executing scripts across all packages. For example, to perform flutter run in an app, append a new script item to your loki.yaml:

name: <project>
description: <description>
packages:
  - apps
scripts:
  run:p1:
    name: Run App1 # Optional
    description: <Description> # Optional
    exec: flutter run # Required
    working_dir: apps/app1 # Optional (Default is . )
    stdin: true # Optional
  test:
    name: Run tests
    exec: flutter test
  analyze:
    name: analyze
    exec: dart analyze
  test:analyze:1:
    exec: lkr analyze && loki run test

In this context,

  • name denotes the script's name and is optional.
  • working_dir determines where exec will be executed.
  • stdin: true enables the script to directly receive input from users through the terminal. This is particularly useful for scripts like flutter run which benefit from features like hot reload and hot restart.
  • exec field specifies the actual command that will be executed by your script. Currently, we have a single shorthand, lkr, which corresponds to the loki run command. Please note that lkr cannot be used independently in a shell; it is exclusively scoped within the context of loki run

To obtain a list of scripts, execute:

loki help run

To execute the run:p1 script, employ the following command:

loki run run:p1

To run an app

To run app app1 in flavor dev in release

loki app app1 --flavor dev -e release

or

loki app app1 -f dev -e release

To get assistance with running an app

loki app <app_name> -h

Commands

Full commands list and args can be viewed by running loki help.

> loki help

 _     ____  _  __ _ 
/ \   /  _ \/ |/ // \
| |   | / \||   / | |
| |_/\| \_/||   \ | |
\____/\____/\_|\_\\_/
                 v0.0.1

A CLI tool for managing Dart & Flutter projects with multiple packages.

Made only because running flutter apps with melos was had an issue with stdin.

Made with ❤️  by Dorji Gyeltshen ( @cybertronbaka )

Usage: loki <command> [arguments]

Global options:
-h, --help    Print this usage information.

Available commands:
  app        Runs a flutter app in the workspace
  clean      Runs `flutter clean` in all packages and apps
  fetch      Install dependencies in packages and apps
  init       Creates loki.yaml.
  list       List all local packages in apps.
  run        Run a script by name defined in the workspace loki.yaml config file.
  validate   Validate loki.yaml config file.
  version    Print version information

Run "loki help <command>" for more information about a command.

Readme badge

Using loki? Add a README badge to show it off:

Static Badge

[![Static Badge](https://img.shields.io/badge/managed_with-loki-blue)](https://pub.dev/packages/loki)

Contributing

Contributions are always welcome!

About

A CLI tool for managing Dart & Flutter projects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published