wrangler
Advanced tools
Comparing version 0.0.0-c63f14a to 0.0.0-c6eb564
{ | ||
"name": "wrangler", | ||
"version": "0.0.0-c63f14a", | ||
"version": "0.0.0-c6eb564", | ||
"author": "wrangler@cloudflare.com", | ||
@@ -42,4 +42,3 @@ "description": "Command-line interface for all things Cloudflare Workers", | ||
"miniflare": "2.0.0-rc.3", | ||
"semiver": "^1.1.0", | ||
"serve": "^13.0.2" | ||
"semiver": "^1.1.0" | ||
}, | ||
@@ -57,6 +56,6 @@ "optionalDependencies": { | ||
"@types/yargs": "^17.0.7", | ||
"chokidar": "^3.5.2", | ||
"clipboardy": "^3.0.0", | ||
"command-exists": "^1.2.9", | ||
"execa": "^6.0.0", | ||
"express": "^4.17.1", | ||
"finalhandler": "^1.1.2", | ||
@@ -66,3 +65,2 @@ "find-up": "^6.2.0", | ||
"http-proxy": "^1.18.1", | ||
"http-proxy-middleware": "^2.0.1", | ||
"ink": "^3.2.0", | ||
@@ -79,2 +77,3 @@ "ink-select-input": "^4.2.1", | ||
"tmp-promise": "^3.0.3", | ||
"undici": "^4.11.1", | ||
"ws": "^8.3.0", | ||
@@ -81,0 +80,0 @@ "yargs": "^17.3.0" |
@@ -6,8 +6,5 @@ import * as fs from "node:fs"; | ||
import { main } from "../index"; | ||
// @ts-expect-error we're mocking cfetch, so of course setMock isn't a thing | ||
import { setMock, unsetAllMocks } from "../cfetch"; | ||
import { setMock, unsetAllMocks } from "./mock-cfetch"; | ||
jest.mock("../cfetch", () => { | ||
return jest.requireActual("./mock-cfetch"); | ||
}); | ||
jest.mock("../cfetch", () => jest.requireActual("./mock-cfetch")); | ||
@@ -48,29 +45,67 @@ async function w(cmd: void | string, options?: { tap: boolean }) { | ||
describe("wrangler", () => { | ||
it("should run", async () => { | ||
const { stdout } = await w(undefined, { tap: true }); | ||
describe("no command", () => { | ||
it("should display a list of available commands", async () => { | ||
const { stdout, stderr } = await w(undefined, { tap: true }); | ||
expect(stdout).toMatchInlineSnapshot(` | ||
"wrangler | ||
expect(stdout).toMatchInlineSnapshot(` | ||
"wrangler | ||
Commands: | ||
wrangler init [name] 📥 Create a wrangler.toml configuration file | ||
wrangler dev <filename> 👂 Start a local server for developing your worker | ||
wrangler publish [script] 🆙 Publish your Worker to Cloudflare. | ||
wrangler tail [name] 🦚 Starts a log tailing session for a deployed Worker. | ||
wrangler secret 🤫 Generate a secret that can be referenced in the worker script | ||
wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces | ||
wrangler kv:key 🔑 Individually manage Workers KV key-value pairs | ||
wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once | ||
wrangler pages ⚡️ Configure Cloudflare Pages | ||
Commands: | ||
wrangler init [name] 📥 Create a wrangler.toml configuration file | ||
wrangler dev <filename> 👂 Start a local server for developing your worker | ||
wrangler publish [script] 🆙 Publish your Worker to Cloudflare. | ||
wrangler tail [name] 🦚 Starts a log tailing session for a deployed Worker. | ||
wrangler secret 🤫 Generate a secret that can be referenced in the worker script | ||
wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces | ||
wrangler kv:key 🔑 Individually manage Workers KV key-value pairs | ||
wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once | ||
wrangler pages ⚡️ Configure Cloudflare Pages | ||
Flags: | ||
-c, --config Path to .toml configuration file [string] | ||
-h, --help Show help [boolean] | ||
-v, --version Show version number [boolean] | ||
Flags: | ||
-c, --config Path to .toml configuration file [string] | ||
-h, --help Show help [boolean] | ||
-v, --version Show version number [boolean] | ||
Options: | ||
-l, --local Run on my machine [boolean] [default: false]" | ||
`); | ||
Options: | ||
-l, --local Run on my machine [boolean] [default: false]" | ||
`); | ||
expect(stderr).toEqual(""); | ||
}); | ||
}); | ||
describe("invalid command", () => { | ||
it("should display an error", async () => { | ||
const { stdout, stderr } = await w("invalid-command", { tap: true }); | ||
expect(stdout).toMatchInlineSnapshot(` | ||
"wrangler | ||
Commands: | ||
wrangler init [name] 📥 Create a wrangler.toml configuration file | ||
wrangler dev <filename> 👂 Start a local server for developing your worker | ||
wrangler publish [script] 🆙 Publish your Worker to Cloudflare. | ||
wrangler tail [name] 🦚 Starts a log tailing session for a deployed Worker. | ||
wrangler secret 🤫 Generate a secret that can be referenced in the worker script | ||
wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces | ||
wrangler kv:key 🔑 Individually manage Workers KV key-value pairs | ||
wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once | ||
wrangler pages ⚡️ Configure Cloudflare Pages | ||
Flags: | ||
-c, --config Path to .toml configuration file [string] | ||
-h, --help Show help [boolean] | ||
-v, --version Show version number [boolean] | ||
Options: | ||
-l, --local Run on my machine [boolean] [default: false]" | ||
`); | ||
expect(stderr).toMatchInlineSnapshot(` | ||
" | ||
Unknown command: invalid-command." | ||
`); | ||
}); | ||
}); | ||
describe("init", () => { | ||
@@ -77,0 +112,0 @@ const ogcwd = process.cwd(); |
// This file mocks ../cfetch.ts | ||
// so we can insert whatever responses we want from it | ||
const pathToRegexp = require("path-to-regexp"); | ||
const { pathToRegexp } = require("path-to-regexp"); | ||
// TODO: add jsdoc style types here | ||
@@ -11,3 +11,3 @@ | ||
function mockCfetch(resource, init) { | ||
export function mockCfetch(resource, init) { | ||
for (const { regexp, handler } of mocks) { | ||
@@ -21,3 +21,3 @@ if (regexp.test(resource)) { | ||
function setMock(resource, handler) { | ||
export function setMock(resource, handler) { | ||
const mock = { | ||
@@ -34,16 +34,9 @@ resource, | ||
function unsetAllMocks() { | ||
export function unsetAllMocks() { | ||
mocks = []; | ||
} | ||
const CF_API_BASE_URL = | ||
export const CF_API_BASE_URL = | ||
process.env.CF_API_BASE_URL || "https://api.cloudflare.com/client/v4"; | ||
Object.assign(module.exports, { | ||
__esModule: true, | ||
default: mockCfetch, | ||
mockCfetch, | ||
setMock, | ||
unsetAllMocks, | ||
CF_API_BASE_URL, | ||
}); | ||
export default mockCfetch; |
@@ -11,2 +11,3 @@ import type { CfWorkerInit } from "./api/worker"; | ||
import { syncAssets } from "./sites"; | ||
import makeModuleCollector from "./module-collection"; | ||
@@ -79,2 +80,3 @@ type CfScriptFormat = void | "modules" | "service-worker"; | ||
const moduleCollector = makeModuleCollector(); | ||
const result = await esbuild.build({ | ||
@@ -102,5 +104,7 @@ ...(props.public | ||
metafile: true, | ||
conditions: ["worker", "browser"], | ||
loader: { | ||
".js": "jsx", | ||
}, | ||
plugins: [moduleCollector.plugin], | ||
...(jsxFactory && { jsxFactory }), | ||
@@ -222,3 +226,3 @@ ...(jsxFragment && { jsxFragment }), | ||
modules: assets.manifest | ||
? [].concat({ | ||
? moduleCollector.modules.concat({ | ||
name: "__STATIC_CONTENT_MANIFEST", | ||
@@ -228,3 +232,3 @@ content: JSON.stringify(assets.manifest), | ||
}) | ||
: [], | ||
: moduleCollector.modules, | ||
compatibility_date: config.compatibility_date, | ||
@@ -231,0 +235,0 @@ compatibility_flags: config.compatibility_flags, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
5
64
9246
12257022
- Removedserve@^13.0.2
- Removed@zeit/schemas@2.6.0(transitive)
- Removedaccepts@1.3.8(transitive)
- Removedajv@6.12.6(transitive)
- Removedansi-align@3.0.1(transitive)
- Removedansi-regex@5.0.1(transitive)
- Removedansi-styles@3.2.14.3.0(transitive)
- Removedarch@2.2.0(transitive)
- Removedarg@2.0.0(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedboxen@5.1.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbytes@3.0.0(transitive)
- Removedcamelcase@6.3.0(transitive)
- Removedchalk@2.4.14.1.2(transitive)
- Removedcli-boxes@2.2.1(transitive)
- Removedclipboardy@2.3.0(transitive)
- Removedcolor-convert@1.9.32.0.1(transitive)
- Removedcolor-name@1.1.31.1.4(transitive)
- Removedcompressible@2.0.18(transitive)
- Removedcompression@1.7.3(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedcontent-disposition@0.5.2(transitive)
- Removedcross-spawn@6.0.6(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddeep-extend@0.6.0(transitive)
- Removedemoji-regex@8.0.0(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedexeca@1.0.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedfast-url-parser@1.1.3(transitive)
- Removedget-stream@4.1.0(transitive)
- Removedhas-flag@3.0.04.0.0(transitive)
- Removedini@1.3.8(transitive)
- Removedis-docker@2.2.1(transitive)
- Removedis-fullwidth-code-point@3.0.0(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedis-wsl@2.2.0(transitive)
- Removedisexe@2.0.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedmime-db@1.33.01.52.01.53.0(transitive)
- Removedmime-types@2.1.182.1.35(transitive)
- Removedminimatch@3.0.4(transitive)
- Removedminimist@1.2.8(transitive)
- Removedms@2.0.0(transitive)
- Removednegotiator@0.6.3(transitive)
- Removednice-try@1.0.5(transitive)
- Removednpm-run-path@2.0.2(transitive)
- Removedon-headers@1.0.2(transitive)
- Removedonce@1.4.0(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedpath-is-inside@1.0.2(transitive)
- Removedpath-key@2.0.1(transitive)
- Removedpath-to-regexp@2.2.1(transitive)
- Removedpump@3.0.2(transitive)
- Removedpunycode@1.4.12.3.1(transitive)
- Removedrange-parser@1.2.0(transitive)
- Removedrc@1.2.8(transitive)
- Removedregistry-auth-token@3.3.2(transitive)
- Removedregistry-url@3.1.0(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedsemver@5.7.2(transitive)
- Removedserve@13.0.4(transitive)
- Removedserve-handler@6.1.3(transitive)
- Removedshebang-command@1.2.0(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedstring-width@4.2.3(transitive)
- Removedstrip-ansi@6.0.1(transitive)
- Removedstrip-eof@1.0.0(transitive)
- Removedstrip-json-comments@2.0.1(transitive)
- Removedsupports-color@5.5.07.2.0(transitive)
- Removedtype-fest@0.20.2(transitive)
- Removedupdate-check@1.5.2(transitive)
- Removeduri-js@4.4.1(transitive)
- Removedvary@1.1.2(transitive)
- Removedwhich@1.3.1(transitive)
- Removedwidest-line@3.1.0(transitive)
- Removedwrap-ansi@7.0.0(transitive)
- Removedwrappy@1.0.2(transitive)