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(wrangler): setup x-provision flag #7348

Merged
merged 6 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/wrangler/src/api/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export async function unstable_dev(
...options,
logLevel: options?.logLevel ?? defaultLogLevel,
port: options?.port ?? 0,
experimentalProvision: undefined,
experimentalVersions: undefined,
experimentalDevEnv: undefined,
experimentalRegistry: fileBasedRegistry,
Expand Down
10 changes: 10 additions & 0 deletions packages/wrangler/src/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { processAssetsArg, validateAssetsArgsAndConfig } from "../assets";
import { configFileName, findWranglerConfig, readConfig } from "../config";
import { getEntry } from "../deployment-bundle/entry";
import { UserError } from "../errors";
import { run } from "../experimental-flags";
import {
getRules,
getScriptName,
Expand Down Expand Up @@ -234,6 +235,15 @@ export function deployOptions(yargs: CommonYargsArgv) {
export type DeployArgs = StrictYargsOptionsToInterface<typeof deployOptions>;

export async function deployHandler(args: DeployArgs) {
await run(
{
RESOURCES_PROVISION: args.experimentalProvision,
},
() => deployWorker(args)
);
}

async function deployWorker(args: DeployArgs) {
await printWranglerBanner();

// Check for deprecated `wrangler publish` command
Expand Down
3 changes: 2 additions & 1 deletion packages/wrangler/src/experimental-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { AsyncLocalStorage } from "async_hooks";
import { logger } from "./logger";

type ExperimentalFlags = {
FILE_BASED_REGISTRY: boolean;
FILE_BASED_REGISTRY?: boolean;
RESOURCES_PROVISION?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Was there a reason to make these optional? Since it's an internal API I feel like it'd be better to keep these required?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mostly to avoid the need to update the feature flag on every place we run an async context. If you prefer making it explicit, I can change that.

Copy link
Member Author

Choose a reason for hiding this comment

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

};

const flags = new AsyncLocalStorage<ExperimentalFlags>();
Expand Down
1 change: 1 addition & 0 deletions packages/wrangler/src/generate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export async function generateHandler(args: GenerateArgs) {
_: args._,
$0: args.$0,
experimentalVersions: args.experimentalVersions,
experimentalProvision: args.experimentalProvision,
});
}

Expand Down
6 changes: 6 additions & 0 deletions packages/wrangler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ export function createCLIParser(argv: string[]) {

return true;
})
.option("experimental-provision", {
describe: `Automatic resources provision`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
describe: `Automatic resources provision`,
describe: `Experimental: Enable automatic resource provisioning`,

Copy link
Member Author

@edmundhung edmundhung Nov 27, 2024

Choose a reason for hiding this comment

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

type: "boolean",
hidden: true,
alias: ["x-provision"],
})
.epilogue(
`Please report any issues to ${chalk.hex("#3B818D")(
"https://github.com/cloudflare/workers-sdk/issues/new/choose"
Expand Down
1 change: 1 addition & 0 deletions packages/wrangler/src/yargs-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface CommonYargsOptions {
config: string | undefined;
env: string | undefined;
"experimental-versions": boolean | undefined;
"experimental-provision": boolean | undefined;
}

/**
Expand Down
Loading