@w5s/conventional-changelog 1.0.1 → 1.0.3

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.
@@ -0,0 +1,3 @@
1
+ export declare const gitRawCommitOpts: {
2
+ format: string;
3
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.gitRawCommitOpts = void 0;
4
+ exports.gitRawCommitOpts = {
5
+ format: '%B%n-hash-%n%H%n-gitTags-%n%d%n-committerDate-%n%ci%n-authorName-%n%an%n-authorEmail-%n%ae',
6
+ };
package/lib/index.d.ts CHANGED
@@ -1,4 +1,15 @@
1
1
  declare const _default: {
2
2
  parserOpts: import("./parser-opts").ParserOptions;
3
+ writerOpts: import("./writer-opts").WriterOptions;
4
+ recommendedBumpOpts: {
5
+ parserOpts: import("./parser-opts").ParserOptions;
6
+ whatBump: (commits: readonly import("./recommended-bump-opts").Commit[]) => {
7
+ level: number;
8
+ reason: string;
9
+ };
10
+ };
11
+ gitRawCommitOpts: {
12
+ format: string;
13
+ };
3
14
  };
4
15
  export default _default;
package/lib/index.js CHANGED
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const git_raw_commit_opts_1 = require("./git-raw-commit-opts");
3
4
  const parser_opts_1 = require("./parser-opts");
5
+ const recommended_bump_opts_1 = require("./recommended-bump-opts");
6
+ const writer_opts_1 = require("./writer-opts");
4
7
  exports.default = {
5
8
  parserOpts: parser_opts_1.parserOpts,
9
+ writerOpts: writer_opts_1.writerOpts,
10
+ recommendedBumpOpts: recommended_bump_opts_1.recommendedBumpOpts,
11
+ gitRawCommitOpts: git_raw_commit_opts_1.gitRawCommitOpts,
6
12
  };
@@ -0,0 +1,9 @@
1
+ import type { Commit as CommitBase } from 'conventional-commits-parser';
2
+ export type Commit = CommitBase;
3
+ export declare const recommendedBumpOpts: {
4
+ parserOpts: import("./parser-opts").ParserOptions;
5
+ whatBump: (commits: ReadonlyArray<Commit>) => {
6
+ level: number;
7
+ reason: string;
8
+ };
9
+ };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.recommendedBumpOpts = void 0;
4
+ const parser_opts_1 = require("./parser-opts");
5
+ exports.recommendedBumpOpts = {
6
+ parserOpts: parser_opts_1.parserOpts,
7
+ whatBump: (commits) => {
8
+ let level = 2;
9
+ let breakings = 0;
10
+ let features = 0;
11
+ for (const commit of commits) {
12
+ if (commit.notes.length > 0) {
13
+ breakings += commit.notes.length;
14
+ level = 0;
15
+ }
16
+ else if (commit.type === 'feat') {
17
+ features += 1;
18
+ if (level === 2) {
19
+ level = 1;
20
+ }
21
+ }
22
+ }
23
+ return {
24
+ level,
25
+ reason: breakings === 1
26
+ ? `There is ${breakings} BREAKING CHANGE and ${features} features`
27
+ : `There are ${breakings} BREAKING CHANGES and ${features} features`,
28
+ };
29
+ },
30
+ };
@@ -4,7 +4,7 @@ exports.writerOpts = void 0;
4
4
  const node_fs_1 = require("node:fs");
5
5
  const node_path_1 = require("node:path");
6
6
  const transform_js_1 = require("./transform.js");
7
- const basePath = (0, node_path_1.resolve)(__dirname, './templates');
7
+ const basePath = (0, node_path_1.resolve)((0, node_path_1.dirname)(__dirname), './template');
8
8
  const template = (0, node_fs_1.readFileSync)(`${basePath}/template.hbs`, 'utf8');
9
9
  const header = (0, node_fs_1.readFileSync)(`${basePath}/header.hbs`, 'utf8');
10
10
  const commit = (0, node_fs_1.readFileSync)(`${basePath}/commit.hbs`, 'utf8');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/conventional-changelog",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Conventional changelog plugin for @w5s",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/w5s/project-config/blob/main/packages/conventional-changelog#readme",
@@ -21,6 +21,7 @@
21
21
  },
