Browse Source

add account-core package to nx workspace

pull/9837/head
mehmet-erim 5 years ago
parent
commit
37b7d321e3
  1. 43
      npm/ng-packs/nx/ng-packs/angular.json
  2. 2
      npm/ng-packs/nx/ng-packs/apps/dev-app/.eslintrc.json
  3. 2
      npm/ng-packs/nx/ng-packs/apps/dev-app/src/app/app.component.ts
  4. 2
      npm/ng-packs/nx/ng-packs/apps/dev-app/src/index.html
  5. 18
      npm/ng-packs/nx/ng-packs/nx.json
  6. 17
      npm/ng-packs/nx/ng-packs/package.json
  7. 36
      npm/ng-packs/nx/ng-packs/packages/account-core/.eslintrc.json
  8. 3
      npm/ng-packs/nx/ng-packs/packages/account-core/README.md
  9. 20
      npm/ng-packs/nx/ng-packs/packages/account-core/jest.config.js
  10. 7
      npm/ng-packs/nx/ng-packs/packages/account-core/ng-package.json
  11. 21
      npm/ng-packs/nx/ng-packs/packages/account-core/package.json
  12. 16
      npm/ng-packs/nx/ng-packs/packages/account-core/src/lib/auth-wrapper.service.spec.ts
  13. 46
      npm/ng-packs/nx/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts
  14. 16
      npm/ng-packs/nx/ng-packs/packages/account-core/src/lib/tenant-box.service.spec.ts
  15. 68
      npm/ng-packs/nx/ng-packs/packages/account-core/src/lib/tenant-box.service.ts
  16. 6
      npm/ng-packs/nx/ng-packs/packages/account-core/src/public-api.ts
  17. 1
      npm/ng-packs/nx/ng-packs/packages/account-core/src/test-setup.ts
  18. 13
      npm/ng-packs/nx/ng-packs/packages/account-core/tsconfig.json
  19. 14
      npm/ng-packs/nx/ng-packs/packages/account-core/tsconfig.lib.json
  20. 11
      npm/ng-packs/nx/ng-packs/packages/account-core/tsconfig.lib.prod.json
  21. 10
      npm/ng-packs/nx/ng-packs/packages/account-core/tsconfig.spec.json
  22. 3
      npm/ng-packs/nx/ng-packs/tsconfig.base.json
  23. 602
      npm/ng-packs/nx/ng-packs/yarn.lock

43
npm/ng-packs/nx/ng-packs/angular.json

@ -1,6 +1,47 @@
{
"version": 1,
"projects": {
"account-core": {
"projectType": "library",
"root": "packages/account-core",
"sourceRoot": "packages/account-core/src",
"prefix": "abp",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"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"
},
"development": {
"tsConfig": "packages/account-core/tsconfig.lib.json"
}
},
"defaultConfiguration": "production"
},
"test": {
"builder": "@nrwl/jest:jest",
"outputs": ["coverage/packages/account-core"],
"options": {
"jestConfig": "packages/account-core/jest.config.js",
"passWithNoTests": true
}
},
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": [
"packages/account-core/src/**/*.ts",
"packages/account-core/src/**/*.html"
]
}
}
}
},
"core": {
"projectType": "library",
"root": "packages/core",
@ -46,7 +87,7 @@
"projectType": "application",
"root": "apps/dev-app",
"sourceRoot": "apps/dev-app/src",
"prefix": "ng-packs",
"prefix": "abp",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",

2
npm/ng-packs/nx/ng-packs/apps/dev-app/.eslintrc.json

@ -21,7 +21,7 @@
"error",
{
"type": "element",
"prefix": "ng-packs",
"prefix": "abp",
"style": "kebab-case"
}
]

2
npm/ng-packs/nx/ng-packs/apps/dev-app/src/app/app.component.ts

