Skip to content

refactor: split Angular utilities into a dedicated package #960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/cold-brooms-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@logto/angular": major
"@logto/angular-sample": major
"@logto/js": major
---

extract Angular-specific utilities from JS package into standalone package

Check the Angular sample app for usage, replace the existing import (`@logto/js`) with the new package (`@logto/angular`).
2 changes: 1 addition & 1 deletion packages/angular-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@angular/platform-server": "^19.0.0",
"@angular/router": "^19.0.0",
"@angular/ssr": "^19.0.0",
"@logto/js": "link:../js",
"@logto/angular": "link:../angular",
"angular-auth-oidc-client": "^19.0.0",
"express": "^4.20.0",
"rxjs": "~7.8.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular-sample/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { CommonModule } from '@angular/common';
import { OidcSecurityService } from 'angular-auth-oidc-client';
import type { UserInfoResponse } from '@logto/js';
import type { UserInfoResponse } from '@logto/angular';

@Component({
selector: 'app-root',
Expand Down
2 changes: 1 addition & 1 deletion packages/angular-sample/src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { provideAuth } from 'angular-auth-oidc-client';
import { routes } from './app.routes';
import { provideClientHydration } from '@angular/platform-browser';
import { provideHttpClient, withFetch } from '@angular/common/http';
import { UserScope, buildAngularAuthConfig } from '@logto/js';
import { UserScope, buildAngularAuthConfig } from '@logto/angular';

export const appConfig: ApplicationConfig = {
providers: [
Expand Down
3 changes: 3 additions & 0 deletions packages/angular/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Logto Angular helper

This package provides a helper for Angular to use Logto.
52 changes: 52 additions & 0 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "@logto/angular",
"version": "0.0.0",
"type": "module",
"module": "./lib/index.js",
"types": "./lib/index.d.ts",
"exports": {
"types": "./lib/index.d.ts",
"import": "./lib/index.js",
"default": "./lib/index.js"
},
"files": [
"lib"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/logto-io/js.git",
"directory": "packages/angular"
},
"scripts": {
"dev:tsc": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
"precommit": "lint-staged",
"check": "tsc --noEmit",
"build": "rm -rf lib/ && tsc -p tsconfig.build.json --noEmit && rollup -c",
"lint": "eslint --ext .ts --ext .tsx src",
"prepack": "pnpm build && pnpm test"
},
"dependencies": {
"@logto/js": "workspace:^",
"@silverhand/essentials": "^2.9.2"
},
"devDependencies": {
"@silverhand/eslint-config": "^6.0.1",
"@silverhand/eslint-config-react": "^6.0.2",
"@silverhand/ts-config": "^6.0.0",
"@silverhand/ts-config-react": "^6.0.0",
"angular-auth-oidc-client": "^19.0.0",
"eslint": "^8.57.0",
"lint-staged": "^15.0.0",
"prettier": "^3.0.0",
"typescript": "^5.3.3",
"vitest": "^2.1.9"
},
"eslintConfig": {
"extends": "@silverhand"
},
"prettier": "@silverhand/eslint-config/.prettierrc",
"publishConfig": {
"access": "public"
}
}
1 change: 1 addition & 0 deletions packages/angular/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '../../rollup.config.js';
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { Prompt, QueryKey, type SignInUriParameters, withReservedScopes } from '@logto/js';
import { conditional } from '@silverhand/essentials';
import { type OpenIdConfiguration } from 'angular-auth-oidc-client';

import { Prompt, QueryKey } from '../consts/index.js';
import { type SignInUriParameters } from '../index.js';

import { withReservedScopes } from './scopes.js';

/** The Logto configuration object for Angular apps. */
export type LogtoAngularConfig = {
/**
Expand Down Expand Up @@ -166,3 +162,6 @@ export const buildAngularAuthConfig = (logtoConfig: LogtoAngularConfig): OpenIdC
},
};
};

export type { UserInfoResponse } from '@logto/js';
export { UserScope } from '@logto/js';
6 changes: 6 additions & 0 deletions packages/angular/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig",
"include": [
"src",
]
}
12 changes: 12 additions & 0 deletions packages/angular/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "@silverhand/ts-config-react/tsconfig.base",
"compilerOptions": {
"noEmit": false,
"outDir": "lib",
"types": ["vitest/globals"]
},
"include": [
"src",
"vitest.config.ts"
]
}
8 changes: 8 additions & 0 deletions packages/angular/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
globals: true,
environment: 'happy-dom',
},
});
1 change: 0 additions & 1 deletion packages/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"@silverhand/ts-config": "^6.0.0",
"@types/node": "^22.0.0",
"@vitest/coverage-v8": "^2.1.9",
"angular-auth-oidc-client": "^19.0.0",
"eslint": "^8.57.0",
"happy-dom": "^16.0.0",
"jose": "^5.2.2",
Expand Down
1 change: 0 additions & 1 deletion packages/js/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ export * from './id-token.js';
export * from './access-token.js';
export * from './scopes.js';
export * from './arbitrary-object.js';
export * from './angular.js';
Loading