@cloudcommerce/cli 2.44.3 → 2.44.5
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/lib/ext/import-feed.js +10 -4
- package/package.json +2 -2
package/lib/ext/import-feed.js
CHANGED
|
@@ -133,14 +133,14 @@ const importFeed = async () => {
|
|
|
133
133
|
const fileExtension = extname(feedFilepath).toLowerCase();
|
|
134
134
|
await echo`Importing ${fileExtension} file at ${feedFilepath}`;
|
|
135
135
|
await echo`Store ${ECOM_STORE_ID} with ${ECOM_AUTHENTICATION_ID}`;
|
|
136
|
-
let
|
|
136
|
+
let _items = [];
|
|
137
137
|
if (fileExtension === '.xml') {
|
|
138
138
|
const parser = new XMLParser({
|
|
139
139
|
ignoreAttributes: false,
|
|
140
140
|
attributeNamePrefix: '',
|
|
141
141
|
});
|
|
142
142
|
const json = parser.parse(fs.readFileSync(argv.feed, 'utf8'));
|
|
143
|
-
|
|
143
|
+
_items = json.rss?.channel?.item?.filter?.((item) => {
|
|
144
144
|
return item?.['g:id'] && item['g:title'];
|
|
145
145
|
});
|
|
146
146
|
} else if (fileExtension === '.tsv') {
|
|
@@ -150,14 +150,20 @@ const importFeed = async () => {
|
|
|
150
150
|
skip_empty_lines: true,
|
|
151
151
|
delimiter: '\t',
|
|
152
152
|
});
|
|
153
|
-
|
|
153
|
+
_items = csvRecords
|
|
154
154
|
.filter((record) => record.sku && record.nome)
|
|
155
155
|
.map(mapCSVToFeed);
|
|
156
156
|
}
|
|
157
|
-
if (!
|
|
157
|
+
if (!_items?.[0] || typeof _items?.[0] !== 'object') {
|
|
158
158
|
await echo`The XML file does not appear to be a valid RSS 2.0 product feed`;
|
|
159
159
|
return process.exit(1);
|
|
160
160
|
}
|
|
161
|
+
const seenIds = new Map();
|
|
162
|
+
const items = _items.filter((item) => {
|
|
163
|
+
if (seenIds.has(item['g:id'])) return false;
|
|
164
|
+
seenIds.set(item['g:id'], true);
|
|
165
|
+
return true;
|
|
166
|
+
});
|
|
161
167
|
const ecomAuthHeaders = {
|
|
162
168
|
'X-Store-ID': ECOM_STORE_ID,
|
|
163
169
|
'X-My-ID': ECOM_AUTHENTICATION_ID,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.44.
|
|
4
|
+
"version": "2.44.5",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce CLI tools",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cloudcommerce": "./bin/run.mjs"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"md5": "^2.3.0",
|
|
40
40
|
"typescript": "~5.8.3",
|
|
41
41
|
"zx": "^8.5.5",
|
|
42
|
-
"@cloudcommerce/api": "2.44.
|
|
42
|
+
"@cloudcommerce/api": "2.44.5"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "bash ../../scripts/build-lib.sh"
|