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

R package build / check / etc as tasks provided by extension #735

Merged
merged 9 commits into from
Jun 17, 2023

Conversation

juliasilge
Copy link
Contributor

@juliasilge juliasilge commented Jun 13, 2023

Addresses #28 and #122

The biggest question is whether implementing this as a task is the right call. I believe the main alternative is a command.

This is currently an initial POC and still needs:

  • additional tasks added for devtools::load_all(), checking, and probably simple testing as well
  • to detect if we are in an R package
  • implement optional resolveTask() for a better command palette experience (only need when there is no execution but all our tasks have execution)

@juliasilge
Copy link
Contributor Author

I think for an internal alpha it is OK to assume folks are devtools users. In the longer run, we will want to provide some kind of implementation for non-devtools users.

@juliasilge
Copy link
Contributor Author

A follow-up to this PR will be to bind these tasks to commands, and then key bindings.

@jmcphers
Copy link
Collaborator

For commands that are meant to be run in the current R session (e.g. load_all), there is a PR open here to add an API for a custom execution hook: #747

@juliasilge
Copy link
Contributor Author

In the longer run, we could use the problem matchers to surface problems from, say, checking, but for now I've turned them off.

@juliasilge juliasilge marked this pull request as ready for review June 16, 2023 19:49
@juliasilge
Copy link
Contributor Author

We chatted and decided that tasks are the right decision for these kinds of needs. I believe this has everything in it now for an initial change.

After this PR is merged, in the short term, I will:

In the long term, we can:

  • check if devtools is installed and if not, provide alternate implementations
  • use problem matchers to surface problems from checking
  • make the R package detection a bit more flexible, like when someone has an R package as a subdirectory of their project

export async function providePackageTasks(_context: vscode.ExtensionContext): Promise<void> {

const isRPackage = await detectRPackage();
vscode.commands.executeCommand('setContext', 'isRPackage', isRPackage);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put this here instead of commands.ts because it is executing the "setContext" command, not registering a command for users to have.

@juliasilge juliasilge requested a review from jmcphers June 16, 2023 20:17
vscode.commands.executeCommand('setContext', 'isRPackage', isRPackage);

const allPackageTasks: PackageTask[] = [
{ 'type': 'rPackageLoad', 'name': 'Load package', 'shellExecution': 'R -e "devtools::load_all()"' },
Copy link
Collaborator

Choose a reason for hiding this comment

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

The new executeCode() API is now available if you want to use it for tasks that should execute in the current R session. (I think that's at least load_all?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was going to do these two things (includes switching execution, yes) in immediate followup PRs after this one, if that is OK:

After this PR is merged, in the short term, I will:

The custom execution for tasks is just a bit more complicated and I wanted to approach it separately, unless you feel strongly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Absolutely fine to handle this in a followup!

extensions/positron-r/package.json Outdated Show resolved Hide resolved
Copy link
Collaborator

@jmcphers jmcphers left a comment

Choose a reason for hiding this comment

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

LGTM!

@juliasilge juliasilge merged commit f6183ee into main Jun 17, 2023
@juliasilge juliasilge deleted the feature/r-pkg-build-task branch June 17, 2023 17:56
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