@toptal/davinci-ci 2.0.14-alpha-fx-3161-refactor-davinci-syntax-681b89c6.39 → 2.0.14-alpha-fx-3251-convert-ci-1aebc76f.41

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.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import cliEngine from '@toptal/davinci-cli-shared'
3
+
4
+ import dangerCLI from '../src/index.mjs'
5
+ console.log('NEW DANGER CI')
6
+ cliEngine.loadCommands(dangerCLI.commands)
7
+ cliEngine.bootstrap()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-ci",
3
- "version": "2.0.14-alpha-fx-3161-refactor-davinci-syntax-681b89c6.39+681b89c6",
3
+ "version": "2.0.14-alpha-fx-3251-convert-ci-1aebc76f.41+1aebc76f",
4
4
  "description": "Continuos integrations tools for frontend projects",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -14,9 +14,10 @@
14
14
  "homepage": "https://github.com/toptal/davinci/tree/master/packages/ci#readme",
15
15
  "license": "ISC",
16
16
  "bin": {
17
- "davinci-ci": "./bin/davinci-ci.js"
17
+ "davinci-ci": "./bin/davinci-ci.mjs"
18
18
  },
19
- "main": "./src/index.js",
19
+ "type": "module",
20
+ "exports": "./index.mjs",
20
21
  "repository": {
21
22
  "type": "git",
22
23
  "url": "git+https://github.com/toptal/davinci.git"
@@ -32,9 +33,9 @@
32
33
  "dependencies": {
33
34
  "@commitlint/cli": "^17.0.2",
34
35
  "@commitlint/config-conventional": "^17.1.0",
35
- "@toptal/davinci-cli-shared": "1.8.2-alpha-fx-3161-refactor-davinci-syntax-681b89c6.85+681b89c6",
36
+ "@toptal/davinci-cli-shared": "1.8.2-alpha-fx-3251-convert-ci-1aebc76f.87+1aebc76f",
36
37
  "danger": "^11.0.7",
37
38
  "markdown-table": "^2.0.0"
38
39
  },
39
- "gitHead": "681b89c60cf07ee4dcc87f6f549a86c3cc79a3e4"
40
+ "gitHead": "1aebc76fe1b5a477c3ea9224c76d7623f494c69b"
40
41
  }
@@ -1,10 +1,9 @@
1
- const {
1
+ import {
2
2
  davinciProjectConfig,
3
3
  runSync,
4
4
  print,
5
5
  convertToCLIParameters,
6
- files,
7
- } = require('@toptal/davinci-cli-shared')
6
+ } from '@toptal/davinci-cli-shared'
8
7
 
