Skip to content

feat(cli): add --no-sync-policy-roles flag#203

Merged
EdouardDem merged 5 commits into
nextfrom
feat/no-sync-policy-roles
Apr 9, 2026
Merged

feat(cli): add --no-sync-policy-roles flag#203
EdouardDem merged 5 commits into
nextfrom
feat/no-sync-policy-roles

Conversation

@EdouardDem
Copy link
Copy Markdown
Member

@EdouardDem EdouardDem commented Apr 8, 2026

Summary

  • Adds a new CLI flag --no-sync-policy-roles (and matching syncPolicyRoles config option) so role ↔ policy attachments (directus_access entries linking roles and policies) can be left untouched on the target during sync.
  • When enabled:
    1. PoliciesDataClient.getQueryCommand omits the roles.* fields, so attachments are never dumped or fetched from the target.
    2. PoliciesDataClient.getUpdateCommand strips diffItem.roles before updating, so existing target attachments are preserved.
  • Policy definitions, permissions and other tweaks still sync normally; only the role↔policy assignments become owned by the target environment.

Fixes #199 — addresses the case where end-users (clients) attach policies to roles in production and those assignments were being wiped on every push.

Note on user-policy attachments: directus_access entries that link policies to users (rather than roles) are already not dumped nor modified by the current sync logic, so they remain untouched without any additional flag.

Test plan

  • tsc --noEmit clean for packages/cli and packages/e2e
  • npm run build succeeds in packages/cli
  • New e2e test pushWithNoSyncPolicyRoles covers:
    • target attachments added/removed by an admin are preserved across push when --no-sync-policy-roles is set
    • pull --no-sync-policy-roles does not include roles in the dumped policy file

🤖 Generated with Claude Code

EdouardDem and others added 2 commits April 8, 2026 09:35
Allows leaving role ↔ policy attachments (directus_access entries)
untouched on the target instance, so end-user-managed assignments are
not overwritten by sync.

Closes #199

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@EdouardDem EdouardDem force-pushed the feat/no-sync-policy-roles branch from 22f6a75 to 130c2a9 Compare April 8, 2026 13:36
@EdouardDem EdouardDem changed the base branch from main to next April 8, 2026 13:37
@EdouardDem EdouardDem merged commit d3008a2 into next Apr 9, 2026
3 checks passed
@BorisKamp
Copy link
Copy Markdown

Nice @EdouardDem ! When do you plan to release a new version with this included?

@EdouardDem
Copy link
Copy Markdown
Member Author

@BorisKamp I'll do it in the next hour, after merging #204

@EdouardDem EdouardDem deleted the feat/no-sync-policy-roles branch April 11, 2026 17:36
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.

Exclude directus_access sync

2 participants