Giter Site home page Giter Site logo

sidekick's Introduction

Sidekick

Dart CLI generator for Flutter and Dart apps - extend your project with custom tasks, add a sidekick to your app.

Write your automation scripts in Dart - a language all your coworkers are comfortable with - while fully supporting debugging and testing without losing the simplicity of executing shell scripts.

Awesome examples

  • Deployment scripts with multi-dimension build flavors
  • Bump the version of your packages at once
  • Generate release notes by combining merged PRs and completed JIRA issues
  • Fix broken generated build_runner code while waiting for a fix to be merged
  • Update GraphQL schemas
  • Create init scripts for coworkers to set up their environment

Getting Started

Create your first CLI

Install the CLI generator sidekick. This is only required for generation, not for the execution of the CLI.

dart pub global activate sidekick

Initialize project

sidekick init <path-to-repo> 

Follow the instructions and you just created your first sidekick CLI. You can execute your CLI right away using its entrypoint and use any of the existing tasks.

Assuming your CLI is called flg (short for flutter gallery), execute the flg shell script in the root of your repository.

$ ./flg

A sidekick CLI to equip Dart/Flutter projects with custom tasks

Usage: flg <command> [arguments]

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

Available commands:
  analyze          Dart analyzes the whole project
  clean            Cleans the project
  dart             Calls dart
  deps             Gets dependencies for all packages
  format           Formats all Dart files in the project
  flutter          Call the Flutter SDK associated with the project
  sidekick         Manages the sidekick CLI

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

Plugins

Our Favorite Plugins

Plugin Description
sidekick_vault Store project secrets encrypted in your repository
dockerize_sidekick_plugin Wrap your Flutter Web App in a docker container
flutterw_sidekick_plugin Pin a Flutter version to your project and share it with your team

See the full list of available plugins

To write your own plugin checkout the docs.

Install plugin

To install more command, you can use install plugins with

$ <cli> sidekick plugins install <pub-package>

Preinstalled commands

analyze

Runs the analyzer for all packages in the project.

dart

Runs the bundled dart runtime with any arguments. By calling flg dart you make sure to always use the correct dart version anyone else in your project is using.

clean

Deletes the build directory of the main application. This commands code is part of your CLI, intended to be modified to your needs.

deps

Gets all dependencies for all packages in your project. This will become your most used command in no time!

format

Formats all Dart files in the project. Default is 80. Change the line length for a specific package by adding the following to the pubspec.yaml of the package:

format:
  line-length: 120

flutter

Runs the bundled flutter runtime (provided via flutter-wrapper) with any arguments. By calling flg flutter you make sure to always use the correct flutter version, like anyone else of your team.

sidekick install-global

You can execute your CLI from anywhere. To do so, run the install-global command and follow the instructions.

$ ./flg sidekick install-global

Please add $HOME/.sidekick/bin to your PATH. 
Add this to your shell's config file (.zshrc, .bashrc, .bash_profile, ...)

  export PATH="$PATH":"$HOME/.sidekick/bin"

Then, restart your terminal

After adjusting your PATH, you can execute the CLI from anywhere.

$ flg

sidekick plugins create

A plugin template can be generated with sidekick plugins create --template <template type> --name <plugin name>.

This plugin was generated from the template $templateType.

The --template parameter must be given one of the following values:

  • install-only
    This template is the very minimum, featuring just a tool/install.dart file that writes all code to be installed into the users sidekick CLI.

    It doesn't add a pub dependency with shared code. All code is generated in the users sidekick CLI, being fully adjustable.

  • shared-command
    This template adds a pub dependency to a shared CLI Command and registers it in the user's sidekick CLI.

    This method is designed for cases where the command might be configurable with parameters but doesn't allow users to actually change the code.

    It allows updates (via pub upgrade) without users having to touch their code.

  • shared-code
    This template adds a pub dependency and writes the code of a Command into the user's sidekick CLI as well as registers it there.

    The Command code is not shared, thus is highly customizable. But it uses shared code from the plugin package that is registered added as dependency. Update of the helper functions is possible via pub, but the actual command flow is up to the user.

sidekick plugins install

Installing a plugin from a pub server

<cli> sidekick plugins install <plugin name on pub server, e.g. sidekick_vault>

