@toptal/davinci-ci 2.0.1 → 2.0.2-alpha-fx-2755-interactive-workflow-generation.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-ci",
3
- "version": "2.0.1",
3
+ "version": "2.0.2-alpha-fx-2755-interactive-workflow-generation.4+46405792",
4
4
  "description": "Continuos integrations tools for frontend projects",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -32,8 +32,9 @@
32
32
  "dependencies": {
33
33
  "@commitlint/cli": "^16.2.4",
34
34
  "@commitlint/config-conventional": "^16.0.0",
35
- "@toptal/davinci-cli-shared": "1.5.2",
35
+ "@toptal/davinci-cli-shared": "1.5.3-alpha-fx-2755-interactive-workflow-generation.4+46405792",
36
36
  "danger": "^11.0.5",
37
37
  "markdown-table": "^2.0.0"
38
- }
38
+ },
39
+ "gitHead": "46405792bfc49fdb4b954b2ca9ddbb9ce8660801"
39
40
  }
@@ -3,18 +3,18 @@ const {
3
3
  runSync,
4
4
  print,
5
5
  convertToCLIParameters,
6
- files
6
+ files,
7
7
  } = require('@toptal/davinci-cli-shared')
8
8
 
9
9
  const commandOptions = [
10
10
  {
11
11
  label: 'check only, without fixing the code',
12
- name: '--check'
12
+ name: '--check',
13
13
  },
14
14
  {
15
15
  label: 'checks commit message quality locally',
16
- name: '--local'
17
- }
16
+ name: '--local',
17
+ },
18
18
  ]
19
19
 
20
20
  const dangerCommand = ({ options }) => {
@@ -43,7 +43,7 @@ const dangerCommand = ({ options }) => {
43
43
  local ? '--failOnErrors' : undefined,
44
44
  '--dangerfile',
45
45
  `${dangerfilePath}`,
46
- ...convertToCLIParameters(rest)
46
+ ...convertToCLIParameters(rest),
47
47
  ].filter(Boolean)
48
48
  )
49
49
  }
@@ -53,7 +53,7 @@ const dangerCommandCreator = {
53
53
  allowUnknownOptions: true,
54
54
  command: 'danger',
55
55
  description: 'Run danger check',
56
- options: commandOptions
56
+ options: commandOptions,
57
57
  }
58
58
 
59
59
  module.exports = dangerCommandCreator