22
22
  "typings": "./lib/index.d.ts",
23
23
  "files": [
24
+ "template/*",
24
25
  "lib/**/!(*.spec).d.ts",
25
26
  "lib/**/!(*.spec).d.ts.map",
26
27
  "lib/**/!(*.spec).js.map",
@@ -62,5 +63,5 @@
62
63
  "publishConfig": {
63
64
  "access": "public"
64
65
  },
65
- "gitHead": "cb12620549f61f9f66685f32a8a72fb5159a6370"
66
+ "gitHead": "8dd55a7518db456cdaa696f873204962e177aa13"
66
67
  }
@@ -0,0 +1,3 @@
1
+ export const gitRawCommitOpts = {
2
+ format: '%B%n-hash-%n%H%n-gitTags-%n%d%n-committerDate-%n%ci%n-authorName-%n%an%n-authorEmail-%n%ae',
3
+ };
package/src/index.ts CHANGED
@@ -1,5 +1,11 @@
1
+ import { gitRawCommitOpts } from './git-raw-commit-opts';
1
2
  import { parserOpts } from './parser-opts';
3
+ import { recommendedBumpOpts } from './recommended-bump-opts';
4
+ import { writerOpts } from './writer-opts';
2
5
 
3
6
  export default {
4
7
  parserOpts,
8
+ writerOpts,
9
+ recommendedBumpOpts,
10
+ gitRawCommitOpts,
5
11
  };
@@ -0,0 +1,33 @@
1
+ import type { Commit as CommitBase } from 'conventional-commits-parser';
2
+ import { parserOpts } from './parser-opts';
3
+
4
+ export type Commit = CommitBase;
5
+
6
+ export const recommendedBumpOpts = {
7
+ parserOpts,
8
+ whatBump: (commits: ReadonlyArray<Commit>) => {
9
+ let level = 2;
10
+ let breakings = 0;
11
+ let features = 0;
12
+
13
+ for (const commit of commits) {
14
+ if (commit.notes.length > 0) {
15
+ breakings += commit.notes.length;
16
+ level = 0;
17
+ } else if (commit.type === 'feat') {
18
+ features += 1;
19
+ if (level === 2) {
20
+ level = 1;
21
+ }
22
+ }
23
+ }
24
+
25
+ return {
26
+ level,
27
+ reason:
28
+ breakings === 1
29
+ ? `There is ${breakings} BREAKING CHANGE and ${features} features`
30
+ : `There are ${breakings} BREAKING CHANGES and ${features} features`,
31
+ };
32
+ },
33
+ };
@@ -1,11 +1,11 @@
1
1
  import type { Options } from 'conventional-changelog-writer';
2
2
  import { readFileSync } from 'node:fs';
3
- import { resolve } from 'node:path';
3
+ import { resolve, dirname } from 'node:path';
4
4
  import { createTransform } from './transform.js';
5
5
 
6
6
  export interface WriterOptions extends Options {}
7
7
 
8
- const basePath = resolve(__dirname, './templates');
8
+ const basePath = resolve(dirname(__dirname), './template');
9
9
 
10
10
  const template = readFileSync(`${basePath}/template.hbs`, 'utf8');
11
11
  const header = readFileSync(`${basePath}/header.hbs`, 'utf8');
