@toptal/davinci-monorepo 8.5.2-alpha-fx-5804-prohibit-customization-of-davinci-graphql-codegen-tool-b6fc3f7c.33 → 8.5.3-alpha-cp-rename-root-libs-in-codeowners-1caff1d8.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @toptal/davinci-monorepo
2
2
 
3
+ ## 8.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2475](https://github.com/toptal/davinci/pull/2475) [`7d8e3041`](https://github.com/toptal/davinci/commit/7d8e3041dc38fdaf2ab3996375d301472535c878) Thanks [@dmaklygin](https://github.com/dmaklygin)!
8
+ - fix monorepo metrics command
9
+
3
10
  ## 8.5.1
4
11
 
5
12
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-monorepo",
3
- "version": "8.5.2-alpha-fx-5804-prohibit-customization-of-davinci-graphql-codegen-tool-b6fc3f7c.33+b6fc3f7c",
3
+ "version": "8.5.3-alpha-cp-rename-root-libs-in-codeowners-1caff1d8.0+1caff1d8",
4
4
  "keywords": [
5
5
  "lint"
6
6
  ],
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@nodelib/fs.walk": "^1.2.6",
29
29
  "@oclif/core": "^1.16.1",
30
- "@toptal/davinci-cli-shared": "2.5.1-alpha-fx-5804-prohibit-customization-of-davinci-graphql-codegen-tool-b6fc3f7c.61+b6fc3f7c",
30
+ "@toptal/davinci-cli-shared": "2.5.1-alpha-cp-rename-root-libs-in-codeowners-1caff1d8.54+1caff1d8",
31
31
  "chalk": "^4.1.2",
32
32
  "codeowners": "5.1.1",
33
33
  "dependency-cruiser": "^16.3.0",
@@ -50,5 +50,5 @@
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
- "gitHead": "b6fc3f7ce0ed642d1004ea9a5daa8a0a2d411564"
53
+ "gitHead": "1caff1d8ff1f282087f0e25dfd719f46b92fb950"
54
54
  }
