Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value from option defined in a composed generator is only available on generator triggered #1456

Closed
adautomendes opened this issue Jun 2, 2023 · 2 comments
Labels
needs triage Awaiting triage stale

Comments

@adautomendes
Copy link

Hi :)

I have a scenario here with 3 subgeneratos following the structure below:

└───generator-dummy-adauto
    │   package-lock.json
    │   package.json
    └───generators
        ├───app
        │       index.js
        ├───sub-gen1
        │       index.js
        └───sub-gen2
                index.js

The app subgenerator is composed by sub-gen1 and sub-gen2. Each one define its own options inside its constructor:

//app
constructor(args, opts) {
    super(args, opts);
    this.option('str1', { type: String });
    this.option('bool1', { type: Boolean });
}
//sub-gen1
constructor(args, opts) {
    super(args, opts);
    this.option('str2', { type: String });
    this.option('bool2', { type: Boolean });
}
//sub-gen2
constructor(args, opts) {
    super(args, opts);
    this.option('str3', { type: String });
    this.option('bool3', { type: Boolean });
}

Then when I run from app I expected that each subgenerator will have access to the value of its options, e.g., in sub-gen1 I may be able to read str2. But, the behavior I'm having here is that app subgenerator have all options values (even the ones defined in the other two subgenerators) and sub-gen1 and sub-gen2 are not able to read the value of its own options, like the output below:

> yo dummy-adauto --str1=val1 --str2=val2 --str3=val3 --bool1 --bool2 --bool3

*** APP ***
str1 => val1
str2 => val2
str3 => val3
bool1 => true
bool2 => true
bool3 => true

** SUB-GEN1 ***
str1 => undefined
str2 => undefined
str3 => undefined
bool1 => undefined
bool2 => undefined
bool3 => undefined

*** SUB-GEN2 ***
str1 => undefined
str2 => undefined
str3 => undefined
bool1 => undefined
bool2 => undefined
bool3 => undefined

Is this the expected behavior under the composability of generators? How can I propagate these values from app to the others subgenerators correctly?

If needed, I have a dummy generator created to demonstrate this behavior: https://github.com/adautomendes/generator-dummy-adauto

@adautomendes adautomendes added the needs triage Awaiting triage label Jun 2, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2023

This issue is stale because it has been open with no activity. Remove stale label or comment or this will be closed

@github-actions github-actions bot added the stale label Jul 3, 2023
@github-actions github-actions bot closed this as completed Jul 9, 2023
@mshima
Copy link
Member

mshima commented Jul 9, 2023

Generator v6 adds an option for that

forwardOptions?: boolean;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Awaiting triage stale
Projects
None yet
Development

No branches or pull requests

2 participants