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
5 changes: 5 additions & 0 deletions .changeset/fuzzy-items-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Deprecate 'wrangler cloudchamber apply' in favor of 'wrangler deploy'
10 changes: 10 additions & 0 deletions .changeset/smart-zoos-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"miniflare": minor
---

Implement local D1 API for experimental/WIP local resource explorer

The following APIs have been (mostly) implemented:

- `GET /d1/database` - Returns a list of D1 databases.
- `POST /d1/database/{database_id}/raw` - Returns the query result rows as arrays rather than objects.
25 changes: 25 additions & 0 deletions fixtures/additional-modules/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import noVitestImportExpect from "@cloudflare/eslint-config-shared/rules/no-vitest-import-expect";
import tsParser from "@typescript-eslint/parser";
import { defineConfig } from "eslint/config";

export default defineConfig([
{
files: [
"**/*.test.ts",
"**/*.spec.ts",
"**/test/**/*.ts",
"**/tests/**/*.ts",
],
languageOptions: {
parser: tsParser,
},
plugins: {
"workers-sdk": {
rules: { "no-vitest-import-expect": noVitestImportExpect },
},
},
rules: {
"workers-sdk/no-vitest-import-expect": "error",
},
},
]);
1 change: 1 addition & 0 deletions fixtures/additional-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"type:tests": "tsc -p ./test/tsconfig.json"
},
"devDependencies": {
"@cloudflare/eslint-config-shared": "workspace:*",
"@cloudflare/workers-tsconfig": "workspace:*",
"@cloudflare/workers-types": "catalog:default",
"typescript": "catalog:default",
Expand Down
20 changes: 10 additions & 10 deletions fixtures/additional-modules/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import os from "node:os";
import path from "node:path";
import { setTimeout } from "node:timers/promises";
import { fetch } from "undici";
import { afterAll, beforeAll, describe, expect, test, vi } from "vitest";
import { afterAll, beforeAll, describe, test, vi } from "vitest";
import { unstable_startWorker } from "wrangler";
import { wranglerEntryPath } from "../../shared/src/run-wrangler-long-lived";

Expand Down Expand Up @@ -61,32 +61,32 @@ describe("find_additional_modules dev", () => {
}
});