@@ -4,7 +4,7 @@ const patterns = [
4
4
  {
5
5
  __name: 'root-libs',
6
6
  expression: /^libs\/([\w-]+)\//,
7
- getName: libraryName => `root/libs/${libraryName}`,
7
+ getName: libraryName => `libs/${libraryName}`,
8
8
  },
9
9
  {
10
10
  __name: 'namespaces',
@@ -28,12 +28,12 @@ describe('fileNameToPackage', () => {
28
28
  {
29
29
  fileName:
30
30
  'libs/clipboard/src/services/use-copy-to-clipboard/use-copy-to-clipboard.test.tsx',
31
- expected: 'root/libs/clipboard',
31
+ expected: 'libs/clipboard',
32
32
  },
33
33
  {
34
34
  fileName:
35
35
  'libs/current-user/src/data/use-user-date-formatter/use-user-date-formatter.ts',
36
- expected: 'root/libs/current-user',
36
+ expected: 'libs/current-user',
37
37
  },
38
38
  ])('return expected package name for root libs', ({ fileName, expected }) => {
39
39
  expect(fileNameToPackage(fileName)).toBe(expected)
@@ -150,6 +150,7 @@ const metricsCommand = options => {
150
150
  }
151
151
  } else {
152
152
  console.log(output)
153
+ process.exit(0)
153
154
  }
154
155
  }
155
156
 
@@ -1,19 +1,23 @@
1
1
  import childProcessLib from 'child_process'
2
+ import fs from 'fs'
2
3
 
3
4
  const lernaGraphCommand =
4
- 'yarn --silent --cwd=../.. lerna list --all --toposort --graph --loglevel silent'
5
+ 'yarn --silent --cwd=../.. lerna list --all --toposort --graph --loglevel silent > lerna-output.json'
5
6
 
6
7
  /**
7
8
  * Generates and returns a graph of monorepo packages
8
9
  */
9
10
  export const createGetLernaGraph =
10
- childProcess =>
11
+ () =>
11
12
  (options = {}) => {
12
13
  const { onlyLocalDependencies = false, excludedPackages = new Set() } =
13
14
  options
14
15
 
15
- const lernaGraphCommandOutput = childProcess.execSync(lernaGraphCommand)
16
- const packagesGraph = JSON.parse(lernaGraphCommandOutput.toString())
16
+ childProcessLib.execSync(lernaGraphCommand)
17
+ const lernaOutput = fs.readFileSync('lerna-output.json', 'utf8')
18
+
19
+ fs.unlinkSync('lerna-output.json')
20
+ const packagesGraph = JSON.parse(lernaOutput)
17
21
 
18
22
  excludedPackages.forEach(packageName => delete packagesGraph[packageName])
19
23
 
@@ -1,5 +1,6 @@
1
1
  import { jest } from '@jest/globals'
2
2
  import childProcess from 'child_process'
3
+ import fs from 'fs'
3
4
 
4
5
  import { createGetLernaGraph } from './get-lerna-graph.js'
5
6
 
@@ -11,29 +12,38 @@ const graph = {
11
12
  }
12
13
 
13
14
  describe('getLernaGraph', () => {
14
- let execSyncMock
15
+ let execSyncMock, readFileSyncMock, unlinkSync
15
16
 
16
17
  beforeEach(() => {
17
18
  execSyncMock = jest.spyOn(childProcess, 'execSync')
19
+ readFileSyncMock = jest.spyOn(fs, 'readFileSync')
20
+ unlinkSync = jest.spyOn(fs, 'unlinkSync')
18
21
  })
19
22
 
20
23
  afterEach(() => {
21
24
  execSyncMock.mockReset()
25
+ readFileSyncMock.mockReset()
26
+ unlinkSync.mockReset()
22
27
  })
23
28
 
24
29
  it('executes the command', () => {
25
- execSyncMock.mockReturnValue(JSON.stringify(graph))
30
+ readFileSyncMock.mockReturnValue(JSON.stringify(graph))
26
31
 
27
32
  getLernaGraph()
28
33
 
29
34
  expect(execSyncMock).toHaveBeenCalledTimes(1)
30
35
  expect(execSyncMock).toHaveBeenCalledWith(
31
- 'yarn --silent --cwd=../.. lerna list --all --toposort --graph --loglevel silent'
36
+ 'yarn --silent --cwd=../.. lerna list --all --toposort --graph --loglevel silent > lerna-output.json'
32
37
  )
38
+ expect(readFileSyncMock).toHaveBeenCalledTimes(1)
39
+ expect(readFileSyncMock).toHaveBeenCalledWith('lerna-output.json', 'utf8')
40
+
41
+ expect(unlinkSync).toHaveBeenCalledTimes(1)
42
+ expect(unlinkSync).toHaveBeenCalledWith('lerna-output.json')
33
43
  })
34
44
 
35
45
  it('returns a graph', () => {
36
- execSyncMock.mockReturnValue(JSON.stringify(graph))
46
+ readFileSyncMock.mockReturnValue(JSON.stringify(graph))
37
47
 
38
48
  const result = getLernaGraph()
39
49
 
@@ -42,7 +52,7 @@ describe('getLernaGraph', () => {
42
52
 
43
53
  describe('when onlyLocalDependencies option is true', () => {
44
54
  it('returns graph with only internal dependencies', () => {
45
- execSyncMock.mockReturnValue(JSON.stringify(graph))
55
+ readFileSyncMock.mockReturnValue(JSON.stringify(graph))
46
56
 
47
57
  const result = getLernaGraph({ onlyLocalDependencies: true })
48
58
 
@@ -52,7 +62,7 @@ describe('getLernaGraph', () => {
52
62
 
53
63
  describe('when there are some excluded packages', () => {
54
64
  it('returns graph without excluded packages', () => {
55
- execSyncMock.mockReturnValue(
65
+ readFileSyncMock.mockReturnValue(
56
66
  JSON.stringify({
57
67
  package1: ['externalDependency1', 'package2'],
58
68
  package2: [