From 7856b223533aaedbb9b068ab8116daffa985b70c Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Tue, 8 Oct 2019 10:14:02 +0300 Subject: [PATCH] feat: create libraries in the module-template #1652 --- .../src/lib/services/account.service.ts | 6 +- templates/module/angular/angular.json | 70 +++++++++++++++++++ templates/module/angular/package.json | 3 + .../projects/my-project-name-config/README.md | 1 + .../my-project-name-config/karma.conf.js | 32 +++++++++ .../my-project-name-config/ng-package.json | 7 ++ .../my-project-name-config/package.json | 7 ++ .../src/lib/my-project-name-config.module.ts | 10 +++ .../my-project-name-config.service.ts | 16 +++++ .../my-project-name-config/src/public-api.ts | 2 + .../my-project-name-config/src/test.ts | 21 ++++++ .../my-project-name-config/tsconfig.lib.json | 26 +++++++ .../my-project-name-config/tsconfig.spec.json | 17 +++++ .../my-project-name-config/tslint.json | 17 +++++ .../projects/my-project-name/README.md | 1 + .../projects/my-project-name/karma.conf.js | 32 +++++++++ .../projects/my-project-name/ng-package.json | 8 +++ .../projects/my-project-name/package.json | 8 +++ .../my-project-name.component.spec.ts | 24 +++++++ .../components/my-project-name.component.ts | 19 +++++ .../src/lib/my-project-name-routing.module.ts | 20 ++++++ .../src/lib/my-project-name.module.ts | 12 ++++ .../my-project-name/src/public-api.ts | 2 + .../projects/my-project-name/src/test.ts | 21 ++++++ .../my-project-name/tsconfig.lib.json | 26 +++++++ .../my-project-name/tsconfig.spec.json | 17 +++++ .../projects/my-project-name/tslint.json | 17 +++++ .../angular/src/app/app-routing.module.ts | 4 ++ .../module/angular/src/app/app.module.ts | 2 + .../my-project-name-wrapper.module.ts | 7 ++ templates/module/angular/tsconfig.json | 18 ++++- 31 files changed, 468 insertions(+), 5 deletions(-) create mode 100644 templates/module/angular/projects/my-project-name-config/README.md create mode 100644 templates/module/angular/projects/my-project-name-config/karma.conf.js create mode 100644 templates/module/angular/projects/my-project-name-config/ng-package.json create mode 100644 templates/module/angular/projects/my-project-name-config/package.json create mode 100644 templates/module/angular/projects/my-project-name-config/src/lib/my-project-name-config.module.ts create mode 100644 templates/module/angular/projects/my-project-name-config/src/lib/services/my-project-name-config.service.ts create mode 100644 templates/module/angular/projects/my-project-name-config/src/public-api.ts create mode 100644 templates/module/angular/projects/my-project-name-config/src/test.ts create mode 100644 templates/module/angular/projects/my-project-name-config/tsconfig.lib.json create mode 100644 templates/module/angular/projects/my-project-name-config/tsconfig.spec.json create mode 100644 templates/module/angular/projects/my-project-name-config/tslint.json create mode 100644 templates/module/angular/projects/my-project-name/README.md create mode 100644 templates/module/angular/projects/my-project-name/karma.conf.js create mode 100644 templates/module/angular/projects/my-project-name/ng-package.json create mode 100644 templates/module/angular/projects/my-project-name/package.json create mode 100644 templates/module/angular/projects/my-project-name/src/lib/components/my-project-name.component.spec.ts create mode 100644 templates/module/angular/projects/my-project-name/src/lib/components/my-project-name.component.ts create mode 100644 templates/module/angular/projects/my-project-name/src/lib/my-project-name-routing.module.ts create mode 100644 templates/module/angular/projects/my-project-name/src/lib/my-project-name.module.ts create mode 100644 templates/module/angular/projects/my-project-name/src/public-api.ts create mode 100644 templates/module/angular/projects/my-project-name/src/test.ts create mode 100644 templates/module/angular/projects/my-project-name/tsconfig.lib.json create mode 100644 templates/module/angular/projects/my-project-name/tsconfig.spec.json create mode 100644 templates/module/angular/projects/my-project-name/tslint.json create mode 100644 templates/module/angular/src/app/lazy-libs/my-project-name-wrapper.module.ts diff --git a/npm/ng-packs/packages/account/src/lib/services/account.service.ts b/npm/ng-packs/packages/account/src/lib/services/account.service.ts index 5061cfeea1..6c2571a518 100644 --- a/npm/ng-packs/packages/account/src/lib/services/account.service.ts +++ b/npm/ng-packs/packages/account/src/lib/services/account.service.ts @@ -4,7 +4,7 @@ import { RestService, Rest } from '@abp/ng.core'; import { RegisterResponse, RegisterRequest, TenantIdResponse } from '../models'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class AccountService { constructor(private rest: RestService) {} @@ -12,7 +12,7 @@ export class AccountService { findTenant(tenantName: string): Observable { const request: Rest.Request = { method: 'GET', - url: `/api/abp/multi-tenancy/tenants/by-name/${tenantName}` + url: `/api/abp/multi-tenancy/tenants/by-name/${tenantName}`, }; return this.rest.request(request); @@ -22,7 +22,7 @@ export class AccountService { const request: Rest.Request = { method: 'POST', url: '/api/account/register', - body + body, }; return this.rest.request(request, { skipHandleError: true }); diff --git a/templates/module/angular/angular.json b/templates/module/angular/angular.json index 5d5b8fae2b..1f298b967c 100644 --- a/templates/module/angular/angular.json +++ b/templates/module/angular/angular.json @@ -130,6 +130,76 @@ } } } + }, + "my-project-name": { + "projectType": "library", + "root": "projects/my-project-name", + "sourceRoot": "projects/my-project-name/src", + "prefix": "lib", + "architect": { + "build": { + "builder": "@angular-devkit/build-ng-packagr:build", + "options": { + "tsConfig": "projects/my-project-name/tsconfig.lib.json", + "project": "projects/my-project-name/ng-package.json" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "projects/my-project-name/src/test.ts", + "tsConfig": "projects/my-project-name/tsconfig.spec.json", + "karmaConfig": "projects/my-project-name/karma.conf.js" + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "projects/my-project-name/tsconfig.lib.json", + "projects/my-project-name/tsconfig.spec.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + } + } + }, + "my-project-name-config": { + "projectType": "library", + "root": "projects/my-project-name-config", + "sourceRoot": "projects/my-project-name-config/src", + "prefix": "lib", + "architect": { + "build": { + "builder": "@angular-devkit/build-ng-packagr:build", + "options": { + "tsConfig": "projects/my-project-name-config/tsconfig.lib.json", + "project": "projects/my-project-name-config/ng-package.json" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "projects/my-project-name-config/src/test.ts", + "tsConfig": "projects/my-project-name-config/tsconfig.spec.json", + "karmaConfig": "projects/my-project-name-config/karma.conf.js" + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "projects/my-project-name-config/tsconfig.lib.json", + "projects/my-project-name-config/tsconfig.spec.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + } + } } }, "defaultProject": "myProjectName" diff --git a/templates/module/angular/package.json b/templates/module/angular/package.json index 09791aefac..93edc29006 100644 --- a/templates/module/angular/package.json +++ b/templates/module/angular/package.json @@ -32,6 +32,7 @@ }, "devDependencies": { "@angular-devkit/build-angular": "~0.803.6", + "@angular-devkit/build-ng-packagr": "~0.803.6", "@angular/cli": "~8.3.6", "@angular/compiler-cli": "~8.2.8", "@angular/language-service": "~8.2.8", @@ -46,9 +47,11 @@ "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~2.0.1", "karma-jasmine-html-reporter": "^1.4.0", + "ng-packagr": "^5.4.0", "ngxs-schematic": "^1.1.9", "protractor": "~5.4.0", "ts-node": "~7.0.0", + "tsickle": "^0.37.0", "tslint": "~5.15.0", "typescript": "~3.5.3" } diff --git a/templates/module/angular/projects/my-project-name-config/README.md b/templates/module/angular/projects/my-project-name-config/README.md new file mode 100644 index 0000000000..3fea508c67 --- /dev/null +++ b/templates/module/angular/projects/my-project-name-config/README.md @@ -0,0 +1 @@ +# MyProjectNameConfig \ No newline at end of file diff --git a/templates/module/angular/projects/my-project-name-config/karma.conf.js b/templates/module/angular/projects/my-project-name-config/karma.conf.js new file mode 100644 index 0000000000..ea173152ce --- /dev/null +++ b/templates/module/angular/projects/my-project-name-config/karma.conf.js @@ -0,0 +1,32 @@ +// 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-istanbul-reporter'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + dir: require('path').join(__dirname, '../../coverage/my-project-name-config'), + reports: ['html', 'lcovonly', 'text-summary'], + fixWebpackSourcePaths: true + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + restartOnFileChange: true + }); +}; diff --git a/templates/module/angular/projects/my-project-name-config/ng-package.json b/templates/module/angular/projects/my-project-name-config/ng-package.json new file mode 100644 index 0000000000..ed77c0b99d --- /dev/null +++ b/templates/module/angular/projects/my-project-name-config/ng-package.json @@ -0,0 +1,7 @@ +{ + "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../dist/my-project-name-config", + "lib": { + "entryFile": "src/public-api.ts" + } +} \ No newline at end of file diff --git a/templates/module/angular/projects/my-project-name-config/package.json b/templates/module/angular/projects/my-project-name-config/package.json new file mode 100644 index 0000000000..35666a4240 --- /dev/null +++ b/templates/module/angular/projects/my-project-name-config/package.json @@ -0,0 +1,7 @@ +{ + "name": "my-project-name.config", + "version": "0.0.1", + "peerDependencies": { + "@abp/ng.core": ">=0.9.0" + } +} diff --git a/templates/module/angular/projects/my-project-name-config/src/lib/my-project-name-config.module.ts b/templates/module/angular/projects/my-project-name-config/src/lib/my-project-name-config.module.ts new file mode 100644 index 0000000000..e230b3c2c0 --- /dev/null +++ b/templates/module/angular/projects/my-project-name-config/src/lib/my-project-name-config.module.ts @@ -0,0 +1,10 @@ +import { NgModule, APP_INITIALIZER } from '@angular/core'; +import { MyProjectNameConfigService } from './services/my-project-name-config.service'; +import { noop } from '@abp/ng.core'; + +@NgModule({ + declarations: [], + providers: [{ provide: APP_INITIALIZER, deps: [MyProjectNameConfigService], multi: true, useFactory: noop }], + exports: [], +}) +export class MyProjectNameConfigModule {} diff --git a/templates/module/angular/projects/my-project-name-config/src/lib/services/my-project-name-config.service.ts b/templates/module/angular/projects/my-project-name-config/src/lib/services/my-project-name-config.service.ts new file mode 100644 index 0000000000..0596ab8711 --- /dev/null +++ b/templates/module/angular/projects/my-project-name-config/src/lib/services/my-project-name-config.service.ts @@ -0,0 +1,16 @@ +import { Injectable } from '@angular/core'; +import { eLayoutType, addAbpRoutes, ABP } from '@abp/ng.core'; + +@Injectable({ + providedIn: 'root', +}) +export class MyProjectNameConfigService { + constructor() { + addAbpRoutes({ + name: 'MyProjectName', + path: 'my-project-name', + layout: eLayoutType.application, + order: 2, + } as ABP.FullRoute); + } +} diff --git a/templates/module/angular/projects/my-project-name-config/src/public-api.ts b/templates/module/angular/projects/my-project-name-config/src/public-api.ts new file mode 100644 index 0000000000..6d4033b309 --- /dev/null +++ b/templates/module/angular/projects/my-project-name-config/src/public-api.ts @@ -0,0 +1,2 @@ +export * from './lib/services/my-project-name-config.service'; +export * from './lib/my-project-name-config.module'; diff --git a/templates/module/angular/projects/my-project-name-config/src/test.ts b/templates/module/angular/projects/my-project-name-config/src/test.ts new file mode 100644 index 0000000000..978c64fb83 --- /dev/null +++ b/templates/module/angular/projects/my-project-name-config/src/test.ts @@ -0,0 +1,21 @@ +// 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: any; + +// 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); diff --git a/templates/module/angular/projects/my-project-name-config/tsconfig.lib.json b/templates/module/angular/projects/my-project-name-config/tsconfig.lib.json new file mode 100644 index 0000000000..bd23948e59 --- /dev/null +++ b/templates/module/angular/projects/my-project-name-config/tsconfig.lib.json @@ -0,0 +1,26 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/lib", + "target": "es2015", + "declaration": true, + "inlineSources": true, + "types": [], + "lib": [ + "dom", + "es2018" + ] + }, + "angularCompilerOptions": { + "annotateForClosureCompiler": true, + "skipTemplateCodegen": true, + "strictMetadataEmit": true, + "fullTemplateTypeCheck": true, + "strictInjectionParameters": true, + "enableResourceInlining": true + }, + "exclude": [ + "src/test.ts", + "**/*.spec.ts" + ] +} diff --git a/templates/module/angular/projects/my-project-name-config/tsconfig.spec.json b/templates/module/angular/projects/my-project-name-config/tsconfig.spec.json new file mode 100644 index 0000000000..16da33db07 --- /dev/null +++ b/templates/module/angular/projects/my-project-name-config/tsconfig.spec.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/spec", + "types": [ + "jasmine", + "node" + ] + }, + "files": [ + "src/test.ts" + ], + "include": [ + "**/*.spec.ts", + "**/*.d.ts" + ] +} diff --git a/templates/module/angular/projects/my-project-name-config/tslint.json b/templates/module/angular/projects/my-project-name-config/tslint.json new file mode 100644 index 0000000000..124133f849 --- /dev/null +++ b/templates/module/angular/projects/my-project-name-config/tslint.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tslint.json", + "rules": { + "directive-selector": [ + true, + "attribute", + "lib", + "camelCase" + ], + "component-selector": [ + true, + "element", + "lib", + "kebab-case" + ] + } +} diff --git a/templates/module/angular/projects/my-project-name/README.md b/templates/module/angular/projects/my-project-name/README.md new file mode 100644 index 0000000000..04db0abd53 --- /dev/null +++ b/templates/module/angular/projects/my-project-name/README.md @@ -0,0 +1 @@ +# MyProjectName \ No newline at end of file diff --git a/templates/module/angular/projects/my-project-name/karma.conf.js b/templates/module/angular/projects/my-project-name/karma.conf.js new file mode 100644 index 0000000000..ef0285b27f --- /dev/null +++ b/templates/module/angular/projects/my-project-name/karma.conf.js @@ -0,0 +1,32 @@ +// 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-istanbul-reporter'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + dir: require('path').join(__dirname, '../../coverage/my-project-name'), + reports: ['html', 'lcovonly', 'text-summary'], + fixWebpackSourcePaths: true + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + restartOnFileChange: true + }); +}; diff --git a/templates/module/angular/projects/my-project-name/ng-package.json b/templates/module/angular/projects/my-project-name/ng-package.json new file mode 100644 index 0000000000..d201249406 --- /dev/null +++ b/templates/module/angular/projects/my-project-name/ng-package.json @@ -0,0 +1,8 @@ +{ + "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../dist/my-project-name", + "lib": { + "entryFile": "src/public-api.ts" + }, + "whitelistedNonPeerDependencies": ["@abp/ng.theme.shared", "my-project-name.config"] +} diff --git a/templates/module/angular/projects/my-project-name/package.json b/templates/module/angular/projects/my-project-name/package.json new file mode 100644 index 0000000000..91425b889b --- /dev/null +++ b/templates/module/angular/projects/my-project-name/package.json @@ -0,0 +1,8 @@ +{ + "name": "my-project-name", + "version": "0.0.1", + "dependencies": { + "@abp/ng.theme.shared": "^0.9.0", + "my-project-name.config": "^0.0.1" + } +} diff --git a/templates/module/angular/projects/my-project-name/src/lib/components/my-project-name.component.spec.ts b/templates/module/angular/projects/my-project-name/src/lib/components/my-project-name.component.spec.ts new file mode 100644 index 0000000000..5dfc08774c --- /dev/null +++ b/templates/module/angular/projects/my-project-name/src/lib/components/my-project-name.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MyProjectNameComponent } from './my-project-name.component'; + +describe('MyProjectNameComponent', () => { + let component: MyProjectNameComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [MyProjectNameComponent], + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MyProjectNameComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/templates/module/angular/projects/my-project-name/src/lib/components/my-project-name.component.ts b/templates/module/angular/projects/my-project-name/src/lib/components/my-project-name.component.ts new file mode 100644 index 0000000000..3f3fa9ec0d --- /dev/null +++ b/templates/module/angular/projects/my-project-name/src/lib/components/my-project-name.component.ts @@ -0,0 +1,19 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'lib-my-project-name', + template: ` +

+ my-project-name works! +

+ `, + styles: [] +}) +export class MyProjectNameComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} diff --git a/templates/module/angular/projects/my-project-name/src/lib/my-project-name-routing.module.ts b/templates/module/angular/projects/my-project-name/src/lib/my-project-name-routing.module.ts new file mode 100644 index 0000000000..5ef00189aa --- /dev/null +++ b/templates/module/angular/projects/my-project-name/src/lib/my-project-name-routing.module.ts @@ -0,0 +1,20 @@ +import { AuthGuard, DynamicLayoutComponent, PermissionGuard } from '@abp/ng.core'; +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { MyProjectNameComponent } from './components/my-project-name.component'; + +const routes: Routes = [ + { + path: '', + component: DynamicLayoutComponent, + canActivate: [AuthGuard, PermissionGuard], + data: { requiredPolicy: '' }, + children: [{ path: '', component: MyProjectNameComponent }], + }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class MyProjectNameRoutingModule {} diff --git a/templates/module/angular/projects/my-project-name/src/lib/my-project-name.module.ts b/templates/module/angular/projects/my-project-name/src/lib/my-project-name.module.ts new file mode 100644 index 0000000000..a446b97bb5 --- /dev/null +++ b/templates/module/angular/projects/my-project-name/src/lib/my-project-name.module.ts @@ -0,0 +1,12 @@ +import { NgModule } from '@angular/core'; +import { MyProjectNameComponent } from './components/my-project-name.component'; +import { MyProjectNameRoutingModule } from './my-project-name-routing.module'; +import { ThemeSharedModule } from '@abp/ng.theme.shared'; +import { CoreModule } from '@abp/ng.core'; + +@NgModule({ + declarations: [MyProjectNameComponent], + imports: [CoreModule, ThemeSharedModule, MyProjectNameRoutingModule], + exports: [MyProjectNameComponent], +}) +export class MyProjectNameModule {} diff --git a/templates/module/angular/projects/my-project-name/src/public-api.ts b/templates/module/angular/projects/my-project-name/src/public-api.ts new file mode 100644 index 0000000000..06a1e26fb3 --- /dev/null +++ b/templates/module/angular/projects/my-project-name/src/public-api.ts @@ -0,0 +1,2 @@ +export * from './lib/components/my-project-name.component'; +export * from './lib/my-project-name.module'; diff --git a/templates/module/angular/projects/my-project-name/src/test.ts b/templates/module/angular/projects/my-project-name/src/test.ts new file mode 100644 index 0000000000..978c64fb83 --- /dev/null +++ b/templates/module/angular/projects/my-project-name/src/test.ts @@ -0,0 +1,21 @@ +// 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: any; + +// 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); diff --git a/templates/module/angular/projects/my-project-name/tsconfig.lib.json b/templates/module/angular/projects/my-project-name/tsconfig.lib.json new file mode 100644 index 0000000000..bd23948e59 --- /dev/null +++ b/templates/module/angular/projects/my-project-name/tsconfig.lib.json @@ -0,0 +1,26 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/lib", + "target": "es2015", + "declaration": true, + "inlineSources": true, + "types": [], + "lib": [ + "dom", + "es2018" + ] + }, + "angularCompilerOptions": { + "annotateForClosureCompiler": true, + "skipTemplateCodegen": true, + "strictMetadataEmit": true, + "fullTemplateTypeCheck": true, + "strictInjectionParameters": true, + "enableResourceInlining": true + }, + "exclude": [ + "src/test.ts", + "**/*.spec.ts" + ] +} diff --git a/templates/module/angular/projects/my-project-name/tsconfig.spec.json b/templates/module/angular/projects/my-project-name/tsconfig.spec.json new file mode 100644 index 0000000000..16da33db07 --- /dev/null +++ b/templates/module/angular/projects/my-project-name/tsconfig.spec.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/spec", + "types": [ + "jasmine", + "node" + ] + }, + "files": [ + "src/test.ts" + ], + "include": [ + "**/*.spec.ts", + "**/*.d.ts" + ] +} diff --git a/templates/module/angular/projects/my-project-name/tslint.json b/templates/module/angular/projects/my-project-name/tslint.json new file mode 100644 index 0000000000..124133f849 --- /dev/null +++ b/templates/module/angular/projects/my-project-name/tslint.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tslint.json", + "rules": { + "directive-selector": [ + true, + "attribute", + "lib", + "camelCase" + ], + "component-selector": [ + true, + "element", + "lib", + "kebab-case" + ] + } +} diff --git a/templates/module/angular/src/app/app-routing.module.ts b/templates/module/angular/src/app/app-routing.module.ts index f65d8238eb..30dacd8547 100644 --- a/templates/module/angular/src/app/app-routing.module.ts +++ b/templates/module/angular/src/app/app-routing.module.ts @@ -16,6 +16,10 @@ const routes: Routes = [ path: 'account', loadChildren: () => import('./lazy-libs/account-wrapper.module').then(m => m.AccountWrapperModule), }, + { + path: 'my-project-name', + loadChildren: () => import('./lazy-libs/my-project-name-wrapper.module').then(m => m.MyProjectNameWrapperModule), + }, ]; @NgModule({ diff --git a/templates/module/angular/src/app/app.module.ts b/templates/module/angular/src/app/app.module.ts index 9bc1839b11..60ab3844ca 100644 --- a/templates/module/angular/src/app/app.module.ts +++ b/templates/module/angular/src/app/app.module.ts @@ -12,6 +12,7 @@ import { AppComponent } from './app.component'; import { SharedModule } from './shared/shared.module'; import { ThemeSharedModule } from '@abp/ng.theme.shared'; import { AccountConfigModule } from '@abp/ng.account.config'; +import { MyProjectNameConfigModule } from '../../projects/my-project-name-config/src/public-api'; @NgModule({ declarations: [AppComponent], @@ -26,6 +27,7 @@ import { AccountConfigModule } from '@abp/ng.account.config'; OAuthModule.forRoot(), NgxsModule.forRoot([]), AccountConfigModule.forRoot({ redirectUrl: '/' }), + MyProjectNameConfigModule, BrowserModule, BrowserAnimationsModule, AppRoutingModule, diff --git a/templates/module/angular/src/app/lazy-libs/my-project-name-wrapper.module.ts b/templates/module/angular/src/app/lazy-libs/my-project-name-wrapper.module.ts new file mode 100644 index 0000000000..2f62d47b39 --- /dev/null +++ b/templates/module/angular/src/app/lazy-libs/my-project-name-wrapper.module.ts @@ -0,0 +1,7 @@ +import { NgModule } from '@angular/core'; +import { MyProjectNameModule } from '../../../projects/my-project-name/src/public-api'; + +@NgModule({ + imports: [MyProjectNameModule], +}) +export class MyProjectNameWrapperModule {} diff --git a/templates/module/angular/tsconfig.json b/templates/module/angular/tsconfig.json index 0a91f81078..76dbb7747d 100644 --- a/templates/module/angular/tsconfig.json +++ b/templates/module/angular/tsconfig.json @@ -18,6 +18,20 @@ "lib": [ "es2018", "dom" - ] + ], + "paths": { + "my-project-name": [ + "dist/my-project-name" + ], + "my-project-name/*": [ + "dist/my-project-name/*" + ], + "my-project-name-config": [ + "dist/my-project-name-config" + ], + "my-project-name-config/*": [ + "dist/my-project-name-config/*" + ] + } } -} +} \ No newline at end of file