Skip to content

feat: add --force flag to push for all resources#742

Merged
cjbell merged 2 commits intomainfrom
cjbell-resource-push-force-option-c51f
Mar 18, 2026
Merged

feat: add --force flag to push for all resources#742
cjbell merged 2 commits intomainfrom
cjbell-resource-push-force-option-c51f

Conversation

@cjbell
Copy link
Contributor

@cjbell cjbell commented Mar 18, 2026

Description

Adds support for a --force boolean flag across all resource push commands. When provided, the flag bypasses environment restrictions and overwrites existing content in Knock by passing force: true to the API.

The flag is defined as a shared CustomFlags.force export in src/lib/helpers/flag.ts, following the same pattern as CustomFlags.branch, so the copy is centralized.

Commands updated:

  • workflow push
  • guide push
  • partial push
  • translation push
  • layout push
  • message-type push
  • audience push
  • push (top-level, which delegates to all of the above)

Implementation details:

  • Shared force flag defined in src/lib/helpers/flag.ts with 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."
  • Each push command references CustomFlags.force in its static flags
  • All upsert* methods in api-v1.ts include force: flags.force in their query params (pruned when falsy)
  • For audience push (which uses the @knocklabs/mgmt SDK directly), force is passed via request options query since the SDK's AudienceUpsertParams type doesn't yet include the force field
  • The top-level push command forwards --force to all sub-commands via the args array
  • Tests added for each resource push command verifying the force flag is passed through correctly

Tasks

N/A

Screenshots

N/A — CLI-only change, verified via automated tests.

Open in Web Open in Cursor 

cursoragent and others added 2 commits March 18, 2026 18:31
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>
@cjbell cjbell changed the title Add --force flag to all resource push commands feat: add --force flag to push for all resources Mar 18, 2026
@cjbell cjbell marked this pull request as ready for review March 18, 2026 18:43
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.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cjbell cjbell merged commit b66a2f0 into main Mar 18, 2026
7 checks passed
@cjbell cjbell deleted the cjbell-resource-push-force-option-c51f branch March 18, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants