From e6744e7ce1b08621354b9fb7963119a40ac7c24f Mon Sep 17 00:00:00 2001 From: brendanlaschke Date: Fri, 24 Nov 2023 15:20:07 +0100 Subject: [PATCH] Danger markdown message & todo comments (#2698) - markdown message & todo comments --- packages/twenty-utils/dangerfile.ts | 49 +++++++++++++++++++---------- packages/twenty-utils/package.json | 1 + packages/twenty-utils/yarn.lock | 12 +++++++ 3 files changed, 45 insertions(+), 17 deletions(-) diff --git a/packages/twenty-utils/dangerfile.ts b/packages/twenty-utils/dangerfile.ts index 3ab1814ff..ac6b0d41a 100644 --- a/packages/twenty-utils/dangerfile.ts +++ b/packages/twenty-utils/dangerfile.ts @@ -1,30 +1,45 @@ -import {message, danger, warn} from "danger" - +import { danger, warn, markdown, schedule } from "danger"; +import todos from "danger-plugin-todos"; +function getMdSection(category: string, message: string) { + return `# ${category}
${message}`; +} // Check if package.json was changed, but not yarn.lock -const packageChanged = danger.git.modified_files.includes('package.json'); -const lockfileChanged = danger.git.modified_files.includes('yarn.lock'); +const packageChanged = danger.git.modified_files.includes("package.json"); +const lockfileChanged = danger.git.modified_files.includes("yarn.lock"); if (packageChanged && !lockfileChanged) { - const message = 'Changes were made to package.json, but not to yarn.lock'; - const idea = 'Perhaps you need to run `yarn install`?'; + const message = "Changes were made to package.json, but not to yarn.lock"; + const idea = "Perhaps you need to run `yarn install`?"; warn(`${message} - ${idea}`); } // Check if .env.example was changed, but not enviroment variable documentation -const envChanged = danger.git.modified_files.includes('.env.example') || danger.git.modified_files.includes('environment.service.ts'); -const envDocsChanged = danger.git.modified_files.includes('enviroment-variables.mdx'); +const envChanged = + danger.git.modified_files.includes(".env.example") || + danger.git.modified_files.includes("environment.service.ts"); +const envDocsChanged = danger.git.modified_files.includes( + "enviroment-variables.mdx" +); if (envChanged && !envDocsChanged) { - const message = 'Changes were made to the enviroment variables, but not to the documentation'; - const idea = 'Please review your changes and check if a change needs to be documented!'; + const message = + "Changes were made to the enviroment variables, but not to the documentation"; + const idea = + "Please review your changes and check if a change needs to be documented!"; warn(`${message} - ${idea}`); } - // CLA alert if first time contributor -if(danger.github.pr.author_association === 'FIRST_TIME_CONTRIBUTOR' || danger.github.pr.author_association === 'NONE') { - message(`Hello there and welcome to our project!`) - message(`By submitting your Pull Request, you acknowledge that you agree with the terms of our [Contributor License Agreement](https://github.com/twentyhq/twenty/blob/main/.github/CLA.md).`) - message(`Although we don't have a dedicated legal counsel, having this kind of agreement can protect us from potential legal issues or patent trolls.`) - message(`Thank you for your understanding.`) -} \ No newline at end of file +if ( + danger.github.pr.author_association === "FIRST_TIME_CONTRIBUTOR" || + danger.github.pr.author_association === "NONE" +) { + markdown(getMdSection('CLA', ` +Hello there and welcome to our project! +By submitting your Pull Request, you acknowledge that you agree with the terms of our [Contributor License Agreement](https://github.com/twentyhq/twenty/blob/main/.github/CLA.md). +Although we don't have a dedicated legal counsel, having this kind of agreement can protect us from potential legal issues or patent trolls. +Thank you for your understanding.`)) +} + +// TODOS / Fixme +schedule(todos()); diff --git a/packages/twenty-utils/package.json b/packages/twenty-utils/package.json index 8f56ae976..40c719b67 100644 --- a/packages/twenty-utils/package.json +++ b/packages/twenty-utils/package.json @@ -5,6 +5,7 @@ "release": "node release.js" }, "dependencies": { + "danger-plugin-todos": "^1.3.1", "semver": "^7.5.4" }, "devDependencies": { diff --git a/packages/twenty-utils/yarn.lock b/packages/twenty-utils/yarn.lock index f6288f5b3..5f1ace6a7 100644 --- a/packages/twenty-utils/yarn.lock +++ b/packages/twenty-utils/yarn.lock @@ -308,6 +308,13 @@ core-js@^3.8.2: resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.33.2.tgz#312bbf6996a3a517c04c99b9909cdd27138d1ceb" integrity sha512-XeBzWI6QL3nJQiHmdzbAOiMYqjrb7hwU7A39Qhvd/POSa/t9E1AeZyEZx3fNvp/vtM8zXwhoL0FsiS0hD0pruQ== +danger-plugin-todos@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/danger-plugin-todos/-/danger-plugin-todos-1.3.1.tgz#460201ac901ba24eade7c10d51f0a19c5c80612d" + integrity sha512-M8/0oo5DV6EyjthIia0ne+yleoZBgO/+lcyH/YDVyY4fKFeiZJMu8TnPQNZ0pt7WeHnbyxImXphsDESHWa+jDA== + dependencies: + lodash "^4.17.15" + danger@^11.3.0: version "11.3.0" resolved "https://registry.yarnpkg.com/danger/-/danger-11.3.0.tgz#5a2cbe3e45f367ed0899156c480c7d7e40d90b3d" @@ -740,6 +747,11 @@ lodash.once@^4.0.0: resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac" integrity sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg== +lodash@^4.17.15: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== + lowercase-keys@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479"