wrangler 0.0.0-ece06ea → 0.0.0-ecef68635
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/README.md +50 -15
- package/bin/wrangler.js +94 -31
- package/config-schema.json +3074 -0
- package/kv-asset-handler.js +1 -0
- package/package.json +155 -75
- package/templates/__tests__/pages-dev-util.test.ts +128 -0
- package/templates/__tests__/tsconfig-sanity.ts +12 -0
- package/templates/__tests__/tsconfig.json +8 -0
- package/templates/checked-fetch.js +30 -0
- package/templates/facade.d.ts +19 -0
- package/templates/gitignore +170 -0
- package/templates/init-tests/test-jest-new-worker.js +23 -0
- package/templates/init-tests/test-vitest-new-worker.js +24 -0
- package/templates/init-tests/test-vitest-new-worker.ts +25 -0
- package/templates/middleware/common.ts +67 -0
- package/templates/middleware/loader-modules.ts +134 -0
- package/templates/middleware/loader-sw.ts +229 -0
- package/templates/middleware/middleware-ensure-req-body-drained.ts +18 -0
- package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
- package/templates/middleware/middleware-mock-analytics-engine.d.ts +3 -0
- package/templates/middleware/middleware-mock-analytics-engine.ts +30 -0
- package/templates/middleware/middleware-pretty-error.ts +40 -0
- package/templates/middleware/middleware-scheduled.ts +29 -0
- package/templates/middleware/middleware-serve-static-assets.d.ts +6 -0
- package/templates/middleware/middleware-serve-static-assets.ts +56 -0
- package/templates/modules-watch-stub.js +4 -0
- package/templates/new-worker-scheduled.js +17 -0
- package/templates/new-worker-scheduled.ts +32 -0
- package/templates/new-worker.js +15 -0
- package/templates/new-worker.ts +33 -0
- package/templates/no-op-worker.js +10 -0
- package/templates/pages-dev-pipeline.ts +32 -0
- package/templates/pages-dev-util.ts +55 -0
- package/templates/pages-shim.ts +9 -0
- package/templates/pages-template-plugin.ts +190 -0
- package/templates/pages-template-worker.ts +198 -0
- package/templates/startDevWorker/InspectorProxyWorker.ts +664 -0
- package/templates/startDevWorker/ProxyWorker.ts +336 -0
- package/templates/tsconfig-sanity.ts +11 -0
- package/templates/tsconfig.init.json +22 -0
- package/templates/tsconfig.json +8 -0
- package/wrangler-dist/InspectorProxyWorker.js +464 -0
- package/wrangler-dist/InspectorProxyWorker.js.map +6 -0
- package/wrangler-dist/ProxyWorker.js +241 -0
- package/wrangler-dist/ProxyWorker.js.map +6 -0
- package/wrangler-dist/cli.d.ts +26463 -0
- package/wrangler-dist/cli.js +206335 -125492
- package/wrangler-dist/wasm-sync.wasm +0 -0
- package/import_meta_url.js +0 -3
- package/miniflare-config-stubs/.env.empty +0 -0
- package/miniflare-config-stubs/package.empty.json +0 -1
- package/miniflare-config-stubs/wrangler.empty.toml +0 -0
- package/src/__tests__/clipboardy-mock.js +0 -4
- package/src/__tests__/fixtures/init/.gitkeep +0 -0
- package/src/__tests__/index.test.ts +0 -153
- package/src/__tests__/mock-cfetch.js +0 -46
- package/src/api/form_data.ts +0 -158
- package/src/api/inspect.ts +0 -441
- package/src/api/preview.ts +0 -123
- package/src/api/worker.ts +0 -161
- package/src/cfetch.ts +0 -72
- package/src/cli.ts +0 -10
- package/src/config.ts +0 -124
- package/src/dev.tsx +0 -736
- package/src/dialogs.tsx +0 -85
- package/src/index.tsx +0 -1845
- package/src/kv.tsx +0 -211
- package/src/pages.tsx +0 -344
- package/src/publish.ts +0 -354
- package/src/sites.tsx +0 -115
- package/src/tail.tsx +0 -71
- package/src/user.tsx +0 -1029
- package/src/util/fetch.ts +0 -74
- package/static-asset-facade.js +0 -47
- package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
- package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
- package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
- package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
- package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
- package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
- package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
- package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
- package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
- package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
- package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
- package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
- package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
- package/vendor/wrangler-mime/CHANGELOG.md +0 -289
- package/vendor/wrangler-mime/LICENSE +0 -21
- package/vendor/wrangler-mime/Mime.js +0 -97
- package/vendor/wrangler-mime/README.md +0 -187
- package/vendor/wrangler-mime/cli.js +0 -46
- package/vendor/wrangler-mime/index.js +0 -4
- package/vendor/wrangler-mime/lite.js +0 -4
- package/vendor/wrangler-mime/package.json +0 -52
- package/vendor/wrangler-mime/types/other.js +0 -1
- package/vendor/wrangler-mime/types/standard.js +0 -1
- package/wrangler-dist/cli.js.map +0 -7
package/src/cfetch.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import fetch from "node-fetch";
|
|
2
|
-
import type { RequestInit } from "node-fetch";
|
|
3
|
-
import { getAPIToken } from "./user";
|
|
4
|
-
import { loginOrRefreshIfRequired } from "./user";
|
|
5
|
-
|
|
6
|
-
export const CF_API_BASE_URL =
|
|
7
|
-
process.env.CF_API_BASE_URL || "https://api.cloudflare.com/client/v4";
|
|
8
|
-
|
|
9
|
-
export default async function fetchWithAuthAndLoginIfRequired<ResponseType>(
|
|
10
|
-
resource: string,
|
|
11
|
-
init: RequestInit = {}
|
|
12
|
-
): Promise<ResponseType> {
|
|
13
|
-
const loggedIn = await loginOrRefreshIfRequired();
|
|
14
|
-
if (!loggedIn) {
|
|
15
|
-
throw new Error("Not logged in");
|
|
16
|
-
}
|
|
17
|
-
const apiToken = getAPIToken();
|
|
18
|
-
if (!apiToken) {
|
|
19
|
-
throw new Error("No API token found");
|
|
20
|
-
}
|
|
21
|
-
// @ts-expect-error Authorization isn't non HeadersInit, annoyingly
|
|
22
|
-
if (init.headers?.Authorization) {
|
|
23
|
-
throw new Error(
|
|
24
|
-
"fetchWithAuthAndLoginIfRequired will not add an authorisation header a request that already specifies it"
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
// should I bother with response code?
|
|
28
|
-
// maybe I can just throw the json error?
|
|
29
|
-
|
|
30
|
-
const response = await fetch(`${CF_API_BASE_URL}${resource}`, {
|
|
31
|
-
method: "GET",
|
|
32
|
-
...init,
|
|
33
|
-
headers: {
|
|
34
|
-
...(init.headers || {}),
|
|
35
|
-
Authorization: `Bearer ${apiToken}`,
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
const text = await response.text();
|
|
39
|
-
let json;
|
|
40
|
-
try {
|
|
41
|
-
json = JSON.parse(text);
|
|
42
|
-
} catch (parseError) {
|
|
43
|
-
// hate this edge case
|
|
44
|
-
// the only api call I know that doesn't return json is kv:key get <key>
|
|
45
|
-
|
|
46
|
-
// maybe it's a plain response
|
|
47
|
-
if (response.ok) {
|
|
48
|
-
// @ts-expect-error bleh
|
|
49
|
-
return text;
|
|
50
|
-
} else {
|
|
51
|
-
// UGH.
|
|
52
|
-
throw new Error(`${response.status}: ${response.statusText}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (json.success) {
|
|
57
|
-
return json.result;
|
|
58
|
-
} else {
|
|
59
|
-
const errorDesc = json.errors?.[0];
|
|
60
|
-
if (errorDesc) {
|
|
61
|
-
// TODO: map .message to real human readable strings
|
|
62
|
-
const error = new Error(`${errorDesc.code}: ${errorDesc.message}`);
|
|
63
|
-
// @ts-expect-error hacksss
|
|
64
|
-
error.code = errorDesc.code;
|
|
65
|
-
throw error;
|
|
66
|
-
} else {
|
|
67
|
-
// This should almost never happen.
|
|
68
|
-
// ... which means it'll probably happen, lol.
|
|
69
|
-
throw new Error(`${response.status}: ${response.statusText}`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
package/src/cli.ts
DELETED
package/src/config.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
// we're going to manually write both the type definition AND
|
|
2
|
-
// the validator for the config, so that we can give better error messages
|
|
3
|
-
|
|
4
|
-
type DOMigration = {
|
|
5
|
-
tag: string;
|
|
6
|
-
new_classes?: string[];
|
|
7
|
-
renamed_classes?: string[];
|
|
8
|
-
deleted_classes?: string[];
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
type Project = "webpack" | "javascript" | "rust";
|
|
12
|
-
|
|
13
|
-
type Site = {
|
|
14
|
-
// inherited
|
|
15
|
-
bucket: string;
|
|
16
|
-
"entry-point": string;
|
|
17
|
-
include?: string[];
|
|
18
|
-
exclude?: string[];
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type Dev = {
|
|
22
|
-
ip?: string;
|
|
23
|
-
port?: number;
|
|
24
|
-
local_protocol?: string;
|
|
25
|
-
upstream_protocol?: string;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
type Vars = { [key: string]: string };
|
|
29
|
-
|
|
30
|
-
type Cron = string; // TODO: we should be able to parse a cron pattern with ts
|
|
31
|
-
|
|
32
|
-
type KVNamespace = {
|
|
33
|
-
binding?: string;
|
|
34
|
-
preview_id: string;
|
|
35
|
-
id: string;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
type DurableObject = {
|
|
39
|
-
name: string;
|
|
40
|
-
class_name: string;
|
|
41
|
-
script_name?: string;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
type Build = {
|
|
45
|
-
command?: string;
|
|
46
|
-
cwd?: string;
|
|
47
|
-
watch_dir?: string;
|
|
48
|
-
} & (
|
|
49
|
-
| {
|
|
50
|
-
upload?: {
|
|
51
|
-
format: "service-worker";
|
|
52
|
-
main: string;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
| {
|
|
56
|
-
upload?: {
|
|
57
|
-
format: "modules";
|
|
58
|
-
dir?: string;
|
|
59
|
-
main?: string;
|
|
60
|
-
rules?: {
|
|
61
|
-
type: "ESModule" | "CommonJS" | "Text" | "Data" | "CompiledWasm";
|
|
62
|
-
globs: string[]; // can we use typescript for these patterns?
|
|
63
|
-
fallthrough?: boolean;
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
type UsageModel = "bundled" | "unbound";
|
|
70
|
-
|
|
71
|
-
type Env = {
|
|
72
|
-
name?: string; // inherited
|
|
73
|
-
account_id?: string; // inherited
|
|
74
|
-
workers_dev?: boolean; // inherited
|
|
75
|
-
compatibility_date?: string; // inherited
|
|
76
|
-
compatibility_flags?: string[]; // inherited
|
|
77
|
-
zone_id?: string; // inherited
|
|
78
|
-
routes?: string[]; // inherited
|
|
79
|
-
route?: string; // inherited
|
|
80
|
-
webpack_config?: string; // inherited
|
|
81
|
-
site?: Site;
|
|
82
|
-
jsx_factory?: string; // inherited
|
|
83
|
-
jsx_fragment?: string; // inherited
|
|
84
|
-
polyfill_node?: boolean; //inherited
|
|
85
|
-
// we should use typescript to parse cron patterns
|
|
86
|
-
triggers?: { crons: Cron[] }; // inherited
|
|
87
|
-
vars?: Vars;
|
|
88
|
-
durable_objects?: { bindings: DurableObject[] };
|
|
89
|
-
kv_namespaces?: KVNamespace[];
|
|
90
|
-
usage_model?: UsageModel; // inherited
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export type Config = {
|
|
94
|
-
name?: string; // inherited
|
|
95
|
-
account_id?: string; // inherited
|
|
96
|
-
// @deprecated Don't use this
|
|
97
|
-
type?: Project; // top level
|
|
98
|
-
compatibility_date?: string; // inherited
|
|
99
|
-
compatibility_flags?: string[]; // inherited
|
|
100
|
-
// -- there's some mutually exclusive logic for this next block,
|
|
101
|
-
// but I didn't bother for now
|
|
102
|
-
workers_dev?: boolean; // inherited
|
|
103
|
-
zone_id?: string; // inherited
|
|
104
|
-
routes?: string[]; // inherited
|
|
105
|
-
route?: string; // inherited
|
|
106
|
-
// -- end mutually exclusive stuff
|
|
107
|
-
// @deprecated Don't use this
|
|
108
|
-
webpack_config?: string; // inherited
|
|
109
|
-
jsx_factory?: string; // inherited
|
|
110
|
-
jsx_fragment?: string; // inherited
|
|
111
|
-
polyfill_node?: boolean; //inherited
|
|
112
|
-
vars?: Vars;
|
|
113
|
-
migrations?: DOMigration[];
|
|
114
|
-
durable_objects?: { bindings: DurableObject[] };
|
|
115
|
-
kv_namespaces?: KVNamespace[];
|
|
116
|
-
site?: Site; // inherited
|
|
117
|
-
// we should use typescript to parse cron patterns
|
|
118
|
-
triggers?: { crons: Cron[] }; // inherited
|
|
119
|
-
dev?: Dev;
|
|
120
|
-
usage_model?: UsageModel; // inherited
|
|
121
|
-
// top level
|
|
122
|
-
build?: Build;
|
|
123
|
-
env?: { [envName: string]: void | Env };
|
|
124
|
-
};
|