-
Notifications
You must be signed in to change notification settings - Fork 724
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add commands * add command description * change private beta message to open beta * refactor to use defineCommand util * add changeset * update snapshots * remove extraneous periods * remove redundant file Co-authored-by: Luís Duarte <lduarte@cloudflare.com>
- Loading branch information
1 parent
244aa57
commit 48152d6
Showing
17 changed files
with
776 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"wrangler": minor | ||
--- | ||
|
||
add `wrangler workflows ...` commands |
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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { fetchResult } from "../../cfetch"; | ||
import { defineCommand } from "../../core"; | ||
import { logger } from "../../logger"; | ||
import { requireAuth } from "../../user"; | ||
|
||
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", | ||
}, | ||
|
||
args: { | ||
name: { | ||
describe: "Name of the workflow", | ||
type: "string", | ||
demandOption: true, | ||
}, | ||
}, | ||
positionalArgs: ["name"], | ||
|
||
async handler(args, { config }) { | ||
const accountId = await requireAuth(config); | ||
|
||
await fetchResult(`/accounts/${accountId}/workflows/${args.name}`, { | ||
method: "DELETE", | ||
}); | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { logRaw } from "@cloudflare/cli"; | ||
import { white } from "@cloudflare/cli/colors"; | ||
import { fetchResult } from "../../cfetch"; | ||
import { defineCommand } from "../../core"; | ||
import { requireAuth } from "../../user"; | ||
import formatLabelledValues from "../../utils/render-labelled-values"; | ||
import type { Version, Workflow } from "../types"; | ||
|
||
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); | ||
|
||
const workflow = await fetchResult<Workflow>( | ||
`/accounts/${accountId}/workflows/${args.name}` | ||
); | ||
|
||
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, | ||
"Created On": workflow.created_on, | ||
"Modified On": workflow.modified_on, | ||
}, | ||
{ indentationCount: 2 } | ||
) | ||
); | ||
}, | ||
}); |
Oops, something went wrong.