mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -05:00
refactor(connector): fix metadataParser wrong path problem
This commit is contained in:
parent
1a557bc184
commit
ff89c0b3a5
18 changed files with 35 additions and 21 deletions
|
@ -52,7 +52,8 @@ export default class AlipayNativeConnector extends SocialConnector<AlipayNativeC
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is AlipayNativeConfig {
|
||||
|
|
|
@ -49,7 +49,8 @@ export default class AlipayConnector extends SocialConnector<AlipayConfig> {
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is AlipayConfig {
|
||||
|
|
|
@ -21,7 +21,8 @@ export default class AliyunDmConnector extends EmailConnector<AliyunDmConfig> {
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is AliyunDmConfig {
|
||||
|
|
|
@ -16,7 +16,8 @@ export default class AliyunSmsConnector extends SmsConnector<AliyunSmsConfig> {
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is AliyunSmsConfig {
|
||||
|
|
|
@ -17,7 +17,8 @@ export default class AppleConnector extends SocialConnector<AppleConfig> {
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is AppleConfig {
|
||||
|
|
|
@ -37,7 +37,8 @@ export default class AzureADConnector extends SocialConnector<AzureADConfig> {
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is AzureADConfig {
|
||||
|
|
|
@ -27,10 +27,7 @@ export class BaseConnector<T> {
|
|||
public validateConfig(config: unknown): asserts config is T {}
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
protected metadataParser = () => {
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
const currentPath = __dirname;
|
||||
|
||||
protected metadataParser = (currentPath: string) => {
|
||||
if (
|
||||
!this.metadata.logo.startsWith('http') &&
|
||||
existsSync(path.join(currentPath, '..', this.metadata.logo))
|
||||
|
|
|
@ -37,7 +37,8 @@ export default class FacebookConnector extends SocialConnector<FacebookConfig> {
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is FacebookConfig {
|
||||
|
|
|
@ -33,7 +33,8 @@ export default class GithubConnector extends SocialConnector<GithubConfig> {
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is GithubConfig {
|
||||
|
|
|
@ -35,7 +35,8 @@ export default class GoogleConnector extends SocialConnector<GoogleConfig> {
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is GoogleConfig {
|
||||
|
|
|
@ -17,7 +17,8 @@ export default class MockMailConnector extends EmailConnector<MockMailConfig> {
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is MockMailConfig {
|
||||
|
|
|
@ -17,7 +17,8 @@ export default class MockSmsConnector extends SmsConnector<MockSmsConfig> {
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is MockSmsConfig {
|
||||
|
|
|
@ -17,7 +17,8 @@ export default class MockSocialConnector extends SocialConnector<MockSocialConfi
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is MockSocialConfig {
|
||||
|
|
|
@ -22,7 +22,8 @@ export default class SendGridMailConnector extends EmailConnector<SendGridMailCo
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is SendGridMailConfig {
|
||||
|
|
|
@ -16,7 +16,8 @@ export default class SmtpConnector extends EmailConnector<SmtpConfig> {
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is SmtpConfig {
|
||||
|
|
|
@ -15,7 +15,8 @@ export default class TwilioSmsConnector extends SmsConnector<TwilioSmsConfig> {
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is TwilioSmsConfig {
|
||||
|
|
|
@ -39,7 +39,8 @@ export default class WechatNativeConnector extends SocialConnector<WechatNativeC
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is WechatNativeConfig {
|
||||
|
|
|
@ -40,7 +40,8 @@ export default class WechatConnector extends SocialConnector<WechatConfig> {
|
|||
constructor(getConnectorConfig: GetConnectorConfig) {
|
||||
super(getConnectorConfig);
|
||||
this.metadata = defaultMetadata;
|
||||
this.metadataParser();
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.metadataParser(__dirname);
|
||||
}
|
||||
|
||||
public validateConfig(config: unknown): asserts config is WechatConfig {
|
||||
|
|
Loading…
Reference in a new issue