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

support creating tasks.json from template #6391

Merged
merged 1 commit into from
Nov 6, 2019
Merged

Conversation

elaihau
Copy link
Contributor

@elaihau elaihau commented Oct 15, 2019

  • group the tasks by workspace folder in the quick open item list populated by "Terminal" -> "Configure Tasks..."
  • when "Configure Tasks" is started, check if tasks.json exists:
    • "Create tasks.json file from template" is displayed if 1) there are no detected or configured tasks, and 2) tasks.json does not exist
    • "Open tasks.json file" is displayed, if 1) tasks.json exists, and 2) no detected or configured tasks are found, display "Open tasks.json file".
  • add VS Code Task templates to Theia. CQ created http://dev.eclipse.org/ipzilla/show_bug.cgi?id=20967
  • part of Align UX for tasks with VS Code #4212

Signed-off-by: Liang Huang liang.huang@ericsson.com

How to test

  • In a multi root workspace, quick open items of "Tasks: Configure Tasks" (or "Terminal -> Configure tasks") should be grouped by the names of root folders
    1_group_by_folder

  • When tasks.json does not exist in the root folder, "Create tasks.json file from template" should show up as an option, and users should be prompted to select which template to to generate the tasks.json from
    2_no_tasks_or_config_file

  • If a non-empty tasks.json exists and there are no configured or detected tasks in the root folder, "Open tasks.json file" should show up as an option. Clicking that option opens the tasks.json by the editor.
    3_show_open_if_config_exists

Review checklist

@akosyakov akosyakov added tasks issues related to the task system vscode issues related to VSCode compatibility labels Oct 15, 2019
@akosyakov
Copy link
Member

@elaihau Are there corresponding docs how does it work in VS Code?

@elaihau
Copy link
Contributor Author

elaihau commented Oct 15, 2019

@akosyakov I followed the descriptions in this page https://code.visualstudio.com/Docs/editor/tasks#_custom-tasks

Of course, the online doc doesn’t document all the details. I experimented in vs code to figure out what should be done.

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed if no .theia/tasks.json exists, if we run the following configure tasks..., the .theia/tasks.json is already created before we select a template option. If a user cancels, they will be left with an empty tasks.json. Should we not instead wait until a choice is made before creating the file like VS Code?

See bellow for screenshare:

template

packages/task/src/browser/task-templates.ts Show resolved Hide resolved
@vince-fugnitto
Copy link
Member

@elaihau I like that we are smarter than VS Code in the case of multi-root where we prompt users to select a default template for a given root. 👍 VS Code only adds to the first root.

I'm not sure if we should keep the No tasks found, WDYT (VS Code does not display it)?

Screen Shot 2019-10-15 at 9 20 26 PM

@vince-fugnitto
Copy link
Member

I've tested the following functionality:

  • configure tasks... is correctly sorted by the roots (order of the roots in the explorer)
  • each configure tasks... template is added correctly
  • if a tasks.json exists (single & multi) then create tasks.json from template is not displayed
  • if a tasks.json exists and is empty, then open tasks.json file is displayed

Copy link
Contributor

@RomanNikitenko RomanNikitenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello!
Could you clarify the behavior:

When tasks.json does not exist in the root folder, "Create tasks.json file from template" should show up as an option, and users should be prompted to select which template to to generate the tasks.json from

I don't have tasks.json file, but I have detected tasks - should be displayed option "Create tasks.json file from template" for this case?
https://youtu.be/i0UbIGgdK0s

@RomanNikitenko
Copy link
Contributor

I tested for multi root workspace for 2 projects.
I don't have tasks.json file for both projects.
"Create tasks.json file from template" creates tasks.json under .theia folder for first project, but for second project it creates config file under .vscode folder
Please see the video: https://youtu.be/Yo--FvfZtJw

I guess the problem can be on my side, do you have idea about cause of this problem?
thanks in advance!

@akosyakov
Copy link
Member

akosyakov commented Oct 16, 2019

@RomanNikitenko Theia decides based on there you have settings.json file whether you prefer VS Code or Theia settings. In the demo, since for che-theia you have them under .vscode folder it prefers VS Code folder. .theia folder has a priority over .vscode but only if there is something, i assume it does not contain settings.json for che-theia. Otherwise it looks like a bug in Theia.

@RomanNikitenko
Copy link
Contributor

@akosyakov
I see, thank you!

@elaihau
could you check the case:

  1. open some project
  2. Use Add Folder to Workspace... to add second project
  3. Terminal => Configure Tasks => Create tasks.json file from template for second project

It works for me after refreshing page only
https://youtu.be/pSa9sORqIuw

@lmcbout
Copy link
Contributor

lmcbout commented Oct 16, 2019

I also tested the multi-workspace.
I see the same as @RomanNikitenko

When I add a new folder to workspace, "Configure Task" does NOT create the file "tasks.json" until I refreshed the front-end with this new workspace folder in it, then using the task "Configure Tasks" creates the file under .theia or .vscode (if settings.json exists under the folder)
Tested on Ubuntu 16.04 and Chrome

