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

feat: add options to readConfig() to specify control how we deal with missing environment definitions #7605

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

petebacondarwin
Copy link
Contributor

Fixes #0000

This will be used by the Vite plugin, since vite dev command will always set the environment
to "development", and we don't want the user to have to define this explicitly if they don't want to.
In such cases there is no need for the user to define this environment explicitly,
even if there are other environments defined.


  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal API only

@petebacondarwin petebacondarwin added the e2e Run e2e tests on a PR label Dec 20, 2024
@petebacondarwin petebacondarwin requested a review from a team as a code owner December 20, 2024 15:25
Copy link

changeset-bot bot commented Dec 20, 2024

🦋 Changeset detected

Latest commit: 84cd433

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

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers 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

Copy link
Contributor

github-actions bot commented Dec 20, 2024

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/12466894588/npm-package-wrangler-7605

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12466894588/npm-package-wrangler-7605 dev path/to/script.js
Additional artifacts:
wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12466894588/npm-package-cloudflare-workers-bindings-extension-7605 -O ./cloudflare-workers-bindings-extension.0.0.0-v1aabb293d.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v1aabb293d.vsix
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12466894588/npm-package-create-cloudflare-7605 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12466894588/npm-package-cloudflare-kv-asset-handler-7605
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12466894588/npm-package-miniflare-7605
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12466894588/npm-package-cloudflare-pages-shared-7605
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12466894588/npm-package-cloudflare-unenv-preset-7605
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12466894588/npm-package-cloudflare-vitest-pool-workers-7605
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12466894588/npm-package-cloudflare-workers-editor-shared-7605
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12466894588/npm-package-cloudflare-workers-shared-7605
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12466894588/npm-package-cloudflare-workflows-shared-7605

Note that these links will no longer work once the GitHub Actions artifact expires.


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20241218.0
workerd 1.20241218.0 1.20241218.0
workerd --version 1.20241218.0 2024-12-18

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

Copy link
Contributor

@jamesopstad jamesopstad left a comment

Choose a reason for hiding this comment

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

This looks good. Did you mean to also include the change where environment names are not appended if the environment is specified but there is only a top-level environment?

packages/wrangler/src/__tests__/configuration.test.ts Outdated Show resolved Hide resolved
@petebacondarwin
Copy link
Contributor Author

Did you mean to also include the change where environment names are not appended if the environment is specified but there is only a top-level environment?

Thanks. I missed that. I fixed it now but it resulted in some renaming of the options to make them make sense. PTAL @jamesopstad

Copy link
Contributor

@jamesopstad jamesopstad left a comment

Choose a reason for hiding this comment

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

Thanks Pete. I feel like the following test cases need to be added. They may already pass but I'm not totally confident from looking at the code.

it("should update the worker name if an environment is requested that is defined and allowEnvironmentsWhenNoneAreDefined is true")

it("should update the worker name if an environment name in optionalEnvironments is requested that is defined")

Is the second one the behaviour we agreed on?

packages/wrangler/src/__tests__/configuration.test.ts Outdated Show resolved Hide resolved
packages/wrangler/src/__tests__/configuration.test.ts Outdated Show resolved Hide resolved
packages/wrangler/src/__tests__/configuration.test.ts Outdated Show resolved Hide resolved
.changeset/rare-dolls-buy.md Outdated Show resolved Hide resolved
packages/wrangler/src/__tests__/configuration.test.ts Outdated Show resolved Hide resolved
packages/wrangler/src/__tests__/configuration.test.ts Outdated Show resolved Hide resolved
@petebacondarwin
Copy link
Contributor Author

it("should update the worker name if an environment name in optionalEnvironments is requested that is defined")
Is the second one the behaviour we agreed on?

Yes, I believe this is what we agreed. If the user has defined the environment that is selected, then it will do its normal processing.

I am still wondering about this though. If the user doesn't have a production environment defined and they deploy the worker name will not be suffixed. But as soon as the define an environment it will be suffixed, and they would have to provide a specific Worker name in that environment to get the same name as before. Is this what we want?

@petebacondarwin petebacondarwin force-pushed the pbd/vite-integration-add-options-to-readme branch from 1f111f1 to f8ebd50 Compare December 23, 2024 10:59
…ronments

In such cases there is no need for the user to define this environment explicitly,
even if there are other environments defined.

This will be used by the Vite plugin, since `vite dev` command will always set the environment
to "development", and we don't want the user to have to define this explicitly if they don't want to.
@petebacondarwin petebacondarwin force-pushed the pbd/vite-integration-add-options-to-readme branch from c14d123 to 84cd433 Compare December 23, 2024 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e tests on a PR
Projects
Status: Untriaged
Development

Successfully merging this pull request may close these issues.

2 participants