From 8431ee20811ec40cb76d88df48edd20f176b1579 Mon Sep 17 00:00:00 2001 From: dslak Date: Wed, 5 Jul 2023 10:45:53 +0200 Subject: [PATCH] lib init --- README.md | 24 ++++++++++++++ karma.conf.js | 44 ++++++++++++++++++++++++++ ng-package.json | 7 ++++ package.json | 11 +++++++ src/lib/boss-library.component.spec.ts | 23 ++++++++++++++ src/lib/boss-library.component.ts | 20 ++++++++++++ src/lib/boss-library.module.ts | 16 ++++++++++ src/lib/boss-library.service.spec.ts | 16 ++++++++++ src/lib/boss-library.service.ts | 9 ++++++ src/public-api.ts | 7 ++++ src/test.ts | 27 ++++++++++++++++ tsconfig.lib.json | 15 +++++++++ tsconfig.lib.prod.json | 10 ++++++ tsconfig.spec.json | 17 ++++++++++ 14 files changed, 246 insertions(+) create mode 100644 README.md create mode 100644 karma.conf.js create mode 100644 ng-package.json create mode 100644 package.json create mode 100644 src/lib/boss-library.component.spec.ts create mode 100644 src/lib/boss-library.component.ts create mode 100644 src/lib/boss-library.module.ts create mode 100644 src/lib/boss-library.service.spec.ts create mode 100644 src/lib/boss-library.service.ts create mode 100644 src/public-api.ts create mode 100644 src/test.ts create mode 100644 tsconfig.lib.json create mode 100644 tsconfig.lib.prod.json create mode 100644 tsconfig.spec.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..9b67486 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# BossLibrary + +This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 14.0.0. + +## Code scaffolding + +Run `ng generate component component-name --project boss-library` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project boss-library`. +> Note: Don't forget to add `--project boss-library` or else it will be added to the default project in your `angular.json` file. + +## Build + +Run `ng build boss-library` to build the project. The build artifacts will be stored in the `dist/` directory. + +## Publishing + +After building your library with `ng build boss-library`, go to the dist folder `cd dist/boss-library` and run `npm publish`. + +## Running unit tests + +Run `ng test boss-library` 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. diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000..699705a --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,44 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + jasmine: { + // you can add configuration options for Jasmine here + // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html + // for example, you can disable the random execution with `random: false` + // or set a specific seed with `seed: 4321` + }, + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + jasmineHtmlReporter: { + suppressAll: true // removes the duplicated traces + }, + coverageReporter: { + dir: require('path').join(__dirname, '../../coverage/boss-library'), + subdir: '.', + reporters: [ + { type: 'html' }, + { type: 'text-summary' } + ] + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + restartOnFileChange: true + }); +}; diff --git a/ng-package.json b/ng-package.json new file mode 100644 index 0000000..de3bccd --- /dev/null +++ b/ng-package.json @@ -0,0 +1,7 @@ +{ + "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../dist/boss-library", + "lib": { + "entryFile": "src/public-api.ts" + } +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..552096e --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "boss-library", + "version": "0.0.1", + "peerDependencies": { + "@angular/common": "^14.0.0", + "@angular/core": "^14.0.0" + }, + "dependencies": { + "tslib": "^2.3.0" + } +} \ No newline at end of file diff --git a/src/lib/boss-library.component.spec.ts b/src/lib/boss-library.component.spec.ts new file mode 100644 index 0000000..f172ecc --- /dev/null +++ b/src/lib/boss-library.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { BossLibraryComponent } from './boss-library.component'; + +describe('BossLibraryComponent', () => { + let component: BossLibraryComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ BossLibraryComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(BossLibraryComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/lib/boss-library.component.ts b/src/lib/boss-library.component.ts new file mode 100644 index 0000000..33b5172 --- /dev/null +++ b/src/lib/boss-library.component.ts @@ -0,0 +1,20 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'lib-boss-library', + template: ` +

+ boss-library works! +

+ `, + styles: [ + ] +}) +export class BossLibraryComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/lib/boss-library.module.ts b/src/lib/boss-library.module.ts new file mode 100644 index 0000000..8a9d083 --- /dev/null +++ b/src/lib/boss-library.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { BossLibraryComponent } from './boss-library.component'; + + + +@NgModule({ + declarations: [ + BossLibraryComponent + ], + imports: [ + ], + exports: [ + BossLibraryComponent + ] +}) +export class BossLibraryModule { } diff --git a/src/lib/boss-library.service.spec.ts b/src/lib/boss-library.service.spec.ts new file mode 100644 index 0000000..07aa1e5 --- /dev/null +++ b/src/lib/boss-library.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { BossLibraryService } from './boss-library.service'; + +describe('BossLibraryService', () => { + let service: BossLibraryService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(BossLibraryService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/lib/boss-library.service.ts b/src/lib/boss-library.service.ts new file mode 100644 index 0000000..e694146 --- /dev/null +++ b/src/lib/boss-library.service.ts @@ -0,0 +1,9 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class BossLibraryService { + + constructor() { } +} diff --git a/src/public-api.ts b/src/public-api.ts new file mode 100644 index 0000000..b6a722f --- /dev/null +++ b/src/public-api.ts @@ -0,0 +1,7 @@ +/* + * Public API Surface of boss-library + */ + +export * from './lib/boss-library.service'; +export * from './lib/boss-library.component'; +export * from './lib/boss-library.module'; diff --git a/src/test.ts b/src/test.ts new file mode 100644 index 0000000..5775317 --- /dev/null +++ b/src/test.ts @@ -0,0 +1,27 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js'; +import 'zone.js/testing'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +declare const require: { + context(path: string, deep?: boolean, filter?: RegExp): { + (id: string): T; + keys(): string[]; + }; +}; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting(), +); + +// Then we find all the tests. +const context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().forEach(context); diff --git a/tsconfig.lib.json b/tsconfig.lib.json new file mode 100644 index 0000000..b77b13c --- /dev/null +++ b/tsconfig.lib.json @@ -0,0 +1,15 @@ +/* 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": [ + "src/test.ts", + "**/*.spec.ts" + ] +} diff --git a/tsconfig.lib.prod.json b/tsconfig.lib.prod.json new file mode 100644 index 0000000..06de549 --- /dev/null +++ b/tsconfig.lib.prod.json @@ -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" + } +} diff --git a/tsconfig.spec.json b/tsconfig.spec.json new file mode 100644 index 0000000..715dd0a --- /dev/null +++ b/tsconfig.spec.json @@ -0,0 +1,17 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/spec", + "types": [ + "jasmine" + ] + }, + "files": [ + "src/test.ts" + ], + "include": [ + "**/*.spec.ts", + "**/*.d.ts" + ] +}