Closed jpt closed 1 year ago
@jpt You're right. Currently, the only way to provide a config is to specify a config file path.
How'd you imagine passing the config via the command line? Could you give some examples of the APIs you'd like to have?
Happy to accept PRs 👍
Thanks for the quick reply!
The way I was thinking about it, it wouldn't be very different than the config object itself, for example:
npx react-scanner -sc -cf ".src" -if "basis"
or more verbosely npx react-scanner --sub-components --crawl-from ".src" --import-from "basis"
Or to run it a few times programmatically, maybe the interface would look something like this, where you populate a config object directly in a script?
import { scanner } from 'react-scanner';
const main = async () => {
scanner.config = {
crawlFrom: "./src",
includeSubComponents: true,
importedFrom: "basis",
};
let scannerOutput = await scanner.run();
// do something with that output, then run again:
scanner.config["crawlFrom"] = "other-src";
scannerOutput = await scanner.run();
}
main();
It's not a very big change, but for me would improve the developer experience a bit working with multiple codebases
Yeah, I like the idea of being able to run the scanner programmatically.
How about passing the config to the scanner
directly?
import { scanner } from 'react-scanner';
const output = await scanner.run(config)
PR is welcome!
How about passing the config to the scanner directly?
Great idea, this is a more elegant solution.
PR is welcome!
I'll start familiarizing myself with the codebase. It might be a little while before I have time, but I'm very interested in implementing the feature - I will keep you updated 🙂
first of all thanks for publishing this great library. I was about to write something on top of babel-traverse instead and this was a huge time-saver.
it's possible I missed some documentation on this, but to run react-scanner on a number of different component libraries (think a multi-brand or multi-platform design system), or with different config options on the same library to compare the data. in order to do this, I am writing a number of config files on the fly, and running react-scanner a number of times. even if react-scanner doesn't get a full API, being able to pass options via command line argument would be an improvement as well.
let me know if I overlooked anything in my thinking about this. if you like this idea, it's possible I could contribute to a PR.
thanks!