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

fix: create d1 dir on wrangler d1 execute command with --yes/-y option #2623

Merged
merged 1 commit into from
Jan 26, 2023

Conversation

dario-piotrowicz
Copy link
Member

@dario-piotrowicz dario-piotrowicz commented Jan 25, 2023

What this PR solves / how to test:

Associated docs issues/PR:

  • [insert associated docs issue(s)/PR(s)]

Author has included the following, where applicable:

  • Tests
  • Changeset

Reviewer has performed the following, where applicable:

  • Checked for inclusion of relevant tests
  • Checked for inclusion of a relevant changeset
  • Checked for creation of associated docs updates
  • Manually pulled down the changes and spot-tested

Fixes # [insert issue number].

Sorry, something went wrong.

@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner January 25, 2023 14:33
@changeset-bot
Copy link

changeset-bot bot commented Jan 25, 2023

🦋 Changeset detected

Latest commit: 240c1b2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
Copy link
Contributor

@rozenmd rozenmd left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@codecov
Copy link

codecov bot commented Jan 25, 2023

Codecov Report

Merging #2623 (240c1b2) into main (416babf) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2623      +/-   ##
==========================================
- Coverage   73.19%   73.19%   -0.01%     
==========================================
  Files         159      159              
  Lines        9847     9848       +1     
  Branches     2622     2624       +2     
==========================================
  Hits         7208     7208              
- Misses       2639     2640       +1     
Impacted Files Coverage Δ
packages/wrangler/src/d1/execute.tsx 16.80% <0.00%> (-0.14%) ⬇️

Copy link
Contributor

@JacobMGEvans JacobMGEvans left a comment

Choose a reason for hiding this comment

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

The confirm infers automation environments, CI/CD, non-TTY, etc... Then does an automatic skip of prompts. Is there another reason besides those for this flag?

@github-actions
Copy link
Contributor

github-actions bot commented Jan 25, 2023

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/runs/4006950162/npm-package-wrangler-2623

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/prs/2623/npm-package-wrangler-2623

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/runs/4006950162/npm-package-wrangler-2623 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/runs/4006950162/npm-package-cloudflare-pages-shared-2623

@rozenmd
Copy link
Contributor

rozenmd commented Jan 25, 2023

the same as wrangler init -y @JacobMGEvans, "wrangler, I know what I'm doing, just give me the thing"

@dario-piotrowicz
Copy link
Member Author

@JacobMGEvans yeah that's like @rozenmd mentioned, specifically I have some d1 apps I want to share, they have a dev script with runs multiple stuff in parallel, the issue there is that the prompt makes things awkward (what if the developer doesn't accept for example? or the d1 prompt can gets lost in other cli text)

but yeah it boils down to the fact that I am providing the command to execute and I know that it's going to create the db, there is no reason to ask me (of the devs I share the apps with) to confirm

@JacobMGEvans
Copy link
Contributor

@JacobMGEvans yeah that's like @rozenmd mentioned, specifically I have some d1 apps I want to share, they have a dev script with runs multiple stuff in parallel, the issue there is that the prompt makes things awkward (what if the developer doesn't accept for example? or the d1 prompt can gets lost in other cli text)

but yeah it boils down to the fact that I am providing the command to execute and I know that it's going to create the db, there is no reason to ask me (of the devs I share the apps with) to confirm

Thank you for the elaboration.

Copy link
Contributor

@JacobMGEvans JacobMGEvans left a comment

Choose a reason for hiding this comment

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

Given the clarification that this is more to handle User workflows and not automation environments, the implementation makes sense.

Copy link
Contributor

@JacobMGEvans JacobMGEvans left a comment

Choose a reason for hiding this comment

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

This needs an associated cloudflare-docs PR Uses preexisting --yes flag

Any particular reason there isn't a test, like it's hard to test?

@rozenmd
Copy link
Contributor

rozenmd commented Jan 25, 2023

This needs an associated cloudflare-docs PR

@JacobMGEvans no it doesn't? it's a bug fix

@JacobMGEvans
Copy link
Contributor

This needs an associated cloudflare-docs PR

@JacobMGEvans no it doesn't? it's a bug fix

Ah I see you're using an existing top --yes not adding one for the fix. Not sure why I thought it was adding one 😆

@rozenmd rozenmd requested a review from JacobMGEvans January 25, 2023 20:19
Copy link
Contributor

@JacobMGEvans JacobMGEvans left a comment

Choose a reason for hiding this comment

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

It is a simple fix, if we can write a test that covers the scenario that was previously breaking to help prevent the same bug or similar in the future that would be awesome 😃

Comment on lines +205 to +206
!shouldPrompt ||
(await confirm(`About to create ${readableRelative(dbPath)}, ok?`));
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we please get a test that covers the bug, for posterity 😄

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 I considered that and asked @rozenmd about it, if I understood correctly he did mention that there isn't a proper test suite for d1 commands and that we could go with the fix as is.

If you want I could look into adding a test now but I'd have to set up the test suite (to some degree at least) I guess but since I am not familiar with things in this codebase nor I am really involved in d1 I'd imagine that it would be better for someone else to start (and I can add the test at that point?).

or I can give it a shot now if you think that'd be ok, I would be up for it 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I considered that and asked @rozenmd about it, if I understood correctly he did mention that there isn't a proper test suite for d1 commands and that we could go with the fix as is.

If you want I could look into adding a test now but I'd have to set up the test suite (to some degree at least) I guess but since I am not familiar with things in this codebase nor I am really involved in d1 I'd imagine that it would be better for someone else to start (and I can add the test at that point?).

or I can give it a shot now if you think that'd be ok, I would be up for it 🙂

If you are willing to try, I am willing to help as well. Anything we both can't figure out we can kick towards Max 😆

Copy link
Contributor

@JacobMGEvans JacobMGEvans Jan 25, 2023

Choose a reason for hiding this comment

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

Additionally if you want to just get this fix in and do a fast follow Test PR (since none previously existed) I would support that in this particular case given the circumstances.

Copy link
Member Author

Choose a reason for hiding this comment

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

ah sorry, I just now say the comment about merging the PR anyways, thanks 🙂👍

@rozenmd rozenmd dismissed JacobMGEvans’s stale review January 26, 2023 10:21

Additionally if you want to just get this fix in and do a fast follow Test PR (since none previously existed) I would support that in this particular case given the circumstances.

@rozenmd rozenmd merged commit 04d8a31 into cloudflare:main Jan 26, 2023
@github-actions github-actions bot mentioned this pull request Jan 26, 2023
@dario-piotrowicz dario-piotrowicz deleted the fix-mkdir-execute-d1 branch January 28, 2023 22:13
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.

None yet

3 participants