wrangler 0.0.0-e5d3690 → 0.0.0-e5ebdb143
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 +44 -25
- package/bin/wrangler.js +94 -31
- package/config-schema.json +3324 -0
- package/kv-asset-handler.js +1 -0
- package/package.json +146 -91
- 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-patch-console-prefix.d.ts +3 -0
- package/templates/middleware/middleware-patch-console-prefix.ts +21 -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 +26702 -0
- package/wrangler-dist/cli.js +164834 -117766
- 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/pages/functions/buildWorker.ts +0 -62
- package/pages/functions/filepath-routing.test.ts +0 -39
- package/pages/functions/filepath-routing.ts +0 -228
- package/pages/functions/identifiers.ts +0 -78
- package/pages/functions/routes.ts +0 -158
- package/pages/functions/template-worker.ts +0 -136
- package/src/__tests__/clipboardy-mock.js +0 -4
- package/src/__tests__/dev.test.tsx +0 -67
- package/src/__tests__/index.test.ts +0 -289
- package/src/__tests__/jest.setup.ts +0 -22
- package/src/__tests__/kv.test.ts +0 -1199
- package/src/__tests__/mock-cfetch.ts +0 -173
- package/src/__tests__/mock-dialogs.ts +0 -65
- package/src/__tests__/publish.test.ts +0 -672
- package/src/__tests__/run-in-tmp.ts +0 -19
- package/src/__tests__/run-wrangler.ts +0 -32
- package/src/__tests__/whoami.test.tsx +0 -130
- package/src/api/form_data.ts +0 -131
- package/src/api/preview.ts +0 -128
- package/src/api/worker.ts +0 -155
- package/src/cfetch/index.ts +0 -110
- package/src/cfetch/internal.ts +0 -71
- package/src/cli.ts +0 -9
- package/src/config.ts +0 -646
- package/src/dev.tsx +0 -779
- package/src/dialogs.tsx +0 -77
- package/src/index.tsx +0 -1975
- package/src/inspect.ts +0 -543
- package/src/kv.tsx +0 -276
- package/src/module-collection.ts +0 -64
- package/src/pages.tsx +0 -1040
- package/src/proxy.ts +0 -302
- package/src/publish.ts +0 -382
- package/src/sites.tsx +0 -243
- package/src/tail.tsx +0 -73
- package/src/user.tsx +0 -1019
- package/src/whoami.tsx +0 -69
- 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/internal.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import fetch from "node-fetch";
|
|
2
|
-
import type { RequestInit, HeadersInit } from "node-fetch";
|
|
3
|
-
import { getAPIToken, loginOrRefreshIfRequired } from "../user";
|
|
4
|
-
|
|
5
|
-
export const CF_API_BASE_URL =
|
|
6
|
-
process.env.CF_API_BASE_URL || "https://api.cloudflare.com/client/v4";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Make a fetch request to the Cloudflare API.
|
|
10
|
-
*
|
|
11
|
-
* This function handles acquiring the API token and logging the caller in, as necessary.
|
|
12
|
-
*
|
|
13
|
-
* Check out https://api.cloudflare.com/ for API docs.
|
|
14
|
-
*
|
|
15
|
-
* This function should not be used directly, instead use the functions in `cfetch/index.ts`.
|
|
16
|
-
*/
|
|
17
|
-
export async function fetchInternal<ResponseType>(
|
|
18
|
-
resource: string,
|
|
19
|
-
init: RequestInit = {},
|
|
20
|
-
queryParams?: URLSearchParams
|
|
21
|
-
): Promise<ResponseType> {
|
|
22
|
-
await requireLoggedIn();
|
|
23
|
-
const apiToken = requireApiToken();
|
|
24
|
-
const headers = cloneHeaders(init.headers);
|
|
25
|
-
addAuthorizationHeader(headers, apiToken);
|
|
26
|
-
|
|
27
|
-
const queryString = queryParams ? `?${queryParams.toString()}` : "";
|
|
28
|
-
const response = await fetch(`${CF_API_BASE_URL}${resource}${queryString}`, {
|
|
29
|
-
method: "GET",
|
|
30
|
-
...init,
|
|
31
|
-
headers,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const jsonText = await response.text();
|
|
35
|
-
try {
|
|
36
|
-
const json = JSON.parse(jsonText);
|
|
37
|
-
return json as ResponseType;
|
|
38
|
-
} catch (e) {
|
|
39
|
-
throw new Error(
|
|
40
|
-
`Failed to fetch ${resource} - ${response.status}: ${response.statusText}\nInvalid JSON response:\n${jsonText}`
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function cloneHeaders(headers: HeadersInit | undefined): HeadersInit {
|
|
46
|
-
return { ...headers };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async function requireLoggedIn(): Promise<void> {
|
|
50
|
-
const loggedIn = await loginOrRefreshIfRequired();
|
|
51
|
-
if (!loggedIn) {
|
|
52
|
-
throw new Error("Not logged in.");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function requireApiToken(): string {
|
|
57
|
-
const apiToken = getAPIToken();
|
|
58
|
-
if (!apiToken) {
|
|
59
|
-
throw new Error("No API token found.");
|
|
60
|
-
}
|
|
61
|
-
return apiToken;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function addAuthorizationHeader(headers: HeadersInit, apiToken: string): void {
|
|
65
|
-
if (headers["Authorization"]) {
|
|
66
|
-
throw new Error(
|
|
67
|
-
"The request already specifies an authorisation header - cannot add a new one."
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
headers["Authorization"] = `Bearer ${apiToken}`;
|
|
71
|
-
}
|
package/src/cli.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { hideBin } from "yargs/helpers";
|
|
2
|
-
import { main } from ".";
|
|
3
|
-
|
|
4
|
-
main(hideBin(process.argv)).catch(() => {
|
|
5
|
-
// The logging of any error that was thrown from `main()` is handled in the `yargs.fail()` handler.
|
|
6
|
-
// Here we just want to ensure that the process exits with a non-zero code.
|
|
7
|
-
// We don't want to do this inside the `main()` function, since that would kill the process when running our tests.
|
|
8
|
-
process.exit(1);
|
|
9
|
-
});
|