Skip to content

[Feat] Add Targets - #65

Open
bean1352 wants to merge 12 commits into
feat/show-target-instancefrom
feat/cli-environments
Open

[Feat] Add Targets#65
bean1352 wants to merge 12 commits into
feat/show-target-instancefrom
feat/cli-environments

Conversation

@bean1352

@bean1352 bean1352 commented Sep 2, 2026

Copy link
Copy Markdown

What

Adds named targets to cli.yaml, so one project directory can point at several Cloud instances, for example staging and production.

  • powersync link cloud --target=<name> --instance-id=<id> stores a link under targets.<name>. The top-level fields stay the default. --create --target=<name> creates the instance and links it in one step.
  • Pick a target per command with --target=<name> or POWERSYNC_TARGET. --instance-id still overrides both.
  • The target instance banner from [Feat] Show target instance before deploy, stop, destroy and compact #64 shows the selected target name.
  • powersync fetch instances lists the targets of each linked directory.

Backwards compatible

A cli.yaml without a targets key works exactly as before. Older CLI versions ignore the key and POWERSYNC_TARGET and use the top-level fields.

Small fixes

  • Commands that accept Cloud and self-hosted instances let --instance-id or --api-url decide the context even when cli.yaml links the other type.
  • A linked directory without service.yaml now suggests powersync pull instance.
  • Invalid IDs in cli.yaml are reported with the field name, for example targets.staging.instance_id in cli.yaml, instead of a flag name.

AI disclosure

I used Claude to research the codebase and implement the change. I reviewed and tested it myself.

@bean1352 bean1352 changed the title feat/cli environments [Feat] Add Environments Sep 2, 2026
@bean1352
bean1352 force-pushed the feat/cli-environments branch from b6fa5ed to f36a269 Compare September 2, 2026 12:13
@bean1352
bean1352 marked this pull request as draft September 2, 2026 12:19
@bean1352
bean1352 requested a review from LucDeCaf September 2, 2026 12:38
@bean1352
bean1352 marked this pull request as ready for review September 2, 2026 12:38
LucDeCaf
LucDeCaf previously approved these changes Sep 2, 2026

@LucDeCaf LucDeCaf 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.

This looks good to me :) Just some minor comments.

Comment thread .changeset/cli-environments.md Outdated
Comment thread packages/cli-core/src/utils/create-environment-flag.ts Outdated
Comment thread cli/src/commands/link/cloud.ts
@benitav

benitav commented Sep 3, 2026

Copy link
Copy Markdown

I understand that --environment is the most common use case for multiple instances, but since "environment" doesn't actually mean anything here, and customers can have multiple instances in the same environment, I think we should call this flag --target or similar to make clearer that you're targeting a specific instance, not environment, with this. --alias could be another option.

@bean1352
bean1352 marked this pull request as draft September 3, 2026 08:41
@bean1352 bean1352 changed the title [Feat] Add Environments [Feat] Add Targets Sep 3, 2026
@bean1352
bean1352 force-pushed the feat/cli-environments branch from 641e9cf to 980b6a0 Compare September 3, 2026 09:03
@bean1352

bean1352 commented Sep 3, 2026

Copy link
Copy Markdown
Author

I understand that --environment is the most common use case for multiple instances, but since "environment" doesn't actually mean anything here, and customers can have multiple instances in the same environment, I think we should call this flag --target or similar to make clearer that you're targeting a specific instance, not environment, with this. --alias could be another option.

I've opted to rename the variable to target.

@bean1352
bean1352 requested a review from LucDeCaf September 3, 2026 10:26
@bean1352
bean1352 marked this pull request as ready for review September 3, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants