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

[wrangler] Add experimental assets config and flag #6312

Merged
merged 4 commits into from
Jul 26, 2024

Conversation

emily-shen
Copy link
Contributor

@emily-shen emily-shen commented Jul 22, 2024

What this PR solves / how to test

Add an experimental asset config key and flag.
Doesn't really do anything yet but should have appropriate validation.
See WC-2389

Author has addressed the following

  • Tests
    • TODO (before merge)
    • Included
    • Not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required / Maybe required
    • Not required because: doesn't affect existing e2e tests
  • Changeset (Changeset guidelines)
    • TODO (before merge)
    • Included
    • Not necessary because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Not necessary because: we don't want this on the docs yet

@emily-shen emily-shen requested a review from a team as a code owner July 22, 2024 17:11
Copy link

changeset-bot bot commented Jul 22, 2024

🦋 Changeset detected

Latest commit: 443fe96

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 Jul 22, 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/10093694977/npm-package-wrangler-6312

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10093694977/npm-package-wrangler-6312 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10093694977/npm-package-create-cloudflare-6312 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10093694977/npm-package-cloudflare-kv-asset-handler-6312
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10093694977/npm-package-miniflare-6312
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10093694977/npm-package-cloudflare-pages-shared-6312
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10093694977/npm-package-cloudflare-vitest-pool-workers-6312

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


wrangler@3.66.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240718.0
workerd 1.20240718.0 1.20240718.0
workerd --version 1.20240718.0 2024-07-18

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

@emily-shen emily-shen changed the title Add experimental assets config and flag [wrangler] Add experimental assets config and flag Jul 23, 2024
@CarmenPopoviciu CarmenPopoviciu force-pushed the experimental-assets-boilerplate branch 2 times, most recently from bff744e to 58b27ed Compare July 24, 2024 10:30
Copy link
Contributor

@CarmenPopoviciu CarmenPopoviciu left a comment

Choose a reason for hiding this comment

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

Approving Emily's changes on behalf of Workers + Assets team. We should get another review though, since I added some small fixes myself

@CarmenPopoviciu CarmenPopoviciu force-pushed the experimental-assets-boilerplate branch from 58b27ed to c200ca7 Compare July 24, 2024 10:53
packages/wrangler/src/config/validation.ts Outdated Show resolved Hide resolved
packages/wrangler/src/config/validation.ts Outdated Show resolved Hide resolved
packages/wrangler/src/config/validation.ts Outdated Show resolved Hide resolved
packages/wrangler/src/deploy/index.ts Outdated Show resolved Hide resolved
@CarmenPopoviciu CarmenPopoviciu force-pushed the experimental-assets-boilerplate branch from 7b204ca to a11bea0 Compare July 24, 2024 12:19
throw new UserError(
`The directory specified by the "--experimental-assets" command line argument does not exist:\n` +
`${path.resolve(experimentalAssetsBasePath, args.experimentalAssets)}`
const experimentalAssets = args.experimentalAssets
Copy link
Contributor

Choose a reason for hiding this comment

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

this is merging args and config into one ExperimentalAssets shape for convenience. I also expect this will come in handy once we start to implement the dev/deploy behaviour, Same is done in dev

@@ -891,3 +886,8 @@ export interface UserLimits {
/** Maximum allowed CPU time for a Worker's invocation in milliseconds */
cpu_ms: number;
}

export type ExperimentalAssets = {
Copy link
Contributor

Choose a reason for hiding this comment

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

as per our sync call today, moving away from array support, as this is not something for this iteration

Comment on lines 777 to 797
const experimentalAssets = args.experimentalAssets
? { directory: args.experimentalAssets }
: config.experimental_assets;
if (experimentalAssets) {
const experimentalAssetsBasePath = getExperimentalAssetsBasePath(
config,
args.experimentalAssets
);
const resolvedExperimentalAssetsPath = path.resolve(
experimentalAssetsBasePath,
experimentalAssets.directory
);

if (!existsSync(resolvedExperimentalAssetsPath)) {
const sourceOfTruthMessage = args.experimentalAssets
? '"--experimental-assets" command line argument'
: '"experimental_assets.directory" field in your configuration file';

throw new UserError(
`The directory specified by the "--experimental-assets" command line argument does not exist:\n` +
`${path.resolve(process.cwd(), args.experimentalAssets)}`
`The directory specified by the ${sourceOfTruthMessage} does not exist:\n` +
`${resolvedExperimentalAssetsPath}`
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel a bit bad that this is a duplicate of the same code in the deploy command...

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'm aware of the code duplication. I can abstract the user error logic into a separate fn if that helps. I don't have strong opinions either way, other than that we should not abstract all of this code block away, as that might become unreadable. Plus we might see some differences as we move further into the implementation.

emily-shen and others added 4 commits July 25, 2024 13:16
This commit adds a new experimental CLI flag (`--experimental-assets`)
and configuration key (`experimental_assets`) for the new Workers +
Assets work.

The new flag and configuration key are for the time being "inactive",
in that no behaviour is attached to them yet. This will follow up in
future work.
@petebacondarwin petebacondarwin merged commit 67c611a into main Jul 26, 2024
18 checks passed
@petebacondarwin petebacondarwin deleted the experimental-assets-boilerplate branch July 26, 2024 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants