Taking this from twitter to here, just to see what we can do!
I'd love to have a core npm module that wraps most of the functionality up, so that both atom and code can just pull from the same feature set.
Right now atom-yeoman has the following features:
Generator Service
Allows package authors the ability to call a specific generator.
yo command
Lists all generators
Loads from various locations that generators can be found (in atom we can't trust some of the NODE paths, code may be very similar)
Parses files added, removed, changed, etc, and forwards that onto the service (for package authors to react to those files).
Proposal
Thoughts and ideas below.
Node Module
Generator class
Constructor
Accepts a factory function that takes a list of generators and returns a Promise<IGenerator[]> which resolves when the generator has been selected.
Accepts a factory function that takes an input question, and returns a Promise<IAnswer> which resolves when that question is completed.
This is where the editor specific package can inject it's UI elements.
Sets search locations, configurable using options.
Method for listing generators
list(pathToDirectory: string, prefix?: string): Promise<IGenerator[]>
Search prefix (only list specific generators). Might not be required, can always be done after it returns.
Method for running a specific generator
run(pathToDirectory: string, generator: string): Promise<IResult>
Shortcut that calls generator.run() under the covers.
Example atom/code usage:
let yeomanService = new YeomanService((q: IQuestion) => showQuestionForUser(q));
yeomanService.list(process.cwd())
.then((generators) => listGeneratorsForUser())
.then(generator => generator.run())
.then(result => doSomethingWithResult())
This would make it much simpler for people to use yeoman in an electron like application, so it may have uses outside of just atom/code.
Atom
Has CSP issues, there are clear work around that is already handled. Hopefully this could be handled outside of the node module, so we don't have to worry about the nasty CSP code everywhere.
Code
Not sure if CSP is enabled, it's entirely possible it is not currently enabled.
Taking this from twitter to here, just to see what we can do!
I'd love to have a core npm module that wraps most of the functionality up, so that both atom and code can just pull from the same feature set.
Right now atom-yeoman has the following features:
yo
commandProposal
Thoughts and ideas below.
Node Module
Promise<IGenerator[]>
which resolves when the generator has been selected.Promise<IAnswer>
which resolves when that question is completed.list(pathToDirectory: string, prefix?: string): Promise<IGenerator[]>
run(pathToDirectory: string, generator: string): Promise<IResult>
Shortcut that callsgenerator.run()
under the covers.Example atom/code usage:
This would make it much simpler for people to use yeoman in an electron like application, so it may have uses outside of just atom/code.
Atom
Has CSP issues, there are clear work around that is already handled. Hopefully this could be handled outside of the node module, so we don't have to worry about the nasty CSP code everywhere.
Code
Not sure if CSP is enabled, it's entirely possible it is not currently enabled.