-
Notifications
You must be signed in to change notification settings - Fork 5
Launch Yeoman Generator in separate thread #6
Conversation
69fb4e4
to
deca66b
Compare
Signed-off-by: Vitaliy Gulyy <[email protected]>
bd5e646
to
0282392
Compare
Signed-off-by: Vitaliy Gulyy <[email protected]>
src/theia-yeoman-backend-plugin.ts
Outdated
@@ -0,0 +1,38 @@ | |||
/********************************************************************* | |||
* Copyright (c) 2018 Red Hat, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as you're doing a refactoring, copyright date needs to be updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/yeoman-process-adapter.ts
Outdated
@@ -0,0 +1,221 @@ | |||
/********************************************************************* | |||
* Copyright (c) 2018 Red Hat, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
const path = require('path'); | ||
const fork = require('child_process').fork; | ||
|
||
export class YeomanProcessAdapter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange, GitHub does not display the changes but they are present
https://github.com/vitaliy-guliy/theia-yeoman-plugin/blob/separate-thread/src/yeoman-process-adapter.ts
src/yeoman-process-adapter.ts
Outdated
const currentWorkspace = workspaceFolders[0]; | ||
|
||
// start Yeoman generator in separate node instance | ||
const scriptPath = this.extensionPath + '/lib/yeoman-process.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should use Path.resolve no ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/yeoman-process-adapter.ts
Outdated
child.on('message', this.onMessage); | ||
|
||
child.stdout.on('data', (data: any) => { | ||
console.log(`## stdout: ${data}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to output to the console stdout or stderr ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It helps us to understand the reason when something goes wrong.
Once it helped me to catch an error when running the generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why it's not part of the output on the UI side then ?
IMHO we shouldn't pollute that console by default (= not when debugging)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UI displays only the messages related to creating the extension.
The messages form stdout / stderr are printed to Theia backend console, which is not visible in Theia.
It's easy to ignore them, but should we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reworked it a bit. All the output has been printed to the UI. Looks nice.
|
||
const proc = process; | ||
|
||
export class YeomanProcess { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please comment ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Hello,
so AFAIK it launches yeoman from the workspace folder which should be |
VS Code extension generator does not take into account In the current code, VS Code yeoman generator is running in current node instance, not in separate. |
Signed-off-by: Vitaliy Gulyy <[email protected]>
Signed-off-by: Vitaliy Guliy <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested. Works fine.
FYI build is failing with CI
Probably you need to replace theia:plugin
by theia-plugin
in package.json file
I tried to do it before. You could scroll up to see the commit where I returned it back to 'theia:plugin'.
|
@benoitf could you merge this PR? It seems only you have right do it. |
I can merge but we need to fix first the ci issue else it won't be built and then it won't be available |
Signed-off-by: Vitaliy Gulyy <[email protected]>
As VS Code extension generator goes not take in attention an option specifying the directory for generated projects, it always generate a project into current working directory.
The idea was to run Yeoman generator in separate node instance and change current working directory to
/projects
.Fixes issue eclipse-che/che#15443
Subtask of eclipse-che/che#14228