From dc88da1a309e9930c6307c2955f7e2cd47a20471 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 15:11:22 +0200 Subject: [PATCH 01/25] Feed issue title as display name to GPT Also replace double quotes with single quotes --- .github/workflows/initiative-auto-pr.yml | 1 + scripts/gptGenerateJsonFromIssue.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/initiative-auto-pr.yml b/.github/workflows/initiative-auto-pr.yml index 5f9bb790..eb901c9a 100644 --- a/.github/workflows/initiative-auto-pr.yml +++ b/.github/workflows/initiative-auto-pr.yml @@ -32,6 +32,7 @@ jobs: env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} ISSUE_BODY: ${{ github.event.issue.body }} + ISSUE_TITLE: ${{ github.event.issue.title }} with: timeout_minutes: 5 max_attempts: 3 diff --git a/scripts/gptGenerateJsonFromIssue.py b/scripts/gptGenerateJsonFromIssue.py index 743bb3af..e700647a 100644 --- a/scripts/gptGenerateJsonFromIssue.py +++ b/scripts/gptGenerateJsonFromIssue.py @@ -107,8 +107,19 @@ def ask_gpt_for_initiative_json(self, issue_body: str) -> str: logging.warn("GPT did not infer function calling, best-effort answer parsing will be performed") return response_message["content"] +def get_new_initiative_details() -> str: + initiative_details = f""" + ### Initiative Display Name + {os.environ["ISSUE_TITLE"]} + + {os.environ["ISSUE_BODY"]} + """ + + # replace double-quotes with single quotes to minimize chance of invalid JSON returned by GPT + return initiative_details.replace('"', "'") + if __name__ == "__main__": - gpt_response = GPTAssistant().ask_gpt_for_initiative_json(os.environ["ISSUE_BODY"]) + gpt_response = GPTAssistant().ask_gpt_for_initiative_json(get_new_initiative_details()) respose_output_file = os.getenv("TEMP", "/tmp") + "/gpt-auto-comment.output" logging.info(f"Writing GPT Response to {respose_output_file}:\n{gpt_response}") From 502bf1e745aa927b7ec814d8b20e2d65de260f05 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 15:19:22 +0200 Subject: [PATCH 02/25] sanitize issue title --- scripts/gptGenerateJsonFromIssue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gptGenerateJsonFromIssue.py b/scripts/gptGenerateJsonFromIssue.py index e700647a..4af2aca4 100644 --- a/scripts/gptGenerateJsonFromIssue.py +++ b/scripts/gptGenerateJsonFromIssue.py @@ -110,7 +110,7 @@ def ask_gpt_for_initiative_json(self, issue_body: str) -> str: def get_new_initiative_details() -> str: initiative_details = f""" ### Initiative Display Name - {os.environ["ISSUE_TITLE"]} + {os.environ["ISSUE_TITLE"].replace("[NEW-INITIATIVE]:", "")} {os.environ["ISSUE_BODY"]} """ From d7cb741eb8f6825240b6eec85faa64a4e3916794 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 16:05:01 +0200 Subject: [PATCH 03/25] Mention new itiative issue author in PR title --- .github/workflows/initiative-auto-pr.yml | 2 ++ scripts/generatePullRequestForNewInitiative.js | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/initiative-auto-pr.yml b/.github/workflows/initiative-auto-pr.yml index eb901c9a..1ec9cab5 100644 --- a/.github/workflows/initiative-auto-pr.yml +++ b/.github/workflows/initiative-auto-pr.yml @@ -40,6 +40,8 @@ jobs: - name: Generate PR uses: actions/github-script@v6 + env: + ISSUE_AUTHOR: ${{ github.event.issue.user.name }} with: script: | const script = require(process.env.GITHUB_WORKSPACE + '/scripts/generatePullRequestForNewInitiative.js') diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index 5604e8af..e59a50ee 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -39,7 +39,7 @@ module.exports = async ({github, context}) => { } const newResponse = await github.rest.pulls.create({ - title: 'New Initiative: ' + name, + title: `New Initiative: ${name} [Suggested by ${ISSUE_AUTHOR}]`, owner: context.repo.owner, repo: context.repo.repo, head: branch, @@ -120,7 +120,10 @@ module.exports = async ({github, context}) => { const PropValueUpper = value.toLocaleUpperCase("en-us"); if (upperCategoryJsonString.indexOf(PropValueUpper) !== -1) { - return await warnAndComment(`Initiative might already exist under this category, the value of property ${prop} is already present in the JSON: ${value}`, "suspected existing initiative", humanReadableJson); + return await warnAndComment( + `Initiative might already exist under this category, the value of property "${prop}" is already present in the JSON: "${value}". If you are certain this initiative doesn't exist`, + "suspected existing initiative", + humanReadableJson); } } From 80836b35b023bd5bbb2bfe0594c55805d0451430 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 16:12:12 +0200 Subject: [PATCH 04/25] Add dev dependency for @octokit/rest required for local auto PR generation testing --- package-lock.json | 185 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 186 insertions(+) diff --git a/package-lock.json b/package-lock.json index 4e4a02c5..055d266b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "remark-html": "^16.0.1" }, "devDependencies": { + "@octokit/rest": "^20.0.2", "@trivago/prettier-plugin-sort-imports": "^4.2.1", "@types/lunr": "^2.3.6", "@types/mixpanel-browser": "^2.47.4", @@ -1562,6 +1563,163 @@ "node": ">= 8" } }, + "node_modules/@octokit/auth-token": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz", + "integrity": "sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==", + "dev": true, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/core": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.1.tgz", + "integrity": "sha512-lyeeeZyESFo+ffI801SaBKmCfsvarO+dgV8/0gD8u1d87clbEdWsP5yC+dSj3zLhb2eIf5SJrn6vDz9AheETHw==", + "dev": true, + "dependencies": { + "@octokit/auth-token": "^4.0.0", + "@octokit/graphql": "^7.0.0", + "@octokit/request": "^8.0.2", + "@octokit/request-error": "^5.0.0", + "@octokit/types": "^12.0.0", + "before-after-hook": "^2.2.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/endpoint": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.2.tgz", + "integrity": "sha512-qhKW8YLIi+Kmc92FQUFGr++DYtkx/1fBv+Thua6baqnjnOsgBYJDCvWZR1YcINuHGOEQt416WOfE+A/oG60NBQ==", + "dev": true, + "dependencies": { + "@octokit/types": "^12.0.0", + "is-plain-object": "^5.0.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/graphql": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.0.2.tgz", + "integrity": "sha512-OJ2iGMtj5Tg3s6RaXH22cJcxXRi7Y3EBqbHTBRq+PQAqfaS8f/236fUrWhfSn8P4jovyzqucxme7/vWSSZBX2Q==", + "dev": true, + "dependencies": { + "@octokit/request": "^8.0.1", + "@octokit/types": "^12.0.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/openapi-types": { + "version": "19.0.2", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-19.0.2.tgz", + "integrity": "sha512-8li32fUDUeml/ACRp/njCWTsk5t17cfTM1jp9n08pBrqs5cDFJubtjsSnuz56r5Tad6jdEPJld7LxNp9dNcyjQ==", + "dev": true + }, + "node_modules/@octokit/plugin-paginate-rest": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-9.1.2.tgz", + "integrity": "sha512-euDbNV6fxX6btsCDnZoZM4vw3zO1nj1Z7TskHAulO6mZ9lHoFTpwll6farf+wh31mlBabgU81bBYdflp0GLVAQ==", + "dev": true, + "dependencies": { + "@octokit/types": "^12.1.1" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": ">=5" + } + }, + "node_modules/@octokit/plugin-request-log": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-4.0.0.tgz", + "integrity": "sha512-2uJI1COtYCq8Z4yNSnM231TgH50bRkheQ9+aH8TnZanB6QilOnx8RMD2qsnamSOXtDj0ilxvevf5fGsBhBBzKA==", + "dev": true, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": ">=5" + } + }, + "node_modules/@octokit/plugin-rest-endpoint-methods": { + "version": "10.1.2", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.1.2.tgz", + "integrity": "sha512-JztgZ82CY4JNlPTuF0jh4iWuuGpEi5czFCoXyAbMg4F2XyFBbG5DWAKfa3odRvdZww6Df1tQgBKnqpd9X0WF9g==", + "dev": true, + "dependencies": { + "@octokit/types": "^12.1.1" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": ">=5" + } + }, + "node_modules/@octokit/request": { + "version": "8.1.4", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.1.4.tgz", + "integrity": "sha512-M0aaFfpGPEKrg7XoA/gwgRvc9MSXHRO2Ioki1qrPDbl1e9YhjIwVoHE7HIKmv/m3idzldj//xBujcFNqGX6ENA==", + "dev": true, + "dependencies": { + "@octokit/endpoint": "^9.0.0", + "@octokit/request-error": "^5.0.0", + "@octokit/types": "^12.0.0", + "is-plain-object": "^5.0.0", + "universal-user-agent": "^6.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/request-error": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.0.1.tgz", + "integrity": "sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==", + "dev": true, + "dependencies": { + "@octokit/types": "^12.0.0", + "deprecation": "^2.0.0", + "once": "^1.4.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/rest": { + "version": "20.0.2", + "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-20.0.2.tgz", + "integrity": "sha512-Ux8NDgEraQ/DMAU1PlAohyfBBXDwhnX2j33Z1nJNziqAfHi70PuxkFYIcIt8aIAxtRE7KVuKp8lSR8pA0J5iOQ==", + "dev": true, + "dependencies": { + "@octokit/core": "^5.0.0", + "@octokit/plugin-paginate-rest": "^9.0.0", + "@octokit/plugin-request-log": "^4.0.0", + "@octokit/plugin-rest-endpoint-methods": "^10.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/types": { + "version": "12.1.1", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-12.1.1.tgz", + "integrity": "sha512-qnJTldJ1NyGT5MTsCg/Zi+y2IFHZ1Jo5+njNCjJ9FcainV7LjuHgmB697kA0g4MjZeDAJsM3B45iqCVsCLVFZg==", + "dev": true, + "dependencies": { + "@octokit/openapi-types": "^19.0.2" + } + }, "node_modules/@radix-ui/react-compose-refs": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@radix-ui/react-compose-refs/-/react-compose-refs-1.0.1.tgz", @@ -2464,6 +2622,12 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, + "node_modules/before-after-hook": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", + "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==", + "dev": true + }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -2889,6 +3053,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/deprecation": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", + "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==", + "dev": true + }, "node_modules/dequal": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", @@ -4789,6 +4959,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-reference": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.2.tgz", @@ -11516,6 +11695,12 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/universal-user-agent": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz", + "integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==", + "dev": true + }, "node_modules/update-browserslist-db": { "version": "1.0.13", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", diff --git a/package.json b/package.json index 14b808d4..a9ad9369 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "remark-html": "^16.0.1" }, "devDependencies": { + "@octokit/rest": "^20.0.2", "@trivago/prettier-plugin-sort-imports": "^4.2.1", "@types/lunr": "^2.3.6", "@types/mixpanel-browser": "^2.47.4", From 5efd45ff4943e18f497fb7631a542f63ef330b95 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 16:17:14 +0200 Subject: [PATCH 05/25] fix issue author env var --- scripts/generatePullRequestForNewInitiative.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index e59a50ee..3a2d2790 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -39,7 +39,7 @@ module.exports = async ({github, context}) => { } const newResponse = await github.rest.pulls.create({ - title: `New Initiative: ${name} [Suggested by ${ISSUE_AUTHOR}]`, + title: `New Initiative: ${name} [Suggested by ${process.env.ISSUE_AUTHOR}]`, owner: context.repo.owner, repo: context.repo.repo, head: branch, From c04c655e78c442c959471853f85129a6dbfe03ee Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 16:49:53 +0200 Subject: [PATCH 06/25] allow forced PR generation via title prefix "[NEW-INITIATIVE-FORCE-PR]:" --- .github/workflows/initiative-auto-pr.yml | 3 +- .../generatePullRequestForNewInitiative.js | 39 +++++++++++-------- scripts/gptGenerateJsonFromIssue.py | 2 +- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/.github/workflows/initiative-auto-pr.yml b/.github/workflows/initiative-auto-pr.yml index 1ec9cab5..9542ba48 100644 --- a/.github/workflows/initiative-auto-pr.yml +++ b/.github/workflows/initiative-auto-pr.yml @@ -31,8 +31,8 @@ jobs: uses: nick-fields/retry@v2 env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - ISSUE_BODY: ${{ github.event.issue.body }} ISSUE_TITLE: ${{ github.event.issue.title }} + ISSUE_BODY: ${{ github.event.issue.body }} with: timeout_minutes: 5 max_attempts: 3 @@ -42,6 +42,7 @@ jobs: uses: actions/github-script@v6 env: ISSUE_AUTHOR: ${{ github.event.issue.user.name }} + ISSUE_TITLE: ${{ github.event.issue.title }} with: script: | const script = require(process.env.GITHUB_WORKSPACE + '/scripts/generatePullRequestForNewInitiative.js') diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index 3a2d2790..f04d6373 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -108,25 +108,32 @@ module.exports = async ({github, context}) => { } delete json.category //not in our schema, and worse - will interfere with the existing initiative detection below - console.log("Attempting to detect already existing initiative under this category"); - const upperCategoryJsonString = categoryJsonString.toLocaleUpperCase("en-us"); - for (const prop in json) { - - const value = json[prop]; - if (typeof value !== "string" || value == "") { - continue; - } - - const PropValueUpper = value.toLocaleUpperCase("en-us"); - if (upperCategoryJsonString.indexOf(PropValueUpper) !== -1) { - return await warnAndComment( - `Initiative might already exist under this category, the value of property "${prop}" is already present in the JSON: "${value}". If you are certain this initiative doesn't exist`, - "suspected existing initiative", - humanReadableJson); + if (process.env.ISSUE_TITLE.toLocaleUpperCase("en-us").startsWith("[NEW-INITIATIVE-FORCE-PR]:")) { + console.warn("FORCE-PR requested: skipping existing initiative validation"); + } + else { + console.log("Attempting to detect already existing initiative under this category"); + + const upperCategoryJsonString = categoryJsonString.toLocaleUpperCase("en-us"); + for (const prop in json) { + + const value = json[prop]; + if (typeof value !== "string" || value == "") { + continue; + } + + const PropValueUpper = value.toLocaleUpperCase("en-us"); + if (upperCategoryJsonString.indexOf(PropValueUpper) !== -1) { + return await warnAndComment( + `Initiative might already exist under this category, the value of property "${prop}" is already present in the JSON: "${value}". + If you are certain this initiative doesn't exist, edit the issue's title so that it starts with [NEW-INITIATIVE-FORCE-PR]:`, + "suspected existing initiative", + humanReadableJson); + } } } - + categoryJson.links.push(json); fs.writeFileSync(categoryLinksJsonFile, JSON.stringify(categoryJson, null, 2), "utf8"); diff --git a/scripts/gptGenerateJsonFromIssue.py b/scripts/gptGenerateJsonFromIssue.py index 4af2aca4..d99d8d0b 100644 --- a/scripts/gptGenerateJsonFromIssue.py +++ b/scripts/gptGenerateJsonFromIssue.py @@ -110,7 +110,7 @@ def ask_gpt_for_initiative_json(self, issue_body: str) -> str: def get_new_initiative_details() -> str: initiative_details = f""" ### Initiative Display Name - {os.environ["ISSUE_TITLE"].replace("[NEW-INITIATIVE]:", "")} + {os.environ["ISSUE_TITLE"].replace("[NEW-INITIATIVE]:", "").replace("[NEW-INITIATIVE-FORCE-PR]:", "")} {os.environ["ISSUE_BODY"]} """ From 63a76151a3b704e99ed9cc630165b3a97b7d3b18 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 17:08:45 +0200 Subject: [PATCH 07/25] Improve comment message Including run ID link --- scripts/generatePullRequestForNewInitiative.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index f04d6373..152fad5a 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -61,8 +61,11 @@ module.exports = async ({github, context}) => { } async function warnAndComment(warning, exception, json) { - console.warn(`${warning}: ${exception}`); - await createComment(`WARNING: ${warning} (see GitHub Action logs for more details)\n` + "Automatic PR will NOT be generated:\n" + json); + console.warn(`${warning} [${exception}]`); + await createComment(`**WARNING**: ${warning} +see GitHub Action logs for more details: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId} +Automatic PR will NOT be generated +${json}`); } function executeGitCommand(args) { @@ -126,8 +129,8 @@ module.exports = async ({github, context}) => { const PropValueUpper = value.toLocaleUpperCase("en-us"); if (upperCategoryJsonString.indexOf(PropValueUpper) !== -1) { return await warnAndComment( - `Initiative might already exist under this category, the value of property "${prop}" is already present in the JSON: "${value}". - If you are certain this initiative doesn't exist, edit the issue's title so that it starts with [NEW-INITIATIVE-FORCE-PR]:`, + `Initiative might already exist under this category - the value of property \`${prop}\` is already present in the JSON \`${value}\`. +If you are certain this initiative doesn't exist, edit the issue's title so that it starts with \`[NEW-INITIATIVE-FORCE-PR]:\``, "suspected existing initiative", humanReadableJson); } From 8c5194a3001335d16708aaf62c4b81326e8a1d15 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 17:11:34 +0200 Subject: [PATCH 08/25] add some test auto pr github-script mocked data --- scripts/test_generatePullRequestForNewInitiative.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/test_generatePullRequestForNewInitiative.js b/scripts/test_generatePullRequestForNewInitiative.js index ac7cfd39..e41f8f97 100644 --- a/scripts/test_generatePullRequestForNewInitiative.js +++ b/scripts/test_generatePullRequestForNewInitiative.js @@ -1,10 +1,12 @@ const context = { + serverUrl: "https://github.com", + runId: 6762019754, repo: { owner: "ohadschn", repo: "ConnectPortal" }, issue: { - number: 13 + number: 10 } } From cfb998a6fa7c9dea2c16370e9e4182ae95ef22e0 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 18:29:20 +0200 Subject: [PATCH 09/25] fs - move to async --- scripts/generatePullRequestForNewInitiative.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index 152fad5a..c7a2ed99 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -1,6 +1,6 @@ module.exports = async ({github, context}) => { - const fs = require('fs'); + const fs = require('fs').promises; const cp = require('child_process'); function tryExtractJson(text, jsonStartMarker, jsonEndMarker) { @@ -74,7 +74,7 @@ ${json}`); } const tempFolder = process.env.TEMP || "/tmp"; - const gptResponse = fs.readFileSync(tempFolder + "/gpt-auto-comment.output", "utf8"); + const gptResponse = await fs.readFile(tempFolder + "/gpt-auto-comment.output", "utf8"); // https://stackoverflow.com/a/51602415/67824 const sanitizedGptResponse = gptResponse.replace(/[\u0000-\u001F\u007F-\u009F]/g, ""); @@ -103,7 +103,7 @@ ${json}`); categoryLinksJsonFile = `${process.env.GITHUB_WORKSPACE}/_data/links/${json.category}/links.json`; console.log("resolved category links file: " + categoryLinksJsonFile); - categoryJsonString = fs.readFileSync(categoryLinksJsonFile, "utf8"); + categoryJsonString = await fs.readFile(categoryLinksJsonFile, "utf8"); categoryJson = JSON.parse(categoryJsonString); } catch (e) { @@ -138,7 +138,7 @@ If you are certain this initiative doesn't exist, edit the issue's title so that } categoryJson.links.push(json); - fs.writeFileSync(categoryLinksJsonFile, JSON.stringify(categoryJson, null, 2), "utf8"); + await fs.writeFile(categoryLinksJsonFile, JSON.stringify(categoryJson, null, 2), "utf8"); const branch = `auto-pr-${context.issue.number}`; try { From b722da39a4aaee6eef3ed4028e01319e31ed0919 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 18:40:25 +0200 Subject: [PATCH 10/25] minor rename json => newInitiativeJson --- scripts/generatePullRequestForNewInitiative.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index c7a2ed99..e6198b86 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -89,18 +89,19 @@ ${json}`); } console.log("Extracted JSON: " + jsonString); + let newInitiativeJson; try { - json = JSON.parse(jsonString); + newInitiativeJson = JSON.parse(jsonString); } catch (e) { return await warnAndComment("Could not process GPT response as JSON", e, jsonString); } - humanReadableJson = "```json\n" + JSON.stringify(json, null, 2) + "\n```"; + humanReadableJson = "```json\n" + JSON.stringify(newInitiativeJson, null, 2) + "\n```"; let categoryLinksJsonFile, categoryJsonString; try { - categoryLinksJsonFile = `${process.env.GITHUB_WORKSPACE}/_data/links/${json.category}/links.json`; + categoryLinksJsonFile = `${process.env.GITHUB_WORKSPACE}/_data/links/${newInitiativeJson.category}/links.json`; console.log("resolved category links file: " + categoryLinksJsonFile); categoryJsonString = await fs.readFile(categoryLinksJsonFile, "utf8"); @@ -110,7 +111,7 @@ ${json}`); return await warnAndComment("Could not process category links JSON", e, humanReadableJson); } - delete json.category //not in our schema, and worse - will interfere with the existing initiative detection below + delete newInitiativeJson.category //not in our schema, and worse - will interfere with the existing initiative detection below if (process.env.ISSUE_TITLE.toLocaleUpperCase("en-us").startsWith("[NEW-INITIATIVE-FORCE-PR]:")) { console.warn("FORCE-PR requested: skipping existing initiative validation"); @@ -119,9 +120,9 @@ ${json}`); console.log("Attempting to detect already existing initiative under this category"); const upperCategoryJsonString = categoryJsonString.toLocaleUpperCase("en-us"); - for (const prop in json) { + for (const prop in newInitiativeJson) { - const value = json[prop]; + const value = newInitiativeJson[prop]; if (typeof value !== "string" || value == "") { continue; } @@ -137,7 +138,7 @@ If you are certain this initiative doesn't exist, edit the issue's title so that } } - categoryJson.links.push(json); + categoryJson.links.push(newInitiativeJson); await fs.writeFile(categoryLinksJsonFile, JSON.stringify(categoryJson, null, 2), "utf8"); const branch = `auto-pr-${context.issue.number}`; @@ -155,7 +156,7 @@ If you are certain this initiative doesn't exist, edit the issue's title so that let pr; try { - pr = await createOrUpdatePullRequest(branch, json.name || "???"); + pr = await createOrUpdatePullRequest(branch, newInitiativeJson.name || "???"); } catch (e) { return await warnAndComment("Could not create pull request", e, humanReadableJson); From 7c3a8e5dde4bd869711ea2b315fcec891ea3f135 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 18:42:34 +0200 Subject: [PATCH 11/25] minor rename humanReadableJson => markdownNewInitiativeJson --- scripts/generatePullRequestForNewInitiative.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index e6198b86..c2286b9c 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -97,7 +97,7 @@ ${json}`); return await warnAndComment("Could not process GPT response as JSON", e, jsonString); } - humanReadableJson = "```json\n" + JSON.stringify(newInitiativeJson, null, 2) + "\n```"; + const markdownNewInitiativeJson = "```json\n" + JSON.stringify(newInitiativeJson, null, 2) + "\n```"; let categoryLinksJsonFile, categoryJsonString; try { @@ -108,7 +108,7 @@ ${json}`); categoryJson = JSON.parse(categoryJsonString); } catch (e) { - return await warnAndComment("Could not process category links JSON", e, humanReadableJson); + return await warnAndComment("Could not process category links JSON", e, markdownNewInitiativeJson); } delete newInitiativeJson.category //not in our schema, and worse - will interfere with the existing initiative detection below @@ -133,7 +133,7 @@ ${json}`); `Initiative might already exist under this category - the value of property \`${prop}\` is already present in the JSON \`${value}\`. If you are certain this initiative doesn't exist, edit the issue's title so that it starts with \`[NEW-INITIATIVE-FORCE-PR]:\``, "suspected existing initiative", - humanReadableJson); + markdownNewInitiativeJson); } } } @@ -151,7 +151,7 @@ If you are certain this initiative doesn't exist, edit the issue's title so that executeGitCommand(["push", "origin", branch, "--force"]) } catch (e) { - return await warnAndComment("encountered error during git execution", e, humanReadableJson); + return await warnAndComment("encountered error during git execution", e, markdownNewInitiativeJson); } let pr; @@ -159,7 +159,7 @@ If you are certain this initiative doesn't exist, edit the issue's title so that pr = await createOrUpdatePullRequest(branch, newInitiativeJson.name || "???"); } catch (e) { - return await warnAndComment("Could not create pull request", e, humanReadableJson); + return await warnAndComment("Could not create pull request", e, markdownNewInitiativeJson); } console.log("resolved PR: " + JSON.stringify(pr)) From b9559b9b479ec30f12a6e803f1b77127017a2bdc Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 18:45:52 +0200 Subject: [PATCH 12/25] minor refactor - exctract git operations to method --- scripts/generatePullRequestForNewInitiative.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index c2286b9c..665ec885 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -72,6 +72,15 @@ ${json}`); console.log(`Executing: git ${args}`); cp.execFileSync("git", args); } + + function pushPrBranch(branch, categoryLinksJsonFile, initiativeName) { + executeGitCommand(["config", "user.name", "github-actions"]); + executeGitCommand(["config", "user.email", "41898282+github-actions[bot]@users.noreply.github.com"]); //https://github.com/orgs/community/discussions/26560 + executeGitCommand(["checkout", "-b", branch]); + executeGitCommand(["add", categoryLinksJsonFile]); + executeGitCommand(["commit", "-m", initiativeName || "new initiative"]); + executeGitCommand(["push", "origin", branch, "--force"]); + } const tempFolder = process.env.TEMP || "/tmp"; const gptResponse = await fs.readFile(tempFolder + "/gpt-auto-comment.output", "utf8"); @@ -143,12 +152,7 @@ If you are certain this initiative doesn't exist, edit the issue's title so that const branch = `auto-pr-${context.issue.number}`; try { - executeGitCommand(["config", "user.name", "github-actions"]) - executeGitCommand(["config", "user.email", "41898282+github-actions[bot]@users.noreply.github.com"]) //https://github.com/orgs/community/discussions/26560 - executeGitCommand(["checkout", "-b", branch]) - executeGitCommand(["add", categoryLinksJsonFile]) - executeGitCommand(["commit", "-m", json.name || "new initiative"]) - executeGitCommand(["push", "origin", branch, "--force"]) + pushPrBranch(branch, categoryLinksJsonFile, newInitiativeJson.name); } catch (e) { return await warnAndComment("encountered error during git execution", e, markdownNewInitiativeJson); From 8eca4cec30c552ac5bdde9baadb4268a46491762 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 19:14:36 +0200 Subject: [PATCH 13/25] remove redundant initiative JSON properties --- .../generatePullRequestForNewInitiative.js | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index 665ec885..d42c5f62 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -82,6 +82,29 @@ ${json}`); executeGitCommand(["push", "origin", branch, "--force"]); } + function removeRedundantInitiativeJsonProperties(json) { + console.log("Removing redundant initiative JSON properties") + + //not in our links.json schema, and worse - will interfere with existing initiative detection + delete json.category; + + var redundantValues = new Set([undefined, "", "N/A", "NOTAPPLICABLE", "NOTAVAILABLE", "UNAVAILABLE"]) + for (const prop in json) { + const value = json[prop]; + if (typeof value !== "string") { + continue; + } + + // remove whitespace and capitalize + const PropValueNormalized = value?.replace(/\s/g, "").toLocaleUpperCase("en-us"); + + if (redundantValues.has(PropValueNormalized)) { + console.log(`Removing redundant property '${prop}' with value '${value}'`); + delete json[prop]; + } + } + } + const tempFolder = process.env.TEMP || "/tmp"; const gptResponse = await fs.readFile(tempFolder + "/gpt-auto-comment.output", "utf8"); @@ -120,7 +143,7 @@ ${json}`); return await warnAndComment("Could not process category links JSON", e, markdownNewInitiativeJson); } - delete newInitiativeJson.category //not in our schema, and worse - will interfere with the existing initiative detection below + removeRedundantInitiativeJsonProperties(newInitiativeJson); if (process.env.ISSUE_TITLE.toLocaleUpperCase("en-us").startsWith("[NEW-INITIATIVE-FORCE-PR]:")) { console.warn("FORCE-PR requested: skipping existing initiative validation"); From c44a7d7440a8b574126e3a0a2d3cbc1e4d4617d3 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 19:49:17 +0200 Subject: [PATCH 14/25] improved shell command execution --- .../generatePullRequestForNewInitiative.js | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index d42c5f62..a3824f52 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -68,9 +68,25 @@ Automatic PR will NOT be generated ${json}`); } + function executeShellCommand(cmd, args) { + console.log(`Executing: ${cmd} ${args.join(" ")}`); + + let stdout; + try { + stdout = cp.execFileSync(cmd, args); + } + catch (e) { + console.error(`Command executed with non-zero exit code ${e.status}: ${e.message}`); + console.error(`stdout: ${e.stdout}`); + console.error(`stderr: ${e.stderr}`); + throw e; + } + + console.log(`Command executed successfully with output: ${stdout}`); + } + function executeGitCommand(args) { - console.log(`Executing: git ${args}`); - cp.execFileSync("git", args); + executeShellCommand("git", args); } function pushPrBranch(branch, categoryLinksJsonFile, initiativeName) { @@ -149,6 +165,7 @@ ${json}`); console.warn("FORCE-PR requested: skipping existing initiative validation"); } else { + //TODO: EXTRACT METHOD console.log("Attempting to detect already existing initiative under this category"); const upperCategoryJsonString = categoryJsonString.toLocaleUpperCase("en-us"); From d991d117061fb69cf860a99fc24ee97329be40ad Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 20:31:46 +0200 Subject: [PATCH 15/25] Find existing link in all existing categories --- .../generatePullRequestForNewInitiative.js | 68 ++++++++++++------- 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index a3824f52..26f5a5e6 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -1,6 +1,7 @@ module.exports = async ({github, context}) => { const fs = require('fs').promises; + const path = require('path'); const cp = require('child_process'); function tryExtractJson(text, jsonStartMarker, jsonEndMarker) { @@ -121,6 +122,46 @@ ${json}`); } } + async function detectExistingInitiative(newInitiativeJson) { + console.log("Attempting to detect already-existing initiative"); + + const linkJsonFileNames = await fs.readdir(`${process.env.GITHUB_WORKSPACE}/_data/links`, { recursive: true }); + + for (const linkJsonFileName of linkJsonFileNames) { + if (path.extname(linkJsonFileName).toLocaleUpperCase("en-us") !== ".JSON") { + console.log(`Skipping non-JSON file: ${linkJsonFileName}`); + continue; + } + + console.log(`processing links file: ${linkJsonFileName}`); + const linksJsonString = await fs.readFile(linkJsonFileName, "utf8"); + const upperlinksJsonString = linksJsonString.toLocaleUpperCase("en-us"); + + for (const prop in newInitiativeJson) { + + const value = newInitiativeJson[prop]; + if (typeof value !== "string") { + continue; + } + + const PropValueUpper = value.toLocaleUpperCase("en-us"); + if (upperlinksJsonString.indexOf(PropValueUpper) !== -1) { + await warnAndComment( +`Initiative might already exist - the value of property \`${prop}\` (\`${value}\`) is already present in ${linkJsonFileName}: +\`\`\`json +${linksJsonString} +\`\`\` +If you are certain this is a mistake and that the initiative doesn't already exist, edit the issue's title so that it starts with \`[NEW-INITIATIVE-FORCE-PR]:\``, + "Suspected existing initiative", + markdownNewInitiativeJson) + return true; + } + } + + return false; + } + } + const tempFolder = process.env.TEMP || "/tmp"; const gptResponse = await fs.readFile(tempFolder + "/gpt-auto-comment.output", "utf8"); @@ -147,12 +188,12 @@ ${json}`); const markdownNewInitiativeJson = "```json\n" + JSON.stringify(newInitiativeJson, null, 2) + "\n```"; - let categoryLinksJsonFile, categoryJsonString; + let categoryLinksJsonFile; try { categoryLinksJsonFile = `${process.env.GITHUB_WORKSPACE}/_data/links/${newInitiativeJson.category}/links.json`; console.log("resolved category links file: " + categoryLinksJsonFile); - categoryJsonString = await fs.readFile(categoryLinksJsonFile, "utf8"); + const categoryJsonString = await fs.readFile(categoryLinksJsonFile, "utf8"); categoryJson = JSON.parse(categoryJsonString); } catch (e) { @@ -164,27 +205,8 @@ ${json}`); if (process.env.ISSUE_TITLE.toLocaleUpperCase("en-us").startsWith("[NEW-INITIATIVE-FORCE-PR]:")) { console.warn("FORCE-PR requested: skipping existing initiative validation"); } - else { - //TODO: EXTRACT METHOD - console.log("Attempting to detect already existing initiative under this category"); - - const upperCategoryJsonString = categoryJsonString.toLocaleUpperCase("en-us"); - for (const prop in newInitiativeJson) { - - const value = newInitiativeJson[prop]; - if (typeof value !== "string" || value == "") { - continue; - } - - const PropValueUpper = value.toLocaleUpperCase("en-us"); - if (upperCategoryJsonString.indexOf(PropValueUpper) !== -1) { - return await warnAndComment( - `Initiative might already exist under this category - the value of property \`${prop}\` is already present in the JSON \`${value}\`. -If you are certain this initiative doesn't exist, edit the issue's title so that it starts with \`[NEW-INITIATIVE-FORCE-PR]:\``, - "suspected existing initiative", - markdownNewInitiativeJson); - } - } + else if (detectExistingInitiative(newInitiativeJson)) { + return; } categoryJson.links.push(newInitiativeJson); From 02709634ea01065b9c237c5437c28fe982e94ba5 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 20:38:12 +0200 Subject: [PATCH 16/25] Fix link file relative path --- scripts/generatePullRequestForNewInitiative.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index 26f5a5e6..4f170692 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -125,7 +125,8 @@ ${json}`); async function detectExistingInitiative(newInitiativeJson) { console.log("Attempting to detect already-existing initiative"); - const linkJsonFileNames = await fs.readdir(`${process.env.GITHUB_WORKSPACE}/_data/links`, { recursive: true }); + const linksFolder = `${process.env.GITHUB_WORKSPACE}/_data/links`; + const linkJsonFileNames = await fs.readdir(linksFolder, { recursive: true }); for (const linkJsonFileName of linkJsonFileNames) { if (path.extname(linkJsonFileName).toLocaleUpperCase("en-us") !== ".JSON") { @@ -133,10 +134,11 @@ ${json}`); continue; } - console.log(`processing links file: ${linkJsonFileName}`); - const linksJsonString = await fs.readFile(linkJsonFileName, "utf8"); + const linkJsonFileNameAbsolute = `${linksFolder}/${linkJsonFileName}` + console.log(`processing links file: ${linkJsonFileNameAbsolute}`); + const linksJsonString = await fs.readFile(linkJsonFileNameAbsolute, "utf8"); const upperlinksJsonString = linksJsonString.toLocaleUpperCase("en-us"); - + for (const prop in newInitiativeJson) { const value = newInitiativeJson[prop]; From e7266fefa02bf47815a62470a91104f303a1fac4 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 23:35:26 +0200 Subject: [PATCH 17/25] fix existing initiative detection --- scripts/generatePullRequestForNewInitiative.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index 4f170692..4d67fb6c 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -159,9 +159,9 @@ If you are certain this is a mistake and that the initiative doesn't already exi return true; } } - - return false; } + + return false; } const tempFolder = process.env.TEMP || "/tmp"; @@ -207,7 +207,7 @@ If you are certain this is a mistake and that the initiative doesn't already exi if (process.env.ISSUE_TITLE.toLocaleUpperCase("en-us").startsWith("[NEW-INITIATIVE-FORCE-PR]:")) { console.warn("FORCE-PR requested: skipping existing initiative validation"); } - else if (detectExistingInitiative(newInitiativeJson)) { + else if (await detectExistingInitiative(newInitiativeJson)) { return; } @@ -231,5 +231,5 @@ If you are certain this is a mistake and that the initiative doesn't already exi } console.log("resolved PR: " + JSON.stringify(pr)) - createComment((pr.existing ? "Updated" : "Created") + " PR: " + pr.html_url); + await createComment((pr.existing ? "Updated" : "Created") + " PR: " + pr.html_url); } From 03ea5f3ad5d6fc97b30c485f018e7fa768c08d6f Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 23:39:17 +0200 Subject: [PATCH 18/25] Introduce Async suffix for async methods Minimize chance of fogetting await --- .../generatePullRequestForNewInitiative.js | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index 4d67fb6c..078b2bf4 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 createOrUpdatePullRequest(branch, name) { + async function createOrUpdatePullRequestAsync(branch, name) { const existingResponse = await github.rest.pulls.list({ owner: context.repo.owner, @@ -52,7 +52,7 @@ module.exports = async ({github, context}) => { return newResponse.data } - async function createComment(body) { + async function createCommentAsync(body) { await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, @@ -61,9 +61,9 @@ module.exports = async ({github, context}) => { }); } - async function warnAndComment(warning, exception, json) { + async function warnAndCommentAsync(warning, exception, json) { console.warn(`${warning} [${exception}]`); - await createComment(`**WARNING**: ${warning} + await createCommentAsync(`**WARNING**: ${warning} see GitHub Action logs for more details: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId} Automatic PR will NOT be generated ${json}`); @@ -122,7 +122,7 @@ ${json}`); } } - async function detectExistingInitiative(newInitiativeJson) { + async function detectExistingInitiativeAsync(newInitiativeJson) { console.log("Attempting to detect already-existing initiative"); const linksFolder = `${process.env.GITHUB_WORKSPACE}/_data/links`; @@ -148,7 +148,7 @@ ${json}`); const PropValueUpper = value.toLocaleUpperCase("en-us"); if (upperlinksJsonString.indexOf(PropValueUpper) !== -1) { - await warnAndComment( + await warnAndCommentAsync( `Initiative might already exist - the value of property \`${prop}\` (\`${value}\`) is already present in ${linkJsonFileName}: \`\`\`json ${linksJsonString} @@ -185,7 +185,7 @@ If you are certain this is a mistake and that the initiative doesn't already exi newInitiativeJson = JSON.parse(jsonString); } catch (e) { - return await warnAndComment("Could not process GPT response as JSON", e, jsonString); + return await warnAndCommentAsync("Could not process GPT response as JSON", e, jsonString); } const markdownNewInitiativeJson = "```json\n" + JSON.stringify(newInitiativeJson, null, 2) + "\n```"; @@ -199,7 +199,7 @@ If you are certain this is a mistake and that the initiative doesn't already exi categoryJson = JSON.parse(categoryJsonString); } catch (e) { - return await warnAndComment("Could not process category links JSON", e, markdownNewInitiativeJson); + return await warnAndCommentAsync("Could not process category links JSON", e, markdownNewInitiativeJson); } removeRedundantInitiativeJsonProperties(newInitiativeJson); @@ -207,7 +207,7 @@ If you are certain this is a mistake and that the initiative doesn't already exi if (process.env.ISSUE_TITLE.toLocaleUpperCase("en-us").startsWith("[NEW-INITIATIVE-FORCE-PR]:")) { console.warn("FORCE-PR requested: skipping existing initiative validation"); } - else if (await detectExistingInitiative(newInitiativeJson)) { + else if (await detectExistingInitiativeAsync(newInitiativeJson)) { return; } @@ -219,17 +219,17 @@ If you are certain this is a mistake and that the initiative doesn't already exi pushPrBranch(branch, categoryLinksJsonFile, newInitiativeJson.name); } catch (e) { - return await warnAndComment("encountered error during git execution", e, markdownNewInitiativeJson); + return await warnAndCommentAsync("encountered error during git execution", e, markdownNewInitiativeJson); } let pr; try { - pr = await createOrUpdatePullRequest(branch, newInitiativeJson.name || "???"); + pr = await createOrUpdatePullRequestAsync(branch, newInitiativeJson.name || "???"); } catch (e) { - return await warnAndComment("Could not create pull request", e, markdownNewInitiativeJson); + return await warnAndCommentAsync("Could not create pull request", e, markdownNewInitiativeJson); } console.log("resolved PR: " + JSON.stringify(pr)) - await createComment((pr.existing ? "Updated" : "Created") + " PR: " + pr.html_url); + await createCommentAsync((pr.existing ? "Updated" : "Created") + " PR: " + pr.html_url); } From 672768ab3c4083eec45629d052db92365c09a65b Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 23:40:01 +0200 Subject: [PATCH 19/25] minor comment markdown fix --- scripts/generatePullRequestForNewInitiative.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index 078b2bf4..2b2c7797 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -149,7 +149,7 @@ ${json}`); const PropValueUpper = value.toLocaleUpperCase("en-us"); if (upperlinksJsonString.indexOf(PropValueUpper) !== -1) { await warnAndCommentAsync( -`Initiative might already exist - the value of property \`${prop}\` (\`${value}\`) is already present in ${linkJsonFileName}: +`Initiative might already exist - the value of property \`${prop}\` (\`${value}\`) is already present in \`${linkJsonFileName}\`: \`\`\`json ${linksJsonString} \`\`\` From 5b0b45f8e028d4a5db6ba7bca6c2fc70193b8765 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 23:47:02 +0200 Subject: [PATCH 20/25] minot comment markdown fix --- scripts/generatePullRequestForNewInitiative.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index 2b2c7797..5615189a 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -64,9 +64,10 @@ module.exports = async ({github, context}) => { async function warnAndCommentAsync(warning, exception, json) { console.warn(`${warning} [${exception}]`); await createCommentAsync(`**WARNING**: ${warning} -see GitHub Action logs for more details: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId} + Automatic PR will NOT be generated -${json}`); +${json} +See GitHub Action logs for more details: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`); } function executeShellCommand(cmd, args) { @@ -149,11 +150,12 @@ ${json}`); const PropValueUpper = value.toLocaleUpperCase("en-us"); if (upperlinksJsonString.indexOf(PropValueUpper) !== -1) { await warnAndCommentAsync( -`Initiative might already exist - the value of property \`${prop}\` (\`${value}\`) is already present in \`${linkJsonFileName}\`: +`Initiative might already exist! +The value of property \`${prop}\` (\`${value}\`) is already present in \`${linkJsonFileName}\`: \`\`\`json ${linksJsonString} \`\`\` -If you are certain this is a mistake and that the initiative doesn't already exist, edit the issue's title so that it starts with \`[NEW-INITIATIVE-FORCE-PR]:\``, +**If this is a mistake and it doesn't already exist:** edit the issue's title so that it starts with **\`[NEW-INITIATIVE-FORCE-PR]:\`**`, "Suspected existing initiative", markdownNewInitiativeJson) return true; From bf95e3ac6185af057086c7e2d03dedf92505b098 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 00:09:18 +0200 Subject: [PATCH 21/25] Use glob needed for node 16 used by gitub-script --- package-lock.json | 313 +++++++++++++++--- package.json | 1 + .../generatePullRequestForNewInitiative.js | 17 +- 3 files changed, 282 insertions(+), 49 deletions(-) diff --git a/package-lock.json b/package-lock.json index 055d266b..32fb85dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "@next/mdx": "^13.5.6", "@radix-ui/react-portal": "^1.0.4", "@types/mdx": "^2.0.9", + "glob": "^10.3.10", "gray-matter": "^4.0.3", "lunr": "^2.3.9", "lunr-languages": "^1.14.0", @@ -650,6 +651,47 @@ "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", "dev": true }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", @@ -1365,6 +1407,26 @@ "glob": "7.1.7" } }, + "node_modules/@next/eslint-plugin-next/node_modules/glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@next/mdx": { "version": "13.5.6", "resolved": "https://registry.npmjs.org/@next/mdx/-/mdx-13.5.6.tgz", @@ -1720,6 +1782,15 @@ "@octokit/openapi-types": "^19.0.2" } }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "optional": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@radix-ui/react-compose-refs": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@radix-ui/react-compose-refs/-/react-compose-refs-1.0.1.tgz", @@ -2327,7 +2398,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, "engines": { "node": ">=8" } @@ -2336,7 +2406,6 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -2619,8 +2688,7 @@ "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, "node_modules/before-after-hook": { "version": "2.2.3", @@ -2907,7 +2975,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, "dependencies": { "color-name": "~1.1.4" }, @@ -2918,8 +2985,7 @@ "node_modules/color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, "node_modules/colorette": { "version": "2.0.20", @@ -2955,7 +3021,6 @@ "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -3126,8 +3191,7 @@ "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==" }, "node_modules/electron-to-chromium": { "version": "1.4.563", @@ -3137,8 +3201,7 @@ "node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==" }, "node_modules/enhanced-resolve": { "version": "5.15.0", @@ -3993,6 +4056,21 @@ "is-callable": "^1.1.3" } }, + "node_modules/foreground-child": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", + "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/fraction.js": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz", @@ -4118,20 +4196,21 @@ } }, "node_modules/glob": { - "version": "7.1.7", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", - "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", - "dev": true, + "version": "10.3.10", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", + "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "foreground-child": "^3.1.0", + "jackspeak": "^2.3.5", + "minimatch": "^9.0.1", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", + "path-scurry": "^1.10.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" }, "engines": { - "node": "*" + "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -4154,6 +4233,28 @@ "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==" }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/globals": { "version": "13.23.0", "resolved": "https://registry.npmjs.org/globals/-/globals-13.23.0.tgz", @@ -5113,8 +5214,7 @@ "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, "node_modules/iterator.prototype": { "version": "1.1.2", @@ -5129,6 +5229,23 @@ "set-function-name": "^2.0.1" } }, + "node_modules/jackspeak": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", + "integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, "node_modules/javascript-natural-sort": { "version": "0.7.1", "resolved": "https://registry.npmjs.org/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz", @@ -9345,6 +9462,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/minipass": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", + "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, "node_modules/mixpanel-browser": { "version": "2.47.0", "resolved": "https://registry.npmjs.org/mixpanel-browser/-/mixpanel-browser-2.47.0.tgz", @@ -9764,7 +9889,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, "engines": { "node": ">=8" } @@ -9775,6 +9899,29 @@ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, + "node_modules/path-scurry": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.1.tgz", + "integrity": "sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==", + "dependencies": { + "lru-cache": "^9.1.1 || ^10.0.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-scurry/node_modules/lru-cache": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.1.tgz", + "integrity": "sha512-IJ4uwUTi2qCccrioU6g9g/5rvvVl13bsdczUUcqbciD9iLr095yj8DQKdObriEvuNSx325N1rV1O0sJFszx75g==", + "engines": { + "node": "14 || >=16.14" + } + }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -10589,6 +10736,26 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rimraf/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -10787,7 +10954,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, "dependencies": { "shebang-regex": "^3.0.0" }, @@ -10799,7 +10965,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, "engines": { "node": ">=8" } @@ -10822,7 +10987,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, "engines": { "node": ">=14" }, @@ -10938,7 +11102,6 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "dev": true, "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", @@ -10951,11 +11114,37 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/string-width-cjs/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, "node_modules/string-width/node_modules/ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "dev": true, "engines": { "node": ">=12" }, @@ -10967,7 +11156,6 @@ "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, "dependencies": { "ansi-regex": "^6.0.1" }, @@ -11060,7 +11248,18 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dependencies": { "ansi-regex": "^5.0.1" }, @@ -11904,7 +12103,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, "dependencies": { "isexe": "^2.0.0" }, @@ -11995,7 +12193,6 @@ "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "dev": true, "dependencies": { "ansi-styles": "^6.1.0", "string-width": "^5.0.1", @@ -12008,11 +12205,53 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/wrap-ansi-cjs/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/wrap-ansi/node_modules/ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "dev": true, "engines": { "node": ">=12" }, @@ -12024,7 +12263,6 @@ "version": "6.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "dev": true, "engines": { "node": ">=12" }, @@ -12036,7 +12274,6 @@ "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, "dependencies": { "ansi-regex": "^6.0.1" }, diff --git a/package.json b/package.json index a9ad9369..8367e86a 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "@next/mdx": "^13.5.6", "@radix-ui/react-portal": "^1.0.4", "@types/mdx": "^2.0.9", + "glob": "^10.3.10", "gray-matter": "^4.0.3", "lunr": "^2.3.9", "lunr-languages": "^1.14.0", diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index 5615189a..c829aca0 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -1,8 +1,8 @@ module.exports = async ({github, context}) => { - const fs = require('fs').promises; - const path = require('path'); - const cp = require('child_process'); + const fs = require("fs").promises; + const glob = require("glob"); + const cp = require("child_process"); function tryExtractJson(text, jsonStartMarker, jsonEndMarker) { console.log(`Attempting to extract JSON with start marker "${jsonStartMarker}" and end marker "${jsonEndMarker}"` ); @@ -127,17 +127,12 @@ See GitHub Action logs for more details: ${context.serverUrl}/${context.repo.own console.log("Attempting to detect already-existing initiative"); const linksFolder = `${process.env.GITHUB_WORKSPACE}/_data/links`; - const linkJsonFileNames = await fs.readdir(linksFolder, { recursive: true }); + const linkJsonFileNames = await glob.glob(linksFolder + "/**/*.json"); for (const linkJsonFileName of linkJsonFileNames) { - if (path.extname(linkJsonFileName).toLocaleUpperCase("en-us") !== ".JSON") { - console.log(`Skipping non-JSON file: ${linkJsonFileName}`); - continue; - } - const linkJsonFileNameAbsolute = `${linksFolder}/${linkJsonFileName}` - console.log(`processing links file: ${linkJsonFileNameAbsolute}`); - const linksJsonString = await fs.readFile(linkJsonFileNameAbsolute, "utf8"); + console.log(`processing links file: ${linkJsonFileName}`); + const linksJsonString = await fs.readFile(linkJsonFileName, "utf8"); const upperlinksJsonString = linksJsonString.toLocaleUpperCase("en-us"); for (const prop in newInitiativeJson) { From 2f75b8c4b7595407cbef1ef142322fff75e57070 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 00:28:04 +0200 Subject: [PATCH 22/25] glob - case-insensitive JSON extension pattern --- scripts/generatePullRequestForNewInitiative.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index c829aca0..cbb89f06 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -127,7 +127,7 @@ See GitHub Action logs for more details: ${context.serverUrl}/${context.repo.own console.log("Attempting to detect already-existing initiative"); const linksFolder = `${process.env.GITHUB_WORKSPACE}/_data/links`; - const linkJsonFileNames = await glob.glob(linksFolder + "/**/*.json"); + const linkJsonFileNames = await glob.glob(linksFolder + "/**/*.json", { nocase: true }); for (const linkJsonFileName of linkJsonFileNames) { From 725ceec318b164d0f9c52bff9b4dadeae65c1622 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 01:11:24 +0200 Subject: [PATCH 23/25] replace glob with custom recursive iterator passing packages to github-scripts is too much overhead --- package-lock.json | 271 ++---------------- package.json | 1 - .../generatePullRequestForNewInitiative.js | 22 +- 3 files changed, 45 insertions(+), 249 deletions(-) diff --git a/package-lock.json b/package-lock.json index 32fb85dd..4e79fdfc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,6 @@ "@next/mdx": "^13.5.6", "@radix-ui/react-portal": "^1.0.4", "@types/mdx": "^2.0.9", - "glob": "^10.3.10", "gray-matter": "^4.0.3", "lunr": "^2.3.9", "lunr-languages": "^1.14.0", @@ -651,47 +650,6 @@ "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", "dev": true }, - "node_modules/@isaacs/cliui": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", - "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", - "dependencies": { - "string-width": "^5.1.2", - "string-width-cjs": "npm:string-width@^4.2.0", - "strip-ansi": "^7.0.1", - "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", - "wrap-ansi": "^8.1.0", - "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@isaacs/cliui/node_modules/ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/@isaacs/cliui/node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", @@ -1782,15 +1740,6 @@ "@octokit/openapi-types": "^19.0.2" } }, - "node_modules/@pkgjs/parseargs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", - "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", - "optional": true, - "engines": { - "node": ">=14" - } - }, "node_modules/@radix-ui/react-compose-refs": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@radix-ui/react-compose-refs/-/react-compose-refs-1.0.1.tgz", @@ -2398,6 +2347,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, "engines": { "node": ">=8" } @@ -2406,6 +2356,7 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -2688,7 +2639,8 @@ "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true }, "node_modules/before-after-hook": { "version": "2.2.3", @@ -2975,6 +2927,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, "dependencies": { "color-name": "~1.1.4" }, @@ -2985,7 +2938,8 @@ "node_modules/color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true }, "node_modules/colorette": { "version": "2.0.20", @@ -3021,6 +2975,7 @@ "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -3191,7 +3146,8 @@ "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==" + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true }, "node_modules/electron-to-chromium": { "version": "1.4.563", @@ -3201,7 +3157,8 @@ "node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==" + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true }, "node_modules/enhanced-resolve": { "version": "5.15.0", @@ -4056,21 +4013,6 @@ "is-callable": "^1.1.3" } }, - "node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/fraction.js": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz", @@ -4195,27 +4137,6 @@ "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" } }, - "node_modules/glob": { - "version": "10.3.10", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", - "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^2.3.5", - "minimatch": "^9.0.1", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", - "path-scurry": "^1.10.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/glob-parent": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", @@ -4233,28 +4154,6 @@ "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==" }, - "node_modules/glob/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/glob/node_modules/minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/globals": { "version": "13.23.0", "resolved": "https://registry.npmjs.org/globals/-/globals-13.23.0.tgz", @@ -5214,7 +5113,8 @@ "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true }, "node_modules/iterator.prototype": { "version": "1.1.2", @@ -5229,23 +5129,6 @@ "set-function-name": "^2.0.1" } }, - "node_modules/jackspeak": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", - "integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==", - "dependencies": { - "@isaacs/cliui": "^8.0.2" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - }, - "optionalDependencies": { - "@pkgjs/parseargs": "^0.11.0" - } - }, "node_modules/javascript-natural-sort": { "version": "0.7.1", "resolved": "https://registry.npmjs.org/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz", @@ -9462,14 +9345,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/minipass": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", - "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, "node_modules/mixpanel-browser": { "version": "2.47.0", "resolved": "https://registry.npmjs.org/mixpanel-browser/-/mixpanel-browser-2.47.0.tgz", @@ -9889,6 +9764,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, "engines": { "node": ">=8" } @@ -9899,29 +9775,6 @@ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, - "node_modules/path-scurry": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.1.tgz", - "integrity": "sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==", - "dependencies": { - "lru-cache": "^9.1.1 || ^10.0.0", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/path-scurry/node_modules/lru-cache": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.1.tgz", - "integrity": "sha512-IJ4uwUTi2qCccrioU6g9g/5rvvVl13bsdczUUcqbciD9iLr095yj8DQKdObriEvuNSx325N1rV1O0sJFszx75g==", - "engines": { - "node": "14 || >=16.14" - } - }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -10954,6 +10807,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, "dependencies": { "shebang-regex": "^3.0.0" }, @@ -10965,6 +10819,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, "engines": { "node": ">=8" } @@ -10987,6 +10842,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, "engines": { "node": ">=14" }, @@ -11102,6 +10958,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", @@ -11114,37 +10971,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/string-width-cjs": { - "name": "string-width", - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width-cjs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" - }, - "node_modules/string-width-cjs/node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "engines": { - "node": ">=8" - } - }, "node_modules/string-width/node_modules/ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, "engines": { "node": ">=12" }, @@ -11156,6 +10987,7 @@ "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, "dependencies": { "ansi-regex": "^6.0.1" }, @@ -11248,18 +11080,7 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi-cjs": { - "name": "strip-ansi", - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, "dependencies": { "ansi-regex": "^5.0.1" }, @@ -12103,6 +11924,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, "dependencies": { "isexe": "^2.0.0" }, @@ -12193,6 +12015,7 @@ "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, "dependencies": { "ansi-styles": "^6.1.0", "string-width": "^5.0.1", @@ -12205,53 +12028,11 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/wrap-ansi-cjs": { - "name": "wrap-ansi", - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" - }, - "node_modules/wrap-ansi-cjs/node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/wrap-ansi/node_modules/ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, "engines": { "node": ">=12" }, @@ -12263,6 +12044,7 @@ "version": "6.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, "engines": { "node": ">=12" }, @@ -12274,6 +12056,7 @@ "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, "dependencies": { "ansi-regex": "^6.0.1" }, diff --git a/package.json b/package.json index 8367e86a..a9ad9369 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "@next/mdx": "^13.5.6", "@radix-ui/react-portal": "^1.0.4", "@types/mdx": "^2.0.9", - "glob": "^10.3.10", "gray-matter": "^4.0.3", "lunr": "^2.3.9", "lunr-languages": "^1.14.0", diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index cbb89f06..412f9498 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -1,7 +1,7 @@ module.exports = async ({github, context}) => { const fs = require("fs").promises; - const glob = require("glob"); + const path = require("path"); const cp = require("child_process"); function tryExtractJson(text, jsonStartMarker, jsonEndMarker) { @@ -123,13 +123,27 @@ See GitHub Action logs for more details: ${context.serverUrl}/${context.repo.own } } + async function* readdirRecursiveAsync(dir, ext) { + const upperExtension = ext.toLocaleUpperCase("en-us"); + + const dirents = await fs.readdir(dir, { withFileTypes: true }); + for (const dirent of dirents) { + const absolutePath = path.resolve(dir, dirent.name); + + if (dirent.isFile && (path.extname(absolutePath).toLocaleUpperCase("en-us") === upperExtension)) { + yield absolutePath; + } + else if (dirent.isDirectory()) { + yield* await readdirRecursiveAsync(absolutePath, ext) + } + } + } + async function detectExistingInitiativeAsync(newInitiativeJson) { console.log("Attempting to detect already-existing initiative"); const linksFolder = `${process.env.GITHUB_WORKSPACE}/_data/links`; - const linkJsonFileNames = await glob.glob(linksFolder + "/**/*.json", { nocase: true }); - - for (const linkJsonFileName of linkJsonFileNames) { + for await (const linkJsonFileName of readdirRecursiveAsync(linksFolder, ".json")) { console.log(`processing links file: ${linkJsonFileName}`); const linksJsonString = await fs.readFile(linkJsonFileName, "utf8"); From 71b48527739ff5f0a52724b9d38b026ae13e2747 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 01:22:30 +0200 Subject: [PATCH 24/25] shell exec - minor logging fix --- scripts/generatePullRequestForNewInitiative.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generatePullRequestForNewInitiative.js b/scripts/generatePullRequestForNewInitiative.js index 412f9498..c4b8dd3f 100644 --- a/scripts/generatePullRequestForNewInitiative.js +++ b/scripts/generatePullRequestForNewInitiative.js @@ -84,7 +84,7 @@ See GitHub Action logs for more details: ${context.serverUrl}/${context.repo.own throw e; } - console.log(`Command executed successfully with output: ${stdout}`); + console.log(`Command executed successfully with stdout: ${stdout}`); } function executeGitCommand(args) { From 02257828dfb65b50534d7ee2dba758ff244c013f Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 01:33:51 +0200 Subject: [PATCH 25/25] fix issue author name isn't passed, use login --- .github/workflows/initiative-auto-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/initiative-auto-pr.yml b/.github/workflows/initiative-auto-pr.yml index 9542ba48..22bca608 100644 --- a/.github/workflows/initiative-auto-pr.yml +++ b/.github/workflows/initiative-auto-pr.yml @@ -41,7 +41,7 @@ jobs: - name: Generate PR uses: actions/github-script@v6 env: - ISSUE_AUTHOR: ${{ github.event.issue.user.name }} + ISSUE_AUTHOR: ${{ github.event.issue.user.login }} ISSUE_TITLE: ${{ github.event.issue.title }} with: script: |