@@ -17,7 +17,7 @@ const conventionalCommits = async () => {
17
17
 
18
18
  const { commits } = danger.git
19
19
  const { rules, parserPreset } = await load({
20
- extends: ['@commitlint/config-conventional']
20
+ extends: ['@commitlint/config-conventional'],
21
21
  })
22
22
 
23
23
  commits.forEach(async commit => {
@@ -33,7 +33,7 @@ const conventionalCommits = async () => {
33
33
 
34
34
  message += table([
35
35
  ['Message'],
36
- ...result.errors.map(error => [error.message])
36
+ ...result.errors.map(error => [error.message]),
37
37
  ])
38
38
 
39
39
  message +=
@@ -48,5 +48,5 @@ const conventionalCommits = async () => {
48
48
  }
49
49
 
50
50
  module.exports = {
51
- conventionalCommits
51
+ conventionalCommits,
52
52
  }
@@ -18,7 +18,7 @@ const conventionalPRTitle = async () => {
18
18
  }
19
19
 
20
20
  const { rules, parserPreset } = await load({
21
- extends: ['@commitlint/config-conventional']
21
+ extends: ['@commitlint/config-conventional'],
22
22
  })
23
23
  const { title } = danger.github.pr
24
24
 
@@ -35,7 +35,7 @@ const conventionalPRTitle = async () => {
35
35
 
36
36
  message += table([
37
37
  ['Message'],
38
- ...result.errors.map(error => [error.message])
38
+ ...result.errors.map(error => [error.message]),
39
39
  ])
40
40
 
41
41
  message +=
@@ -49,5 +49,5 @@ const conventionalPRTitle = async () => {
49
49
  }
50
50
 
51
51
  module.exports = {
52
- conventionalPRTitle
52
+ conventionalPRTitle,
53
53
  }
@@ -3,5 +3,5 @@ const { conventionalPRTitle } = require('./conventional-pr-title')
3
3
 
4
4
  module.exports = {
5
5
  conventionalCommits,
6
- conventionalPRTitle
6
+ conventionalPRTitle,
7
7
  }
@@ -1,7 +1,7 @@
1
1
  const WHITELISTED_USERS = [
2
2
  'dependabot-preview[bot]',
3
3
  'dependabot[bot]',
4
- 'toptal-devbot'
4
+ 'toptal-devbot',
5
5
  ]
6
6
  const VALID_PR_CODE_REGEX = /\[[A-Z]{1,5}-.*]\s/
7
7
  // Valid commit titles:
@@ -26,5 +26,5 @@ module.exports = {
26
26
  MISSING_TICKET_CODE_ERROR_MESSAGE,
27
27
  VALID_COMMIT_TITLE_REGEX,
28
28
  VALID_PR_CODE_REGEX,
29
- WHITELISTED_USERS
29
+ WHITELISTED_USERS,
30
30
  }
@@ -3,5 +3,5 @@ const { toptalPRTitle } = require('./toptal-pr-title')
3
3
 
4
4
  module.exports = {
5
5
  toptalCommits,
6
- toptalPRTitle
6
+ toptalPRTitle,
7
7
  }
@@ -2,7 +2,7 @@
2
2
  const {
3
3
  MAX_COMMIT_LINE_LENGTH,
4
4
  VALID_COMMIT_TITLE_REGEX,
5
- WHITELISTED_USERS
5
+ WHITELISTED_USERS,
6
6
  } = require('../../config')
7
7
 
8
8
  const validateCommitMessage = message => {
@@ -61,7 +61,7 @@ const toptalCommits = () => {
61
61
  fail(
62
62
  [
63
63
  `Commit ${commit.sha.trim()} does not meet requirements of [Commit Message Quality](https://toptal-core.atlassian.net/wiki/spaces/ENG/pages/210665897/Commit+Message+Quality):`,
64
- ...validationErrors
64
+ ...validationErrors,
65
65
  ].join('\n')
66
66
  )
67
67
  }
@@ -69,5 +69,5 @@ const toptalCommits = () => {
69
69
  }
70
70
 
71
71
  module.exports = {
72
- toptalCommits
72
+ toptalCommits,
73
73
  }
@@ -4,7 +4,7 @@ const {
4
4
  VALID_PR_CODE_REGEX,
5
5
  WHITELISTED_USERS,
6
6
  DEFAULT_PR_TITLE_ERROR_MESSAGE,
7
- MISSING_TICKET_CODE_ERROR_MESSAGE
7
+ MISSING_TICKET_CODE_ERROR_MESSAGE,
8
8
  } = require('../../config')
9
9
 
10
10
  const getTicketCode = text => {
@@ -58,5 +58,5 @@ const toptalPRTitle = () => {
58
58
  }
59
59
 
60
60
  module.exports = {
61
- toptalPRTitle
61
+ toptalPRTitle,
62
62
  }
package/src/index.js CHANGED
@@ -7,11 +7,11 @@ module.exports = {
7
7
  plugins: {
8
8
  conventionalCommit: {
9
9
  PRTitle: conventionalCommitsPlugins.conventionalPRTitle,
10
- commits: conventionalCommitsPlugins.conventionalCommits
10
+ commits: conventionalCommitsPlugins.conventionalCommits,
11
11
  },
12
12
  toptal: {
13
13
  PRTitle: toptalPlugins.toptalPRTitle,
14
- commits: toptalPlugins.toptalCommits
15
- }
16
- }
14
+ commits: toptalPlugins.toptalCommits,
15
+ },
16
+ },
17
17
  }
@@ -1,39 +0,0 @@
1
- {
2
- "name": "@toptal/davinci-ci",
3
- "version": "2.0.1",
4
- "description": "Continuos integrations tools for frontend projects",
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
- "keywords": [
9
- "jenkins",
10
- "docker",
11
- "ci"
12
- ],
13
- "author": "Toptal",
14
- "homepage": "https://github.com/toptal/davinci/tree/master/packages/ci#readme",
15
- "license": "ISC",
16
- "bin": {
17
- "davinci-code": "./bin/davinci-ci.js"
18
- },
19
- "main": "./src/index.js",
20
- "repository": {
21
- "type": "git",
22
- "url": "git+https://github.com/toptal/davinci.git"
23
- },
24
- "scripts": {
25
- "build:package": "../../bin/build-package.js",
26
- "prepublishOnly": "../../bin/prepublish.js",
27
- "test": "echo \"Error: run tests from root\" && exit 1"
28
- },
29
- "bugs": {
30
- "url": "https://github.com/toptal/davinci/issues"
31
- },
32
- "dependencies": {
33
- "@commitlint/cli": "^16.2.4",
34
- "@commitlint/config-conventional": "^16.0.0",
35
- "@toptal/davinci-cli-shared": "1.5.2",
36
- "danger": "^11.0.5",
37
- "markdown-table": "^2.0.0"
38
- }
39
- }
@@ -1,128 +0,0 @@
1
- const { toptalCommits } = require('.')
2
-
3
- const prepareCommitsWithMessages = (messages = []) => ({
4
- commits: messages.map(message => ({
5
- message,
6
- sha: '123'
7
- }))
8
- })
9
-
10
- describe('commit danger plugin', () => {
11
- beforeEach(() => {
12
- global.fail = jest.fn()
13
- global.danger = {
14
- github: {
15
- pr: {
16
- user: {
17
- login: 'user'
18
- }
19
- }
20
- }
21
- }
22
- })
23
-
24
- afterEach(() => {
25
- global.fail = undefined
26
- global.danger = undefined
27
- })
28
-
29
- it('commit with title only', () => {
30
- global.danger.git = prepareCommitsWithMessages(['Hello world'])
31
- toptalCommits()
32
-
33
- expect(global.fail).toHaveBeenCalledTimes(0)
34
- })
35
-
36
- it('commit with title and body', () => {
37
- global.danger.git = prepareCommitsWithMessages([
38
- 'Hello world\n\nSome commit body here.'
39
- ])
40
- toptalCommits()
41
-
42
- expect(global.fail).toHaveBeenCalledTimes(0)
43
- })
44
-
45
- it('commit with multi-line body', () => {
46
- global.danger.git = prepareCommitsWithMessages([
47
- 'Hello world\n\nFirst line of commit body\nSecond line of commit body'
48
- ])
49
- toptalCommits()
50
-
51
- expect(global.fail).toHaveBeenCalledTimes(0)
52
- })
53
-
54
- it('commit with title longer than allowed', () => {
55
- global.danger.git = prepareCommitsWithMessages([
56
- 'This commit message is a teeny tiny bit longer than allowed length of 79 characters'
57
- ])
58
- toptalCommits()
59
-
60
- expect(global.fail).toHaveBeenCalledTimes(1)
61
- })
62
-
63
- it('commit with body lines longer than allowed', () => {
64
- global.danger.git = prepareCommitsWithMessages([
65
- 'Short commit title\n\nBut this body line commit message is a bit longer than allowed length of 79 characters\nAnd this one is fine again.'
66
- ])
67
- toptalCommits()
68
-
69
- expect(global.fail).toHaveBeenCalledTimes(1)
70
- })
71
-
72
- it('commit message not starting with an uppercase letter', () => {
73
- global.danger.git = prepareCommitsWithMessages([
74
- '23432 starts with a number',
75
- 'starts with a lowercase letter',
76
- '* starts with a symbol',
77
- ' starts with a space'
78
- ])
79
- toptalCommits()
80
-
81
- expect(global.fail).toHaveBeenCalledTimes(4)
82
- })
83
-
84
- it('commit message ending with a period in title', () => {
85
- global.danger.git = prepareCommitsWithMessages([
86
- 'Commit title ending with period.'
87
- ])
88
- toptalCommits()
89
-
90
- expect(global.fail).toHaveBeenCalledTimes(1)
91
- })
92
-
93
- it('commit without a blank line between title and body', () => {
94
- global.danger.git = prepareCommitsWithMessages([
95
- 'Commit title\nBody without a blank line after title'
96
- ])
97
- toptalCommits()
98
-
99
- expect(global.fail).toHaveBeenCalledTimes(1)
100
- })
101
-
102
- it('valid commit titles', () => {
103
- global.danger.git = prepareCommitsWithMessages([
104
- 'Regular commit title',
105
- 'Commit with sentence. But does not end with a full-stop',
106
- '[FOO-1234] Commit with prefix',
107
- '[FOO] Prefix numbers can be omitted',
108
- '[FOO][BAR] Prefixes can couple',
109
- '[FOO-1234][BAR] Mixed prefixes',
110
- '[FOO-1234][BAR-123][BAZ] Everything. Together'
111
- ])
112
- toptalCommits()
113
-
114
- expect(global.fail).toHaveBeenCalledTimes(0)
115
- })
116
-
117
- it('invalid commit title prefixes', () => {
118
- global.danger.git = prepareCommitsWithMessages([
119
- '[FOO-1234] commit with lowercase',
120
- '[FOO-BAR] Prefix with letter after dash',
121
- '[FOO] [BAR] Prefixes with space between',
122
- '[FOO]Prefix without space'
123
- ])
124
- toptalCommits()
125
-
126
- expect(global.fail).toHaveBeenCalledTimes(4)
127
- })
128
- })
@@ -1,68 +0,0 @@
1
- const { toptalPRTitle } = require('.')
2
- const {
3
- MISSING_TICKET_CODE_ERROR_MESSAGE,
4
- DEFAULT_PR_TITLE_ERROR_MESSAGE
5
- } = require('../../config')
6
-
7
- const VALID_PR_TITLE = '[ASD-123] Hello world'
8
- const INVALID_PR_TITLE = '[ASD-123] hello world'
9
- const NO_TICKET_CODE_PR_TITLE = 'Hello world'
10
-
11
- describe('commit danger plugin', () => {
12
- beforeEach(() => {
13
- global.fail = jest.fn()
14
- global.danger = {
15
- github: {
16
- issue: {
17
- labels: [{ name: 'My Team' }]
18
- },
19
- pr: {
20
- title: '',
21
- user: {
22
- login: 'user'
23
- }
24
- }
25
- }
26
- }
27
- })
28
-
29
- afterEach(() => {
30
- global.fail = undefined
31
- global.danger = undefined
32
- })
33
-
34
- it('should pass valid PR title', () => {
35
- global.danger.github.pr.title = VALID_PR_TITLE
36
-
37
- toptalPRTitle()
38
-
39
- expect(global.fail).toHaveBeenCalledTimes(0)
40
- })
41
-
42
- it('should fail PR title with missing ticket code', () => {
43
- global.danger.github.pr.title = NO_TICKET_CODE_PR_TITLE
44
-
45
- toptalPRTitle()
46
-
47
- expect(global.fail).toHaveBeenCalledTimes(1)
48
- expect(global.fail).toHaveBeenCalledWith(MISSING_TICKET_CODE_ERROR_MESSAGE)
49
- })
50
-
51
- it('should pass valid PR title with missing ticket code and no-jira label', () => {
52
- global.danger.github.pr.title = NO_TICKET_CODE_PR_TITLE
53
- global.danger.github.issue.labels = [{ name: 'no-jira' }]
54
-
55
- toptalPRTitle()
56
-
57
- expect(global.fail).toHaveBeenCalledTimes(0)
58
- })
59
-
60
- it('should fail invalid PR title', () => {
61
- global.danger.github.pr.title = INVALID_PR_TITLE
62
-
63
- toptalPRTitle()
64
-
65
- expect(global.fail).toHaveBeenCalledTimes(1)
66
- expect(global.fail).toHaveBeenCalledWith(DEFAULT_PR_TITLE_ERROR_MESSAGE)
67
- })
68
- })