@toptal/davinci-monorepo 8.1.4-alpha-CRT-5891-create-coverage-command-0a4adac5.7 → 8.1.4-alpha-CRT-5891-create-coverage-command-e6e5bd51.7

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-monorepo",
3
- "version": "8.1.4-alpha-CRT-5891-create-coverage-command-0a4adac5.7+0a4adac5",
3
+ "version": "8.1.4-alpha-CRT-5891-create-coverage-command-e6e5bd51.7+e6e5bd51",
4
4
  "description": "Monorepo utility tools",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -35,10 +35,9 @@
35
35
  "dependencies": {
36
36
  "@nodelib/fs.walk": "^1.2.6",
37
37
  "@oclif/core": "^1.16.1",
38
- "@toptal/davinci-cli-shared": "2.3.1-alpha-CRT-5891-create-coverage-command-0a4adac5.39+0a4adac5",
38
+ "@toptal/davinci-cli-shared": "2.3.1-alpha-CRT-5891-create-coverage-command-e6e5bd51.39+e6e5bd51",
39
39
  "chalk": "^4.1.2",
40
40
  "codeowners": "5.1.1",
41
- "commander": "^10.0.0",
42
41
  "dependency-cruiser": "^12.5.0",
43
42
  "ervy": "^1.0.7",
44
43
  "execa": "^5.1.1",
@@ -55,5 +54,5 @@
55
54
  "devDependencies": {
56
55
  "@jest/globals": "^29.4.2"
57
56
  },
58
- "gitHead": "0a4adac5650c666f07b97522a76b2f30dd604738"
57
+ "gitHead": "e6e5bd5114c669c12d4b245907649d617b9fdd96"
59
58
  }
@@ -4,8 +4,6 @@ import fs from 'fs'
4
4
  import { print } from '@toptal/davinci-cli-shared'
5
5
  import getWorkspaceRoot from 'find-yarn-workspace-root'
6
6
 
7
- // eslint-disable-next-line no-restricted-syntax
8
- import Codeowners from '../codeowners/core/codeowners/codeowners.js'
9
7
  import { sanitizeTeamName } from './services/sanitize-team-name/sanitize-team-name.js'
10
8
  import {
11
9
  CYPRESS_COVERAGE_PATH,
@@ -46,9 +44,23 @@ const getCoverageSummary = (type, teamPath) => {
46
44
  const generateTeamCoverage = async options => {
47
45
  print.header('Generating team coverage')
48
46
 
49
- const codeowners = new Codeowners(workspaceRoot)
47
+ let codeowners
48
+ const { default: CodeOwnersTool } = await import(
49
+ // eslint-disable-next-line no-restricted-syntax
50
+ 'codeowners/codeowners.js'
51
+ )
52
+
53
+ try {
54
+ codeowners = new CodeOwnersTool(workspaceRoot)
55
+ } catch (e) {
56
+ console.error(e.message)
57
+ process.exit(1)
58
+ }
59
+
50
60
  const teams = getUniqueTeams(codeowners.ownerEntries)
51
61
 
62
+ print.grey('Teams: ', teams)
63
+
52
64
  await execa.command(`rm -rf ${TEAMS_COVERAGE_PATH}`)
53
65
  await execa.command(`mkdir ${TEAMS_COVERAGE_PATH}`)
54
66
 
@@ -3,8 +3,6 @@ import fs from 'fs'
3
3
  import { print } from '@toptal/davinci-cli-shared'
4
4
  import getWorkspaceRoot from 'find-yarn-workspace-root'
5
5
 
6
- // eslint-disable-next-line no-restricted-syntax
7
- import Codeowners from '../codeowners/core/codeowners/codeowners.js'
8
6
  import { CYPRESS_COVERAGE_PATH, JEST_COVERAGE_PATH } from './config.js'
9
7
  import { sanitizeTeamName } from './services/sanitize-team-name/sanitize-team-name.js'
10
8
  import { getUniqueTeams } from './services/get-unique-teams/get-unique-teams.js'
@@ -58,9 +56,23 @@ const groupCoverageByCodeowners = async () => {
58
56
  path.join(CYPRESS_COVERAGE_PATH, 'coverage-final-cypress.json')
59
57
  )
60
58
 
61
- const codeowners = new Codeowners(workspaceRoot)
59
+ let codeowners
60
+ const { default: CodeOwnersTool } = await import(
61
+ // eslint-disable-next-line no-restricted-syntax
62
+ 'codeowners/codeowners.js'
63
+ )
64
+
65
+ try {
66
+ codeowners = new CodeOwnersTool(workspaceRoot)
67
+ } catch (e) {
68
+ console.error(e.message)
69
+ process.exit(1)
70
+ }
71
+
62
72
  const teams = getUniqueTeams(codeowners.ownerEntries)
63
73
 
74
+ print.grey('Teams: ', teams)
75
+
64
76
  splitReportIntoTeams({
65
77
  report: jestReport,
66
78
  teams,
@@ -1,11 +1,4 @@
1
- import { print } from '@toptal/davinci-cli-shared'
2
-
3
- export const getUniqueTeams = teams => {
4
- const uniqueTeams = teams
1
+ export const getUniqueTeams = teams =>
2
+ teams
5
3
  .flatMap(entry => entry.usernames)
6
4
  .filter((teamName, index, allTeams) => allTeams.indexOf(teamName) === index)
7
-
8
- print.grey('Teams: ', uniqueTeams)
9
-
10
- return uniqueTeams
11
- }
@@ -1,21 +1,6 @@
1
- // eslint-disable-next-line import/no-extraneous-dependencies
2
- import { jest } from '@jest/globals'
3
-
4
1
  import { getUniqueTeams } from './get-unique-teams'
5
2
 
6
- jest.unstable_mockModule('@toptal/davinci-cli-shared', () => ({
7
- print: {
8
- grey: jest.fn(),
9
- },
10
- }))
11
-
12
- const { print } = await import('@toptal/davinci-cli-shared')
13
-
14
3
  describe('getUniqueTeams', () => {
15
- beforeEach(() => {
16
- print.grey.mockImplementation(jest.fn())
17
- })
18
-
19
4
  it.each([
20
5
  [
21
6
  [