{"id":25070283,"url":"https://github.com/thomascogez/cf-script","last_synced_at":"2025-07-21T07:03:14.211Z","repository":{"id":273890081,"uuid":"920874256","full_name":"Thomascogez/cf-script","owner":"Thomascogez","description":"Run local script that can access your cloudflare worker bindings","archived":false,"fork":false,"pushed_at":"2025-06-23T05:08:33.000Z","size":2011,"stargazers_count":3,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-29T16:04:50.746Z","etag":null,"topics":["cli","cloudflare","cloudflare-pages","cloudflare-workers","script"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/cf-script","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Thomascogez.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-22T23:17:20.000Z","updated_at":"2025-05-27T09:58:27.000Z","dependencies_parsed_at":"2025-01-23T15:38:06.138Z","dependency_job_id":"a3f30f2c-d3d1-4d38-a25d-db112c5428b4","html_url":"https://github.com/Thomascogez/cf-script","commit_stats":null,"previous_names":["thomascogez/cf-script"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/Thomascogez/cf-script","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thomascogez%2Fcf-script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thomascogez%2Fcf-script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thomascogez%2Fcf-script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thomascogez%2Fcf-script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Thomascogez","download_url":"https://codeload.github.com/Thomascogez/cf-script/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thomascogez%2Fcf-script/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266255244,"owners_count":23900098,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","cloudflare","cloudflare-pages","cloudflare-workers","script"],"created_at":"2025-02-06T21:19:34.753Z","updated_at":"2025-07-21T07:03:14.180Z","avatar_url":"https://github.com/Thomascogez.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003ch1 align=\"center\"\u003e\n  \u003cbr\u003e\n  \u003cimg src=\"./assets/logo.png\" alt=\"cf-script-logo\" width=\"200\"\u003e\n  \u003cbr\u003e\n  Cloudflare script\n  \u003cbr\u003e\n\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003eA simple CLI tool that allow to run local scripts that can access your Worker bindings\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://badge.fury.io/js/cf-script\"\u003e\n    \u003cimg src=\"https://badge.fury.io/js/cf-script.svg\" alt=\"cf-script\"\u003e\n  \u003c/a\u003e\n\n\u003c/p\u003e\n\n![screenshot](./assets/demo.gif)\n\n## What is this ?\n\nWhen working with cloudflare worker and cloudflare platform locally we don't have any easy way to directly access\nWorker bindings such has (kv, r2, d1, ...).\n\nThis is by the nature of the secure cloudflare design where the bindings are provided to the app and not directly accessible.\n\nSo cf-script allow to run piece of code (scripts) that have access to your local cloudflare worker bindings. This can allow you to:\n\n- Run one time sql query against your D1 database\n- List, debug, write value in your KV database\n- Download a file from your R2 bucket\n\n## How To Use\n\n### 1. Install\n\n```bash\nnpm install cf-script # For local project install\n\n# or\n\nnpm install cf-script -g # For global install\n```\n\n### 2. Write your first script\n\nIn order to write script you need to create a new file either (.ts or .js) and make it export by default a function\n\n```ts\nexport default (env, args) =\u003e {\n  console.log(\"Running script with following bindings \", env)\n  console.log(\"And following args \", args)\n}\n```\n\n### 3. Run your script\n\n```bash\ncf-script ./scripts/my-first-script.ts\n```\n\nAnd that it 🎉\n\nYou can check examples in the `/dogfood` folder (including one using typescript)\n\n## CLI args\n\n| Name | Description | Default | Example |\n| --- | --- | --- | --- |\n| `--env` | Environment to run the script in | undefined (default wrangler env) | --env staging |\n| `--wcp` | Path to the wrangler config file | undefined (by default it will look for the closest one from cwd) | --wcp ./wrangler.toml |\n| `--cwd` | Current working directory | process.cwd() | --cwd ./my-project |\n| `--sa` | Args that will be passed to the executed script | undefined (no args) | --sa foo:bar or --sa foo:bar biz:baz |\n\n## Credits\n\nThis software uses the following open source packages:\n\n- [jiti](https://github.com/unjs/jiti)\n- [wrangler](https://github.com/cloudflare/workers-sdk)\n- [commander](https://github.com/tj/commander.js)\n- [ora](https://github.com/sindresorhus/ora)\n- [vitest](https://github.com/vitest-dev/vitest)\n- [biome](https://github.com/biomejs/biome)\n- [tsup](https://github.com/egoist/tsup)\n\n## License\n\nMIT\n\n---\n\n\u003e GitHub [@Thomascogez](https://github.com/Thomascogez) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e X [@Thomascogez](https://x.com/ThomasCogez)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomascogez%2Fcf-script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomascogez%2Fcf-script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomascogez%2Fcf-script/lists"}