-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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
let urlParts = /^https?:\/\/workers\.cloudflare\.com\/get\-npm\-wrangler\-binary\/([^\/]+)\/([^\/]+)(?:\/|$)/.exec(request.url) | ||
if (!urlParts) | ||
return new Response("Missing URL components", {status: 400}) |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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>", |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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?
Third caching worker, this time for the wrangler binary installed by the npm installer.