semver
semver copied to clipboard
Feature: handle no workspace.json configuration
Since workspace.json file in the root directory is optional we have to handle projects without global configuration.
https://nx.dev/configuration/packagejson
I added back the workspace.json in my repo and not having success.
I even pulled this one and ran nx run workspace:version
and get Cannot find project 'workspace'
.
How can I have consistent versioning across all packages? Is there a specific command?
I have the same issue even with a normally generated workspace.json
file:
$ nx run workspace:version
> NX Cannot find project 'workspace'
Environment: a newly generated Nx workspace with a single Angular lib configured by install
command to be versioned.
Anyone have any luck. This is really promissing but needs to support workspaces that have been around for a while. I'm not about to generate a new workspace and migrate a full mon-repo for just this but would still like to use.
@travishamera-hka @avchugaev @shawnmclean I also had the same problem... There is a bit of missing documentation, I found this in another post of @edbzn and this works, they use a virtual project, you need to put it in the workspace.json file, example:
{
"version": 2,
"projects": {
"workspace": {
"root": ".",
"targets": {
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"syncVersions": true
}
},
}
},
"demo": "apps/demo",
"demo-e2e": "apps/demo-e2e"
}
}
Copied from here: https://github.com/jscutlery/semver/issues/420#issuecomment-1006090320
@travishamera-hka @avchugaev @shawnmclean I also had the same problem... There is a bit of missing documentation, I found this in another post of @edbzn and this works, they use a virtual project, you need to put it in the workspace.json file, example:
{ "version": 2, "projects": { "workspace": { "root": ".", "targets": { "version": { "executor": "@jscutlery/semver:version", "options": { "syncVersions": true } }, } }, "demo": "apps/demo", "demo-e2e": "apps/demo-e2e" } }
Copied from here: #420 (comment)
Part of the challenge is that not everyone has a workspace.json. I tried manually adding the file to my root using the example provided but it doesn't work as NX doesn't seem to even try reading the file if it was generated as part of the initial setup? Just still response "cannot find project 'workspace'"
You can clean up your code further by:
workspace.json
{
"version": 2,
"projects": {
"workspace": "",
"demo": "apps/demo",
"demo-e2e": "apps/demo-e2e"
}
}
and adding this to your root project.json:
{
"$schema": "node_modules/nx/schemas/project-schema.json",
"targets": {
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"syncVersions": true,
"commitMessageFormat": "chore(${projectName}): publish version ${version}"
}
},
"github": {
"executor": "@jscutlery/semver:github",
"options": {
"target": "master",
"tag": "${tag}",
"notes": "${notes}"
}
}
},
"tags": []
}
However, this introduces further issues. There is no way around an error free semver configuration with v2 workspaces until @edbzn fixes this in his code.
You will start seeing this warning when creating new libraries and apps:
[NX] Angular devkit called `writeWorkspace`, this may have had unintended consequences in workspace.json
[NX] Double check workspace.json before proceeding
You will be unable to move or remove libraries. Nx will complain that it cannot find the project in the workspace. You'll have to temporarily remove "workspace": "" from workspace.json before executing these types of actions. Just don't forget to put it back in or semver won't be able to find workspace when trying to do a release [done this umpteen times myself already].
This should be the #1 voted improvement on this great plugin!!
Sadly I could not use this plugin because of this missing feature.
When I tried to add the fake workspace project into angular or at the root as proposed here, I got other issues, like eslint dependency constrain problems and nx graph errors.
Plz upvote!
We are stuck with this too :/
This plugin works as expected if you setup a "workspace" project with the following project.json
in the root folder:
{
"name": "workspace",
"$schema": "node_modules/nx/schemas/project-schema.json",
"targets": {
"version": {
"executor": "@jscutlery/semver:version",
"options": {
...
}
}
}
}
In this case it is perfectly compatible with the current standard NX setup without a root workspace.json
.
The key is to set "name"
property with "workspace"
.
Doing that the nx run workspace:version
command works as documented.
This plugin works as expected if you setup a "workspace" project with the following
project.json
in the root folder:{ "name": "workspace", "$schema": "node_modules/nx/schemas/project-schema.json", "targets": { "version": { "executor": "@jscutlery/semver:version", "options": { ... } } } }
In this case it is perfectly compatible with the current standard NX setup without a root
workspace.json
.The key is to set
"name"
property with"workspace"
.Doing that the
nx run workspace:version
command works as documented.
It works