wrangler 0.0.0-e151223 → 0.0.0-e29a241
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/miniflare-dist/index.mjs +79 -0
- package/miniflare-dist/index.mjs.map +7 -0
- package/package.json +29 -13
- package/pages/functions/filepath-routing.test.ts +212 -36
- package/pages/functions/filepath-routing.ts +69 -119
- package/pages/functions/routes.ts +8 -17
- package/pages/functions/template-worker.ts +3 -9
- package/src/__tests__/configuration.test.ts +2754 -0
- package/src/__tests__/dev.test.tsx +488 -63
- package/src/__tests__/dev2.test.tsx +154 -0
- package/src/__tests__/guess-worker-format.test.ts +58 -0
- package/src/__tests__/helpers/cmd-shim.d.ts +11 -0
- package/src/__tests__/helpers/faye-websocket.d.ts +6 -0
- package/src/__tests__/helpers/mock-account-id.ts +26 -8
- package/src/__tests__/helpers/mock-bin.ts +36 -0
- package/src/__tests__/helpers/mock-cfetch.ts +44 -10
- package/src/__tests__/helpers/mock-console.ts +21 -7
- package/src/__tests__/helpers/mock-kv.ts +9 -16
- package/src/__tests__/helpers/mock-stdin.ts +103 -0
- package/src/__tests__/helpers/mock-web-socket.ts +29 -0
- package/src/__tests__/helpers/run-in-tmp.ts +3 -0
- package/src/__tests__/helpers/run-wrangler.ts +5 -3
- package/src/__tests__/helpers/write-wrangler-toml.ts +17 -0
- package/src/__tests__/https-options.test.ts +127 -0
- package/src/__tests__/index.test.ts +617 -32
- package/src/__tests__/jest.setup.ts +41 -6
- package/src/__tests__/kv.test.ts +455 -222
- package/src/__tests__/logout.test.ts +15 -13
- package/src/__tests__/package-manager.test.ts +206 -0
- package/src/__tests__/pages.test.ts +44 -0
- package/src/__tests__/parse.test.ts +322 -0
- package/src/__tests__/publish.test.ts +1919 -437
- package/src/__tests__/r2.test.ts +198 -0
- package/src/__tests__/route.test.ts +45 -0
- package/src/__tests__/secret.test.ts +301 -86
- package/src/__tests__/sentry.test.ts +146 -0
- package/src/__tests__/tail.test.ts +564 -0
- package/src/__tests__/whoami.test.tsx +21 -7
- package/src/bundle.ts +142 -0
- package/src/cfetch/index.ts +9 -16
- package/src/cfetch/internal.ts +89 -22
- package/src/cli.ts +10 -0
- package/src/config/README.md +107 -0
- package/src/config/config.ts +274 -0
- package/src/config/diagnostics.ts +80 -0
- package/src/config/environment.ts +310 -0
- package/src/config/index.ts +56 -0
- package/src/config/validation-helpers.ts +486 -0
- package/src/config/validation.ts +1096 -0
- package/src/{api/preview.ts → create-worker-preview.ts} +59 -21
- package/src/create-worker-upload-form.ts +217 -0
- package/src/dev/dev.tsx +364 -0
- package/src/dev/local.tsx +226 -0
- package/src/dev/remote.tsx +203 -0
- package/src/dev/use-esbuild.ts +100 -0
- package/src/entry.ts +208 -0
- package/src/environment-variables.ts +33 -0
- package/src/https-options.ts +122 -0
- package/src/index.tsx +1079 -766
- package/src/inspect.ts +25 -4
- package/src/{kv.tsx → kv.ts} +104 -61
- package/src/miniflare-cli/README.md +30 -0
- package/src/miniflare-cli/enum-keys.ts +17 -0
- package/src/miniflare-cli/index.ts +37 -0
- package/src/module-collection.ts +226 -31
- package/src/open-in-browser.ts +25 -0
- package/src/package-manager.ts +126 -0
- package/src/pages.tsx +11 -11
- package/src/parse.ts +183 -0
- package/src/proxy.ts +115 -45
- package/src/publish.ts +265 -328
- package/src/r2.ts +50 -0
- package/src/reporting.ts +131 -0
- package/src/selfsigned.d.ts +29 -0
- package/src/sites.tsx +83 -43
- package/src/tail/filters.ts +279 -0
- package/src/tail/index.ts +299 -0
- package/src/tail/printing.ts +62 -0
- package/src/user.tsx +223 -124
- package/src/{api/worker.ts → worker.ts} +44 -36
- package/templates/new-worker.js +15 -0
- package/templates/new-worker.ts +15 -0
- package/{static-asset-facade.js → templates/static-asset-facade.js} +0 -0
- package/templates/tsconfig.json +105 -0
- package/wrangler-dist/cli.js +60837 -43876
- package/wrangler-dist/cli.js.map +3 -3
- package/src/__tests__/helpers/mock-user.ts +0 -27
- package/src/api/form_data.ts +0 -134
- package/src/config.ts +0 -641
- package/src/dev.tsx +0 -834
- package/src/npm-installer.ts +0 -20
- package/src/tail.tsx +0 -73
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
-
import os from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
|
|
5
|
-
export function writeUserConfig(
|
|
6
|
-
oauth_token?: string,
|
|
7
|
-
refresh_token?: string,
|
|
8
|
-
expiration_time?: string
|
|
9
|
-
) {
|
|
10
|
-
const lines: string[] = [];
|
|
11
|
-
if (oauth_token) {
|
|
12
|
-
lines.push(`oauth_token = "${oauth_token}"`);
|
|
13
|
-
}
|
|
14
|
-
if (refresh_token) {
|
|
15
|
-
lines.push(`refresh_token = "${refresh_token}"`);
|
|
16
|
-
}
|
|
17
|
-
if (expiration_time) {
|
|
18
|
-
lines.push(`expiration_time = "${expiration_time}"`);
|
|
19
|
-
}
|
|
20
|
-
const configPath = path.join(os.homedir(), ".wrangler/config");
|
|
21
|
-
mkdirSync(configPath, { recursive: true });
|
|
22
|
-
writeFileSync(
|
|
23
|
-
path.join(configPath, "default.toml"),
|
|
24
|
-
lines.join("\n"),
|
|
25
|
-
"utf-8"
|
|
26
|
-
);
|
|
27
|
-
}
|
package/src/api/form_data.ts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { FormData, File } from "undici";
|
|
2
|
-
import type {
|
|
3
|
-
CfWorkerInit,
|
|
4
|
-
CfModuleType,
|
|
5
|
-
CfModule,
|
|
6
|
-
CfDurableObjectMigrations,
|
|
7
|
-
} from "./worker.js";
|
|
8
|
-
|
|
9
|
-
export function toMimeType(type: CfModuleType): string {
|
|
10
|
-
switch (type) {
|
|
11
|
-
case "esm":
|
|
12
|
-
return "application/javascript+module";
|
|
13
|
-
case "commonjs":
|
|
14
|
-
return "application/javascript";
|
|
15
|
-
case "compiled-wasm":
|
|
16
|
-
return "application/wasm";
|
|
17
|
-
case "buffer":
|
|
18
|
-
return "application/octet-stream";
|
|
19
|
-
case "text":
|
|
20
|
-
return "text/plain";
|
|
21
|
-
default:
|
|
22
|
-
throw new TypeError("Unsupported module: " + type);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function toModule(module: CfModule, entryType: CfModuleType): File {
|
|
27
|
-
const { type: moduleType, content } = module;
|
|
28
|
-
const type = toMimeType(moduleType ?? entryType);
|
|
29
|
-
return new File([content], module.name, { type });
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface WorkerMetadata {
|
|
33
|
-
/** The name of the entry point module. Only exists when the worker is in the ES module format */
|
|
34
|
-
main_module?: string;
|
|
35
|
-
/** The name of the entry point module. Only exists when the worker is in the Service Worker format */
|
|
36
|
-
body_part?: string;
|
|
37
|
-
compatibility_date?: string;
|
|
38
|
-
compatibility_flags?: string[];
|
|
39
|
-
usage_model?: "bundled" | "unbound";
|
|
40
|
-
migrations?: CfDurableObjectMigrations;
|
|
41
|
-
bindings: (
|
|
42
|
-
| { type: "kv_namespace"; name: string; namespace_id: string }
|
|
43
|
-
| { type: "plain_text"; name: string; text: string }
|
|
44
|
-
| {
|
|
45
|
-
type: "durable_object_namespace";
|
|
46
|
-
name: string;
|
|
47
|
-
class_name: string;
|
|
48
|
-
script_name?: string;
|
|
49
|
-
}
|
|
50
|
-
| {
|
|
51
|
-
type: "service";
|
|
52
|
-
name: string;
|
|
53
|
-
service: string;
|
|
54
|
-
environment: string;
|
|
55
|
-
}
|
|
56
|
-
)[];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Creates a `FormData` upload from a `CfWorkerInit`.
|
|
61
|
-
*/
|
|
62
|
-
export function toFormData(worker: CfWorkerInit): FormData {
|
|
63
|
-
const formData = new FormData();
|
|
64
|
-
const {
|
|
65
|
-
main,
|
|
66
|
-
modules,
|
|
67
|
-
bindings,
|
|
68
|
-
migrations,
|
|
69
|
-
usage_model,
|
|
70
|
-
compatibility_date,
|
|
71
|
-
compatibility_flags,
|
|
72
|
-
} = worker;
|
|
73
|
-
|
|
74
|
-
const metadataBindings: WorkerMetadata["bindings"] = [];
|
|
75
|
-
|
|
76
|
-
bindings.kv_namespaces?.forEach(({ id, binding }) => {
|
|
77
|
-
metadataBindings.push({
|
|
78
|
-
name: binding,
|
|
79
|
-
type: "kv_namespace",
|
|
80
|
-
namespace_id: id,
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
bindings.durable_objects?.bindings.forEach(
|
|
85
|
-
({ name, class_name, script_name }) => {
|
|
86
|
-
metadataBindings.push({
|
|
87
|
-
name,
|
|
88
|
-
type: "durable_object_namespace",
|
|
89
|
-
class_name: class_name,
|
|
90
|
-
...(script_name && { script_name }),
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
Object.entries(bindings.vars || {})?.forEach(([key, value]) => {
|
|
96
|
-
metadataBindings.push({ name: key, type: "plain_text", text: value });
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
bindings.services?.forEach(({ name, service, environment }) => {
|
|
100
|
-
metadataBindings.push({
|
|
101
|
-
name,
|
|
102
|
-
type: "service",
|
|
103
|
-
service,
|
|
104
|
-
environment,
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const metadata: WorkerMetadata = {
|
|
109
|
-
...(main.type !== "commonjs"
|
|
110
|
-
? { main_module: main.name }
|
|
111
|
-
: { body_part: main.name }),
|
|
112
|
-
bindings: metadataBindings,
|
|
113
|
-
...(compatibility_date && { compatibility_date }),
|
|
114
|
-
...(compatibility_flags && { compatibility_flags }),
|
|
115
|
-
...(usage_model && { usage_model }),
|
|
116
|
-
...(migrations && { migrations }),
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
formData.set("metadata", JSON.stringify(metadata));
|
|
120
|
-
|
|
121
|
-
if (main.type === "commonjs" && modules && modules.length > 0) {
|
|
122
|
-
throw new TypeError(
|
|
123
|
-
"More than one module can only be specified when type = 'esm'"
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
for (const module of [main].concat(modules || [])) {
|
|
128
|
-
const { name } = module;
|
|
129
|
-
const file = toModule(module, main.type ?? "esm");
|
|
130
|
-
formData.set(name, file);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return formData;
|
|
134
|
-
}
|