-
Notifications
You must be signed in to change notification settings - Fork 949
feat: interactively handle wonky asset deploy commands #10016
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
Conversation
🦋 Changeset detectedLatest commit: 8c6c672 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
2984c23
to
164b6fd
Compare
try { | ||
const stats = statSync(args.script); | ||
if (stats.isDirectory()) { | ||
args = await handleMaybeAssetsDeployment(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving the dir check inside handleMaybeAssetsDeployment
?
Maybe comment on handleMaybeAssetsDeployment
what the req are (i.e. directory)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the dir check here is correct but the signature on handleMaybeAssetsDeployment()
should be something like (assetDirectory: string, args: DeployArgs)
to make it clear that this function expects a directory of some kind.
const projectName = await prompt("What do you want to name your project?", { | ||
defaultValue: process.cwd().split(path.sep).pop(), | ||
}); | ||
args.name = projectName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it not get validated later in the normal deploy validation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'll validate that the default we suggest is valid, at least.
try { | ||
const stats = statSync(args.script); | ||
if (stats.isDirectory()) { | ||
args = await handleMaybeAssetsDeployment(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the dir check here is correct but the signature on handleMaybeAssetsDeployment()
should be something like (assetDirectory: string, args: DeployArgs)
to make it clear that this function expects a directory of some kind.
const projectName = await prompt("What do you want to name your project?", { | ||
defaultValue: process.cwd().split(path.sep).pop(), | ||
}); | ||
args.name = projectName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it not get validated later in the normal deploy validation?
); | ||
|
||
if (writeConfig) { | ||
const configPath = path.join(process.cwd(), "wrangler.json"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely encourage JSONC.
Moreover, we could actually create a JSONC file with comments in if we felt inclined.
const configPath = path.join(process.cwd(), "wrangler.json"); | |
const configPath = path.join(process.cwd(), "wrangler.jsonc"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use this in C3 - https://www.npmjs.com/package/comment-json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to use jsonc. i can't really think of a useful comment to add though, so i might just leave it as is. since its assets only, linking to the full wrangler config docs might just cause more confusion.
164b6fd
to
8c6c672
Compare
Interactively handle
wrangler deploy
s that are probably assets-only, where there is no config file found and flags are incorrect or missing.For example:
npx wrangler deploy ./public
will now ask if you meant to deploy an folder of assets only, ask for a name, set the compat date and then ask to write your choices out towrangler.json
for subsequent deployments.npx wrangler deploy --assets=./public
will now ask for a name, set the compat date and then ask to write your choices out towrangler.json
for subsequent deployments.In non-interactive contexts, we will error as we currently do.
Out of scope (for this PR) are worker or worker and asset deploys.