Skip to content

Commit 68992aa

Browse files
authored
build: upgrade angular to 12 (#5)
1 parent f4d9b40 commit 68992aa

18 files changed

+196
-233
lines changed

.eslintrc.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": [
4+
"projects/**/*"
5+
],
6+
"overrides": [
7+
{
8+
"files": [
9+
"*.ts"
10+
],
11+
"parserOptions": {
12+
"project": [
13+
"tsconfig.json",
14+
"e2e/tsconfig.json"
15+
],
16+
"createDefaultProgram": true
17+
},
18+
"extends": [
19+
"plugin:@angular-eslint/recommended",
20+
"plugin:@angular-eslint/template/process-inline-templates"
21+
],
22+
"rules": {
23+
"@angular-eslint/directive-selector": [
24+
"off",
25+
{
26+
"type": "attribute",
27+
"prefix": "app",
28+
"style": "camelCase"
29+
}
30+
],
31+
"@angular-eslint/component-selector": [
32+
"off",
33+
{
34+
"type": "element",
35+
"prefix": "app",
36+
"style": "kebab-case"
37+
}
38+
],
39+
"@angular-eslint/no-host-metadata-property": [
40+
"off"
41+
]
42+
}
43+
},
44+
{
45+
"files": [
46+
"*.html"
47+
],
48+
"extends": [
49+
"plugin:@angular-eslint/template/recommended"
50+
],
51+
"rules": {}
52+
}
53+
]
54+
}

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12.14.1
1+
12.16.1

angular.json

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"schematics": {
99
"@schematics/angular:component": {
1010
"style": "less"
11+
},
12+
"@schematics/angular:application": {
13+
"strict": true
1114
}
1215
},
1316
"root": "",
@@ -22,78 +25,84 @@
2225
"main": "src/main.ts",
2326
"polyfills": "src/polyfills.ts",
2427
"tsConfig": "tsconfig.app.json",
25-
"aot": true,
26-
"assets": ["src/assets"],
28+
"assets": [
29+
"src/favicon.ico",
30+
"src/assets"
31+
],
32+
"inlineStyleLanguage": "less",
2733
"styles": [],
2834
"scripts": []
2935
},
3036
"configurations": {
3137
"production": {
32-
"fileReplacements": [
33-
{
34-
"replace": "src/environments/environment.ts",
35-
"with": "src/environments/environment.prod.ts"
36-
}
37-
],
38-
"optimization": true,
39-
"outputHashing": "all",
40-
"sourceMap": false,
41-
"namedChunks": false,
42-
"extractLicenses": true,
43-
"vendorChunk": false,
44-
"buildOptimizer": true,
4538
"budgets": [
4639
{
4740
"type": "initial",
48-
"maximumWarning": "2mb",
49-
"maximumError": "5mb"
41+
"maximumWarning": "500kb",
42+
"maximumError": "1mb"
5043
},
5144
{
5245
"type": "anyComponentStyle",
53-
"maximumWarning": "6kb",
54-
"maximumError": "10kb"
46+
"maximumWarning": "2kb",
47+
"maximumError": "4kb"
5548
}
56-
]
49+
],
50+
"fileReplacements": [
51+
{
52+
"replace": "src/environments/environment.ts",
53+
"with": "src/environments/environment.prod.ts"
54+
}
55+
],
56+
"outputHashing": "all"
57+
},
58+
"development": {
59+
"buildOptimizer": false,
60+
"optimization": false,
61+
"vendorChunk": true,
62+
"extractLicenses": false,
63+
"sourceMap": true,
64+
"namedChunks": true
5765
}
58-
}
66+
},
67+
"defaultConfiguration": "production"
5968
},
6069
"serve": {
6170
"builder": "@angular-devkit/build-angular:dev-server",
62-
"options": {
63-
"browserTarget": "ng-github-button:build"
64-
},
6571
"configurations": {
6672
"production": {
6773
"browserTarget": "ng-github-button:build:production"
74+
},
75+
"development": {
76+
"browserTarget": "ng-github-button:build:development"
6877
}
69-
}
78+
},
79+
"defaultConfiguration": "development"
7080
},
7181
"test": {
7282
"builder": "@angular-devkit/build-angular:karma",
7383
"options": {
7484
"main": "lib/test.ts",
7585
"polyfills": "src/polyfills.ts",
7686
"tsConfig": "tsconfig.spec.json",
77-
"karmaConfig": "karma.conf.js",
78-
"scripts": [],
79-
"styles": [],
80-
"assets": []
87+
"karmaConfig": "karma.conf.js"
8188
}
8289
},
8390
"lint": {
84-
"builder": "@angular-devkit/build-angular:tslint",
91+
"builder": "@angular-eslint/builder:lint",
8592
"options": {
86-
"tsConfig": [
87-
"tsconfig.app.json",
88-
"tsconfig.spec.json"
89-
],
90-
"exclude": [
91-
"**/node_modules/**"
93+
"lintFilePatterns": [
94+
"src/**/*.ts",
95+
"src/**/*.html",
96+
"lib/**/*.ts",
97+
"lib/**/*.html"
9298
]
9399
}
94100
}
95101
}
96102
}
97103
},
98-
"defaultProject": "ng-github-button"
104+
"defaultProject": "ng-github-button",
105+
"cli": {
106+
"defaultCollection": "@angular-eslint/schematics"
107+
}
99108
}

karma.conf.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,38 @@ module.exports = function (config) {
1313
require('@angular-devkit/build-angular/plugins/karma')
1414
],
1515
client: {
16+
jasmine: {
17+
// you can add configuration options for Jasmine here
18+
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19+
// for example, you can disable the random execution with `random: false`
20+
// or set a specific seed with `seed: 4321`
21+
},
1622
clearContext: false // leave Jasmine Spec Runner output visible in browser
1723
},
24+
jasmineHtmlReporter: {
25+
suppressAll: true // removes the duplicated traces
26+
},
1827
coverageReporter: {
19-
dir: require('path').join(__dirname, '../coverage'),
28+
dir: require('path').join(__dirname, './coverage'),
2029
subdir: '.',
2130
reporters: [
2231
{ type: 'html' },
2332
{ type: 'text-summary' }
24-
],
33+
]
2534
},
2635
reporters: ['progress', 'kjhtml'],
2736
port: 9876,
2837
colors: true,
2938
logLevel: config.LOG_INFO,
3039
autoWatch: true,
3140
browsers: ['Chrome'],
41+
singleRun: false,
42+
restartOnFileChange: true,
3243
customLaunchers: {
3344
ChromeHeadlessCI: {
3445
base: 'ChromeHeadless',
3546
flags: ['--no-sandbox'],
3647
},
37-
},
38-
singleRun: false,
39-
restartOnFileChange: true
48+
}
4049
});
4150
};

lib/ng-package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
"deleteDestPath": true,
55
"lib": {
66
"entryFile": "index.ts"
7-
},
8-
"whitelistedNonPeerDependencies": ["tslib", "angular"]
7+
}
98
}

lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ng-github-button",
3-
"version": "11.0.1",
3+
"version": "12.0.0",
44
"description": "Unofficial GitHub buttons in Angular.",
55
"author": "cipchk <[email protected]>",
66
"license": "MIT",

lib/spec/component.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('github-button', () => {
1616
return dl.query(By.css('.gh-count')).nativeElement as HTMLElement;
1717
}
1818
function getCount(): number {
19-
const value = getCountEl().textContent.trim();
19+
const value = getCountEl().textContent!.trim();
2020
return +value;
2121
}
2222

@@ -65,7 +65,7 @@ describe('github-button', () => {
6565
fixture.detectChanges();
6666

6767
mockHttp({ forks_count: 3 });
68-
expect((dl.nativeElement as HTMLElement).querySelector('github-button').classList).toContain('github-btn-large');
68+
expect((dl.nativeElement as HTMLElement).querySelector('github-button')!.classList).toContain('github-btn-large');
6969
});
7070

7171
it('#repo_url', () => {
@@ -76,7 +76,7 @@ describe('github-button', () => {
7676
fixture.detectChanges();
7777

7878
mockHttp({ forks_count: 3 });
79-
expect((dl.nativeElement as HTMLElement).querySelector('.gh-btn').attributes.getNamedItem('href').textContent).toContain(
79+
expect((dl.nativeElement as HTMLElement).querySelector('.gh-btn')!.attributes.getNamedItem('href')!.textContent).toContain(
8080
`//github.com/cipchk/ng-github-button/`,
8181
);
8282
});
@@ -126,10 +126,10 @@ describe('github-button', () => {
126126
})
127127
class TestComponent {
128128
@ViewChild('comp')
129-
comp: GithubButtonComponent;
129+
comp!: GithubButtonComponent;
130130
showZero = false;
131131
type = 'stargazers';
132-
size: string;
133-
namespace: string;
134-
repo: string;
132+
size: string = 'default';
133+
namespace: string = '';
134+
repo: string = '';
135135
}

lib/src/component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ const isSSR = !(typeof document === 'object' && !!document);
3434
changeDetection: ChangeDetectionStrategy.OnPush,
3535
})
3636
export class GithubButtonComponent implements OnChanges, OnInit, OnDestroy {
37-
private notify$: Subscription;
37+
private notify$: Subscription | null = null;
3838
typeToLabel = {
3939
stargazers: 'Star',
4040
subscribers: 'Watch',
4141
forks: 'Fork',
4242
};
43-
typeToPath = {
43+
typeToPath: { [key: string]: string } = {
4444
forks: 'network',
4545
};
46-
count: number;
46+
count = 0;
4747

4848
@Input() type: 'stargazers' | 'subscribers' | 'forks' = 'stargazers';
49-
@Input() size: 'default' | 'large';
50-
@Input() namespace: string;
51-
@Input() repo: string;
49+
@Input() size: 'default' | 'large' = 'default';
50+
@Input() namespace!: string;
51+
@Input() repo!: string;
5252
@Input() showZero = false;
5353

5454
get repo_url(): string {

lib/src/service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { HttpClient } from '@angular/common/http';
66
export class GithubButtonService {
77
private cached: { [url: string]: any } = {};
88
// tslint:disable-next-line: variable-name
9-
private _notify = new BehaviorSubject<{ [url: string]: any }>(null);
9+
private _notify = new BehaviorSubject<{ [url: string]: any } | null>(null);
1010

11-
get notify(): Observable<{ [url: string]: any }> {
11+
get notify(): Observable<{ [url: string]: any } | null> {
1212
return this._notify.asObservable();
1313
}
1414

lib/test.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
22

3-
import 'zone.js/dist/zone-testing';
3+
import 'zone.js/testing';
44
import { getTestBed } from '@angular/core/testing';
5-
import {
6-
BrowserDynamicTestingModule,
7-
platformBrowserDynamicTesting,
8-
} from '@angular/platform-browser-dynamic/testing';
5+
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
96

10-
declare const require: any;
7+
declare const require: {
8+
context(
9+
path: string,
10+
deep?: boolean,
11+
filter?: RegExp,
12+
): {
13+
keys(): string[];
14+
<T>(id: string): T;
15+
};
16+
};
1117

1218
// First, initialize the Angular testing environment.
13-
getTestBed().initTestEnvironment(
14-
BrowserDynamicTestingModule,
15-
platformBrowserDynamicTesting(),
16-
);
19+
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
1720
// Then we find all the tests.
1821
const context = require.context('./', true, /\.spec\.ts$/);
1922
// And load the modules.

0 commit comments

Comments
 (0)