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

Yeoman fails if the generator uses user.github.username mixin #1255

Closed
kyoh86 opened this issue Jun 27, 2020 · 5 comments
Closed

Yeoman fails if the generator uses user.github.username mixin #1255

kyoh86 opened this issue Jun 27, 2020 · 5 comments
Labels
needs triage Awaiting triage

Comments

@kyoh86
Copy link

kyoh86 commented Jun 27, 2020

  • I have an account with public email address which ends with *.dev TLD.
  • GitHub may have a bug so I cannot find my account with my public email address.
  • Yeoman uses github-username package and it calls GitHub API.

So now, I cannot use yeoman generators using user.github.username mixin.
I know that it is not issue of Yeoman, but I want Yeoman to be able to get GitHub Username without GitHub access.

Proposal: If an environment variable YEOMAN_GITHUB_USERNAME is set, Yeoman uses it.

@kyoh86 kyoh86 added the needs triage Awaiting triage label Jun 27, 2020
@mshima
Copy link
Member

mshima commented Jun 28, 2020

Have you tried to update github-username from 3.x to 5.x?
I can upgrade if it works.
A workaround like that should not be implemented at generator side.
You should do something like:

async task() {
  const username = await this.user.github.username().catch( ()=> fallback );
}

@kyoh86
Copy link
Author

kyoh86 commented Jun 28, 2020

It's not problem of the github-username.
GitHub API does not return my account with my correct email.

... I'll try to negotiate with some generator authors...

@kyoh86 kyoh86 closed this as completed Jun 28, 2020
@mshima
Copy link
Member

mshima commented Jun 28, 2020

Do you have this problem with multiples generators?
I fell a env var is not good but adding an option is possible.

yo foo --github-username username

@kyoh86
Copy link
Author

kyoh86 commented Jun 28, 2020

ya, but I'll try. thanks.

@mshima
Copy link
Member

mshima commented Jun 28, 2020

If you are willing to provide a PR:

  1. You should add an option like:

    generator/lib/index.js

    Lines 182 to 186 in ba43e2c

    this.option('ask-answered', {
    type: Boolean,
    description: 'Show prompts for already configured options',
    default: false
    });

  2. Change user mixing to be able to read the generator:

    const user = module.exports;

    to:

const generator = module.exports;
const user = generator.user = {};
  1. Update username function to read options:
    user.github.username = () => githubUsername(user.git.email());

    To something like:
user.github.username = () => {
  if (generator.options && generator.options.githubUsername) {
    return Promise.resolve(generator.options.githubUsername);
  }
  return githubUsername(user.git.email());
}
  1. Change user mixin load:
    Generator.prototype.user = require('./actions/user');

    to
_.extend(Generator.prototype, require('./actions/user'));
  1. The missing part: provide test case.

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

No branches or pull requests

2 participants