wrangler 0.0.2 → 0.0.6
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 +51 -55
- package/bin/wrangler.js +36 -0
- package/import_meta_url.js +3 -0
- package/miniflare-config-stubs/.env.empty +0 -0
- package/miniflare-config-stubs/package.empty.json +1 -0
- package/miniflare-config-stubs/wrangler.empty.toml +0 -0
- package/package.json +111 -9
- package/src/__tests__/clipboardy-mock.js +4 -0
- package/src/__tests__/index.test.ts +391 -0
- package/src/__tests__/jest.setup.ts +17 -0
- package/src/__tests__/mock-cfetch.js +42 -0
- package/src/__tests__/mock-dialogs.ts +65 -0
- package/src/api/form_data.ts +141 -0
- package/src/api/inspect.ts +430 -0
- package/src/api/preview.ts +128 -0
- package/src/api/worker.ts +161 -0
- package/src/cfetch.ts +72 -0
- package/src/cli.ts +10 -0
- package/src/config.ts +122 -0
- package/src/dev.tsx +867 -0
- package/src/dialogs.tsx +77 -0
- package/src/index.tsx +1875 -0
- package/src/kv.tsx +211 -0
- package/src/module-collection.ts +64 -0
- package/src/pages.tsx +818 -0
- package/src/proxy.ts +104 -0
- package/src/publish.ts +358 -0
- package/src/sites.tsx +115 -0
- package/src/tail.tsx +71 -0
- package/src/user.tsx +1029 -0
- package/static-asset-facade.js +47 -0
- package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +332 -0
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +176 -0
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +25 -0
- package/vendor/@cloudflare/kv-asset-handler/README.md +245 -0
- package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +32 -0
- package/vendor/@cloudflare/kv-asset-handler/dist/index.js +354 -0
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +13 -0
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +148 -0
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +1 -0
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +436 -0
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +1 -0
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +40 -0
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +1 -0
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +42 -0
- package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +26 -0
- package/vendor/@cloudflare/kv-asset-handler/dist/types.js +31 -0
- package/vendor/@cloudflare/kv-asset-handler/package.json +52 -0
- package/vendor/@cloudflare/kv-asset-handler/src/index.ts +296 -0
- package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +136 -0
- package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +464 -0
- package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +33 -0
- package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +42 -0
- package/vendor/@cloudflare/kv-asset-handler/src/types.ts +39 -0
- package/vendor/wrangler-mime/CHANGELOG.md +289 -0
- package/vendor/wrangler-mime/LICENSE +21 -0
- package/vendor/wrangler-mime/Mime.js +97 -0
- package/vendor/wrangler-mime/README.md +187 -0
- package/vendor/wrangler-mime/cli.js +46 -0
- package/vendor/wrangler-mime/index.js +4 -0
- package/vendor/wrangler-mime/lite.js +4 -0
- package/vendor/wrangler-mime/package.json +52 -0
- package/vendor/wrangler-mime/types/other.js +1 -0
- package/vendor/wrangler-mime/types/standard.js +1 -0
- package/wrangler-dist/cli.js +125758 -0
- package/wrangler-dist/cli.js.map +7 -0
- package/.npmignore +0 -15
- package/index.js +0 -250
- package/tests/is.spec.js +0 -1155
package/README.md
CHANGED
|
@@ -1,55 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
## The other `is`
|
|
54
|
-
|
|
55
|
-
Note: This is not the same as the `is` by Enrico Marino, which is another interesting JavaScript type checking library. He uses some neat techniques, and also adds functions for comparison (e.g., `is.gt()`, `is.odd()`, `is.divisibleBy()`) which I had no interest in. You can find his library at https://github.com/onirame/is
|
|
1
|
+
## 🤠 wrangler
|
|
2
|
+
|
|
3
|
+
`wrangler` is a command line tool for building [Cloudflare Workers](https://workers.cloudflare.com/).
|
|
4
|
+
|
|
5
|
+
[(Read the full stack week launch blog post.)](https://blog.cloudflare.com/wrangler-v2-beta/)
|
|
6
|
+
|
|
7
|
+
**DISCLAIMER**: This is a work in progress, and is NOT recommended for use in production. We are opening this preview for feedback from the community, and to openly share our [roadmap](https://github.com/cloudflare/wrangler2/issues/12) for the future. As such, expect APIs and documentation to change before the end of the preview.
|
|
8
|
+
|
|
9
|
+
Further, we will NOT do a general release until we are both feature complete, and have a full backward compatibility and incremental migration plan in place. For more details, follow the [parent roadmap issue](https://github.com/cloudflare/wrangler2/issues/12).
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Make a javascript file
|
|
15
|
+
$ echo "export default { fetch() { return new Response('hello world') } }" > index.js
|
|
16
|
+
# try it out
|
|
17
|
+
$ npx wrangler@beta dev index.js
|
|
18
|
+
# and then publish it
|
|
19
|
+
$ npx wrangler@beta publish index.js --name my-worker
|
|
20
|
+
# visit https://my-worker.<your workers subdomain>.workers.dev
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Installation:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
$ npm install wrangler@beta
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Commands
|
|
30
|
+
|
|
31
|
+
### `wrangler init [name]`
|
|
32
|
+
|
|
33
|
+
Creates a `wrangler.toml` configuration file. For more details on the configuration keys and values, refer to the [documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration).
|
|
34
|
+
|
|
35
|
+
### `wrangler dev [script]`
|
|
36
|
+
|
|
37
|
+
Start a local development server, with live reloading and devtools.
|
|
38
|
+
|
|
39
|
+
### `wrangler publish [script] --name [name]`
|
|
40
|
+
|
|
41
|
+
Publish the given script to the worldwide Cloudflare network.
|
|
42
|
+
|
|
43
|
+
For more commands and options, refer to the [documentation](https://developers.cloudflare.com/workers/cli-wrangler/commands).
|
|
44
|
+
|
|
45
|
+
### `wrangler pages dev [directory] [-- command]`
|
|
46
|
+
|
|
47
|
+
Either serves a static build asset directory, or proxies itself in front of a command.
|
|
48
|
+
|
|
49
|
+
Builds and runs functions from a `./functions` directory or uses a `_worker.js` file inside the static build asset directory.
|
|
50
|
+
|
|
51
|
+
For more commands and options, refer to the [documentation](https://developers.cloudflare.com/pages/platform/functions#develop-and-preview-locally) or run `wrangler pages dev --help`.
|
package/bin/wrangler.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn } = require("child_process");
|
|
3
|
+
const { join } = require("path");
|
|
4
|
+
const semiver = require("semiver");
|
|
5
|
+
|
|
6
|
+
const MIN_NODE_VERSION = "16.7.0";
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
if (semiver(process.versions.node, MIN_NODE_VERSION) < 0) {
|
|
10
|
+
// Note Volta and nvm are also recommended in the official docs:
|
|
11
|
+
// https://developers.cloudflare.com/workers/get-started/guide#2-install-the-workers-cli
|
|
12
|
+
console.error(
|
|
13
|
+
`Wrangler requires at least Node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}.
|
|
14
|
+
You should use the latest Node.js version if possible, as Cloudflare Workers use a very up-to-date version of V8.
|
|
15
|
+
Consider using a Node.js version manager such as https://volta.sh/ or https://github.com/nvm-sh/nvm.`
|
|
16
|
+
);
|
|
17
|
+
process.exitCode = 1;
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
spawn(
|
|
22
|
+
process.execPath,
|
|
23
|
+
[
|
|
24
|
+
"--no-warnings",
|
|
25
|
+
"--experimental-vm-modules",
|
|
26
|
+
...process.execArgv,
|
|
27
|
+
join(__dirname, "../wrangler-dist/cli.js"),
|
|
28
|
+
...process.argv.slice(2),
|
|
29
|
+
],
|
|
30
|
+
{ stdio: "inherit" }
|
|
31
|
+
).on("exit", (code) =>
|
|
32
|
+
process.exit(code === undefined || code === null ? 0 : code)
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void main();
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,16 +1,118 @@
|
|
|
1
1
|
{
|
|
2
|
-
"author": "Paul d'Aoust <paul@heliosstudio.ca> (http://heliosstudio.ca/)",
|
|
3
2
|
"name": "wrangler",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"author": "wrangler@cloudflare.com",
|
|
5
|
+
"description": "Command-line interface for all things Cloudflare Workers",
|
|
6
|
+
"bin": {
|
|
7
|
+
"wrangler": "./bin/wrangler.js",
|
|
8
|
+
"wrangler2": "./bin/wrangler.js"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT OR Apache-2.0",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/cloudflare/wrangler/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/cloudflare/wrangler#readme",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"wrangler",
|
|
17
|
+
"cloudflare",
|
|
18
|
+
"workers",
|
|
19
|
+
"cloudflare workers",
|
|
20
|
+
"edge",
|
|
21
|
+
"compute",
|
|
22
|
+
"serverless",
|
|
23
|
+
"serverless application",
|
|
24
|
+
"serverless module",
|
|
25
|
+
"wasm",
|
|
26
|
+
"web",
|
|
27
|
+
"assembly",
|
|
28
|
+
"webassembly",
|
|
29
|
+
"rust",
|
|
30
|
+
"emscripten",
|
|
31
|
+
"rust",
|
|
32
|
+
"typescript",
|
|
33
|
+
"graphql",
|
|
34
|
+
"router",
|
|
35
|
+
"http",
|
|
36
|
+
"cli"
|
|
37
|
+
],
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@cloudflare/pages-functions-compiler": "0.3.8",
|
|
40
|
+
"esbuild": "0.14.1",
|
|
41
|
+
"miniflare": "2.0.0-rc.4",
|
|
42
|
+
"semiver": "^1.1.0"
|
|
43
|
+
},
|
|
44
|
+
"optionalDependencies": {
|
|
45
|
+
"fsevents": "~2.3.2"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@iarna/toml": "^2.2.5",
|
|
49
|
+
"@types/react": "^17.0.37",
|
|
50
|
+
"@types/serve-static": "^1.13.10",
|
|
51
|
+
"@types/signal-exit": "^3.0.1",
|
|
52
|
+
"@types/ws": "^8.2.1",
|
|
53
|
+
"@types/yargs": "^17.0.7",
|
|
54
|
+
"chokidar": "^3.5.2",
|
|
55
|
+
"clipboardy": "^3.0.0",
|
|
56
|
+
"command-exists": "^1.2.9",
|
|
57
|
+
"execa": "^6.0.0",
|
|
58
|
+
"faye-websocket": "^0.11.4",
|
|
59
|
+
"finalhandler": "^1.1.2",
|
|
60
|
+
"find-up": "^6.2.0",
|
|
61
|
+
"formdata-node": "^4.3.1",
|
|
62
|
+
"ink": "^3.2.0",
|
|
63
|
+
"ink-select-input": "^4.2.1",
|
|
64
|
+
"ink-table": "^3.0.0",
|
|
65
|
+
"ink-text-input": "^4.0.2",
|
|
66
|
+
"node-fetch": "^3.1.0",
|
|
67
|
+
"open": "^8.4.0",
|
|
68
|
+
"path-to-regexp": "^6.2.0",
|
|
69
|
+
"react": "^17.0.2",
|
|
70
|
+
"react-error-boundary": "^3.1.4",
|
|
71
|
+
"serve-static": "^1.14.1",
|
|
72
|
+
"signal-exit": "^3.0.6",
|
|
73
|
+
"tmp-promise": "^3.0.3",
|
|
74
|
+
"undici": "^4.11.1",
|
|
75
|
+
"ws": "^8.3.0",
|
|
76
|
+
"yargs": "^17.3.0"
|
|
77
|
+
},
|
|
78
|
+
"files": [
|
|
79
|
+
"src",
|
|
80
|
+
"bin",
|
|
81
|
+
"miniflare-config-stubs",
|
|
82
|
+
"wrangler-dist",
|
|
83
|
+
"static-asset-facade.js",
|
|
84
|
+
"vendor",
|
|
85
|
+
"import_meta_url.js"
|
|
86
|
+
],
|
|
7
87
|
"scripts": {
|
|
8
|
-
"
|
|
88
|
+
"clean": "rm -rf wrangler-dist",
|
|
89
|
+
"bundle": "node -r esbuild-register scripts/bundle.ts",
|
|
90
|
+
"build": "npm run clean && npm run bundle",
|
|
91
|
+
"start": "npm run bundle && NODE_OPTIONS=--enable-source-maps ./bin/wrangler.js",
|
|
92
|
+
"test": "CF_API_TOKEN=some-api-token CF_ACCOUNT_ID=some-account-id jest --silent=false --verbose=true"
|
|
9
93
|
},
|
|
10
|
-
"dependencies": {},
|
|
11
|
-
"devDependencies": {},
|
|
12
|
-
"optionalDependencies": {},
|
|
13
94
|
"engines": {
|
|
14
|
-
"node": "
|
|
95
|
+
"node": ">=16.7.0"
|
|
96
|
+
},
|
|
97
|
+
"jest": {
|
|
98
|
+
"restoreMocks": true,
|
|
99
|
+
"testRegex": ".*.(test|spec)\\.[jt]sx?$",
|
|
100
|
+
"transformIgnorePatterns": [
|
|
101
|
+
"node_modules/(?!node-fetch|fetch-blob|find-up|locate-path|p-locate|p-limit|yocto-queue|path-exists|data-uri-to-buffer|formdata-polyfill|execa|strip-final-newline|npm-run-path|path-key|onetime|mimic-fn|human-signals|is-stream)"
|
|
102
|
+
],
|
|
103
|
+
"moduleNameMapper": {
|
|
104
|
+
"clipboardy": "<rootDir>/src/__tests__/clipboardy-mock.js"
|
|
105
|
+
},
|
|
106
|
+
"transform": {
|
|
107
|
+
"^.+\\.c?(t|j)sx?$": [
|
|
108
|
+
"esbuild-jest",
|
|
109
|
+
{
|
|
110
|
+
"sourcemap": true
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
"setupFilesAfterEnv": [
|
|
115
|
+
"<rootDir>/src/__tests__/jest.setup.ts"
|
|
116
|
+
]
|
|
15
117
|
}
|
|
16
118
|
}
|