fix(ci): Update CI workflows, repository URL, and apply minor code formatting fixes

This commit is contained in:
2025-04-30 12:09:13 +00:00
parent 5d77214222
commit 36d9db4332
19 changed files with 531 additions and 264 deletions

View File

@@ -23,7 +23,7 @@ export class CloudflareZone {
public account: interfaces.ICflareZone['account'];
public permissions: string[];
public plan: interfaces.ICflareZone['plan'];
private cfAccount?: CloudflareAccount; // Will be set when created through a manager
/**
@@ -33,19 +33,19 @@ export class CloudflareZone {
* @returns CloudflareZone instance
*/
public static createFromApiObject(
apiObject: plugins.ICloudflareTypes['Zone'],
cfAccount?: CloudflareAccount
apiObject: plugins.ICloudflareTypes['Zone'],
cfAccount?: CloudflareAccount,
): CloudflareZone {
const cloudflareZone = new CloudflareZone();
Object.assign(cloudflareZone, apiObject);
if (cfAccount) {
cloudflareZone.cfAccount = cfAccount;
}
return cloudflareZone;
}
/**
* Check if development mode is currently active
* @returns True if development mode is active
@@ -53,7 +53,7 @@ export class CloudflareZone {
public isDevelopmentModeActive(): boolean {
return this.development_mode > 0;
}
/**
* Enable development mode for the zone
* @param cfAccount Cloudflare account to use if not already set
@@ -62,23 +62,23 @@ export class CloudflareZone {
*/
public async enableDevelopmentMode(
cfAccount?: CloudflareAccount,
duration: number = 10800
duration: number = 10800,
): Promise<CloudflareZone> {
const account = cfAccount || this.cfAccount;
if (!account) {
throw new Error('CloudflareAccount is required to enable development mode');
}
logger.log('info', `Enabling development mode for zone ${this.name}`);
try {
// The official client doesn't have a direct method for development mode
// We'll use the request method for this specific case
await account.request('PATCH', `/zones/${this.id}/settings/development_mode`, {
value: 'on',
time: duration
time: duration,
});
this.development_mode = duration;
return this;
} catch (error) {
@@ -86,7 +86,7 @@ export class CloudflareZone {
throw error;
}
}
/**
* Disable development mode for the zone
* @param cfAccount Cloudflare account to use if not already set
@@ -97,16 +97,16 @@ export class CloudflareZone {
if (!account) {
throw new Error('CloudflareAccount is required to disable development mode');
}
logger.log('info', `Disabling development mode for zone ${this.name}`);
try {
// The official client doesn't have a direct method for development mode
// We'll use the request method for this specific case
await account.request('PATCH', `/zones/${this.id}/settings/development_mode`, {
value: 'off'
value: 'off',
});
this.development_mode = 0;
return this;
} catch (error) {
@@ -114,7 +114,7 @@ export class CloudflareZone {
throw error;
}
}
/**
* Purge all cached content for this zone
* @param cfAccount Cloudflare account to use if not already set
@@ -125,13 +125,13 @@ export class CloudflareZone {
if (!account) {
throw new Error('CloudflareAccount is required to purge cache');
}
logger.log('info', `Purging all cache for zone ${this.name}`);
try {
await account.apiAccount.cache.purge({
zone_id: this.id,
purge_everything: true
purge_everything: true,
});
return true;
} catch (error) {
@@ -139,7 +139,7 @@ export class CloudflareZone {
return false;
}
}
/**
* Purge specific URLs from the cache
* @param urls Array of URLs to purge
@@ -151,17 +151,17 @@ export class CloudflareZone {
if (!account) {
throw new Error('CloudflareAccount is required to purge URLs');
}
if (!urls.length) {
return true;
}
logger.log('info', `Purging ${urls.length} URLs from cache for zone ${this.name}`);
try {
await account.apiAccount.cache.purge({
zone_id: this.id,
files: urls
files: urls,
});
return true;
} catch (error) {
@@ -169,7 +169,7 @@ export class CloudflareZone {
return false;
}
}
/**
* Check if the zone is active
* @returns True if the zone is active
@@ -177,7 +177,7 @@ export class CloudflareZone {
public isActive(): boolean {
return this.status === 'active' && !this.paused;
}
/**
* Check if the zone is using Cloudflare nameservers
* @returns True if using Cloudflare nameservers
@@ -187,11 +187,11 @@ export class CloudflareZone {
if (!this.original_name_servers || !this.name_servers) {
return false;
}
// If they're different, and current nameservers are Cloudflare's
return this.name_servers.some(ns => ns.includes('cloudflare'));
return this.name_servers.some((ns) => ns.includes('cloudflare'));
}
/**
* Update zone settings
* @param settings Settings to update
@@ -205,23 +205,23 @@ export class CloudflareZone {
vanity_name_servers: string[];
type: 'full' | 'partial' | 'secondary';
}>,
cfAccount?: CloudflareAccount
cfAccount?: CloudflareAccount,
): Promise<CloudflareZone> {
const account = cfAccount || this.cfAccount;
if (!account) {
throw new Error('CloudflareAccount is required to update zone settings');
}
logger.log('info', `Updating settings for zone ${this.name}`);
try {
// Use the request method instead of zones.edit to avoid type issues
const response: { result: interfaces.ICflareZone } = await account.request(
'PATCH',
`/zones/${this.id}`,
settings
settings,
);
Object.assign(this, response.result);
return this;
} catch (error) {
@@ -229,4 +229,4 @@ export class CloudflareZone {
throw error;
}
}
}
}