fix(ci): Update CI workflows, repository URL, and apply minor code formatting fixes
This commit is contained in:
@@ -19,7 +19,7 @@ export class ZoneManager {
|
||||
public async getZones(zoneName?: string): Promise<CloudflareZone[]> {
|
||||
try {
|
||||
const options: any = { per_page: 50 };
|
||||
|
||||
|
||||
// May be optionally filtered by domain name
|
||||
if (zoneName) {
|
||||
options.name = zoneName;
|
||||
@@ -29,14 +29,14 @@ export class ZoneManager {
|
||||
for await (const zone of this.cfAccount.apiAccount.zones.list(options)) {
|
||||
zones.push(zone);
|
||||
}
|
||||
|
||||
return zones.map(zone => CloudflareZone.createFromApiObject(zone, this.cfAccount));
|
||||
|
||||
return zones.map((zone) => CloudflareZone.createFromApiObject(zone, this.cfAccount));
|
||||
} catch (error) {
|
||||
logger.log('error', `Failed to fetch zones: ${error.message}`);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a single zone by name
|
||||
* @param zoneName Zone name to find
|
||||
@@ -44,9 +44,9 @@ export class ZoneManager {
|
||||
*/
|
||||
public async getZoneByName(zoneName: string): Promise<CloudflareZone | undefined> {
|
||||
const zones = await this.getZones(zoneName);
|
||||
return zones.find(zone => zone.name === zoneName);
|
||||
return zones.find((zone) => zone.name === zoneName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a zone by its ID
|
||||
* @param zoneId Zone ID to find
|
||||
@@ -56,17 +56,17 @@ export class ZoneManager {
|
||||
try {
|
||||
// Use the request method instead of the zones.get method to avoid type issues
|
||||
const response: { result: interfaces.ICflareZone } = await this.cfAccount.request(
|
||||
'GET',
|
||||
`/zones/${zoneId}`
|
||||
'GET',
|
||||
`/zones/${zoneId}`,
|
||||
);
|
||||
|
||||
|
||||
return CloudflareZone.createFromApiObject(response.result as any, this.cfAccount);
|
||||
} catch (error) {
|
||||
logger.log('error', `Failed to fetch zone with ID ${zoneId}: ${error.message}`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new zone
|
||||
* @param zoneName Name of the zone to create
|
||||
@@ -75,37 +75,37 @@ export class ZoneManager {
|
||||
* @returns The created zone
|
||||
*/
|
||||
public async createZone(
|
||||
zoneName: string,
|
||||
zoneName: string,
|
||||
jumpStart: boolean = false,
|
||||
accountId?: string
|
||||
accountId?: string,
|
||||
): Promise<CloudflareZone | undefined> {
|
||||
const useAccountId = accountId || this.cfAccount.preselectedAccountId;
|
||||
|
||||
|
||||
if (!useAccountId) {
|
||||
throw new Error('No account selected. Please select it first on the account.');
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
logger.log('info', `Creating zone ${zoneName}`);
|
||||
|
||||
|
||||
// Use the request method for more direct control over the parameters
|
||||
const response: { result: interfaces.ICflareZone } = await this.cfAccount.request(
|
||||
'POST',
|
||||
'/zones',
|
||||
'POST',
|
||||
'/zones',
|
||||
{
|
||||
name: zoneName,
|
||||
jump_start: jumpStart,
|
||||
account: { id: useAccountId }
|
||||
}
|
||||
account: { id: useAccountId },
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
return CloudflareZone.createFromApiObject(response.result as any, this.cfAccount);
|
||||
} catch (error) {
|
||||
logger.log('error', `Failed to create zone ${zoneName}: ${error.message}`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a zone
|
||||
* @param zoneId ID of the zone to delete
|
||||
@@ -114,7 +114,7 @@ export class ZoneManager {
|
||||
public async deleteZone(zoneId: string): Promise<boolean> {
|
||||
try {
|
||||
logger.log('info', `Deleting zone with ID ${zoneId}`);
|
||||
|
||||
|
||||
// Use the request method to avoid type issues
|
||||
await this.cfAccount.request('DELETE', `/zones/${zoneId}`);
|
||||
return true;
|
||||
@@ -123,7 +123,7 @@ export class ZoneManager {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a zone exists
|
||||
* @param zoneName Name of the zone to check
|
||||
@@ -131,9 +131,9 @@ export class ZoneManager {
|
||||
*/
|
||||
public async zoneExists(zoneName: string): Promise<boolean> {
|
||||
const zones = await this.getZones(zoneName);
|
||||
return zones.some(zone => zone.name === zoneName);
|
||||
return zones.some((zone) => zone.name === zoneName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Activate a zone (if it's in pending status)
|
||||
* @param zoneId ID of the zone to activate
|
||||
@@ -142,23 +142,23 @@ export class ZoneManager {
|
||||
public async activateZone(zoneId: string): Promise<CloudflareZone | undefined> {
|
||||
try {
|
||||
logger.log('info', `Activating zone with ID ${zoneId}`);
|
||||
|
||||
|
||||
// Use the request method for better control
|
||||
const response: { result: interfaces.ICflareZone } = await this.cfAccount.request(
|
||||
'PATCH',
|
||||
'PATCH',
|
||||
`/zones/${zoneId}`,
|
||||
{
|
||||
status: 'active'
|
||||
}
|
||||
status: 'active',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
return CloudflareZone.createFromApiObject(response.result as any, this.cfAccount);
|
||||
} catch (error) {
|
||||
logger.log('error', `Failed to activate zone with ID ${zoneId}: ${error.message}`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check the activation status of a zone
|
||||
* @param zoneId ID of the zone to check
|
||||
@@ -167,17 +167,17 @@ export class ZoneManager {
|
||||
public async checkZoneActivation(zoneId: string): Promise<CloudflareZone | undefined> {
|
||||
try {
|
||||
logger.log('info', `Checking activation for zone with ID ${zoneId}`);
|
||||
|
||||
|
||||
// For this specific endpoint, we'll use the request method
|
||||
const response: { result: interfaces.ICflareZone } = await this.cfAccount.request(
|
||||
'PUT',
|
||||
`/zones/${zoneId}/activation_check`
|
||||
`/zones/${zoneId}/activation_check`,
|
||||
);
|
||||
|
||||
|
||||
return CloudflareZone.createFromApiObject(response.result as any, this.cfAccount);
|
||||
} catch (error) {
|
||||
logger.log('error', `Failed to check zone activation with ID ${zoneId}: ${error.message}`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user