@ -1,7 +1,7 @@
import { Component } from '@angular/core';
@Component({
selector: 'ng-packs-root',
selector: 'abp-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})

2
npm/ng-packs/nx/ng-packs/apps/dev-app/src/index.html

@ -8,6 +8,6 @@
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
<ng-packs-root></ng-packs-root>
<abp-root></abp-root>
</body>
</html>

18
npm/ng-packs/nx/ng-packs/nx.json

@ -1,7 +1,7 @@
{
"npmScope": "ng-packs",
"npmScope": "abp",
"affected": {
"defaultBase": "master"
"defaultBase": "dev"
},
"implicitDependencies": {
"package.json": {
@ -26,7 +26,15 @@
}
]
},
"workspaceLayout": {
"libsDir": "packages",
"appsDir": ""
},
"projects": {
"account-core": {
"tags": [],
"implicitDependencies": ["core", "theme-shared"]
},
"core": {
"tags": []
},
@ -38,10 +46,12 @@
"implicitDependencies": ["dev-app"]
},
"theme-basic": {
"tags": []
"tags": [],
"implicitDependencies": ["core", "theme-shared", "account-core"]
},
"theme-shared": {
"tags": []
"tags": [],
"implicitDependencies": ["core"]
}
}
}

17
npm/ng-packs/nx/ng-packs/package.json

@ -1,5 +1,5 @@
{
"name": "ng-packs",
"name": "abp-ng-packs",
"version": "0.0.0",
"license": "MIT",
"scripts": {
@ -30,6 +30,8 @@
"private": true,
"devDependencies": {
"@abp/ng.core": "~4.4.0",
"@abp/ng.account": "~4.4.0",
"@abp/ng.account.core": "~4.4.0",
"@abp/ng.feature-management": "~4.4.0",
"@abp/ng.identity": "~4.4.0",
"@abp/ng.permission-management": "~4.4.0",
@ -108,5 +110,18 @@
"tslint": "~6.1.0",
"typescript": "~4.3.5",
"zone.js": "~0.11.4"
},
"dependencies": {
"@angular/animations": "^12.1.0",
"@angular/common": "^12.1.0",
"@angular/compiler": "^12.1.0",
"@angular/core": "^12.1.0",
"@angular/forms": "^12.1.0",
"@angular/platform-browser": "^12.1.0",
"@angular/platform-browser-dynamic": "^12.1.0",
"@angular/router": "^12.1.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.4"
}
}

36
npm/ng-packs/nx/ng-packs/packages/account-core/.eslintrc.json

@ -0,0 +1,36 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"extends": [
"plugin:@nrwl/nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "abp",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "abp",
"style": "kebab-case"
}
]
}
},
{
"files": ["*.html"],
"extends": ["plugin:@nrwl/nx/angular-template"],
"rules": {}
}
]
}

3
npm/ng-packs/nx/ng-packs/packages/account-core/README.md

@ -0,0 +1,3 @@
# @abp/ng.account.core
Visit the [ABP documentation](https://docs.abp.io)

20
npm/ng-packs/nx/ng-packs/packages/account-core/jest.config.js

@ -0,0 +1,20 @@
module.exports = {
displayName: 'account-core',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
},
coverageDirectory: '../../coverage/packages/account-core',
transform: {
'^.+\\.(ts|js|html)$': 'jest-preset-angular',
},
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};

7
npm/ng-packs/nx/ng-packs/packages/account-core/ng-package.json

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

21
npm/ng-packs/nx/ng-packs/packages/account-core/package.json

@ -0,0 +1,21 @@
{
"name": "@abp/ng.account.core",
"version": "4.4.0",
"homepage": "https://abp.io",
"repository": {
"type": "git",
"url": "https://github.com/abpframework/abp.git"
},
"peerDependencies": {
"@abp/ng.core": "~4.4.0",
"@abp/ng.theme.shared": "~4.4.0",
"@angular/common": ">=12.0.0",
"@angular/core": ">=12.0.0"
},
"dependencies": {
"tslib": "^2.0.0"
},
"publishConfig": {
"access": "public"
}
}

16
npm/ng-packs/nx/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();
});
});

46
npm/ng-packs/nx/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts

@ -0,0 +1,46 @@
import { Injectable, Injector } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ActivatedRoute } from '@angular/router';
import { ConfigStateService, MultiTenancyService } from '@abp/ng.core';
@Injectable()
export class AuthWrapperService {
isMultiTenancyEnabled$ = this.configState.getDeep$('multiTenancy.isEnabled');
get enableLocalLogin$(): Observable<boolean> {
return this.configState
.getSetting$('Abp.Account.EnableLocalLogin')
.pipe(map(value => value?.toLowerCase() !== 'false'));
}
tenantBoxKey = 'Account.TenantBoxComponent';
route: ActivatedRoute;
get isTenantBoxVisibleForCurrentRoute() {
return this.getMostInnerChild().data.tenantBoxVisible ?? true;
}
get isTenantBoxVisible() {
return this.isTenantBoxVisibleForCurrentRoute && this.multiTenancy.isTenantBoxVisible;
}
constructor(
public readonly multiTenancy: MultiTenancyService,
private configState: ConfigStateService,
injector: Injector,
) {
this.route = injector.get(ActivatedRoute);
}
private getMostInnerChild() {
let child = this.route.snapshot;
let depth = 0;
const depthLimit = 10;
while (child.firstChild && depth < depthLimit) {
child = child.firstChild;
depth++;
}
return child;
}
}

16
npm/ng-packs/nx/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();
});
});

68
npm/ng-packs/nx/ng-packs/packages/account-core/src/lib/tenant-box.service.ts

@ -0,0 +1,68 @@
import { Injectable } from '@angular/core';
import { ToasterService } from '@abp/ng.theme.shared';
import {
AbpApplicationConfigurationService,
AbpTenantService,
ConfigStateService,
CurrentTenantDto,
SessionStateService,
} from '@abp/ng.core';
import { finalize } from 'rxjs/operators';
@Injectable()
export class TenantBoxService {
currentTenant$ = this.sessionState.getTenant$();
name: string;
isModalVisible: boolean;
modalBusy: boolean;
constructor(
private toasterService: ToasterService,
private tenantService: AbpTenantService,
private sessionState: SessionStateService,
private configState: ConfigStateService,
private appConfigService: AbpApplicationConfigurationService,
) {}
onSwitch() {
const tenant = this.sessionState.getTenant();
this.name = tenant?.name;
this.isModalVisible = true;
}
save() {
if (!this.name) {
this.setTenant(null);
this.isModalVisible = false;
return;
}
this.modalBusy = true;
this.tenantService
.findTenantByName(this.name, {})
.pipe(finalize(() => (this.modalBusy = false)))
.subscribe(({ success, tenantId: id, ...tenant }) => {
if (!success) {
this.showError();
return;
}
this.setTenant({ ...tenant, id, isAvailable: true });
this.isModalVisible = false;
});
}
private setTenant(tenant: CurrentTenantDto) {
this.sessionState.setTenant(tenant);
this.appConfigService.get().subscribe(res => this.configState.setState(res));
}
private showError() {
this.toasterService.error('AbpUiMultiTenancy::GivenTenantIsNotAvailable', 'AbpUi::Error', {
messageLocalizationParams: [this.name],
});
}
}

6
npm/ng-packs/nx/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';

1
npm/ng-packs/nx/ng-packs/packages/account-core/src/test-setup.ts

@ -0,0 +1 @@
import 'jest-preset-angular/setup-jest';

13
npm/ng-packs/nx/ng-packs/packages/account-core/tsconfig.json

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

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

@ -0,0 +1,14 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"target": "es2015",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": [],
"lib": ["dom", "es2018"]
},
"exclude": ["src/test-setup.ts", "**/*.spec.ts"],
"include": ["**/*.ts"]
}

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

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

10
npm/ng-packs/nx/ng-packs/packages/account-core/tsconfig.spec.json

@ -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", "**/*.d.ts"]
}

3
npm/ng-packs/nx/ng-packs/tsconfig.base.json

@ -15,10 +15,9 @@
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
// "@abp/ng.core": ["packages/core/src/public-api.ts"],
// "@abp/ng.theme.shared": ["packages/theme-shared/src/public-api.ts"]
"@abp/ng.core": ["dist/packages/core"],
"@abp/ng.theme.shared": ["dist/packages/theme-shared"],
"@abp/ng.account.core": ["dist/packages/account-core"],
"@abp/ng.theme.basic": ["dist/packages/theme-basic"]
}
},

602
npm/ng-packs/nx/ng-packs/yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save