@ethima/semantic-release-configuration 4.1.0 → 4.1.2

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/README.md CHANGED
@@ -15,8 +15,8 @@ configuration supporting a range of languages and platforms supported by the
15
15
  [`@semantic-release/release-notes-generator`][semantic-release-notes-generator-plugin-url].
16
16
  - Updates templated content in files, e.g. a project's root-level `README.md`,
17
17
  with updated version information using
18
- [`@google/semantic-release-replace-plugin`][semantic-release-replace-plugin-url]
19
- and [`@semantic-release/git`][semantic-release-git-plugin-url].
18
+ [`semantic-release-replace-plugin`][semantic-release-replace-plugin-url] and
19
+ [`@semantic-release/git`][semantic-release-git-plugin-url].
20
20
  - Maintains a `CHANGELOG.md` from the generated release notes using
21
21
  [`@semantic-release/changelog`][semantic-release-changelog-plugin-url] and
22
22
  [`@semantic-release/git`][semantic-release-git-plugin-url].
@@ -25,8 +25,8 @@ configuration supporting a range of languages and platforms supported by the
25
25
  and [`@semantic-release/git`][semantic-release-git-plugin-url].
26
26
  - (Conditionally) maintains Julia package files, i.e. `version` fields in
27
27
  `Project.toml` files, using
28
- [`@google/semantic-release-replace-plugin`][semantic-release-replace-plugin-url]
29
- and [`@semantic-release/git`][semantic-release-git-plugin-url].
28
+ [`semantic-release-replace-plugin`][semantic-release-replace-plugin-url] and
29
+ [`@semantic-release/git`][semantic-release-git-plugin-url].
30
30
  - Publishes releases to the relevant hosting platform, i.e. GitHub or GitLab,
31
31
  using the platform-specific release plugins
32
32
  [`@semantic-release/github`][semantic-release-github-plugin-url] or
@@ -314,6 +314,6 @@ release by hand from the tag and changelog that was created by the
314
314
  [semantic-release-notes-generator-plugin-url]: https://github.com/semantic-release/release-notes-generator
315
315
  [semantic-release-npm-plugin-configuration-url]: https://github.com/semantic-release/npm#npm-registry-authentication
316
316
  [semantic-release-npm-plugin-url]: https://www.npmjs.com/package/@semantic-release/npm
317
- [semantic-release-replace-plugin-url]: https://github.com/google/semantic-release-replace-plugin
317
+ [semantic-release-replace-plugin-url]: https://github.com/jpoehnelt/semantic-release-replace-plugin
318
318
  [semantic-release-url]: https://semantic-release.gitbook.io/
319
319
  [semantic-versioning-prerelease-precedence-url]: https://semver.org/#spec-item-9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethima/semantic-release-configuration",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "description": "A shareable semantic release configuration supporting a range of languages and platforms supported by the Ethima organization.",
5
5
  "main": "./src/index.js",
6
6
  "repository": {
@@ -21,13 +21,13 @@
21
21
  },
22
22
  "homepage": "https://gitlab.com/ethima/semantic-release-configuration#readme",
23
23
  "dependencies": {
24
- "@google/semantic-release-replace-plugin": "1.2.0",
25
24
  "@semantic-release/changelog": "6.0.3",
26
25
  "@semantic-release/git": "10.0.1",
27
- "@semantic-release/github": "9.0.3",
28
- "@semantic-release/gitlab": "12.0.3",
29
- "conventional-changelog-conventionalcommits": "6.1.0",
30
- "cosmiconfig": "8.2.0"
26
+ "@semantic-release/github": "9.2.1",
27
+ "@semantic-release/gitlab": "12.0.6",
28
+ "conventional-changelog-conventionalcommits": "7.0.2",
29
+ "cosmiconfig": "8.3.6",
30
+ "semantic-release-replace-plugin": "1.2.7"
31
31
  },
