Skip to content

Commit

Permalink
build: upgrade angular to 12 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored May 27, 2021
1 parent f4d9b40 commit 68992aa
Show file tree
Hide file tree
Showing 18 changed files with 196 additions and 233 deletions.
54 changes: 54 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"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/directive-selector": [
"off",
{
"type": "attribute",
"prefix": "app",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"off",
{
"type": "element",
"prefix": "app",
"style": "kebab-case"
}
],
"@angular-eslint/no-host-metadata-property": [
"off"
]
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended"
],
"rules": {}
}
]
}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.14.1
12.16.1
83 changes: 46 additions & 37 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"schematics": {
"@schematics/angular:component": {
"style": "less"
},
"@schematics/angular:application": {
"strict": true
}
},
"root": "",
Expand All @@ -22,78 +25,84 @@
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": ["src/assets"],
"assets": [
"src/favicon.ico",
"src/assets"
],
"inlineStyleLanguage": "less",
"styles": [],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
"maximumWarning": "2kb",
"maximumError": "4kb"
}
]
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "ng-github-button:build"
},
"configurations": {
"production": {
"browserTarget": "ng-github-button:build:production"
},
"development": {
"browserTarget": "ng-github-button:build:development"
}
}
},
"defaultConfiguration": "development"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "lib/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"scripts": [],
"styles": [],
"assets": []
"karmaConfig": "karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"builder": "@angular-eslint/builder:lint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
"lintFilePatterns": [
"src/**/*.ts",
"src/**/*.html",
"lib/**/*.ts",
"lib/**/*.html"
]
}
}
}
}
},
"defaultProject": "ng-github-button"
"defaultProject": "ng-github-button",
"cli": {
"defaultCollection": "@angular-eslint/schematics"
}
}
19 changes: 14 additions & 5 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,38 @@ module.exports = function (config) {
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'),
dir: require('path').join(__dirname, './coverage'),
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,
customLaunchers: {
ChromeHeadlessCI: {
base: 'ChromeHeadless',
flags: ['--no-sandbox'],
},
},
singleRun: false,
restartOnFileChange: true
}
});
};
3 changes: 1 addition & 2 deletions lib/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
"deleteDestPath": true,
"lib": {
"entryFile": "index.ts"
},
"whitelistedNonPeerDependencies": ["tslib", "angular"]
}
}
2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng-github-button",
"version": "11.0.1",
"version": "12.0.0",
"description": "Unofficial GitHub buttons in Angular.",
"author": "cipchk <[email protected]>",
"license": "MIT",
Expand Down
14 changes: 7 additions & 7 deletions lib/spec/component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('github-button', () => {
return dl.query(By.css('.gh-count')).nativeElement as HTMLElement;
}
function getCount(): number {
const value = getCountEl().textContent.trim();
const value = getCountEl().textContent!.trim();
return +value;
}

Expand Down Expand Up @@ -65,7 +65,7 @@ describe('github-button', () => {
fixture.detectChanges();

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

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

mockHttp({ forks_count: 3 });
expect((dl.nativeElement as HTMLElement).querySelector('.gh-btn').attributes.getNamedItem('href').textContent).toContain(
expect((dl.nativeElement as HTMLElement).querySelector('.gh-btn')!.attributes.getNamedItem('href')!.textContent).toContain(
`//github.com/cipchk/ng-github-button/`,
);
});
Expand Down Expand Up @@ -126,10 +126,10 @@ describe('github-button', () => {
})
class TestComponent {
@ViewChild('comp')
comp: GithubButtonComponent;
comp!: GithubButtonComponent;
showZero = false;
type = 'stargazers';
size: string;
namespace: string;
repo: string;
size: string = 'default';
namespace: string = '';
repo: string = '';
}
12 changes: 6 additions & 6 deletions lib/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ const isSSR = !(typeof document === 'object' && !!document);
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class GithubButtonComponent implements OnChanges, OnInit, OnDestroy {
private notify$: Subscription;
private notify$: Subscription | null = null;
typeToLabel = {
stargazers: 'Star',
subscribers: 'Watch',
forks: 'Fork',
};
typeToPath = {
typeToPath: { [key: string]: string } = {
forks: 'network',
};
count: number;
count = 0;

@Input() type: 'stargazers' | 'subscribers' | 'forks' = 'stargazers';
@Input() size: 'default' | 'large';
@Input() namespace: string;
@Input() repo: string;
@Input() size: 'default' | 'large' = 'default';
@Input() namespace!: string;
@Input() repo!: string;
@Input() showZero = false;

get repo_url(): string {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { HttpClient } from '@angular/common/http';
export class GithubButtonService {
private cached: { [url: string]: any } = {};
// tslint:disable-next-line: variable-name
private _notify = new BehaviorSubject<{ [url: string]: any }>(null);
private _notify = new BehaviorSubject<{ [url: string]: any } | null>(null);

get notify(): Observable<{ [url: string]: any }> {
get notify(): Observable<{ [url: string]: any } | null> {
return this._notify.asObservable();
}

Expand Down
23 changes: 13 additions & 10 deletions lib/test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files

import 'zone.js/dist/zone-testing';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
} from '@angular/platform-browser-dynamic/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';

declare const require: any;
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(),
);
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
Expand Down
6 changes: 2 additions & 4 deletions lib/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"alwaysStrict": true,
"sourceMap": true,
"inlineSources": true,
"emitDecoratorMetadata": true,
"declaration": true,
"strictFunctionTypes": true,
"stripInternal": true
},
"files": ["./src/module.ts"],
"include": ["**/*.ts"],
"angularCompilerOptions": {
"enableIvy": false
"enableIvy": true,
"compilationMode": "partial"
}
}
Loading

0 comments on commit 68992aa

Please sign in to comment.