Skip to content

Commit c422043

Browse files
committed
perf(projects): filter commits means that release version
1 parent cad052d commit c422043

File tree

7 files changed

+29
-92
lines changed

7 files changed

+29
-92
lines changed

.vscode/extensions.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
{
22
"recommendations": [
3-
"afzalsayed96.icones",
4-
"antfu.iconify",
53
"antfu.unocss",
6-
"christian-kohler.path-intellisense",
74
"dbaeumer.vscode-eslint",
8-
"eamodio.gitlens",
95
"editorconfig.editorconfig",
106
"esbenp.prettier-vscode",
117
"formulahendry.auto-complete-tag",
@@ -14,13 +10,8 @@
1410
"kisstkondoros.vscode-gutter-preview",
1511
"mariusalchimavicius.json-to-ts",
1612
"mhutchie.git-graph",
17-
"mikestead.dotenv",
18-
"naumovs.color-highlight",
19-
"pkief.material-icon-theme",
2013
"sdras.vue-vscode-snippets",
2114
"vue.volar",
22-
"vue.vscode-typescript-vue-plugin",
23-
"whtouche.vscode-js-console-utils",
24-
"zhuangtongfa.material-theme"
15+
"vue.vscode-typescript-vue-plugin"
2516
]
2617
}

.vscode/settings.json

Lines changed: 8 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,81 +4,20 @@
44
},
55
"editor.fontLigatures": true,
66
"editor.formatOnSave": false,
7-
"editor.guides.bracketPairs": "active",
87
"editor.quickSuggestions": {
98
"strings": true
109
},
1110
"editor.tabSize": 2,
12-
"eslint.validate": [
13-
"javascript",
14-
"javascriptreact",
15-
"typescript",
16-
"typescriptreact",
17-
"vue",
18-
"json",
19-
"svelte",
20-
"astro"
21-
],
11+
"eslint.validate": ["json"],
2212
"files.associations": {
23-
"*.env.*": "dotenv"
13+
"*.env.*": "dotenv",
14+
"*.svg": "html",
15+
".*rc": "json"
2416
},
2517
"files.eol": "\n",
26-
"git.enableSmartCommit": true,
27-
"gutterpreview.paths": {
28-
"@": "/src",
29-
"~@": "/src"
18+
"[html][css][less][scss][sass][markdown][yaml][yml][jsonc]": {
19+
"editor.defaultFormatter": "esbenp.prettier-vscode",
20+
"editor.formatOnSave": true
3021
},
31-
"material-icon-theme.activeIconPack": "angular",
32-
"material-icon-theme.files.associations": {},
33-
"material-icon-theme.folders.associations": {
34-
"src-tauri": "src",
35-
"enum": "typescript",
36-
"enums": "typescript",
37-
"store": "context",
38-
"stores": "context",
39-
"composable": "hook",
40-
"composables": "hook",
41-
"directive": "tools",
42-
"directives": "tools",
43-
"business": "core",
44-
"request": "api",
45-
"adapter": "middleware"
46-
},
47-
"path-intellisense.mappings": {
48-
"@": "${workspaceFolder}/src",
49-
"~@": "${workspaceFolder}/src"
50-
},
51-
"terminal.integrated.cursorStyle": "line",
52-
"terminal.integrated.fontSize": 14,
53-
"terminal.integrated.fontWeight": 500,
54-
"terminal.integrated.tabs.enabled": true,
55-
"workbench.iconTheme": "material-icon-theme",
56-
"workbench.colorTheme": "One Dark Pro",
57-
"[html]": {
58-
"editor.defaultFormatter": "esbenp.prettier-vscode"
59-
},
60-
"[json]": {
61-
"editor.defaultFormatter": "esbenp.prettier-vscode"
62-
},
63-
"[jsonc]": {
64-
"editor.defaultFormatter": "esbenp.prettier-vscode"
65-
},
66-
"[javascript]": {
67-
"editor.defaultFormatter": "esbenp.prettier-vscode"
68-
},
69-
"[javascriptreact]": {
70-
"editor.defaultFormatter": "esbenp.prettier-vscode"
71-
},
72-
"[markdown]": {
73-
"editor.defaultFormatter": "yzhang.markdown-all-in-one"
74-
},
75-
"[typescript]": {
76-
"editor.defaultFormatter": "esbenp.prettier-vscode"
77-
},
78-
"[typescriptreact]": {
79-
"editor.defaultFormatter": "esbenp.prettier-vscode"
80-
},
81-
"[vue]": {
82-
"editor.defaultFormatter": "Vue.volar"
83-
}
22+
"cSpell.words": ["creatordate", "execa", "gitmoji", "ofetch"]
8423
}

src/constant.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export const VERSION_REG = /v\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?/;
22

33
export const VERSION_REG_OF_MARKDOWN = /## \[v\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?]/g;
4+
5+
export const VERSION_WITH_RELEASE = /release\sv\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?/;

