Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the powersync deploy sync-config flow so it can deploy/validate sync rules without requiring a local service.yaml, and adds an option to point at a sync config file in a custom location.
Changes:
- Stop requiring
service.yamlfordeploy sync-configby avoiding local service config parsing for that command. - Add
--sync-config-file-pathto deploy sync config from an arbitrary file location. - Add unit tests covering
deploy sync-config(noservice.yaml) anddeploy service-config(nosync-config.yaml) scenarios.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/cli-core/src/command-types/SelfHostedInstanceCommand.ts | Renames config parsing method to parseLocalConfig. |
| packages/cli-core/src/command-types/CloudInstanceCommand.ts | Renames config parsing method to parseLocalConfig and updates docs. |
| cli/src/commands/link/cloud.ts | Updates call site to renamed parsing method. |
| cli/src/commands/deploy/index.ts | Updates override + call sites to renamed parsing method. |
| cli/src/commands/deploy/service-config.ts | Updates call site to renamed parsing method. |
| cli/src/commands/deploy/sync-config.ts | Implements optional sync config path flag and removes local service.yaml dependency for this command. |
| cli/test/commands/deploy/sync-config.test.ts | Adds coverage for sync-config deploy without service.yaml and with custom sync config path. |
| cli/test/commands/deploy/service-config.test.ts | Adds coverage for service-config deploy without sync-config.yaml. |
| cli/README.md | Documents the new --sync-config-file-path flag in CLI docs. |
Comments suppressed due to low confidence (2)
packages/cli-core/src/command-types/CloudInstanceCommand.ts:223
- Renaming the exported method
parseConfig()toparseLocalConfig()is a breaking change for any external consumers/plugins extendingCloudInstanceCommand. Consider keepingparseConfig()as a backwards-compatible wrapper (possibly deprecated) that forwards toparseLocalConfig()so existing plugins don’t break on upgrade.
parseLocalConfig(projectDirectory: string): ServiceCloudConfigDecoded {
const servicePath = join(projectDirectory, SERVICE_FILENAME);
const doc = parseYamlFile(servicePath);
// validate the config with full schema
const validationResult = validateCloudConfig(doc.contents?.toJSON());
if (!validationResult.valid) {
throw new Error(`Invalid cloud config: ${validationResult.errors?.join('\n')}`);
}
this.serviceConfig = ServiceCloudConfig.decode(doc.contents?.toJSON());
return this.serviceConfig;
}
packages/cli-core/src/command-types/SelfHostedInstanceCommand.ts:127
- Same API-compat concern as
CloudInstanceCommand: renamingparseConfig()→parseLocalConfig()on an exported base command can break downstream plugin code. If this package is consumed outside this repo, consider keeping a deprecatedparseConfig()wrapper for compatibility.
parseLocalConfig(projectDirectory: string): ServiceSelfHostedConfigDecoded {
const servicePath = join(projectDirectory, SERVICE_FILENAME);
const doc = parseYamlFile(servicePath);
// validate the config with full schema
const validationResult = validateSelfHostedConfig(doc.contents?.toJSON());
if (!validationResult.valid) {
throw new Error(`Invalid self-hosted config: ${validationResult.errors?.join('\n')}`);
}
return ServiceSelfHostedConfig.decode(doc.contents?.toJSON());
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
The
deploy sync-configcommand is used when users only want to deploy Sync config (without service changes) - if service config isn't deployed, users don't need to track the PowerSync service Sync config in their projects. This command should not require aservice.yamlfile to be present.The previous implementation threw an error, blocking deploy, if the
service.yamlfile was not found.This updates the
sync-configdeploy to not requireservice.yamlto be present. We also allow the sync config to be present in any location with a new optionalsync-config-file-pathflag.Unit tests have been added to ensure this behaviour. Unit tests have also been added to ensure the
deploy service-configcommand - which does not require sync-config to be present, works as expected.