fix(ci): Update CI workflows, repository URL, and apply minor code formatting fixes
This commit is contained in:
@@ -20,7 +20,7 @@ export class WorkerManager {
|
||||
if (!this.cfAccount.preselectedAccountId) {
|
||||
throw new Error('No account selected. Please select it first on the account.');
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// Use the official client to create/update the worker (upload script content)
|
||||
// Build params as any to include the script form part without TS errors
|
||||
@@ -31,12 +31,12 @@ export class WorkerManager {
|
||||
contentParams['CF-WORKER-BODY-PART'] = 'script';
|
||||
contentParams['script'] = workerScript;
|
||||
await this.cfAccount.apiAccount.workers.scripts.content.update(workerName, contentParams);
|
||||
|
||||
|
||||
// Create a new worker instance
|
||||
const worker = new CloudflareWorker(this);
|
||||
worker.id = workerName;
|
||||
worker.script = workerScript;
|
||||
|
||||
|
||||
// Initialize the worker and get its routes
|
||||
try {
|
||||
await worker.getRoutes();
|
||||
@@ -44,7 +44,7 @@ export class WorkerManager {
|
||||
logger.log('warn', `Failed to get routes for worker ${workerName}: ${routeError.message}`);
|
||||
// Continue anyway since the worker was created
|
||||
}
|
||||
|
||||
|
||||
return worker;
|
||||
} catch (error) {
|
||||
logger.log('error', `Failed to create worker ${workerName}: ${error.message}`);
|
||||
@@ -61,22 +61,22 @@ export class WorkerManager {
|
||||
if (!this.cfAccount.preselectedAccountId) {
|
||||
throw new Error('No account selected. Please select it first on the account.');
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// Get the worker script using the official client
|
||||
const workerScript = await this.cfAccount.apiAccount.workers.scripts.get(workerName, {
|
||||
account_id: this.cfAccount.preselectedAccountId
|
||||
account_id: this.cfAccount.preselectedAccountId,
|
||||
});
|
||||
|
||||
|
||||
// Create a new worker instance
|
||||
const worker = new CloudflareWorker(this);
|
||||
worker.id = workerName;
|
||||
|
||||
|
||||
// Save script content if available
|
||||
if (workerScript && typeof workerScript === 'object') {
|
||||
Object.assign(worker, workerScript);
|
||||
}
|
||||
|
||||
|
||||
// Initialize the worker and get its routes
|
||||
try {
|
||||
await worker.getRoutes();
|
||||
@@ -84,7 +84,7 @@ export class WorkerManager {
|
||||
logger.log('warn', `Failed to get routes for worker ${workerName}: ${routeError.message}`);
|
||||
// Continue anyway since we found the worker
|
||||
}
|
||||
|
||||
|
||||
return worker;
|
||||
} catch (error) {
|
||||
logger.log('warn', `Worker '${workerName}' not found: ${error.message}`);
|
||||
@@ -100,35 +100,35 @@ export class WorkerManager {
|
||||
if (!this.cfAccount.preselectedAccountId) {
|
||||
throw new Error('No account selected. Please select it first on the account.');
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// Collect all scripts using the new client's async iterator
|
||||
const workerScripts: plugins.ICloudflareTypes['Script'][] = [];
|
||||
|
||||
|
||||
try {
|
||||
for await (const script of this.cfAccount.apiAccount.workers.scripts.list({
|
||||
account_id: this.cfAccount.preselectedAccountId,
|
||||
})) {
|
||||
workerScripts.push(script);
|
||||
}
|
||||
|
||||
|
||||
logger.log('info', `Found ${workerScripts.length} worker scripts`);
|
||||
return workerScripts;
|
||||
} catch (error) {
|
||||
logger.log('warn', `Error while listing workers with async iterator: ${error.message}`);
|
||||
|
||||
|
||||
// Try alternative approach if the async iterator fails
|
||||
const result = await this.cfAccount.apiAccount.workers.scripts.list({
|
||||
const result = (await this.cfAccount.apiAccount.workers.scripts.list({
|
||||
account_id: this.cfAccount.preselectedAccountId,
|
||||
}) as any;
|
||||
|
||||
})) as any;
|
||||
|
||||
// Check if the result has a 'result' property (older API response format)
|
||||
if (result && result.result && Array.isArray(result.result)) {
|
||||
logger.log('info', `Found ${result.result.length} worker scripts using direct result`);
|
||||
return result.result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger.log('warn', 'Could not retrieve worker scripts');
|
||||
return [];
|
||||
} catch (error) {
|
||||
@@ -136,7 +136,7 @@ export class WorkerManager {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a worker script
|
||||
* @param workerName Name of the worker to delete
|
||||
@@ -146,10 +146,10 @@ export class WorkerManager {
|
||||
if (!this.cfAccount.preselectedAccountId) {
|
||||
throw new Error('No account selected. Please select it first on the account.');
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
await this.cfAccount.apiAccount.workers.scripts.delete(workerName, {
|
||||
account_id: this.cfAccount.preselectedAccountId
|
||||
account_id: this.cfAccount.preselectedAccountId,
|
||||
});
|
||||
logger.log('info', `Worker '${workerName}' deleted successfully`);
|
||||
return true;
|
||||
@@ -158,4 +158,4 @@ export class WorkerManager {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user