Skip to content

Commit 6f3ed08

Browse files
committed
feat: refactor commits
1 parent 324bff6 commit 6f3ed08

8 files changed

Lines changed: 64 additions & 65 deletions

File tree

lib/commands/git/commit-msg.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ git commit -m"feat(core)!: commit description"
9191
}
9292

9393
const type = types[ commit.type ],
94-
scopes = new Map( Object.entries( type?.primaryChange
94+
scopes = new Map( Object.entries( type?.productionChange
9595
? pkg.cliConfig?.commits.scopes || {}
9696
: type?.scopes || {} ).filter( ( [ key, value ] ) => value ) );
9797

@@ -127,9 +127,9 @@ git commit -m"feat(core)!: commit description"
127127
return this.#throwError( `Commit scope is required. Allowed scopes for this commit type are:\n${ this.#getAllowedScopes( scopes ) }` );
128128
}
129129

130-
// restrict breaking changes to the primary changes only
131-
if ( commit.isBreakingChange && type && !type.primaryChange ) {
132-
return this.#throwError( `Breaking change flag can be set for primary changes only.` );
130+
// restrict breaking changes to the production changes only
131+
if ( commit.isBreakingChange && type && !type.productionChange ) {
132+
return this.#throwError( `Breaking change flag can be set for production changes only.` );
133133
}
134134
}
135135

@@ -149,12 +149,12 @@ git commit -m"feat(core)!: commit description"
149149
// private
150150
#getAllowedTypes ( types ) {
151151
return Object.values( types )
152-
.map( type => ` - "${ type.type }": ${ type.description };` )
152+
.map( type => ` - "${ type.type }": ${ type.description }` )
153153
.join( "\n" );
154154
}
155155

156156
#getAllowedScopes ( scopes ) {
157-
return [ ...scopes.keys() ].map( scope => ` - "${ scope }": ${ scopes.get( scope ) };` ).join( "\n" );
157+
return [ ...scopes.keys() ].map( scope => ` - "${ scope }": ${ scopes.get( scope ) }` ).join( "\n" );
158158
}
159159

160160
#throwError ( message ) {

lib/git/changelog.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import Markdown from "#core/markdown";
44
import { resolve } from "#core/utils";
55

66
const TITLES = {
7-
"feat": "New features",
8-
"fix": "Fixes",
9-
"refactor": "Refactoring",
7+
"feat": "New features or functionality",
8+
"fix": "Bug fixes",
9+
"refactor": "Code refactoring",
1010
},
1111
DEFAULT_COMMIT_TYPES = {
1212
"feat": {
13-
"primaryChange": true,
13+
"productionChange": true,
1414
"notableChange": true,
1515
},
1616
"fix": {
17-
"primaryChange": true,
17+
"productionChange": true,
1818
"notableChange": true,
1919
},
2020
};
@@ -113,7 +113,7 @@ export default class GitChangelog {
113113

114114
for ( const change of group.changes ) {
115115
lines.push( `- ${ change.getChangelogSubject( {
116-
"withSemanticVersionType": group.primaryChange,
116+
"withSemanticVersionType": group.productionChange,
117117
"withCommits": true,
118118
} ) }` );
119119
}
@@ -200,13 +200,13 @@ export default class GitChangelog {
200200
return commitTypes;
201201
}, {} );
202202

203-
// index primary types
204-
const primaryTypes = new Map();
203+
// index production types
204+
const productionTypes = new Map();
205205

206-
for ( const [ type, { title, primaryChange } ] of Object.entries( commitTypes ) ) {
207-
if ( !primaryChange ) continue;
206+
for ( const [ type, { title, productionChange } ] of Object.entries( commitTypes ) ) {
207+
if ( !productionChange ) continue;
208208

209-
primaryTypes.set( type, title || TITLES[ type ] || type.charAt( 0 ).toUpperCase() + type.slice( 1 ) );
209+
productionTypes.set( type, title || TITLES[ type ] || type.charAt( 0 ).toUpperCase() + type.slice( 1 ) );
210210
}
211211

212212
// breaking changes
@@ -221,12 +221,12 @@ export default class GitChangelog {
221221
"name": "Breaking changes",
222222
"changes": breakingChanges,
223223
"report": true,
224-
"primaryChange": true,
224+
"productionChange": true,
225225
"showAnnotatiion": true,
226226
} );
227227

228-
// primary changes
229-
for ( const [ type, title ] of primaryTypes.entries() ) {
228+
// production changes
229+
for ( const [ type, title ] of productionTypes.entries() ) {
230230
const changes = this.#changes.getChanges( change => !change.isBreakingChange && change.type === type );
231231

232232
// notable change
@@ -238,17 +238,17 @@ export default class GitChangelog {
238238
"name": title,
239239
changes,
240240
"report": commitTypes[ type ].notableChange,
241-
"primaryChange": true,
241+
"productionChange": true,
242242
"showAnnotatiion": true,
243243
} );
244244
}
245245

246246
// secondary changes
247247
this.#changesGroups.push( {
248248
"name": "Other changes",
249-
"changes": this.#changes.getChanges( change => !change.isBreakingChange && !primaryTypes.has( change.type ) && !change.isReleaseChange ),
249+
"changes": this.#changes.getChanges( change => !change.isBreakingChange && !productionTypes.has( change.type ) && !change.isReleaseChange ),
250250
"report": true,
251-
"primaryChange": false,
251+
"productionChange": false,
252252
"showAnnotatiion": true,
253253
} );
254254

