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

Reduce the usage of appPath #696

Merged
merged 4 commits into from
Feb 23, 2023
Merged

Reduce the usage of appPath #696

merged 4 commits into from
Feb 23, 2023

Conversation

hadley
Copy link
Member

@hadley hadley commented Feb 22, 2023

  • I think the hooks should always get a directory, not sometimes a path.

  • It's clear that deploymentTarget should get the path where the deployments are recorded

@aronatkins this is part of a very gradual unpicking of the complicated appPath/recordDir logic in deployApp().

* I think the hooks should always get a directory, not sometimes a path.

* It's clear that `deploymentTarget` should get the path where the deployments are recorded
@hadley
Copy link
Member Author

hadley commented Feb 22, 2023

I think this suggests that appSourceDoc doesn't do anything useful and could be deprecated:

  • appSourceDoc is only used in one place to set appPath.
  • After this PR, appPath is only to set recordDir

So appSourceDoc just acts an alias for recordDir.

I reviewed the code from v0.8.29 (https://github.com/rstudio/rsconnect/blob/v0.8.29/R/deployApp.R) to make sure I hadn't accidentally refactored out some other use case, but it doesn't look like it. And looking at the commit where it was added shows that recordDir didn't exist at that time. PR that added recordDir: #290

If I deprecate it, also need to adjust deploySite() to use recordDir instead.

Copy link
Contributor

@aronatkins aronatkins left a comment

Choose a reason for hiding this comment

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

Unsure if we can safely shift the hooks from using the path (DIR/document.Rmd) to always using the project directory... there are very few public references to be found.

@@ -237,7 +237,7 @@ deployApp <- function(appDir = getwd(),
}

# invoke pre-deploy hook if we have one
runDeploymentHook(appPath, "rsconnect.pre.deploy", verbose = verbose)
runDeploymentHook(appDir, "rsconnect.pre.deploy", verbose = verbose)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a functional change to package contract, correct? Given a target Rmd in a directory containing lots of Rmd, how will the hook know what you're about to deploy?

This work initially landed with #283 and #295, but without a specific motivating example.

Additionally, I think the IDE deploy pane transfers many (most? all?) R options and environment variables from the R session to the deploy pane (without using these hooks).

I did find one issue referencing this hook:

and a reference from thematic!!:

Unfortunately, I don't know of many in-the-wild uses of this feature that might care about the file-path vs. directory change. At the very least, we should NEWS this adjustment and mark it as a potentially breaking change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this is a change, and the documentation for the hooks is murky:

\item{\code{rsconnect.pre.deploy}}{A function to run prior to deploying content; it receives as an argument the path to the content that's about to be deployed.}

What does "content about to be deployed" mean? (especially if you've used appFiles or friends).

My guess is that this won't affect any code in the wild, but I'll add a news bullet.

FWIW I think the thematic usage would break when appPath is not a directory.

@aronatkins
Copy link
Contributor

Agreed that appSourceDoc feels redundant and can be replaced by deploySite computing an appropriate recordDir.

@@ -247,7 +247,7 @@ deployApp <- function(appDir = getwd(),
}

# determine the deployment target and target account info
target <- deploymentTarget(appPath, appName, appTitle, appId, account, server)
target <- deploymentTarget(recordDir, appName, appTitle, appId, account, server)
Copy link
Contributor

Choose a reason for hiding this comment

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

Internally, deploymentTarget calls this argument appPath; should it be renamed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've renamed it to recordPath, in anticipation of renaming recordDir to recordPath in a future PR.

@@ -18,11 +18,10 @@ deploymentTarget <- function(appPath = ".",
if (nrow(appDeployments) == 0) {
fullAccount <- findAccount(account, server)
if (is.null(appName)) {
appName <- generateAppName(appTitle, appPath, account, unique = FALSE)
appName <- generateAppName(appTitle, recordPath, account, unique = FALSE)
Copy link
Member Author

Choose a reason for hiding this comment

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

This reinforces that the recordPath really should be original source of the content.

@hadley hadley merged commit abb6104 into main Feb 23, 2023
@hadley hadley deleted the reduce-appPath branch February 23, 2023 13:36
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