Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: remove deprecated enum levels #216

Merged
merged 6 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,10 @@ jobs:
- name: Run NX Commands
run: |
pnpm exec nx-cloud record -- nx format:check
pnpm exec nx affected -t lint test build e2e-ci
pnpm exec nx affected -t lint test:ci build e2e-ci

sonarcloud:
name: SonarCloud
needs: main
runs-on: ubuntu-latest
permissions:
id-token: write
Expand All @@ -114,16 +113,16 @@ jobs:
uses: ./.github/actions/setup
# Uses the cache generated in the distributed step (Needed for the sonar eslint reports).
- name: Lint with reports
run: pnpm exec nx run-many --all --target=lint --configuration=report --parallel=2 --max-warnings=0
run: pnpm exec nx run-many --target=lint --configuration=report --parallel=2 --max-warnings=0
# Uses the cache generated in the distributed step (Needed for the sonar jest coverage reports).
- name: Tests with coverage
run: pnpm exec nx run-many --all --target=test --configuration=coverage --parallel=1 --max-workers=2
run: pnpm exec nx run-many --target=test --configuration=ci --parallel=1 --max-workers=2

- name: Configure Sonar report paths
run: pnpm run configure-sonar-report-paths

- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@v2.1.1
uses: sonarsource/sonarcloud-github-action@v3.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3 changes: 1 addition & 2 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
},
"@nx/eslint:lint": {
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"],
"cache": true,
"outputs": ["{options.outputFile}"]
"cache": true
},
"@angular-devkit/build-angular:application": {
"cache": true,
Expand Down
1 change: 1 addition & 0 deletions packages/examples/lumberjack-app/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default {
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
globals: {},
coverageReporters: ['lcovonly', 'text-summary'],
coverageDirectory: '../../../coverage/packages/examples/lumberjack-app',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
Expand Down
14 changes: 9 additions & 5 deletions packages/examples/lumberjack-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@
"ci": {
"ci": true,
"coverage": true
},
"coverage": {
"ci": true,
"coverageReporters": ["lcovonly", "text-summary"],
"coverage": true
}
}
},
Expand All @@ -98,6 +93,15 @@
"staticFilePath": "dist/packages/examples/lumberjack-app/browser",
"spa": true
}
},
"lint": {
"outputs": ["{workspaceRoot}/reports/packages/examples/lumberjack-app/lint/report.json"],
"configurations": {
"report": {
"format": "json",
"output-file": "../../../reports/packages/examples/lumberjack-app/lint/report.json"
}
}
}
}
}
4 changes: 3 additions & 1 deletion packages/examples/lumberjack-app/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
import 'jest-preset-angular/setup-jest';
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';