open some project
Use Add Folder to Workspace... to add second project
Terminal => Configure Tasks => Create tasks.json file from template for second project

@elaihau
Copy link
Contributor Author

elaihau commented Oct 17, 2019

Hello!
Could you clarify the behavior:

When tasks.json does not exist in the root folder, "Create tasks.json file from template" should show up as an option, and users should be prompted to select which template to to generate the tasks.json from

I don't have tasks.json file, but I have detected tasks - should be displayed option "Create tasks.json file from template" for this case?

@RomanNikitenko
Sorry for the confusion, I should have described the feature clearer.
"Create tasks.json file from template" should show up if

  • tasks.json does not exist, and
  • Theia is unable to find any detected tasks

I also updated the commit message and PR description to the following:

  • when "Configure Tasks" is started, check if tasks.json exists:
    • "Create tasks.json file from template" is displayed if 1) there are no detected or configured tasks, and 2) tasks.json does not exist
    • "Open tasks.json file" is displayed, if 1) tasks.json exists, and 2) no detected or configured tasks are found, display "Open tasks.json file".

I tested for multi root workspace for 2 projects.
I don't have tasks.json file for both projects.
"Create tasks.json file from template" creates tasks.json under .theia folder for first project, but for second project it creates config file under .vscode folder
Please see the video: https://youtu.be/Yo--FvfZtJw

I guess the problem can be on my side, do you have idea about cause of this problem?
thanks in advance!

What Anton said was correct.

could you check the case:

  1. open some project
  2. Use Add Folder to Workspace... to add second project
  3. Terminal => Configure Tasks => Create tasks.json file from template for second project

It works for me after refreshing page only
https://youtu.be/pSa9sORqIuw

Thank you for the review and testing, really apprecited !
@RomanNikitenko
@lmcbout
It is a bug in the TaskConfigurationManager and I fixed it with the latest change.

@elaihau
Copy link
Contributor Author

elaihau commented Oct 17, 2019

I noticed if no .theia/tasks.json exists, if we run the following configure tasks..., the .theia/tasks.json is already created before we select a template option. If a user cancels, they will be left with an empty tasks.json. Should we not instead wait until a choice is made before creating the file like VS Code?

See bellow for screenshare:

template

wow nice catch ! I updated the code to support the scenario where no templates is chosen.

While working on the update I found the QuickPickService did not work 100% the way I expected. I will connect with you online when you have time to show you the details.

Thank you for the review and the test ! @vince-fugnitto

Copy link
Contributor

@RomanNikitenko RomanNikitenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the changes after update:

  • tasks are grouped by the roots for Terminal => Configure Tasks
  • Create tasks.json file from template is displayed if there are no detected tasks and tasks.json file does not exist
  • Terminal => Configure Tasks works correctly if tasks.json file doesn't exist but detected tasks are present
  • Open tasks.json file is displayed if tasks.json file exists and no configured tasks are found
  • can not reproduce support creating tasks.json from template #6391 (comment)

@elaihau
Copy link
Contributor Author

elaihau commented Oct 19, 2019

Thank you for spending time with me on Friday. @vince-fugnitto
I figured out how to work around the problem and updated the PR.

Thanks !

- group the tasks by workspace folder in the quick open item list populated by "Terminal" -> "Configure Tasks..."
- when "Configure Tasks" is started, check if tasks.json exists:
  - "Create tasks.json file from template" is displayed if 1) there are no detected or configured tasks, and 2) tasks.json does not exist
  - "Open tasks.json file" is displayed, if 1) tasks.json exists, and 2) no detected or configured tasks are found.
- add VS Code Task templates to Theia. CQ created http://dev.eclipse.org/ipzilla/show_bug.cgi?id=20967
- part of #4212

Signed-off-by: Liang Huang <liang.huang@ericsson.com>
@elaihau
Copy link
Contributor Author

elaihau commented Nov 2, 2019

Thank you for the feedback @akosyakov your comments have been address in the lastest update.

I am still waiting for the CQ to get approved - is there a way to speed up the process ?

}
}
for (const taskConfigs of grouped.values()) {
taskConfigs.sort((t1, t2) => t1.label.localeCompare(t2.label));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, for case when tasks.json contains invalid configuration without label
Terminal => Configure Tasks can not be open without any messages to inform user about the cause, only error in browser console is displayed

configure_error

You can use the following configuration to reproduce it:

   {
      "type": "shell",
      "command": "sleep 2 && echo test",
      "problemMatcher": []
    }

I think it can be fixed within #6482

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for pointing it out ! I am working on this bug as part of 6482 :)

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code wise looks good now, please rely on @RomanNikitenko approve for testing

@elaihau elaihau merged commit 602f44d into master Nov 6, 2019
@elaihau elaihau deleted the Liang/create_tasks_json branch November 6, 2019 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tasks issues related to the task system vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants