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.
Files changed (69) hide show
  1. package/README.md +51 -55
  2. package/bin/wrangler.js +36 -0
  3. package/import_meta_url.js +3 -0
  4. package/miniflare-config-stubs/.env.empty +0 -0
  5. package/miniflare-config-stubs/package.empty.json +1 -0
  6. package/miniflare-config-stubs/wrangler.empty.toml +0 -0
  7. package/package.json +111 -9
  8. package/src/__tests__/clipboardy-mock.js +4 -0
  9. package/src/__tests__/index.test.ts +391 -0
  10. package/src/__tests__/jest.setup.ts +17 -0
  11. package/src/__tests__/mock-cfetch.js +42 -0
  12. package/src/__tests__/mock-dialogs.ts +65 -0
  13. package/src/api/form_data.ts +141 -0
  14. package/src/api/inspect.ts +430 -0
  15. package/src/api/preview.ts +128 -0
  16. package/src/api/worker.ts +161 -0
  17. package/src/cfetch.ts +72 -0
  18. package/src/cli.ts +10 -0
  19. package/src/config.ts +122 -0
  20. package/src/dev.tsx +867 -0
  21. package/src/dialogs.tsx +77 -0
  22. package/src/index.tsx +1875 -0
  23. package/src/kv.tsx +211 -0
  24. package/src/module-collection.ts +64 -0
  25. package/src/pages.tsx +818 -0
  26. package/src/proxy.ts +104 -0
  27. package/src/publish.ts +358 -0
  28. package/src/sites.tsx +115 -0
  29. package/src/tail.tsx +71 -0
  30. package/src/user.tsx +1029 -0
  31. package/static-asset-facade.js +47 -0
  32. package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +332 -0
  33. package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +176 -0
  34. package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +25 -0
  35. package/vendor/@cloudflare/kv-asset-handler/README.md +245 -0
  36. package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +32 -0
  37. package/vendor/@cloudflare/kv-asset-handler/dist/index.js +354 -0
  38. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +13 -0
  39. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +148 -0
  40. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +1 -0
  41. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +436 -0
  42. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +1 -0
  43. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +40 -0
  44. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +1 -0
  45. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +42 -0
  46. package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +26 -0
  47. package/vendor/@cloudflare/kv-asset-handler/dist/types.js +31 -0
  48. package/vendor/@cloudflare/kv-asset-handler/package.json +52 -0
  49. package/vendor/@cloudflare/kv-asset-handler/src/index.ts +296 -0
  50. package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +136 -0
  51. package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +464 -0
  52. package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +33 -0
  53. package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +42 -0
  54. package/vendor/@cloudflare/kv-asset-handler/src/types.ts +39 -0
  55. package/vendor/wrangler-mime/CHANGELOG.md +289 -0
  56. package/vendor/wrangler-mime/LICENSE +21 -0
  57. package/vendor/wrangler-mime/Mime.js +97 -0
  58. package/vendor/wrangler-mime/README.md +187 -0
  59. package/vendor/wrangler-mime/cli.js +46 -0
  60. package/vendor/wrangler-mime/index.js +4 -0
  61. package/vendor/wrangler-mime/lite.js +4 -0
  62. package/vendor/wrangler-mime/package.json +52 -0
  63. package/vendor/wrangler-mime/types/other.js +1 -0
  64. package/vendor/wrangler-mime/types/standard.js +1 -0
  65. package/wrangler-dist/cli.js +125758 -0
  66. package/wrangler-dist/cli.js.map +7 -0
  67. package/.npmignore +0 -15
  68. package/index.js +0 -250
  69. package/tests/is.spec.js +0 -1155
