Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wrangler

Package Overview
Dependencies
Maintainers
4
Versions
3903
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wrangler - npm Package Compare versions

Comparing version 0.0.0-c63f14a to 0.0.0-c6eb564

src/module-collection.ts

9

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc