commit-and-tag-version 11.2.4 → 11.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [11.3.0](https://github.com/absolute-version/commit-and-tag-version/compare/v11.2.4...v11.3.0) (2023-10-10)
6
+
7
+
8
+ ### Features
9
+
10
+ * **updater:** add .csproj file support ([#95](https://github.com/absolute-version/commit-and-tag-version/issues/95)) ([a96554c](https://github.com/absolute-version/commit-and-tag-version/commit/a96554c9467bacdf6c9d898b223883ee32f63c15))
11
+
5
12
  ## [11.2.4](https://github.com/absolute-version/commit-and-tag-version/compare/v11.2.3...v11.2.4) (2023-10-02)
6
13
 
7
14
 
package/README.md CHANGED
@@ -19,6 +19,7 @@ _Having problems? Want to contribute? Join us on the [node-tooling community Sla
19
19
  - [How It Works:](#how-it-works)
20
20
  - [`bumpFiles`, `packageFiles` and `updaters`](#bumpfiles-packagefiles-and-updaters)
21
21
  - [Gradle Support (Java/Kotlin)](#gradle-support-javakotlin)
22
+ - [.NET Support](#net-support)
22
23
  - [Installing `commit-and-tag-version`](#installing-commit-and-tag-version)
23
24
  - [As a local `npm run` script](#as-a-local-npm-run-script)
24
25
  - [As global `bin`](#as-global-bin)
@@ -88,6 +89,13 @@ If you are using Gradle, then just point to your `build.gradle` file (or `build.
88
89
  commit-and-tag-version --packageFiles build.gradle --bumpFiles build.gradle
89
90
  ```
90
91
 
92
+ ### .NET Support
93
+
94
+ If you are using .NET with `.csproj` files.
95
+ This is going to read and update only the `<Version>` tag in the file.
96
+ ```sh
97
+ commit-and-tag-version --packageFiles <YOUR-PROJECT-NAME>.csproj --bumpFiles <YOUR-PROJECT-NAME>.csproj
98
+ ```
91
99
 
92
100
  ## Installing `commit-and-tag-version`
93
101
 
@@ -3,7 +3,8 @@ const JSON_BUMP_FILES = require('../../defaults').bumpFiles
3
3
  const updatersByType = {
4
4
  json: require('./types/json'),
5
5
  'plain-text': require('./types/plain-text'),
6
- gradle: require('./types/gradle')
6
+ gradle: require('./types/gradle'),
7
+ csproj: require('./types/csproj')
7
8
  }
8
9
  const PLAIN_TEXT_BUMP_FILES = ['VERSION.txt', 'version.txt']
9
10
 
@@ -25,6 +26,9 @@ function getUpdaterByFilename (filename) {
25
26
  if (/build.gradle/.test(filename)) {
26
27
  return getUpdaterByType('gradle')
27
28
  }
29
+ if (filename.endsWith('.csproj')) {
30
+ return getUpdaterByType('csproj')
31
+ }
28
32
  throw Error(
29
33
  `Unsupported file (${filename}) provided for bumping.\n Please specify the updater \`type\` or use a custom \`updater\`.`
30
34
  )
@@ -0,0 +1,13 @@
1
+ const versionRegex = /<Version>(.*)<\/Version>/
2
+
3
+ module.exports.readVersion = function (contents) {
4
+ const matches = versionRegex.exec(contents)
5
+ if (matches === null || matches.length !== 2) {
6
+ throw new Error('Failed to read the Version field in your csproj file - is it present?')
7
+ }
8
+ return matches[1]
9
+ }
10
+
11
+ module.exports.writeVersion = function (contents, version) {
12
+ return contents.replace(versionRegex, `<Version>${version}</Version>`)
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commit-and-tag-version",
3
- "version": "11.2.4",
3
+ "version": "11.3.0",
4
4
  "description": "replacement for `npm version` with automatic CHANGELOG generation",
5
5
  "bin": "bin/cli.js",
6
6
  "scripts": {
package/test/core.spec.js CHANGED
@@ -769,6 +769,22 @@ describe('commit-and-tag-version', function () {
769
769
  fs.readFileSync('build.gradle.kts', 'utf-8').should.equal(expected)
770
770
  })
771
771
 
772
+ it('bumps version in .NET `Project.csproj` file', async function () {
773
+ const expected = fs.readFileSync('./test/mocks/Project-6.4.0.csproj', 'utf-8')
774
+ const filename = 'Project.csproj'
775
+ mock({
776
+ bump: 'minor',
777
+ fs: {
778
+ [filename]: fs.readFileSync('./test/mocks/Project-6.3.1.csproj')
779
+ }
780
+ })
781
+ await exec({
782
+ packageFiles: [{ filename, type: 'csproj' }],
783
+ bumpFiles: [{ filename, type: 'csproj' }]
784
+ })
785
+ fs.readFileSync(filename, 'utf-8').should.equal(expected)
786
+ })
787
+
772
788
  it('bumps version # in npm-shrinkwrap.json', async function () {
773
789
  mock({
774
790
  bump: 'minor',
@@ -0,0 +1,18 @@
1
+ <Project Sdk="Microsoft.NET.Sdk.Web">
2
+
3
+ <PropertyGroup>
4
+ <TargetFramework>net7.0</TargetFramework>
5
+ <Nullable>enable</Nullable>
6
+ <ImplicitUsings>enable</ImplicitUsings>
7
+ <Version>6.3.1</Version>
8
+ </PropertyGroup>
9
+
10
+ <ItemGroup>
11
+ <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.10"/>
12
+ <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="7.0.10"/>
13
+ <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.10"/>
14
+ <PackageReference Include="Microsoft.Identity.Web" Version="1.16.0"/>
15
+ <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
16
+ </ItemGroup>
17
+
18
+ </Project>
@@ -0,0 +1,18 @@
1
+ <Project Sdk="Microsoft.NET.Sdk.Web">
2
+
3
+ <PropertyGroup>
4
+ <TargetFramework>net7.0</TargetFramework>
5
+ <Nullable>enable</Nullable>
6
+ <ImplicitUsings>enable</ImplicitUsings>
7
+ <Version>6.4.0</Version>
8
+ </PropertyGroup>
9
+
10
+ <ItemGroup>
11
+ <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.10"/>
12
+ <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="7.0.10"/>
13
+ <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.10"/>
14
+ <PackageReference Include="Microsoft.Identity.Web" Version="1.16.0"/>
15
+ <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
16
+ </ItemGroup>
17
+
18
+ </Project>