By default, pub.dev is used as pub server. A custom pub server can be used with the --hosted-url parameter.

Installing a plugin from a git repository

<cli> sidekick plugins install --source git <link to git repository>

Optional parameters:

  • --git-ref: Git branch name, tag or full commit SHA (40 characters) to be installed
  • --git-path: Path of git package in repository (use when repository root contains multiple packages)
    • e.g. ${cliNameOrNull ?? 'your_custom_sidekick_cli'} sidekick plugins install --source git --git-path sidekick_vault https://github.com/phntmxyz/sidekick

Installing a plugin from a local path

<cli> sidekick plugins install --source path <path to plugin on local machine>

recompile

The entrypoint usually automatically detects when you changed the source code of your CLI. But for rare cases (like path dependencies) it is not possible to detect changes. In those scenarios use flg recompile to force recompile your CLI.

Writing custom tasks (Commands)

Writing your own commands is done in two steps.

  1. Create a class for your new command, give it a name.
import 'package:sidekick_core/sidekick_core.dart';

class YourCommand extends Command {
  @override
  String get description => 'does foo';

  @override
  String get name => 'foo';
  
  @override
  Future<void> run() async {
    // your custom code here
  }
}
  1. Register your new command in the packages/flg_sidekick/lib/flg_sidekick.dart file by adding it to the runner
