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

quarto use support for non-empty directories #8764

Merged
merged 5 commits into from
Feb 19, 2024
Merged

Conversation

dragonstyle
Copy link
Collaborator

@dragonstyle dragonstyle commented Feb 16, 2024

Add for executing the quarto use command in non-empty directories. This requires some additional improvements to the overall installation process as outlined below. (Fixes #8595)

When prompting is enabled

  • The user may always elect to install into the current directory
  • If the user selects the current directory, its folder name will be used as the name for the main qmd (e.g. a folder named my-article will contain the file my-article.qmd once the template has been used).
  • The user may still elect to use a subdirectory
  • The use command will now explicitly use extension installation to compare any existing extensions with extensions provided by the template. The user is presented with an option to accept the extension changes or exit.
  • The use command will now prompt before overwriting a conflicting file. If there are no file conflicts, it will not prompt.

When prompting is not enabled

  • If prompting is not allowed (e.g. in CI), quarto use will error when attempting to use a template in a non-empty directory. It the responsibility of the calling script to ensure that the working directory for quarto use is empty.

Tests

This PR adds tests that verify

  • basic unprompted installation works as expected
  • unprompted non-empty installation throws an error

Example Session

The following example shell session uses two different templates in the same working directory:

charlesteague@MacBook-Pro journal-article % quarto use template quarto-journals/jasa

Quarto templates may execute code when documents are rendered. If you do not
trust the authors of the template, we recommend that you do not install or
use the template.
 ? Do you trust the authors of this template (Y/n) › Yes
 ? Create a subdirectory for template? (y/N) › No
[✓] Downloading
[✓] Unzipping

The template requires the following changes to extensions:
Journal of the American Statistical Association   [Install]   0.10.1 (formats)
 ? Would you like to continue (Y/n) › Yes

Preparing template files...

[✓] Copying
[✓] Installing extensions...
[✓] Copying files...

Extensions installed:
 - Journal of the American Statistical Association

Files created:
 - agsm.bst
 - bibliography.bib
 - fig1.pdf
 - journal-article.qmd
charlesteague@MacBook-Pro journal-article % quarto use template quarto-journals/jss

Quarto templates may execute code when documents are rendered. If you do not
trust the authors of the template, we recommend that you do not install or
use the template.
 ? Do you trust the authors of this template (Y/n) › Yes
 ? Create a subdirectory for template? (Y/n) › No
[✓] Downloading
[✓] Unzipping

The template requires the following changes to extensions:
Journal of Statistical Software Format   [Install]   0.9.4 (formats)
 ? Would you like to continue (Y/n) › Yes

Preparing template files...
 ? Overwrite file bibliography.bib? (y/n) › No
 ? Overwrite file journal-article.qmd? (y/n) › No

[✓] Copying
[✓] Installing extensions...
[✓] Copying files...

Extensions installed:
 - Journal of Statistical Software Format

Files created:
 - article-visualization.pdf
charlesteague@MacBook-Pro journal-article %

Don’t prevent the user from using the current directory if there are files present. Instead, just ask whether to create a subdirectory and use the proper defaulting of the answer.
Before template files are overwritten, prompt whether they should be overwritten
Use the internal extension installation information to confirm the installation of extensions. Allow user to abort if they don’t want to overwrite.
@dragonstyle dragonstyle added this to the v1.5 milestone Feb 16, 2024
@dragonstyle dragonstyle merged commit 83899e2 into main Feb 19, 2024
47 checks passed
@dragonstyle dragonstyle deleted the feature/use-overwrite branch February 19, 2024 21:12
cderv added a commit that referenced this pull request Apr 3, 2024
`quarto use template` can be used to copy files from a remote even if it does not have extension

Tweaks from #8764 regarding installation of extension only needs to happen if there is an `_extension` folder
cderv added a commit that referenced this pull request Jun 4, 2024
`quarto use template` can be used to copy files from a remote even if it does not have extension

Tweaks from #8764 regarding installation of extension only needs to happen if there is an `_extension` folder
cderv added a commit that referenced this pull request Jun 4, 2024
`quarto use template` can be used to copy files from a remote even if it does not have extension

Tweaks from #8764 regarding installation of extension only needs to happen if there is an `_extension` folder
cderv added a commit to cderv/quarto-cli that referenced this pull request Jun 10, 2024
`quarto use template` can be used to copy files from a remote even if it does not have extension

Tweaks from quarto-dev#8764 regarding installation of extension only needs to happen if there is an `_extension` folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow quarto use to download to the current directory
1 participant