Browse Source

create account core package and create services

pull/9395/head
muhammedaltug 5 years ago
parent
commit
cd8e346afe
  1. 40
      npm/ng-packs/angular.json
  2. 24
      npm/ng-packs/packages/account-core/README.md
  3. 44
      npm/ng-packs/packages/account-core/karma.conf.js
  4. 8
      npm/ng-packs/packages/account-core/ng-package.json
  5. 18
      npm/ng-packs/packages/account-core/package.json
  6. 16
      npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.spec.ts
  7. 16
      npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts
  8. 16
      npm/ng-packs/packages/account-core/src/lib/tenant-box.service.spec.ts
  9. 13
      npm/ng-packs/packages/account-core/src/lib/tenant-box.service.ts
  10. 6
      npm/ng-packs/packages/account-core/src/public-api.ts
  11. 26
      npm/ng-packs/packages/account-core/src/test.ts
  12. 20
      npm/ng-packs/packages/account-core/tsconfig.lib.json
  13. 6
      npm/ng-packs/packages/account-core/tsconfig.lib.prod.json
  14. 17
      npm/ng-packs/packages/account-core/tsconfig.spec.json
  15. 17
      npm/ng-packs/packages/account-core/tslint.json
  16. 1
      npm/ng-packs/tsconfig.json

40
npm/ng-packs/angular.json

@ -541,6 +541,46 @@
}
}
}
},
"account-core": {
"projectType": "library",
"root": "packages/account-core",
"sourceRoot": "packages/account-core/src",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"tsConfig": "packages/account-core/tsconfig.lib.json",
"project": "packages/account-core/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "packages/account-core/tsconfig.lib.prod.json"
}
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "packages/account-core/src/test.ts",
"tsConfig": "packages/account-core/tsconfig.spec.json",
"karmaConfig": "packages/account-core/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"packages/account-core/tsconfig.lib.json",
"packages/account-core/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"cli": {

24
npm/ng-packs/packages/account-core/README.md

