-
Notifications
You must be signed in to change notification settings - Fork 12
Replace pullRealmFiles with BoxelCLIClient.pull() #4422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
780a313
2431c2a
f0f2813
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ interface PullOptions extends SyncOptions { | |
|
|
||
| class RealmPuller extends RealmSyncBase { | ||
| hasError = false; | ||
| downloadedFiles: string[] = []; | ||
|
|
||
| constructor( | ||
| private pullOptions: PullOptions, | ||
|
|
@@ -106,7 +107,7 @@ class RealmPuller extends RealmSyncBase { | |
| }), | ||
| ), | ||
| ); | ||
| const downloadedFiles = downloadResults.filter( | ||
| this.downloadedFiles = downloadResults.filter( | ||
| (f): f is string => f !== null, | ||
| ); | ||
|
|
||
|
|
@@ -138,10 +139,10 @@ class RealmPuller extends RealmSyncBase { | |
|
|
||
| if ( | ||
| !this.options.dryRun && | ||
| downloadedFiles.length + deletedFiles.length > 0 | ||
| this.downloadedFiles.length + deletedFiles.length > 0 | ||
| ) { | ||
| const pullChanges: CheckpointChange[] = [ | ||
| ...downloadedFiles.map((f) => ({ | ||
| ...this.downloadedFiles.map((f) => ({ | ||
| file: f, | ||
| status: 'modified' as const, | ||
| })), | ||
|
|
@@ -189,23 +190,28 @@ export function registerPullCommand(realm: Command): void { | |
| localDir: string, | ||
| options: { delete?: boolean; dryRun?: boolean }, | ||
| ) => { | ||
| await pullCommand(realmUrl, localDir, options); | ||
| let result = await pull(realmUrl, localDir, options); | ||
| if (result.error) { | ||
| console.error(`Error: ${result.error}`); | ||
| process.exit(result.files.length > 0 ? 2 : 1); | ||
| } | ||
| console.log('Pull completed successfully'); | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| export async function pullCommand( | ||
| export async function pull( | ||
| realmUrl: string, | ||
| localDir: string, | ||
| options: PullCommandOptions, | ||
| ): Promise<void> { | ||
| ): Promise<{ files: string[]; error?: string }> { | ||
| let pm = options.profileManager ?? getProfileManager(); | ||
| let active = pm.getActiveProfile(); | ||
| if (!active) { | ||
| console.error( | ||
| 'Error: no active profile. Run `boxel profile add` to create one.', | ||
| ); | ||
| process.exit(1); | ||
| return { | ||
| files: [], | ||
| error: 'No active profile. Run `boxel profile add` to create one.', | ||
| }; | ||
|
Comment on lines
+203
to
+214
|
||
| } | ||
|
|
||
| try { | ||
|
|
@@ -222,13 +228,18 @@ export async function pullCommand( | |
| await puller.sync(); | ||
|
|
||
| if (puller.hasError) { | ||
| console.log('Pull did not complete successfully. View logs for details'); | ||
| process.exit(2); | ||
| } else { | ||
| console.log('Pull completed successfully'); | ||
| return { | ||
| files: puller.downloadedFiles.sort(), | ||
| error: | ||
| 'Pull completed with errors. Some files may not have been downloaded.', | ||
| }; | ||
| } | ||
|
|
||
| return { files: puller.downloadedFiles.sort() }; | ||
| } catch (error) { | ||
| console.error('Pull failed:', error); | ||
| process.exit(1); | ||
| return { | ||
| files: [], | ||
| error: `Pull failed: ${error instanceof Error ? error.message : String(error)}`, | ||
| }; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can drop the
pullCommandfunction and use this function inregisterPullCommandand move theconsole.logandprocess.exitthat previously handled in pullCommand toregisterPullCommand.