0
Fork 0
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:
Darcy Ye 2022-08-08 23:55:47 +08:00
parent 1a557bc184
commit ff89c0b3a5
No known key found for this signature in database
GPG key ID: B46F4C07EDEFC610
18 changed files with 35 additions and 21 deletions

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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))

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {