@toptal/davinci-monorepo 9.0.3-alpha-MP-469-f3f2c8cc.20 → 10.0.1-alpha-PF-add-update-picasso-command-2eb2da4f.2

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
+ ## 10.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#2519](https://github.com/toptal/davinci/pull/2519) [`d025cf0d`](https://github.com/toptal/davinci/commit/d025cf0de421084918c01f762ea50b417d316560) Thanks [@rafael-anachoreta](https://github.com/rafael-anachoreta)!
8
+ - rename the `getChangedPackagesLocations` utility function to `getPackagesLocations`, and allow all packages to be returned depending on whether they are expected to have changed or not
9
+
3
10
  ## 9.0.2
4
11
 
5
12
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-monorepo",
3
- "version": "9.0.3-alpha-MP-469-f3f2c8cc.20+f3f2c8cc",
3
+ "version": "10.0.1-alpha-PF-add-update-picasso-command-2eb2da4f.2+2eb2da4f",
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.2-alpha-MP-469-f3f2c8cc.22+f3f2c8cc",
30
+ "@toptal/davinci-cli-shared": "2.5.2-alpha-PF-add-update-picasso-command-2eb2da4f.26+2eb2da4f",
31
31
  "chalk": "^4.1.2",
32
32
  "codeowners": "5.1.1",
33
33
  "dependency-cruiser": "^16.3.0",
@@ -39,6 +39,7 @@
39
39
  "ignore": "^5.2.0",
40
40
  "is-directory": "^0.3.1",
41
41
  "lodash": "^4.17.21",
42
+ "npm-check-updates": "^16.14.15",
42
43
  "nx": "^19.2.3",
43
44
  "ora": "^5.4.1",
44
45
  "ramda": "^0.28.0",
@@ -50,5 +51,5 @@
50
51
  "publishConfig": {
51
52
  "access": "public"
52
53
  },
53
- "gitHead": "f3f2c8cca781fc088dd2a28a1f9a0deec50021b2"
54
+ "gitHead": "2eb2da4fbd6d2dc07dcd15a04c47728f7d22681b"
54
55
  }
@@ -0,0 +1,48 @@
1
+ import { print, runSync } from '@toptal/davinci-cli-shared'
2
+
3
+ const updatePicassoCommand = async ({ dryRun }) => {
4
+ print.header('Updating Picasso packages')
5
+
6
+ try {
7
+ // Update Picasso dependencies using locally installed npm-check-updates
8
+ print.info(
9
+ dryRun
10
+ ? 'Checking for Picasso updates (dry run)...'
11
+ : 'Updating Picasso dependencies...'
12
+ )
13
+ runSync('yarn', [
14
+ 'lerna',
15
+ 'exec',
16
+ '--',
17
+ 'npx',
18
+ 'npm-check-updates',
19
+ '--filter="/^@toptal\\/picasso/"',
20
+ ...(dryRun ? [] : ['-u']),
21
+ ])
22
+
23
+ if (!dryRun) {
24
+ // Install updated dependencies
25
+ print.info('Installing updated dependencies...')
26
+ runSync('yarn')
27
+ print.success('Successfully updated Picasso packages!')
28
+ }
29
+ } catch (error) {
30
+ print.red('Failed to update Picasso packages:')
31
+ print.red(error.message || error)
32
+ process.exit(1)
33
+ }
34
+ }
35
+
36
+ export const createUpdatePicassoCommand = program => {
37
+ return program
38
+ .createCommand('update-picasso')
39
+ .description(
40
+ 'Updates Picasso dependencies across all packages in the monorepo'
41
+ )
42
+ .option(
43
+ '--dry-run',
44
+ 'Check for updates without modifying package.json files',
45
+ false
46
+ )
47
+ .action(updatePicassoCommand)
48
+ }
@@ -0,0 +1,40 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+ import { jest } from '@jest/globals'
3
+ // eslint-disable-next-line import/no-extraneous-dependencies
4
+ import { Command } from 'commander'
5
+
6
+ const { createUpdatePicassoCommand } = await import('./update-picasso.js')
7
+
8
+ describe('createUpdatePicassoCommand', () => {
9
+ let program
10
+
11
+ beforeEach(() => {
12
+ program = new Command()
13
+ })
14
+
15
+ afterEach(() => {
16
+ jest.clearAllMocks()
17
+ })
18
+
19
+ it('creates a command with the correct parameters', () => {
20
+ const command = createUpdatePicassoCommand(program)
21
+
22
+ expect(command._name).toBe('update-picasso')
23
+ expect(command._description).toBe(
24
+ 'Updates Picasso dependencies across all packages in the monorepo'
25
+ )
26
+ })
27
+
28
+ it('has the dry-run option', () => {
29
+ const command = createUpdatePicassoCommand(program)
30
+ const dryRunOption = command.options.find(
31
+ option => option.long === '--dry-run'
32
+ )
33
+
34
+ expect(dryRunOption).toBeDefined()
35
+ expect(dryRunOption.description).toBe(
36
+ 'Check for updates without modifying package.json files'
37
+ )
38
+ expect(dryRunOption.defaultValue).toBe(false)
39
+ })
40
+ })
package/src/index.js CHANGED
@@ -4,6 +4,7 @@ import { createGraphGenerateCommand } from './commands/graph-generate.js'
4
4
  import { createCodeownersCommand } from './commands/codeowners/index.js'
5
5
  import { createCoverageCommand } from './commands/coverage-command/index.js'
6
6
  import { hostsCommandFactory } from './commands/hosts/index.js'
7
+ import { createUpdatePicassoCommand } from './commands/update-picasso.js'
7
8
  import checkIfMonorepo from './utils/check-if-monorepo.js'
8
9
  import { getPackages, getPackagesLocations } from './utils/get-packages.js'
9
10
 
@@ -20,6 +21,7 @@ export const commands = [
20
21
  createCodeownersCommand,
21
22
  createCoverageCommand,
22
23
  hostsCommandFactory,
24
+ createUpdatePicassoCommand,
23
25
  ]
24
26
 
25
27
  export default {