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: sync versions between dependencies such as @aws-cdk/* #44

Closed
abelmokadem opened this issue Sep 28, 2020 · 15 comments
Closed

feat: sync versions between dependencies such as @aws-cdk/* #44

abelmokadem opened this issue Sep 28, 2020 · 15 comments

Comments

@abelmokadem
Copy link

Description

I would expect version group to match packages in the devDependencies, dependencies and peerDependencies field alltogether.

Suggested Solution

Fix mismatches for packages across dev, peer and prod dependencies.

Help Needed

@JamieMason
Copy link
Owner

Could you share your project structure and configuration so we can debug it? Thanks

@abelmokadem
Copy link
Author

@JamieMason I think the version groups are not working for me at all. I'm using a lerna project and this is my configuration in my package.json:

  ...
  "syncpack": {
    "versionGroups": [
      {
        "packages": [
          "aws-cdk",
          "@aws-cdk/core",
          "@aws-cdk/aws-ssm",
          "@aws-cdk/aws-s3",
          "@aws-cdk/assert"
        ],
        "dependencies": [
          "@account-setup-stacks/cdk-toolkit-stack",
          "@account-setup-stacks/parameters-stack"
        ]
      }
    ]
  }

This is my directory structure:

account-setup-stacks
├── lerna.json
├── package-lock.json
├── package.json
├── packages
|  ├── cdk-toolkit-stack
|  └── parameters-stack
└── scripts
   └── npm

@abelmokadem
Copy link
Author

cdk-toolkit-stack dependencies

  "dependencies": {
    "@aws-cdk/core": "1.64.1",
    "@aws-cdk/aws-s3": "1.64.0",
    "source-map-support": "^0.5.16"
  },
  "devDependencies": {
    "@aws-cdk/assert": "1.64.1",
    "@types/jest": "^26.0.10",
    "@types/node": "10.17.27",
    "aws-cdk": "1.64.1",
    "jest": "^26.4.2",
    "ts-jest": "^26.2.0",
    "ts-node": "^8.1.0",
    "typescript": "~3.9.7"
  },

parameters-stack dependencies

  "dependencies": {
    "@aws-cdk/core": "1.64.1",
    "@aws-cdk/aws-ssm": "1.64.0",
    "source-map-support": "^0.5.16"
  },
  "devDependencies": {
    "@aws-cdk/assert": "1.64.1",
    "@types/jest": "^26.0.10",
    "@types/node": "10.17.27",
    "aws-cdk": "1.64.1",
    "jest": "^26.4.2",
    "ts-jest": "^26.2.0",
    "ts-node": "^8.1.0",
    "typescript": "~3.9.7"
  },

@JamieMason
Copy link
Owner

Which version of syncpack please?

@abelmokadem
Copy link
Author

    "syncpack": {
      "version": "5.6.10",
      "resolved": "https://registry.npmjs.org/syncpack/-/syncpack-5.6.10.tgz",

@JamieMason
Copy link
Owner

What are the contents of lerna.json

@abelmokadem
Copy link
Author

{
  "packages": [
    "packages/*"
  ],
  "version": "0.0.0"
}

@JamieMason
Copy link
Owner

Thanks, and what output are you expecting to see? And what do you see instead?

@abelmokadem
Copy link
Author

I have a version mismatch between these 2 packages in the cdk toolkit stack:

    "@aws-cdk/core": "1.64.1",
    "@aws-cdk/aws-s3": "1.64.0",

But also in the parameters stack:

    "@aws-cdk/core": "1.64.1",
    "@aws-cdk/aws-ssm": "1.64.0",

I'm expecting the package to complain about this version mismatch.

@JamieMason
Copy link
Owner

thanks, what's the output of syncpack list?

@abelmokadem
Copy link
Author

Btw, I tried swapping packages and dependencies field. No luck.

$ npx syncpack list            
- @aws-cdk/assert 1.64.1
- @aws-cdk/aws-s3 1.64.0
- @aws-cdk/aws-ssm 1.64.0
- @aws-cdk/core 1.64.1
- @types/jest ^26.0.10
- @types/node 10.17.27
- aws-cdk 1.64.1
- jest ^26.4.2
- lerna ^3.22.1
- source-map-support ^0.5.16
- syncpack ^5.6.10
- ts-jest ^26.2.0
- ts-node ^8.1.0
- typescript ~3.9.7

@JamieMason
Copy link
Owner

Correct me if I'm wrong but I think you're expecting behaviour which isn't quite what this tool is designed for, let me know. Are you expecting that these two separate packages "@aws-cdk/core": "1.64.1", and "@aws-cdk/aws-s3": "1.64.0", should have the same versions as each other?

I'll review and improve the docs if so, but the goal is only to ensure that multiple packages requiring the same dependency define the same version, so that every package requires eg.
react@16.4.2, instead of a combination of react@16.4.2, react@0.15.9, and react@16.0.0.

The situation you describe is valid, you do get families of packages which are all versioned in sync with one another, but it's not something syncpack handles at the moment. It's an interesting use case though which I'll think over to see how much effort it would be to account for.

Sorry for the confusion.

@abelmokadem
Copy link
Author

Aha, that explains! Yes that's exactly what I was expecting. It would really be a nice feature to have when using dependencies like AWS CDK. AWS CDK only works if all the AWS CDK dependencies are on the same version.

@JamieMason JamieMason changed the title Version groups only check within devDependencies / dependencies Q: Support syncing versions between different packages Sep 28, 2020
@JamieMason JamieMason changed the title Q: Support syncing versions between different packages Q: Support syncing versions between different packages? Sep 28, 2020
@JamieMason JamieMason changed the title Q: Support syncing versions between different packages? feat: sync versions between dependencies such as @aws-cdk/* Aug 6, 2021
@JamieMason
Copy link
Owner

This should now be possible in 6.1.0, thanks for contributing.

@sgarfinkel
Copy link

@JamieMason Sorry to necro, but is there a way to sync back this update to the syncpackrc? We would like to be able to periodically npm up these dependencies, but it's a bit irritating to have to manually copy the version into the syncpackrc file every time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants