jscutlery / semver Goto Github PK
View Code? Open in Web Editor NEWNx plugin to automate semantic versioning and CHANGELOG generation.
License: MIT License
Nx plugin to automate semantic versioning and CHANGELOG generation.
License: MIT License
ng-add
schematics should prompt user to select the projects to version.
x-prompt
. We have to hack our way through the PromptProvider
(Cf. https://github.com/angular/angular-cli/blob/7a39938cd0373eaee75597b96909b747e3094f18/packages/angular_devkit/schematics_cli/bin/schematics.ts) or just use inquirer directly.😊
Cf. #42 (comment)__
I am not sure if it is a bug or feature. When running:
nx run workspace:version
the changelog of the libs is udpated but no version bump is happening for the package.json
in that lib.
"workspace": {
"architect": {
"version": {
"builder": "@jscutlery/semver:version",
"options": {
"syncVersions": true
}
}
},
"root": "."
}
Hi,
Versioning fails frequently in a project containing several modules, see this repo: https://github.com/Katona/nx-version-test. The problem seems to be that CHANGELOG files are generated and added to the git repo concurrently, and while one of the processes is adding the file the git repo is locked.
I am using @jscutlery/[email protected]
and [email protected]
.
The user should be able to add @jscutlery/semver
in a workspace using a schematic.
workspace.json
or angular.json
accordinglyI am trying to get the current version of the library to use it in the outputPath path of package executor. Is there a way to get the version in workspace.json to do something like
"package": {
"executor": "@nrwl/web:package",
"options": {
"project": "package.json",
"outputPath": "dist/libs/element-base/{version}",
"entryFile": "libs/element-base/src/index.ts",
"tsConfig": "libs/element-base/tsconfig.lib.json"
}
}
We are currently using semantic-release
but semver
could be the perfect replacement. However there is on scenario that I am struggling with: Besides creating the changelog we also want to publish a GitHub release
semver
will end the process with creating a tag.gh cli
to create a release I would be in trouble because the tag has already been createdIs there a smart way out of that?
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.
When user selects independent mode, version builder should be applied to all projects by default.
projects
option and a list prompt)I'm getting this error every time I try to run nx run workspace:version
. The tag gets pushed to the remote repo, but the commits don't get uploaded. Any idea on how to solve this?
√ tagging release v1.11.15
i Run `git push --follow-tags origin main` to publish
git push --atomic failed, attempting non-atomic push
[object Object]
error Command failed with exit code 1.
We shouldn't check if there are changes or not when --version
is used.
--version
usage probably means there is an operator (human or machine) outside of semver so we don't need the idempotency security that avoid releasing empty versions.
Cf. we might need a --force
option some day.
This is a follow-up to the following discussion #98.
Given a repo with 3 packages a, b & c, one should be able to sync versions for a & b but still keep independent versioning for c; meaning that changing a would have to bump b as well.
The solution we agreed to is to use the project structure for grouping (using folders).
By creating a "group" project in workspace config, like we already do in sync mode with a root path set to the group folder. This way, Nx cache, and Nx dep graph might work.
This will just run the sync mode with a filter of projects that are in the group path. we also have to be careful about the root changelog.
Example:
{
"name": "lumberjack",
"root": "packages/lumberjack",
"architect": {
"version": {
"builder": "@jscutlery/semver:version"
},
},
},
{
"name": "spectacular",
"root": "packages/spectacular",
"architect": {
"version": {
"builder": "@jscutlery/semver:version"
},
},
},
{
"name": "angular-group",
"root": "packages/angular",
"architect": {
"version": {
"builder": "@jscutlery/semver:version"
},
},
},
{
"name": "angular-cdk",
"root": "packages/angular/cdk",
"architect": {"build": "..."}
},
{
"name": "workspace",
"root": ".",
"architect": {
"version": {
"builder": "@jscutlery/semver:version",
"options": {
"configs": [
{
"name": "rx-state",
"type": "independent",
// path is optional for independent versioning
// as we can just pick the projectRoot in workspace.json
// "path": "packages/rx-state", // we need this for git log & changelog path & root package.json
},
{
"name": "cdk",
"type": "group",
"path": "packages/cdk",
"packages": [
"packages/cdk/operators",
"packages/cdk/helpers", // or even a wildcard "packages/cdk/*"
]
}
]
}
}
}
}
vMAJOR.MINOR.PATCH
group-name-MAJOR.MINOR.PATCH
cc. @LayZeeDK, @NachoVazquez, @santoshyadavdev, and @SerkanSipahi.
Bumping @angular-devkit/build-angular
from 0.1100.5 to 0.1100.6 break the CLI and log the following error when running nx run semver:version
:
Unable to resolve @jscutlery/semver:version.
Cannot find module '/home/edouard/work/jscutlery/semver/packages/semver/src/builders/version/builder'
Require stack:
- /home/edouard/work/jscutlery/semver/node_modules/@nrwl/tao/src/shared/workspace.js
- /home/edouard/work/jscutlery/semver/node_modules/@nrwl/tao/src/commands/run.js
- /home/edouard/work/jscutlery/semver/node_modules/@nrwl/tao/index.js
- /home/edouard/work/jscutlery/semver/node_modules/@nrwl/cli/lib/run-cli.js
Does it is related to Nx, or the angular-devkit itself? While this being resolved I revert the update.
This task will simplify the code a lot, but it's a lot of work.
Hi there I have tried to use this plug and added the following to my config asper documentation .
"version": {
"builder": "@jscutlery/semver:version",
"options": {
"push": true,
"remote": "origin",
"baseBranch": "origin/master"
}
}
all I get is the following is logged with nothing happening : nx run my-ap:version --dry-run . No package update or logs
ng-add schematic should prompt user about setting up npm publish if project is publishable.
If user accepts, schematic should:
@jscutlery/semver:github
postTargets
(cf. #167)When creating a new angular lib via nx the default initial version number of the package is 0.0.1
instead of 0.0.0
. This causes the plugin to fail when executing nx run mylib:version
.
When manually setting the version of to 0.0.0 the command starts working as expected.
Root cause is the following line:
Suggestion:
since: initial || version !== '0.0.0' ? `${tagPrefix}${version}` : null,
The use of standard-version
is tightly coupled to the use of conventional-changelog-angular
, and the use of these libraries has become a de facto standard to enforce correct use. It would be nice to allow the installation and configuration of these libraries, even if it is optional.
I'm now testing the setup of these libraries with semver to ensure that all works well together.
The project ngx-semantic-version is doing something similar, but focused in Angular apps.
We have to use the declarative approach for the following reasons:
package.json
ng add @jscutlery/[email protected]
Cf. #30 (comment)
calledTimes(1)
here
but for some reason, this is called 6 times.MockBuilderContext
seems to read the filesystem for some reason. We should avoid that.jest.mock('fs')
?cc. @edbzn
Maybe this should be an issue 😅
A few colleagues were looking for a solution to bump our application version based not only changes in the application code but also any libraries that it is dependent on. Is that possible with this module or will it only ever bump the version of the individual library or app when changed?
This sounds like a strange request. What we're looking to achieve is a way to kinda semantically version our overall application but most of the functionality of these is actually maintained in seperate libraries.
Thanks for this lib, was easy to get up and running and works like a charm.
Users (including us) want to publish apps/docs/packages, and maybe do other stuff when semver
bumps something.
As discussed with @edbzn, instead of implementing a custom plugin system or trying to hack our way to be compatible with semantic-release
plugins, let's allow users to run any Angular/Nx target after bump.
This could look something like this:
{
"name": "workspace",
"root": ".",
"architect": {
"version": {
"builder": "@jscutlery/semver:version",
"options": {
"configs": [
{
"name": "rx-state",
"type": "independent"
},
{
"name": "cdk",
"type": "group",
"path": "packages/cdk",
"projects": [
"packages/cdk/operators",
"packages/cdk/helpers" // or a wildcard "packages/cdk/*"
],
"postTargets": [
"helpers:deploy",
{
"name": "operators:deploy",
"options": {
"my-deploy-option": "{{ version }}-jscutlery",
"is-dry-run": "{{ dryRun }}"
}
}
]
}
]
}
}
}
}
In the future, we could add a preTargets
option.
By the way, should we call the option postTargets
or postBump
in order to add options like preChangelog
and postChangelog
in the future?
It would be great to be able to bump versions explicitly based on a passed in parameter. This is similar in nature to Lerna's version
command.
I think this command could look like:
# would patch all affected packages
nx affected --target version --semver-type patch
# would patch all packages
nx run workspace:version --semver-type patch
When executing nx run workspace:version --sync-versions true --root-changelog false
in my nx repo I get the following warning:
(node:7184) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'project/workspace.json'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:7184) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:7184) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
NX version: "@nrwl/workspace": "11.1.5"
Hi,
I would like to verify my workflow:
Steps:
At Step 4., has the semver plugin invalidated all the caches for the libraries where it updated the CHANGELOG.md file?
If yes, is there a way to avoid doing that?
Thank you
In our current release process we have modified the ruleset in some aspects like this:
{
"preset": "angular",
"releaseRules": [
{ "breaking": true, "release": "minor" },
{ "tag": "Breaking", "release": "minor"}
]
}
Is it possible to pass a custom config to semver
as well?
Cf. #125
We could simply check if a CHANGELOG.md
file exists to define its value.
Running nx migrate @jscutlery/semver
doesn't detect migrations. The package.json
and migrations.json
look good though.
Here is the output:
Fetching meta data about packages.
It may take a few minutes.
Fetching @jscutlery/[email protected]
> NX The migrate command has run successfully.
- package.json has been updated
- there are no migrations to run, so migrations.json has not been created.
> NX Next steps:
- Make sure package.json changes make sense and then run 'yarn'
- To learn more go to https://nx.dev/latest/core-concepts/updating-nx
- You may run "nx connect-to-nx-cloud" to get faster builds, Github integration, and more. Check out https://nx.app
nx migrate
command.Cf. #125
In independent mode, git tags should be prefixed with the package name. Currently we have version tag collisions.
When using a monorepo, developers should be able to choose locked/fixed mode and bump all libs synchronously.
Cf. lerna fixed mode.
The main goal is to automate the release process and automation comes with continuous integration btw. We should document how to do this. We can start with GitHub actions.
version
schematic should add a latest
git tag. This can be used as a base when running version on affected projects: nx affected --target version --base latest
When using the nx cli and passing --version=prerelease
that option never makes it into my builder. It's as if I never passed the option
npx nx run workspace:version --version=prerelease --preid=beta --dry-run
> nx run workspace:version --preid=beta --dry-run --dryRun
passing in --version=x
would actually get recognized as an option by the builder
I'm not quite sure if this is an issue with semver or with nx. I'm curious because it seems like an issue with nx from what I've dug into (as the option never even reaches the runBuilder function in runtime), but I can't believe that I'm the only user who is facing this issue. I have opened an issue in the nrwl/nx repo and will see if they have thoughts, but I'm curious if anyone else here has run into or seen this issue.
Node : 12.22.1
OS : darwin x64
yarn : 1.22.10
nx : Not Found
@nrwl/angular : 12.0.8
@nrwl/cli : 12.0.8
@nrwl/cypress : 12.0.8
@nrwl/devkit : 12.0.8
@nrwl/eslint-plugin-nx : 12.0.8
@nrwl/express : Not Found
@nrwl/jest : 12.0.8
@nrwl/linter : 12.0.8
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : 12.0.8
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 11.2.12
@nrwl/web : Not Found
@nrwl/workspace : 12.0.8
@nrwl/storybook : Not Found
@nrwl/gatsby : Not Found
typescript : 4.1.5
When using a monorepo, developers can choose independent versioning:
standard-version doesn't handle commits filtering per directory.
Maybe we should use lerna's libraries. Cf. https://github.com/lerna/lerna/blob/main/core/conventional-commits/lib/recommend-version.js
For now we only have one root CHANGELOG for the monorepo. There is some interest of having sub CHANGELOGs :
Fun fact: Lerna made this feature early, before they included a root CHANGELOG as an enhancement, see this.
It could be a new option for the version builder. We can use the standard-changelog
package to generate sub CHANGELOGs.
I have a monorepo with 750+ libraries. When I run
nx run workspace:version
The command finishes without any error but there was no version bump and no change logs generated
I believe this is a 2-part issue.
Our project contains 1000+ libraries. When I run nx run workspace:version
, the semver plugin starts generating CHANGELOG.md files for every library. At some point it stops with the following error:
Error: Command failed: git add /Users/crash/git/iko-travel-spa/libs/shared/ui-date-time-picker-form/CHANGELOG.md
fatal: Unable to create '/Users/crash/git/iko-travel-spa/.git/index.lock': File exists.
Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
at ChildProcess.exithandler (child_process.js:308:12)
at ChildProcess.emit (events.js:314:20)
at maybeClose (internal/child_process.js:1022:16)
at Socket.<anonymous> (internal/child_process.js:444:11)
at Socket.emit (events.js:314:20)
at Pipe.<anonymous> (net.js:675:12)
I am not running any other process of Git.
The second part of this issue is that, according to your documentation, it should just create / update a single
CHANGELOG.md file located in project root. I've tried updating the call by including:
nx run workspace:version --root-changelog=true
with no success.
I think there is definitely an error happening when there are too many projects and the lock file wasn't removed fast enough between change log generations. But this error is caused by the fact that the plugin should be generating only one change log but instead generates 1K+, in the case of my project.
Please let me know if I can provide you with anything else.
Guys, i'm sorry for be so bothersome 🙄
Sync mode update all changelogs and package.json versions at once (with one single version) and produce single "bump" commit.
Indepdendent mode goes for each library and produce multiple "bump" commit for each library.
Is it possible to run independent mode like sync mode (over all apps and libs) and produce single commit not multiple?
Thank you!) 🍺
Hi semver Team,
Thanks for the plugin.
Any chance on supporting https://github.com/semantic-release/semantic-release in addition to standard-version (users could decide through a new option on the schematics for e.g)?
It has the advantage of fully automating the release (no manually operation at all),
integrates with NPM, Github Releases out-of-the-box (closing #70), etc.
Hi!
Great work guys, super powerful plugin!
I would like to suggest allowing the user to provide a custom header for the change log.
Currently it defaults to:
This file was generated using @jscutlery/semver.
While this is great to promote this plugin and excelent as the default header, users should be able to provide their own header and not being force to promote something.
In the majority of the use cases users will probably not opt out, but some would like to have this option.
Thanks!
Running nx run workspace:version
fails and logs Error: fatal: bad revision 'v1.10.10..HEAD'
.
Any idea about how to solve this?
Cf. #125
I guess the following "works as designed" but can cause problems:
When using the following setting:
"workspace": {
"architect": {
"version": {
"builder": "@jscutlery/semver:version",
"options": {
"syncVersions": true
}
}
},
"root": "."
}
the changelog is only created for some libraries - probably affected
? But when keeping all the versions in sync I always need to publish a new version of all libs - no matter if they are affected or not. So the package.json should be updated in any case and probably an empty changelog as well? At least that is the standard behaviour when using something like standard-changelog
Cf. #125
It could be useful to publish to npm directly using this package. It could be a new builder.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.