@toptal/davinci-monorepo 8.3.8-alpha-fx-5435-monorepo-commands-0774222d.6 → 8.5.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,19 @@
1
1
  # @toptal/davinci-monorepo
2
2
 
3
+ ## 8.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#2416](https://github.com/toptal/davinci/pull/2416) [`9518893e`](https://github.com/toptal/davinci/commit/9518893ec55a03736bbaa4ec49b8dea2e6d1f46f) Thanks [@dmaklygin](https://github.com/dmaklygin)!
8
+ - add hosts command to davinci-monorepo package. Try it out with `yarn davinci-monorepo hosts`
9
+
10
+ ## 8.4.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [#2412](https://github.com/toptal/davinci/pull/2412) [`e0df16d2`](https://github.com/toptal/davinci/commit/e0df16d2e60c2ccd302059ff28f6311af488719f) Thanks [@sashuk](https://github.com/sashuk)!
15
+ - check if nx build system exists
16
+
3
17
  ## 8.3.7
4
18
 
5
19
  ### Patch Changes
package/docs/hosts.md CHANGED
@@ -2,18 +2,18 @@
2
2
 
3
3
  The `host` functions are used to get information about hosts in the monorepo.
4
4
 
5
- ## Specified Hosts Command
5
+ ## Filter Valid Hosts Command
6
6
 
7
- This command is used to identify and validate specified hosts from the input.
7
+ This command is used to identify and validate hosts from the input.
8
8
 
9
9
  ### Description
10
10
 
11
- The `davinci-monorepo specified` command processes an input string to determine existing hosts. It checks the input for valid host names, filters the corresponding packages, and outputs the result either to the console or GitHub.
11
+ The `davinci-monorepo hosts filter-valid-hosts` command processes an input string to determine existing hosts. It checks the input for valid host names, filters the corresponding packages, and outputs the result either to the console or GitHub.
12
12
 
13
13
  ### Usage
14
14
 
15
15
  ```shell
16
- davinci-monorepo hosts specified --hosts="@toptal/test-1-host @toptal/test-2-host"
16
+ davinci-monorepo hosts filter-valid-hosts --hosts="@toptal/test-1-host @toptal/test-2-host"
17
17
  ```
18
18
 
19
19
  ### Options
@@ -43,7 +43,7 @@ davinci-monorepo hosts specified --hosts="@toptal/test-1-host @toptal/test-2-hos
43
43
  #### Example 1: Specifying Hosts and Output to Console
44
44
 
45
45
  ```bash
46
- davinci-monorepo hosts specified --hosts "@toptal/test-1-host @toptal/test-2-host" --output console
46
+ davinci-monorepo hosts filter-valid-hosts --hosts "@toptal/test-1-host @toptal/test-2-host" --output console
47
47
  ```
48
48
 
49
49
  #### Example 2: Using Environment Variables and Output to GitHub
@@ -52,7 +52,7 @@ davinci-monorepo hosts specified --hosts "@toptal/test-1-host @toptal/test-2-hos
52
52
  export HOSTS_SEQUENCE="@toptal/test-1-host @toptal/test-2-host"
53
53
  export NX_HEAD="abc1234"
54
54
  export NX_BASE="def5678"
