dashkite / tempo

Polyrepo project and package management
Other
1 stars 0 forks source link

Enhanced Scripts #20

Open dyoder opened 1 year ago

dyoder commented 1 year ago

We can allow queries or include/exclude criteria to be part of a script definition. This makes it easier to reliably run more complex commands. We can also allow positional arguments in the queries or include/exclude lists.

For example, our upgrade script might look like this:

update-dev:
  query: package.json > devDependencies["$0"]?
  exclude: $0
  command: pnpm add $0@latest

We can even do a limited form of command inheritance, not that it’s that useful:

update: &update
  query: package.json > dependencies["$0"]?
  exclude: $0
  command: pnpm add $0@latest
update-dev:
  <<: *update
  query: package.json > devDependencies["$0"]?

Complex commands may also use arrays instead of relying on shell-chaining. Arrays allow us to determine which part of a command failed and log that information instead of just logging that the whole command failed.

For example, our commit command might look like this:

commit:
  command:
    - git add -A .
    - git commit -m $0

Compound commands are often commands with tacit queries. We can extend our query language to handle checks like this: we might rewrite the above like so:

commit:
  query: ! git add -A .
  command: git commit -m $0
dyoder commented 11 months ago

An early version of this is implemented now but untested. Only supports command-line flags, ex: retry or batch.