test("supports bundled modules", async () => {
test("supports bundled modules", async ({ expect }) => {
const res = await get(worker, "/dep");
expect(await res.text()).toBe("bundled");
});
test("supports text modules", async () => {
test("supports text modules", async ({ expect }) => {
const res = await get(worker, "/text");
expect(await res.text()).toBe("test\n");
});
test("supports SQL modules", async () => {
test("supports SQL modules", async ({ expect }) => {
const res = await get(worker, "/sql");
expect(await res.text()).toBe("SELECT * FROM users;\n");
});
test("supports dynamic imports", async () => {
test("supports dynamic imports", async ({ expect }) => {
const res = await get(worker, "/dynamic");
expect(await res.text()).toBe("dynamic");
});
test("supports commonjs lazy imports", async () => {
test("supports commonjs lazy imports", async ({ expect }) => {
const res = await get(worker, "/common");
expect(await res.text()).toBe("common");
});
test("supports variable dynamic imports", async () => {
test("supports variable dynamic imports", async ({ expect }) => {
const res = await get(worker, "/lang/en");
expect(await res.text()).toBe("hello");
});

test("watches additional modules", async () => {
test("watches additional modules", async ({ expect }) => {
const srcDir = path.join(tmpDir, "src");

// Update dynamically imported file
Expand Down Expand Up @@ -148,7 +148,7 @@ describe("find_additional_modules deploy", () => {
await fs.rm(tmpDir, { recursive: true, force: true });
});

test("doesn't bundle additional modules", async () => {
test("doesn't bundle additional modules", async ({ expect }) => {
const outDir = path.join(tmpDir, "out");
const result = await build(path.resolve(__dirname, ".."), outDir);
expect(result.status).toBe(0);
Expand Down Expand Up @@ -205,7 +205,7 @@ describe("find_additional_modules deploy", () => {
expect(existsSync(path.join(outDir, "lang", "fr.js"))).toBe(true);
});

test("fails with service worker entrypoint", async () => {
test("fails with service worker entrypoint", async ({ expect }) => {
// Write basic service worker with `find_additional_modules` enabled
const serviceWorkerDir = path.join(tmpDir, "service-worker");
await fs.mkdir(serviceWorkerDir, { recursive: true });
Expand Down
25 changes: 25 additions & 0 deletions fixtures/browser-rendering/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import noVitestImportExpect from "@cloudflare/eslint-config-shared/rules/no-vitest-import-expect";
import tsParser from "@typescript-eslint/parser";
import { defineConfig } from "eslint/config";

export default defineConfig([
{
files: [
"**/*.test.ts",
"**/*.spec.ts",
"**/test/**/*.ts",
"**/tests/**/*.ts",
],
languageOptions: {
parser: tsParser,
},
plugins: {
"workers-sdk": {
rules: { "no-vitest-import-expect": noVitestImportExpect },
},
},
rules: {
"workers-sdk/no-vitest-import-expect": "error",
},
},
]);
1 change: 1 addition & 0 deletions fixtures/browser-rendering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"test:ci": "vitest run"
},
"devDependencies": {
"@cloudflare/eslint-config-shared": "workspace:*",
"@cloudflare/playwright": "^0.0.10",
"@cloudflare/puppeteer": "^1.0.2",
"@cloudflare/vitest-pool-workers": "workspace:*",
Expand Down
14 changes: 9 additions & 5 deletions fixtures/browser-rendering/test/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// test/index.spec.ts
import { rm } from "node:fs/promises";
import { resolve } from "path";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { afterAll, beforeAll, describe, it } from "vitest";
import { runWranglerDev } from "../../shared/src/run-wrangler-long-lived";

describe.sequential("Local Browser", () => {
Expand Down Expand Up @@ -39,21 +39,23 @@ describe.sequential("Local Browser", () => {

for (const lib of ["puppeteer", "playwright"]) {
describe(`using @cloudflare/${lib}`, () => {
it("Doesn't run a browser, just testing that the worker is running!", async () => {
it("Doesn't run a browser, just testing that the worker is running!", async ({
expect,
}) => {
await expect(
fetchText(`http://${ip}:${port}/?lib=${lib}`)
).resolves.toEqual("Please add an ?url=https://example.com/ parameter");
});

it("Run a browser, and check h1 text content", async () => {
it("Run a browser, and check h1 text content", async ({ expect }) => {
await expect(
fetchText(
`http://${ip}:${port}/?lib=${lib}&url=https://example.com&action=select`
)
).resolves.toEqual("Example Domain");
});

it("Run a browser, and check p text content", async () => {
it("Run a browser, and check p text content", async ({ expect }) => {
await expect(
fetchText(
`http://${ip}:${port}/?lib=${lib}&url=https://example.com&action=alter`
Expand All @@ -63,7 +65,9 @@ describe.sequential("Local Browser", () => {
);
});

it("Disconnect a browser, and check its session connection status", async () => {
it("Disconnect a browser, and check its session connection status", async ({
expect,
}) => {
await expect(
fetchText(
`http://${ip}:${port}/?lib=${lib}&url=https://example.com&action=disconnect`
Expand Down
25 changes: 25 additions & 0 deletions fixtures/d1-read-replication-app/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import noVitestImportExpect from "@cloudflare/eslint-config-shared/rules/no-vitest-import-expect";
import tsParser from "@typescript-eslint/parser";
import { defineConfig } from "eslint/config";

export default defineConfig([
{
files: [
"**/*.test.ts",
"**/*.spec.ts",
"**/test/**/*.ts",
"**/tests/**/*.ts",
],
languageOptions: {
parser: tsParser,
},
plugins: {
"workers-sdk": {
rules: { "no-vitest-import-expect": noVitestImportExpect },
},
},
rules: {
"workers-sdk/no-vitest-import-expect": "error",
},
},
]);
1 change: 1 addition & 0 deletions fixtures/d1-read-replication-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"type:tests": "tsc -p ./tests/tsconfig.json"
},
"devDependencies": {
"@cloudflare/eslint-config-shared": "workspace:*",
"@cloudflare/workers-tsconfig": "workspace:*",
"@cloudflare/workers-types": "catalog:default",
"typescript": "catalog:default",
Expand Down
12 changes: 8 additions & 4 deletions fixtures/d1-read-replication-app/tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolve } from "node:path";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { afterAll, beforeAll, describe, it } from "vitest";
import { runWranglerDev } from "../../shared/src/run-wrangler-long-lived";

describe("d1-sessions-api - getBookmark", () => {
Expand All @@ -17,7 +17,9 @@ describe("d1-sessions-api - getBookmark", () => {
await stop?.();
});

it("should respond with bookmarks before and after a session query", async () => {
it("should respond with bookmarks before and after a session query", async ({
expect,
}) => {
let response = await fetch(`http://${ip}:${port}`);
let parsed = await response.json();
expect(response.status).toBe(200);
Expand All @@ -27,7 +29,7 @@ describe("d1-sessions-api - getBookmark", () => {
});
});

it("should progress the bookmark after a write", async () => {
it("should progress the bookmark after a write", async ({ expect }) => {
let response = await fetch(
`http://${ip}:${port}?q=${encodeURIComponent("create table if not exists users1(id text);")}`
);
Expand All @@ -46,7 +48,9 @@ describe("d1-sessions-api - getBookmark", () => {
).toEqual(true);
});

it("should maintain the latest bookmark after many queries", async () => {
it("should maintain the latest bookmark after many queries", async ({
expect,
}) => {
let responses = [];

for (let i = 0; i < 10; i++) {
Expand Down
25 changes: 25 additions & 0 deletions fixtures/d1-worker-app/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import noVitestImportExpect from "@cloudflare/eslint-config-shared/rules/no-vitest-import-expect";
import tsParser from "@typescript-eslint/parser";
import { defineConfig } from "eslint/config";

export default defineConfig([
{
files: [
"**/*.test.ts",
"**/*.spec.ts",
"**/test/**/*.ts",
"**/tests/**/*.ts",
],
languageOptions: {
parser: tsParser,
},
plugins: {
"workers-sdk": {
rules: { "no-vitest-import-expect": noVitestImportExpect },
},
},
rules: {
"workers-sdk/no-vitest-import-expect": "error",
},
},
]);
1 change: 1 addition & 0 deletions fixtures/d1-worker-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"type:tests": "tsc -p ./tests/tsconfig.json"
},
"devDependencies": {
"@cloudflare/eslint-config-shared": "workspace:*",
"@cloudflare/workers-tsconfig": "workspace:*",
"@cloudflare/workers-types": "catalog:default",
"typescript": "catalog:default",
Expand Down
4 changes: 2 additions & 2 deletions fixtures/d1-worker-app/tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { execSync } from "node:child_process";
import { resolve } from "node:path";
import { describe, expect, it } from "vitest";
import { describe, it } from "vitest";

describe("d1", () => {
describe("d1 execute --local", () => {
it("should execute SQL file against the local db", () => {
it("should execute SQL file against the local db", ({ expect }) => {
const stdout = execSync("pnpm run db:reset", {
cwd: resolve(__dirname, ".."),
}).toString();
Expand Down
25 changes: 25 additions & 0 deletions fixtures/dev-registry/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import noVitestImportExpect from "@cloudflare/eslint-config-shared/rules/no-vitest-import-expect";
import tsParser from "@typescript-eslint/parser";
import { defineConfig } from "eslint/config";

export default defineConfig([
{
files: [
"**/*.test.ts",
"**/*.spec.ts",
"**/test/**/*.ts",
"**/tests/**/*.ts",
],
languageOptions: {
parser: tsParser,
},
plugins: {
"workers-sdk": {
rules: { "no-vitest-import-expect": noVitestImportExpect },
},
},
rules: {
"workers-sdk/no-vitest-import-expect": "error",
},
},
]);
1 change: 1 addition & 0 deletions fixtures/dev-registry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"wrangler": "wrangler dev"
},
"devDependencies": {
"@cloudflare/eslint-config-shared": "workspace:*",
"@cloudflare/vite-plugin": "workspace:*",
"@cloudflare/workers-tsconfig": "workspace:*",
"@cloudflare/workers-types": "catalog:default",
Expand Down
2 changes: 2 additions & 0 deletions fixtures/dev-registry/tests/dev-registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as fs from "node:fs/promises";
import * as os from "node:os";
import * as path from "node:path";
import { resolve } from "node:path";
/* eslint-disable workers-sdk/no-vitest-import-expect -- uses expect in module-scope helper functions */
import {
describe,
expect,
Expand All @@ -10,6 +11,7 @@ import {
test,
vi,
} from "vitest";
/* eslint-enable workers-sdk/no-vitest-import-expect */
import {
runLongLived,
waitForReady,
Expand Down
25 changes: 25 additions & 0 deletions fixtures/durable-objects-app/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import noVitestImportExpect from "@cloudflare/eslint-config-shared/rules/no-vitest-import-expect";
import tsParser from "@typescript-eslint/parser";
import { defineConfig } from "eslint/config";

export default defineConfig([
{
files: [
"**/*.test.ts",
"**/*.spec.ts",
"**/test/**/*.ts",
"**/tests/**/*.ts",
],
languageOptions: {
parser: tsParser,
},
plugins: {
"workers-sdk": {
rules: { "no-vitest-import-expect": noVitestImportExpect },
},
},
rules: {
"workers-sdk/no-vitest-import-expect": "error",
},
},
]);
Loading
Loading