Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(align-deps): suggest capabilities to add #2204

Merged
merged 3 commits into from
Feb 24, 2023

Conversation

tido64
Copy link
Member

@tido64 tido64 commented Feb 14, 2023

Description

When in vigilant mode, also suggest capabilities that can be added. This is warning as there are legitimate reasons to not have dependencies managed by align-deps. For instance, the maintainers of AsyncStorage would not want to use the storage capability.

Resolves #933.

Test plan

  1. Build:
    yarn build-scope align-deps
    cd packages/align-deps
    
  2. Remove random capabilities, e.g.:
    diff --git a/packages/test-app/package.json b/packages/test-app/package.json
    index c15c775f..2ef1ca40 100644
    --- a/packages/test-app/package.json
    +++ b/packages/test-app/package.json
    @@ -26,8 +26,7 @@
       },
       "dependencies": {
         "react": "17.0.2",
    -    "react-native": "^0.68.0",
    -    "react-native-macos": "^0.68.0",
    +    "react-native-macos": "^0.69.0",
         "react-native-windows": "^0.68.0"
       },
       "devDependencies": {
    @@ -48,10 +47,11 @@
         "@rnx-kit/third-party-notices": "*",
         "@types/react": "^17.0.2",
         "@types/react-native": "^0.68.0",
    -    "eslint": "^8.0.0",
    +    "eslint": "^9.0.0",
         "jest-cli": "^27.5.1",
         "metro-react-native-babel-preset": "^0.67.0",
         "prettier": "^2.8.0",
    +    "react-native": "^0.68.0",
         "react-native-test-app": "^2.0.2",
         "react-test-renderer": "17.0.2",
         "typescript": "^4.0.0"
  3. Verify that capabilities are suggested for test-app:
    node lib/cli.js --requirements react-native@0.71 ../test-app
    
  4. Verify that capabilities are not suggested for metro-config:
    node lib/cli.js --requirements react-native@0.68 ../metro-config
    

Example output:

warn ../test-app/package.json: Found dependencies that are currently missing from capabilities:
	  - @types/react-native can be managed by '@types/react-native'
	  - eslint can be managed by 'eslint'
	  - jest-cli can be managed by 'jest-cli'
	  - prettier can be managed by 'prettier'
	  - react-test-renderer can be managed by 'react-test-renderer'
	  - typescript can be managed by 'typescript'
info Note: Capabilities will never be added automatically, even with '--write'.
error ../test-app/package.json: Changes are needed to satisfy all capabilities.
	In dependencies:
	  - react-native "^0.68.0" is missing
	  - react-native-macos "^0.69.0" should be "^0.68.0"
	In devDependencies:
	  - react-native should be removed
error ../test-app/package.json: Found 1 violation(s) outside of capabilities.
	In devDependencies:
	  - eslint "^9.0.0" should be "^8.0.0"
error Re-run with '--write' to fix them.
info Visit https://aka.ms/align-deps for more information about align-deps.

Output with only warnings:

warn packages/test-app/package.json: Found dependencies that are currently missing from capabilities:
	  - @types/react-native can be managed by '@types/react-native'
	  - eslint can be managed by 'eslint'
	  - jest-cli can be managed by 'jest-cli'
	  - prettier can be managed by 'prettier'
	  - react-test-renderer can be managed by 'react-test-renderer'
	  - typescript can be managed by 'typescript'
info Note: Capabilities will never be added automatically, even with '--write'.

@github-actions github-actions bot added the feature: align-deps This is related to align-deps label Feb 14, 2023
@kelset
Copy link
Member

kelset commented Feb 20, 2023

follow up from meeting; a new shape for the error log:

warn A number of unmanaged dependencies were found - they can be managed by adding the following capabilities:
	react-native can be managed by 'core'
	react-native-macos can be managed by 'core-macos'
	react-native-windows can be managed by 'core-windows'
	@types/react-native can be managed by '@types/react-native'
	eslint can be managed by 'eslint'
	jest-cli can be managed by 'jest-cli'
	metro-react-native-babel-preset can be managed by 'babel-preset-react-native'
	prettier can be managed by 'prettier'
	react-native-test-app can be managed by 'test-app'
	react-test-renderer can be managed by 'react-test-renderer'
	typescript can be managed by 'typescript'

Note: Capabilities will never be added automatically, even with '--write'.

error Found violation(s) in '../test-app/package.json':
  Found 1 violation(s) [MANAGED BY CAPABILITIES]
    in dependencies:
      react "17.0.2" should be "18.2.0" (via "react" capability)
    in devDependencies:
        metro-react-native-babel-preset "^0.67.0" should be "^0.73.7" (via "metro" capability)

  Found 5 violation(s) [UNMANAGED BY CAPABILITIES (only through --requirements), check if any can be managed in the warning above(?)]
    in dependencies:
      react-native "^0.68.0" should be "^0.71.0"
      react-native-macos "^0.68.0" should be "^0.71.0"
      react-native-windows "^0.68.0" should be "^0.71.0"
    in devDependencies:
      react-test-renderer "17.0.2" should be "18.2.0"

Re-run with '--write' to fix them.

info Visit https://aka.ms/align-deps for more information about align-deps.

@tido64 tido64 marked this pull request as draft February 23, 2023 10:02
@tido64 tido64 force-pushed the tido/align-deps/suggest-capabilities branch 2 times, most recently from 185b7e6 to be719a3 Compare February 23, 2023 14:19
@tido64 tido64 force-pushed the tido/align-deps/suggest-capabilities branch from be719a3 to 836a455 Compare February 24, 2023 07:25
@tido64 tido64 marked this pull request as ready for review February 24, 2023 07:27
Copy link
Member

@kelset kelset left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested locally once again, I think this new error outputting is so much better - thanks for doing this Tommy! 👏

@tido64 tido64 merged commit 162b1dd into main Feb 24, 2023
@tido64 tido64 deleted the tido/align-deps/suggest-capabilities branch February 24, 2023 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: align-deps This is related to align-deps
Projects
None yet
Development

Successfully merging this pull request may close these issues.

new feature: have align-deps tell you which capabilities you could add
2 participants