@@ -257,7 +257,7 @@ export default class GitChangelog {
257257
"name": "Included pre-releases",
258258
"changes": this.#changes.getChanges( change => change.isReleaseChange ),
259259
"report": false,
260-
"primaryChange": false,
260+
"productionChange": false,
261261
"showAnnotatiion": false,
262262
} );
263263
}

lib/package.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ export default class Package {
982982

983983
// commit changes
984984
res = await repeatAction( async () => {
985-
const res = await this.git.exec( [ "commit", "-m", "deps: update package dependencies" ] );
985+
const res = await this.git.exec( [ "commit", "-m", "chore(deps): update package dependencies" ] );
986986

987987
if ( !res.ok ) console.log( ansi.error( res + "" ) );
988988

@@ -1335,7 +1335,7 @@ export default class Package {
13351335
if ( !res.ok ) return res;
13361336

13371337
// commit changes
1338-
res = await this.git.exec( [ "commit", "-m", "metadata: update package metadata" ] );
1338+
res = await this.git.exec( [ "commit", "-m", "chore(metadata): update package metadata" ] );
13391339
if ( !res.ok ) return res;
13401340

13411341
// push

lib/package/release.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export default class Publish {
209209
res = await repeatAction( async () => {
210210
process.stdout.write( "Commiting ... " );
211211

212-
const res = await this.#pkg.git.exec( [ "commit", "--cleanup=verbatim", "-m", `release: release ${ this.#currentRelease.versionString }\n\n${ this.#changelogText }\n` ] );
212+
const res = await this.#pkg.git.exec( [ "commit", "--cleanup=verbatim", "-m", `build(release): release ${ this.#currentRelease.versionString }\n\n${ this.#changelogText }\n` ] );
213213

214214
console.log( res + "" );
215215

npm-shrinkwrap.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/cli.config.yaml

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,52 +59,51 @@ commits:
5959
requireType: true
6060
strictType: true
6161

62+
# DOCS: https://www.bavaga.com/blog/2025/01/27/my-ultimate-conventional-commit-types-cheatsheet/
6263
types:
6364
feat:
64-
description: a commit that introduces a new feature to the codebase (MINOR in Semantic Versioning)
65-
primaryChange: true
65+
description: Uused for adding new features or functionality. (MINOR in semantic versioning).
66+
productionChange: true
6667
notableChange: true
6768
requireScope: true
6869
strictScope: true
6970
fix:
70-
description: a commit that patches a bug in your codebase (PATCH in Semantic Versioning)
71-
primaryChange: true
71+
description: Used to address actual bugs that cause incorrect behavior in production code. (PATCH in semantic versioning).
72+
productionChange: true
7273
notableChange: true
7374
requireScope: true
7475
strictScope: true
7576
refactor:
76-
description: a code change that neither fixes a bug nor adds a feature
77-
primaryChange: true
77+
description: Is for structural improvements to the code without changing its behavior. Unlike style, refactor focuses on enhancing the internal structure, logic, or organization of the code without altering its external behavior.
78+
productionChange: true
7879
notableChange: false
7980
requireScope: true
8081
strictScope: true
8182

8283
build:
83-
description: package build related changes
84-
requireScope: true
84+
title: Build process or dependencies
85+
description: Should be used for changes that impact the build process or production dependencies, including tools and configurations necessary for application deployment or runtime.
86+
requireScope: false
8587
strictScope: true
88+
scopes:
89+
deps: Changing or upgrading dependencies that affect production code.
90+
release: Releasing code.
8691
chore:
87-
description: a commit that does not affect main codebase
88-
requireScope: true
89-
strictScope: true
90-
deps:
91-
description: package dependencies updates
92-
requireScope: true
92+
title: Maintenance and routine tasks
93+
description: Used for administrative or supportive tasks that do not impact production code.
94+
requireScope: false
9395
strictScope: true
96+
scopes:
97+
deps: Updating development dependencies.
98+
metadata: Updating package metadata.
9499
docs:
95-
description: documentation changes
96-
requireScope: true
97-
strictScope: true
98-
metadata:
99-
description: package metadata changes
100-
requireScope: true
101-
strictScope: true
102-
release:
103-
description: package release
100+
title: Documentation
101+
description: Used for changes to documentation, comments, or API descriptions.
104102
requireScope: true
105103
strictScope: true
106104
style:
107-
description: code stylistic changes
105+
title: Code formatting and style-only changes
106+
description: Is for cosmetic changes to code that do not affect its behavior. Style changes are purely superficial and do not affect the structure, semantics, or functionality of the code.
108107
requireScope: true
109108
strictScope: true
110109

resources/schemas/cli.config.schema.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ properties:
157157
properties:
158158
title: { type: string }
159159
description: { type: string }
160-
primaryChange: { type: boolean }
160+
productionChange: { type: boolean }
161161
notableChange: { type: boolean }
162162
requireScope: { type: boolean }
163163
strictScope: { type: boolean }

resources/templates/changelog.md.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ See the list of the breaking changes below for details.
1212
**<%- group.name %>:**
1313
<%_ for ( const change of group.changes ) { -%>
1414
15-
- <%- change.getChangelogSubject( { "withSemanticVersionType": group.primaryChange, "withCommits": true } ) %>
15+
- <%- change.getChangelogSubject( { "withSemanticVersionType": group.productionChange, "withCommits": true } ) %>
1616
<%_ if ( group.showAnnotatiion && change.bodyText ) { -%>
1717
1818
<%- change.bodyText.replaceAll( /^(?!$)/gm, " ".repeat( 4 ) ) %>

0 commit comments

Comments
 (0)