@cluerise/tools 4.2.1 → 5.0.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/README.md +1 -1
- package/dist/configs/.nvmrc +1 -1
- package/dist/configs/.prettierignore +6 -6
- package/dist/configs/_gitignore +2 -1
- package/dist/configs/eslint.config.js +12 -12
- package/dist/configs/release-cwd.config.cjs +26 -0
- package/dist/configs/release.config.js +8 -2
- package/dist/scripts/check-heroku-node-version/main.js +43 -14
- package/dist/scripts/create-commit-message/main.js +29 -22
- package/dist/scripts/format-commit-message/main.js +21 -18
- package/dist/scripts/init/main.js +66 -33
- package/dist/scripts/lint/main.js +42 -35
- package/dist/scripts/release/main.js +233 -34124
- package/dist/scripts/update-node-versions/main.js +44 -15
- package/package.json +4 -4
- package/dist/scripts/release/assets/index-BOULatd3.js +0 -50541
package/README.md
CHANGED
package/dist/configs/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
v24.
|
|
1
|
+
v24.3.0
|
|
@@ -18,6 +18,12 @@ worker-configuration.d.ts
|
|
|
18
18
|
# Dependencies
|
|
19
19
|
node_modules/
|
|
20
20
|
|
|
21
|
+
# .env, .envrc
|
|
22
|
+
.env
|
|
23
|
+
.env.*
|
|
24
|
+
.envrc
|
|
25
|
+
.envrc.*
|
|
26
|
+
|
|
21
27
|
# Git
|
|
22
28
|
.git/
|
|
23
29
|
|
|
@@ -35,12 +41,6 @@ yarn.lock
|
|
|
35
41
|
etc/
|
|
36
42
|
.DS_Store
|
|
37
43
|
|
|
38
|
-
# Sample of .env file
|
|
39
|
-
.env.example
|
|
40
|
-
.env.sample
|
|
41
|
-
.envrc.example
|
|
42
|
-
.envrc.sample
|
|
43
|
-
|
|
44
44
|
# Stryker
|
|
45
45
|
.stryker-tmp/
|
|
46
46
|
|
package/dist/configs/_gitignore
CHANGED
|
@@ -50,7 +50,7 @@ export default defineConfig([
|
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
name: 'cluerise: typescript-eslint/disable-type-checked',
|
|
53
|
-
files: ['**/*.html', '**/*.js', '**/*.json', '**/*.jsonc', '**/*.yaml'],
|
|
53
|
+
files: ['**/*.html', '**/*.js', '**/*.cjs', '**/*.json', '**/*.jsonc', '**/*.yaml'],
|
|
54
54
|
extends: [typescriptEslint.configs.disableTypeChecked]
|
|
55
55
|
},
|
|
56
56
|
{
|
|
@@ -118,7 +118,7 @@ export default defineConfig([
|
|
|
118
118
|
// Import
|
|
119
119
|
{
|
|
120
120
|
name: 'cluerise: eslint/import/js',
|
|
121
|
-
files: ['**/*.js'],
|
|
121
|
+
files: ['**/*.js', '**/*.cjs'],
|
|
122
122
|
extends: [eslintPluginImport.flatConfigs.recommended],
|
|
123
123
|
rules: {
|
|
124
124
|
'import/first': 'error',
|
|
@@ -152,16 +152,16 @@ export default defineConfig([
|
|
|
152
152
|
}
|
|
153
153
|
},
|
|
154
154
|
{
|
|
155
|
-
name: 'cluerise: eslint/import/rules/config.js',
|
|
156
|
-
files: ['**/*.config.js'],
|
|
155
|
+
name: 'cluerise: eslint/import/rules/config.js,cjs',
|
|
156
|
+
files: ['**/*.config.{js,cjs}'],
|
|
157
157
|
rules: {
|
|
158
158
|
'@typescript-eslint/no-require-imports': 'off',
|
|
159
159
|
'import/no-commonjs': 'off'
|
|
160
160
|
}
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
|
-
name: 'cluerise: eslint/import/rules/config.js,ts',
|
|
164
|
-
files: ['**/*.config.{js,ts}'],
|
|
163
|
+
name: 'cluerise: eslint/import/rules/config.js,cjs,ts',
|
|
164
|
+
files: ['**/*.config.{js,cjs,ts}'],
|
|
165
165
|
rules: {
|
|
166
166
|
'import/no-default-export': 'off'
|
|
167
167
|
}
|
|
@@ -285,6 +285,12 @@ export default defineConfig([
|
|
|
285
285
|
// Dependencies
|
|
286
286
|
'**/node_modules/',
|
|
287
287
|
|
|
288
|
+
// .env, .envrc
|
|
289
|
+
'**/.env',
|
|
290
|
+
'**/.env.*',
|
|
291
|
+
'**/.envrc',
|
|
292
|
+
'**/.envrc.*',
|
|
293
|
+
|
|
288
294
|
// Fonts
|
|
289
295
|
'**/*.ttf',
|
|
290
296
|
'**/*.woff2',
|
|
@@ -322,12 +328,6 @@ export default defineConfig([
|
|
|
322
328
|
'**/etc/',
|
|
323
329
|
'**/.DS_Store',
|
|
324
330
|
|
|
325
|
-
// Sample of .env and .envrc files
|
|
326
|
-
'**/.env.example',
|
|
327
|
-
'**/.env.sample',
|
|
328
|
-
'**/.envrc.example',
|
|
329
|
-
'**/.envrc.sample',
|
|
330
|
-
|
|
331
331
|
// Stryker
|
|
332
332
|
'**/.stryker-tmp/',
|
|
333
333
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const Path = require('node:path');
|
|
2
|
+
|
|
3
|
+
const modulesNames = Object.keys(require.cache).filter((path) =>
|
|
4
|
+
Path.posix.normalize(path).endsWith('/git-log-parser/src/index.js')
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
for (const moduleName of modulesNames) {
|
|
8
|
+
const { parse, __patched = false } = require.cache[moduleName].exports;
|
|
9
|
+
if (__patched) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
require.cache[moduleName].exports.__patched = true;
|
|
14
|
+
|
|
15
|
+
require.cache[moduleName].exports.parse = (config, options) => {
|
|
16
|
+
if (Array.isArray(config._)) {
|
|
17
|
+
config._.push(options.cwd);
|
|
18
|
+
} else if (config._) {
|
|
19
|
+
config._ = [config._, options.cwd];
|
|
20
|
+
} else {
|
|
21
|
+
config._ = options.cwd;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return parse(config, options);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import Path from 'node:path';
|
|
2
|
+
import Url from 'node:url';
|
|
3
|
+
|
|
1
4
|
export const defaultReleaseRules = [
|
|
2
5
|
{ breaking: true, release: 'major' },
|
|
3
6
|
{ type: 'feat', release: 'minor' },
|
|
@@ -24,8 +27,9 @@ export const defaultChangelogTypes = [
|
|
|
24
27
|
const getRepositoryUrl = (path) => {
|
|
25
28
|
const pathSegments = path.split('/');
|
|
26
29
|
const rootSegments = pathSegments.filter((segments) => segments.trim().length > 0).map(() => '..');
|
|
30
|
+
const rootPath = Path.join(process.cwd(), ...rootSegments);
|
|
27
31
|
|
|
28
|
-
return
|
|
32
|
+
return Url.pathToFileURL(rootPath).href;
|
|
29
33
|
};
|
|
30
34
|
|
|
31
35
|
export const createReleaseConfig = ({
|
|
@@ -33,14 +37,16 @@ export const createReleaseConfig = ({
|
|
|
33
37
|
owner,
|
|
34
38
|
repository,
|
|
35
39
|
path = '',
|
|
40
|
+
tagFormat,
|
|
36
41
|
releaseRules = defaultReleaseRules,
|
|
37
42
|
changelogTypes = defaultChangelogTypes
|
|
38
43
|
}) => ({
|
|
44
|
+
extends: [Path.join(import.meta.dirname, 'release-cwd.config.cjs')],
|
|
39
45
|
branches: ['main'],
|
|
40
46
|
repositoryUrl: getRepositoryUrl(path),
|
|
47
|
+
tagFormat,
|
|
41
48
|
preset: 'conventionalcommits',
|
|
42
49
|
dryRun: true,
|
|
43
|
-
commitPath: path,
|
|
44
50
|
|
|
45
51
|
plugins: [
|
|
46
52
|
[
|
|
@@ -9,19 +9,19 @@ class GitProvider {
|
|
|
9
9
|
static #origins = gitProviderOrigins;
|
|
10
10
|
static #names = Object.keys(this.#origins);
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Check if the provided name is a valid Git provider name.
|
|
13
13
|
*
|
|
14
|
-
* @param name
|
|
15
|
-
* @returns True if the name is valid, false
|
|
14
|
+
* @param name The name to check.
|
|
15
|
+
* @returns True if the name is valid, otherwise false.
|
|
16
16
|
*/
|
|
17
17
|
static isValidName(name) {
|
|
18
18
|
return this.#names.includes(name);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Get the origin URL for the given Git provider name.
|
|
22
22
|
*
|
|
23
|
-
* @param name
|
|
24
|
-
* @returns The origin URL
|
|
23
|
+
* @param name The Git provider name.
|
|
24
|
+
* @returns The origin URL.
|
|
25
25
|
*/
|
|
26
26
|
static getOrigin(name) {
|
|
27
27
|
return this.#origins[name];
|
|
@@ -48,6 +48,13 @@ class PackageJson {
|
|
|
48
48
|
constructor(data) {
|
|
49
49
|
this.#data = data;
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Load and parse the `package.json` file, returning a `PackageJson` instance.
|
|
53
|
+
*
|
|
54
|
+
* Throws an error if the file is invalid or cannot be parsed.
|
|
55
|
+
*
|
|
56
|
+
* @returns A new `PackageJson` instance with parsed data.
|
|
57
|
+
*/
|
|
51
58
|
static async init() {
|
|
52
59
|
const content = await FileSystem.readFile("package.json", { encoding: "utf8" });
|
|
53
60
|
const data = JsonUtils.parse(content);
|
|
@@ -60,21 +67,41 @@ class PackageJson {
|
|
|
60
67
|
return new PackageJson(data);
|
|
61
68
|
}
|
|
62
69
|
/**
|
|
63
|
-
*
|
|
70
|
+
* Get the package name from `package.json`.
|
|
71
|
+
*
|
|
72
|
+
* @returns The package name.
|
|
73
|
+
*/
|
|
74
|
+
get name() {
|
|
75
|
+
return this.#data.name;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get the package version from `package.json`.
|
|
79
|
+
*
|
|
80
|
+
* @returns The package version.
|
|
81
|
+
*/
|
|
82
|
+
get version() {
|
|
83
|
+
return this.#data.version;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the engines field from `package.json`, if present.
|
|
87
|
+
*
|
|
88
|
+
* @returns The engines object or undefined.
|
|
64
89
|
*/
|
|
65
90
|
get engines() {
|
|
66
91
|
return this.#data.engines;
|
|
67
92
|
}
|
|
68
93
|
/**
|
|
69
|
-
*
|
|
94
|
+
* Set the engines field in `package.json`.
|
|
70
95
|
*
|
|
71
|
-
* @param engines
|
|
96
|
+
* @param engines The engines object to set.
|
|
72
97
|
*/
|
|
73
98
|
set engines(engines) {
|
|
74
99
|
this.#data.engines = engines;
|
|
75
100
|
}
|
|
76
101
|
/**
|
|
77
|
-
*
|
|
102
|
+
* Get the repository field from `package.json`, if present.
|
|
103
|
+
*
|
|
104
|
+
* @returns The repository object or string, or undefined.
|
|
78
105
|
*/
|
|
79
106
|
get repository() {
|
|
80
107
|
return this.#data.repository;
|
|
@@ -111,9 +138,11 @@ class PackageJson {
|
|
|
111
138
|
throw new Error("Unsupported repository URL");
|
|
112
139
|
}
|
|
113
140
|
/**
|
|
114
|
-
*
|
|
141
|
+
* Parse the repository information from `package.json` and return a `GitRepository` object or null.
|
|
142
|
+
*
|
|
143
|
+
* Returns null if no repository is defined or if parsing fails.
|
|
115
144
|
*
|
|
116
|
-
* @returns The parsed GitRepository or null if
|
|
145
|
+
* @returns The parsed `GitRepository`, or null if not available.
|
|
117
146
|
*/
|
|
118
147
|
parseGitRepository() {
|
|
119
148
|
if (!this.repository) {
|
|
@@ -125,7 +154,7 @@ class PackageJson {
|
|
|
125
154
|
return this.#parseGitRepository(this.repository.url);
|
|
126
155
|
}
|
|
127
156
|
/**
|
|
128
|
-
*
|
|
157
|
+
* Save the current `package.json` data to disk, formatting it as prettified JSON.
|
|
129
158
|
*/
|
|
130
159
|
async save() {
|
|
131
160
|
const content = JsonUtils.prettify(this.#data) + "\n";
|
|
@@ -165,7 +194,7 @@ const herokuNodeReleasesSchema = z.object({
|
|
|
165
194
|
class Heroku {
|
|
166
195
|
static #nodeReleasesUrl = "https://raw.githubusercontent.com/heroku/heroku-buildpack-nodejs/latest/inventory/node.toml";
|
|
167
196
|
/**
|
|
168
|
-
*
|
|
197
|
+
* Fetch supported Node.js releases on Heroku.
|
|
169
198
|
*
|
|
170
199
|
* @returns A promise that resolves to an array of HerokuNodeRelease objects.
|
|
171
200
|
*/
|
|
@@ -31,10 +31,12 @@ const runMain = (main2) => {
|
|
|
31
31
|
};
|
|
32
32
|
class StringUtils {
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Capitalize the first letter of a given string.
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
36
|
+
* If the string is empty, it is returned unchanged.
|
|
37
|
+
*
|
|
38
|
+
* @param value The string to capitalize.
|
|
39
|
+
* @returns The string with the first letter capitalized, or the original string if empty.
|
|
38
40
|
*/
|
|
39
41
|
static capitalize(value) {
|
|
40
42
|
const [firstLetter] = value;
|
|
@@ -46,17 +48,21 @@ class StringUtils {
|
|
|
46
48
|
}
|
|
47
49
|
class Git {
|
|
48
50
|
/**
|
|
49
|
-
*
|
|
51
|
+
* Get the name of the current branch in the git repository.
|
|
52
|
+
*
|
|
53
|
+
* Uses `git symbolic-ref --short HEAD` to determine the branch name.
|
|
50
54
|
*
|
|
51
|
-
* @returns The
|
|
55
|
+
* @returns The current branch name.
|
|
52
56
|
*/
|
|
53
57
|
static getBranchName() {
|
|
54
58
|
return ChildProcess.execSync("git symbolic-ref --short HEAD").toString().trim();
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
57
|
-
*
|
|
61
|
+
* Check if the repository is currently in a rebase state.
|
|
58
62
|
*
|
|
59
|
-
*
|
|
63
|
+
* Checks for the presence of a rebase directory in the git directory.
|
|
64
|
+
*
|
|
65
|
+
* @returns True if rebasing, otherwise false.
|
|
60
66
|
*/
|
|
61
67
|
static isRebasing() {
|
|
62
68
|
try {
|
|
@@ -73,7 +79,7 @@ class CommitLinter {
|
|
|
73
79
|
this.#config = config;
|
|
74
80
|
}
|
|
75
81
|
/**
|
|
76
|
-
*
|
|
82
|
+
* Initialize the CommitLinter with the loaded commitlint configuration.
|
|
77
83
|
*
|
|
78
84
|
* @returns A Promise that resolves to an instance of CommitLinter.
|
|
79
85
|
*/
|
|
@@ -82,9 +88,9 @@ class CommitLinter {
|
|
|
82
88
|
return new CommitLinter(config);
|
|
83
89
|
}
|
|
84
90
|
/**
|
|
85
|
-
*
|
|
91
|
+
* Lint commit messages using commitlint.
|
|
86
92
|
*
|
|
87
|
-
* @param args
|
|
93
|
+
* @param args An array of arguments to pass to commitlint.
|
|
88
94
|
* @returns The exit status of the commitlint command.
|
|
89
95
|
*/
|
|
90
96
|
static lint(args) {
|
|
@@ -109,9 +115,9 @@ class CommitLinter {
|
|
|
109
115
|
return this.#isValidEnumValue("scope-enum", scope);
|
|
110
116
|
}
|
|
111
117
|
/**
|
|
112
|
-
*
|
|
118
|
+
* Parse a semantic branch name into its type and scope.
|
|
113
119
|
*
|
|
114
|
-
* @param name
|
|
120
|
+
* @param name The branch name to parse.
|
|
115
121
|
* @returns An object containing the type and scope of the commit message.
|
|
116
122
|
* @throws An error if the branch name is invalid.
|
|
117
123
|
*/
|
|
@@ -128,12 +134,13 @@ class CommitLinter {
|
|
|
128
134
|
};
|
|
129
135
|
}
|
|
130
136
|
/**
|
|
131
|
-
*
|
|
137
|
+
* Get the prefix of a semantic commit message as a string.
|
|
132
138
|
*
|
|
133
139
|
* This prefix consists of the type and scope of the commit message.
|
|
134
140
|
* If the scope is not provided, it will only return the type.
|
|
135
|
-
*
|
|
136
|
-
* @
|
|
141
|
+
*
|
|
142
|
+
* @param prefix An object containing the type and scope of the commit message.
|
|
143
|
+
* @returns The stringified prefix.
|
|
137
144
|
*/
|
|
138
145
|
static stringifySemanticCommitMessagePrefix({ type, scope }) {
|
|
139
146
|
return `${type}${scope ? `(${scope})` : ""}`;
|
|
@@ -145,9 +152,9 @@ class CommitLinter {
|
|
|
145
152
|
return { prefix, content };
|
|
146
153
|
}
|
|
147
154
|
/**
|
|
148
|
-
*
|
|
155
|
+
* Format a semantic commit message by capitalizing the content after the prefix.
|
|
149
156
|
*
|
|
150
|
-
* @param message
|
|
157
|
+
* @param message The commit message to format.
|
|
151
158
|
* @returns The formatted commit message.
|
|
152
159
|
*/
|
|
153
160
|
static formatSemanticCommitMessage(message) {
|
|
@@ -158,20 +165,20 @@ class CommitLinter {
|
|
|
158
165
|
return `${prefix}: ${StringUtils.capitalize(content)}`;
|
|
159
166
|
}
|
|
160
167
|
/**
|
|
161
|
-
*
|
|
168
|
+
* Create a semantic commit message from a prefix and a message.
|
|
162
169
|
*
|
|
163
|
-
* @param prefix
|
|
164
|
-
* @param message
|
|
170
|
+
* @param prefix The prefix of the commit message, containing type and scope.
|
|
171
|
+
* @param message The content of the commit message.
|
|
165
172
|
* @returns The formatted semantic commit message.
|
|
166
173
|
*/
|
|
167
174
|
static createSemanticCommitMessage(prefix, message) {
|
|
168
175
|
const [subject, ...comments] = message.split("\n#");
|
|
169
176
|
let commitMessage = this.stringifySemanticCommitMessagePrefix(prefix) + ": ";
|
|
170
177
|
if (subject) {
|
|
171
|
-
commitMessage += StringUtils.capitalize(subject);
|
|
178
|
+
commitMessage += StringUtils.capitalize(subject.trim());
|
|
172
179
|
}
|
|
173
180
|
if (comments.length > 0) {
|
|
174
|
-
commitMessage += "\n\n#" + comments.join("\n#");
|
|
181
|
+
commitMessage += "\n\n#" + comments.map((comment) => comment.trim()).join("\n#");
|
|
175
182
|
}
|
|
176
183
|
return commitMessage;
|
|
177
184
|
}
|
|
@@ -31,10 +31,12 @@ const runMain = (main2) => {
|
|
|
31
31
|
};
|
|
32
32
|
class StringUtils {
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Capitalize the first letter of a given string.
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
36
|
+
* If the string is empty, it is returned unchanged.
|
|
37
|
+
*
|
|
38
|
+
* @param value The string to capitalize.
|
|
39
|
+
* @returns The string with the first letter capitalized, or the original string if empty.
|
|
38
40
|
*/
|
|
39
41
|
static capitalize(value) {
|
|
40
42
|
const [firstLetter] = value;
|
|
@@ -50,7 +52,7 @@ class CommitLinter {
|
|
|
50
52
|
this.#config = config;
|
|
51
53
|
}
|
|
52
54
|
/**
|
|
53
|
-
*
|
|
55
|
+
* Initialize the CommitLinter with the loaded commitlint configuration.
|
|
54
56
|
*
|
|
55
57
|
* @returns A Promise that resolves to an instance of CommitLinter.
|
|
56
58
|
*/
|
|
@@ -59,9 +61,9 @@ class CommitLinter {
|
|
|
59
61
|
return new CommitLinter(config);
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
62
|
-
*
|
|
64
|
+
* Lint commit messages using commitlint.
|
|
63
65
|
*
|
|
64
|
-
* @param args
|
|
66
|
+
* @param args An array of arguments to pass to commitlint.
|
|
65
67
|
* @returns The exit status of the commitlint command.
|
|
66
68
|
*/
|
|
67
69
|
static lint(args) {
|
|
@@ -86,9 +88,9 @@ class CommitLinter {
|
|
|
86
88
|
return this.#isValidEnumValue("scope-enum", scope);
|
|
87
89
|
}
|
|
88
90
|
/**
|
|
89
|
-
*
|
|
91
|
+
* Parse a semantic branch name into its type and scope.
|
|
90
92
|
*
|
|
91
|
-
* @param name
|
|
93
|
+
* @param name The branch name to parse.
|
|
92
94
|
* @returns An object containing the type and scope of the commit message.
|
|
93
95
|
* @throws An error if the branch name is invalid.
|
|
94
96
|
*/
|
|
@@ -105,12 +107,13 @@ class CommitLinter {
|
|
|
105
107
|
};
|
|
106
108
|
}
|
|
107
109
|
/**
|
|
108
|
-
*
|
|
110
|
+
* Get the prefix of a semantic commit message as a string.
|
|
109
111
|
*
|
|
110
112
|
* This prefix consists of the type and scope of the commit message.
|
|
111
113
|
* If the scope is not provided, it will only return the type.
|
|
112
|
-
*
|
|
113
|
-
* @
|
|
114
|
+
*
|
|
115
|
+
* @param prefix An object containing the type and scope of the commit message.
|
|
116
|
+
* @returns The stringified prefix.
|
|
114
117
|
*/
|
|
115
118
|
static stringifySemanticCommitMessagePrefix({ type, scope }) {
|
|
116
119
|
return `${type}${scope ? `(${scope})` : ""}`;
|
|
@@ -122,9 +125,9 @@ class CommitLinter {
|
|
|
122
125
|
return { prefix, content };
|
|
123
126
|
}
|
|
124
127
|
/**
|
|
125
|
-
*
|
|
128
|
+
* Format a semantic commit message by capitalizing the content after the prefix.
|
|
126
129
|
*
|
|
127
|
-
* @param message
|
|
130
|
+
* @param message The commit message to format.
|
|
128
131
|
* @returns The formatted commit message.
|
|
129
132
|
*/
|
|
130
133
|
static formatSemanticCommitMessage(message) {
|
|
@@ -135,20 +138,20 @@ class CommitLinter {
|
|
|
135
138
|
return `${prefix}: ${StringUtils.capitalize(content)}`;
|
|
136
139
|
}
|
|
137
140
|
/**
|
|
138
|
-
*
|
|
141
|
+
* Create a semantic commit message from a prefix and a message.
|
|
139
142
|
*
|
|
140
|
-
* @param prefix
|
|
141
|
-
* @param message
|
|
143
|
+
* @param prefix The prefix of the commit message, containing type and scope.
|
|
144
|
+
* @param message The content of the commit message.
|
|
142
145
|
* @returns The formatted semantic commit message.
|
|
143
146
|
*/
|
|
144
147
|
static createSemanticCommitMessage(prefix, message) {
|
|
145
148
|
const [subject, ...comments] = message.split("\n#");
|
|
146
149
|
let commitMessage = this.stringifySemanticCommitMessagePrefix(prefix) + ": ";
|
|
147
150
|
if (subject) {
|
|
148
|
-
commitMessage += StringUtils.capitalize(subject);
|
|
151
|
+
commitMessage += StringUtils.capitalize(subject.trim());
|
|
149
152
|
}
|
|
150
153
|
if (comments.length > 0) {
|
|
151
|
-
commitMessage += "\n\n#" + comments.join("\n#");
|
|
154
|
+
commitMessage += "\n\n#" + comments.map((comment) => comment.trim()).join("\n#");
|
|
152
155
|
}
|
|
153
156
|
return commitMessage;
|
|
154
157
|
}
|