Skip to content

Add manage:projects-add-feature-conditionally command#94

Merged
ondrajodas merged 2 commits into
mainfrom
ondra/projects-add-feature-conditionally
Jun 1, 2026
Merged

Add manage:projects-add-feature-conditionally command#94
ondrajodas merged 2 commits into
mainfrom
ondra/projects-add-feature-conditionally

Conversation

@ondrajodas

Copy link
Copy Markdown
Contributor

Summary

Adds a new console command manage:projects-add-feature-conditionally that adds a target feature to projects, but only to those that already have a given condition feature.

Behavior

For each project in scope:

  • skipped if the project is disabled
  • skipped if it does not have the condition feature
  • skipped if it already has the target feature
  • otherwise the target feature is added (only with -f/--force; without it the command runs as a dry run)

Scope

The whole stack is processed by default. The scope can be narrowed with one of the mutually exclusive options:

  • --project-id – a single project
  • --organization-id – all projects of one organization
  • --maintainer-id – all projects of all organizations of one maintainer

Implementation notes

  • ProjectsAddFeatureConditionally extends ProjectsAddFeature to reuse createClient(), checkIfFeatureExists() and the result counters, following the existing OrganizationsAddFeature pattern.
  • Both the condition and target features must exist (type project) or the command exits early.
  • Registered in cli.php and documented in README.md.

Verification

  • composer phpcs – passes
  • composer phpstan – no errors

Adds a target feature to projects that already have a given condition
feature. Scope can be narrowed with mutually exclusive --maintainer-id,
--organization-id or --project-id options; defaults to the whole stack.
Runs as a dry run unless -f/--force is passed.
@ondrajodas ondrajodas requested a review from Copilot June 1, 2026 08:19
@ondrajodas ondrajodas marked this pull request as ready for review June 1, 2026 08:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Symfony Console command to conditionally add a target project feature only for projects that already have a condition feature, with optional scoping (project/org/maintainer) and dry-run by default.

Changes:

  • Introduces manage:projects-add-feature-conditionally command, reusing ProjectsAddFeature client setup, feature existence checks, and counters.
  • Registers the command in cli.php.
  • Documents the new command usage and examples in README.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Keboola/Console/Command/ProjectsAddFeatureConditionally.php Implements the conditional feature-add command with mutually exclusive scope options and result reporting.
cli.php Registers the new command with the CLI application.
README.md Adds usage documentation and examples for the new command.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Keboola/Console/Command/ProjectsAddFeatureConditionally.php

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread src/Keboola/Console/Command/ProjectsAddFeatureConditionally.php
@ondrajodas

Copy link
Copy Markdown
Contributor Author
# Release Notes
New console command `manage:projects-add-feature-conditionally` for operators. It adds a target project feature only to projects that already have a specified condition feature. Scope can be the whole stack (default) or narrowed to a single maintainer, organization, or project. Runs as a dry run by default; actual changes require the -f/--force flag.

# Plans for Customer Communication
None required. This is an internal operator/maintenance CLI tool; no customer-facing change.

# Impact Analysis
Affects only the cli-utils tooling. Uses existing Manage API endpoints (listMaintainers, listMaintainerOrganizations, listOrganizationProjects, getProject, listFeatures, addProjectFeature). Without -f the command only reads and reports. Risk is limited to applying the target feature to a wider set of projects than intended if scope/feature names are wrong; mitigated by the default dry run, mutually exclusive scope options, and up-front validation that both features exist.

# Change Type
Feature (new CLI command).

# Justification
Enables bulk-enabling a feature across a stack conditionally on another feature already being present, without manually selecting project IDs. No Linear issue associated.

# Deployment Plan
No deployment needed. The command ships with the cli-utils image and is available once merged. No config changes or migrations.

# Rollback Plan
Revert the PR. The command is additive and has no persisted state; reverting removes it with no side effects.

# Post-Release Support Plan
Operators should run without -f first to review the dry-run summary (counts of disabled / missing-condition / already-having-target / updatable projects), then re-run with -f. Watch for Manage API rate limits on full-stack runs over large numbers of projects.

* features: string[]
* } $project
*/
$this->addFeatureToProjectConditionally($client, $output, $project, $conditionFeature, $targetFeature, $force);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nehodil by se tu nějakej try-catch, aby to celý nekřáplo?

@ondrajodas ondrajodas Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

jo, je to tam

@ondrajodas ondrajodas force-pushed the ondra/projects-add-feature-conditionally branch from c59ae77 to 60feb83 Compare June 1, 2026 10:30
@ondrajodas ondrajodas merged commit 1ef772e into main Jun 1, 2026
1 check passed
@ondrajodas ondrajodas deleted the ondra/projects-add-feature-conditionally branch June 1, 2026 10:31
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