Skip to content

Commit 37b8944

Browse files
authored
feat: export version const for external tools (#428)
The difference between version 4 and 5 is big, so we need to provide some API to allow external tools to detect which version of the plugin is used.
1 parent 5665dac commit 37b8944

File tree

6 files changed

+2854
-89
lines changed

6 files changed

+2854
-89
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ jobs:
9797
path: lib
9898

9999
- name: Release
100-
run: npx semantic-release@16.0.2
100+
run: yarn semantic-release

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"test:pack": "yarn pack --filename fork-ts-checker-webpack-plugin.tgz",
3939
"test:e2e": "yarn test:pack && cross-env jest e2e --ci --runInBand --bail --verbose",
4040
"precommit": "cross-env lint-staged && yarn build && yarn test:unit",
41-
"commit": "cross-env git-cz"
41+
"commit": "cross-env git-cz",
42+
"semantic-release": "semantic-release"
4243
},
4344
"husky": {
4445
"hooks": {
@@ -73,6 +74,11 @@
7374
},
7475
"devDependencies": {
7576
"@commitlint/config-conventional": "^8.3.4",
77+
"@semantic-release/commit-analyzer": "^8.0.1",
78+
"@semantic-release/exec": "^5.0.0",
79+
"@semantic-release/github": "^7.0.7",
80+
"@semantic-release/npm": "^7.0.5",
81+
"@semantic-release/release-notes-generator": "^9.0.1",
7682
"@types/babel__code-frame": "^7.0.1",
7783
"@types/cross-spawn": "^6.0.2",
7884
"@types/eslint": "^6.8.0",
@@ -101,6 +107,7 @@
101107
"mock-fs": "^4.11.0",
102108
"prettier": "^2.0.4",
103109
"rimraf": "^3.0.2",
110+
"semantic-release": "^17.0.0",
104111
"strip-ansi": "^6.0.0",
105112
"tree-kill": "^1.2.2",
106113
"ts-jest": "^25.3.1",

release.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,12 @@ module.exports = {
2929
'@semantic-release/release-notes-generator',
3030
'@semantic-release/npm',
3131
'@semantic-release/github',
32+
[
33+
'@semantic-release/exec',
34+
{
35+
prepareCmd:
36+
"sed -i 's/{{VERSION}}/${nextRelease.version}/g' lib/ForkTsCheckerWebpackPlugin.js",
37+
},
38+
],
3239
],
3340
};

src/ForkTsCheckerWebpackPlugin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import { tapErrorToLogMessage } from './hooks/tapErrorToLogMessage';
1818
import { getForkTsCheckerWebpackPluginHooks } from './hooks/pluginHooks';
1919

2020
class ForkTsCheckerWebpackPlugin implements webpack.Plugin {
21+
static readonly version: string = '{{VERSION}}'; // will be replaced by the @semantic-release/exec
22+
2123
private readonly options: ForkTsCheckerWebpackPluginOptions;
2224

2325
constructor(options: ForkTsCheckerWebpackPluginOptions = {}) {

test/unit/ForkTsCheckerWebpackPlugin.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ describe('ForkTsCheckerWebpackPlugin', () => {
99
}
1010
);
1111

12+
it('exposes current version', () => {
13+
expect(ForkTsCheckerWebpackPlugin.version).toEqual('{{VERSION}}'); // will be replaced by the @semantic-release/exec
14+
});
15+
1216
it("doesn't throw an error for empty options", () => {
1317
expect(() => new ForkTsCheckerWebpackPlugin()).not.toThrowError();
1418
});

0 commit comments

Comments
 (0)