-
Notifications
You must be signed in to change notification settings - Fork 736
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
chore: defineCommand refactor for wrangler types
and tail
#7220
base: main
Are you sure you want to change the base?
Conversation
|
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/workers-sdk/runs/11854761777/npm-package-wrangler-7220 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/7220/npm-package-wrangler-7220 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11854761777/npm-package-wrangler-7220 dev path/to/script.js Additional artifacts:npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11854761777/npm-package-create-cloudflare-7220 --no-auto-update npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11854761777/npm-package-cloudflare-kv-asset-handler-7220 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11854761777/npm-package-miniflare-7220 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11854761777/npm-package-cloudflare-pages-shared-7220 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11854761777/npm-package-cloudflare-vitest-pool-workers-7220 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11854761777/npm-package-cloudflare-workers-editor-shared-7220 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11854761777/npm-package-cloudflare-workers-shared-7220 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11854761777/npm-package-cloudflare-workflows-shared-7220 Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
e05e304
to
f087b10
Compare
const validInterfaceRegex = /^[a-zA-Z][a-zA-Z0-9_]*$/; | ||
|
||
if (!validInterfaceRegex.test(envInterface)) { | ||
throw new CommandLineArgsError( | ||
`The provided env-interface value ("${envInterface}") does not satisfy the validation regex: ${validInterfaceRegex}` | ||
); | ||
} | ||
if (!validInterfaceRegex.test(envInterface)) { | ||
throw new CommandLineArgsError( | ||
`The provided env-interface value ("${envInterface}") does not satisfy the validation regex: ${validInterfaceRegex}` | ||
); | ||
} | ||
|
||
if (!outputPath.endsWith(".d.ts")) { | ||
throw new CommandLineArgsError( | ||
`The provided path value ("${outputPath}") does not point to a declaration file (please use the 'd.ts' extension)` | ||
); | ||
} | ||
if (!outputPath.endsWith(".d.ts")) { | ||
throw new CommandLineArgsError( | ||
`The provided path value ("${outputPath}") does not point to a declaration file (please use the 'd.ts' extension)` | ||
); | ||
} |
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.
The difference you see on the tests seems to be caused by us calling readConfig
before the handler. Move these logic to validateArgs
might fix it
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.
ugh it isn't failing locally, that's super weird - but good point
edit: nope, the tests are failing for tail and this is for types (sorry again for having the two in one PR 😅 ...)
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.
oh sorry do you mean the tests I modify? Yeah those have changed because readConfig
is running first. Don't think moving these into validateArgs would fix it, but arguably makes sense to do anyway 👍
Could have moved the config file check into validateArgs, but I thought it would be better to have readConfig
handle the case where the specified config file doesn't exist since that's a general error (hence getting a ParseError now), and the type gen handler to handle the case where there is no config file at all, since that's a wrangler types
specific error.
41a2720
to
8be89ec
Compare
07d09c6
to
2669795
Compare
await expect( | ||
runWrangler("types -c hello.toml") | ||
).rejects.toThrowErrorMatchingInlineSnapshot( | ||
`[ParseError: Could not read file: hello.toml]` |
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.
This seems like a slightly worse error message—is there any way we can improve it?
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.
think its okay as it does also output ENOENT: no such file or directory...
but that didn't show up in the snapshot for some reason 🤔
50590c5
to
1338784
Compare
moving another couple of commands to defineCommand
related #6655