Skip to content

Commit

Permalink
feat: add support for Angular 13
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciovigolo authored and jonkoops committed Dec 15, 2021
1 parent eccbe1c commit 0eb4983
Show file tree
Hide file tree
Showing 42 changed files with 19,193 additions and 28,617 deletions.
40 changes: 40 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"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": "lib",
"style": "kebab-case",
"type": "element"
}
],
"@angular-eslint/directive-selector": [
"error",
{
"prefix": "lib",
"style": "camelCase",
"type": "attribute"
}
]
}
},
{
"files": ["*.html"],
"extends": ["plugin:@angular-eslint/template/recommended"],
"rules": {}
}
]
}
Empty file removed .github/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ daysUntilStale: 180
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 30
# Issues with these labels will never be considered stale
exemptLabels:w
exemptLabels:
- planning
- committed
- in-progress
Expand Down
34 changes: 0 additions & 34 deletions .github/workflows/ci.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
NODE_VERSION: 16
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
check-latest: true
cache: npm

- name: Cache Node modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci

- name: Cache setup
uses: actions/cache@v2
with:
path: ./*
key: ${{ github.sha }}

run:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
command: [lint, test -- --no-watch --no-progress --browsers=ChromeHeadless, build]
steps:
- name: Restore setup
uses: actions/cache@v2
with:
path: ./*
key: ${{ github.sha }}

- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}

- name: Run ${{ matrix.command }}
run: npm run ${{ matrix.command }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ node_modules
!.vscode/extensions.json

# misc
/.angular/cache
/.sass-cache
/connect.lock
/coverage
Expand Down
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.github
.angular
dist
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"printWidth": 80,
"singleQuote": true,
"bracketSpacing": true,
"semi": true,
"tabWidth": 2,
"useTabs": false,
"trailingComma": "none"
}
32 changes: 18 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ Missing an important feature? Please open an issue for discussion. If you want t
- First of all, fork this repository at GitHub.

- Clone the forked repository

```sh
git clone https://github.com/YOUR-USERNAME/keycloak-angular.git
```

- Install the dependencies

```sh
npm install
```
Expand All @@ -46,24 +48,26 @@ For opening an issue, you can fill out this [issue form](https://github.com/maur
### Submitting a Pull Request (PR)

Before submiting a Pull Request, please:

- Search for open and closed related PRs.
- Follow the coding rules.
- Follow the commit message guidelines.
- Checkout the code documentation - jsdocs.

## <a name="cru"></a> Coding rules

This project uses the [Airbnb coding style](https://github.com/airbnb/javascript) with little
exceptions. The project tslint.json file extends tslint-config-airbnb. Check if you have the tslint
This project uses the [Airbnb coding style](https://github.com/airbnb/javascript) with little
exceptions. The project tslint.json file extends tslint-config-airbnb. Check if you have the tslint
extension in your editor.

Details:

- The code must also be documented following the [jsdoc guidelines](http://usejsdoc.org/).
- Wrap all code at 100 characters.

## <a name="cmg"></a> Commit message guidelines

This project follows the [Angular commit message guidelines](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit).
This project follows the [Angular commit message guidelines](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit).

From the Angular documentation:

Expand Down Expand Up @@ -93,15 +97,15 @@ If the commit reverts a previous commit, it should begin with revert:, followed

Must be one of the following:

* **build:** Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
* **ci:** Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
* **docs:** Documentation only changes
* **feat:** A new feature
* **fix:** A bug fix
* **perf:** A code change that improves performance
* **refactor:** A code change that neither fixes a bug nor adds a feature
* **style:** Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
* **test:** Adding missing tests or correcting existing tests
- **build:** Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
- **ci:** Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
- **docs:** Documentation only changes
- **feat:** A new feature
- **fix:** A bug fix
- **perf:** A code change that improves performance
- **refactor:** A code change that neither fixes a bug nor adds a feature
- **style:** Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- **test:** Adding missing tests or correcting existing tests

### Subject

Expand All @@ -122,6 +126,6 @@ Breaking Changes should start with the word BREAKING CHANGE: with a space or two

## <a name="fmg"></a> Final message

Thanks for your interest in this project. Hope to see your contribution!
Thanks for your interest in this project. Hope to see your contribution!

See you and happy coding!
See you and happy coding!
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ Note that `keycloak-js` is a peer dependency of Keycloak Angular. This change al

### Versions

| Angular | keycloak-angular | keycloak-js | Support |
| :---------: | :--------------: | :-----------------------: | :-----------------: |
| 11.x - 12.x | 8.4.x | 10 - 15 | Bugs / New Features |
| 10.x | 8.x.x | 10 - 11 | Bugs |
| 9.x | 7.3.x | 3.4.3 - 10 (excluding v7) | Bugs |
| Angular | keycloak-angular | keycloak-js | Support |
| :---------: | :--------------: | :---------: | :-----------------: |
| 11.x - 13.x | 9.x.x | 10 - 15 | Bugs / New Features |
| 10.x | 8.x.x | 10 - 11 | Bugs |

We try to support the same Angular versions that are [supported](https://angular.io/guide/releases#support-policy-and-schedule) by the Angular team. That said, it's always best to keep up to date with the latest version of Angular for optimal support.

Expand Down Expand Up @@ -84,13 +83,13 @@ function initializeKeycloak(keycloak: KeycloakService) {
config: {
url: 'http://localhost:8080/auth',
realm: 'your-realm',
clientId: 'your-client-id',
clientId: 'your-client-id'
},
initOptions: {
onLoad: 'check-sso',
silentCheckSsoRedirectUri:
window.location.origin + '/assets/silent-check-sso.html',
},
window.location.origin + '/assets/silent-check-sso.html'
}
});
}

Expand All @@ -102,10 +101,10 @@ function initializeKeycloak(keycloak: KeycloakService) {
provide: APP_INITIALIZER,
useFactory: initializeKeycloak,
multi: true,
deps: [KeycloakService],
},
deps: [KeycloakService]
}
],
bootstrap: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {}
```
Expand Down Expand Up @@ -143,12 +142,12 @@ import { Injectable } from '@angular/core';
import {
ActivatedRouteSnapshot,
Router,
RouterStateSnapshot,
RouterStateSnapshot
} from '@angular/router';
import { KeycloakAuthGuard, KeycloakService } from 'keycloak-angular';

@Injectable({
providedIn: 'root',
providedIn: 'root'
})
export class AuthGuard extends KeycloakAuthGuard {
constructor(
Expand All @@ -165,7 +164,7 @@ export class AuthGuard extends KeycloakAuthGuard {
// Force the user to log in if currently unauthenticated.
if (!this.authenticated) {
await this.keycloak.login({
redirectUri: window.location.origin + state.url,
redirectUri: window.location.origin + state.url
});
}

Expand Down Expand Up @@ -194,9 +193,9 @@ await keycloak.init({
config: {
url: 'http://localhost:8080/auth',
realm: 'your-realm',
clientId: 'your-client-id',
clientId: 'your-client-id'
},
bearerExcludedUrls: ['/assets', '/clients/public'],
bearerExcludedUrls: ['/assets', '/clients/public']
});
```

Expand All @@ -208,7 +207,7 @@ For example you make keycloak-angular auto refreshing your access token when exp

```ts
keycloakService.keycloakEvents$.subscribe({
next: e => {
next: (e) => {
if (e.type == KeycloakEventType.OnTokenExpired) {
keycloakService.updateToken(20);
}
Expand Down Expand Up @@ -247,4 +246,4 @@ document.
[contributors-badge]: https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square
[discord-badge]: https://img.shields.io/discord/790617227853692958.svg?color=7389D8&labelColor=6A7EC2&logo=discord&logoColor=ffffff&style=flat-square
[discord]: https://discord.gg/mmzEhYXXDG
<!-- prettier-ignore-end -->
<!-- prettier-ignore-end -->
18 changes: 10 additions & 8 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"production": {
"project": "projects/keycloak-angular/ng-package.prod.json",
"tsConfig": "projects/keycloak-angular/tsconfig.lib.prod.json"
}
}
}
},
"test": {
Expand All @@ -31,17 +31,19 @@
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"builder": "@angular-eslint/builder:lint",
"options": {
"tsConfig": [
"projects/keycloak-angular/tsconfig.lib.json",
"projects/keycloak-angular/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**"]
"lintFilePatterns": [
"projects/keycloak-angular/**/*.ts",
"projects/keycloak-angular/**/*.html"
]
}
}
}
}
},
"defaultProject": "keycloak-angular"
"defaultProject": "keycloak-angular",
"cli": {
"defaultCollection": "@angular-eslint/schematics"
}
}
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ speed-measure-plugin*.json
.history/*

# misc
/.angular/cache
/.sass-cache
/connect.lock
/coverage
Expand Down
Loading

0 comments on commit 0eb4983

Please sign in to comment.