Open oscard0m opened 3 years ago
for reference: here is some good docs on base64: https://developer.mozilla.org/en-US/docs/Glossary/Base64. We might need to use TextEncoder instead of atob/btoa (see https://discourse.wicg.io/t/base64-with-textencoder-textdecoder/1307), I need to do some more research.
great insights: https://stackoverflow.com/questions/30631927/converting-to-base64-in-javascript-without-deprecated-escape-call
I'm making it an official @octokit plugin after all, as so many folks run into headaches with the repository contents APIs: https://github.com/octokit/plugin-create-or-update-text-file.js
Plugin is ready. We'll see how it will hold up across node / browser / deno, but at least it has the universal base64 encoding/decoding logic in a single place, and it is definitely better to only use Buffer
directly
Next step is to add the plugin to @octoherd/octokit
and then update the scripts to use the new octokit.createOrUpdateTextFile()
method instead of sending requests to get/update file contents and handle the encoding/decoding within the script
Considerations: Use polyfill for Node: https://github.com/gr2m/octoherd-script-normalize-package-repository-field/blob/0272b1555ba5479e01e7a240d3e5ec646024bf37/script.js#L85-L92
Originally posted here: https://github.com/octoherd/script-setup-renovate/issues/3#issuecomment-792326838