@govbr-ds/release-config 3.3.0 → 4.1.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 CHANGED
@@ -19,9 +19,9 @@ Configurações para o [Semantic Release](https://github.com/semantic-release/se
19
19
  1. Crie um arquivo `release.config.js` na raiz do seu projeto e importe os plugins que deseja usar:
20
20
 
21
21
  ```javascript
22
- const { branches, commitAnalyzer, releaseNotesGenerator, changelog, gitlab, git } = require('./node_modules/@govbr-ds/config-tools/src/semantic-release.cjs')
22
+ import { branches, commitAnalyzer, releaseNotesGenerator, changelog, gitlab, git } from './node_modules/@govbr-ds/config-tools/src/semantic-release.cjs'
23
23
 
24
- module.exports = {
24
+ export defaul {
25
25
  branches: branches,
26
26
  plugins: [
27
27
  commitAnalyzer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@govbr-ds/release-config",
3
- "version": "3.3.0",
3
+ "version": "4.1.0",
4
4
  "private": false,
5
5
  "description": "Configuração compartilhada do semantic-release para projetos do GovBR-DS",
6
6
  "keywords": [
@@ -13,29 +13,25 @@
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "git@gitlab.com:govbr-ds/tools/govbr-ds-config-tools.git"
16
+ "url": "git@gitlab.com:govbr-ds/tools/govbr-ds-config-tools.git",
17
+ "directory": "packages/release"
17
18
  },
18
19
  "license": "MIT",
19
20
  "author": "SERPRO (http://serpro.gov.br/)",
20
- "main": "semantic-release.cjs",
21
+ "type": "module",
22
+ "exports": "./src/index.js",
23
+ "main": "./src/index.js",
21
24
  "files": [
22
- "semantic-release.cjs"
25
+ "src"
23
26
  ],
24
- "scripts": {
25
- "commit": "git-cz"
26
- },
27
- "config": {
28
- "commitizen": {
29
- "path": "@commitlint/cz-commitlint"
30
- }
31
- },
32
27
  "dependencies": {
33
28
  "@semantic-release/changelog": "^6.0.3",
34
29
  "@semantic-release/commit-analyzer": "^12.0.0",
35
30
  "@semantic-release/git": "^10.0.1",
36
- "inquirer": "^9.2.19",
37
31
  "@semantic-release/gitlab": "^13.0.3",
38
32
  "@semantic-release/release-notes-generator": "^13.0.0",
33
+ "compare-func": "^2.0.0",
34
+ "inquirer": "^9.2.19",
39
35
  "semantic-release": "^23.0.8"
40
36
  }
41
37
  }
@@ -1,3 +1,5 @@
1
+ import { createWriterOpts } from './writer.js'
2
+
1
3
  const branches = [
2
4
  'main',
3
5
  '+([0-9])?(.{+([0-9]),x}).x', //1.x.x
@@ -68,87 +70,7 @@ const releaseNotesGenerator = [
68
70
  parserOpts: {
69
71
  noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES', 'BREAKING'],
70
72
  },
71
- writerOpts: {
72
- groupBy: 'type',
73
- commitsSort: ['scope', 'subject', 'header'],
74
- finalizeContext: (context) => {
75
- const date = new Date()
76
- context.date = date.toLocaleString('pt-BR', {
77
- timeZone: 'America/Sao_Paulo',
78
- dateStyle: 'short',
79
- })
80
- return context
81
- },
82
- mainTemplate: `
83
- {{> header}}
84
-
85
- {{#if noteGroups}}
86
- {{#each noteGroups}}
87
-
88
- ### 💥 {{title}}
89
-
90
- {{#each notes}}
91
- * {{#if commit.scope}}**{{commit.scope}}:** {{/if}}{{text}}
92
- {{commit.body}}
93
- {{/each}}
94
- {{/each}}
95
- {{/if}}
96
- {{#each commitGroups}}
97
-
98
- {{#if title}}
99
- ### {{title}}
100
-
101
- {{/if}}
102
- {{#each commits}}
103
- {{> commit root=@root}}
104
- {{/each}}
105
-
106
- {{/each}}
107
- `,
108
- commitPartial: `
109
- *{{#if scope}} **{{scope}}:**
110
- {{~/if}} {{#if subject}}
111
- {{~subject}}
112
- {{~else}}
113
- {{~header}}
114
- {{~/if}}
115
-
116
- {{~!-- commit link --}}{{~#if hash}} {{#if @root.linkReferences~}}
117
- ([{{shortHash}}]({{commitUrlFormat}}))
118
- {{~else}}
119
- {{~shortHash}}
120
- {{~/if}}{{~/if}}
121
-
122
- {{~!-- commit references --}}
123
- {{~#if references~}}
124
- , closes
125
- {{~#each references}} {{#if @root.linkReferences~}}
126
- [
127
- {{~#if this.owner}}
128
- {{~this.owner}}/
129
- {{~/if}}
130
- {{~this.repository}}{{this.prefix}}{{this.issue}}]({{issueUrlFormat}})
131
- {{~else}}
132
- {{~#if this.owner}}
133
- {{~this.owner}}/
134
- {{~/if}}
135
- {{~this.repository}}{{this.prefix}}{{this.issue}}
136
- {{~/if}}{{/each}}
137
- {{~/if}}
138
- `,
139
- headerPartial: `
140
- ## {{#if @root.linkCompare~}}
141
- [{{version}}]({{compareUrlFormat}})
142
- {{~else}}
143
- {{~version}}
144
- {{~/if}}
145
- {{~#if title}} "{{title}}"
146
- {{~/if}}
147
- {{~#if date}} ({{date}})
148
- {{/if}}
149
- `,
150
- footerPartial: ``,
151
- },
73
+ writerOpts: await createWriterOpts(),
152
74
  },
153
75
  ]
154
76
 
@@ -180,4 +102,4 @@ const git = [
180
102
  },
181
103
  ]
182
104
 
183
- module.exports = { branches, commitAnalyzer, releaseNotesGenerator, changelog, gitlab, git }
105
+ export { branches, changelog, commitAnalyzer, git, gitlab, releaseNotesGenerator }
@@ -0,0 +1,29 @@
1
+ *{{#if scope}} **{{scope}}:**
2
+ {{~/if}} {{#if subject}}
3
+ {{~subject}}
4
+ {{~else}}
5
+ {{~header}}
6
+ {{~/if}}
7
+
8
+ {{~!-- commit link --}}{{~#if hash}} {{#if @root.linkReferences~}}
9
+ ([{{shortHash}}]({{commitUrlFormat}}))
10
+ {{~else}}
11
+ {{~shortHash}}
12
+ {{~/if}}{{~/if}}
13
+
14
+ {{~!-- commit references --}}
15
+ {{~#if references~}}
16
+ , closes
17
+ {{~#each references}} {{#if @root.linkReferences~}}
18
+ [
19
+ {{~#if this.owner}}
20
+ {{~this.owner}}/
21
+ {{~/if}}
22
+ {{~this.repository}}{{this.prefix}}{{this.issue}}]({{issueUrlFormat}})
23
+ {{~else}}
24
+ {{~#if this.owner}}
25
+ {{~this.owner}}/
26
+ {{~/if}}
27
+ {{~this.repository}}{{this.prefix}}{{this.issue}}
28
+ {{~/if}}{{/each}}
29
+ {{~/if}}
File without changes
@@ -0,0 +1,9 @@
1
+ ## {{#if @root.linkCompare~}}
2
+ [{{version}}]({{compareUrlFormat}})
3
+ {{~else}}
4
+ {{~version}}
5
+ {{~/if}}
6
+ {{~#if title}} "{{title}}"
7
+ {{~/if}}
8
+ {{~#if date}} ({{date}})
9
+ {{/if}}
@@ -0,0 +1,22 @@
1
+ {{> header}}
2
+
3
+ {{#if noteGroups}}
4
+ {{#each noteGroups}}
5
+ ### 💥 {{title}}
6
+
7
+ {{#each notes}}
8
+ * {{#if commit.scope}}**{{commit.scope}}:** {{/if}}{{text}}
9
+ {{/each}}
10
+ {{/each}}
11
+ {{/if}}
12
+ {{#each commitGroups}}
13
+
14
+ {{#if title}}
15
+ ### {{title}}
16
+
17
+ {{/if}}
18
+ {{#each commits}}
19
+ {{> commit root=@root}}
20
+
21
+ {{/each}}
22
+ {{/each}}
package/src/writer.js ADDED
@@ -0,0 +1,39 @@
1
+ import compareFunc from 'compare-func'
2
+ import { readFile } from 'fs/promises'
3
+ import { resolve } from 'path'
4
+ import { fileURLToPath } from 'url'
5
+
6
+ const dirname = fileURLToPath(new URL('.', import.meta.url))
7
+
8
+ export async function createWriterOpts() {
9
+ const [template, header, commit, footer] = await Promise.all([
10
+ readFile(resolve(dirname, './templates/template.hbs'), 'utf-8'),
11
+ readFile(resolve(dirname, './templates/header.hbs'), 'utf-8'),
12
+ readFile(resolve(dirname, './templates/commit.hbs'), 'utf-8'),
13
+ readFile(resolve(dirname, './templates/footer.hbs'), 'utf-8'),
14
+ ])
15
+ const writerOpts = getWriterOpts()
16
+
17
+ writerOpts.mainTemplate = template
18
+ writerOpts.headerPartial = header
19
+ writerOpts.commitPartial = commit
20
+ writerOpts.footerPartial = footer
21
+
22
+ return writerOpts
23
+ }
24
+
25
+ function getWriterOpts() {
26
+ return {
27
+ groupBy: 'type',
28
+ commitsSort: ['scope', 'subject', 'header'],
29
+ finalizeContext: (context) => {
30
+ const date = new Date()
31
+ context.date = date.toLocaleString('pt-BR', {
32
+ timeZone: 'America/Sao_Paulo',
33
+ dateStyle: 'short',
34
+ })
35
+ return context
36
+ },
37
+ notesSort: compareFunc,
38
+ }
39
+ }