// Generated by `sidekick init`
Future<void> runFlg(List<String> args) async {
  final runner = initializeSidekick(mainProjectPath: '.');

  runner
    ..addCommand(FlutterCommand())
    //.. more commands
    ..addCommand(InstallGlobalCommand())
    ..addCommand(YourCommand()); // <-- Register your own command

  //...

Handling arguments

The sidekick CLI is based on package:args. Use the existing argParser of Command to define and parse the arguments of your command.

class EchoTextCommand extends Command {
  @override
  String get name => 'echo-text';

  @override
  String get description => 'Echos the text';

  EchoTextCommand() {
    argParser.addOption('text');
  }

  @override
  Future<void> run() async {
    final cliName = argResults!['text'] as String?;
    print('echo $cliName');
  }
}
$ flg echo-text --text="Hello World"
Hello World

Motivation

Once you start automating your development workflow, you rather soon hit the limits of Bash. Not only is it hard to learn for newcomers, but also hard to understand for experienced developers. The lack of dependency management and JSON parsing are only a few reasons that rule it out as a usable scripting language.

Build systems like Gradle allow you to write your tasks. But Dart and Flutter projects are not compatible with Gradle and don't offer an easy way to add custom tasks.

While you can place your dart scripts in /tool and add dev_dependencies to your pubspec.yaml you might rather soon run into version conflicts between your app and your scripts.

Let's face it, you need a standalone dart project for your custom CLI, and sidekick does the heavy lifting for you.

Principals

The sidekick CLI is self-executable

  • Executing the CLI requires no extra dependencies. The entrypoint can be executed as shell script. That makes it easy to use on CI/CD servers.
  • By calling the entrypoint shell script, it automatically downloads a (pinned) Dart runtime and compiles the CLI project.
  • Self-executable and self-contained. Dependencies are not shared with the app.

Full control of the source code

  • Changing existing code doesn't require a PR to the sidekick project. You can customize the generated commands to your liking.
  • There is no program between your CLI and the Dart compiler that reads, alters, wraps or breaks your code.
  • You don't like how the CLI handles errors or prints the help page? You can change that, you have full control

Being able to use all the benefits of a modern language

  • Like any pure Dart program, the sidekick CLI can be executed with a debugger. No need for print statements!
  • Full IDE support and syntax highlighting
  • Full testing support. Who doesn't want unit tests for their custom tasks?

Development

Install cli locally during development

That's useful when you want to test the sidekick cli during development on your machine. Tests are great, but sometimes you want to see the beast in action.

cd sidekick
dart pub global activate -s path .

License

Copyright 2021 phntm GmbH

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

sidekick's People

Contributors

giuspepe avatar minhqdao avatar nilsreichardt avatar nohli avatar passsy avatar robiness avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sidekick's Issues

Reduce `plugins install` output

The output in the terminal when installing a plugin from pub is unbearable. We should not show the verbose output of pub global activate to the users

Fix `Sort pub dependencies.` command

Having a way to fix Sort pub dependencies. with a single command would be awesome.
Even dart fix --apply is not capable of fixing this annoyance.

`sidekick init` fails when CLI name contains underscores

sidekick_package.template.dart uses titleCase which results in syntax errors because it unexpectedly splits names with underscores into multiple words:

sidekick init -n foo_bar generates

class Foo BarProject extends DartPackage
...
factory Foo BarProject(Directory root)
...
Future<void> runFoo Bar(List<String> args) async {
...
await runFoo Bar(arguments);

Known project structures are not detected properly

When sidekick init is run in the packages directory, the project structures ProjectStructure.rootWithPackages and ProjectStructure.multiPackage aren't recognized.

How to reproduce

  1. Set up project
❯ cp -r sidekick/sidekick/test/templates/multi_package sample_project
# or cp -r sidekick/sidekick/test/templates/root_with_packages sample_project
  1. Run sidekick init in the packages directory
cd sample_project/packages
❯ sidekick init
Welcome to sidekick. You're about to initialize a sidekick project

Please select a name for your sidekick CLI.
...

Generating p_sidekick
Analyzing project structure in /Users/pepe/dev/repos/sample_project/packages
The project structure is not yet supported. Please open an issue at https://github.com/phntmxyz/sidekick/issues with details about your project structure

If sidekick init is run from sample_project instead of sample_project/packages, the project structure is detected properly and the command succeeds.

Improve `install.dart` of `shared-code` template

Right now the shared-code template generates this part in install.dart:

final commandFile = package.root.file('lib/src/my_plugin.dart');
commandFile.writeAsStringSync("""
import 'package:sidekick_core/sidekick_core.dart';
import 'package:my_plugin/my_plugin.dart';

class MyPluginCommand extends Command {
  @override
  final String description = 'Sample command';

  @override
  final String name = 'my-plugin;

  MyPluginCommand() {
    // add parameters here with argParser.addOption
  }

  @override
  Future<void> run() async {
    // please implement me
    final hello = getGreetings().shuffled().first;
    print('\\\$hello from PHNTM!');
    
    final bye = getFarewells().shuffled().first;
    print('\\\$bye from PHNTM!');
  }
}""");

It would be neat if you didn't have to copy paste the command code into install.dart, e.g.

final commandFile = package.root.file('lib/src/my_plugin.dart');
commandFile.writeAsStringSync(myPluginCommandFile.readAsStringSync());

I'm just not sure if/how we can get the correct path of myPluginCommandFile

Detect upgrade

New versions of sidekick eventually require the sidekick project to be recreated, eventually we can do the update automatically. But we need to know the version the code was generated with.

Possible solutions:

  • Create some kind of manifest where we store information
  • add something to pubspec.yaml

`sidekickDartRuntime` update check

Now that sidekick downloads its own Dart runtime, we should add a check so users can update sidekick's Dart runtime when a new version is released.

Also see discussion at #53 (comment)

Possible solution

https://storage.googleapis.com/dart-archive/channels/stable/release/latest/VERSION returns a json with the latest Dart version, e.g.

{
  "date": "2022-09-27",
  "version": "2.18.2",
  "revision": "317ad8967414ef8e5e2fca7557ec4cff4c6c9df1"
}

Insert the latest version in this url to download the latest Dart SDK: https://storage.googleapis.com/dart-archive/channels/stable/release/<dart-version>/sdk/dartsdk-<operating-system>-<architecture>-release.zip where e.g. <dart-version>: 2.18.2, <operating-system>: macos, <architecture>: arm64

VersionChecker crashes when sidekick.cli_version is not set in pubspec.yaml

$ export SIDEKICK_ENABLE_UPDATE_CHECK=true 
$ ./noa vault

Causes

Couldn't read path '['sidekick', 'cli_version']' from yaml file '/Users/pascalwelsch/Projects/noa-frontend/packages/noa_sidekick/pubspec.yaml'
#0      VersionChecker._readFromYaml (package:sidekick_core/src/version_checker.dart:166)
#1      VersionChecker.getMinimumVersionConstraint (package:sidekick_core/src/version_checker.dart:119)
#2      SidekickCommandRunner._checkCliVersionIntegrity (package:sidekick_core/sidekick_core.dart:204)
#3      SidekickCommandRunner.run (package:sidekick_core/sidekick_core.dart:167)
<asynchronous suspension>
#4      runNoa (package:noa_sidekick/noa_sidekick.dart:66)
<asynchronous suspension>
#5      main (file:///Users/pascalwelsch/Projects/noa-frontend/packages/noa_sidekick/bin/main.dart:4)
<asynchronous suspension>

Updating transitive dependency of `file`

@passsy @jxstxn1 On current flutter master there was a breaking change regarding file handling which is used in file and fixed with file 6.1.3.

file is a transitive dependency here because of dcli, which we ideally should update but it seems that we do not want that:

dcli: '>=1.15.0 <1.31.0' # 1.17 requires Dart 2.16 https://github.com/noojee/dcli/pull/192

What do you think about this? Should we update dcli anyway or dependecy_override file?

<cli> sidekick upgrade

Create an upgrade command that updates the bash scripting of the already installed cli

Unify testing utilities in a shared package

I frequently find myself copying testing utility code from one sidekick package to another sidekick package and feel like we should unify that. E.g. overrideSidekickCoreWithLocalPath exists in sidekick, sidekick_core (on branch update-command), and sidekick_plugin_installer (on branch fix-78/install-plugin-from-git-source).

Installing a plugin should be idempotence

When testing a new plugin locally i want to call plugins install multiple times to just update my plugin in the sidekick project.

plugins install always does add the command to the command list. Even though it's already present.
This leads to Invalid argument(s): Duplicate command "docker". when running the command.

image

Can i create a PR for this?

Show warning when `sidekick init` would downgrade the cli

In the past, we used sidekick init to "upgrade" a sidekick cli to the latest template version.

Now it may happen, that a user calls sidekick init with an outdated sidekick version, basically downgrading the sidekick package.

We can prevent this by checking the version in pubspec.yaml and compare it to the version of sidekick_core.

Release pipeline for sidekick CLI

We need a release pipeline for https://pub.dev/packages/sidekick

One part of the release pipeline is to lock the upper bounds of all dependencies (direct + transitive).
This is important because dart pub global activate doesn't respect the lock file of packages, so we have to do it ourselves.
Pinning the exact version is not sufficient because that may make version resolution impossible for some Dart SDK versions.

Improve error message when installing plugins

During installation of plugins we use sidekickDartRuntime to run pub get to download the dependencies of the plugin's installer. sidekickDartRuntime may depend on a different Dart SDK version than the actual sidekick CLI does. This may lead to an error like the following:

Process `/var/folders/c0/vw17q1tx6k50xkmzl4wx1pbh0000gn/T/iH2gEe/dashi sidekick plugins install flutterw_sidekick_plugin` exited with exitCode 255. Output:

    Installing flutterw_sidekick_plugin   for dashi
    Downloading from pub flutterw_sidekick_plugin...
    Running sidekickDartRuntime.dart with dart at /private/var/folders/c0/vw17q1tx6k50xkmzl4wx1pbh0000gn/T/iH2gEe/packages/dashi_sidekick/build/cache/dart-sdk/bin/dart
    Running sidekickDartRuntime.dart with dart at /private/var/folders/c0/vw17q1tx6k50xkmzl4wx1pbh0000gn/T/iH2gEe/packages/dashi_sidekick/build/cache/dart-sdk/bin/dart
    Installer downloaded
    Preparing flutterw_sidekick_plugin installer...
    Running sidekickDartRuntime.dart with dart at /private/var/folders/c0/vw17q1tx6k50xkmzl4wx1pbh0000gn/T/iH2gEe/packages/dashi_sidekick/build/cache/dart-sdk/bin/dart
    The current Dart SDK version is 2.14.0.
    
    Because dart_style >=2.2.0 <2.2.1 depends on analyzer ^2.0.0 and dart_style >=2.2.1 <2.2.2 depends on analyzer >=2.6.0 <4.0.0, dart_style >=2.2.0 <2.2.2 requires analyzer >=2.0.0 <4.0.0.
    And because dart_style >=2.2.2 <2.2.3 depends on analyzer ^3.3.1, dart_style >=2.2.0 <2.2.3 requires analyzer >=2.0.0 <4.0.0.
    And because dart_style >=2.2.3 <2.2.4 depends on analyzer >=3.3.1 <5.0.0 and dart_style >=2.2.4 requires SDK version >=2.17.0 <3.0.0, dart_style >=2.2.0 requires analyzer >=2.0.0 <5.0.0.
    So, because flutterw_sidekick_plugin depends on both analyzer ^5.0.0 and dart_style ^2.2.0, version solving failed.
[e] Unhandled exception:
[e] /private/var/folders/c0/vw17q1tx6k50xkmzl4wx1pbh0000gn/T/iH2gEe/packages/dashi_sidekick/build/cache/dart-sdk/bin/dart pub get 
[e] exit: 1

The sidekick CLI is using Dart SDK version 2.18, so it should be able to use the plugin. However, because its sidekickDartRuntime is on Dart SDK version 2.14, pub get fails.

A clearer error message should be printed in this case. The solution would be to update the sidekickDartRuntime's Dart SDK version (see #149)

Breaking cli app when switching flutter versions

The last days i experience a weird behavior when switching flutter versions.
Sidekick will not be installed/reinstalled because of missing dart sdk. Even though it's there.

➜  adb-frontend git:(irn-1575-mfa-api) adb flutter --version
Installing 'adb' command line application...
- Getting dependencies
.../adb_sidekick/tool/install.sh: line 30: ../.flutter/bin/cache/dart-sdk/bin/dart: No such file or directory

Workaround:
Going into .flutter/bin and calling ./flutter --version will download the correct version and it works afterwards.

Add SidekickContext

Similar to PluginContext, add a SidekickContext which contains all relevant variables which are a bit scattered right now (in Repository etc.)

[plugin] Missing git source for plugin dependnecy

Installing a plugin from git, which is not yet published on pub results in the following error:

Because vf_sidekick depends on flutterw_sidekick_plugin any which doesn't exist (could not find package flutterw_sidekick_plugin at https://pub.dartlang.org), version solving failed.
Unhandled exception:
/Users/pascalwelsch/Downloads/vgvdefault/packages/vf_sidekick/build/cache/dart-sdk/bin/dart pub add flutterw_sidekick_plugin 
exit: 65
reason: The command [/Users/pascalwelsch/Downloads/vgvdefault/packages/vf_sidekick/build/cache/dart-sdk/bin/dart] with args [pub, add, flutterw_sidekick_plugin] failed with exitCode: 65 workingDirectory: /Users/pascalwelsch/Downloads/vgvdefault/packages/vf_sidekick
wait_for_ex.dart : waitForEx : 21

The cause for this is that plugins today only support local and pub dependencies.

  if (PluginContext.localPlugin == null) {
    pubAddDependency(package, 'flutterw_sidekick_plugin');
  } else {
    // For local development
    pubAddLocalDependency(package, PluginContext.localPlugin!.root.path);
  }

During install, sidekick should inject the git repo as env into the installer. A new method in sidekick_plugin_installer could then automatically select the correct dependency method:

addDependency(
  name: 'flutterw_sidekick_plugin',
  pubServer: 'https://onepub.dev/',
  repo: 'https://github.com/passsy/flutterw_sidekick_plugin',
);

Consider Gitbook

As Sidekick is growing and the documentation gets bigger and bigger, I think it would be nice if we could provide our Documentation via Gitbook or use some kind of Table of Contents to make orientation easier

VersionChecker doesn't check without command

VersionChecker is not executed when just calling the cli, it always requires an argument

$ export SIDEKICK_ENABLE_UPDATE_CHECK=true 
$ noa

(no check)

$ export SIDEKICK_ENABLE_UPDATE_CHECK=true
$ noa vault

(does the check)

The reason for this is, that we do an early return for zero args

  if (args.isEmpty) {
    print(runner.usage);
    return;
  }

Replace flutterw with a pure dart sdk downloader

Downloading flutter to download a dart sdk is maybe too much. Why not simply download just the dart SDK?

That has to be implemented in bash, but the ground work was already implemented by the flutter_tool and can by copy pasted

Create sub package as a plugin

As a plugin we create a new folder for the dockerize command called server.
We create it by hand and later when we need to reference it we need to find it ourselves.

Would it be wanted and feasible to have a addPackage function in the plugin_installer?

It would be cool to have the project's structure abstracted away for plugins.

I imagine this creates a folder in the right place. Be it the packages folder or top level if no packages folder is present.
Then introduces this folder in the <cli>_project.dart.

feat: Add template for Sidekick Plugin

Now that we are supporting plugins, it would be nice if I could run something like sidekick create:plugin to easily generate a starter template for a sidekick plugin.

Add possibility to update Dart SDK version of `sidekickDartRuntime`

Currently the sidekickDartRuntime's Dart SDK version can only be updated by increasing the minimum version constraint in the sidekick CLI's pubspec.yaml and running the CLI's entrypoint. This is not very intuitive and unnecessarily coupled. So we should add another way to update the sidekickDartRuntime's Dart SDK version.

We could add it to the sidekick update command, e.g. like this: sidekick update <{cli (default), dart}> [{<version>, latest}]

sidekick update cli or sidekick update to update the sidekick CLI (current implementation of the command)

sidekick update dart to update sidekickDartRuntime (new)

`sidekick plugins create` only works in generated sidekick CLIs

Currently plugins create only works inside generated sidekick CLIs (<custom_cli> plugins create but not in the general sidekick CLI (sidekick plugins create).

This is because the generated code is formatted with sidekickDartRuntime.dart(['format', pluginDirectory.path]);. However, sidekickDartRuntime and dart are only accessible in generated sidekick CLIs, but not in the general sidekick CLI.

❯ sidekick plugins create -t install-only -n foobar
Unhandled exception:
env.SIDEKICK_PACKAGE_HOME is not set
#0      Repository.requiredCliPackage (package:sidekick_core/src/repository.dart:66:7)
#1      sidekickDartRuntime (package:sidekick_core/src/dart_runtime.dart:5:60)
#2      sidekickDartRuntime (package:sidekick_core/src/dart_runtime.dart)
#3      CreatePluginCommand.run (package:sidekick_core/src/commands/plugins/create_plugin_command.dart:78:5)
#4      CommandRunner.runCommand (package:args/command_runner.dart:209:27)
#5      CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:119:25)
#6      new Future.sync (dart:async/future.dart:302:31)
#7      CommandRunner.run (package:args/command_runner.dart:119:14)
#8      main (package:sidekick/sidekick.dart:13:18)
#9      main (file:///Users/pepe/dev/repos/sidekick/sidekick/bin/sidekick.dart:4:18)
#10     _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:32)
#11     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

Updating plugins

We should add a command for updating plugins which have been installed to a sidekick cli.

PluginsUpdateCommand

The usage could look like this: <my_cli> sidekick plugins update <plugin> [version]

The implementation can be similar to UpdateCommand

  1. Download the plugin at the specified version (or latest if none was given)
  2. Run <plugin>/tool/update.dart and pass it the name of the cli, the currently installed plugin version, as well as the target version
  3. The update.dartscript must be implemented by the plugin author. If possible, he can implement automatic migrations. If there are breaking changes without automatic fixes, information messages can be printed or thrown here.
  4. Update the minimum constraint of the plugin dependency in the cli

Update check

How do we let the user know that an update for one of his plugins is available?

It would be nice to do an update check for a specific plugin only when a command of that plugin is run. However, I don't know how we can map the plugin which is currently being run to the plugin it comes from.

An easier way would be to do an update check for every installed plugin when running any command except the PluginsUpdateCommand.

But how do we know which plugins have been installed to the cli?

  1. We could save the information in the sidekick section of pubspec.yaml. A list of all plugins which have been installed under sidekick: plugins: [...]. When installing a plugin, we add its entry to that list.
  2. Read all direct dependencies from the cli's pubspec.yaml. Filter dependencies which themselves have a direct dependency on sidekick_plugin_installer - those are sidekick plugins.

Add `--version`/`-v` Command

It would be nice if I could just type sidekick -v or sidekick --version to get the current version of the installed sidekick

crash if sidekick name exists

Sidekick should be crashing or give the user the chance to enter a other name if the sidekick abbreviation conflicts with an installed cli tool.

Speed up sidekick tests

In sidekick there are many tests where first sidekick init is executed. We should do that just once and use copies of the generated sidekick CLI to speed up the tests

addSelfAsDependency() fails when installing from local

 ./vgs sidekick plugins install -s path ~/Projects/passsy/flutterw_sidekick_plugin/
Error on line 1, column 7 of /Users/pascalwelsch/Projects/passsy/flutterw_sidekick_plugin/pubspec.yaml: "name" field doesn't match expected name "/Users/pascalwelsch/Projects/passsy/flutterw_sidekick_plugin/".
  ╷
1 │ name: flutterw_sidekick_plugin
  │       ^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
Unhandled exception:
/Users/pascalwelsch/Downloads/vgv_start/packages/vgs_sidekick/build/cache/dart-sdk/bin/dart pub add /Users/pascalwelsch/Projects/passsy/flutterw_sidekick_plugin/ --path /Users/pascalwelsch/Projects/passsy/flutterw_sidekick_plugin/ 
exit: 65
reason: The command [/Users/pascalwelsch/Downloads/vgv_start/packages/vgs_sidekick/build/cache/dart-sdk/bin/dart] with args [pub, add, /Users/pascalwelsch/Projects/passsy/flutterw_sidekick_plugin/, --path, /Users/pascalwelsch/Projects/passsy/flutterw_sidekick_plugin/] failed with exitCode: 65 workingDirectory: /Users/pascalwelsch/Downloads/vgv_start/packages/vgs_sidekick
#0      waitForEx (package:dcli/src/util/wait_for_ex.dart:67:5)
#1      RunnableProcess.processUntilExit (package:dcli/src/util/runnable_process.dart:460:7)
#2      RunnableProcess.run (package:dcli/src/util/runnable_process.dart:180:11)
#3      startFromArgs (package:dcli/src/functions/run.dart:174:19)
#4      SidekickDartRuntime.dart (package:sidekick_core/src/dart_runtime.dart:54:5)
#5      addDependency (package:sidekick_plugin_installer/src/add_dependency.dart:119:23)
#6      addSelfAsDependency (package:sidekick_plugin_installer/src/add_dependency.dart:29:5)
#7      main (file:///Users/pascalwelsch/Downloads/vgv_start/packages/vgs_sidekick/build/plugins/flutterw_sidekick_plugin/tool/install.dart:23:3)
#8      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:283:19)
#9      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
Unhandled exception:
/Users/pascalwelsch/Downloads/vgv_start/packages/vgs_sidekick/build/cache/dart-sdk/bin/dart /Users/pascalwelsch/Downloads/vgv_start/packages/vgs_sidekick/build/plugins/flutterw_sidekick_plugin/tool/install.dart 
exit: 255
reason: The command [/Users/pascalwelsch/Downloads/vgv_start/packages/vgs_sidekick/build/cache/dart-sdk/bin/dart] with args [/Users/pascalwelsch/Downloads/vgv_start/packages/vgs_sidekick/build/plugins/flutterw_sidekick_plugin/tool/install.dart] failed with exitCode: 255 workingDirectory: /Users/pascalwelsch/Downloads/vgv_start/packages/vgs_sidekick
#0      waitForEx (package:dcli/src/util/wait_for_ex.dart:67)
#1      RunnableProcess._waitForExit (package:dcli/src/util/runnable_process.dart:331)
#2      RunnableProcess.run (package:dcli/src/util/runnable_process.dart:177)
#3      startFromArgs (package:dcli/src/functions/run.dart:174)
#4      SidekickDartRuntime.dart (package:sidekick_core/src/dart_runtime.dart:54)
#5      InstallPluginCommand.run (package:sidekick_core/src/commands/plugins/install_plugin_command.dart:189)
<asynchronous suspension>
#6      CommandRunner.runCommand (package:args/command_runner.dart:209)
<asynchronous suspension>
#7      SidekickCommandRunner.run (package:sidekick_core/sidekick_core.dart:162)
<asynchronous suspension>
#8      runVgs (package:vgs_sidekick/vgs_sidekick.dart:31)
<asynchronous suspension>
#9      main (file:///Users/pascalwelsch/Downloads/vgv_start/packages/vgs_sidekick/bin/main.dart:4)
<asynchronous suspension>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.