feat: add --force flag to push for all resources#742
Merged
Conversation
Add support for a --force boolean flag across all resource push commands (workflow, guide, partial, translation, layout, message-type, audience) and the top-level push command. When provided, the flag is passed to the API as force: true to bypass environment restrictions and overwrite existing content in Knock. - Added --force flag definition to all push command static flags - Updated all upsert methods in api-v1.ts to include force in params - For audience push (SDK-based), force is passed via request options query - Top-level push command forwards --force to all sub-commands - Added tests for each resource push command verifying force flag behavior Co-authored-by: Chris Bell <chris@cjbell.co>
Extract the --force flag definition into src/lib/helpers/flag.ts as a shared CustomFlags.force export, following the same pattern as CustomFlags.branch. All push commands now reference CustomFlags.force instead of defining the flag inline. Updated the summary copy to: "Force pushes the resource or resources to Knock, overwriting whatever is currently stored. If you're using this on a non-development environment, you should also ensure you commit the changes." Co-authored-by: Chris Bell <chris@cjbell.co>
--force flag to push for all resources
meryldakin
reviewed
Mar 18, 2026
| export const force = Flags.boolean({ | ||
| summary: | ||
| "Force pushes the resource or resources to Knock, overwriting whatever is currently stored. " + | ||
| "If you're using this on a non-development environment, you should also ensure you `commit` the changes.", |
Contributor
There was a problem hiding this comment.
Does this feel actionable enough as an instruction? Are we leaving it up to the users to do this or do we have some kind of guard around not messing this up?
Contributor
Author
There was a problem hiding this comment.
I think so? You can run knock push --force without commit then you'd just need to commit the changes in your non dev env, like you have to already in dev.
meryldakin
approved these changes
Mar 18, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Adds support for a
--forceboolean flag across all resource push commands. When provided, the flag bypasses environment restrictions and overwrites existing content in Knock by passingforce: trueto the API.The flag is defined as a shared
CustomFlags.forceexport insrc/lib/helpers/flag.ts, following the same pattern asCustomFlags.branch, so the copy is centralized.Commands updated:
workflow pushguide pushpartial pushtranslation pushlayout pushmessage-type pushaudience pushpush(top-level, which delegates to all of the above)Implementation details:
forceflag defined insrc/lib/helpers/flag.tswith summary: "Force pushes the resource or resources to Knock, overwriting whatever is currently stored. If you're using this on a non-development environment, you should also ensure you `commit` the changes."CustomFlags.forcein its static flagsupsert*methods inapi-v1.tsincludeforce: flags.forcein their query params (pruned when falsy)@knocklabs/mgmtSDK directly),forceis passed via request optionsquerysince the SDK'sAudienceUpsertParamstype doesn't yet include theforcefieldpushcommand forwards--forceto all sub-commands via the args arrayTasks
N/A
Screenshots
N/A — CLI-only change, verified via automated tests.