Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions .changeset/bump-undici.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"wrangler": patch
"miniflare": patch
---

Bump undici from 7.18.2 to 7.24.4
11 changes: 11 additions & 0 deletions .changeset/c3-frameworks-update-12907.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"create-cloudflare": patch
---

Update dependencies of "create-cloudflare"

The following dependency versions have been updated:

| Dependency | From | To |
| ------------ | ------ | ----- |
| create-astro | 4.13.2 | 5.0.0 |
7 changes: 7 additions & 0 deletions .changeset/quick-items-shine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

Simplify description of --json option

Remove extraneous adjectives in the description of the `--json` option.
7 changes: 7 additions & 0 deletions .changeset/warm-mirrors-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

Reject cross-drive module paths in Pages Functions routing

On Windows, module paths using a different drive letter could be parsed in a way that bypassed the project-root check. These paths are now parsed correctly and rejected when they resolve outside the project.
2 changes: 1 addition & 1 deletion packages/create-cloudflare/src/frameworks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"so that we can use dependabot to update these dependencies automatically."
],
"dependencies": {
"create-astro": "4.13.2",
"create-astro": "5.0.0",
"create-analog": "2.3.1",
"@angular/create": "21.2.2",
"create-docusaurus": "3.9.2",
Expand Down
6 changes: 4 additions & 2 deletions packages/vite-plugin-cloudflare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ Full documentation can be found [here](https://developers.cloudflare.com/workers
- Uses the Vite [Environment API](https://vite.dev/guide/api-environment) to integrate Vite with the Workers runtime
- Provides direct access to [Workers runtime APIs](https://developers.cloudflare.com/workers/runtime-apis/) and [bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/)
- Builds your front-end assets for deployment to Cloudflare, enabling you to build static sites, SPAs, and full-stack applications
- Official support for [React Router v7](https://reactrouter.com/) with server-side rendering
- Official support for [TanStack Start](https://tanstack.com/start/) and [React Router v7](https://reactrouter.com/) with server-side rendering
- Leverages Vite's hot module replacement for consistently fast updates
- Supports `vite preview` for previewing your build output in the Workers runtime prior to deployment

## Use cases

- React Router v7 (support for more full-stack frameworks is coming soon)
- [TanStack Start](https://tanstack.com/start/)
- [React Router v7](https://reactrouter.com/)
- Support for more full-stack frameworks is coming soon
- Static sites, such as single-page applications, with or without an integrated backend API
- Standalone Workers
- Multi-Worker applications
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe("containers instances", () => {

OPTIONS
--per-page Number of instances per page [number] [default: 25]
--json Return output as clean JSON [boolean] [default: false]"
--json Return output as JSON [boolean] [default: false]"
`);
});

Expand Down
53 changes: 53 additions & 0 deletions packages/wrangler/src/__tests__/pages/routes-module.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { UserError } from "@cloudflare/workers-utils";
import { describe, it } from "vitest";
import { writeRoutesModule } from "../../pages/functions/routes";
import { toUrlPath } from "../../paths";
import { runInTempDir } from "../helpers/run-in-tmp";

describe("routes module", () => {
runInTempDir();

it("accepts module paths when srcDir is a relative path", async ({
expect,
}) => {
await expect(
writeRoutesModule({
config: {
routes: [
{
routePath: toUrlPath("/"),
mountPath: toUrlPath("/"),
module: "hello.js:onRequest",
},
],
},
srcDir: "functions",
outfile: "_routes.js",
})
).resolves.toBeDefined();
});

it.skipIf(process.platform !== "win32")(
"rejects module paths on a different drive",
async ({ expect }) => {
const modulePath = String.raw`D:\evil.js`;
const config = {
routes: [
{
routePath: toUrlPath("/"),
mountPath: toUrlPath("/"),
module: modulePath,
},
],
};

await expect(
writeRoutesModule({
config,
srcDir: String.raw`C:\project`,
outfile: "_routes.js",
})
).rejects.toThrow(new UserError(`Invalid module path "${modulePath}"`));
}
);
});
4 changes: 2 additions & 2 deletions packages/wrangler/src/__tests__/vectorize/vectorize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe("vectorize help", () => {
-v, --version Show version number [boolean]

OPTIONS
--json Return output as clean JSON [boolean] [default: false]
--json Return output as JSON [boolean] [default: false]
--deprecated-v1 Fetch a deprecated V1 Vectorize index. This must be enabled if the index was created with V1 option. [boolean] [default: false]"
`);
});
Expand Down Expand Up @@ -1048,7 +1048,7 @@ describe("vectorize commands", () => {
OPTIONS
--count Maximum number of vectors to return (1-1000) [number]
--cursor Cursor for pagination to get the next page of results [string]
--json Return output as clean JSON [boolean] [default: false]
--json Return output as JSON [boolean] [default: false]

EXAMPLES
wrangler vectorize list-vectors my-index List vector identifiers in the index 'my-index'
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/ai/listCatalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const aiModelsCommand = createCommand({
args: {
json: {
type: "boolean",
description: "Return output as clean JSON",
description: "Return output as JSON",
default: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/ai/listFinetune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const aiFineTuneListCommand = createCommand({
args: {
json: {
type: "boolean",
description: "Return output as clean JSON",
description: "Return output as JSON",
default: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/containers/instances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const instancesArgs = {
default: 25,
},
json: {
describe: "Return output as clean JSON",
describe: "Return output as JSON",
type: "boolean",
default: false,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const d1ExecuteCommand = createCommand({
},
json: {
type: "boolean",
description: "Return output as clean JSON",
description: "Return output as JSON",
default: false,
},
preview: {
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const d1InfoCommand = createCommand({
},
json: {
type: "boolean",
description: "Return output as clean JSON",
description: "Return output as JSON",
default: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const d1InsightsCommand = createCommand({
},
json: {
type: "boolean",
description: "return output as clean JSON",
description: "return output as JSON",
default: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const d1ListCommand = createCommand({
args: {
json: {
type: "boolean",
description: "Return output as clean JSON",
description: "Return output as JSON",
default: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/timeTravel/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const d1TimeTravelInfoCommand = createCommand({
},
json: {
type: "boolean",
description: "Return output as clean JSON",
description: "Return output as JSON",
default: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/timeTravel/restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const d1TimeTravelRestoreCommand = createCommand({
},
json: {
type: "boolean",
description: "Return output as clean JSON",
description: "Return output as JSON",
default: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/pages/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const pagesDeploymentListCommand = createCommand({
},
json: {
type: "boolean",
description: "Return output as clean JSON",
description: "Return output as JSON",
default: false,
},
},
Expand Down
28 changes: 21 additions & 7 deletions packages/wrangler/src/pages/functions/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export async function writeRoutesModule({
}

function parseConfig(config: Config, baseDir: string) {
baseDir = path.resolve(baseDir);
const routes: RoutesCollection = [];
const importMap: ImportMap = new Map();
const identifierCount = new Map<string, number>(); // to keep track of identifier collisions
Expand All @@ -77,23 +78,32 @@ function parseConfig(config: Config, baseDir: string) {
}

return paths.map((modulePath) => {
const [filepath, name = "default"] = modulePath.split(":");
let { identifier } = importMap.get(modulePath) ?? {};
const resolvedPath = path.resolve(baseDir, modulePath);
const moduleRoot = path.parse(resolvedPath).root;

const resolvedPath = path.resolve(baseDir, filepath);
// Strip the drive letter (if any) to avoid confusing the drive colon with the export name separator
const strippedPath = resolvedPath.slice(moduleRoot.length - 1);
const [filepath, name = "default"] = strippedPath.split(":");

const fullFilepath = path.resolve(moduleRoot, filepath);
const relativePath = path.relative(baseDir, fullFilepath);

// ensure the filepath isn't attempting to resolve to anything outside of the project
if (path.relative(baseDir, resolvedPath).startsWith("..")) {
throw new UserError(`Invalid module path "${filepath}"`);
if (
moduleRoot !== path.parse(baseDir).root ||
relativePath.startsWith("..")
) {
throw new UserError(`Invalid module path "${fullFilepath}"`);
}

// ensure the module name (if provided) is a valid identifier to guard against injection attacks
if (name !== "default" && !isValidIdentifier(name)) {
throw new UserError(`Invalid module identifier "${name}"`);
}

let { identifier } = importMap.get(resolvedPath) ?? {};
if (!identifier) {
identifier = normalizeIdentifier(`__${filepath}_${name}`);
identifier = normalizeIdentifier(`__${relativePath}_${name}`);

let count = identifierCount.get(identifier) ?? 0;
identifierCount.set(identifier, ++count);
Expand All @@ -102,7 +112,11 @@ function parseConfig(config: Config, baseDir: string) {
identifier += `_${count}`;
}

importMap.set(modulePath, { filepath: resolvedPath, name, identifier });
importMap.set(resolvedPath, {
filepath: fullFilepath,
name,
identifier,
});
}

return identifier;
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/pages/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const pagesProjectListCommand = createCommand({
args: {
json: {
type: "boolean",
description: "Return output as clean JSON",
description: "Return output as JSON",
default: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/vectorize/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const vectorizeCreateCommand = createCommand({
json: {
type: "boolean",
default: false,
description: "Return output as clean JSON",
description: "Return output as JSON",
},
"deprecated-v1": {
type: "boolean",
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/vectorize/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const vectorizeGetCommand = createCommand({
json: {
type: "boolean",
default: false,
description: "Return output as clean JSON",
description: "Return output as JSON",
},
"deprecated-v1": {
type: "boolean",
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/vectorize/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const vectorizeInfoCommand = createCommand({
description: "The name of the Vectorize index.",
},
json: {
describe: "return output as clean JSON",
describe: "return output as JSON",
type: "boolean",
default: false,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/vectorize/insert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const vectorizeInsertCommand = createCommand({
default: VECTORIZE_UPSERT_BATCH_SIZE,
},
json: {
describe: "return output as clean JSON",
describe: "return output as JSON",
type: "boolean",
default: false,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/vectorize/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const vectorizeListCommand = createCommand({
json: {
type: "boolean",
default: false,
description: "Return output as clean JSON",
description: "Return output as JSON",
},
"deprecated-v1": {
type: "boolean",
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/vectorize/listMetadataIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const vectorizeListMetadataIndexCommand = createCommand({
description: "The name of the Vectorize index.",
},
json: {
describe: "return output as clean JSON",
describe: "return output as JSON",
type: "boolean",
default: false,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/vectorize/listVectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const vectorizeListVectorsCommand = createCommand({
json: {
type: "boolean",
default: false,
description: "Return output as clean JSON",
description: "Return output as JSON",
},
},
positionalArgs: ["name"],
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/vectorize/upsert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const vectorizeUpsertCommand = createCommand({
default: VECTORIZE_MAX_BATCH_SIZE,
},
json: {
describe: "return output as clean JSON",
describe: "return output as JSON",
type: "boolean",
default: false,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/versions/deployments/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const deploymentsListCommand = createCommand({
requiresArg: true,
},
json: {
describe: "Display output as clean JSON",
describe: "Display output as JSON",
type: "boolean",
default: false,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/versions/deployments/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const deploymentsStatusCommand = createCommand({
requiresArg: true,
},
json: {
describe: "Display output as clean JSON",
describe: "Display output as JSON",
type: "boolean",
default: false,
},
Expand Down
Loading
Loading