Code Monkey home page Code Monkey logo

cfw's Introduction

cfw CI npm

A build and deploy utility for Cloudflare Workers.


WORK IN PROGRESS

Status: Functional, but incomplete.


Credentials

There are two approaches in providing cfw with a set of Cloudflare credentials:

Persisted

Create a ~/.cfw/config file, where ~ is that path to your home directory. Inside, you'll store your credentials under different "profile" namespaces. (If you're familiar, this is very similar to an AWS credentials file.) An example file may look like this:

[personal]
CLOUDFLARE_AUTH_EMAIL = [email protected]
CLOUDFLARE_ACCOUNTID = ACCOUNTID_VALUE
CLOUDFLARE_AUTH_KEY = GLOBAL_API_KEY
CLOUDFLARE_ZONEID = ZONEID_VALUE

In this case, we have a "personal" profile containing our personal account credentials. You can define multiple credential groups by repeating this template as needed, using different profile names.

[personal]
CLOUDFLARE_AUTH_EMAIL = [email protected]
# ...

[work]
CLOUDFLARE_AUTH_EMAIL = [email protected]
# ...

Additionally, all credential key names may be lowercased.

Default Profile

If a profile named [default] exists, then cfw will auto-load that credentials group when no there is no profile configured.

Selecting a Profile

You may use a profile key inside your configuration file, or define --profile when running an cfw command.

Environment Variables

The same keys found within your credentials file may be used again as environment variables.

When defined, an environment variable takes priority over all other configuration avenues.

  • CLOUDFLARE_ACCOUNTID – your account identifier; alias of config.accountid
  • CLOUDFLARE_AUTH_EMAIL – your account email address; alias of config.email
  • CLOUDFLARE_AUTH_KEY – your account's global API key; alias of config.authkey
  • CLOUDFLARE_ZONEID – your domain/zone's identifier; alias of config.zoneid
  • CLOUDFLARE_TOKEN – an API access token; alias of config.token

Authentication

In order to successfull access your Cloudflare account's resources, you must satisfy the following requirements:

  1. A CLOUDFLARE_ACCOUNTID (or config.accountid) is always required.

  2. A valid token or key-pair; you have two options:

    1. A CLOUDFLARE_TOKEN (or config.token) containing a valid API token.
      (Recommended) Preferred solution, as this API token can be narrowly scoped and can be revoked at any time.

    2. A valid CLOUDFLARE_AUTH_EMAIL and CLOUDFLARE_AUTH_KEY combination.
      This requires your Global API Key, which grants full access to all account resources.

  3. A CLOUDFLARE_ZONEID is only required if you are not deploying to a *.workers.dev subdomain (via config.subdomain).

The following profiles represent valid combinations:

[recommended]
cloudflare_accountid = da32...
cloudflare_token = 78a...
# (optional) cloudflare_zoneid = b58...

[other]
cloudflare_accountid = da32...
cloudflare_auth_email = [email protected]
cloudflare_auth_key = 62d...
# (optional) cloudflare_zoneid = b58...

License

MIT © Luke Edwards

cfw's People

Contributors

lukeed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

lgs ivoreis licitdev

cfw's Issues

feat: kv keys

Manage/browse KV namespace keys through CLI

$ cfw kv keys list [prefix]
$ cfw kv keys get <name>
$ cfw kv keys delete <name>
$ cfw kv keys pue <name> <value>

Have to figure out how to deal with pagination, if at all.

Triggers support

Be nice to be able to support cron workers too:

[triggers]
crons = ["*/15 * * * *"]

feat: secrets

Manage secrets through CLI

$ cfw secrets list
$ cfw secrets delete <name>
$ cfw secrets put <name> <value>

Ability to deploy to .workers.dev?

First off, apologies if this is a misunderstanding, first time playing with workers so I still have a lot of doc reading to do.

It seems that cfw can only deploy to custom domains, hence the requirement on having a zoneid. Is this intentional, or maybe a limitation on CF's side? As I don't have any domains set up with CF at the moment, there's no way to get a zoneid for quick demo of worktop + cfw. Had to switch over to wrangler for that.

Certainly not a huge deal as anything past a demo I'd want to toss up on a real domain anyhow.

Multiple environments (spanning multiple zone ids)

My wrangler.toml file looks something like this:

name = "worker"
type = "javascript"
route = "..."
vars = { ... }

[build]
upload.format = "service-worker"
command = "yarn run build"

[env.qa]
route = "..." # Zone ID 1
vars = { ... }

[env.staging]
route = "..." # Zone ID 2
vars = { ... }

[env.production]
route = "..." # Zone ID 2
vars = { ... }

Is there a way to specify different environments, each with their respective settings, in cfw?

Deploy single site

When we run cfw deploy it deploys all folders. Is there a way only to deploy a single folder?

feat: static upload

Upload a directory of static files.

  • Can utilize config.build to run Rollup-based website builder (optional)
  • Requires (probably) "type": "static" or "static": "<dir>" for targeting
  • Define KV namespace through config and/or CLI

Should try to make use of existing deploy command instead of new upload command.

See local sirv branch for worker-based runtime.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.