Skip to content

Commit

Permalink
chore: use --x-include-runtime instead of --x-with-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjessop committed Jul 23, 2024
1 parent 37668a0 commit a2eed89
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
6 changes: 0 additions & 6 deletions fixtures/worker-app/worker-configuration.d.ts

This file was deleted.

12 changes: 6 additions & 6 deletions packages/wrangler/e2e/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("types", () => {
it("should generate runtime types at the default path", async () => {
const helper = new WranglerE2ETestHelper();
await helper.seed(seed);
const output = await helper.run(`wrangler types --x-with-runtime`);
const output = await helper.run(`wrangler types --x-include-runtime`);

const fileExists = existsSync(
path.join(helper.tmpPath, "./.wrangler/types/runtime.d.ts")
Expand All @@ -59,15 +59,15 @@ describe("types", () => {
`📣 It looks like you have some Node.js compatibility turned on in your project. You might want to consider adding Node.js typings with "npm i --save-dev @types/node@20.8.3". Please see the docs for more details: https://developers.cloudflare.com/workers/languages/typescript/#transitive-loading-of-typesnode-overrides-cloudflareworkers-types`
);
expect(output.stdout).toContain(
`Remember to run 'wrangler types --x-with-runtime' again if you change 'compatibility_date' or 'compatibility_flags' in your wrangler.toml.`
`Remember to run 'wrangler types --x-include-runtime' again if you change 'compatibility_date' or 'compatibility_flags' in your wrangler.toml.`
);
});

it("should generate runtime types at the provided path", async () => {
const helper = new WranglerE2ETestHelper();
await helper.seed(seed);
const output = await helper.run(
`wrangler types --x-with-runtime="./types.d.ts"`
`wrangler types --x-include-runtime="./types.d.ts"`
);

const fileExists = existsSync(path.join(helper.tmpPath, "./types.d.ts"));
Expand All @@ -80,7 +80,7 @@ describe("types", () => {
it("should generate types", async () => {
const helper = new WranglerE2ETestHelper();
await helper.seed(seed);
await helper.run(`wrangler types --x-with-runtime="./types.d.ts"`);
await helper.run(`wrangler types --x-include-runtime="./types.d.ts"`);

const file = (
await readFile(path.join(helper.tmpPath, "./types.d.ts"))
Expand All @@ -102,7 +102,7 @@ describe("types", () => {
`,
});
const output = await helper.run(
`wrangler types --x-with-runtime="./types.d.ts"`
`wrangler types --x-include-runtime="./types.d.ts"`
);

expect(output.stdout).toContain(
Expand All @@ -123,7 +123,7 @@ describe("types", () => {
`,
});
const output = await helper.run(
`wrangler types --x-with-runtime="./types.d.ts"`
`wrangler types --x-include-runtime="./types.d.ts"`
);

expect(output.stdout).not.toContain(
Expand Down
12 changes: 6 additions & 6 deletions packages/wrangler/src/type-generation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export function typesOptions(yargs: CommonYargsArgv) {
describe: "The name of the generated environment interface",
requiresArg: true,
})
.option("experimental-with-runtime", {
alias: "x-with-runtime",
.option("experimental-include-runtime", {
alias: "x-include-runtime",
type: "string",
describe: "The outfile for runtime types",
describe: "The path of the generated runtime types file",
demandOption: false,
});
}
Expand Down Expand Up @@ -80,13 +80,13 @@ export async function typesHandler(

const config = readConfig(configPath, args);

// args.xRuntime will be a string if the user passes "--x-runtime" or "--x-runtime=..."
if (typeof args.experimentalWithRuntime === "string") {
// args.xRuntime will be a string if the user passes "--x-include-runtime" or "--x-include-runtime=..."
if (typeof args.experimentalIncludeRuntime === "string") {
logger.log(`Generating runtime types...`);

const { outFile } = await generateRuntimeTypes({
config,
outFile: args.experimentalWithRuntime || undefined,
outFile: args.experimentalIncludeRuntime || undefined,
});

const tsconfigPath =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function logRuntimeTypesMessage(
);
}
logger.info(
"📣 Remember to run 'wrangler types --x-with-runtime' again if you change 'compatibility_date' or 'compatibility_flags' in your wrangler.toml.\n"
"📣 Remember to run 'wrangler types --x-include-runtime' again if you change 'compatibility_date' or 'compatibility_flags' in your wrangler.toml.\n"
);
}

Expand Down

0 comments on commit a2eed89

Please sign in to comment.