@ -0,0 +1,24 @@
# AccountCore
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 11.1.2.
## Code scaffolding
Run `ng generate component component-name --project account-core` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project account-core`.
> Note: Don't forget to add `--project account-core` or else it will be added to the default project in your `angular.json` file.
## Build
Run `ng build account-core` to build the project. The build artifacts will be stored in the `dist/` directory.
## Publishing
After building your library with `ng build account-core`, go to the dist folder `cd dist/account-core` and run `npm publish`.
## Running unit tests
Run `ng test account-core` 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.

44
npm/ng-packs/packages/account-core/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/account-core'),
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
});
};

8
npm/ng-packs/packages/account-core/ng-package.json

@ -0,0 +1,8 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/account-core",
"lib": {
"entryFile": "src/public-api.ts"
},
"allowedNonPeerDependencies": ["@abp/ng.core", "@abp/ng.theme.shared"]
}

18
npm/ng-packs/packages/account-core/package.json

@ -0,0 +1,18 @@
{
"name": "@abp/ng.account-core",
"version": "0.0.1",
"homepage": "https://abp.io",
"repository": {
"type": "git",
"url": "https://github.com/abpframework/abp.git"
},
"peerDependencies": {
"@angular/common": "^11.1.2",
"@angular/core": "^11.1.2"
},
"dependencies": {
"tslib": "^2.0.0",
"@abp/ng.core": "~4.3.3",
"@abp/ng.theme.shared": "~4.3.3"
}
}

16
npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.spec.ts

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

16
npm/ng-packs/packages/account/src/lib/components/auth-wrapper/auth-wrapper.component.ts → npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts

@ -1,17 +1,11 @@
import { ConfigStateService, MultiTenancyService, SubscriptionService } from '@abp/ng.core';
import { Component, Injector } from '@angular/core';
import { Injectable, Injector } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { eAccountComponents } from '../../enums/components';
import { ActivatedRoute } from '@angular/router';
import { ConfigStateService, MultiTenancyService } from '@abp/ng.core';
@Component({
selector: 'abp-auth-wrapper',
templateUrl: './auth-wrapper.component.html',
exportAs: 'abpAuthWrapper',
providers: [SubscriptionService],
})
export class AuthWrapperComponent {
@Injectable()
export class AuthWrapperService {
isMultiTenancyEnabled$ = this.configState.getDeep$('multiTenancy.isEnabled');
get enableLocalLogin$(): Observable<boolean> {
@ -20,7 +14,7 @@ export class AuthWrapperComponent {
.pipe(map(value => value?.toLowerCase() !== 'false'));
}
tenantBoxKey = eAccountComponents.TenantBox;
tenantBoxKey = 'Account.TenantBoxComponent';
route: ActivatedRoute;
private _tenantBoxVisible = true;

16
npm/ng-packs/packages/account-core/src/lib/tenant-box.service.spec.ts

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

13
npm/ng-packs/packages/account/src/lib/components/tenant-box/tenant-box.component.ts → npm/ng-packs/packages/account-core/src/lib/tenant-box.service.ts

@ -1,3 +1,5 @@
import { Injectable } from '@angular/core';
import { ToasterService } from '@abp/ng.theme.shared';
import {
AbpApplicationConfigurationService,
AbpTenantService,
@ -5,17 +7,10 @@ import {
CurrentTenantDto,
SessionStateService,
} from '@abp/ng.core';
import { ToasterService } from '@abp/ng.theme.shared';
import { Component } from '@angular/core';
import { finalize } from 'rxjs/operators';
import { Account } from '../../models/account';
@Component({
selector: 'abp-tenant-box',
templateUrl: './tenant-box.component.html',
})
export class TenantBoxComponent
implements Account.TenantBoxComponentInputs, Account.TenantBoxComponentOutputs {
@Injectable()
export class TenantBoxService {
currentTenant$ = this.sessionState.getTenant$();
name: string;

6
npm/ng-packs/packages/account-core/src/public-api.ts

@ -0,0 +1,6 @@
/*
* Public API Surface of account-core
*/
export * from './lib/auth-wrapper.service';
export * from './lib/tenant-box.service';

26
npm/ng-packs/packages/account-core/src/test.ts

@ -0,0 +1,26 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone';
import 'zone.js/dist/zone-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): {
keys(): string[];
<T>(id: string): T;
};
};
// 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().map(context);

20
npm/ng-packs/packages/account-core/tsconfig.lib.json

@ -0,0 +1,20 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.prod.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"declaration": true,
"inlineSources": true,
"types": [],
"lib": ["dom", "es2018"]
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
},
"exclude": ["src/test.ts", "**/*.spec.ts"]
}

6
npm/ng-packs/packages/account-core/tsconfig.lib.prod.json

@ -0,0 +1,6 @@
{
"extends": "./tsconfig.lib.json",
"angularCompilerOptions": {
"enableIvy": false
}
}

17
npm/ng-packs/packages/account-core/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"
]
}

17
npm/ng-packs/packages/account-core/tslint.json

@ -0,0 +1,17 @@
{
"extends": "../../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"lib",
"camelCase"
],
"component-selector": [
true,
"element",
"lib",
"kebab-case"
]
}
}

1
npm/ng-packs/tsconfig.json

@ -25,6 +25,7 @@
"@abp/ng.components/page": ["packages/components/page/src/public-api.ts"],
"@abp/ng.theme.basic": ["packages/theme-basic/src/public-api.ts"],
"@abp/ng.account": ["packages/account/src/public-api.ts"],
"@abp/ng.account-core": ["packages/account-core/src/public-api.ts"],
"@abp/ng.account/config": ["packages/account/config/src/public-api.ts"],
"@abp/ng.identity": ["packages/identity/src/public-api.ts"],
"@abp/ng.identity/config": ["packages/identity/config/src/public-api.ts"],

Loading…
Cancel
Save