55
- davinci-monorepo hosts specified --output github
55
+ davinci-monorepo hosts filter-valid-hosts --output github
56
56
  ```
57
57
 
58
58
  ### Environment Variables
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-monorepo",
3
- "version": "8.3.8-alpha-fx-5435-monorepo-commands-0774222d.6+0774222d",
3
+ "version": "8.5.0",
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-5435-monorepo-commands-0774222d.9+0774222d",
30
+ "@toptal/davinci-cli-shared": "^2.5.0",
31
31
  "chalk": "^4.1.2",
32
32
  "codeowners": "5.1.1",
33
33
  "dependency-cruiser": "^12.5.0",
@@ -49,6 +49,5 @@
49
49
  },
50
50
  "publishConfig": {
51
51
  "access": "public"
52
- },
53
- "gitHead": "0774222ddf02b514f6737a7ce94b67ac4498b3ac"
52
+ }
54
53
  }
@@ -3,7 +3,7 @@ import { print } from '@toptal/davinci-cli-shared'
3
3
  import { getPackages } from '../../utils/get-packages.js'
4
4
  import { validateHost, writeToGithubOutput } from '../../utils/index.js'
5
5
 
6
- const specifiedHostsCommand = async ({
6
+ const filterValidHostsCommand = async ({
7
7
  hosts,
8
8
  output,
9
9
  head,
@@ -61,11 +61,11 @@ const specifiedHostsCommand = async ({
61
61
  process.exit(0)
62
62
  }
63
63
 
64
- export const createSpecifiedHostsCommand = program => {
64
+ export const createFilterValidHostsCommand = program => {
65
65
  return program
66
- .createCommand('specified')
66
+ .createCommand('filter-valid-hosts')
67
67
  .description('Gets the input and determines existing hosts in the input')
68
- .action(specifiedHostsCommand)
68
+ .action(filterValidHostsCommand)
69
69
  .option(
70
70
  '-h, --hosts [hosts]',
71
71
  'Input string to search for hosts in. By default, it is taken from the environment variable HOSTS_SEQUENCE'
@@ -28,8 +28,14 @@ const hostAttributesCommand = ({ host, output, logLevel }) => {
28
28
 
29
29
  const hostName = getHostNameFromPackageName(packageName)
30
30
  const jenkinsTemployJobName = `${hostName}-temploy-helm-run`
31
- const jenkinsStagingJobName = `${hostName}-portal-staging-deployment`
32
- const deploybotName = `${hostName}-portal`
31
+ const jenkinsStagingJobName =
32
+ hostName === 'client-portal'
33
+ ? 'portal-staging-deployment'
34
+ : `${hostName}-portal-staging-deployment`
35
+ // In order to deploy to the portal, we need to replace the "host" with "portal"
36
+ // e.g. hire-global-client-host -> hire-global-client-portal
37
+ const deploybotName =
38
+ hostName === 'client-portal' ? 'portal' : `${hostName}-portal`
33
39
 
34
40
  const result = JSON.stringify({
35
41
  packageName,
@@ -37,6 +43,7 @@ const hostAttributesCommand = ({ host, output, logLevel }) => {
37
43
  jenkinsTemployJobName,
38
44
  jenkinsStagingJobName,
39
45
  deploybotName,
46
+ sentryProject: hostName,
40
47
  })
41
48
 
42
49
  switch (output) {
@@ -1,10 +1,10 @@
1
- import { createSpecifiedHostsCommand } from './specified-hosts.js'
1
+ import { createFilterValidHostsCommand } from './filter-valid-hosts.js'
2
2
  import { createHostAttributesCommand } from './host-attributes.js'
3
3
 
4
4
  export const hostsCommandFactory = program => {
5
5
  return program
6
6
  .createCommand('hosts')
7
- .addCommand(createSpecifiedHostsCommand(program))
7
+ .addCommand(createFilterValidHostsCommand(program))
8
8
  .addCommand(createHostAttributesCommand(program))
9
9
  }
10
10
 
@@ -27,15 +27,18 @@ const isPNPMWorkspace = () => {
27
27
  */
28
28
  const checkIfMonorepo = () => {
29
29
  const lernaIsAvailable = yarnCommandExists('lerna --version')
30
+ const nxIsAvailable = yarnCommandExists('nx --version')
30
31
  const pnpmWorkspaceExists = isPNPMWorkspace()
31
32
  const yarnWorkspaceExists = yarnCommandExists('workspaces info')
32
33
  const workspacesExist = yarnWorkspaceExists || pnpmWorkspaceExists
33
34
  const isMonorepo =
34
- (lernaIsAvailable && yarnWorkspaceExists) || pnpmWorkspaceExists
35
+ ((lernaIsAvailable || nxIsAvailable) && yarnWorkspaceExists) ||
36
+ pnpmWorkspaceExists
35
37
 
36
38
  return {
37
39
  isMonorepo,
38
40
  lernaIsAvailable,
41
+ nxIsAvailable,
39
42
  workspacesExist,
40
43
  pnpmWorkspaceExists,
41
44
  }
@@ -20,6 +20,20 @@ describe('checkIfMonorepo', () => {
20
20
  })
21
21
  })
22
22
 
23
+ describe('when project does not have `nx` installed', () => {
24
+ it('returns false for `nxIsAvailable`', () => {
25
+ execa.sync
26
+ .mockImplementation(() => true)
27
+ .mockImplementation(() => {
28
+ throw new Error('Cannot execute nx')
29
+ })
30
+ const { nxIsAvailable, isMonorepo } = checkIfMonorepo()
31
+
32
+ expect(nxIsAvailable).toBe(false)
33
+ expect(isMonorepo).toBe(false)
34
+ })
35
+ })
36
+
23
37
  describe('when project does not have workspaces configured', () => {
24
38
  afterEach(() => execa.sync.mockClear())
25
39
 
@@ -36,7 +50,16 @@ describe('checkIfMonorepo', () => {
36
50
 
37
51
  describe('when project has `lerna` installed and workspaces are configured', () => {
38
52
  it('returns true for `isMonorepo`', () => {
39
- execa.sync.mockImplementation(() => true)
53
+ execa.sync.mockImplementation(() => true).mockImplementation(() => false)
54
+ const { isMonorepo } = checkIfMonorepo()
55
+
56
+ expect(isMonorepo).toBe(true)
57
+ })
58
+ })
59
+
60
+ describe('when project has `nx` installed and workspaces are configured', () => {
61
+ it('returns true for `isMonorepo`', () => {
62
+ execa.sync.mockImplementation(() => false).mockImplementation(() => true)
40
63
  const { isMonorepo } = checkIfMonorepo()
41
64
 
42
65
  expect(isMonorepo).toBe(true)