src/git.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ async function getGitDiff(from?: string, to = 'HEAD'): Promise<RawGitCommit[]> {
116116
const gitCommits = rwaGitLines.map(line => {
117117
const [firstLine, ...body] = line.split('\n');
118118
const [message, shortHash, authorName, authorEmail] = firstLine.split('|');
119-
const gitCommmit: RawGitCommit = {
119+
const gitCommit: RawGitCommit = {
120120
message,
121121
shortHash,
122122
author: { name: authorName, email: authorEmail },
123123
body: body.join('\n')
124124
};
125-
return gitCommmit;
125+
return gitCommit;
126126
});
127127

128128
return gitCommits;
@@ -167,9 +167,9 @@ function parseGitCommit(commit: RawGitCommit): GitCommit | null {
167167
// Find all authors
168168
const authors: GitCommitAuthor[] = [commit.author];
169169

170-
const matchs = commit.body.matchAll(CoAuthoredByRegex);
170+
const matches = commit.body.matchAll(CoAuthoredByRegex);
171171

172-
for (const $match of matchs) {
172+
for (const $match of matches) {
173173
const { name = '', email = '' } = $match.groups || {};
174174

175175
const author: GitCommitAuthor = {

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,5 @@ export async function generateTotalChangelog(options?: Partial<ChangelogOption>,
9494
}
9595

9696
export type { ChangelogOption };
97+
98+
getChangelogMarkdown();

src/markdown.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { readFile, writeFile } from 'fs/promises';
33
import dayjs from 'dayjs';
44
import { convert } from 'convert-gitmoji';
55
import { partition, groupBy, capitalize, join } from './shared';
6-
import { VERSION_REG, VERSION_REG_OF_MARKDOWN } from './constant';
6+
import { VERSION_REG, VERSION_WITH_RELEASE, VERSION_REG_OF_MARKDOWN } from './constant';
77
import type { Reference, GitCommit, ChangelogOption, ResolvedAuthor } from './types';
88

99
function formatReferences(references: Reference[], githubRepo: string, type: 'issues' | 'hash'): string {
@@ -108,7 +108,7 @@ function getGitUserAvatar(userName: string) {
108108

109109
function createContributorLine(contributors: ResolvedAuthor[]) {
110110
let loginLine = '';
111-
let unloginLine = '';
111+
let unLoginLine = '';
112112

113113
contributors.forEach((contributor, index) => {
114114
const { name, email, login } = contributor;
@@ -120,15 +120,15 @@ function createContributorLine(contributors: ResolvedAuthor[]) {
120120
line += ',&nbsp;';
121121
}
122122

123-
unloginLine += line;
123+
unLoginLine += line;
124124
} else {
125125
const githubUrl = getUserGithub(login);
126126
const avatar = getGitUserAvatar(login);
127127
loginLine += `[![${login}](${avatar})](${githubUrl})&nbsp;&nbsp;`;
128128
}
129129
});
130130

131-
return `${loginLine}\n${unloginLine}`;
131+
return `${loginLine}\n${unLoginLine}`;
132132
}
133133

134134
export function generateMarkdown(params: {
@@ -137,7 +137,10 @@ export function generateMarkdown(params: {
137137
showTitle: boolean;
138138
contributors: ResolvedAuthor[];
139139
}) {
140-
const { commits, options, showTitle, contributors } = params;
140+
const { options, showTitle, contributors } = params;
141+
142+
// filter commits means that release version
143+
const commits = params.commits.filter(commit => commit.description.match(VERSION_WITH_RELEASE) === null);
141144

142145
const lines: string[] = [];
143146

@@ -163,7 +166,7 @@ export function generateMarkdown(params: {
163166

164167
const group = groupBy(changes, 'type');
165168

166-
lines.push(...formatSection(breaking, options.titles.breakingChanges!, options));
169+
lines.push(...formatSection(breaking, options.titles.breakingChanges, options));
167170

168171
for (const type of Object.keys(options.types)) {
169172
const items = group[type] || [];

src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ export interface Reference {
4949
}
5050

5151
/**
52-
* the resolved githhub author
52+
* the resolved github author
5353
*/
5454
export interface ResolvedAuthor extends GitCommitAuthor {
5555
/**
5656
* the git commit of the author
5757
*/
5858
commits: string[];
5959
/**
60-
* the github logined username of the author
60+
* the github logged username of the author
6161
*/
6262
login: string;
6363
}
@@ -169,7 +169,7 @@ export interface ChangelogOption {
169169
*/
170170
regenerate: boolean;
171171
/**
172-
* version from package.json, with preffix "v"
172+
* version from package.json, with prefix "v"
173173
* @description if the options "to" is not specified, the version will be used
174174
*/
175175
newVersion: string;

0 commit comments

Comments
 (0)