@modern-js/plugin-changeset 1.3.0 → 1.3.1-alpha.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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @modern-js/plugin-changeset
2
2
 
3
+ ## 1.3.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [9cd364e06]
8
+ - Updated dependencies [a90bc96bd]
9
+ - @modern-js/utils@1.7.9-alpha.0
10
+ - @modern-js/plugin-i18n@1.2.8-alpha.0
11
+
3
12
  ## 1.3.0
4
13
 
5
14
  ### Minor Changes
@@ -1,4 +1,5 @@
1
1
  import path from 'path';
2
+ import resolveFrom from 'resolve-from';
2
3
  import { fs, execa } from '@modern-js/utils';
3
4
  import readChangesets from '@changesets/read';
4
5
  export function getReleaseInfo(commit, commitObj) {
@@ -51,7 +52,19 @@ export async function genReleaseNote(options) {
51
52
  }
52
53
 
53
54
  if (custom) {
54
- customReleaseNoteFunction = require(custom);
55
+ let possibleReleaseNoteFunc;
56
+ const releasenotePath = resolveFrom(cwd, custom);
57
+ possibleReleaseNoteFunc = require(releasenotePath);
58
+
59
+ if (possibleReleaseNoteFunc.default) {
60
+ possibleReleaseNoteFunc = possibleReleaseNoteFunc.default;
61
+ }
62
+
63
+ if (typeof possibleReleaseNoteFunc.getReleaseInfo === 'function' && typeof possibleReleaseNoteFunc.getReleaseNoteLine === 'function') {
64
+ customReleaseNoteFunction = possibleReleaseNoteFunc;
65
+ } else {
66
+ throw new Error('Could not resolve relesae note generation functions');
67
+ }
55
68
  }
56
69
 
57
70
  const changesets = await readChangesets(cwd);
@@ -81,7 +94,7 @@ export async function genReleaseNote(options) {
81
94
  };
82
95
 
83
96
  if ((_customReleaseNoteFun = customReleaseNoteFunction) !== null && _customReleaseNoteFun !== void 0 && _customReleaseNoteFun.getReleaseInfo) {
84
- commitObj = customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
97
+ commitObj = await customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
85
98
  } else {
86
99
  commitObj = getReleaseInfo(stdout, commitObj);
87
100
  }
@@ -99,11 +112,17 @@ export async function genReleaseNote(options) {
99
112
 
100
113
  if (features.length) {
101
114
  console.info('Features:\n');
102
- features.forEach(commit => console.info(getReleaseNoteLine(commit, customReleaseNoteFunction)));
115
+ features.forEach(async commit => {
116
+ const releaseNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
117
+ console.info(releaseNote);
118
+ });
103
119
  }
104
120
 
105
121
  if (bugFix.length) {
106
122
  console.info('Bug Fix:\n');
107
- bugFix.forEach(commit => console.info(getReleaseNoteLine(commit, customReleaseNoteFunction)));
123
+ bugFix.forEach(async commit => {
124
+ const relesaeNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
125
+ console.info(relesaeNote);
126
+ });
108
127
  }
109
128
  }
@@ -9,6 +9,8 @@ exports.getReleaseNoteLine = getReleaseNoteLine;
9
9
 
10
10
  var _path = _interopRequireDefault(require("path"));
11
11
 
12
+ var _resolveFrom = _interopRequireDefault(require("resolve-from"));
13
+
12
14
  var _utils = require("@modern-js/utils");
13
15
 
14
16
  var _read = _interopRequireDefault(require("@changesets/read"));
@@ -67,7 +69,19 @@ async function genReleaseNote(options) {
67
69
  }
68
70
 
69
71
  if (custom) {
70
- customReleaseNoteFunction = require(custom);
72
+ let possibleReleaseNoteFunc;
73
+ const releasenotePath = (0, _resolveFrom.default)(cwd, custom);
74
+ possibleReleaseNoteFunc = require(releasenotePath);
75
+
76
+ if (possibleReleaseNoteFunc.default) {
77
+ possibleReleaseNoteFunc = possibleReleaseNoteFunc.default;
78
+ }
79
+
80
+ if (typeof possibleReleaseNoteFunc.getReleaseInfo === 'function' && typeof possibleReleaseNoteFunc.getReleaseNoteLine === 'function') {
81
+ customReleaseNoteFunction = possibleReleaseNoteFunc;
82
+ } else {
83
+ throw new Error('Could not resolve relesae note generation functions');
84
+ }
71
85
  }
72
86
 
73
87
  const changesets = await (0, _read.default)(cwd);
@@ -97,7 +111,7 @@ async function genReleaseNote(options) {
97
111
  };
98
112
 
99
113
  if ((_customReleaseNoteFun = customReleaseNoteFunction) !== null && _customReleaseNoteFun !== void 0 && _customReleaseNoteFun.getReleaseInfo) {
100
- commitObj = customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
114
+ commitObj = await customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
101
115
  } else {
102
116
  commitObj = getReleaseInfo(stdout, commitObj);
103
117
  }
@@ -115,11 +129,17 @@ async function genReleaseNote(options) {
115
129
 
116
130
  if (features.length) {
117
131
  console.info('Features:\n');
118
- features.forEach(commit => console.info(getReleaseNoteLine(commit, customReleaseNoteFunction)));
132
+ features.forEach(async commit => {
133
+ const releaseNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
134
+ console.info(releaseNote);
135
+ });
119
136
  }
120
137
 
121
138
  if (bugFix.length) {
122
139
  console.info('Bug Fix:\n');
123
- bugFix.forEach(commit => console.info(getReleaseNoteLine(commit, customReleaseNoteFunction)));
140
+ bugFix.forEach(async commit => {
141
+ const relesaeNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
142
+ console.info(relesaeNote);
143
+ });
124
144
  }
125
145
  }
@@ -6,16 +6,17 @@ export interface Commit {
6
6
  author?: string;
7
7
  message: string;
8
8
  summary: string;
9
+ [key: string]: string | undefined;
9
10
  }
10
11
  interface ReleaseNoteOptions {
11
12
  repo?: string;
12
13
  custom?: string;
13
14
  }
14
15
  export declare type CustomReleaseNoteFunction = {
15
- getReleaseInfo?: (commit: string, commitObj: Commit) => Commit;
16
- getReleaseNoteLine?: (commit: Commit) => string;
16
+ getReleaseInfo?: (commit: string, commitObj: Commit) => Commit | Promise<Commit>;
17
+ getReleaseNoteLine?: (commit: Commit) => string | Promise<string>;
17
18
  } | undefined;
18
19
  export declare function getReleaseInfo(commit: string, commitObj: Commit): Commit;
19
- export declare function getReleaseNoteLine(commit: Commit, customReleaseNoteFunction?: CustomReleaseNoteFunction): string;
20
+ export declare function getReleaseNoteLine(commit: Commit, customReleaseNoteFunction?: CustomReleaseNoteFunction): string | Promise<string>;
20
21
  export declare function genReleaseNote(options: ReleaseNoteOptions): Promise<void>;
21
22
  export {};
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.3.0",
14
+ "version": "1.3.1-alpha.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -37,12 +37,13 @@
37
37
  "@changesets/git": "^1.3.2",
38
38
  "@changesets/read": "^0.5.5",
39
39
  "@modern-js/i18n-cli-language-detector": "^1.2.4",
40
- "@modern-js/plugin-i18n": "^1.2.7",
41
- "@modern-js/utils": "^1.7.8",
42
- "execa": "^5.1.1"
40
+ "@modern-js/plugin-i18n": "^1.2.8-alpha.0",
41
+ "@modern-js/utils": "^1.7.9-alpha.0",
42
+ "execa": "^5.1.1",
43
+ "resolve-from": "^5.0.0"
43
44
  },
44
45
  "devDependencies": {
45
- "@modern-js/core": "1.12.1",
46
+ "@modern-js/core": "1.12.2-alpha.0",
46
47
  "@scripts/build": "0.0.0",
47
48
  "@types/jest": "^27",
48
49
  "@types/node": "^14",