fabien0102 / ts-to-zod

Generate zod schemas from typescript types/interfaces
MIT License
1.17k stars 65 forks source link

add equivalent to --all cli flag to ignore ts-to-zod config at all #211

Open vladdcom opened 6 months ago

vladdcom commented 6 months ago

Feature description

In cli prompt the program has option "Don't use the config" but i cannot use it through inline command ts-to-zod --none or ts-to-zod --config=none doesnt work

Input

ts-to-zod --config=none

Output

ts-to-zod ignore ts-to-zod config and use passed inline data

tvillaren commented 6 months ago

Hello @vladdcom,

Do you mean that it would just ignore this prompt:

? You have multiple configs available in "ts-to-zod.config.js"
 What do you want? (Use arrow keys)
❯ Execute all configs (--all) 
  Execute "example" config (--config=example) 
  Execute "example/person" config (--config=example/person) 
  Execute "config" config (--config=config)
  Don't use the config 

and be the equivalent of selecting the last option?

vladdcom commented 6 months ago

yeah, exactly the equivalent of selecting the last option

tvillaren commented 6 months ago

In that case, you must add arguments to CLI call, right?

At least an input argument (and ideally an output otherwise your input will be overwritten). Maybe we should skip the config step altogether when an input is passed.

vladdcom commented 6 months ago

per repo

yarn ts-to-zod --all -> use the ts-to-zod config yarn ts-to-zod --noneConfig src/iDontTrustThisApi.ts src/nowIcanValidateEverything.ts -> ignore the config, use inline params

"Don't use the config" in the prompt is working the same way

tvillaren commented 6 months ago

In terms of developer experience, I'm wondering if we actually need the --noConfig flag.

Why not skip config when calling

yarn ts-to-zod src/iDontTrustThisApi.ts src/nowIcanValidateEverything.ts

?

My point being that all the information needed to perform the action is in the command. I think your request is very valid, but I feel that adding a new flag is not the best DevExp. What do you think?

vladdcom commented 6 months ago

I have ts-to-zod config in my repo and if I run this command yarn ts-to-zod src/iDontTrustThisApi.ts src/nowIcanValidateEverything.ts

I'm gonna get into a interactive mode of the prompt. But I want to disable config by one command

tvillaren commented 6 months ago

I'm gonna get into a interactive mode of the prompt. But I want to disable config by one command

Yes, I think I understand that. My point is that might be better to disable config if the command actually passes input and output arguments: no need to add a flag for that, it would be the logical behaviour to execute the generation directly.

vladdcom commented 6 months ago

got it, the idea is good

schiller-manuel commented 6 months ago

@tvillaren sounds good. If we implement this, so it would be breaking. Let's collect breaking changes such as this and the exit code 1 upon failure so we can combine those in a v4 release.

tvillaren commented 6 months ago

Yep, had the same thought 😄 I don't have any permission on this repository, but I would be glad to help tag some features to track what could be added in a V4

aminya commented 3 months ago

How can I tell the CLI to use the config file? It seems it needs me to duplicate the input-output files in the CLI.

tvillaren commented 3 months ago

@aminya: if you have a ts-to-zod.config.js at the root of your project, the CLI should use it directly.

aminya commented 3 months ago

@tvillaren I tried that in a mono-repo, but it did not work. Could you add more documentation on this? Also, the CLI doesn't have any indication of this happening despite using --verbose, or I could not find a --config settings for specifying the path.