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

Howto yeoman-environment to build a custom cli. #500

Closed
ntucker opened this issue Nov 3, 2023 · 5 comments
Closed

Howto yeoman-environment to build a custom cli. #500

ntucker opened this issue Nov 3, 2023 · 5 comments
Labels

Comments

@ntucker
Copy link

ntucker commented Nov 3, 2023

How to use yeoman 4? I just want to run a generator that i have the filepath for

const command = Environment.prepareCommand(require('./fixtures/generator-commands/generators/arguments'));
doesn't work I get Environment.prepareEnvironment is not a function

Related to yeoman/yo#793 (comment)

@mshima mshima changed the title Docs Howto yeoman-environment to build a custom cli. Nov 3, 2023
@mshima
Copy link
Member

mshima commented Nov 3, 2023

cli.mjs:

import { prepareCommand } from 'yeoman-environment`;
import generator from '../generators/app/index.js';

await prepareCommand(generator).parseAsync();

cli.cjs (executable should be commonjs`):

#!/usr/bin/env node
(async function () {
  await import('../cli.mjs');
})();

@ntucker
Copy link
Author

ntucker commented Nov 4, 2023

I'm getting some conflicting indicators in the prepareCommand types:

/**
 * Prepare a commander instance for cli support.
 *
 * @param generatorPaht - Generator to create Command
 * @return Return a Command instance
 */
export declare const prepareCommand: (options: CommandPreparation) => Promise<YeomanCommand>;

JSDOCS do not match types.

When I try the import code you had above, I get

A generator with namespace or a generator path is required

@ntucker
Copy link
Author

ntucker commented Nov 4, 2023

https://github.com/yeoman/environment/blob/main/src/commands.ts#L27C1-L33C4

Indicates that prepareCommand(generator) is not a valid call

@ntucker
Copy link
Author

ntucker commented Nov 4, 2023

This definitely doesn't do the same thing as calling yo as env isn't setup the same

Copy link
Contributor

github-actions bot commented Dec 5, 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 Dec 5, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants