stkb / Rewrap

Rewrap extension for VSCode and Visual Studio
https://marketplace.visualstudio.com/items/stkb.rewrap
Other
506 stars 62 forks source link

CLI for CI integration #328

Open jasonkuhrt opened 2 years ago

jasonkuhrt commented 2 years ago

I want to add this tool to my team's CI. Editor integration is great but a convenience rather than a guarantee of process.

For guarantees we would need CI integration, which I guess we would need a CLI for.

bartekpacia commented 2 years ago

I'd love this feature as well!

stkb commented 2 years ago

Hi sorry didn't get an email notification for this.

Yeah I've basically been waiting for someone to to request this. I use a hacked-together version myself, though that's directly from the source code.

If you have any ideas what the CLI should look like, let me know.

bartekpacia commented 2 years ago

@stkb Thanks for response! :D

For the first v0.1.0 version, I'd just like to be able to run rewrap from terminal and that's all. + accept --width that defaults to 80.

jasonkuhrt commented 2 years ago

I wonder if there could be a way to distribute as an npm package to make it easy for Node projects to consume in their projects and thus in CI.

I realize this project is written in F# (I think) but who knows, maybe there is a transpile or WASM thing that could be done.

stkb commented 2 years ago

@bartekpacia @jasonkuhrt Thanks, yeah publishing an npm package should be doable this week (the F# already gets transpiled to JS for the vs-code extension).

bartekpacia commented 2 years ago

@stkb Have you considered creating a Homebrew Formula for rewrap?

If you don't want/don't have time, then I think I could contribute it.

stkb commented 2 years ago

I've never looked into that, but if it can be easily made from an npm package I guess I could. However since I don't have MacOS it might be better if you did. I'll let you know once the npm package is published.

stkb commented 2 years ago

NPM package is now published at @stkb/rewrap. It's pretty basic and no test infrastructure yet but seems to work for me.

Example use:

rewrap file.md > wrapped.md # defaults to --column 80

rewrap -i --column 90 file1.js file2.js  # With '-i', overwrites input file
bartekpacia commented 2 years ago

@stkb I have tried creating a basic Homebrew Formula for rewrap.

Unfortunately I have problems with running npm install, which yield this:

$ npm install                                                                                                       exit 1
npm ERR! code ETARGET
npm ERR! notarget No matching version found for minimist@^3.0.2.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/bartek/.npm/_logs/2022-05-02T20_30_29_595Z-debug-0.lo

It would help a lot if you added instructions to README on how to build & run rewrap locally :)

bartekpacia commented 2 years ago

Would love to see some progress on this :)

patrickkunka commented 1 year ago

Would love to get this integrated into our CI pipelines. I've had a look at the NPM package linked above but the main thing that seems to be missing is support for passing a glob.

For example, instead of :

rewrap -i --column 90 file1.js file2.js

It would be more powerful and idiomatic to pass something like:

rewrap -i --column 90 "src/**/*.ts"
peter-lyons-kehl commented 1 year ago

As for the immediate previous comment: This can be achieved easily on Linux/Mac OS/Unix with shell escaping with backticks, which run the inner command and then pass the output from that inner command as part of shell arguments to the outer commands, like (in bash):

rewrap -i --column 90 `find src/ -name "*.ts"`

If you are on Windows, investigate Powershell.

peter-lyons-kehl commented 1 year ago

Thank you for Rewrap, and also for this feature request.

Given that the project contributors are overloaded, may I suggest, as per the Pareto principle (the 20%-80% rule: 80% of results or use cases can be achieved or handled with 20% of effort):

What needs to be done for this to

If anyone wants to invoke it on Windows, Mac OS or esoteric distributions or kernels, they can integrate, test, document and share their solution. But the original poster and the title of this issue is asking for CI integration, which most commonly runs on Linux and has Docker.

To help people contribute, please also give thumbs up to