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: read isLegacyEnv correctly #807

Merged
merged 1 commit into from
Apr 15, 2022
Merged

fix: read isLegacyEnv correctly #807

merged 1 commit into from
Apr 15, 2022

Conversation

threepointone
Copy link
Contributor

@threepointone threepointone commented Apr 15, 2022

This fixes the signature for isLegacyEnv() since it doesn't use args, and we fix reading legacy_env correctly when creating a draft worker when creating a secret.

@changeset-bot
Copy link

changeset-bot bot commented Apr 15, 2022

🦋 Changeset detected

Latest commit: c277a07

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

@github-actions
Copy link
Contributor

github-actions bot commented Apr 15, 2022

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

npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2173999288/npm-package-wrangler-807

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

npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/807/npm-package-wrangler-807

Or you can use npx with this latest build directly:

npx https://prerelease-registry.developers.workers.dev/runs/2173999288/npm-package-wrangler-807 dev path/to/script.js

@threepointone threepointone requested a review from caass April 15, 2022 15:49
Copy link
Contributor

@caass caass left a comment

Choose a reason for hiding this comment

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

approving pending an answer on why the change u mentioned was made. makes sense otherwise

@threepointone
Copy link
Contributor Author

yeah I'll let @JacobMGEvans have a look before I merge, thank you!

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Can you double check that this is actually broken?

@threepointone threepointone changed the title fix: read args["legacy-env"] correctly fix: read isLgeacyEnv correctly Apr 15, 2022
@threepointone threepointone changed the title fix: read isLgeacyEnv correctly fix: read isLegacyEnv correctly Apr 15, 2022
@threepointone threepointone force-pushed the fix-read-legacy-env branch 3 times, most recently from 0b83e2c to b160168 Compare April 15, 2022 17:20
@JacobMGEvans
Copy link
Contributor

JacobMGEvans commented Apr 15, 2022

This function is checking for validation of configuration

const isLegacyEnv =
    (args as { "legacy-env": boolean | undefined })["legacy-env"] ??
    rawConfig.legacy_env ??
    true;

This function seems to be checking against only the config which I think I missed when moving args to be generically passed to the validation check for the normalizeAndValidateConfig I would question if instead of removing the args from the param/argument of this helper, it should just look like the validator function; checking args then config to confirm which mode it is in.

function isLegacyEnv(args: unknown, config: Config): boolean {
  return config.legacy_env;
}

@threepointone
Copy link
Contributor Author

It doesn't check args though, which is confusing. It's just a local helper, let's have it take only what it needs.

@JacobMGEvans
Copy link
Contributor

JacobMGEvans commented Apr 15, 2022

It doesn't check args though, which is confusing. It's just a local helper, let's have it take only what it needs.

What I am saying is it should take both and use them, since the local helper is checking which mode it is in.
It is unclear to me why we would check args and config in the validator but not the helper checking what mode it is in locally which args is in scope of.

It is being resolved BY the validation and passed into CONFIG so the args is already resolved in the CLI parsing. (I wrote this refactor and forgot how it worked 😅 )

This fixes the signature for `isLegacyEnv()` since it doesn't use args, and we fix reading legacy_env correctly when creating a draft worker when creating a secret.
@threepointone
Copy link
Contributor Author

Landing this since it's now a smaller fix, and Pete's on leave and I don't want to bother him more haha.

@threepointone threepointone merged commit 7e560e1 into main Apr 15, 2022
@threepointone threepointone deleted the fix-read-legacy-env branch April 15, 2022 19:17
@github-actions github-actions bot mentioned this pull request Apr 15, 2022
@petebacondarwin
Copy link
Contributor

The original idea was to drop the isLegacyEnv() function altogether but we were going to do it in a follow up PR.

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.

4 participants