Added external library to the project

This commit is contained in:
Lorenz Hilpert
2023-02-03 16:20:45 +01:00
parent 06fe8b3742
commit 3cdb3d6294
21 changed files with 246 additions and 0 deletions

View File

@@ -1566,6 +1566,40 @@
}
}
}
},
"external": {
"projectType": "library",
"root": "apps/external",
"sourceRoot": "apps/external",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"project": "apps/external/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "apps/external/tsconfig.lib.prod.json"
},
"development": {
"tsConfig": "apps/external/tsconfig.lib.json"
}
},
"defaultConfiguration": "production"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"tsConfig": "apps/external/tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"polyfills": [
"zone.js",
"zone.js/testing"
]
}
}
}
}
}
}

25
apps/external/README.md vendored Normal file
View File

@@ -0,0 +1,25 @@
# External
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 15.0.0.
## Code scaffolding
Run `ng generate component component-name --project external` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project external`.
> Note: Don't forget to add `--project external` or else it will be added to the default project in your `angular.json` file.
## Build
Run `ng build external` to build the project. The build artifacts will be stored in the `dist/` directory.
## Publishing
After building your library with `ng build external`, go to the dist folder `cd dist/external` and run `npm publish`.
## Running unit tests
Run `ng test external` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.

7
apps/external/ng-package.json vendored Normal file
View File

@@ -0,0 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/external",
"lib": {
"entryFile": "src/public-api.ts"
}
}

View File

@@ -0,0 +1,6 @@
{
"$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
"lib": {
"entryFile": "src/public-api.ts"
}
}

View File

@@ -0,0 +1 @@
export * from './place.dto';

View File

@@ -0,0 +1,12 @@
/**
* @see https://nominatim.org/release-docs/latest/api/Output/
*/
export interface PlaceDto {
place_id: number;
lat: string;
lon: string;
display_name: string;
}

View File

@@ -0,0 +1,8 @@
export namespace OpenStreetMapParams {
export interface Query {
q?: string;
postalcode?: string;
country?: string;
limit?: number;
}
}

View File

@@ -0,0 +1,20 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { OpenStreetMapParams } from './openstreetmap.params';
import { PlaceDto } from './defs';
@Injectable({ providedIn: 'root' })
export class OpenStreetMap {
url = 'https://nominatim.openstreetmap.org/';
constructor(private httpClient: HttpClient) {}
query(query: OpenStreetMapParams.Query) {
return this.httpClient.get<PlaceDto[]>(`${this.url}search`, {
params: {
format: 'json',
...query,
},
});
}
}

View File

@@ -0,0 +1,3 @@
export * from './lib/openstreetmap.service';
export * from './lib/openstreetmap.params';
export * from './lib/defs';

11
apps/external/package.json vendored Normal file
View File

@@ -0,0 +1,11 @@
{
"name": "external",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^15.0.0",
"@angular/core": "^15.0.0"
},
"dependencies": {
"tslib": "^2.3.0"
}
}

View File

@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ExternalComponent } from './external.component';
describe('ExternalComponent', () => {
let component: ExternalComponent;
let fixture: ComponentFixture<ExternalComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ExternalComponent],
}).compileComponents();
fixture = TestBed.createComponent(ExternalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,12 @@
import { Component } from '@angular/core';
@Component({
selector: 'lib-external',
template: `
<p>
external works!
</p>
`,
styles: [],
})
export class ExternalComponent {}

View File

@@ -0,0 +1,9 @@
import { NgModule } from '@angular/core';
import { ExternalComponent } from './external.component';
@NgModule({
declarations: [ExternalComponent],
imports: [],
exports: [ExternalComponent],
})
export class ExternalModule {}

View File

@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { ExternalService } from './external.service';
describe('ExternalService', () => {
let service: ExternalService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ExternalService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@@ -0,0 +1,8 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root',
})
export class ExternalService {
constructor() {}
}

7
apps/external/src/public-api.ts vendored Normal file
View File

@@ -0,0 +1,7 @@
/*
* Public API Surface of external
*/
export * from './lib/external.service';
export * from './lib/external.component';
export * from './lib/external.module';

14
apps/external/tsconfig.lib.json vendored Normal file
View File

@@ -0,0 +1,14 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": []
},
"exclude": [
"**/*.spec.ts"
]
}

10
apps/external/tsconfig.lib.prod.json vendored Normal file
View File

@@ -0,0 +1,10 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false
},
"angularCompilerOptions": {
"compilationMode": "partial"
}
}

14
apps/external/tsconfig.spec.json vendored Normal file
View File

@@ -0,0 +1,14 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/spec",
"types": [
"jasmine"
]
},
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}

View File

@@ -21,6 +21,7 @@
"*test:domain-printer": "ng test @domain/printer",
"test:domain-remission": "ng test @domain/remission",
"*test:domain-task-calendar": "ng test @domain/task-calendar",
"test:external": "ng test external",
"*test:hub-notifications": "ng test @hub/notifications",
"*test:isa-remission": "ng test @isa/remission",
"*test:modal-availabilities": "ng test @modal/availabilities",

View File

@@ -159,6 +159,12 @@
"core": [
"dist/core"
],
"external": [
"dist/external"
],
"@external/*": [
"apps/external/*/src/public-api.ts"
],
"native-container": [
"apps/native-container/src/public-api.ts"
],