dhoulb / multi-semantic-release

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

doc: error when using * as recommended #102

Open Badisi opened 2 years ago

Badisi commented 2 years ago

According to the documentation:

This means there's no need to hard-code versions any more (we recommend just using * asterisk instead in your repo code).

But using "*" will bring the following error : Invalid version: "*".

So I think it might be better to recommend not having the version property at all (which works in my case).


Trace

[10:49:31 AM] › ✖  Failed step "verifyConditions" of plugin "Inline plugin"
[10:49:31 AM] › ✖  An error occurred while running semantic-release: Error: Invalid version: "*"
    at Object.fixVersionField (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/read-pkg/node_modules/normalize-package-data/lib/fixer.js:191:13)
    at /Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/read-pkg/node_modules/normalize-package-data/lib/normalize.js:32:38
    at Array.forEach (<anonymous>)
    at normalize (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/read-pkg/node_modules/normalize-package-data/lib/normalize.js:31:15)
    at module.exports (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/read-pkg/index.js:20:36)
    at async module.exports (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/@semantic-release/npm/lib/get-pkg.js:8:17)
    at async verifyConditions (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/@semantic-release/npm/index.js:32:17)
    at async validator (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/semantic-release/lib/plugins/normalize.js:34:24)
    at async /Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/semantic-release/lib/plugins/pipeline.js:37:34
    at async Promise.all (index 0) {
  pluginName: 'Inline plugin'
}
[multi-semantic-release]: AggregateError: 
    Error: Invalid version: "*"
        at Object.fixVersionField (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/read-pkg/node_modules/normalize-package-data/lib/fixer.js:191:13)
        at /Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/read-pkg/node_modules/normalize-package-data/lib/normalize.js:32:38
        at Array.forEach (<anonymous>)
        at normalize (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/read-pkg/node_modules/normalize-package-data/lib/normalize.js:31:15)
        at module.exports (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/read-pkg/index.js:20:36)
        at async module.exports (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/@semantic-release/npm/lib/get-pkg.js:8:17)
        at async verifyConditions (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/@semantic-release/npm/index.js:32:17)
        at async validator (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/semantic-release/lib/plugins/normalize.js:34:24)
        at async /Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/semantic-release/lib/plugins/pipeline.js:37:34
        at async Promise.all (index 0)
    at /Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/semantic-release/lib/plugins/pipeline.js:54:11
    at async Object.pluginsConf.<computed> [as verifyConditions] (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/semantic-release/lib/plugins/index.js:80:11)
    at async run (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/semantic-release/index.js:95:3)
    at async module.exports (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/semantic-release/index.js:260:22)
    at async releasePackage (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/multi-semantic-release/lib/multiSemanticRelease.js:201:15)
    at async Promise.all (index 0)
    at async multiSemanticRelease (/Users/badisi/.npm/_npx/fc5f6a55a6a495a8/node_modules/multi-semantic-release/lib/multiSemanticRelease.js:96:2)
Badisi commented 2 years ago

EDIT: I think the best recommendation is to use "version": "0.0.0-semantically-released" as you do.

It is self-explanatory and it avoids the issue below.


Issue

Consider the following:

root
└── projects
    ├── A
    ├── B
    └── C

// root package.json
{
  "name": "my-workspace",
  "workspaces": [
    "projects/A",
    "projects/B"
  ]
}

// A package.json
{
  "name": "A"
}

// B package.json
{
  "name": "B",
  "dependencies": {
    "A": "^1.0.0"
  }
}

Solution

Using the following will makes npm find the local version of A which is what we want. And thanks to MSR all those versions will be replaced during the release process.

// A package.json
{
  "name": "A",
  "version": "0.0.0-semantically-released"
}

// B package.json
{
  "name": "B",
  "version": "0.0.0-semantically-released"
  "dependencies": {
    "A": "0.0.0-semantically-released"
  }
}
antongolub commented 2 years ago

Lools like an old elusive bug in the deps updating algorithm. I've tried to replace concurrent events flow with toposort-based queue, but it may have gotten even worse.

Badisi commented 2 years ago

I don't think this is related to your update as the error here comes from the normalize-package-data package. It simply does not accept "*" as a version.

But anyhow it was just a "recommendation" in your documentation, so updating the doc to recommend "0.0.0-semantically-released" instead seems not a big deal 🙂