closer-cli 2.16.3 → 2.16.6
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.
- package/CHANGELOG.md +11 -0
- package/cmds/exportData.js +84 -0
- package/helpers.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.16.4](https://code.hfarm.dev/closer/closer/compare/v2.16.3...v2.16.4) (2022-06-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* hide retail price row if not exists ([883784e](https://code.hfarm.dev/closer/closer/commits/883784e97c64df77631ca569a0622ac8407c0cc4))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [2.11.0](https://code.hfarm.dev/closer/closer/compare/v2.10.0...v2.11.0) (2022-05-18)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
/* eslint-disable no-await-in-loop */
|
|
3
|
+
/* eslint-disable no-restricted-syntax */
|
|
4
|
+
|
|
5
|
+
const chalk = require('chalk')
|
|
6
|
+
const Ora = require('ora')
|
|
7
|
+
const prompts = require('prompts')
|
|
8
|
+
const { ALLOWED_CSV_FILES, exportCsv } = require('../helpers')
|
|
9
|
+
|
|
10
|
+
exports.command = 'export:data'
|
|
11
|
+
exports.desc = 'Export data from Closer'
|
|
12
|
+
|
|
13
|
+
exports.builder = yargs => {
|
|
14
|
+
yargs.usage(`Usage: ${chalk.cyan('$0 export:data')} [options]`)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.handler = async argv => {
|
|
18
|
+
const interactive = !argv.nonInteractive
|
|
19
|
+
|
|
20
|
+
const csvChoices = Object.keys(ALLOWED_CSV_FILES).map(csvType => ({
|
|
21
|
+
title: csvType,
|
|
22
|
+
csvType,
|
|
23
|
+
value: csvType
|
|
24
|
+
}))
|
|
25
|
+
|
|
26
|
+
let csvTypes
|
|
27
|
+
if (interactive && !argv.type) {
|
|
28
|
+
const answers = await prompts(
|
|
29
|
+
[
|
|
30
|
+
{
|
|
31
|
+
instructions: false,
|
|
32
|
+
name: 'csvTypes',
|
|
33
|
+
type: 'multiselect',
|
|
34
|
+
message: 'Select CSV type',
|
|
35
|
+
choices: csvChoices,
|
|
36
|
+
min: 1
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
{ onCancel: () => process.exit() }
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
csvTypes = answers.csvTypes
|
|
43
|
+
} else {
|
|
44
|
+
csvTypes = argv.type.map(type => {
|
|
45
|
+
const choice = csvChoices.find(csvChoice => csvChoice.csvType === type)
|
|
46
|
+
return choice.value
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const spinner = new Ora()
|
|
51
|
+
// const hrstart = process.hrtime()
|
|
52
|
+
|
|
53
|
+
const ws = {
|
|
54
|
+
endpoint: argv.endpoint,
|
|
55
|
+
adminSecret: argv['admin-secret']
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (interactive) {
|
|
59
|
+
console.log('')
|
|
60
|
+
const { confirmed } = await prompts(
|
|
61
|
+
[
|
|
62
|
+
{
|
|
63
|
+
type: 'confirm',
|
|
64
|
+
name: 'confirmed',
|
|
65
|
+
message: 'Continue?',
|
|
66
|
+
initial: false
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
{ onCancel: () => process.exit() }
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
if (!confirmed) {
|
|
73
|
+
process.exit()
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
console.log('')
|
|
78
|
+
|
|
79
|
+
for (const csvType of csvTypes) {
|
|
80
|
+
await exportCsv(csvType, argv.out, spinner, ws, argv.csvDelimiter)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
process.exit()
|
|
84
|
+
}
|
package/helpers.js
CHANGED
|
@@ -725,7 +725,7 @@ exports.flushMedia = (spinner, ws) =>
|
|
|
725
725
|
|
|
726
726
|
exports.getArchiveFolder = instanceEndpoint => {
|
|
727
727
|
const prefix = 'closer'
|
|
728
|
-
const instance = slugify(instanceEndpoint.split('/')[0], { lower: true })
|
|
728
|
+
const instance = slugify(instanceEndpoint.split('/')[0].split('.').join('-'), { lower: true })
|
|
729
729
|
const ts = getTimestampForFilename()
|
|
730
730
|
return `${prefix}_${instance}/${ts}`
|
|
731
731
|
}
|