New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More →

wrangler

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wrangler - npm Package Compare versions

Comparing version

to
0.0.0-0192aae04

#!/usr/bin/env node
const { spawn } = require("child_process");
const { join } = require("path");
const semiver = require("semiver");
const path = require("path");
const MIN_NODE_VERSION = "16.7.0";
const MIN_NODE_VERSION = "16.13.0";
async function main() {
if (semiver(process.versions.node, MIN_NODE_VERSION) < 0) {
// Note Volta and nvm are also recommended in the official docs:
// https://developers.cloudflare.com/workers/get-started/guide#2-install-the-workers-cli
console.error(
`Wrangler requires at least Node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}.
You should use the latest Node.js version if possible, as Cloudflare Workers use a very up-to-date version of V8.
let wranglerProcess;
/**
* Executes ../wrangler-dist/cli.js
*/
function runWrangler() {
if (semiver(process.versions.node, MIN_NODE_VERSION) < 0) {
// Note Volta and nvm are also recommended in the official docs:
// https://developers.cloudflare.com/workers/get-started/guide#2-install-the-workers-cli
console.error(
`Wrangler requires at least Node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}. Please update your version of Node.js.
Consider using a Node.js version manager such as https://volta.sh/ or https://github.com/nvm-sh/nvm.`
);
process.exitCode = 1;
return;
}
);
process.exitCode = 1;
return;
}
spawn(
process.execPath,
[
"--no-warnings",
"--experimental-vm-modules",
...process.execArgv,
join(__dirname, "../wrangler-dist/cli.js"),
...process.argv.slice(2),
],
{ stdio: "inherit" }
).on("exit", (code) =>
process.exit(code === undefined || code === null ? 0 : code)
);
return spawn(
process.execPath,
[
"--no-warnings",
"--experimental-vm-modules",
...process.execArgv,
path.join(__dirname, "../wrangler-dist/cli.js"),
...process.argv.slice(2),
],
{
stdio: ["inherit", "inherit", "inherit", "ipc"],
}
)
.on("exit", (code) =>
process.exit(code === undefined || code === null ? 0 : code)
)
.on("message", (message) => {
if (process.send) {
process.send(message);
}
})
.on("disconnect", () => {
if (process.disconnect) {
process.disconnect();
}
});
}
void main();
// semiver implementation via https://github.com/lukeed/semiver/blob/ae7eebe6053c96be63032b14fb0b68e2553fcac4/src/index.js
/**
MIT License
Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var fn = new Intl.Collator(0, { numeric: 1 }).compare;
function semiver(a, b, bool) {
a = a.split(".");
b = b.split(".");
return (
fn(a[0], b[0]) ||
fn(a[1], b[1]) ||
((b[2] = b.slice(2).join(".")),
(bool = /[.-]/.test((a[2] = a.slice(2).join(".")))),
bool == /[.-]/.test(b[2]) ? fn(a[2], b[2]) : bool ? -1 : 1)
);
}
// end semiver implementation
if (module === require.main) {
wranglerProcess = runWrangler();
process.on("SIGINT", () => {
wranglerProcess && wranglerProcess.kill();
});
process.on("SIGTERM", () => {
wranglerProcess && wranglerProcess.kill();
});
}
{
"name": "wrangler",
"version": "0.0.0-014a731",
"author": "wrangler@cloudflare.com",
"version": "0.0.0-0192aae04",
"description": "Command-line interface for all things Cloudflare Workers",
"bin": {
"wrangler": "./bin/wrangler.js",
"wrangler2": "./bin/wrangler.js"
},
"license": "MIT OR Apache-2.0",
"bugs": {
"url": "https://github.com/cloudflare/wrangler/issues"
},
"homepage": "https://github.com/cloudflare/wrangler#readme",
"keywords": [

@@ -31,3 +21,2 @@ "wrangler",

"emscripten",
"rust",
"typescript",

@@ -39,90 +28,160 @@ "graphql",

],
"homepage": "https://github.com/cloudflare/workers-sdk#readme",
"bugs": {
"url": "https://github.com/cloudflare/workers-sdk/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/cloudflare/workers-sdk.git",
"directory": "packages/wrangler"
},
"license": "MIT OR Apache-2.0",
"author": "wrangler@cloudflare.com",
"main": "wrangler-dist/cli.js",
"types": "wrangler-dist/cli.d.ts",
"bin": {
"wrangler": "./bin/wrangler.js",
"wrangler2": "./bin/wrangler.js"
},
"files": [
"bin",
"miniflare-dist",
"wrangler-dist",
"templates",
"kv-asset-handler.js",
"config-schema.json"
],
"dependencies": {
"esbuild": "0.14.1",
"miniflare": "2.2.0",
"path-to-regexp": "^6.2.0",
"semiver": "^1.1.0"
"@cloudflare/unenv-preset": "2.0.2",
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
"@esbuild-plugins/node-modules-polyfill": "0.2.2",
"blake3-wasm": "2.1.5",
"esbuild": "0.17.19",
"path-to-regexp": "6.3.0",
"unenv": "2.0.0-rc.14",
"workerd": "1.20250310.0",
"@cloudflare/kv-asset-handler": "0.3.4",
"miniflare": "0.0.0-0192aae04"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
},
"devDependencies": {
"@babel/types": "^7.16.0",
"@iarna/toml": "^2.2.5",
"@types/estree": "^0.0.50",
"@types/mime": "^2.0.3",
"@types/react": "^17.0.37",
"@types/serve-static": "^1.13.10",
"@aws-sdk/client-s3": "^3.721.0",
"@cloudflare/types": "6.18.4",
"@cloudflare/workers-types": "^4.20250310.0",
"@cspotcode/source-map-support": "0.8.1",
"@iarna/toml": "^3.0.0",
"@microsoft/api-extractor": "^7.47.0",
"@sentry/node": "^7.86.0",
"@sentry/types": "^7.86.0",
"@sentry/utils": "^7.86.0",
"@types/command-exists": "^1.2.0",
"@types/glob-to-regexp": "^0.4.1",
"@types/is-ci": "^3.0.0",
"@types/javascript-time-ago": "^2.0.3",
"@types/mime": "^3.0.4",
"@types/minimatch": "^5.1.2",
"@types/node": "^18.19.75",
"@types/node-forge": "^1.3.11",
"@types/prompts": "^2.0.14",
"@types/resolve": "^1.20.6",
"@types/shell-quote": "^1.7.2",
"@types/signal-exit": "^3.0.1",
"@types/ws": "^8.2.1",
"@types/yargs": "^17.0.7",
"acorn": "^8.6.0",
"acorn-walk": "^8.2.0",
"chokidar": "^3.5.2",
"clipboardy": "^3.0.0",
"@types/supports-color": "^8.1.1",
"@types/ws": "^8.5.7",
"@types/yargs": "^17.0.22",
"@vitest/ui": "~3.0.5",
"@webcontainer/env": "^1.1.0",
"chalk": "^5.2.0",
"chokidar": "^4.0.1",
"cli-table3": "^0.6.3",
"cmd-shim": "^4.1.0",
"command-exists": "^1.2.9",
"devtools-protocol": "^0.0.955664",
"execa": "^6.0.0",
"faye-websocket": "^0.11.4",
"finalhandler": "^1.1.2",
"find-up": "^6.2.0",
"formdata-node": "^4.3.1",
"ink": "^3.2.0",
"ink-select-input": "^4.2.1",
"ink-table": "^3.0.0",
"ink-testing-library": "^2.1.0",
"ink-text-input": "^4.0.2",
"concurrently": "^8.2.2",
"date-fns": "^4.1.0",
"devtools-protocol": "^0.0.1182435",
"dotenv": "^16.3.1",
"execa": "^6.1.0",
"find-up": "^6.3.0",
"get-port": "^7.0.0",
"glob-to-regexp": "^0.4.1",
"https-proxy-agent": "7.0.2",
"is-ci": "^3.0.1",
"itty-time": "^1.0.6",
"javascript-time-ago": "^2.5.4",
"md5-file": "5.0.0",
"mime": "^3.0.0",
"node-fetch": "^3.1.0",
"minimatch": "^5.1.0",
"mock-socket": "^9.3.1",
"msw": "2.4.3",
"node-forge": "^1.3.1",
"open": "^8.4.0",
"react": "^17.0.2",
"react-error-boundary": "^3.1.4",
"serve-static": "^1.14.1",
"signal-exit": "^3.0.6",
"tmp-promise": "^3.0.3",
"undici": "^4.11.1",
"ws": "^8.3.0",
"yargs": "^17.3.0"
"p-queue": "^7.2.0",
"patch-console": "^1.0.0",
"pretty-bytes": "^6.0.0",
"prompts": "^2.4.2",
"resolve": "^1.22.8",
"rimraf": "^5.0.10",
"selfsigned": "^2.0.1",
"semiver": "^1.1.0",
"shell-quote": "^1.8.1",
"signal-exit": "^3.0.7",
"source-map": "^0.6.1",
"strip-ansi": "^7.1.0",
"supports-color": "^9.2.2",
"timeago.js": "^4.0.2",
"ts-dedent": "^2.2.0",
"ts-json-schema-generator": "^1.5.0",
"typescript": "^5.7.2",
"undici": "^5.28.5",
"update-check": "^1.5.4",
"vitest": "~3.0.5",
"vitest-websocket-mock": "^0.4.0",
"ws": "8.18.0",
"xdg-app-paths": "^8.3.0",
"xxhash-wasm": "^1.0.1",
"yargs": "^17.7.2",
"@cloudflare/cli": "1.1.1",
"@cloudflare/eslint-config-worker": "1.1.0",
"@cloudflare/pages-shared": "^0.13.13",
"@cloudflare/workers-tsconfig": "0.0.0",
"@cloudflare/workers-shared": "0.0.0-0192aae04"
},
"files": [
"src",
"bin",
"pages",
"miniflare-config-stubs",
"wrangler-dist",
"static-asset-facade.js",
"vendor",
"import_meta_url.js"
],
"scripts": {
"clean": "rm -rf wrangler-dist",
"bundle": "node -r esbuild-register scripts/bundle.ts",
"build": "npm run clean && npm run bundle",
"start": "npm run bundle && NODE_OPTIONS=--enable-source-maps ./bin/wrangler.js",
"test": "CF_API_TOKEN=some-api-token CF_ACCOUNT_ID=some-account-id jest --silent=false --verbose=true"
"peerDependencies": {
"@cloudflare/workers-types": "^4.20250310.0"
},
"peerDependenciesMeta": {
"@cloudflare/workers-types": {
"optional": true
}
},
"optionalDependencies": {
"fsevents": "~2.3.2",
"sharp": "^0.33.5"
},
"engines": {
"node": ">=16.7.0"
"node": ">=16.17.0"
},
"jest": {
"restoreMocks": true,
"testRegex": ".*.(test|spec)\\.[jt]sx?$",
"transformIgnorePatterns": [
"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)"
],
"moduleNameMapper": {
"clipboardy": "<rootDir>/src/__tests__/clipboardy-mock.js"
},
"transform": {
"^.+\\.c?(t|j)sx?$": [
"esbuild-jest",
{
"sourcemap": true
}
]
},
"setupFilesAfterEnv": [
"<rootDir>/src/__tests__/jest.setup.ts"
]
"volta": {
"extends": "../../package.json"
},
"workers-sdk": {
"prerelease": true
},
"scripts": {
"assert-git-version": "node -r esbuild-register scripts/assert-git-version.ts",
"build": "pnpm run clean && pnpm run bundle && pnpm run emit-types && pnpm run generate-json-schema",
"bundle": "node -r esbuild-register scripts/bundle.ts",
"check:lint": "eslint . --max-warnings=0",
"check:type": "tsc -p ./tsconfig.json && tsc -p ./templates/tsconfig.json",
"clean": "rimraf wrangler-dist miniflare-dist emitted-types",
"dev": "pnpm run clean && concurrently -c black,blue --kill-others-on-fail false \"pnpm run bundle --watch\" \"pnpm run check:type --watch --preserveWatchOutput\"",
"emit-types": "tsc -p tsconfig.emit.json && node -r esbuild-register scripts/emit-types.ts",
"generate-json-schema": "pnpm exec ts-json-schema-generator --no-type-check --path src/config/config.ts --type RawConfig --out config-schema.json",
"start": "pnpm run bundle && cross-env NODE_OPTIONS=--enable-source-maps ./bin/wrangler.js",
"test": "dotenv -- pnpm run assert-git-version && dotenv -- vitest",
"test:ci": "pnpm run test run",
"test:debug": "pnpm run test --silent=false --verbose=true",
"test:e2e": "dotenv -- vitest -c ./e2e/vitest.config.mts",
"test:watch": "pnpm run test --testTimeout=50000 --watch",
"type:tests": "tsc -p ./src/__tests__/tsconfig.json && tsc -p ./e2e/tsconfig.json"
}
}
}

@@ -1,51 +0,70 @@

## 🤠 wrangler
<h1 align="center"> ⛅️ wrangler </h1>
<section align="center" id="shieldio-badges">
<a href="https://www.npmjs.com/package/wrangler"><img alt="npm" src="https://img.shields.io/npm/dw/wrangler?style=flat-square"></a>
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors/cloudflare/workers-sdk?style=flat-square">
<img alt="GitHub commit activity (branch)" src="https://img.shields.io/github/commit-activity/w/cloudflare/workers-sdk/main?style=flat-square">
<a href="https://discord.cloudflare.com"><img alt="Discord" src="https://img.shields.io/discord/595317990191398933?color=%23F48120&style=flat-square"></a>
</section>
`wrangler` is a command line tool for building [Cloudflare Workers](https://workers.cloudflare.com/).
[(Read the full stack week launch blog post.)](https://blog.cloudflare.com/wrangler-v2-beta/)
> [!WARNING]
>
> Wrangler v2 is **only receiving critical security updates.** We recommend you [migrate to Wrangler v3](https://developers.cloudflare.com/workers/wrangler/migration/update-v2-to-v3/) if you can.
**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.
## Quick Start
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).
To get started quickly with a Hello World worker, run the command below:
## Quick Start
```bash
# Make a javascript file
$ echo "export default { fetch() { return new Response('hello world') } }" > index.js
# try it out
$ npx wrangler@beta dev index.js
# and then publish it
$ npx wrangler@beta publish index.js --name my-worker
# visit https://my-worker.<your workers subdomain>.workers.dev
npx wrangler init my-worker -y
```
## Installation:
For more info, visit our [Getting Started](https://developers.cloudflare.com/workers/get-started/guide/) guide.
```bash
$ npm install wrangler@beta
## Documentation
For the latest Wrangler documentation, [click here](https://developers.cloudflare.com/workers/wrangler/).
To read more about Workers in general:
- [Getting Started](https://developers.cloudflare.com/workers/get-started/guide/)
- [How Workers works](https://developers.cloudflare.com/workers/reference/how-workers-works/)
- [Observability](https://developers.cloudflare.com/workers/observability/)
- [Platform](https://developers.cloudflare.com/workers/platform/)
## Configuration
Wrangler is configured via a `wrangler.toml` or `wrangler.json` file in the project root. An example configuration generated by `npx wrangler init` or `npx create cloudflare` is as follows:
```toml
name = "my-worker"
main = "./src/index.ts"
compatibility_date = "YYYY-MM-DD"
```
For more detailed information about configuration, refer to the [documentation](https://developers.cloudflare.com/workers/wrangler/configuration/).
## Commands
### `wrangler init [name]`
### Workers
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).
#### `wrangler dev`
### `wrangler dev [script]`
Start a local development server, with live reloading and devtools.
### `wrangler publish [script] --name [name]`
#### `wrangler deploy`
Publish the given script to the worldwide Cloudflare network.
Publish the given script to Cloudflare's global network.
For more commands and options, refer to the [documentation](https://developers.cloudflare.com/workers/cli-wrangler/commands).
For more commands and options, refer to the [documentation](https://developers.cloudflare.com/workers/wrangler/commands/).
### `wrangler pages dev [directory] [-- command]`
### Pages
Either serves a static build asset directory, or proxies itself in front of a command.
#### `wrangler pages dev [directory]`
Serves a static build asset directory.
Builds and runs functions from a `./functions` directory or uses a `_worker.js` file inside the static build asset directory.
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`.

Sorry, the diff of this file is too big to display