knope-dev / knope

A command line tool to to handle all the tasks most developers find tedious.
https://knope.tech
MIT License
72 stars 8 forks source link

Update version in more places #482

Open dbanty opened 1 year ago

dbanty commented 1 year ago

There are many times you'll want to keep your version up to date in multiple places (e.g., documentation's install instructions). Knope should facilitate this somehow. The most obvious solution is probably regex match groups for set files but maybe there's a simpler option (that doesn't require testing regexs, which is hard)?

alex-way commented 1 month ago

Just throwing out a potentially terrible idea here but could something like the following work:

[package]
# Query parameter style. Similar to vite asset importing: https://vitejs.dev/guide/assets.html#importing-asset-as-string
versioned_files = ["docker-compose.yml?replace=REGEX$version"]
[package]
# Potentially simpler, but could be limiting if further features are required in the future
versioned_files = ["docker-compose.yml:REGEX$version"]

The idea being that there's a defined separator (? or :) between the filename (docker-compose.yml) and the regex. One other thing we'll need is an identifier for the current version rather than relying on regex. I suggest $version as it's what's used elsewhere in the documentation for similar purposes.

We'd need to replace the $version first, prior to evaluating the regex to avoid the $version from mangling the regex.

I think whatever method is implemented should only be used as a fallback and as further development is done to parse different files, the reliance on this should be less prevalent and hopefully less of an issue.

alex-way commented 1 month ago

Another idea I've had is some kind've plugin system which will allow developers to be able to implement their own systems.

alex-way commented 3 weeks ago

Following the idea of a plugin system, I've come across a framework, Extism, which allows extremely easy consumption of functions exported via WASM modules. WASM is seemingly the perfect fit as it'll allow users to be able to write plugins in any of the supported languages and provides extreme safety via sandboxing.

Executing an exposed function is as simple as:

let url = Wasm::url(
  "https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm"
);
let manifest = Manifest::new([url]);
let mut plugin = Plugin::new(&manifest, [], true).unwrap();
let res = plugin.call::<&str, &str>("count_vowels", "Hello, world!").unwrap();
println!("{}", res);