Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add caching worker for npm installer #3

Merged
merged 1 commit into from
Nov 5, 2019

Conversation

gabbifish
Copy link
Contributor

Third caching worker, this time for the wrangler binary installed by the npm installer.

Copy link

@EverlastingBugstopper EverlastingBugstopper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have some nits here but they can probably be made in another PR since I'm assuming this is simply putting what we currently have into this repo

event.respondWith(handleRequest(event.request))
})

async function getJSONFromGitHub(url) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this takes a url, i feel like this function should be called getJSON since it only gets it from github if the url passed is a github url

Comment on lines +33 to +35
let urlParts = /^https?:\/\/workers\.cloudflare\.com\/get\-npm\-wrangler\-binary\/([^\/]+)\/([^\/]+)(?:\/|$)/.exec(request.url)
if (!urlParts)
return new Response("Missing URL components", {status: 400})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's hard for me to grok what's happening here - is it possible to use URL to have cleaner conditionals, or maybe a more descriptive error message than "Missing URL components"

let assets = await getJSONFromGitHub(release.assets_url)

const [compatibleAsset] = assets.filter(asset =>
asset.name.endsWith(arch + ".tar.gz")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would use template string

`${arch}.tar.gz`

"test": "echo \"Error: no test specified\" && exit 1",
"format": "prettier --write '**/*.{js,css,json,md}'"
},
"author": "Gabbi Fisher <gabbi@cloudflare.com>",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should likely be wrangler@cloudflare.com to be consistent with wrangler author

name = "cache-npm-wrangler-binary"
type = "js"
route = "https://workers.cloudflare.com/get-npm-wrangler-binary*"
workers_dev = false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workers_dev = false is unnecessary now! :)

@@ -0,0 +1,6 @@
account_id = "8995c0f49cdcf57eb54d2c1e52b7d2f3"
name = "cache-npm-wrangler-binary"
type = "js"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason we aren't using webpack to minify?

@gabbifish gabbifish merged commit 5c1e5b8 into master Nov 5, 2019
@gabbifish gabbifish deleted the gabbi/cache-npm-wrangler-binary branch November 5, 2019 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants