-
Notifications
You must be signed in to change notification settings - Fork 736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workflows commands #7015
Merged
Merged
Workflows commands #7015
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f0be6ea
start from workflows branch, squashed
RamIdeas 0cb8b8c
remove commands for another PR
RamIdeas 5a2d0ef
add Workflow support to `wrangler types`
RamIdeas 0f6ca2e
update fixture
RamIdeas 0d9880b
add (skipped) e2e test
RamIdeas b8d41b2
fix pnpm-lock.yaml
RamIdeas 37ea252
fix test
RamIdeas 9f6adc9
add changeset
RamIdeas 80af061
add commands
RamIdeas 2ceb959
add command description
RamIdeas 1ad3b9a
change private beta message to open beta
RamIdeas 998453f
refactor to use defineCommand util
RamIdeas 74a8019
add changeset
RamIdeas 5f368a0
update snapshots
RamIdeas 9a2b2e4
remove extraneous periods
RamIdeas 658f82e
Merge remote-tracking branch 'origin/main' into workflows-commands
RamIdeas fd82b95
remove redundant file
RamIdeas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", | ||
RamIdeas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might think about creating a separate
owners
config, which would help to keep this consistent over time.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered this in the design but I think the granularity and colocation trump the duplication and especially since it will be infrequently changed