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(breadcrumb-plugin): extract plugin to the package #8

Merged
merged 1 commit into from
Dec 4, 2023
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
5 changes: 5 additions & 0 deletions libs/breadcrumb-plugin/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "../../.eslintrc.json",
"ignorePatterns": ["!**/*"],
"rules": {}
}
24 changes: 24 additions & 0 deletions libs/breadcrumb-plugin/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* eslint-disable */
export default {
displayName: 'breadcrumb-plugin',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
globals: {},
coverageDirectory: '../../coverage/libs/breadc',
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
transform: {
'^.+.(ts|mjs|js|html)$': [
'jest-preset-angular',
{
stringifyContentPathRegex: '\\.(html|svg)$',

tsconfig: '<rootDir>/tsconfig.spec.json',
},
],
},
transformIgnorePatterns: ['node_modules/(?!.*.mjs$)'],
};
7 changes: 7 additions & 0 deletions libs/breadcrumb-plugin/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/libs/breadcrumb-plugin",
"lib": {
"entryFile": "src/index.ts"
}
}
33 changes: 33 additions & 0 deletions libs/breadcrumb-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@micro-sentry/breadcrumb-plugin",
"version": "0.0.0-development",
"dependencies": {
"tslib": "^2.0.0"
},
"peerDependencies": {
"@micro-sentry/browser": "0.0.0-development"
},
"license": "Apache-2.0",
"keywords": [
"monitoring",
"errors",
"sentry",
"log",
"angular"
],
"authors": [
"Igor Katsuba <[email protected]>",
sevaru marked this conversation as resolved.
Show resolved Hide resolved
"Roman Sedov <[email protected]>",
"Vsevolod Arutyunov <[email protected]>"
],
"contributors": [
"Igor Katsuba <[email protected]>",
"Roman Sedov <[email protected]>",
"Vsevolod Arutyunov <[email protected]>"
],
"repository": "https://github.com/taiga-family/micro-sentry",
"homepage": "https://github.com/taiga-family/micro-sentry",
"publishConfig": {
"access": "public"
}
}
67 changes: 67 additions & 0 deletions libs/breadcrumb-plugin/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "breadcrumb-plugin",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "libs/breadcrumb-plugin/src",
"prefix": "micro-sentry",
"targets": {
"build": {
"executor": "@nx/angular:package",
"options": {
"tsConfig": "libs/breadcrumb-plugin/tsconfig.lib.json",
"project": "libs/breadcrumb-plugin/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "libs/breadcrumb-plugin/tsconfig.lib.prod.json"
}
}
},
"lint": {
"executor": "@nx/eslint:lint",
"options": {
"lintFilePatterns": ["libs/breadcrumb-plugin/src/**/*.ts"]
}
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "libs/breadcrumb-plugin/jest.config.ts"
},
"outputs": ["{workspaceRoot}/coverage/libs/breadcrumb-plugin"]
},
"semrel": {
"executor": "@ng-builders/semrel:release",
"options": {
"npm": {
"pkgRoot": "dist/libs/breadcrumb-plugin"
},
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"main",
"next",
"next-major",
{
"name": "beta",
"prerelease": true
},
{
"name": "alpha",
"prerelease": true
}
]
}
},
"release": {
"executor": "nx:run-commands",
"options": {
"commands": [
"nx build breadcrumb-plugin --configuration production",
"nx semrel breadcrumb-plugin"
],
"parallel": false
}
}
},
"tags": []
}
1 change: 1 addition & 0 deletions libs/breadcrumb-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/breadcrumb-plugin';
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { MicroSentryPlugin } from '../models/plugin';
import { BrowserMicroSentryClient } from '../services/browser-micro-sentry-client';
import { fill } from '../utils/fill';
import {
BrowserMicroSentryClient,
MicroSentryPlugin,
} from '@micro-sentry/browser';
import { Severity } from '@micro-sentry/core';
import { parseUrl } from '../utils/parse-url';
import { fill } from './utils/fill';
import { htmlTreeAsString } from './utils/html-tree-as-path';
import {
getFetchMethod,
getFetchUrl,
supportsNativeFetch,
} from '../utils/fetch-utils';
import { htmlTreeAsString } from '../utils/html-tree-as-path';
import { safeJoin } from '../utils/safe-join';
} from './utils/fetch-utils';
import { safeJoin } from './utils/safe-join';
import { parseUrl } from './utils/parse-url';

export class BreadcrumbPlugin implements MicroSentryPlugin {
private subscriptions: (() => void)[] = [];
Expand Down
14 changes: 14 additions & 0 deletions libs/breadcrumb-plugin/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'jest-preset-angular/setup-jest';

import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
} from '@angular/platform-browser-dynamic/testing';

getTestBed().resetTestEnvironment();
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(),
{ teardown: { destroyAfterEach: false } }
);
19 changes: 19 additions & 0 deletions libs/breadcrumb-plugin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.lib.prod.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"target": "es2020"
}
}
25 changes: 25 additions & 0 deletions libs/breadcrumb-plugin/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"target": "ES2022",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": [],
"lib": ["dom", "es2018"],
"useDefineForClassFields": false
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"enableResourceInlining": true
},
"exclude": [
"src/test-setup.ts",
"**/*.spec.ts",
"**/*.test.ts",
"jest.config.ts"
],
"include": ["**/*.ts"]
}
12 changes: 12 additions & 0 deletions libs/breadcrumb-plugin/tsconfig.lib.prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false,
"target": "ES2022",
"useDefineForClassFields": false
},
"angularCompilerOptions": {
"compilationMode": "partial"
},
"exclude": ["jest.config.ts"]
}
10 changes: 10 additions & 0 deletions libs/breadcrumb-plugin/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": ["**/*.spec.ts", "**/*.test.ts", "**/*.d.ts", "jest.config.ts"]
}
2 changes: 1 addition & 1 deletion libs/browser/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './lib/models/browser-sentry-client-options';
export * from './lib/models/plugin';
export * from './lib/services/browser-micro-sentry-client';
export * from './lib/plugins/breadcrumb-plugin';
1 change: 0 additions & 1 deletion libs/browser/src/lib/models/state.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { SentryRequestBody } from '@micro-sentry/core';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface State
extends Partial<
Pick<
Expand Down
10 changes: 6 additions & 4 deletions scripts/prerelease.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
const { dir } = require('console');
const fs = require('fs');

const DIST_LIB_PATH = '/common/';
const README_PATH = 'README.md';
const DIRS = fs.readdirSync('libs');

copyExtraFiles();

function copyExtraFiles() {
if (!fs.existsSync(README_PATH)) {
throw new Error('README do not exit');
} else {
copyReadmeIntoLibFolder(README_PATH, 'core');
copyReadmeIntoLibFolder(README_PATH, 'browser');
copyReadmeIntoLibFolder(README_PATH, 'angular');
DIRS.forEach((dir) => {
console.log(dir);
copyReadmeIntoLibFolder(README_PATH, dir);
});
}
}

Expand Down
3 changes: 3 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"strict": true,
"paths": {
"@micro-sentry/angular": ["libs/angular/src/index.ts"],
"@micro-sentry/breadcrumb-plugin": [
"libs/breadcrumb-plugin/src/index.ts"
],
"@micro-sentry/browser": ["libs/browser/src/index.ts"],
"@micro-sentry/core": ["libs/core/src/index.ts"]
}
Expand Down
Loading