package/README.md CHANGED
@@ -1,55 +1,51 @@
1
- # Wrangler
2
- `Wrangler` is a very small CommonJS module that smoothes over some of the gotchas in JavaScript type checking and casting. It behaves the way you (or rather, I) would expect type checking and casting to work -- e.g., `is.object()` only works on objects that are neither arrays nor regular expressions. It also makes `indexOf()` easier to use, and provides search functions. Works in Node; should work in browser as well, exporting the objects `is` and `to` into the global namespace.
3
-
4
- None of these techniques are earth-shattering; most people will use these in their daily work. I just didn't want to have to remember all of them while I was banging out code.
5
-
6
- Test coverage is as thorough as my imagination allows. I used Jasmine for unit testing.
7
-
8
- ## API
9
-
10
- ### Type checking
11
-
12
- All checking is strict, unless otherwise noted. Each function returns either true or false.
13
-
14
- * `is.undefined( value )`
15
- * `is.null( value )`
16
- * `is.empty( value )` - checks for null or undefined
17
- * `is.empty.array( value )` or `is.emptyArray( value )` - must be an array-like object and have no items
18
- * `is.empty.arguments( value )` or `is.emptyArguments( value )` - identical to above
19
- * `is.empty.object( value )` or `is.emptyObject( value )` - must be an object and have no properties of its own; objects with properties in their prototype chains will also fail
20
- * `is.null( value )`
21
- * `is.boolean( value )`
22
- * `is.nan( value )` - really not necessary, since it merely calls `isNan()`. But I just included it to be thorough.
23
- * `is.infinite( value )` - opposite of `isFinite()`. I didn't include an `isFinite()` function because `is.number()` performs this check.
24
- * `is.number( value )` - includes all the sensible numbers (e.g., not `NaN` or `Infinity`).
25
- * `is.integer( value )` - we all know JavaScript doesn't have integers or floats, so this fills half that gap.
26
- * `is.float( value )` - and this fills the other half of the gap.
27
- * `is.string( value )`
28
- * `is.object( value )` - anything considered to be an object, except `null`, regular expressions, arrays, or array-like objects. Functions are considered objects, of course.
29
- * `is.array( value )` - any good old honest 'true' array.
30
- * `is.enumerable( value )` - arrays, array-like objects, and strings. Anything that can be iterated upon. (Yes, that does include strings!)
31
- * `is.arrayLike( value )` - array-like objects (but not arrays).
32
- * `is.arguments( value )` - the `arguments` array-like object.
33
- * `is.function( value )`
34
- * `is.regexp( value )`
35
- * `is.in( needle [, haystack] )` - takes a needle and performs a strict search on the haystack. If the haystack is not supplied, `this` is assumed as the haystack. The haystack can be an object, array-like object, or string. In case of objects, only the self-owned, direct descendants are searched.
36
- * `is.in.array( needle [, haystack] )` or `is.inArray( needle [, haystack] )` - works on array-like objects only.
37
- * `is.in.object( needle [, haystack] )` or `is.inObject( needle [, haystack] )` - works only on haystacks that pass the `is.object()` test.
38
- * `is.in.string( needle [, haystack] )` or `is.inString( needle [, haystack] )` - string search; converts non-strings to strings.
39
- * `is.ownProperty( property [, object] )` - calls `Object.prototype.hasOwnProperty()` on the object. If the object is not supplied, `this` is assumed.
40
-
41
- ### Type casting
42
-
43
- * `to.boolean( value )`
44
- * `to.number( value )` or `to.float( value )` - calls `parseFloat()` on the value; therefore, it may return `NaN`.
45
- * `to.integer( value )` - returns the integral part of the value. Acts as floor for positive numbers and ceiling for negative integers.
46
- * `to.string( value )`
47
- * `to.array( value )` - casts array-like objects to arrays and everything else to an array containing a single element, which happens to be the passed value.
48
- * `to.regexp( value )` - if the value is a string, returns a regular expression using the `new RegExp()` constructor. Returns `undefined` if the value is not a string.
49
- * `to.date( value )` - returns a new date object using the `new Date()` constructor.
50
-
51
- More typecasting to follow, as I think of cases that need it!
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`.
@@ -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();
@@ -0,0 +1,3 @@
1
+ // as per https://github.com/evanw/esbuild/issues/1492
2
+ // to make some libs work
3
+ export const import_meta_url = require("url").pathToFileURL(__filename);
File without changes
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
- "description": "'Wrangler' is a very small module that smoothes over some of the gotchas in JavaScript type checking and casting. It behaves the way you (or perhaps just I) would expect type checking to work -- e.g., is.object() only works on objects that are neither arrays nor regular expressions. It also makes indexOf() easier to use, and provides search functions. Works in Node; should work in browser as well, exporting a variable 'is' into the global namespace.",
5
- "version": "0.0.2",
6
- "main": "index.js",
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
- "test": "jasmine-node tests/*.spec.js"
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
  }
@@ -0,0 +1,4 @@
1
+ // We use this mock during tests because we're having trouble
2
+ // properly compiling clipboardy for jest
3
+ // We can revisit this if and when we write tests that test
4
+ // the copying part of `dev`