diff --git a/functions/colab.js b/functions/colab.js index 07f1024d..c7e2431e 100644 --- a/functions/colab.js +++ b/functions/colab.js @@ -2,11 +2,10 @@ // `external_node_modules` of [functions] in netlify.toml // They are required for this function to run -import { v4 as uuidv4 } from 'uuid' +import { v5 as uuidv5 } from 'uuid' import JSZip from 'jszip' import { pushToGitHub } from './utils' -const nbUid = uuidv4() const repoOwner = process.env.VUE_APP_GH_USER const repo = process.env.VUE_APP_GH_REPO @@ -17,6 +16,7 @@ exports.handler = async function (event, _) { const data = JSON.parse(event.body) const zip = new JSZip() const code = data.code + let hash = '' const template = `ignite-${data.template}` const nbName = `${template}.ipynb` @@ -25,8 +25,10 @@ exports.handler = async function (event, _) { // generate a base64 format for pushing to GitHub // with Octokit. for (const filename in code) { + hash += code[filename] zip.file(filename, code[filename]) } + const nbUid = uuidv5(hash, uuidv5.URL) const content = await zip.generateAsync({ type: 'base64' }) const zipRes = await pushToGitHub( content,