Commit migrated from dotnet/aspnetcore@0011eff564
This commit is contained in:
Hao Kung 2021-05-06 09:52:07 -07:00 коммит произвёл GitHub
Родитель fdf973046c
Коммит 14b60e92f8
26 изменённых файлов: 268 добавлений и 310 удалений

Просмотреть файл

@ -0,0 +1,17 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support
# You can see what browsers were selected by your queries by running:
# npx browserslist
last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.

Просмотреть файл

@ -8,6 +8,9 @@ indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
quote_type = single
[*.md]
max_line_length = off
trim_trailing_whitespace = false

Просмотреть файл

@ -0,0 +1,51 @@
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"tsconfig.json",
"e2e/tsconfig.json"
],
"createDefaultProgram": true
},
"extends": [
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@angular-eslint/component-selector": [
"error",
{
"prefix": "app",
"style": "kebab-case",
"type": "element"
}
],
"@angular-eslint/directive-selector": [
"error",
{
"prefix": "app",
"style": "camelCase",
"type": "attribute"
}
]
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended"
],
"rules": {}
}
]
}

Просмотреть файл

@ -14,13 +14,14 @@
"builder": "@angular-devkit/build-angular:browser",
"options": {
"progress": false,
"extractCss": true,
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": ["src/assets"],
"tsConfig": "tsconfig.app.json",
"assets": [
"src/assets"
],
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
@ -70,18 +71,24 @@
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": ["src/styles.css"],
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"styles": [
"src/styles.css"
],
"scripts": [],
"assets": ["src/assets"]
"assets": [
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"builder": "@angular-eslint/builder:lint",
"options": {
"tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
"lintFilePatterns": [
"src/**/*.ts",
"src/**/*.html"
]
}
},
"server": {
@ -89,7 +96,7 @@
"options": {
"outputPath": "dist-server",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.server.json"
"tsConfig": "tsconfig.server.json"
},
"configurations": {
"dev": {
@ -124,14 +131,19 @@
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"builder": "@angular-eslint/builder:lint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": ["**/node_modules/**"]
"lintFilePatterns": [
"e2e//**/*.ts",
"e2e//**/*.html"
]
}
}
}
}
},
"defaultProject": "Company.WebApplication1"
"defaultProject": "Company.WebApplication1",
"cli": {
"defaultCollection": "@angular-eslint/schematics"
}
}

Просмотреть файл

@ -1,9 +0,0 @@
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# For IE 9-11 support, please uncomment the last line of the file and adjust as needed
> 0.5%
last 2 versions
Firefox ESR
not dead
# IE 9-11

Просмотреть файл

@ -1,28 +1,35 @@
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require("jasmine-spec-reporter");
const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
/**
* @type { import("protractor").Config }
*/
exports.config = {
allScriptsTimeout: 11000,
specs: ["./src/**/*.e2e-spec.ts"],
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
browserName: "chrome"
browserName: 'chrome'
},
directConnect: true,
baseUrl: "http://localhost:4200/",
framework: "jasmine",
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require("ts-node").register({
project: require("path").join(__dirname, "./tsconfig.e2e.json")
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.json')
});
jasmine
.getEnv()
.addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
jasmine.getEnv().addReporter(new SpecReporter({
spec: {
displayStacktrace: StacktraceOption.PRETTY
}
}));
}
};

Просмотреть файл

@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "commonjs",
"target": "es5",
"target": "es2018",
"types": [
"jasmine",
"jasminewd2",

Просмотреть файл

@ -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/angularapp'),
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
});
};

Просмотреть файл

@ -19,49 +19,53 @@
},
"private": true,
"dependencies": {
"@angular/animations": "8.2.14",
"@angular/common": "8.2.14",
"@angular/compiler": "8.2.14",
"@angular/core": "8.2.14",
"@angular/forms": "8.2.14",
"@angular/platform-browser": "8.2.14",
"@angular/platform-browser-dynamic": "8.2.14",
"@angular/platform-server": "8.2.14",
"@angular/router": "8.2.14",
"@nguniversal/module-map-ngfactory-loader": "8.1.1",
"@angular/animations": "~11.2.11",
"@angular/common": "~11.2.11",
"@angular/compiler": "~11.2.11",
"@angular/core": "~11.2.11",
"@angular/forms": "~11.2.11",
"@angular/platform-browser": "~11.2.11",
"@angular/platform-browser-dynamic": "~11.2.11",
"@angular/platform-server": "~11.2.11",
"@angular/router": "~11.2.11",
"@nguniversal/module-map-ngfactory-loader": "^8.2.6",
"bootstrap": "^4.6.0",
"core-js": "^3.8.3",
"jquery": "^3.5.1",
"oidc-client": "^1.11.3",
"popper.js": "^1.16.0",
"run-script-os": "^1.1.6",
"rxjs": "^6.6.3",
"zone.js": "0.9.1"
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.803.29",
"@angular/cli": "^8.3.29",
"@angular/compiler-cli": "^8.2.14",
"@angular/language-service": "^8.2.14",
"@types/jasmine": "~3.4.4",
"@angular-devkit/build-angular": "~0.1102.10",
"@angular-eslint/builder": "4.0.0",
"@angular-eslint/eslint-plugin": "4.0.0",
"@angular-eslint/eslint-plugin-template": "4.0.0",
"@angular-eslint/schematics": "4.0.0",
"@angular-eslint/template-parser": "4.0.0",
"@angular/cli": "~11.2.10",
"@angular/compiler-cli": "~11.2.11",
"@types/jasmine": "^3.6.10",
"@types/jasminewd2": "~2.0.8",
"@types/node": "~12.11.6",
"codelyzer": "^5.2.2",
"@types/node": "^12.11.1",
"@typescript-eslint/eslint-plugin": "4.16.1",
"@typescript-eslint/parser": "4.16.1",
"eslint": "^7.6.0",
"ini": "^1.3.7",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^5.2.3",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.1.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.5.4",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"karma-spec-reporter": "0.0.32",
"typescript": "3.5.3"
},
"optionalDependencies": {
"node-sass": "^5.0.0",
"protractor": "~5.4.2",
"protractor": "~7.0.0",
"ts-node": "~8.4.1",
"tslint": "~5.20.0"
}
"typescript": "~4.1.5"
},
"optionalDependencies": {}
}

