@toptal/davinci-ci 3.0.1-alpha-fix-davinci-metric-61af05c8.9 → 3.0.1-alpha-chore-improve-packages-building-23e03d25.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/commands/danger.d.ts +11 -0
  2. package/dist/commands/danger.js +64 -0
  3. package/dist/configs/danger/conventional-commits/dangerfile.d.ts +1 -0
  4. package/dist/configs/danger/conventional-commits/dangerfile.js +12 -0
  5. package/dist/configs/danger/conventional-commits/plugins/conventional-commits/index.d.ts +1 -0
  6. package/dist/configs/danger/conventional-commits/plugins/conventional-commits/index.js +99 -0
  7. package/dist/configs/danger/conventional-commits/plugins/conventional-pr-title/index.d.ts +1 -0
  8. package/dist/configs/danger/conventional-commits/plugins/conventional-pr-title/index.js +94 -0
  9. package/dist/configs/danger/conventional-commits/plugins/index.d.ts +3 -0
  10. package/dist/configs/danger/conventional-commits/plugins/index.js +7 -0
  11. package/dist/configs/danger/plugins/empty-assignee.d.ts +1 -0
  12. package/dist/configs/danger/plugins/empty-assignee.js +18 -0
  13. package/dist/configs/danger/toptal/config.d.ts +7 -0
  14. package/dist/configs/danger/toptal/config.js +27 -0
  15. package/dist/configs/danger/toptal/dangerfile.d.ts +1 -0
  16. package/dist/configs/danger/toptal/dangerfile.js +12 -0
  17. package/dist/configs/danger/toptal/plugins/index.d.ts +3 -0
  18. package/dist/configs/danger/toptal/plugins/index.js +7 -0
  19. package/dist/configs/danger/toptal/plugins/toptal-commits/index.d.ts +1 -0
  20. package/dist/configs/danger/toptal/plugins/toptal-commits/index.js +51 -0
  21. package/dist/configs/danger/toptal/plugins/toptal-pr-title/index.d.ts +1 -0
  22. package/dist/configs/danger/toptal/plugins/toptal-pr-title/index.js +45 -0
  23. package/dist/index.d.ts +24 -0
  24. package/dist/index.js +17 -0
  25. package/package.json +9 -6
  26. package/CHANGELOG.md +0 -978
  27. package/src/commands/danger.js +0 -67
  28. package/src/configs/danger/conventional-commits/dangerfile.js +0 -17
  29. package/src/configs/danger/conventional-commits/plugins/conventional-commits/index.js +0 -52
  30. package/src/configs/danger/conventional-commits/plugins/conventional-pr-title/index.js +0 -53
  31. package/src/configs/danger/conventional-commits/plugins/index.js +0 -7
  32. package/src/configs/danger/plugins/empty-assignee.js +0 -24
  33. package/src/configs/danger/toptal/config.js +0 -30
  34. package/src/configs/danger/toptal/dangerfile.js +0 -17
  35. package/src/configs/danger/toptal/plugins/index.js +0 -7
  36. package/src/configs/danger/toptal/plugins/toptal-commits/index.js +0 -73
  37. package/src/configs/danger/toptal/plugins/toptal-pr-title/index.js +0 -62
  38. package/src/configs/docker/Dockerfile +0 -30
  39. package/src/configs/docker/Dockerfile.gha-deploy +0 -33
  40. package/src/configs/docker/Dockerfile.release +0 -28
  41. package/src/configs/docker/Dockerfile.storybook +0 -20
  42. package/src/configs/docker/env-runtime.entrypoint.sh +0 -47
  43. package/src/configs/docker/nginx-vhost-storybook.conf +0 -20
  44. package/src/configs/docker/nginx-vhost.conf +0 -18
  45. package/src/configs/jobs/build-image/Jenkinsfile +0 -142
  46. package/src/configs/jobs/build-image/config.xml +0 -119
  47. package/src/configs/jobs/build-release-image/Jenkinsfile +0 -154
  48. package/src/configs/jobs/build-release-image/config.xml +0 -102
  49. package/src/configs/jobs/consumer-contracts-verify/Jenkinsfile +0 -117
  50. package/src/configs/jobs/consumer-contracts-verify/config.xml +0 -114
  51. package/src/configs/jobs/deploy/config.xml +0 -107
  52. package/src/configs/jobs/deploy-helm-run/Jenkinsfile +0 -159
  53. package/src/configs/jobs/deploy-helm-run/config.xml +0 -107
  54. package/src/configs/jobs/deploy-helm-run-trigger/Jenkinsfile +0 -200
  55. package/src/configs/jobs/master-main/Jenkinsfile +0 -460
  56. package/src/configs/jobs/master-main/config.xml +0 -119
  57. package/src/configs/jobs/pr-tests/Jenkinsfile +0 -407
  58. package/src/configs/jobs/pr-tests/config.xml +0 -134
  59. package/src/configs/jobs/publish-alpha-package/Jenkinsfile +0 -189
  60. package/src/configs/jobs/publish-alpha-package/config.xml +0 -136
  61. package/src/configs/jobs/temploy-helm-run/Jenkinsfile +0 -141
  62. package/src/configs/jobs/temploy-helm-run/config.xml +0 -97
  63. package/src/index.js +0 -17
@@ -0,0 +1,11 @@
1
+ declare function dangerCommand({ options }: {
2
+ options: any;
3
+ }): void;
4
+ declare const commandOptions: {
5
+ label: string;
6
+ name: string;
7
+ }[];
8
+ export declare const allowUnknownOptions: boolean;
9
+ export declare const command: string;
10
+ export declare const description: string;
11
+ export { dangerCommand as action, commandOptions as options };
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
+ if (ar || !(i in from)) {
16
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
+ ar[i] = from[i];
18
+ }
19
+ }
20
+ return to.concat(ar || Array.prototype.slice.call(from));
21
+ };
22
+ var _a = require('@toptal/davinci-cli-shared'), davinciProjectConfig = _a.davinciProjectConfig, runSync = _a.runSync, print = _a.print, convertToCLIParameters = _a.convertToCLIParameters, files = _a.files;
23
+ var commandOptions = [
24
+ {
25
+ label: 'check only, without fixing the code',
26
+ name: '--check',
27
+ },
28
+ {
29
+ label: 'checks commit message quality locally',
30
+ name: '--local',
31
+ },
32
+ {
33
+ label: 'specify custom danger file',
34
+ name: '--dangerfile <dangerfile>',
35
+ },
36
+ ];
37
+ var dangerCommand = function (_a) {
38
+ var options = _a.options;
39
+ print.green('Running danger check...');
40
+ var local = options.local, dangerfile = options.dangerfile, rest = __rest(options, ["local", "dangerfile"]);
41
+ var conventionalCommitsDangerfilePath = files.getPackageFilePath('@toptal/davinci-ci', 'src/configs/danger/conventional-commits/dangerfile.js');
42
+ var toptalCommitsDangerfilePath = files.getPackageFilePath('@toptal/davinci-ci', 'src/configs/danger/toptal/dangerfile.js');
43
+ var dangerfilePath = dangerfile;
44
+ if (!dangerfilePath) {
45
+ dangerfilePath = davinciProjectConfig.master.conventionalCommits
46
+ ? conventionalCommitsDangerfilePath
47
+ : toptalCommitsDangerfilePath;
48
+ }
49
+ runSync('yarn', __spreadArray([
50
+ 'danger',
51
+ local ? 'local' : 'ci',
52
+ local ? '--failOnErrors' : undefined,
53
+ '--dangerfile',
54
+ "".concat(dangerfilePath)
55
+ ], convertToCLIParameters(rest), true).filter(Boolean));
56
+ };
57
+ var dangerCommandCreator = {
58
+ action: dangerCommand,
59
+ allowUnknownOptions: true,
60
+ command: 'danger',
61
+ description: 'Run danger check',
62
+ options: commandOptions,
63
+ };
64
+ module.exports = dangerCommandCreator;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var schedule = require('danger').schedule;
3
+ var davinciProjectConfig = require('@toptal/davinci-cli-shared').davinciProjectConfig;
4
+ var conventionalCommits = require('./plugins/conventional-commits').conventionalCommits;
5
+ var conventionalPRTitle = require('./plugins/conventional-pr-title').conventionalPRTitle;
6
+ var checkAssigneeExist = require('../plugins/empty-assignee').checkAssigneeExist;
7
+ schedule(conventionalCommits);
8
+ schedule(conventionalPRTitle);
9
+ var requireAssignee = davinciProjectConfig.master.requireAssignee;
10
+ if (requireAssignee) {
11
+ schedule(checkAssigneeExist);
12
+ }
@@ -0,0 +1 @@
1
+ export function conventionalCommits(): Promise<void>;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
+ if (ar || !(i in from)) {
41
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
+ ar[i] = from[i];
43
+ }
44
+ }
45
+ return to.concat(ar || Array.prototype.slice.call(from));
46
+ };
47
+ /* globals danger, fail */
48
+ /* eslint-disable import/no-extraneous-dependencies */
49
+ var load = require('@commitlint/load').default;
50
+ var lint = require('@commitlint/lint').default;
51
+ /* eslint-enable */
52
+ var table = require('markdown-table');
53
+ var WHITELISTED_USERS = require('../../../toptal/config').WHITELISTED_USERS;
54
+ var conventionalCommits = function () { return __awaiter(void 0, void 0, void 0, function () {
55
+ var commits, _a, rules, parserPreset;
56
+ return __generator(this, function (_b) {
57
+ switch (_b.label) {
58
+ case 0:
59
+ if (danger.github &&
60
+ WHITELISTED_USERS.includes(danger.github.pr.user.login)) {
61
+ return [2 /*return*/];
62
+ }
63
+ commits = danger.git.commits;
64
+ return [4 /*yield*/, load({
65
+ extends: ['@commitlint/config-conventional'],
66
+ })];
67
+ case 1:
68
+ _a = _b.sent(), rules = _a.rules, parserPreset = _a.parserPreset;
69
+ commits.forEach(function (commit) { return __awaiter(void 0, void 0, void 0, function () {
70
+ var result, message;
71
+ return __generator(this, function (_a) {
72
+ switch (_a.label) {
73
+ case 0: return [4 /*yield*/, lint(commit.message, rules, parserPreset ? { parserOpts: parserPreset.parserOpts } : {})];
74
+ case 1:
75
+ result = _a.sent();
76
+ if (!result.valid) {
77
+ if (result.errors.length > 0) {
78
+ message = "The commit - ".concat(commit.sha.trim(), " doesn't conform the conventional commit guidelines. \n\n**Errors**:\n\n");
79
+ message += table(__spreadArray([
80
+ ['Message']
81
+ ], result.errors.map(function (error) { return [error.message]; }), true));
82
+ message +=
83
+ '\n\n💡 For a guidance on how to fix this problem please refer to [https://www.conventionalcommits.org](https://www.conventionalcommits.org)';
84
+ message +=
85
+ '\n\n💡 Or you can check our [documentation](https://github.com/toptal/picasso/blob/master/docs/contribution/github-workflow.md#general-commit-message-pattern)';
86
+ fail(message);
87
+ }
88
+ }
89
+ return [2 /*return*/];
90
+ }
91
+ });
92
+ }); });
93
+ return [2 /*return*/];
94
+ }
95
+ });
96
+ }); };
97
+ module.exports = {
98
+ conventionalCommits: conventionalCommits,
99
+ };
@@ -0,0 +1 @@
1
+ export function conventionalPRTitle(): Promise<void>;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
+ if (ar || !(i in from)) {
41
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
+ ar[i] = from[i];
43
+ }
44
+ }
45
+ return to.concat(ar || Array.prototype.slice.call(from));
46
+ };
47
+ /// <reference types="danger" />
48
+ /* globals danger, fail */
49
+ /* eslint-disable import/no-extraneous-dependencies */
50
+ var load = require('@commitlint/load').default;
51
+ var lint = require('@commitlint/lint').default;
52
+ /* eslint-enable */
53
+ var table = require('markdown-table');
54
+ var WHITELISTED_USERS = require('../../../toptal/config').WHITELISTED_USERS;
55
+ var conventionalPRTitle = function () { return __awaiter(void 0, void 0, void 0, function () {
56
+ var _a, rules, parserPreset, title, result, message;
57
+ return __generator(this, function (_b) {
58
+ switch (_b.label) {
59
+ case 0:
60
+ if (!danger.github) {
61
+ return [2 /*return*/];
62
+ }
63
+ if (WHITELISTED_USERS.includes(danger.github.pr.user.login)) {
64
+ return [2 /*return*/];
65
+ }
66
+ return [4 /*yield*/, load({
67
+ extends: ['@commitlint/config-conventional'],
68
+ })];
69
+ case 1:
70
+ _a = _b.sent(), rules = _a.rules, parserPreset = _a.parserPreset;
71
+ title = danger.github.pr.title;
72
+ return [4 /*yield*/, lint(title, rules, parserPreset ? { parserOpts: parserPreset.parserOpts } : {})];
73
+ case 2:
74
+ result = _b.sent();
75
+ if (!result.valid) {
76
+ if (result.errors.length > 0) {
77
+ message = "PR title doesn't conform the conventional commit guidelines. \n\n**Errors**:\n\n";
78
+ message += table(__spreadArray([
79
+ ['Message']
80
+ ], result.errors.map(function (error) { return [error.message]; }), true));
81
+ message +=
82
+ '\n\n💡 For a guidance on how to fix this problem please refer to [https://www.conventionalcommits.org](https://www.conventionalcommits.org)';
83
+ message +=
84
+ '\n\n💡 Or you can check our [documentation](https://github.com/toptal/picasso/blob/master/docs/contribution/github-workflow.md#general-commit-message-pattern)';
85
+ fail(message);
86
+ }
87
+ }
88
+ return [2 /*return*/];
89
+ }
90
+ });
91
+ }); };
92
+ module.exports = {
93
+ conventionalPRTitle: conventionalPRTitle,
94
+ };
@@ -0,0 +1,3 @@
1
+ import { conventionalCommits } from "./conventional-commits";
2
+ import { conventionalPRTitle } from "./conventional-pr-title";
3
+ export { conventionalCommits, conventionalPRTitle };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var conventionalCommits = require('./conventional-commits').conventionalCommits;
3
+ var conventionalPRTitle = require('./conventional-pr-title').conventionalPRTitle;
4
+ module.exports = {
5
+ conventionalCommits: conventionalCommits,
6
+ conventionalPRTitle: conventionalPRTitle,
7
+ };
@@ -0,0 +1 @@
1
+ export function checkAssigneeExist(): void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /// <reference types="danger" />
3
+ /* globals danger, fail */
4
+ var davinciProjectConfig = require('@toptal/davinci-cli-shared').davinciProjectConfig;
5
+ var _a = davinciProjectConfig.master.requireAssigneeWhiteList, requireAssigneeWhiteList = _a === void 0 ? [] : _a;
6
+ var WHITELISTED_USERS = requireAssigneeWhiteList;
7
+ var checkAssigneeExist = function () {
8
+ var isLocalRun = !danger.github;
9
+ if (isLocalRun || WHITELISTED_USERS.includes(danger.github.pr.user.login)) {
10
+ return;
11
+ }
12
+ if (!danger.github.pr.assignee || danger.github.pr.assignees.length === 0) {
13
+ fail('Please assign someone to this PR before merging.');
14
+ }
15
+ };
16
+ module.exports = {
17
+ checkAssigneeExist: checkAssigneeExist,
18
+ };
@@ -0,0 +1,7 @@
1
+ export const DEFAULT_PR_TITLE_ERROR_MESSAGE: string;
2
+ export const ENGINEERING_DOCS_LINK: "https://toptal-core.atlassian.net/wiki/spaces/ENG/pages/210665897/Commit+Message+Quality";
3
+ export const MAX_COMMIT_LINE_LENGTH: 79;
4
+ export const MISSING_TICKET_CODE_ERROR_MESSAGE: "The pull request title is missing a Jira issue code. Correct format '[ASD-123] Add a cool feature'. If you're working without a Jira issue then add a 'no-jira' label to your pull request.";
5
+ export const VALID_COMMIT_TITLE_REGEX: RegExp;
6
+ export const VALID_PR_CODE_REGEX: RegExp;
7
+ export const WHITELISTED_USERS: string[];
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var WHITELISTED_USERS = [
3
+ 'dependabot-preview[bot]',
4
+ 'dependabot[bot]',
5
+ 'toptal-devbot',
6
+ ];
7
+ var VALID_PR_CODE_REGEX = /\[[A-Z]{1,5}-.*]\s/;
8
+ // Valid commit titles:
9
+ // "Regular commit message"
10
+ // "Commit with sentence. But does not end with a full-stop"
11
+ // "[FOO-1234] Commit with prefix"
12
+ // "[FOO] Prefix numbers can be omitted"
13
+ // "[FOO][BAR] Prefixes can couple"
14
+ var VALID_COMMIT_TITLE_REGEX = /^((\[[A-Z]+(-\d+)?])+ )?[A-Z]\w[^\n]*[^.]$/;
15
+ var MAX_COMMIT_LINE_LENGTH = 79;
16
+ var ENGINEERING_DOCS_LINK = 'https://toptal-core.atlassian.net/wiki/spaces/ENG/pages/210665897/Commit+Message+Quality';
17
+ var DEFAULT_PR_TITLE_ERROR_MESSAGE = "The pull request title doesn't conform to Toptal's engineering practices. For guidance on how to fix this problem please refer [here](".concat(ENGINEERING_DOCS_LINK, ")");
18
+ var MISSING_TICKET_CODE_ERROR_MESSAGE = "The pull request title is missing a Jira issue code. Correct format '[ASD-123] Add a cool feature'. If you're working without a Jira issue then add a 'no-jira' label to your pull request.";
19
+ module.exports = {
20
+ DEFAULT_PR_TITLE_ERROR_MESSAGE: DEFAULT_PR_TITLE_ERROR_MESSAGE,
21
+ ENGINEERING_DOCS_LINK: ENGINEERING_DOCS_LINK,
22
+ MAX_COMMIT_LINE_LENGTH: MAX_COMMIT_LINE_LENGTH,
23
+ MISSING_TICKET_CODE_ERROR_MESSAGE: MISSING_TICKET_CODE_ERROR_MESSAGE,
24
+ VALID_COMMIT_TITLE_REGEX: VALID_COMMIT_TITLE_REGEX,
25
+ VALID_PR_CODE_REGEX: VALID_PR_CODE_REGEX,
26
+ WHITELISTED_USERS: WHITELISTED_USERS,
27
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var schedule = require('danger').schedule;
3
+ var davinciProjectConfig = require('@toptal/davinci-cli-shared').davinciProjectConfig;
4
+ var toptalCommits = require('./plugins/toptal-commits').toptalCommits;
5
+ var toptalPRTitle = require('./plugins/toptal-pr-title').toptalPRTitle;
6
+ var checkAssigneeExist = require('../plugins/empty-assignee').checkAssigneeExist;
7
+ schedule(toptalCommits);
8
+ schedule(toptalPRTitle);
9
+ var requireAssignee = davinciProjectConfig.master.requireAssignee;
10
+ if (requireAssignee) {
11
+ schedule(checkAssigneeExist);
12
+ }
@@ -0,0 +1,3 @@
1
+ import { toptalCommits } from "./toptal-commits";
2
+ import { toptalPRTitle } from "./toptal-pr-title";
3
+ export { toptalCommits, toptalPRTitle };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var toptalCommits = require('./toptal-commits').toptalCommits;
3
+ var toptalPRTitle = require('./toptal-pr-title').toptalPRTitle;
4
+ module.exports = {
5
+ toptalCommits: toptalCommits,
6
+ toptalPRTitle: toptalPRTitle,
7
+ };
@@ -0,0 +1 @@
1
+ export function toptalCommits(): void;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ /* globals danger, fail */
12
+ var _a = require('../../config'), MAX_COMMIT_LINE_LENGTH = _a.MAX_COMMIT_LINE_LENGTH, VALID_COMMIT_TITLE_REGEX = _a.VALID_COMMIT_TITLE_REGEX, WHITELISTED_USERS = _a.WHITELISTED_USERS;
13
+ var validateCommitMessage = function (message) {
14
+ var errors = [];
15
+ var _a = message.split(/\n\n/), _b = _a[0], title = _b === void 0 ? '' : _b, _c = _a[1], body = _c === void 0 ? '' : _c;
16
+ var bodyLines = body.split(/\n/);
17
+ var isTitleFormatValid = VALID_COMMIT_TITLE_REGEX.test(title);
18
+ var isTitleLengthValid = title.length <= MAX_COMMIT_LINE_LENGTH;
19
+ var isBodyLinesLengthValid = bodyLines.every(function (line) { return line.length <= MAX_COMMIT_LINE_LENGTH; });
20
+ if (!isTitleFormatValid) {
21
+ errors.push("- format of commit title is not correct ([read more](https://toptal-core.atlassian.net/wiki/spaces/ENG/pages/210665897/Commit+Message+Quality)): \n - Title should start with capital letter\n - Title should not end with a full-stop (i.e .)\n\n Example of a valid commit title:\n - Regular commit message\n - [FOO-1234] Commit with prefix\n - [FOO][BAR] Coupled prefixes");
22
+ }
23
+ if (!isTitleLengthValid) {
24
+ errors.push("- title is too long (max ".concat(MAX_COMMIT_LINE_LENGTH, " characters)"));
25
+ }
26
+ if (!isBodyLinesLengthValid) {
27
+ errors.push("- body lines must not exceed ".concat(MAX_COMMIT_LINE_LENGTH, " characters"));
28
+ }
29
+ return errors;
30
+ };
31
+ var toptalCommits = function () {
32
+ if (danger.github &&
33
+ WHITELISTED_USERS.includes(danger.github.pr.user.login)) {
34
+ return;
35
+ }
36
+ var commits = danger.git.commits;
37
+ commits.forEach(function (commit) {
38
+ if (commit.author && WHITELISTED_USERS.includes(commit.author.name)) {
39
+ return;
40
+ }
41
+ var validationErrors = validateCommitMessage(commit.message);
42
+ if (validationErrors.length) {
43
+ fail(__spreadArray([
44
+ "Commit ".concat(commit.sha.trim(), " does not meet requirements of [Commit Message Quality](https://toptal-core.atlassian.net/wiki/spaces/ENG/pages/210665897/Commit+Message+Quality):")
45
+ ], validationErrors, true).join('\n'));
46
+ }
47
+ });
48
+ };
49
+ module.exports = {
50
+ toptalCommits: toptalCommits,
51
+ };
@@ -0,0 +1 @@
1
+ export function toptalPRTitle(): void;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ /* globals danger, fail */
3
+ var _a = require('../../config'), VALID_COMMIT_TITLE_REGEX = _a.VALID_COMMIT_TITLE_REGEX, VALID_PR_CODE_REGEX = _a.VALID_PR_CODE_REGEX, WHITELISTED_USERS = _a.WHITELISTED_USERS, DEFAULT_PR_TITLE_ERROR_MESSAGE = _a.DEFAULT_PR_TITLE_ERROR_MESSAGE, MISSING_TICKET_CODE_ERROR_MESSAGE = _a.MISSING_TICKET_CODE_ERROR_MESSAGE;
4
+ var getTicketCode = function (text) {
5
+ var ticketCode = text.match(VALID_PR_CODE_REGEX);
6
+ if (!ticketCode) {
7
+ return;
8
+ }
9
+ return ticketCode[0];
10
+ };
11
+ var showError = function (error) {
12
+ if (error === void 0) { error = DEFAULT_PR_TITLE_ERROR_MESSAGE; }
13
+ fail(error);
14
+ };
15
+ var toptalPRTitle = function () {
16
+ if (!danger.github) {
17
+ return;
18
+ }
19
+ if (WHITELISTED_USERS.includes(danger.github.pr.user.login)) {
20
+ return;
21
+ }
22
+ var title = danger.github.pr.title;
23
+ var labelNames = danger.github.issue.labels.map(function (_a) {
24
+ var name = _a.name;
25
+ return name;
26
+ });
27
+ var ticketCode = getTicketCode(title);
28
+ if (!ticketCode && !labelNames.includes('no-jira')) {
29
+ showError(MISSING_TICKET_CODE_ERROR_MESSAGE);
30
+ return;
31
+ }
32
+ var splitTitle = title.split(ticketCode);
33
+ if (!splitTitle.length) {
34
+ showError();
35
+ return;
36
+ }
37
+ var titleText = splitTitle[splitTitle.length - 1];
38
+ var isTitleFormatValid = VALID_COMMIT_TITLE_REGEX.test(titleText);
39
+ if (!isTitleFormatValid) {
40
+ showError();
41
+ }
42
+ };
43
+ module.exports = {
44
+ toptalPRTitle: toptalPRTitle,
45
+ };
@@ -0,0 +1,24 @@
1
+ export const commands: {
2
+ action: ({ options }: {
3
+ options: any;
4
+ }) => void;
5
+ allowUnknownOptions: boolean;
6
+ command: string;
7
+ description: string;
8
+ options: {
9
+ label: string;
10
+ name: string;
11
+ }[];
12
+ }[];
13
+ export namespace plugins {
14
+ namespace conventionalCommit {
15
+ const PRTitle: () => Promise<void>;
16
+ const commits: () => Promise<void>;
17
+ }
18
+ namespace toptal {
19
+ const PRTitle_1: () => void;
20
+ export { PRTitle_1 as PRTitle };
21
+ const commits_1: () => void;
22
+ export { commits_1 as commits };
23
+ }
24
+ }
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var dangerCommandCreator = require('./commands/danger');
3
+ var toptalPlugins = require('./configs/danger/toptal/plugins');
4
+ var conventionalCommitsPlugins = require('./configs/danger/conventional-commits/plugins');
5
+ module.exports = {
6
+ commands: [dangerCommandCreator],
7
+ plugins: {
8
+ conventionalCommit: {
9
+ PRTitle: conventionalCommitsPlugins.conventionalPRTitle,
10
+ commits: conventionalCommitsPlugins.conventionalCommits,
11
+ },
12
+ toptal: {
13
+ PRTitle: toptalPlugins.toptalPRTitle,
14
+ commits: toptalPlugins.toptalCommits,
15
+ },
16
+ },
17
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-ci",
3
- "version": "3.0.1-alpha-fix-davinci-metric-61af05c8.9+61af05c8",
3
+ "version": "3.0.1-alpha-chore-improve-packages-building-23e03d25.38+23e03d25",
4
4
  "description": "Continuos integrations tools for frontend projects",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -16,14 +16,17 @@
16
16
  "bin": {
17
17
  "davinci-ci": "./bin/davinci-ci.js"
18
18
  },
19
- "main": "./src/index.js",
19
+ "main": "./dist/index.js",
20
+ "files": [
21
+ "dist"
22
+ ],
20
23
  "repository": {
21
24
  "type": "git",
22
25
  "url": "git+https://github.com/toptal/davinci.git"
23
26
  },
24
27
  "scripts": {
25
- "build:package": "../../bin/build-package.js",
26
- "prepublishOnly": "../../bin/prepublish.js",
28
+ "build:package": "tsc --project tsconfig.json",
29
+ "prepublishOnly": "yarn build:package",
27
30
  "test": "echo \"Error: run tests from root\" && exit 1"
28
31
  },
29
32
  "bugs": {
@@ -32,9 +35,9 @@
32
35
  "dependencies": {
33
36
  "@commitlint/cli": "^17.0.2",
34
37
  "@commitlint/config-conventional": "^17.1.0",
35
- "@toptal/davinci-cli-shared": "1.10.1-alpha-fix-davinci-metric-61af05c8.23+61af05c8",
38
+ "@toptal/davinci-cli-shared": "1.10.1-alpha-chore-improve-packages-building-23e03d25.52+23e03d25",
36
39
  "danger": "^11.0.7",
37
40
  "markdown-table": "^2.0.0"
38
41
  },
39
- "gitHead": "61af05c830c4e56d8a3bd47b4b90fb2cd51c9eee"
42
+ "gitHead": "23e03d253cc3112ae20c258b8b42e97c3b6ff2e4"
40
43
  }