Skip to content

Commit aa74bea

Browse files
committed
refactor: update commits config
1 parent ca98dd0 commit aa74bea

6 files changed

Lines changed: 47 additions & 33 deletions

File tree

lib/commands/git/commit-msg.js

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

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

9898
// check strict type
9999
if ( pkg.cliConfig?.commits.strictType ) {

lib/debian-repository.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default class DebianRepository {
8686
res = await git.exec( [ "init", "--initial-branch", "dists", this.distsRoot ] );
8787
if ( !res.ok ) return res;
8888

89-
res = await git.exec( [ "commit", "--allow-empty", "-m", "chore(build): init" ] );
89+
res = await git.exec( [ "commit", "--allow-empty", "-m", "build: init" ] );
9090
if ( !res.ok ) return res;
9191

9292
res = await git.exec( [ "push", "--set-upstream", upstream.sshCloneUrl, "dists" ] );
@@ -335,7 +335,7 @@ export default class DebianRepository {
335335
if ( !res.ok ) return res;
336336

337337
// overwrite the first commit
338-
res = await this.git.exec( [ "commit", "--amend", "-m", "chore(build): update distributions" ] );
338+
res = await this.git.exec( [ "commit", "--amend", "-m", "build: update distributions" ] );
339339
if ( !res.ok ) return res;
340340

341341
// push

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", "chore(deps): update package dependencies" ] );
985+
const res = await this.git.exec( [ "commit", "-m", "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", "chore(metadata): update package metadata" ] );
1338+
res = await this.git.exec( [ "commit", "-m", "metadata: update package metadata" ] );
13391339
if ( !res.ok ) return res;
13401340

13411341
// push

lib/package/release.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export default class Publish {
179179
res = await repeatAction( async () => {
180180
process.stdout.write( "Commiting docs ... " );
181181

182-
const res = await this.#pkg.git.exec( [ "commit", "-m", `chore(docs): update docs` ] );
182+
const res = await this.#pkg.git.exec( [ "commit", "-m", `docs: update docs` ] );
183183

184184
console.log( res + "" );
185185

@@ -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", `chore(release): release ${ this.#currentRelease.versionString }\n\n${ this.#changelogText }\n` ] );
212+
const res = await this.#pkg.git.exec( [ "commit", "--cleanup=verbatim", "-m", `release: release ${ this.#currentRelease.versionString }\n\n${ this.#changelogText }\n` ] );
213213

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

resources/cli.config.yaml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,36 @@ commits:
7878
notableChange: false
7979
requireScope: true
8080
strictScope: true
81+
82+
build:
83+
description: package build related changes
84+
requireScope: true
85+
strictScope: true
8186
chore:
8287
description: a commit that does not affect main codebase
83-
primaryChange: false
84-
notableChange: false
88+
requireScope: true
89+
strictScope: true
90+
deps:
91+
description: package dependencies updates
92+
requireScope: true
93+
strictScope: true
94+
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
104+
requireScope: true
105+
strictScope: true
106+
style:
107+
description: code stylistic changes
85108
requireScope: true
86109
strictScope: true
87110

88-
primaryScopes: ~
89-
90-
secondaryScopes:
91-
build: package build related changes
92-
deps: package dependencies updates
93-
docs: documentation changes
94-
metadata: package metadata changes
95-
release: package release
96-
style: code stylistic changes
111+
scopes: ~
97112

98113
docs: ~

resources/schemas/cli.config.schema.yaml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,20 +161,19 @@ properties:
161161
notableChange: { type: boolean }
162162
requireScope: { type: boolean }
163163
strictScope: { type: boolean }
164+
scopes:
165+
anyOf:
166+
- type: "null"
167+
- type: object
168+
propertyNames: { type: string, format: kebab-case }
169+
additionalProperties:
170+
anyOf:
171+
- const: false
172+
- type: string
164173
additionalProperties: false
165-
required: [description, primaryChange, notableChange, requireScope, strictScope]
174+
required: [description]
166175

167-
primaryScopes:
168-
anyOf:
169-
- type: "null"
170-
- type: object
171-
propertyNames: { type: string, format: kebab-case }
172-
additionalProperties:
173-
anyOf:
174-
- const: false
175-
- type: string
176-
177-
secondaryScopes:
176+
scopes:
178177
anyOf:
179178
- type: "null"
180179
- type: object
@@ -185,7 +184,7 @@ properties:
185184
- type: string
186185

187186
additionalProperties: false
188-
required: [requireType, strictType, types, primaryScopes, secondaryScopes]
187+
required: [requireType, strictType, types, scopes]
189188

190189
docs:
191190
anyOf:

0 commit comments

Comments
 (0)