From 7338ae8bdcb67714feb702c6672253935b8c28c6 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 24 Nov 2023 23:12:29 +0200 Subject: [PATCH 1/6] minor variable declaration let categoryJson --- scripts/generatePullRequestForNewInitiative.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index 29885337..19350666 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -237,7 +237,7 @@ ${linksJsonString} return; } - let categoryLinksJsonFile; + let categoryJson, categoryLinksJsonFile; try { categoryLinksJsonFile = `${process.env.GITHUB_WORKSPACE}/_data/links/${category}/links.json`; console.log("resolved category links file: " + categoryLinksJsonFile); From 3939459c9fdfd1b702738da9aed12920e74b0895 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 24 Nov 2023 23:19:40 +0200 Subject: [PATCH 2/6] minor refactor updatexistingInitiative => getExistingInitiativeIndex --- .../generatePullRequestForNewInitiative.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index 19350666..7e931a24 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -178,24 +178,21 @@ ${linksJsonString} return false; } - async function updateExistingInitiativeAsync(categoryJson, newInitiativeJson) { + async function getExistingInitiativeIndexAsync(categoryJson, newInitiativeJson) { const initiativeName = newInitiativeJson.name; if (!(initiativeName?.trim())) { await warnAndCommentAsync("For update, you must provide a name that matches the name of an existing initiative", "no initiative name provided", newInitiativeJson); - return false; + return -1; } - const existingCategoryIndex = categoryJson.links.findIndex((link => - link.name?.localeCompare(initiativeName, undefined, { sensitivity: 'accent' }) === 0 - )) + const existingCategoryIndex = categoryJson.links.findIndex(link => link.name?.localeCompare(initiativeName, undefined, { sensitivity: 'accent' }) === 0) if (existingCategoryIndex === -1) { await warnAndCommentAsync(`Could not find existing initiative '${initiativeName}' in category '${category}'`, "initiative not found", newInitiativeJson); - return false; + return -1; } - categoryJson.links[existingCategoryIndex] = newInitiativeJson; - return true; + return existingCategoryIndex; } const tempFolder = process.env.TEMP || "/tmp"; @@ -250,10 +247,12 @@ ${linksJsonString} } if (updateInitiative) { - const edited = await updateExistingInitiativeAsync(categoryJson, newInitiativeJson, newInitiativeJson) - if (!edited) { + const existingInitiativeIndex = await getExistingInitiativeIndexAsync(categoryJson, newInitiativeJson, newInitiativeJson) + if (existingInitiativeIndex === -1) { return; } + + categoryJson.links[existingInitiativeIndex] = newInitiativeJson; } else { categoryJson.links.push(newInitiativeJson); From 8219ef91126d35130169fecdd4c5151cd52ddff1 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 24 Nov 2023 23:21:32 +0200 Subject: [PATCH 3/6] Fix update PR name --- scripts/generatePullRequestForNewInitiative.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index 7e931a24..578cc76f 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -22,7 +22,7 @@ module.exports = async ({github, context}) => { return text.substring(indexOfJsonStart + jsonStartMarker.length, indexOfJsonEnd); } - async function createOrUpdatePullRequestAsync(branch, name) { + async function createOrUpdatePullRequestAsync(update, branch, name) { const existingResponse = await github.rest.pulls.list({ owner: context.repo.owner, @@ -40,7 +40,7 @@ module.exports = async ({github, context}) => { } const newResponse = await github.rest.pulls.create({ - title: `New Initiative: ${name} [Suggested by ${process.env.ISSUE_AUTHOR}]`, + title: `${update ? "Update" : "New"} Initiative: ${name} [Suggested by ${process.env.ISSUE_AUTHOR}]`, owner: context.repo.owner, repo: context.repo.repo, head: branch, @@ -251,7 +251,7 @@ ${linksJsonString} if (existingInitiativeIndex === -1) { return; } - + categoryJson.links[existingInitiativeIndex] = newInitiativeJson; } else { @@ -270,7 +270,7 @@ ${linksJsonString} let pr; try { - pr = await createOrUpdatePullRequestAsync(branch, newInitiativeJson.name || "???"); + pr = await createOrUpdatePullRequestAsync(updateInitiative, branch, newInitiativeJson.name || "???"); } catch (e) { return await warnAndCommentAsync("Could not create pull request", e, newInitiativeJson); From c9f91025c8883d533d5238a91daa88e9671405d3 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 25 Nov 2023 00:48:14 +0200 Subject: [PATCH 4/6] exclude initiativeValidationDetails from existing initiative detection --- scripts/generatePullRequestForNewInitiative.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index 578cc76f..f1344384 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -154,7 +154,7 @@ See GitHub Action logs for more details: ${context.serverUrl}/${context.repo.own for (const prop in newInitiativeJson) { const value = newInitiativeJson[prop]; - if (typeof value !== "string") { + if (prop === "initiativeValidationDetails" || typeof value !== "string") { continue; } From 8bb06d2d8f05041b80a54200eeb70ce83617737a Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 25 Nov 2023 00:51:33 +0200 Subject: [PATCH 5/6] minor prop rename --- scripts/generatePullRequestForNewInitiative.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index f1344384..f370780d 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -151,10 +151,10 @@ See GitHub Action logs for more details: ${context.serverUrl}/${context.repo.own const linksJsonString = await fs.readFile(linkJsonFileName, "utf8"); const upperlinksJsonString = linksJsonString.toLocaleUpperCase("en-us"); - for (const prop in newInitiativeJson) { + for (const propName in newInitiativeJson) { - const value = newInitiativeJson[prop]; - if (prop === "initiativeValidationDetails" || typeof value !== "string") { + const value = newInitiativeJson[propName]; + if (propName === "initiativeValidationDetails" || typeof value !== "string") { continue; } @@ -162,7 +162,7 @@ See GitHub Action logs for more details: ${context.serverUrl}/${context.repo.own if (upperlinksJsonString.indexOf(PropValueUpper) !== -1) { await warnAndCommentAsync( `Initiative might already exist! -The value of property \`${prop}\` (\`${value}\`) is already present in \`${linkJsonFileName}\`: +The value of property \`${propName}\` (\`${value}\`) is already present in \`${linkJsonFileName}\`: \`\`\`json ${linksJsonString} \`\`\` From e9ac32c3e49b1a875576b03865df28c72769af45 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 25 Nov 2023 01:05:57 +0200 Subject: [PATCH 6/6] BrainPop --- _data/links/Children/Main/links.json | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/_data/links/Children/Main/links.json b/_data/links/Children/Main/links.json index 8ca5ffae..b40cad94 100644 --- a/_data/links/Children/Main/links.json +++ b/_data/links/Children/Main/links.json @@ -49,12 +49,17 @@ "website": "https://padlet.com/redirect?url=https%3A%2F%2Fschool.booksgiant.com%2Flogin%2Fhe" }, { + "displayName": "Foo-babysit", "name": "BrainPop", - "displayName": "BrainPop", - "shortDescription": "תכנים חינוכיים עם קוד חינמי", - "description": "קוד: בריינפופ23", - "url": "https://il.brainpop.com/", - "website": "https://il.brainpop.com/" + "shortDescription": "FooFoo-Baz", + "description": "helloFoo-world", + "tags": [ + "החמ'ל המתוק", + "הילדים/ראשי", + "באר213111", + "FooBaz", + "עולם שלום" + ] }, { "displayName": "simplesteps",