9
8
  const commandOptions = [
10
9
  {
@@ -21,16 +20,33 @@ const commandOptions = [
21
20
  },
22
21
  ]
23
22
 
23
+ import { createRequire } from 'module'
24
+ import path from 'path'
25
+ import url from 'url'
26
+
27
+ const localRequire = createRequire(import.meta.url)
28
+ const thisScriptDirname = path.dirname(url.fileURLToPath(import.meta.url))
29
+
30
+ const getPackageFilePath = (davinciPackageName, filename) => {
31
+ console.log('davinciPackageName:', davinciPackageName)
32
+ const packageIndexPath = localRequire.resolve(davinciPackageName, {
33
+ paths: [thisScriptDirname],
34
+ })
35
+ const davinciQARoot = path.join(packageIndexPath, '../..')
36
+
37
+ return path.join(davinciQARoot, filename)
38
+ }
39
+
24
40
  const dangerCommand = ({ options }) => {
25
41
  print.green('Running danger check...')
26
42
 
27
43
  const { local, dangerfile, ...rest } = options
28
44
 
29
- const conventionalCommitsDangerfilePath = files.getPackageFilePath(
45
+ const conventionalCommitsDangerfilePath = getPackageFilePath(
30
46
  '@toptal/davinci-ci',
31
47
  'src/configs/danger/conventional-commits/dangerfile.js'
32
48
  )
33
- const toptalCommitsDangerfilePath = files.getPackageFilePath(
49
+ const toptalCommitsDangerfilePath = getPackageFilePath(
34
50
  '@toptal/davinci-ci',
35
51
  'src/configs/danger/toptal/dangerfile.js'
36
52
  )
@@ -64,4 +80,4 @@ const dangerCommandCreator = {
64
80
  options: commandOptions,
65
81
  }
66
82
 
67
- module.exports = dangerCommandCreator
83
+ export default dangerCommandCreator
@@ -1,7 +1,6 @@
1
- const { schedule } = require('danger')
1
+ import { schedule } from 'danger'
2
2
 
3
- const { conventionalCommits } = require('./plugins/conventional-commits')
4
- const { conventionalPRTitle } = require('./plugins/conventional-pr-title')
3
+ import { conventionalCommits, conventionalPRTitle } from './plugins/index.mjs'
5
4
 
6
5
  schedule(conventionalCommits)
7
6
  schedule(conventionalPRTitle)
@@ -1,13 +1,13 @@
1
1
  /* globals danger, fail */
2
2
  /* eslint-disable import/no-extraneous-dependencies */
3
- const { default: load } = require('@commitlint/load')
4
- const { default: lint } = require('@commitlint/lint')
3
+ import { default as load } from '@commitlint/load'
4
+ import { default as lint } from '@commitlint/lint'
5
5
  /* eslint-enable */
6
- const table = require('markdown-table')
6
+ import table from 'markdown-table'
7
7
 
8
- const { WHITELISTED_USERS } = require('../../../toptal/config')
8
+ import { WHITELISTED_USERS } from '../../../toptal/config.mjs'
9
9
 
10
- const conventionalCommits = async () => {
10
+ export const conventionalCommits = async () => {
11
11
  if (
12
12
  danger.github &&
13
13
  WHITELISTED_USERS.includes(danger.github.pr.user.login)
@@ -47,6 +47,6 @@ const conventionalCommits = async () => {
47
47
  })
48
48
  }
49
49
 
50
- module.exports = {
50
+ export default {
51
51
  conventionalCommits,
52
52
  }
@@ -1,14 +1,14 @@
1
1
  /// <reference types="danger" />
2
2
  /* globals danger, fail */
3
3
  /* eslint-disable import/no-extraneous-dependencies */
4
- const { default: load } = require('@commitlint/load')
5
- const { default: lint } = require('@commitlint/lint')
4
+ import { default as load } from '@commitlint/load'
5
+ import { default as lint } from '@commitlint/lint'
6
6
  /* eslint-enable */
7
- const table = require('markdown-table')
7
+ import table from 'markdown-table'
8
8
 
9
- const { WHITELISTED_USERS } = require('../../../toptal/config')
9
+ import { WHITELISTED_USERS } from '../../../toptal/config.mjs'
10
10
 
11
- const conventionalPRTitle = async () => {
11
+ export const conventionalPRTitle = async () => {
12
12
  if (!danger.github) {
13
13
  return
14
14
  }
@@ -48,6 +48,6 @@ const conventionalPRTitle = async () => {
48
48
  }
49
49
  }
50
50
 
51
- module.exports = {
51
+ export default {
52
52
  conventionalPRTitle,
53
53
  }
@@ -0,0 +1,2 @@
1
+ export { conventionalCommits } from './conventional-commits/index.mjs'
2
+ export { conventionalPRTitle } from './conventional-pr-title/index.mjs'
@@ -1,25 +1,26 @@
1
- const WHITELISTED_USERS = [
1
+ export const WHITELISTED_USERS = [
2
2
  'dependabot-preview[bot]',
3
3
  'dependabot[bot]',
4
4
  'toptal-devbot',
5
5
  ]
6
- const VALID_PR_CODE_REGEX = /\[[A-Z]{1,5}-.*]\s/
6
+ export const VALID_PR_CODE_REGEX = /\[[A-Z]{1,5}-.*]\s/
7
7
  // Valid commit titles:
8
8
  // "Regular commit message"
9
9
  // "Commit with sentence. But does not end with a full-stop"
10
10
  // "[FOO-1234] Commit with prefix"
11
11
  // "[FOO] Prefix numbers can be omitted"
12
12
  // "[FOO][BAR] Prefixes can couple"
13
- const VALID_COMMIT_TITLE_REGEX = /^((\[[A-Z]+(-\d+)?])+ )?[A-Z]\w[^\n]*[^.]$/
14
- const MAX_COMMIT_LINE_LENGTH = 79
15
- const ENGINEERING_DOCS_LINK =
13
+ export const VALID_COMMIT_TITLE_REGEX =
14
+ /^((\[[A-Z]+(-\d+)?])+ )?[A-Z]\w[^\n]*[^.]$/
15
+ export const MAX_COMMIT_LINE_LENGTH = 79
16
+ export const ENGINEERING_DOCS_LINK =
16
17
  'https://toptal-core.atlassian.net/wiki/spaces/ENG/pages/210665897/Commit+Message+Quality'
17
18
 
18
- const 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](${ENGINEERING_DOCS_LINK})`
19
- const MISSING_TICKET_CODE_ERROR_MESSAGE =
19
+ export const 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](${ENGINEERING_DOCS_LINK})`
20
+ export const MISSING_TICKET_CODE_ERROR_MESSAGE =
20
21
  "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."
21
22
 
22
- module.exports = {
23
+ export default {
23
24
  DEFAULT_PR_TITLE_ERROR_MESSAGE,
24
25
  ENGINEERING_DOCS_LINK,
25
26
  MAX_COMMIT_LINE_LENGTH,
@@ -1,7 +1,6 @@
1
- const { schedule } = require('danger')
1
+ import { schedule } from 'danger'
2
2
 
3
- const { toptalCommits } = require('./plugins/toptal-commits')
4
- const { toptalPRTitle } = require('./plugins/toptal-pr-title')
3
+ import { toptalCommits, toptalPRTitle } from './plugins/index.mjs'
5
4
 
6
5
  schedule(toptalCommits)
7
6
  schedule(toptalPRTitle)
@@ -0,0 +1,2 @@
1
+ export { toptalCommits } from './toptal-commits/index.mjs'
2
+ export { toptalPRTitle } from './toptal-pr-title/index.mjs'
@@ -1,9 +1,9 @@
1
1
  /* globals danger, fail */
2
- const {
2
+ import {
3
3
  MAX_COMMIT_LINE_LENGTH,
4
4
  VALID_COMMIT_TITLE_REGEX,
5
5
  WHITELISTED_USERS,
6
- } = require('../../config')
6
+ } from '../../config.mjs'
7
7
 
8
8
  const validateCommitMessage = message => {
9
9
  const errors = []
@@ -40,7 +40,7 @@ const validateCommitMessage = message => {
40
40
  return errors
41
41
  }
42
42
 
43
- const toptalCommits = () => {
43
+ export const toptalCommits = () => {
44
44
  if (
45
45
  danger.github &&
46
46
  WHITELISTED_USERS.includes(danger.github.pr.user.login)
@@ -68,6 +68,6 @@ const toptalCommits = () => {
68
68
  })
69
69
  }
70
70
 
71
- module.exports = {
71
+ export default {
72
72
  toptalCommits,
73
73
  }
@@ -1,11 +1,11 @@
1
1
  /* globals danger, fail */
2
- const {
2
+ import {
3
3
  VALID_COMMIT_TITLE_REGEX,
4
4
  VALID_PR_CODE_REGEX,
5
5
  WHITELISTED_USERS,
6
6
  DEFAULT_PR_TITLE_ERROR_MESSAGE,
7
7
  MISSING_TICKET_CODE_ERROR_MESSAGE,
8
- } = require('../../config')
8
+ } from '../../config.mjs'
9
9
 
10
10
  const getTicketCode = text => {
11
11
  const ticketCode = text.match(VALID_PR_CODE_REGEX)
@@ -21,7 +21,7 @@ const showError = (error = DEFAULT_PR_TITLE_ERROR_MESSAGE) => {
21
21
  fail(error)
22
22
  }
23
23
 
24
- const toptalPRTitle = () => {
24
+ export const toptalPRTitle = () => {
25
25
  if (!danger.github) {
26
26
  return
27
27
  }
@@ -57,6 +57,6 @@ const toptalPRTitle = () => {
57
57
  }
58
58
  }
59
59
 
60
- module.exports = {
60
+ export default {
61
61
  toptalPRTitle,
62
62
  }
package/src/index.mjs ADDED
@@ -0,0 +1,17 @@
1
+ import dangerCommandCreator from './commands/danger.mjs'
2
+ import {toptalPRTitle, toptalCommits} from './configs/danger/toptal/plugins/index.mjs'
3
+ import {conventionalPRTitle, conventionalCommits} from './configs/danger/conventional-commits/plugins/index.mjs'
4
+
5
+ export default {
6
+ commands: [dangerCommandCreator],
7
+ plugins: {
8
+ conventionalCommit: {
9
+ PRTitle: conventionalPRTitle,
10
+ commits: conventionalCommits,
11
+ },
12
+ toptal: {
13
+ PRTitle: toptalPRTitle,
14
+ commits: toptalCommits,
15
+ },
16
+ },
17
+ }
package/bin/davinci-ci.js DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const cliEngine = require('@toptal/davinci-cli-shared')
4
-
5
- const { commands } = require('../src')
6
-
7
- cliEngine.loadCommands(commands)
8
- cliEngine.bootstrap()
@@ -1,7 +0,0 @@
1
- const { conventionalCommits } = require('./conventional-commits')
2
- const { conventionalPRTitle } = require('./conventional-pr-title')
3
-
4
- module.exports = {
5
- conventionalCommits,
6
- conventionalPRTitle,
7
- }
@@ -1,7 +0,0 @@
1
- const { toptalCommits } = require('./toptal-commits')
2
- const { toptalPRTitle } = require('./toptal-pr-title')
3
-
4
- module.exports = {
5
- toptalCommits,
6
- toptalPRTitle,
7
- }
package/src/index.js DELETED
@@ -1,17 +0,0 @@
1
- const dangerCommandCreator = require('./commands/danger')
2
- const toptalPlugins = require('./configs/danger/toptal/plugins')
3
- const conventionalCommitsPlugins = require('./configs/danger/conventional-commits/plugins')
4
-
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
- }