@@ -0,0 +1 @@
1
+ {{#if authorName}}by: **{{authorName}}**{{#if authorEmail}}<{{authorEmail}}>{{/if}}{{/if}}
@@ -0,0 +1,64 @@
1
+ *{{#if scope}} **{{scope}}**:
2
+ {{~/if}} {{#if subject}}
3
+ {{~subject}}
4
+ {{~else}}
5
+ {{~header}}
6
+ {{~/if}}
7
+
8
+ {{~!-- commit link --}} {{#if @root.linkReferences~}}
9
+ ([{{hash}}](
10
+ {{~#if @root.repository}}
11
+ {{~#if @root.host}}
12
+ {{~@root.host}}/
13
+ {{~/if}}
14
+ {{~#if @root.owner}}
15
+ {{~@root.owner}}/
16
+ {{~/if}}
17
+ {{~@root.repository}}
18
+ {{~else}}
19
+ {{~@root.repoUrl}}
20
+ {{~/if}}/
21
+ {{~@root.commit}}/{{hash}})) {{gitUserInfo}}
22
+ {{~else}}
23
+ {{~hash}}
24
+ {{~/if}}
25
+
26
+ {{~!-- commit references --}}
27
+ {{~#if references~}}
28
+ , closes
29
+ {{~#each references}} {{#if @root.linkReferences~}}
30
+ [
31
+ {{~#if this.owner}}
32
+ {{~this.owner}}/
33
+ {{~/if}}
34
+ {{~this.repository}}#{{this.issue}}](
35
+ {{~#if this.bugsUrl}}
36
+ {{~this.bugsUrl}}{{this.issue}}
37
+ {{~else}}
38
+ {{~#if @root.repository}}
39
+ {{~#if @root.host}}
40
+ {{~@root.host}}/
41
+ {{~/if}}
42
+ {{~#if this.repository}}
43
+ {{~#if this.owner}}
44
+ {{~this.owner}}/
45
+ {{~/if}}
46
+ {{~this.repository}}
47
+ {{~else}}
48
+ {{~#if @root.owner}}
49
+ {{~@root.owner}}/
50
+ {{~/if}}
51
+ {{~@root.repository}}
52
+ {{~/if}}
53
+ {{~else}}
54
+ {{~@root.repoUrl}}
55
+ {{~/if}}/
56
+ {{~@root.issue}}/{{this.issue}}
57
+ {{~/if}})
58
+ {{~else}}
59
+ {{~#if this.owner}}
60
+ {{~this.owner}}/
61
+ {{~/if}}
62
+ {{~this.repository}}#{{this.issue}}
63
+ {{~/if}}{{/each}}
64
+ {{~/if}}
@@ -0,0 +1,11 @@
1
+ {{#if noteGroups}}
2
+ {{#each noteGroups}}
3
+
4
+ ### {{title}}
5
+
6
+ {{#each notes}}
7
+ * {{#if commit.scope}}**{{commit.scope}}**: {{/if}}{{text}}
8
+ {{/each}}
9
+ {{/each}}
10
+
11
+ {{/if}}
@@ -0,0 +1,25 @@
1
+ {{#if isPatch~}}
2
+ ##
3
+ {{~else~}}
4
+ #
5
+ {{~/if}} {{#if @root.linkCompare~}}
6
+ [{{version}}](
7
+ {{~#if @root.repository~}}
8
+ {{~#if @root.host}}
9
+ {{~@root.host}}/
10
+ {{~/if}}
11
+ {{~#if @root.owner}}
12
+ {{~@root.owner}}/
13
+ {{~/if}}
14
+ {{~@root.repository}}
15
+ {{~else}}
16
+ {{~@root.repoUrl}}
17
+ {{~/if~}}
18
+ /compare/{{previousTag}}...{{currentTag}})
19
+ {{~else}}
20
+ {{~version}}
21
+ {{~/if}}
22
+ {{~#if title}} "{{title}}"
23
+ {{~/if}}
24
+ {{~#if date}} ({{date}})
25
+ {{/if}}
@@ -0,0 +1,14 @@
1
+ {{> header}}
2
+
3
+ {{#each commitGroups}}
4
+
5
+ {{#if title}}
6
+ ### {{title}}
7
+
8
+ {{/if}}
9
+ {{#each commits}}
10
+ {{> commit root=@root}}
11
+ {{/each}}
12
+
13
+ {{/each}}
14
+ {{> footer}}