Skip to content

Commit a156ae6

Browse files
authored
chore(all): npm libraries bump (#215)
* chore(all): npm libraries bump * build(logger,tracer): added Error typings to test * fix(logger,metrics): handle errors as unknown types * fix: move coverage creation in GA - PR event * fix: create lcov.info file in GA - PR build event * fix: check for lcov file to exist in PR build
1 parent 03ae555 commit a156ae6

File tree

9 files changed

+2995
-3061
lines changed

9 files changed

+2995
-3061
lines changed

.github/workflows/on-pull-request.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ jobs:
2424
- name: Collate Coverage Reports
2525
if: ${{ github.actor != 'dependabot[bot]' }}
2626
run: |
27-
mkdir -p coverage
2827
for d in ./packages/*/ ; do
28+
mkdir -p coverage
29+
if [[ ! -f coverage/lcov.info ]]
30+
then
31+
continue
32+
fi
2933
filename="$d""coverage/lcov.info"
3034
targetSource="SF:""$d""src"
3135
sed "s|SF:src|$targetSource|g" $filename >> coverage/lcov.info

npm-shrinkwrap.json

Lines changed: 1418 additions & 1738 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/logger/npm-shrinkwrap.json

Lines changed: 534 additions & 519 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/logger/src/Logger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ class Logger implements ClassThatLogs {
162162
if (typeof input !== 'string') {
163163
logItem.addAttributes(input);
164164
}
165-
extraInput.forEach((item: Error | LogAttributes) => {
165+
extraInput.forEach((item: Error | LogAttributes | unknown) => {
166166
const attributes = (item instanceof Error) ? { error: item } : item;
167-
logItem.addAttributes(attributes);
167+
logItem.addAttributes(<LogAttributes>attributes);
168168
});
169169

170170
return logItem;

packages/logger/tests/unit/formatter/PowertoolLogFormatter.test.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ describe('Class: PowertoolLogFormatter', () => {
109109
shouldThrow();
110110
} catch (error) {
111111
// Assess
112-
const formattedError = formatter.formatError(error);
112+
expect(error).toBeInstanceOf(Error);
113+
const formattedError = formatter.formatError(<Error>error);
113114
expect(formattedError).toEqual({
114115
location: expect.stringMatching(/PowertoolLogFormatter.test.ts:[0-9]+$/),
115116
message: 'Ouch!',
@@ -136,7 +137,8 @@ describe('Class: PowertoolLogFormatter', () => {
136137
shouldThrow();
137138
} catch (error) {
138139
// Assess
139-
const formattedReferenceError = formatter.formatError(error);
140+
expect(error).toBeInstanceOf(Error);
141+
const formattedReferenceError = formatter.formatError(<Error>error);
140142
expect(formattedReferenceError).toEqual({
141143
location: expect.stringMatching(/PowertoolLogFormatter.test.ts:[0-9]+$/),
142144
message: 'doesNotExist is not defined',
@@ -164,7 +166,8 @@ describe('Class: PowertoolLogFormatter', () => {
164166
shouldThrow();
165167
} catch (error) {
166168
// Assess
167-
const formattedAssertionError = formatter.formatError(error);
169+
expect(error).toBeInstanceOf(AssertionError);
170+
const formattedAssertionError = formatter.formatError(<AssertionError>error);
168171
expect(formattedAssertionError).toEqual({
169172
location: expect.stringMatching(/PowertoolLogFormatter.test.ts:[0-9]+/),
170173
message: expect.stringMatching(/Expected values to be strictly equal/),
@@ -192,7 +195,8 @@ describe('Class: PowertoolLogFormatter', () => {
192195
shouldThrow();
193196
} catch (error) {
194197
// Assess
195-
const formattedRangeError = formatter.formatError(error);
198+
expect(error).toBeInstanceOf(RangeError);
199+
const formattedRangeError = formatter.formatError(<RangeError>error);
196200
expect(formattedRangeError).toEqual({
197201
location: expect.stringMatching(/PowertoolLogFormatter.test.ts:[0-9]+/),
198202
message: 'The argument must be between 10 and 20',
@@ -219,7 +223,8 @@ describe('Class: PowertoolLogFormatter', () => {
219223
shouldThrow();
220224
} catch (error) {
221225
// Assess
222-
const formattedSyntaxError = formatter.formatError(error);
226+
expect(error).toBeInstanceOf(SyntaxError);
227+
const formattedSyntaxError = formatter.formatError(<SyntaxError>error);
223228
expect(formattedSyntaxError).toEqual({
224229
location: expect.stringMatching(/PowertoolLogFormatter.test.ts:[0-9]+/),
225230
message: 'Unexpected identifier',
@@ -247,7 +252,8 @@ describe('Class: PowertoolLogFormatter', () => {
247252
shouldThrow();
248253
} catch (error) {
249254
// Assess
250-
const formattedTypeError = formatter.formatError(error);
255+
expect(error).toBeInstanceOf(Error);
256+
const formattedTypeError = formatter.formatError(<Error>error);
251257
expect(formattedTypeError).toEqual({
252258
location: expect.stringMatching(/PowertoolLogFormatter.test.ts:[0-9]+/),
253259
message: 'Cannot read property \'foo\' of null',

packages/logger/types/Logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type UnformattedAttributes = {
5050
};
5151

5252
type LogItemMessage = string | LogAttributesWithMessage;
53-
type LogItemExtraInput = Array<Error | LogAttributes>;
53+
type LogItemExtraInput = Array<Error | LogAttributes | unknown>;
5454

5555
type HandlerMethodDecorator = (target: LambdaInterface, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<Handler>) => TypedPropertyDescriptor<Handler> | void;
5656

0 commit comments

Comments
 (0)