Skip to content

Commit

Permalink
Build script.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Feb 15, 2024
1 parent fefc0ee commit f2557e6
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 9 deletions.
10 changes: 10 additions & 0 deletions frontend/src/app/shared/components/Integrated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ export interface IntegratedProps {
export const Integrated = (props: IntegratedProps) => {
const { token } = props;

React.useEffect(() => {
if (import.meta.env.PROD) {
const script = document.createElement('script');
script.src = '/notifo-sdk.js';
script.async = true;

document.body.appendChild(script);
}
}, []);

React.useEffect(() => {
const notifo = (window as any)['notifo'] || ((window as any)['notifo'] = []);

Expand Down
4 changes: 4 additions & 0 deletions frontend/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
}
2 changes: 1 addition & 1 deletion frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"jsx": "react-jsx",
"lib": ["es6", "dom", "WebWorker"],
"moduleResolution": "node",
"module": "es2015",
"module": "ES2020",
"noEmit": true,
"noEmitHelpers": true,
"noImplicitAny": true,
Expand Down
16 changes: 8 additions & 8 deletions frontend/vite.build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ import defaultConfig from './vite.config.mjs';

const dirName = fileURLToPath(new URL('.', import.meta.url));

const inputs = [{
const inputs = {
// The actual management app.
['app']: path.resolve(dirName, 'index.html'),

// The Notifo SKD is also used by our app. Therefore we build it together.
// Build the worker separately to prevent exports.
['notifo-sdk']: path.resolve(dirName, 'src/sdk/sdk.ts'),
}, {
// Build the worker separately so that it does not get any file
// Build the worker separately so that it does not get any file.
['notifo-sdk-worker']: path.resolve(dirName, 'src/sdk/sdk-worker.ts'),
}];
};

async function buildPackages() {
await rimraf('./build');

for (const input of inputs) {
for (const [chunk, source] of Object.entries(inputs)) {
// https://vitejs.dev/config/
await build({
publicDir: false,
build: {
outDir: 'build',
rollupOptions: {
input,
input: {
[chunk]: source,
},
output: {
entryFileNames: chunk => {
if (chunk.name === 'index') {
Expand Down
50 changes: 50 additions & 0 deletions tools/sdk/Notifo.SDK.Tests/NotifoExceptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,55 @@ public void Should_format_exception_with_dto()

Assert.Contains("My Message", formatted);
}

[Fact]
public void Should_format_exception_with_dto_and_details()
{
var exception =
new NotifoException<ErrorDto>(
"Error",
404,
string.Empty,
null,
new ErrorDto
{
Message = "My Message",
Details =
[
"Error1",
"Error2"
]
},
null);

var formatted = exception.ToString();

Assert.Contains("My Message: Error1. Error2.", formatted);
}

[Fact]
public void Should_format_exception_with_dto_and_details_and_dots()
{
var exception =
new NotifoException<ErrorDto>(
"Error",
404,
string.Empty,
null,
new ErrorDto
{
Message = "My Message",
Details =
[
"Error1.",
"Error2 "
]
},
null);

var formatted = exception.ToString();

Assert.Contains("My Message: Error1. Error2.", formatted);
}
}
}
1 change: 1 addition & 0 deletions tools/sdk/Notifo.SDK/Generated.Custom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public override string ToString()

foreach (var detail in validDetails)
{
sb.Append(' ');
sb.Append(detail);

if (!detail.EndsWith('.'))
Expand Down

0 comments on commit f2557e6

Please sign in to comment.