Slide 1

Slide 1 text

Sidekick by @passsy (Pascal Welsch) sidekick A CLI for your app

Slide 2

Slide 2 text

Sidekick by @passsy (Pascal Welsch) Your app deserves its own CLI: Try sidekick Pascal Welsch Google Developer Expert Co-Founder of wiredash.io CTO at phntm GmbH Droidcon London 2022 @passsy

Slide 3

Slide 3 text

Sidekick by @passsy (Pascal Welsch)

Slide 4

Slide 4 text

Sidekick by @passsy (Pascal Welsch) PHNTM ['fæntəm] Flutter Agency with 15 Flutter Experts from all across Germany

Slide 5

Slide 5 text

Sidekick by @passsy (Pascal Welsch) Automating our workday at PHNTM - Get dependencies for all packages - Bump app version - Update localization files - Create release notes with Jira tickets from merged PR descriptions - Standup: What are open PRs across multiple repos? - Publish releases

Slide 6

Slide 6 text

Sidekick by @passsy (Pascal Welsch) Where to place the automation code?

Slide 7

Slide 7 text

Sidekick by @passsy (Pascal Welsch) Bash scripts Pros: - Run everywhere (even on Windows) - No installation required - No compilation Cons: - Hard to write (unknown feature set) - Hard to read - No dependency management - No debugger - No testing

Slide 8

Slide 8 text

Sidekick by @passsy (Pascal Welsch) Gradle scripts Pros: - stable framework - bash entry, downloads gradle jar on demand - Debugging possible - Testing possible Cons: - Requires a JRE installed - Gradle is a build system, not a CLI - Flutter/Dart are not compatible with Gradle

Slide 9

Slide 9 text

Sidekick by @passsy (Pascal Welsch) Dart scripts in /tool Pros: - Dart is easy to read and write for everyone - pub dependency manager - Rich set of pub packages - Debugging - Testing Cons: - Shared dependencies with your app - functions of different scripts are hard to discover - Dart need to be installed - No fixed dart version for execution

Slide 10

Slide 10 text

Sidekick by @passsy (Pascal Welsch) sidekick

Slide 11

Slide 11 text

Sidekick by @passsy (Pascal Welsch) Sidekick CLIs combines the best of all worlds Bash entrypoint, no other software required on system. Auto-compile on change Self-executing, automatically downloads a dart runtime, compiles the cli and executes it Dart is easy to read and write, and extendable with dependencies from pub. Support for debugging and testing comes for free

Slide 12

Slide 12 text

Sidekick by @passsy (Pascal Welsch) $ sidekick init $ dart pub global activate sidekick

Slide 13

Slide 13 text

Sidekick by @passsy (Pascal Welsch) $ sidekick init $ dart pub global activate sidekick Dart CLI generator ● With bash entrypoint ● Self executable (automatically downloads dart runtime, auto recompile) ● Build-in commands for Dart / Flutter projects ● Write your own custom commands ● Share commands with others using the plugin system

Slide 14

Slide 14 text

Sidekick by @passsy (Pascal Welsch) $ sidekick init $ dart pub global activate sidekick

Slide 15

Slide 15 text

Sidekick by @passsy (Pascal Welsch)

Slide 16

Slide 16 text

Sidekick by @passsy (Pascal Welsch) > vgs > sidekick init > y

Slide 17

Slide 17 text

Sidekick by @passsy (Pascal Welsch) > vgs > y

Slide 18

Slide 18 text

Sidekick by @passsy (Pascal Welsch)

Slide 19

Slide 19 text

Sidekick by @passsy (Pascal Welsch)

Slide 20

Slide 20 text

Sidekick by @passsy (Pascal Welsch) entrypoint Dart binary entry point Command registration Your custom commands magic bash scripts

Slide 21

Slide 21 text

Sidekick by @passsy (Pascal Welsch)

Slide 22

Slide 22 text

Sidekick by @passsy (Pascal Welsch)

Slide 23

Slide 23 text

Sidekick by @passsy (Pascal Welsch) Extending your CLI

Slide 24

Slide 24 text

Sidekick by @passsy (Pascal Welsch) Task: Build our app for web

Slide 25

Slide 25 text

Sidekick by @passsy (Pascal Welsch)

Slide 26

Slide 26 text

Sidekick by @passsy (Pascal Welsch)

Slide 27

Slide 27 text

Sidekick by @passsy (Pascal Welsch) > vgs compile takes ~5s

Slide 28

Slide 28 text

Sidekick by @passsy (Pascal Welsch) > vgs

Slide 29

Slide 29 text

Sidekick by @passsy (Pascal Welsch)

Slide 30

Slide 30 text

Sidekick by @passsy (Pascal Welsch) The Plugins System Share your commands with others

Slide 31

Slide 31 text

Sidekick by @passsy (Pascal Welsch) $ sidekick plugins install Install a sidekick plugin from pub

Slide 32

Slide 32 text

Sidekick by @passsy (Pascal Welsch) Plugin installation 1. Download the pub package 2. Get plugin dependencies with cli dart runtime 3. Execute /tool/install.dart of plugin The plugin is now free to modify the cli package - Add dependencies - Add files - Modify files (to register Commands)

Slide 33

Slide 33 text

Sidekick by @passsy (Pascal Welsch)

Slide 34

Slide 34 text

Sidekick by @passsy (Pascal Welsch) Which plugin template should I use? Allow users to edit the Command code? yes no shared-command Wanna share some code with a pub package? yes no shared-code install-only

Slide 35

Slide 35 text

Sidekick by @passsy (Pascal Welsch) Plugin template comparison install-only ● All generated code is directly accessible for devs ● Code can not be updated with pub upgrade

Slide 36

Slide 36 text

Sidekick by @passsy (Pascal Welsch) install-only plugins sidekick plugins create \ -t install-only \ --name install_only_sidekick_plugin

Slide 37

Slide 37 text

Sidekick by @passsy (Pascal Welsch)

Slide 38

Slide 38 text

Sidekick by @passsy (Pascal Welsch)

Slide 39

Slide 39 text

Sidekick by @passsy (Pascal Welsch)

Slide 40

Slide 40 text

Sidekick by @passsy (Pascal Welsch)

Slide 41

Slide 41 text

Sidekick by @passsy (Pascal Welsch) Which plugin template should I use? Allow users to edit the Command code? yes no shared-command Wanna share some code with a pub package? yes no shared-code install-only

Slide 42

Slide 42 text

Sidekick by @passsy (Pascal Welsch) Plugin template comparison shared-command install-only ● All generated code is directly accessible for devs ● Code can not be updated with pub upgrade ● The generated command code can not be modified ● The command can be update via pub ● Inject properties via Command constructor

Slide 43

Slide 43 text

Sidekick by @passsy (Pascal Welsch) shared-command plugins sidekick plugins create \ -t shared-command \ --name shared_command_sidekick_plugin

Slide 44

Slide 44 text

Sidekick by @passsy (Pascal Welsch) shared_command_sidekick_plugin/tool/install.dart

Slide 45

Slide 45 text

Sidekick by @passsy (Pascal Welsch) Which plugin template should I use? Allow users to edit the Command code? yes no shared-command Wanna share some code with a pub package? yes no shared-code install-only

Slide 46

Slide 46 text

Sidekick by @passsy (Pascal Welsch) Plugin template comparison shared-command shared-code install-only ● All generated code is directly accessible for devs ● Code can not be updated with pub upgrade ● The generated command can be modified ● Command uses reusable functionality from pub package ● The generated command code can not be modified ● The command can be update via pub ● Inject properties via Command constructor

Slide 47

Slide 47 text

Sidekick by @passsy (Pascal Welsch) shared-code plugins sidekick plugins create \ -t shared-code \ --name shared_code_sidekick_plugin

Slide 48

Slide 48 text

Sidekick by @passsy (Pascal Welsch) shared-code plugins

Slide 49

Slide 49 text

Sidekick by @passsy (Pascal Welsch) Which plugin template should I use? Allow users to edit the Command code? yes no shared-command Wanna share some code with a pub package? yes no shared-code install-only

Slide 50

Slide 50 text

Sidekick by @passsy (Pascal Welsch) Plugins can be found on pub.dev

Slide 51

Slide 51 text

Sidekick by @passsy (Pascal Welsch) github.com/phntmxyz/sidekick

Slide 52

Slide 52 text

Sidekick by @passsy (Pascal Welsch) Please share your awesome cli commands as sidekick plugins with the community! github.com/phntmxyz/sidekick

Slide 53

Slide 53 text

Sidekick by @passsy (Pascal Welsch) Your app deserves its own CLI: Try sidekick Pascal Welsch Google Developer Expert Co-Founder of wiredash.io CTO at phntm GmbH Droidcon London 2022 @passsy