@signageos/lib 8.3.0 → 8.4.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
@@ -4,10 +4,17 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [8.4.0] - 2022-02-07
8
+ ### Added
9
+ - Object util getObjectKeys. Which is typed version of the object keys
10
+
7
11
  ## [8.3.0] - 2022-01-31
8
12
  ### Added
9
13
  - Add object utils omitByRecursively and getObjectWithOmittedValuesBy
10
14
 
15
+ ### Fixed
16
+ - Allow white spaces in changelog change types
17
+
11
18
  ## [8.2.0] - 2022-01-24
12
19
  ### Added
13
20
  - 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.0",
3
+ "version": "8.4.0",
4
4
  "main": "./dist",
5
5
  "files": [
6
6
  "tools",
@@ -74,7 +74,7 @@
74
74
  },
75
75
  "devDependencies": {
76
76
  "@influxdata/influxdb-client": "1.16.0",
77
- "@signageos/codestyle": "0.0.19",
77
+ "@signageos/codestyle": "0.0.20",
78
78
  "@types/amqplib": "0.5.13",
79
79
  "@types/async-lock": "1.1.1",
80
80
  "@types/debug": "0.0.29",
@@ -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
  };