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

doc: error when using * as recommended #102

Open
Badisi opened this issue Apr 2, 2022 · 3 comments
Open

doc: error when using * as recommended #102

Badisi opened this issue Apr 2, 2022 · 3 comments

Comments

@Badisi
Copy link
Contributor

Badisi commented Apr 2, 2022

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 Badisi changed the title fix(doc): doc: error when using * as recommended Apr 2, 2022
@Badisi
Copy link
Contributor Author

Badisi commented Apr 2, 2022

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:

  • A package B depending on a package A@^1.0.0 (located and developed in the same mono-repo).
  • If A has no package.json#version, then running npm install will either:
    • throw an error that package A@^1.0.0 does not exists (if it was never or not yet published)
    • produce a projects/B/node_modules/A (in case A already exists on npm registry) which is not much recommended
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
Copy link
Collaborator

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
Copy link
Contributor Author

Badisi commented Apr 4, 2022

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 🙂

bitgopatmcl added a commit to bitgopatmcl/api-ts that referenced this issue Apr 13, 2022
`multi-semantic-release`'s readme says to use `*` as the version field
for monorepo packages, but this fails in a strange way. This switches
them to `0.0.0-semantically-released` as recommended in a Github issue.

See: dhoulb/multi-semantic-release#102
bitgopatmcl added a commit to bitgopatmcl/api-ts that referenced this issue Apr 13, 2022
`multi-semantic-release`'s readme says to use `*` as the version field
for monorepo packages, but this fails in a strange way. This switches
them to `0.0.0-semantically-released` as recommended in a Github issue.

See: dhoulb/multi-semantic-release#102
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants