linux-china / task-keeper

A cli to manage tasks from different task runners or package managers
Apache License 2.0
20 stars 3 forks source link
package-manager

Task Keeper

tk(Task Keeper) is a tool to manage tasks from different task files, such as Makefile,justfile, package.json , deno.jso, .fleet/run.json etc, and call tasks from different project management tools, such as Apache Maven, Gradle, Cargo and npm etc.

Task Keeper

Features

How to get started?

After install, execute tk --help for usage. Some commands as following:

Why task keeper?

Sorry, I got lost in different task files and management tools, and sometimes I even can not remember how to run them.

Too many differences, I want to save my brain and keyboard, and you know MacBook keyboard's price tag is $400+.

Task runners support

Bun Shell - Taskfile.ts

Bun Shell is a nice feature from Bun to make shell scripting with JavaScript & TypeScript fun.

Now Task Keeper support Taskfile.ts with Bun Shell, and you can use following code to run tasks:

import {$} from "bun";

  export async function hello() {
  await $`echo Hello World!`;
}
  export async function list_js() {
  await $`ls *.js`;
}

Then tk hello to run task with Bun Shell.

Fleet Run configurations

command type support now:

For details, please refer https://www.jetbrains.com/help/fleet/run-configurations.html

Language version detection and PATH

Task Keeper uses .java-version, .node-version, .python-version files to detect language version and bound with local installed SDK.

To make task runner run tasks smoothly, Task Keeper will append following directories to PATH automatically:

For example, if you use Python virtual env to manage your project, Task Keeper will add venv/bin to PATH automatically, and you don't need to do anything.

hello:
  python hello.py

Tips: you can use double dash to run command with language detection and correct PATH, such as tk -- mvn spring-boot:run. To make life easy, and you can use alias e='tk --' to create an alias, then you can run e mvn spring-boot:run to run your project.

Package manager support

Common tasks for all package managers:

Attention: if package manager's task name is in a task runner, and task keeper will not execute package manager's command.

Apache Maven

Available

Gradle

Please set up gradle-versions-plugin for dependency version management. You can transparently add the plugin to every Gradle project that you run via a Gradle init script. $HOME/.gradle/init.d/plugins.gradle with following code:

initscript {
  repositories {
     gradlePluginPortal()
  }

  dependencies {
    classpath 'com.github.ben-manes:gradle-versions-plugin:+'
  }
}

allprojects {
  apply plugin: com.github.benmanes.gradle.versions.VersionsPlugin

  tasks.named("dependencyUpdates").configure {
    // configure the task, for example wrt. resolution strategies
  }
}

Sbt

Please add sbt-updates and DependencyTreePlugin as global plugins. $HOME/.sbt/1.0/plugins/plugins.sbt with following code:

addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.3")
addDependencyTreePlugin

npm

Available

Cargo

Available. Please install cargo-tree, cargo-outdated.

Composer

Available

Bundler

Available

Go Module

Available

CMake

Only support cmake-conan, and conanfile.txt required.

Default build directory is cmake-build-debug, and you override it by CMAKE_BINARY_DIR=_build tk build.

Meson

Available

Swift

Available. Please install swift-outdated for outdated operation.

Bazel

Available.

Python

Available with following tools:

Lein

Available.

Please set up antq for outdated dependencies. $HOME/.lein/profiles.clj

{
 :user
 {:dependencies [[com.github.liquidz/antq "RELEASE"]]
  :aliases {"outdated" ["run" "-m" "antq.core"]}
 }
}

Mix package manager

Available.

Rebar3 package manager

Available.

Dart package manager

Available.

Zig Build System

Available.

task - Taskfile.yml

if you use JetBrains IDE to edit Taskfile.yml, please add $schema comment on top of Taskfile.yml for completion.

# $schema: https://taskfile.dev/schema.json
version: '3'

tasks:
  hello:
    cmds:
      - echo 'Hello World from Task!'
    silent: true

xtask for Rust and Golang

Tasks from README.md

Task keeper will parse README.md and extract tasks with following code block format:

```shell {#task_name}
curl https://httpbin.org/ip
```

Now only shell, sh, javascript and typescript are supported.

Run JavaScript/TypeScript by node or deno:

```javascript {#task_name .deno}
console.log("hello world");
```

Task options/params and global options

Todo

Task Runners

Package Managers

Version detection

Task Keeper will detect version configuration file and adjust the environment variables to run tasks.

Python

.python-version is used for version management for pyenv.

Java

.java-version is used for version management, and values as following:

Task Keeper will try to find Java from $HOME/.jbang/cache/jdks or $HOME/.sdkman/candidates/java/.

.sdkmanrc support, and set HOME and PATH environment variables automatically. Please refer https://sdkman.io/usage#env for detail.

Node.js

.node-version is used for Node.js version management, and values as following:

Task Keeper will try to find Node from $HOME/.nvm/versions/node or $HOME/.volta/tools/image/node.

References

Task scripts demo in Markdown

$ curl https://httpbin.org/get
$ curl -X POST https://httpbin.org/post
curl --silent https://httpbin.org/ip | jq '.origin'
curl https://httpbin.org/ip \
    --user-agent "Task Keeper/0.1.0" \
    --silent
curl https://httpbin.org/headers
let name: string = "linux_china";
console.log(name);