@frsource/release-it-config 1.4.0 → 1.6.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.
@@ -48,7 +48,7 @@ module.exports = ({
48
48
  [`${pluginsPath}/cross-deps-version-plugin.mjs`]: {},
49
49
  },
50
50
  hooks: {
51
- 'before:bump': buildCmd,
51
+ 'after:init': buildCmd,
52
52
  'before:npm:release': 'pnpm pack',
53
53
  'after:npm:release': 'rm *.tgz',
54
54
  },
@@ -48,7 +48,7 @@ declare function _exports({ pkgName, buildCmd, pluginsPath, }: {
48
48
  };
49
49
  };
50
50
  hooks: {
51
- 'before:bump': string;
51
+ 'after:init': string;
52
52
  'before:npm:release': string;
53
53
  'after:npm:release': string;
54
54
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frsource/release-it-config",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "main": "index.cjs",
5
5
  "types": "index.d.cts",
6
6
  "type": "module",
@@ -11,8 +11,8 @@
11
11
  "globals": "^15.0.0",
12
12
  "release-it": "^17.2.0",
13
13
  "typescript": "^5.4.5",
14
- "@frsource/eslint-config": "1.2.0",
15
- "@frsource/prettier-config": "1.2.0"
14
+ "@frsource/eslint-config": "1.3.0",
15
+ "@frsource/prettier-config": "1.3.0"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "release-it": ">= 17"
@@ -31,7 +31,7 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "packageManager": "pnpm@8.14.1",
34
+ "packageManager": "pnpm@8.15.7",
35
35
  "keywords": [
36
36
  "release-it",
37
37
  "release-it config"
@@ -18,19 +18,41 @@ class VersionFilePlugin extends Plugin {
18
18
  super(...args);
19
19
  this.setContext({ versionFile: path.resolve('./VERSION') });
20
20
  }
21
- init() {
21
+
22
+ getVersion() {
23
+ let isFilePresent = true;
22
24
  try {
23
25
  fs.accessSync(this.getContext('versionFile'));
24
26
  } catch {
25
- throw e('Skipping release: VERSION file not present.', false);
27
+ isFilePresent = false;
28
+ }
29
+
30
+ if (isFilePresent) {
31
+ const data = fs.readFileSync(this.getContext('versionFile'));
32
+ return data.toString().trim();
33
+ }
34
+ }
35
+
36
+ getIncrement({ latestVersion }) {
37
+ const newVersion = this.getVersion();
38
+ if (!newVersion && this.options.skipReleaseIfNotPresent) {
39
+ throw e('Skipping release: VERSION file not present.', '', false);
40
+ }
41
+ if (latestVersion === newVersion) {
42
+ throw e(
43
+ 'Skipping release: version from VERSION file was already released.',
44
+ '',
45
+ false,
46
+ );
26
47
  }
27
48
 
28
- const data = fs.readFileSync(this.getContext('versionFile'));
29
- const latestVersion = data.toString().trim();
30
- this.setContext({ latestVersion });
49
+ return newVersion || null;
50
+ }
51
+ getIncrementedVersion(...args) {
52
+ return this.getIncrement(...args);
31
53
  }
32
- getLatestVersion() {
33
- return this.getContext('latestVersion');
54
+ getIncrementedVersionCI(...args) {
55
+ return this.getIncrement(...args);
34
56
  }
35
57
  bump(version) {
36
58
  this.setContext({ version });