@thisismanta/semantic-version 2.0.0-4 → 2.0.0-6
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/lib/auto-npm-version.js +12 -10
- package/package.json +1 -1
package/lib/auto-npm-version.js
CHANGED
|
@@ -33,19 +33,20 @@ const index_1 = require("./index");
|
|
|
33
33
|
const debug_1 = require("./debug");
|
|
34
34
|
main();
|
|
35
35
|
async function main() {
|
|
36
|
-
|
|
37
|
-
(0, debug_1.debug)('ver', await run('npm pkg get version'));
|
|
38
|
-
const lastVersion = semver_1.default.valid(await run('npm pkg get version'));
|
|
36
|
+
const lastVersion = semver_1.default.valid(JSON.parse(await run('npm pkg get version')));
|
|
39
37
|
(0, debug_1.debug)('lastVersion »', JSON.stringify(lastVersion));
|
|
40
38
|
if (!lastVersion) {
|
|
41
|
-
throw new Error('Expect to have a
|
|
39
|
+
throw new Error('Expect to have a valid "version" field in package.json.');
|
|
42
40
|
}
|
|
43
|
-
const commits = (await run(`git log v${lastVersion}..HEAD --format
|
|
44
|
-
.trim()
|
|
41
|
+
const commits = (await run(`git log v${lastVersion}..HEAD --format=%H%s`))
|
|
45
42
|
.split('\n')
|
|
46
|
-
.
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
.filter(line => line.length > 0)
|
|
44
|
+
.map(line => ({
|
|
45
|
+
hash: line.substring(0, 40),
|
|
46
|
+
message: line.substring(40),
|
|
47
|
+
}))
|
|
48
|
+
.filter(({ message }) => semver_1.default.valid(message) === null)
|
|
49
|
+
.map(({ hash, message }) => {
|
|
49
50
|
const { type, breaking, subject } = (0, index_1.checkConventionalMessage)(message, { debug: debug_1.debug });
|
|
50
51
|
return {
|
|
51
52
|
hash,
|
|
@@ -54,8 +55,9 @@ async function main() {
|
|
|
54
55
|
subject,
|
|
55
56
|
};
|
|
56
57
|
});
|
|
57
|
-
console.log(`Found ${commits.length} commits since ${lastVersion}`);
|
|
58
|
+
console.log(`Found ${commits.length} commits since v${lastVersion}`);
|
|
58
59
|
(0, debug_1.debug)('commits »', JSON.stringify(commits, null, 2));
|
|
60
|
+
return;
|
|
59
61
|
const releaseType = commits.reduce((releaseType, { type, breaking }) => {
|
|
60
62
|
if (releaseType === 'major' || breaking) {
|
|
61
63
|
return 'major';
|