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

update yeoman-environment to v4.0.0 #793

Merged
merged 3 commits into from
Oct 29, 2023
Merged

update yeoman-environment to v4.0.0 #793

merged 3 commits into from
Oct 29, 2023

Conversation

mshima
Copy link
Member

@mshima mshima commented Oct 21, 2023

Purpose of this pull request?

  • Documentation update
  • Bug fix
  • Enhancement
  • Other, please explain:

What changes did you make?

Is there anything you'd like reviewers to focus on?

@ntucker
Copy link

ntucker commented Oct 28, 2023

What's the point of yeoman-environment release without this updated? Can yeoman-environment be used without yo?

@mshima
Copy link
Member Author

mshima commented Oct 29, 2023

Yes it’s possible.

Would be nice if someone could convert yo to ESM.

@mshima mshima merged commit 8749847 into yeoman:main Oct 29, 2023
6 checks passed
@mshima mshima deleted the env4 branch October 29, 2023 01:03
@mshima
Copy link
Member Author

mshima commented Nov 3, 2023

What's the point of yeoman-environment release without this updated? Can yeoman-environment be used without yo?

@ntucker yes it's possible and I actually recommend.
There a yeoman-environment built-in cli yoe (I consider experimental since I've never had a feedback about it and do not use it, generator-jhipster has a much more complex custom cli which yeoman-environment is based on).
https://github.com/yeoman/environment/blob/e929644f4497a417dc158a12dd32d24690b2cf9c/package.json#L33.
Since v3.0.0 https://github.com/yeoman/environment/releases/tag/v3.0.0.

You can build your own, yeoman-environment has helpers for that.

@ntucker
Copy link

ntucker commented Nov 3, 2023

Oh that's cool. Is there much difference than yoe? I actually have my own cli that I just proxy calls to yo with https://github.com/ntucker/anansi/blob/master/packages/cli/run.mjs#L42

Would it be as simple as replacing yo with yoe to run a generator?

@ntucker
Copy link

ntucker commented Nov 3, 2023

@mshima I don't get how to use yoe. the help says

run [options] <namespace> <namespace>  Run a generator

What are namespaces? What happened to specifying the generator? With yo I do yo [generator-filepath] [...args]

So where does [generator-filepath] go?

@ntucker
Copy link

ntucker commented Nov 3, 2023

Running npx --package=yeoman-environment yoe run @anansi/generator-js app temp:

TypeError: Cannot read properties of undefined (reading 'splice')
    at YeomanCommand.environmentAction (file:///home/ntucker/.npm/_npx/39f97afeb06609d2/node_modules/yeoman-environment/dist/cli/utils.js:33:57)

which associates with

export const environmentAction = async function (generatorNamespace, options, command) {
    debug('Handling operands %o', generatorNamespace);
    if (!generatorNamespace) {
        return;
    }
    const env = createEnv({ ...options, command: this });
    this.env = env;
    await env.lookupLocalPackages();
    return env.execute(generatorNamespace, command.args.splice(1));
};

the return line here

console.log on command gives:

{
  skipInstall: false,
  skipCache: false,
  localConfigOnly: false,
  askAnswered: false,
  force: false,
  dryRun: false,
  whitespace: false,
  bail: false,
  skipYoResolve: false,
  skipLocalCache: true,
  skipParseOptions: false,
  experimental: false
}

@mshima
Copy link
Member Author

mshima commented Nov 3, 2023

It’s not designed to use paths, it relies on lookup and use namespaces.
You can easily create your own using YeomanCommand and prepareCommand.
https://github.com/yeoman/environment/blob/6bacec60de3cc2bbd8b3f4bd5c890a50f26da013/test/command.js#L139.

You can use yoe as reference implementation.

@ntucker
Copy link

ntucker commented Nov 3, 2023

Is require('./fixtures/generator-commands/generators/arguments') a generator?

@mshima
Copy link
Member Author

mshima commented Nov 3, 2023

Yes, https://github.com/yeoman/environment/blob/6bacec60de3cc2bbd8b3f4bd5c890a50f26da013/test/fixtures/generator-commands/generators/arguments/index.js.
Please open a new issue at environment repository to keep the discussion registered in the right repository.

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

Successfully merging this pull request may close these issues.

2 participants