bajo-extra 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,7 +3,8 @@ async function fetchAndSave ({ source = {}, converter, coll, current = {}, optio
|
|
|
3
3
|
const { isEmpty, isFunction } = await importPkg('lodash-es')
|
|
4
4
|
const { fetch } = this.bajoExtra.helper
|
|
5
5
|
const { recordCreate, recordFind, recordUpdate, validationErrorMessage } = this.bajoDb.helper
|
|
6
|
-
const
|
|
6
|
+
const opts = { type: options.showSpinner ? 'bora' : 'log', pkg: options.pkg }
|
|
7
|
+
const spinner = print.bora('Fetching starts...', { showCounter: true, showDatetime: true, isEnabled: !options.returnEarly }).start()
|
|
7
8
|
const resp = await fetch(source.url, source.options ?? {})
|
|
8
9
|
if (isEmpty(resp)) spinner.fatal('No result from server, aborted!')
|
|
9
10
|
if (source.abort) {
|
|
@@ -29,7 +30,7 @@ async function fetchAndSave ({ source = {}, converter, coll, current = {}, optio
|
|
|
29
30
|
await recordCreate(current.coll, rc)
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
if (options.printCount && (count % options.printCount === 0)) print.succeed(`[${spinner.getElapsed()}] Batch line %d/%d`, count, resp.response.length,
|
|
33
|
+
if (options.printCount && (count % options.printCount === 0)) print.succeed(`[${spinner.getElapsed()}] Batch line %d/%d`, count, resp.response.length, opts)
|
|
33
34
|
else spinner.setText('Record %d/%d...', count, resp.response.length)
|
|
34
35
|
count++
|
|
35
36
|
} catch (err) {
|