32
32
  "devDependencies": {
33
33
  "ava": "5.3.1"
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Determines the type of branch for the provided `branch`, i.e. whether it
3
+ * represents a "maintenance" or a "prerelease" branch.
4
+ *
5
+ * @return object The `branch_prefix` and whether it `is_prerelease`.
6
+ */
7
+ function determinePrefixedBranchType(
8
+ branch,
9
+ { maintenance_branch_prefix, prerelease_branch_prefix },
10
+ ) {
11
+ if (branch.startsWith(maintenance_branch_prefix)) {
12
+ return { branch_prefix: maintenance_branch_prefix, is_prerelease: false };
13
+ } else {
14
+ return { branch_prefix: prerelease_branch_prefix, is_prerelease: true };
15
+ }
16
+ }
17
+
18
+ /**
19
+ * Determines the "branches" for a semantic-release configuration given the
20
+ * provided `configuration` for the shareable configuration. This ensures more
21
+ * (patterned) release branches can be supported than would typically be the
22
+ * case.
23
+ *
24
+ * The function is capable of dealing with "primary release branches", the
25
+ * corresponding "prerelease branch", and patterned "maintenance" and
26
+ * "prerelease" branches.
27
+ *
28
+ * @return array An array containing the determined branch configuration as the
29
+ * sole entry.
30
+ */
31
+ function BranchesConfiguration(branch, configuration) {
32
+ if (configuration.primary_release_branch === branch) {
33
+ return [branch];
34
+ }
35
+
36
+ if (configuration.prerelease_branch_prefix === branch) {
37
+ return [
38
+ configuration.primary_release_branch,
39
+ { name: branch, prerelease: configuration.prerelease_tag_suffix },
40
+ ];
41
+ }
42
+
43
+ const { branch_prefix, is_prerelease } = determinePrefixedBranchType(
44
+ branch,
45
+ configuration,
46
+ );
47
+
48
+ // The matching pattern is configured to match all allowed permutations of
49
+ // version specifications as closely as possible to ensure other permutations
50
+ // that look valid, e.g. `N.z.q`, do not also accidentally match
51
+ const branch_prefix_separator = configuration.branch_prefix_separator ?? "-";
52
+ const version_branch_matcher = new RegExp(
53
+ `^${branch_prefix}${branch_prefix_separator}(?<major>\\d+)(?<minor>\\.(\\d+|x|y))?(\\.(x|z))?$`,
54
+ );
55
+ if (version_branch_matcher.test(branch)) {
56
+ let {
57
+ groups: { major, minor },
58
+ } = branch.match(version_branch_matcher);
59
+
60
+ // Remove minor parts not representing digits, so they are not included in
61
+ // the returned `range`
62
+ const version_part_matcher = new RegExp("\\.\\d+");
63
+ if (!version_part_matcher.test(minor)) {
64
+ minor = "";
65
+ }
66
+
67
+ return [
68
+ configuration.primary_release_branch,
69
+ {
70
+ name: branch,
71
+ ...(is_prerelease
72
+ ? { prerelease: configuration.prerelease_tag_suffix }
73
+ : {}),
74
+ range: `${major}${minor}.x`,
75
+ },
76
+ ];
77
+ }
78
+
79
+ return [];
80
+ }
81
+
82
+ module.exports = BranchesConfiguration;
package/src/index.js CHANGED
@@ -39,7 +39,7 @@ try {
39
39
  accessSync("Project.toml");
40
40
  GIT_ASSETS.push("Project.toml");
41
41
  JULIA_PROJECT_TOML_PLUGIN.push([
42
- "@google/semantic-release-replace-plugin",
42
+ "semantic-release-replace-plugin",
43
43
  {
44
44
  replacements: [
45
45
  {
@@ -89,7 +89,7 @@ const SEMANTIC_RELEASE_CONFIGURATION = {
89
89
  },
90
90
  ],
91
91
  VersionedTemplatesConfiguration(
92
- CONFIGURATION.files_with_versioned_templates
92
+ CONFIGURATION.files_with_versioned_templates,
93
93
  ),
94
94
  ...NPM_PLUGIN,
95
95
  ...JULIA_PROJECT_TOML_PLUGIN,
@@ -103,7 +103,7 @@ const SEMANTIC_RELEASE_CONFIGURATION = {
103
103
  ],
104
104
  ...platformSpecificReleasePlugin(
105
105
  "GITHUB_ACTIONS",
106
- "@semantic-release/github"
106
+ "@semantic-release/github",
107
107
  ),
108
108
  ...platformSpecificReleasePlugin("GITLAB_CI", "@semantic-release/gitlab"),
109
109
  ],
@@ -99,14 +99,14 @@ function buildReplacement(
99
99
  _, // Index of match start
100
100
  _, // Searched text
101
101
  filename,
102
- context
102
+ context,
103
103
  ) {
104
104
  const { next_version_placeholder_token, template_continuation_token } =
105
105
  getTemplateTokenConfiguration(filename);
106
106
 
107
107
  const normalized_template = stripTemplateContinuationTokens(
108
108
  template_continuation_token,
109
- template
109
+ template,
110
110
  );
111
111
 
112
112
  return [
@@ -115,7 +115,7 @@ function buildReplacement(
115
115
  template_end,
116
116
  normalized_template.replaceAll(
117
117
  next_version_placeholder_token,
118
- context.nextRelease.version
118
+ context.nextRelease.version,
119
119
  ),
120
120
  replacement_end,
121
121
  ].join("");
@@ -155,7 +155,7 @@ function buildTemplateMatcher(filename) {
155
155
  ".*?",
156
156
  `(\n[^\n]*${replacement_end_token}[^\n]*?)`,
157
157
  ].join(""),
158
- "gs"
158
+ "gs",
159
159
  );
160
160
  }
161
161
 
@@ -190,7 +190,7 @@ function getTemplateTokenConfiguration(filename) {
190
190
  */
191
191
  function stripTemplateContinuationTokens(
192
192
  template_continuation_token,
193
- template
193
+ template,
194
194
  ) {
195
195
  // The capture group is only necessary when using this matcher in the context
196
196
  // of replacement, i.e. where all the matched content should be replaced by
@@ -198,7 +198,7 @@ function stripTemplateContinuationTokens(
198
198
  // largest common whitespace prefix for each line in the template
199
199
  const indented_continuation_token_matcher = `^(\\s*)${template_continuation_token}`;
200
200
  const continuation_prefix_matcher = new RegExp(
201
- `${indented_continuation_token_matcher}(?<prefix>\\s*)`
201
+ `${indented_continuation_token_matcher}(?<prefix>\\s*)`,
202
202
  );
203
203
 
204
204
  const prefix_lengths = template
@@ -213,7 +213,7 @@ function stripTemplateContinuationTokens(
213
213
 
214
214
  const largest_common_prefix_matcher = new RegExp(
215
215
  `${indented_continuation_token_matcher}\\s{${Math.min(...prefix_lengths)}}`,
216
- "gm"
216
+ "gm",
217
217
  );
218
218
 
219
219
  return template.replaceAll(largest_common_prefix_matcher, "$1");
@@ -221,12 +221,12 @@ function stripTemplateContinuationTokens(
221
221
 
222
222
  /**
223
223
  * Returns the semantic release configuration for the
224
- * `@google/semantic-release-replace-plugin` set up to replace specific tokens
225
- * with the next semantic release version in the provided {@param files}.
224
+ * `semantic-release-replace-plugin` set up to replace specific tokens with the
225
+ * next semantic release version in the provided {@param files}.
226
226
  */
227
227
  function VersionedTemplatesConfiguration(files) {
228
228
  return [
229
- "@google/semantic-release-replace-plugin",
229
+ "semantic-release-replace-plugin",
230
230
  {
231
231
  replacements: [
232
232
  {