setupZoneTestEnv();
1 change: 1 addition & 0 deletions packages/internal/console-driver/test-util/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default {
preset: '../../../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
globals: {},
coverageReporters: ['lcovonly', 'text-summary'],
coverageDirectory: '../../../../coverage/packages/internal/console-driver/test-util',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
Expand Down
8 changes: 2 additions & 6 deletions packages/internal/console-driver/test-util/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,15 @@
"ci": {
"ci": true,
"coverage": true
},
"coverage": {
"ci": true,
"coverageReporters": ["lcovonly", "text-summary"],
"coverage": true
}
}
},
"lint": {
"outputs": ["{workspaceRoot}/reports/packages/internal/console-driver/test-util/lint/report.json"],
"configurations": {
"report": {
"format": "json",
"output-file": "reports/packages/internal/console-driver/test-util/lint/report.json"
"output-file": "../../../../reports/packages/internal/console-driver/test-util/lint/report.json"
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/internal/console-driver/test-util/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
import 'jest-preset-angular/setup-jest';
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';

setupZoneTestEnv();
1 change: 1 addition & 0 deletions packages/internal/test-util/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default {
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
globals: {},
coverageReporters: ['lcovonly', 'text-summary'],
coverageDirectory: '../../../coverage/packages/internal/test-util',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
Expand Down
8 changes: 2 additions & 6 deletions packages/internal/test-util/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,15 @@
"ci": {
"ci": true,
"coverage": true
},
"coverage": {
"ci": true,
"coverageReporters": ["lcovonly", "text-summary"],
"coverage": true
}
}
},
"lint": {
"outputs": ["{workspaceRoot}/reports/packages/internal/test-util/lint/report.json"],
"configurations": {
"report": {
"format": "json",
"output-file": "reports/packages/internal/test-util/lint/report.json"
"output-file": "../../../reports/packages/internal/test-util/lint/report.json"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { TestBed } from '@angular/core/testing';

import {
LogLevel,
LumberjackLevel,
LumberjackLogDriver,
LumberjackLogDriverLog,
lumberjackLogDriverToken,
Expand Down Expand Up @@ -33,26 +31,20 @@ describe(ErrorThrowingDriver.name, () => {
}

describe.each([
[LumberjackLevel.Critical, (driver) => driver.logCritical],
[LumberjackLevel.Debug, (driver) => driver.logDebug],
[LumberjackLevel.Error, (driver) => driver.logError],
[LumberjackLevel.Info, (driver) => driver.logInfo],
[LumberjackLevel.Trace, (driver) => driver.logTrace],
[LumberjackLevel.Warning, (driver) => driver.logWarning],
['critical', (driver) => driver.logCritical],
['debug', (driver) => driver.logDebug],
['error', (driver) => driver.logError],
['info', (driver) => driver.logInfo],
['trace', (driver) => driver.logTrace],
['warn', (driver) => driver.logWarning],
] as ReadonlyArray<[LumberjackLogLevel | LogLevel, (driver: LumberjackLogDriver) => (driverLog: LumberjackLogDriverLog) => void]>)(
] as ReadonlyArray<[LumberjackLogLevel, (driver: LumberjackLogDriver) => (driverLog: LumberjackLogDriverLog) => void]>)(
`implements a spy when using the %s log level`,
(logLevel, logMethod) => {
it('throws an error on first log when the default log driver configuration is used', () => {
const { driver } = setup();
const driverLog = createDriverLog(logLevel, logLevel, '', 'ErrorThrowingDriverDefaultTest');

expect(() => logMethod(driver).call(driver, driverLog)).toThrowError();
expect(() => logMethod(driver).call(driver, driverLog)).toThrow();
});

describe.each([0, 1, 2, 3])(
Expand All @@ -64,7 +56,7 @@ describe(ErrorThrowingDriver.name, () => {
const act = () => logMethod(driver).call(driver, driverLog);
repeatSideEffect(logsBeforeThrowing, act);

expect(act).toThrowError();
expect(act).toThrow();
});
}
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { TestBed } from '@angular/core/testing';

import {
LogLevel,
LumberjackLogDriverLog,
LumberjackLogLevel,
LumberjackLogPayload,
Expand All @@ -10,7 +9,7 @@ import {

export const createDriverLog = <TPayload extends LumberjackLogPayload | void = void>(
formattedLog: string,
level: LumberjackLogLevel | LogLevel,
level: LumberjackLogLevel,
message = '',
scope = 'Test',
payload?: TPayload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { TestBed } from '@angular/core/testing';

import { createDriverLog, provideObjectDriver } from '@internal/test-util';
import {
LogLevel,
LumberjackLevel,
LumberjackLogDriver,
LumberjackLogDriverLog,
lumberjackLogDriverToken,
Expand All @@ -30,19 +28,13 @@ describe(ObjectDriver.name, () => {
});

describe.each([
[LumberjackLevel.Critical, (driver) => driver.logCritical, { isWorking: true }],
[LumberjackLevel.Debug, (driver) => driver.logDebug, { isWorking: false }],
[LumberjackLevel.Error, (driver) => driver.logError, undefined],
[LumberjackLevel.Info, (driver) => driver.logInfo, { isWorking: true }],
[LumberjackLevel.Trace, (driver) => driver.logTrace, { isWorking: false }],
[LumberjackLevel.Warning, (driver) => driver.logWarning, undefined],
['critical', (driver) => driver.logCritical, { isWorking: true }],
['debug', (driver) => driver.logDebug, { isWorking: false }],
['error', (driver) => driver.logError, undefined],
['info', (driver) => driver.logInfo, { isWorking: true }],
['trace', (driver) => driver.logTrace, { isWorking: false }],
['warn', (driver) => driver.logWarning, undefined],
] as ReadonlyArray<[LumberjackLogLevel | LogLevel, (driver: LumberjackLogDriver<ObjectPayload>) => (driverLog: LumberjackLogDriverLog<ObjectPayload>) => void, ObjectPayload | undefined]>)(
] as ReadonlyArray<[LumberjackLogLevel, (driver: LumberjackLogDriver<ObjectPayload>) => (driverLog: LumberjackLogDriverLog<ObjectPayload>) => void, ObjectPayload | undefined]>)(
`delegates to ${ObjectService.name} when using the %s log level`,
(logLevel, logMethod, expectedPayload) => {
it(`forwards the log payload to the ${ObjectService.prototype.log.name} method`, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { TestBed } from '@angular/core/testing';

import {
LogLevel,
LumberjackLevel,
LumberjackLogDriver,
LumberjackLogDriverLog,
lumberjackLogDriverToken,
Expand All @@ -27,19 +25,13 @@ describe(SpyDriver.name, () => {
});

describe.each([
[LumberjackLevel.Critical, (driver) => driver.logCritical],
[LumberjackLevel.Debug, (driver) => driver.logDebug],
[LumberjackLevel.Error, (driver) => driver.logError],
[LumberjackLevel.Info, (driver) => driver.logInfo],
[LumberjackLevel.Trace, (driver) => driver.logTrace],
[LumberjackLevel.Warning, (driver) => driver.logWarning],
['critical', (driver) => driver.logCritical],
['debug', (driver) => driver.logDebug],
['error', (driver) => driver.logError],
['info', (driver) => driver.logInfo],
['trace', (driver) => driver.logTrace],
['warn', (driver) => driver.logWarning],
] as ReadonlyArray<[LumberjackLogLevel | LogLevel, (driver: LumberjackLogDriver<void>) => (driverLog: LumberjackLogDriverLog<void>) => void]>)(
] as ReadonlyArray<[LumberjackLogLevel, (driver: LumberjackLogDriver<void>) => (driverLog: LumberjackLogDriverLog<void>) => void]>)(
`implements a spy when using the %s log level`,
(logLevel, logMethod) => {
it('records calls', () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/internal/test-util/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
import 'jest-preset-angular/setup-jest';
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';

setupZoneTestEnv();
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { TestBed } from '@angular/core/testing';
import { HttpHandlerFn, HttpRequest, withInterceptors } from '@angular/common/http';

import {
ConfigLevels,
LumberjackConfigLevels,
LumberjackLogDriver,
lumberjackLogDriverToken,
Expand All @@ -23,7 +22,7 @@ import { LumberjackHttpDriverInternalConfig } from './lumberjack-http-driver-int
import { LumberjackHttpDriverOptions } from './lumberjack-http-driver.options';

function createHttpOptions(
extraOptions: { levels?: ConfigLevels; identifier?: string } = {}
extraOptions: { levels?: LumberjackConfigLevels; identifier?: string } = {}
): LumberjackHttpDriverOptions {
return {
origin: 'TEST_MODULE',
Expand All @@ -33,10 +32,7 @@ function createHttpOptions(
};
}

function createHttpConfig(
levels: LumberjackConfigLevels | ConfigLevels,
identifier?: string
): LumberjackHttpDriverConfig {
function createHttpConfig(levels: LumberjackConfigLevels, identifier?: string): LumberjackHttpDriverConfig {
const config: Writable<LumberjackHttpDriverConfig> = {
levels,
origin: 'TEST_MODULE',
Expand Down Expand Up @@ -169,7 +165,7 @@ describe(provideLumberjackHttpDriver.name, () => {
});

it('registers the specified options with custom levels', () => {
const customLevels: ConfigLevels = ['critical'];
const customLevels: LumberjackConfigLevels = ['critical'];
const options = createHttpOptions({ levels: customLevels });

const httpDriver = createHttpDriverWithOptions({ options });
Expand Down Expand Up @@ -228,7 +224,7 @@ describe(provideLumberjackHttpDriver.name, () => {
it('does register the specified log driver options WITH HttpClient features', () => {
const testInterceptor = jest.fn((req, next) => next(req));
const features: HttpClientFeatures = [withInterceptors([testInterceptor])];
const customLevels: ConfigLevels = ['critical'];
const customLevels: LumberjackConfigLevels = ['critical'];
const options = createHttpOptions({ levels: customLevels });

const httpDriver = createHttpDriverWithOptions({ options, features });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { VERSION } from '@angular/platform-browser';

import { createCriticalDriverLog, createDriverLog, repeatSideEffect } from '@internal/test-util';
import {
LogLevel,
LumberjackLevel,
LumberjackLogDriver,
LumberjackLogDriverLog,
lumberjackLogDriverToken,
Expand Down Expand Up @@ -104,19 +102,13 @@ describe(LumberjackHttpDriver.name, () => {
});

describe.each([
[LumberjackLevel.Critical, (driver) => driver.logCritical],
[LumberjackLevel.Debug, (driver) => driver.logDebug],
[LumberjackLevel.Error, (driver) => driver.logError],
[LumberjackLevel.Info, (driver) => driver.logInfo],
[LumberjackLevel.Trace, (driver) => driver.logTrace],
[LumberjackLevel.Warning, (driver) => driver.logWarning],
['critical', (driver) => driver.logCritical],
['debug', (driver) => driver.logDebug],
['error', (driver) => driver.logError],
['info', (driver) => driver.logInfo],
['trace', (driver) => driver.logTrace],
['warn', (driver) => driver.logWarning],
] as ReadonlyArray<[LumberjackLogLevel | LogLevel, (driver: LumberjackLogDriver<HttpDriverPayload>) => (driverLog: LumberjackLogDriverLog<HttpDriverPayload>) => void]>)(
] as ReadonlyArray<[LumberjackLogLevel, (driver: LumberjackLogDriver<HttpDriverPayload>) => (driverLog: LumberjackLogDriverLog<HttpDriverPayload>) => void]>)(
'logs to a web API using the %s log level',
(logLevel, logMethod) => {
it('sends the driver log to the configured URL', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/ngworker/lumberjack/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default {
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
globals: {},
coverageReporters: ['lcovonly', 'text-summary'],
coverageDirectory: '../../../coverage/packages/ngworker/lumberjack',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
Expand Down
8 changes: 2 additions & 6 deletions packages/ngworker/lumberjack/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,15 @@
"ci": {
"ci": true,
"coverage": true
},
"coverage": {
"ci": true,
"coverageReporters": ["lcovonly", "text-summary"],
"coverage": true
}
}
},
"lint": {
"outputs": ["{workspaceRoot}/reports/packages/ngworker/lumberjack/lint/report.json"],
"configurations": {
"report": {
"format": "json",
"output-file": "reports/packages/ngworker/lumberjack/lint/report.json"
"output-file": "../../../reports/packages/ngworker/lumberjack/lint/report.json"
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions packages/ngworker/lumberjack/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export { LumberjackLogFactory } from './lib/logging/lumberjack-log-factory';
export { LumberjackLogBuilder } from './lib/logging/lumberjack-log.builder';

// Logs
export { LumberjackConfigLevels, ConfigLevels } from './lib/logs/lumberjack-config-levels';
export { LumberjackLevel, Level } from './lib/logs/lumberjack-level';
export { LumberjackConfigLevels } from './lib/logs/lumberjack-config-levels';
export { LumberjackLevel } from './lib/logs/lumberjack-level';
export { LumberjackLog } from './lib/logs/lumberjack.log';
export { LumberjackLogLevel, LogLevel } from './lib/logs/lumberjack-log-level';
export { LumberjackLogLevel } from './lib/logs/lumberjack-log-level';
export { LumberjackLogPayload } from './lib/logs/lumberjack-log-payload';

// Time
Expand Down
Loading