@signageos/lib 8.3.1-master.1364 → 8.3.1-master.1366

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
@@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
8
8
  ### Added
9
9
  - Add object utils omitByRecursively and getObjectWithOmittedValuesBy
10
10
 
11
+ ### Fixed
12
+ - Allow white spaces in changelog change types
13
+
11
14
  ## [8.2.0] - 2022-01-24
12
15
  ### Added
13
16
  - Redis connection factory creates even connection pool
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signageos/lib",
3
- "version": "8.3.1-master.1364",
3
+ "version": "8.3.1-master.1366",
4
4
  "main": "./dist",
5
5
  "files": [
6
6
  "tools",
@@ -1,6 +1,15 @@
1
1
 
2
2
  const { getPipedInput, getGroupedChangeLog } = require('./helper');
3
3
 
4
+ const allChangeTypes = [
5
+ 'Changed',
6
+ 'Removed',
7
+ 'Added',
8
+ 'Fixed',
9
+ 'Security',
10
+ 'Deprecated',
11
+ ];
12
+
4
13
  (async function () {
5
14
  const changeLog = await getPipedInput();
6
15
  const groupedLog = getGroupedChangeLog(changeLog);
@@ -18,8 +27,11 @@ const { getPipedInput, getGroupedChangeLog } = require('./helper');
18
27
  case changedTypes.indexOf('Deprecated') !== -1:
19
28
  process.stdout.write('patch');
20
29
  break;
21
- default:
30
+ case changedTypes.length === 0:
22
31
  process.stdout.write('patch');
32
+ break;
33
+ default:
34
+ throw new Error(`Unknown type of change: ${changedTypes.join(', ')} Only following values are allowed: ${allChangeTypes.join(', ')}`);
23
35
  }
24
36
  })();
25
37
 
package/tools/helper.js CHANGED
@@ -1,3 +1,6 @@
1
+ const VERSION_HEADER = '## ';
2
+ const CHANGES_HEADER = '### ';
3
+ const LOG_LINE = '- ';
1
4
 
2
5
  exports.getPipedInput = function () {
3
6
  return new Promise((resolve, reject) => {
@@ -13,11 +16,11 @@ exports.getPipedInput = function () {
13
16
  exports.getGroupedChangeLog = function (changeLog) {
14
17
  const newLines = changeLog
15
18
  .split(/\n|\r/)
16
- .filter((line) => line.startsWith('## ') || line.startsWith('### ') || line.startsWith('- '));
19
+ .filter((line) => line.startsWith(VERSION_HEADER) || line.startsWith(CHANGES_HEADER) || line.startsWith(LOG_LINE));
17
20
  const { groupedLog } = newLines.reduce(
18
21
  (reduction, line) => {
19
- if (line.startsWith('## ')) {
20
- const version = line.match(/^\#\# \[(([\d\w\.\-\+])+)\]/)[1];
22
+ if (line.startsWith(VERSION_HEADER)) {
23
+ const version = line.substring(VERSION_HEADER.length).match(/^\[?(([\d\w\.\-\+])+)\]?/)[1].trim();
21
24
  if (reduction.groupedLog[version] !== undefined) {
22
25
  throw new Error(`The version "${version}" is duplicated in CHANGELOG`);
23
26
  }
@@ -30,8 +33,8 @@ exports.getGroupedChangeLog = function (changeLog) {
30
33
  },
31
34
  };
32
35
  } else
33
- if (line.startsWith('### ')) {
34
- const type = line.substring('### '.length);
36
+ if (line.startsWith(CHANGES_HEADER)) {
37
+ const type = line.substring(CHANGES_HEADER.length).trim();
35
38
  if (reduction.groupedLog[reduction.lastVersion] === undefined) {
36
39
  throw new Error(`The type "${type}" is not under any version section in CHANGELOG`);
37
40
  }
@@ -56,7 +59,7 @@ exports.getGroupedChangeLog = function (changeLog) {
56
59
  ...reduction.groupedLog,
57
60
  [reduction.lastVersion]: {
58
61
  ...reduction.groupedLog[reduction.lastVersion],
59
- [reduction.lastType]: [...reduction.groupedLog[reduction.lastVersion][reduction.lastType], line.substring('- '.length)],
62
+ [reduction.lastType]: [...reduction.groupedLog[reduction.lastVersion][reduction.lastType], line.substring(LOG_LINE.length)],
60
63
  },
61
64
  },
62
65
  };