closer-cli 0.4.0 → 0.5.0
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/cmds/importData.js
CHANGED
|
@@ -24,8 +24,7 @@ exports.builder = yargs => {
|
|
|
24
24
|
.option('out', {
|
|
25
25
|
alias: 'o',
|
|
26
26
|
describe: 'Directory path that will contain errored CSV files',
|
|
27
|
-
type: 'string'
|
|
28
|
-
default: '.out'
|
|
27
|
+
type: 'string'
|
|
29
28
|
})
|
|
30
29
|
.option('skipTasksBeforeImport', {
|
|
31
30
|
describe: 'Skip tasks before start import process',
|
|
@@ -6,6 +6,7 @@ const path = require('path')
|
|
|
6
6
|
const chalk = require('chalk')
|
|
7
7
|
const prompts = require('prompts')
|
|
8
8
|
const Ora = require('ora')
|
|
9
|
+
|
|
9
10
|
const {
|
|
10
11
|
getCsvFilesFromDir,
|
|
11
12
|
ALLOWED_CSV_FILES,
|
|
@@ -17,7 +18,8 @@ const {
|
|
|
17
18
|
download,
|
|
18
19
|
callBeforeDataImportProcess,
|
|
19
20
|
callAfterDataImportProcess,
|
|
20
|
-
getExecutionTime
|
|
21
|
+
getExecutionTime,
|
|
22
|
+
getArchiveFolder
|
|
21
23
|
} = require('../../helpers')
|
|
22
24
|
|
|
23
25
|
exports.command = 'multiple [options]'
|
|
@@ -52,6 +54,9 @@ exports.builder = yargs => {
|
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
exports.handler = async argv => {
|
|
57
|
+
// eslint-disable-next-line no-param-reassign
|
|
58
|
+
argv.out = argv.out || getArchiveFolder(argv.endpoint)
|
|
59
|
+
|
|
55
60
|
const hrstart = process.hrtime()
|
|
56
61
|
const report = {
|
|
57
62
|
start: new Date(),
|
|
@@ -13,7 +13,8 @@ const {
|
|
|
13
13
|
callBeforeDataImportProcess,
|
|
14
14
|
ALLOWED_CSV_FILES,
|
|
15
15
|
download,
|
|
16
|
-
validateCsvFromFile
|
|
16
|
+
validateCsvFromFile,
|
|
17
|
+
getArchiveFolder
|
|
17
18
|
} = require('../../helpers')
|
|
18
19
|
|
|
19
20
|
exports.command = 'single [options]'
|
|
@@ -48,6 +49,9 @@ exports.builder = yargs => {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
exports.handler = async argv => {
|
|
52
|
+
// eslint-disable-next-line no-param-reassign
|
|
53
|
+
argv.out = argv.out || getArchiveFolder(argv.endpoint)
|
|
54
|
+
|
|
51
55
|
const spinner = new Ora()
|
|
52
56
|
const hrstart = process.hrtime()
|
|
53
57
|
|
package/helpers.js
CHANGED
|
@@ -10,6 +10,7 @@ const parse = require('csv-parse/lib/sync')
|
|
|
10
10
|
const stringify = require('csv-stringify/lib/sync')
|
|
11
11
|
const got = require('got')
|
|
12
12
|
const { createWriteStream } = require('fs')
|
|
13
|
+
const slugify = require('slugify')
|
|
13
14
|
|
|
14
15
|
exports.createSocketConnection = (endpoint, adminSecret) => {
|
|
15
16
|
const protocol = endpoint.includes('localhost') ? 'ws' : 'wss'
|
|
@@ -704,3 +705,13 @@ exports.flushMedia = (spinner, ws) =>
|
|
|
704
705
|
resolve({ error: e.message })
|
|
705
706
|
})
|
|
706
707
|
})
|
|
708
|
+
|
|
709
|
+
exports.getArchiveFolder = instanceEndpoint => {
|
|
710
|
+
const date = new Date()
|
|
711
|
+
const prefix = 'closer'
|
|
712
|
+
const instance = slugify(instanceEndpoint.split('/')[0], { lower: true })
|
|
713
|
+
const [isoDateString, isoTimeString] = date.toISOString().split('T')
|
|
714
|
+
const dateString = isoDateString.split('-').join('')
|
|
715
|
+
const timeString = isoTimeString.split(':').join('').split('.')[0]
|
|
716
|
+
return `${prefix}_${instance}/${dateString}_${timeString}`.split(':').join('')
|
|
717
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "closer-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"ora": "^5.4.1",
|
|
20
20
|
"prompts": "^2.4.2",
|
|
21
21
|
"require-directory": "^2.1.1",
|
|
22
|
+
"slugify": "^1.6.3",
|
|
22
23
|
"ws": "^8.0.0",
|
|
23
24
|
"yargs": "^17.0.1"
|
|
24
25
|
}
|