closer-cli 2.8.0 → 2.16.3

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 CHANGED
@@ -3,6 +3,28 @@
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.11.0](https://code.hfarm.dev/closer/closer/compare/v2.10.0...v2.11.0) (2022-05-18)
7
+
8
+
9
+ ### Features
10
+
11
+ * **#PJX-445:** Multilingua ([f24f066](https://code.hfarm.dev/closer/closer/commits/f24f0668b7c0c8338c8d91db68afc871efb534ed)), closes [#PJX-445](https://code.hfarm.dev/closer/closer/issues/PJX-445)
12
+
13
+
14
+
15
+
16
+
17
+ # [2.9.0](https://code.hfarm.dev/closer/closer/compare/v2.8.0...v2.9.0) (2022-05-09)
18
+
19
+
20
+ ### Features
21
+
22
+ * **#PJX-442:** Import ad hoc disponibilità incrementale non bloccante ([aad991b](https://code.hfarm.dev/closer/closer/commits/aad991ba97e76977c6a6a2d73ef614026324b0d3)), closes [#PJX-442](https://code.hfarm.dev/closer/closer/issues/PJX-442)
23
+
24
+
25
+
26
+
27
+
6
28
  # [2.8.0](https://code.hfarm.dev/closer/closer/compare/v2.7.1...v2.8.0) (2022-04-27)
7
29
 
8
30
 
package/helpers.js CHANGED
@@ -23,6 +23,9 @@ exports.createSocketConnection = (endpoint, adminSecret) => {
23
23
 
24
24
  exports.ALLOWED_CSV_FILES = {
25
25
  product: 'products.csv',
26
+ localizedProduct: 'localizedProducts.csv',
27
+ localizedFilter: 'localizedFilters.csv',
28
+ localizedVariant: 'localizedVariants.csv',
26
29
  price: 'prices.csv',
27
30
  group: 'groups.csv',
28
31
  lookup: 'lookups.csv',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "closer-cli",
3
- "version": "2.8.0",
3
+ "version": "2.16.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,215 +0,0 @@
1
- /* eslint-disable no-await-in-loop */
2
- /* eslint-disable no-restricted-syntax */
3
- /* eslint-disable no-console */
4
- const fs = require('fs')
5
- const chalk = require('chalk')
6
- const path = require('path')
7
-
8
- const Ora = require('ora')
9
- const prompts = require('prompts')
10
- const {
11
- importCsvFromFile,
12
- getExecutionTime,
13
- callAfterDataImportProcess,
14
- ALLOWED_CSV_FILES,
15
- download,
16
- validateCsvFromFile,
17
- getArchiveFolder,
18
- getGoogleSheetCsvUrl
19
- } = require('../helpers')
20
-
21
- exports.command = 'import:stock'
22
-
23
- exports.desc = 'Import Stock Availability from CSV file'
24
-
25
- exports.builder = yargs => {
26
- yargs
27
- .usage(`Usage: ${chalk.cyan('$0 import:stock')} [options]`)
28
- .option('fromFile', {
29
- alias: 'f',
30
- describe: 'File to import',
31
- type: 'string'
32
- })
33
- .option('fromUrl', {
34
- alias: 'u',
35
- describe: 'Remote URL file to import',
36
- type: 'string'
37
- })
38
- .option('fromDir', {
39
- alias: 'd',
40
- describe: 'Directory path that contains file to import',
41
- type: 'string'
42
- })
43
- .option('fromGoogleDocId', {
44
- alias: 'g',
45
- describe: 'Google Doc ID that contains sheet to import',
46
- type: 'string'
47
- })
48
- // .conflicts('fromFile', 'fromUrl', 'fromDir', 'fromGoogleDocId')
49
- .check(argv => {
50
- if (!argv.fromFile && !argv.fromUrl && !argv.fromDir && !argv.fromGoogleDocId) {
51
- throw new Error(
52
- 'Missing required argument: fromFile OR fromUrl OR fromDir OR fromGoogleDocId'
53
- )
54
- }
55
-
56
- if (argv.fromFile) {
57
- fs.accessSync(argv.fromFile, fs.constants.F_OK)
58
- }
59
-
60
- if (argv.fromDir) {
61
- fs.accessSync(argv.fromDir, fs.constants.F_OK)
62
- }
63
-
64
- return true
65
- })
66
- }
67
-
68
- exports.handler = async argv => {
69
- // eslint-disable-next-line no-param-reassign
70
- argv.out = argv.out || getArchiveFolder(argv.endpoint)
71
-
72
- const spinner = new Ora()
73
- const hrstart = process.hrtime()
74
-
75
- const report = {
76
- start: new Date(),
77
- end: null,
78
- time: null,
79
- endpoint: argv.endpoint,
80
- mode: null,
81
- type: [],
82
- result: []
83
- }
84
-
85
- const ws = {
86
- endpoint: argv.endpoint,
87
- adminSecret: argv['admin-secret']
88
- }
89
-
90
- const interactive = !argv.nonInteractive
91
-
92
- const csvType = 'stockAvailability'
93
-
94
- let file
95
- if (argv.fromDir) {
96
- file = {
97
- file: path.resolve(argv.fromDir, ALLOWED_CSV_FILES.stockAvailability),
98
- csvType
99
- }
100
- } else if (argv.fromGoogleDocId) {
101
- file = {
102
- url: getGoogleSheetCsvUrl(argv.fromGoogleDocId, csvType),
103
- csvType
104
- }
105
- } else if (argv.fromFile) {
106
- file = {
107
- file: argv.fromFile,
108
- csvType
109
- }
110
- } else if (argv.fromUrl) {
111
- file = {
112
- url: argv.fromUrl,
113
- csvType
114
- }
115
- }
116
-
117
- let mode
118
- if (interactive && !argv.mode) {
119
- const answers = await prompts(
120
- [
121
- {
122
- type: 'select',
123
- name: 'mode',
124
- message: 'Import Mode',
125
- choices: [
126
- {
127
- title: 'Incremental',
128
- value: 'incremental'
129
- },
130
- {
131
- title: 'Full',
132
- description: 'Before starting, all database records will be logically deleted',
133
- value: 'full'
134
- }
135
- ],
136
- hint: ' '
137
- }
138
- ],
139
- { onCancel: () => process.exit() }
140
- )
141
-
142
- mode = answers.mode
143
- } else {
144
- mode = argv.mode
145
- }
146
-
147
- if (interactive) {
148
- console.log('')
149
- const { confirmed } = await prompts(
150
- [
151
- {
152
- type: 'confirm',
153
- name: 'confirmed',
154
- message: 'Continue?',
155
- initial: false
156
- }
157
- ],
158
- { onCancel: () => process.exit() }
159
- )
160
-
161
- if (!confirmed) {
162
- process.exit()
163
- }
164
-
165
- console.log('')
166
- }
167
-
168
- let filepath = argv.fromFile
169
-
170
- if (argv.fromDir) {
171
- filepath = file.file
172
- } else if (argv.fromUrl || argv.fromGoogleDocId) {
173
- spinner.start('Downloading file...')
174
- filepath = await download(file.url, argv.out, `${csvType}.csv`)
175
- spinner.succeed('Downloaded file')
176
- }
177
-
178
- const validation = await validateCsvFromFile(filepath, csvType, ws, argv.csvDelimiter)
179
-
180
- if (validation.error) {
181
- console.log(`ERROR => [${chalk.red(validation.inputFile)}] ${validation.error}`)
182
- process.exit()
183
- }
184
-
185
- const csvReport = await importCsvFromFile(
186
- filepath,
187
- csvType,
188
- argv.out,
189
- spinner,
190
- ws,
191
- argv.csvDelimiter
192
- )
193
-
194
- //
195
- // Report
196
- //
197
-
198
- report.end = new Date()
199
- report.time = getExecutionTime(hrstart)
200
- report.mode = mode
201
- report.type = [csvType]
202
-
203
- const reportRows = []
204
-
205
- reportRows.push({
206
- type: 'import.csv',
207
- payload: csvReport
208
- })
209
-
210
- report.result = reportRows
211
-
212
- await callAfterDataImportProcess(spinner, ws, report)
213
-
214
- process.exit()
215
- }