File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed
packages/libraries/cli/src/commands/app Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @graphql-hive/cli ' : patch
3
+ ---
4
+
5
+ Add progress log to app: create
Original file line number Diff line number Diff line change @@ -119,10 +119,18 @@ export default class AppCreate extends Command<typeof AppCreate> {
119
119
return ;
120
120
}
121
121
122
+ const totalDocuments = Object . keys ( validationResult . data ) . length ;
123
+
124
+ this . log (
125
+ `App deployment "${ flags [ 'name' ] } @${ flags [ 'version' ] } " is created pending document upload. Uploading documents...` ,
126
+ ) ;
127
+
122
128
let buffer : Array < { hash : string ; body : string } > = [ ] ;
123
129
130
+ let counter = 0 ;
131
+
124
132
const flush = async ( force = false ) => {
125
- if ( buffer . length >= 100 || force ) {
133
+ if ( buffer . length >= 100 || ( force && buffer . length > 0 ) ) {
126
134
const result = await this . registryApi ( endpoint , accessToken ) . request ( {
127
135
operation : AddDocumentsToAppDeploymentMutation ,
128
136
variables : {
@@ -159,15 +167,20 @@ export default class AppCreate extends Command<typeof AppCreate> {
159
167
throw new APIError ( result . addDocumentsToAppDeployment . error . message ) ;
160
168
}
161
169
buffer = [ ] ;
170
+
171
+ // don't bother showing 100% since there's another log line when it's done. And for deployments with just a few docs, showing this progress is unnecessary.
172
+ if ( counter !== totalDocuments ) {
173
+ this . log (
174
+ `${ counter } / ${ totalDocuments } (${ Math . round ( ( 100.0 * counter ) / totalDocuments ) } %) documents uploaded...` ,
175
+ ) ;
176
+ }
162
177
}
163
178
} ;
164
179
165
- let counter = 0 ;
166
-
167
180
for ( const [ hash , body ] of Object . entries ( validationResult . data ) ) {
168
181
buffer . push ( { hash, body } ) ;
169
- await flush ( ) ;
170
182
counter ++ ;
183
+ await flush ( ) ;
171
184
}
172
185
173
186
await flush ( true ) ;
You can’t perform that action at this time.
0 commit comments