@ethima/semantic-release-configuration 6.0.0 → 7.0.0-rc.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
@@ -20,9 +20,10 @@ configuration supporting a range of languages and platforms supported by the
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].
23
- - (Conditionally) maintains NPM package files, i.e. `package.json` and
24
- publishes using [`@semantic-release/npm`][semantic-release-npm-plugin-url]
25
- and [`@semantic-release/git`][semantic-release-git-plugin-url].
23
+ - (Conditionally) maintains NPM package files, i.e. `package.json`,
24
+ `package-lock.json` (if committed), and publishes using
25
+ [`@semantic-release/npm`][semantic-release-npm-plugin-url] and
26
+ [`@semantic-release/git`][semantic-release-git-plugin-url].
26
27
  - (Conditionally) maintains Julia package files, i.e. `version` fields in
27
28
  `Project.toml` files, using
28
29
  [`semantic-release-replace-plugin`][semantic-release-replace-plugin-url] and
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@ethima/semantic-release-configuration",
3
- "version": "6.0.0",
3
+ "version": "7.0.0-rc.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": {
7
7
  "type": "git",
8
8
  "url": "git+ssh://git@gitlab.com/ethima/semantic-release-configuration.git"
9
9
  },
10
+ "type": "module",
10
11
  "scripts": {
11
12
  "test": "ava"
12
13
  },
@@ -27,11 +28,15 @@
27
28
  "@semantic-release/gitlab": "13.0.0",
28
29
  "conventional-changelog-conventionalcommits": "7.0.2",
29
30
  "cosmiconfig": "8.3.6",
31
+ "execa": "8.0.1",
30
32
  "semantic-release-replace-plugin": "1.2.7"
31
33
  },
32
34
  "devDependencies": {
33
35
  "ava": "6.0.1"
34
36
  },
37
+ "peerDependencies": {
38
+ "semantic-release": ">= 22.0.7"
39
+ },
35
40
  "engines": {
36
41
  "node": ">= 20.8.1"
37
42
  }
package/src/branches.js CHANGED
@@ -28,7 +28,7 @@ function determinePrefixedBranchType(
28
28
  * @return array An array containing the determined branch configuration as the
29
29
  * sole entry.
30
30
  */
31
- function BranchesConfiguration(branch, configuration) {
31
+ export function BranchesConfiguration(branch, configuration) {
32
32
  if (configuration.primary_release_branch === branch) {
33
33
  return [branch];
34
34
  }
@@ -78,5 +78,3 @@ function BranchesConfiguration(branch, configuration) {
78
78
 
79
79
  return [];
80
80
  }
81
-
82
- module.exports = BranchesConfiguration;
@@ -1,5 +1,5 @@
1
- const { cosmiconfigSync } = require("cosmiconfig");
2
- const { env } = require("node:process");
1
+ import { cosmiconfigSync } from "cosmiconfig";
2
+ import { env } from "node:process";
3
3
 
4
4
  const CONFIGURATION_DEFAULTS = {
5
5
  // The character(s) to use to separate the prefix for maintenance and
@@ -27,6 +27,7 @@ const ethimaConfig = cosmiconfigSync("ethima").search();
27
27
  // sufficient for the current configuration needs, which tend to be simple
28
28
  // values and doing a deep merge would add currently unnecessary complexity.
29
29
  // This can be revisited once the need arises
30
- const CONFIGURATION = { ...CONFIGURATION_DEFAULTS, ...ethimaConfig?.config };
31
-
32
- module.exports = CONFIGURATION;
30
+ export const CONFIGURATION = {
31
+ ...CONFIGURATION_DEFAULTS,
32
+ ...ethimaConfig?.config,
33
+ };
package/src/index.js CHANGED
@@ -1,15 +1,29 @@
1
- const { accessSync } = require("node:fs");
2
- const { env } = require("node:process");
1
+ import { accessSync } from "node:fs";
2
+ import { env } from "node:process";
3
+ import { execa } from "execa";
3
4
 
4
- const BranchesConfiguration = require("./branches.js");
5
- const CONFIGURATION = require("./configuration.js");
6
- const VersionedTemplatesConfiguration = require("./versioned-templates.js");
5
+ import { BranchesConfiguration } from "./branches.js";
6
+ import { CONFIGURATION } from "./configuration.js";
7
+ import { VersionedTemplatesConfiguration } from "./versioned-templates.js";
7
8
 
8
9
  const GIT_ASSETS = [
9
10
  CONFIGURATION.changelog_filename,
10
11
  ...CONFIGURATION.files_with_versioned_templates,
11
12
  ];
12
13
 
14
+ /**
15
+ * Checks whether a file is being tracked by Git.
16
+ *
17
+ * @param {string} path The path to the file to verify for whether it's being
18
+ * tracked by Git.
19
+ *
20
+ * @return bool Whether the file is being tracked by Git.
21
+ */
22
+ async function isFileTrackedByGit(path) {
23
+ const { stdout } = await execa("git", ["ls-files", path]);
24
+ return stdout.includes(path);
25
+ }
26
+
13
27
  /*
14
28
  * Determines whether the provided plugin should be added to the semantic
15
29
  * release configuration based on the presence of select environment variables.
@@ -32,6 +46,10 @@ try {
32
46
  accessSync("package.json");
33
47
  GIT_ASSETS.push("package.json");
34
48
  NPM_PLUGIN.push("@semantic-release/npm");
49
+
50
+ if (isFileTrackedByGit("package-lock.json")) {
51
+ GIT_ASSETS.push("package-lock.json");
52
+ }
35
53
  } catch {}
36
54
 
37
55
  const JULIA_PROJECT_TOML_PLUGIN = [];
@@ -109,4 +127,4 @@ const SEMANTIC_RELEASE_CONFIGURATION = {
109
127
  ],
110
128
  };
111
129
 
112
- module.exports = SEMANTIC_RELEASE_CONFIGURATION;
130
+ export default SEMANTIC_RELEASE_CONFIGURATION;
@@ -1,4 +1,4 @@
1
- const { extname } = require("node:path");
1
+ import { extname } from "node:path";
2
2
 
3
3
  /**
4
4
  * The default configuration for tokens used by the {@link buildReplacement}
@@ -96,8 +96,8 @@ function buildReplacement(
96
96
  template,
97
97
  template_end,
98
98
  replacement_end,
99
- _, // Index of match start
100
- _, // Searched text
99
+ __, // Index of match start
100
+ ___, // Searched text
101
101
  filename,
102
102
  context,
103
103
  ) {
@@ -224,7 +224,7 @@ function stripTemplateContinuationTokens(
224
224
  * `semantic-release-replace-plugin` set up to replace specific tokens with the
225
225
  * next semantic release version in the provided {@param files}.
226
226
  */
227
- function VersionedTemplatesConfiguration(files) {
227
+ export function VersionedTemplatesConfiguration(files) {
228
228
  return [
229
229
  "semantic-release-replace-plugin",
230
230
  {
@@ -239,5 +239,3 @@ function VersionedTemplatesConfiguration(files) {
239
239
  },
240
240
  ];
241
241
  }
242
-
243
- module.exports = VersionedTemplatesConfiguration;