Просмотреть файл

@ -18,7 +18,7 @@ export class AuthorizeInterceptor implements HttpInterceptor {
// Checks if there is an access_token available in the authorize service
// and adds it to the request in case it's targeted at the same origin as the
// single page application.
private processRequestWithToken(token: string, req: HttpRequest<any>, next: HttpHandler) {
private processRequestWithToken(token: string | null, req: HttpRequest<any>, next: HttpHandler) {
if (!!token && this.isSameOriginUrl(req)) {
req = req.clone({
setHeaders: {

Просмотреть файл

@ -41,8 +41,8 @@ export class AuthorizeService {
// If you want to enable pop up authentication simply set this flag to false.
private popUpDisabled = true;
private userManager: UserManager;
private userSubject: BehaviorSubject<IUser | null> = new BehaviorSubject(null);
private userManager?: UserManager;
private userSubject: BehaviorSubject<IUser | null> = new BehaviorSubject<IUser | null>(null);
public isAuthenticated(): Observable<boolean> {
return this.getUser().pipe(map(u => !!u));
@ -55,9 +55,9 @@ export class AuthorizeService {
this.userSubject.asObservable());
}
public getAccessToken(): Observable<string> {
public getAccessToken(): Observable<string | null> {
return from(this.ensureUserManagerInitialized())
.pipe(mergeMap(() => from(this.userManager.getUser())),
.pipe(mergeMap(() => from(this.userManager!.getUser())),
map(user => user && user.access_token));
}
@ -71,9 +71,9 @@ export class AuthorizeService {
// redirect flow.
public async signIn(state: any): Promise<IAuthenticationResult> {
await this.ensureUserManagerInitialized();
let user: User = null;
let user: User | null = null;
try {
user = await this.userManager.signinSilent(this.createArguments());
user = await this.userManager!.signinSilent(this.createArguments());
this.userSubject.next(user.profile);
return this.success(state);
} catch (silentError) {
@ -84,7 +84,7 @@ export class AuthorizeService {
if (this.popUpDisabled) {
throw new Error('Popup disabled. Change \'authorize.service.ts:AuthorizeService.popupDisabled\' to false to enable it.');
}
user = await this.userManager.signinPopup(this.createArguments());
user = await this.userManager!.signinPopup(this.createArguments());
this.userSubject.next(user.profile);
return this.success(state);
} catch (popupError) {
@ -97,7 +97,7 @@ export class AuthorizeService {
// PopUps might be blocked by the user, fallback to redirect
try {
await this.userManager.signinRedirect(this.createArguments(state));
await this.userManager!.signinRedirect(this.createArguments(state));
return this.redirect();
} catch (redirectError) {
console.log('Redirect authentication error: ', redirectError);
@ -110,7 +110,7 @@ export class AuthorizeService {
public async completeSignIn(url: string): Promise<IAuthenticationResult> {
try {
await this.ensureUserManagerInitialized();
const user = await this.userManager.signinCallback(url);
const user = await this.userManager!.signinCallback(url);
this.userSubject.next(user && user.profile);
return this.success(user && user.state);
} catch (error) {
@ -126,13 +126,13 @@ export class AuthorizeService {
}
await this.ensureUserManagerInitialized();
await this.userManager.signoutPopup(this.createArguments());
await this.userManager!.signoutPopup(this.createArguments());
this.userSubject.next(null);
return this.success(state);
} catch (popupSignOutError) {
console.log('Popup signout error: ', popupSignOutError);
try {
await this.userManager.signoutRedirect(this.createArguments(state));
await this.userManager!.signoutRedirect(this.createArguments(state));
return this.redirect();
} catch (redirectSignOutError) {
console.log('Redirect signout error: ', redirectSignOutError);
@ -144,7 +144,7 @@ export class AuthorizeService {
public async completeSignOut(url: string): Promise<IAuthenticationResult> {
await this.ensureUserManagerInitialized();
try {
const response = await this.userManager.signoutCallback(url);
const response = await this.userManager!.signoutCallback(url);
this.userSubject.next(null);
return this.success(response && response.state);
} catch (error) {
@ -185,15 +185,15 @@ export class AuthorizeService {
this.userManager = new UserManager(settings);
this.userManager.events.addUserSignedOut(async () => {
await this.userManager.removeUser();
await this.userManager!.removeUser();
this.userSubject.next(null);
});
}
private getUserFromStorage(): Observable<IUser> {
private getUserFromStorage(): Observable<IUser | null> {
return from(this.ensureUserManagerInitialized())
.pipe(
mergeMap(() => this.userManager.getUser()),
mergeMap(() => this.userManager!.getUser()),
map(u => u && u.profile));
}
}

Просмотреть файл

@ -6,7 +6,7 @@
<a class="nav-link text-dark" [routerLink]='["/authentication/logout"]' [state]='{ local: true }' title="Logout">Logout</a>
</li>
</ul>
<ul class="navbar-nav" *ngIf="!(isAuthenticated | async)">
<ul class="navbar-nav" *ngIf="(isAuthenticated | async) !== true">
<li class="nav-item">
<a class="nav-link text-dark" [routerLink]='["/authentication/register"]'>Register</a>
</li>

Просмотреть файл

@ -9,8 +9,8 @@ import { map } from 'rxjs/operators';
styleUrls: ['./login-menu.component.css']
})
export class LoginMenuComponent implements OnInit {
public isAuthenticated: Observable<boolean>;
public userName: Observable<string>;
public isAuthenticated?: Observable<boolean>;
public userName?: Observable<string | null | undefined>;
constructor(private authorizeService: AuthorizeService) { }

Просмотреть файл

@ -14,7 +14,7 @@ import { LoginActions, QueryParameterNames, ApplicationPaths, ReturnUrlType } fr
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
public message = new BehaviorSubject<string>(null);
public message = new BehaviorSubject<string | null | undefined>(null);
constructor(
private authorizeService: AuthorizeService,

Просмотреть файл

@ -14,7 +14,7 @@ import { LogoutActions, ApplicationPaths, ReturnUrlType } from '../api-authoriza
styleUrls: ['./logout.component.css']
})
export class LogoutComponent implements OnInit {
public message = new BehaviorSubject<string>(null);
public message = new BehaviorSubject<string | null>(null);
constructor(
private authorizeService: AuthorizeService,

Просмотреть файл

@ -6,7 +6,7 @@ import { HttpClient } from '@angular/common/http';
templateUrl: './fetch-data.component.html'
})
export class FetchDataComponent {
public forecasts: WeatherForecast[];
public forecasts: WeatherForecast[] = [];
constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string) {
http.get<WeatherForecast[]>(baseUrl + 'weatherforecast').subscribe(result => {

Просмотреть файл

@ -1,32 +0,0 @@
// 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-spec-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'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml', 'spec'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};

Просмотреть файл

@ -7,7 +7,7 @@ import {
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require;
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(

Просмотреть файл

@ -1,11 +0,0 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": []
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}

Просмотреть файл

@ -1,9 +0,0 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "commonjs"
},
"angularCompilerOptions": {
"entryModule": "app/app.server.module#AppServerModule"
}
}

Просмотреть файл

@ -1,18 +0,0 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts",
"polyfills.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -4,18 +4,30 @@
"baseUrl": "./",
"module": "esnext",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"module": "es2020",
"lib": [
"es2017",
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}

Просмотреть файл

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

Просмотреть файл

@ -1,130 +0,0 @@
{
"rulesDirectory": [
"node_modules/codelyzer"
],
"rules": {
"arrow-return-shorthand": true,
"callable-types": true,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": true,
"deprecation": {
"severity": "warn"
},
"eofline": true,
"forin": true,
"import-blacklist": [
true,
"rxjs/Rx"
],
"import-spacing": true,
"indent": [
true,
"spaces"
],
"interface-over-type-literal": true,
"label-position": true,
"max-line-length": [
true,
140
],
"member-access": false,
"member-ordering": [
true,
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-arg": true,
"no-bitwise": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-super": true,
"no-empty": false,
"no-empty-interface": true,
"no-eval": true,
"no-inferrable-types": [
true,
"ignore-params"
],
"no-misused-new": true,
"no-non-null-assertion": true,
"no-shadowed-variable": true,
"no-string-literal": false,
"no-string-throw": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unnecessary-initializer": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"object-literal-sort-keys": false,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"prefer-const": true,
"quotemark": [
true,
"single"
],
"radix": true,
"semicolon": [
true,
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"unified-signatures": true,
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
],
"no-output-on-prefix": true,
"no-inputs-metadata-property": true,
"no-outputs-metadata-property": true,
"no-host-metadata-property": true,
"no-input-rename": true,
"no-output-rename": true,
"use-lifecycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": true,
"directive-class-suffix": true
}
}