dhoulb / multi-semantic-release

Proof of concept that wraps semantic-release to work with monorepos.
BSD Zero Clause License
200 stars 37 forks source link

bug: replace pnpm `workspace:^` correctly #111

Closed lyh543 closed 1 year ago

lyh543 commented 2 years ago

Expected behavior

According to pnpm docs, workspace: * and other versions will be transformed from:

{
    "dependencies": {
        "foo": "workspace:*",
        "bar": "workspace:~",
        "qar": "workspace:^",
        "zoo": "workspace:^1.5.0"
    }
}

to:

{
    "dependencies": {
        "foo": "1.5.0",
        "bar": "~1.5.0",
        "qar": "^1.5.0",
        "zoo": "^1.5.0"
    }
}

Current MSR behavior

{
    "dependencies": {
        "foo": "1.5.0",
        "bar": "1.5.0",
        "qar": "1.5.0",
        "zoo": "(not tested)"
    }
}
lyh543 commented 2 years ago

I'm happy to contribute to MSR, however I'm afraid I don't have enough time until July (working on my graduate papers). So I just report this bug right now :)

antongolub commented 2 years ago

Hey @lyh543,

No rush. Focus on your thesis and come back)

lyh543 commented 1 year ago

I added code and tests in resolveNextVersion, to handle versions like pnpm workspace: (see #128).

I met some problems, then I modify existing code to fix it. I hope we can discuss it in PR #128 Now I meet some problems. To be clear, suppose we are talking about a pnpm monorepo including`product`, `foo`, `bar`, `qar` and `zoo`. `product` depends on others, and `product/package.json` looks like this: ```json { "name": "product", "version": "1.0.0", "dependencies": { "foo": "workspace:*", "bar": "workspace:^", "qar": "workspace:~", "zoo": "workspace:^1.1.0", }, } ``` After release, `product/package.json` should look like this: ```json { "name": "product", "version": "1.0.1", "dependencies": { "foo": "1.0.0", "bar": "^1.0.0", "qar": "~1.0.0", "zoo": "^1.1.0", }, } ``` My release command is: `multi-semantic-release --no-ci --deps.bump satisfy` ------------------------ When we are calling `resolveNextVersion` in `updateManifestDeps` to determine which version of `foo` will be written to `product/package.json`, we pass in last released version of `foo` (`dependency._lastRelease.version`) as `currentVersion`, not the version defined in `product/package.json`. https://github.com/dhoulb/multi-semantic-release/blob/2dedffc0bae8380fff8404ef5acd84b20f40f0c3/lib/updateDeps.js#L308-L313 At this point, I think it may be difficult to impement the feature, without passing new params to `resolveNextVersion`, since I can't get `foo`'s version defined in `product/package.json`. Can anyone help me? Any discussion and help will be appreciatedā¤
antongolub commented 1 year ago

:tada: This issue has been resolved in version 3.0.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: