2024-01-05 16:59:58 +03:00
|
|
|
import { danger, markdown, schedule, warn } from 'danger';
|
|
|
|
import todos from 'danger-plugin-todos';
|
2023-11-13 18:09:59 +03:00
|
|
|
|
2023-11-24 17:20:07 +03:00
|
|
|
function getMdSection(category: string, message: string) {
|
|
|
|
return `# ${category} <br>${message}`;
|
|
|
|
}
|
2023-11-13 18:09:59 +03:00
|
|
|
|
|
|
|
// Check if package.json was changed, but not yarn.lock
|
2024-01-05 16:59:58 +03:00
|
|
|
const packageChanged = danger.git.modified_files.find((x) =>
|
|
|
|
x.includes('package.json'),
|
|
|
|
);
|
|
|
|
const lockfileChanged = danger.git.modified_files.find((x) =>
|
|
|
|
x.includes('yarn.lock'),
|
|
|
|
);
|
2023-11-13 16:10:11 +03:00
|
|
|
if (packageChanged && !lockfileChanged) {
|
2024-01-05 16:59:58 +03:00
|
|
|
const message = 'Changes were made to package.json, but not to yarn.lock';
|
|
|
|
const idea = 'Perhaps you need to run `yarn install`?';
|
2023-11-13 16:10:11 +03:00
|
|
|
warn(`${message} - <i>${idea}</i>`);
|
2023-11-13 18:09:59 +03:00
|
|
|
}
|
|
|
|
|
2024-01-08 12:42:03 +03:00
|
|
|
// Check if .env.example was changed, but not environment variable documentation
|
2023-11-24 17:20:07 +03:00
|
|
|
const envChanged =
|
2024-01-05 16:59:58 +03:00
|
|
|
danger.git.modified_files.find((x) => x.includes('.env.example')) ||
|
|
|
|
danger.git.modified_files.find((x) => x.includes('environment.service.ts'));
|
2023-11-24 17:20:07 +03:00
|
|
|
const envDocsChanged = danger.git.modified_files.includes(
|
2024-01-08 12:42:03 +03:00
|
|
|
'environment-variables.mdx',
|
2023-11-24 17:20:07 +03:00
|
|
|
);
|
2023-11-14 12:41:09 +03:00
|
|
|
if (envChanged && !envDocsChanged) {
|
2023-11-24 17:20:07 +03:00
|
|
|
const message =
|
2024-01-08 12:42:03 +03:00
|
|
|
'Changes were made to the environment variables, but not to the documentation';
|
2023-11-24 17:20:07 +03:00
|
|
|
const idea =
|
2024-01-05 16:59:58 +03:00
|
|
|
'Please review your changes and check if a change needs to be documented!';
|
2023-11-14 12:41:09 +03:00
|
|
|
warn(`${message} - <i>${idea}</i>`);
|
|
|
|
}
|
|
|
|
|
2023-11-13 18:09:59 +03:00
|
|
|
// CLA alert if first time contributor
|
2024-01-05 16:59:58 +03:00
|
|
|
if (
|
|
|
|
danger.github &&
|
|
|
|
danger.github.pr &&
|
|
|
|
(danger.github.pr.author_association === 'FIRST_TIME_CONTRIBUTOR' ||
|
|
|
|
danger.github.pr.author_association === 'NONE')
|
2023-11-24 17:20:07 +03:00
|
|
|
) {
|
2024-01-05 16:59:58 +03:00
|
|
|
markdown(
|
|
|
|
getMdSection(
|
|
|
|
'CLA',
|
|
|
|
`
|
2023-11-24 17:20:07 +03:00
|
|
|
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.
|
2024-01-05 16:59:58 +03:00
|
|
|
Thank you for your understanding.`,
|
|
|
|
),
|
|
|
|
);
|
2023-11-24 17:20:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODOS / Fixme
|
|
|
|
schedule(todos());
|