-
Notifications
You must be signed in to change notification settings - Fork 736
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
402 additions
and
455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
import { fetchResult } from "../../cfetch"; | ||
import { readConfig } from "../../config"; | ||
import { defineCommand } from "../../core"; | ||
import { logger } from "../../logger"; | ||
import { printWranglerBanner } from "../../update-check"; | ||
import { requireAuth } from "../../user"; | ||
import type { | ||
CommonYargsArgv, | ||
StrictYargsOptionsToInterface, | ||
} from "../../yargs-types"; | ||
|
||
export const workflowDeleteOptions = (args: CommonYargsArgv) => { | ||
return args.positional("name", { | ||
describe: "Name of the workflow", | ||
type: "string", | ||
demandOption: true, | ||
}); | ||
}; | ||
defineCommand({ | ||
command: "wrangler workflows delete", | ||
metadata: { | ||
description: | ||
"Delete workflow - when deleting a workflow, it will also delete it's own instances", | ||
owner: "Product: Workflows", | ||
status: "open-beta", | ||
}, | ||
|
||
type HandlerOptions = StrictYargsOptionsToInterface< | ||
typeof workflowDeleteOptions | ||
>; | ||
export const workflowDeleteHandler = async (args: HandlerOptions) => { | ||
await printWranglerBanner(); | ||
args: { | ||
name: { | ||
describe: "Name of the workflow", | ||
type: "string", | ||
demandOption: true, | ||
}, | ||
}, | ||
positionalArgs: ["name"], | ||
|
||
const config = readConfig(args.config, args); | ||
const accountId = await requireAuth(config); | ||
async handler(args, { config }) { | ||
const accountId = await requireAuth(config); | ||
|
||
await fetchResult(`/accounts/${accountId}/workflows/${args.name}`, { | ||
method: "DELETE", | ||
}); | ||
await fetchResult(`/accounts/${accountId}/workflows/${args.name}`, { | ||
method: "DELETE", | ||
}); | ||
|
||
logger.info(`Workflow "${args.name}" was successfully removed`); | ||
}; | ||
logger.info(`Workflow "${args.name}" was successfully removed`); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,59 @@ | ||
import { logRaw } from "@cloudflare/cli"; | ||
import { white } from "@cloudflare/cli/colors"; | ||
import { fetchResult } from "../../cfetch"; | ||
import { readConfig } from "../../config"; | ||
import { printWranglerBanner } from "../../update-check"; | ||
import { defineCommand } from "../../core"; | ||
import { requireAuth } from "../../user"; | ||
import formatLabelledValues from "../../utils/render-labelled-values"; | ||
import { | ||
type CommonYargsArgv, | ||
type StrictYargsOptionsToInterface, | ||
} from "../../yargs-types"; | ||
import type { Version, Workflow } from "../types"; | ||
|
||
export const workflowDescribeOptions = (args: CommonYargsArgv) => { | ||
return args.positional("name", { | ||
describe: "Name of the workflow", | ||
type: "string", | ||
demandOption: true, | ||
}); | ||
}; | ||
defineCommand({ | ||
command: "wrangler workflows describe", | ||
metadata: { | ||
description: "Describe Workflow resource", | ||
owner: "Product: Workflows", | ||
status: "open-beta", | ||
}, | ||
args: { | ||
name: { | ||
describe: "Name of the workflow", | ||
type: "string", | ||
demandOption: true, | ||
}, | ||
}, | ||
positionalArgs: ["name"], | ||
async handler(args, { config }) { | ||
const accountId = await requireAuth(config); | ||
|
||
type HandlerOptions = StrictYargsOptionsToInterface< | ||
typeof workflowDescribeOptions | ||
>; | ||
export const workflowDescribeHandler = async (args: HandlerOptions) => { | ||
await printWranglerBanner(); | ||
const workflow = await fetchResult<Workflow>( | ||
`/accounts/${accountId}/workflows/${args.name}` | ||
); | ||
|
||
const config = readConfig(args.config, args); | ||
const accountId = await requireAuth(config); | ||
const versions = await fetchResult<Version[]>( | ||
`/accounts/${accountId}/workflows/${args.name}/versions` | ||
); | ||
|
||
const workflow = await fetchResult<Workflow>( | ||
`/accounts/${accountId}/workflows/${args.name}` | ||
); | ||
const latestVersion = versions[0]; | ||
|
||
const versions = await fetchResult<Version[]>( | ||
`/accounts/${accountId}/workflows/${args.name}/versions` | ||
); | ||
|
||
const latestVersion = versions[0]; | ||
|
||
logRaw( | ||
formatLabelledValues({ | ||
Name: workflow.name, | ||
Id: workflow.id, | ||
"Script Name": workflow.script_name, | ||
"Class Name": workflow.class_name, | ||
"Created On": workflow.created_on, | ||
"Modified On": workflow.modified_on, | ||
}) | ||
); | ||
logRaw(white("Latest Version:")); | ||
logRaw( | ||
formatLabelledValues( | ||
{ | ||
Id: latestVersion.id, | ||
logRaw( | ||
formatLabelledValues({ | ||
Name: workflow.name, | ||
Id: workflow.id, | ||
"Script Name": workflow.script_name, | ||
"Class Name": workflow.class_name, | ||
"Created On": workflow.created_on, | ||
"Modified On": workflow.modified_on, | ||
}, | ||
{ indentationCount: 2 } | ||
) | ||
); | ||
}; | ||
}) | ||
); | ||
logRaw(white("Latest Version:")); | ||
logRaw( | ||
formatLabelledValues( | ||
{ | ||
Id: latestVersion.id, | ||
"Created On": workflow.created_on, | ||
"Modified On": workflow.modified_on, | ||
}, | ||
{ indentationCount: 2 } | ||
) | ||
); | ||
}, | ||
}); |
Oops, something went wrong.